:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e2ded6;
  --border-strong: #c9c3b8;
  --text: #1f1d1a;
  --muted: #6f6a61;
  --accent-main: #7a2e2e;
  --accent-soft: #f3e7e5;
  --item: #c2410c;
  --know: #047857;
  --danger: #dc2626;
  --warning: #b45309;
  --info: #2563eb;
  --ok: #15803d;
  --edge-step: #8a8378;
  --edge-start: #a8a29e;
  --node-bg: #ffffff;
  --grid: #e8e4dc;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #1b1a18;
    --border: #35322d;
    --border-strong: #4a463f;
    --text: #ece8e1;
    --muted: #a39d92;
    --accent-main: #e0928a;
    --accent-soft: #3a2624;
    --item: #fb923c;
    --know: #34d399;
    --edge-step: #8f887d;
    --edge-start: #6f6a61;
    --node-bg: #262420;
    --grid: #26241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #1b1a18;
    --border: #35322d;
    --border-strong: #4a463f;
    --text: #ece8e1;
    --muted: #a39d92;
    --accent-main: #e0928a;
    --accent-soft: #3a2624;
    --item: #fb923c;
    --know: #34d399;
    --edge-step: #8f887d;
    --edge-start: #6f6a61;
    --node-bg: #262420;
    --grid: #26241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }


* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
}
button:hover { background: var(--surface-2); border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent-main); border-color: var(--accent-main); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--danger); }
button.link {
  background: none; border: none; padding: 0; color: var(--accent-main);
  text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: transparent;
}
button.link:hover { text-decoration-color: currentColor; }
button.link.strong { font-weight: 600; color: var(--text); }
input[type=text], input[type=search], textarea, select {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 8px;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent-main); outline-offset: 1px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }

/* ---------- Structure ---------- */
#app {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 370px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: .02em; color: var(--accent-main); font-size: 17px; margin-right: 6px; }
.scenario-title { border: none; font-weight: 650; font-size: 16px; padding: 4px 8px; background: none; }
.scenario-title:hover { background: var(--surface-2); }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-main); }
#library { width: auto; max-width: 220px; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 0 16px 24px;
}

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.tabs button {
  border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  padding: 7px 12px; color: var(--muted); font-weight: 550;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent-main); }
.tabs.small { padding: 8px 6px 0; }
.tabs.small button { padding: 6px 2px; font-size: 13px; flex: 1; white-space: nowrap; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px; color: #fff; text-align: center; }
.badge:empty { display: none; }
.badge.error { background: var(--danger); }
.badge.warning { background: var(--warning); }

/* ---------- Liste latérale ---------- */
.list-tools { display: flex; gap: 6px; padding: 10px; }
.list-tools input { flex: 1; min-width: 0; }
.list-tools button { white-space: nowrap; }
.entity-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow-y: auto; flex: 1; }
.entity-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
}
.entity-list li:hover { background: var(--surface-2); }
.entity-list li.selected { background: var(--accent-soft); }
.entity-list li.empty { color: var(--muted); cursor: default; font-size: 13px; }
.li-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--accent); flex: none; }
.li-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.li-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-flag { width: 17px; height: 17px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.li-flag.error { background: var(--danger); }
.li-flag.warning { background: var(--warning); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg i { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); display: inline-block; }
.lg-item { color: var(--item); }
.lg-know { color: var(--know); }

/* ---------- Vues ---------- */
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }
.view-scroll { overflow: auto; padding: 18px 22px 40px; flex: 1; }
.view-scroll h2 { font-size: 16px; margin: 26px 0 10px; }
.view-scroll h2:first-child { margin-top: 0; }

.graph-toolbar, .print-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 5px 11px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.active { background: var(--accent-soft); color: var(--accent-main); font-weight: 600; }
#sim-toggle.on { background: var(--text); border-color: var(--text); color: var(--surface); }

.graph-wrap { position: relative; flex: 1; min-height: 0; }
.graph-svg {
  width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--grid) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.graph-svg:active { cursor: grabbing; }
.graph-hint { position: absolute; left: 12px; bottom: 10px; font-size: 11.5px; color: var(--muted); pointer-events: none; background: var(--surface); padding: 3px 8px; border-radius: 5px; opacity: .85; }

/* Nœuds du graphe */
.node { cursor: pointer; }
.node .box { fill: var(--node-bg); stroke: var(--border-strong); stroke-width: 1.2; filter: drop-shadow(0 1px 2px rgba(0,0,0,.08)); }
.node:hover .box { stroke: var(--muted); }
.node.selected .box { stroke: var(--accent-main); stroke-width: 2.5; }
.node.has-error .box { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 5 3; }
.node .n-title { font-size: 13px; font-weight: 600; fill: var(--text); }
.node .n-sub { font-size: 11px; fill: var(--muted); }
.node .n-res { font-size: 12px; fill: var(--text); }
.node .n-initials { font-size: 8.5px; font-weight: 700; fill: #fff; pointer-events: none; }
.node .n-flag { font-size: 9.5px; fill: var(--muted); font-style: italic; }
.node .start-dot { stroke: var(--node-bg); stroke-width: 2; }
.node-item .box { stroke: var(--item); }
.node-item .n-res { fill: var(--item); font-weight: 550; }
.node-know .box { stroke: var(--know); }
.node-know .n-res { fill: var(--know); font-weight: 550; }
.node-char .box { stroke-width: 2; }
.node.dim, .edge.dim, .edge-label.dim { opacity: .18; }
.edge { fill: none; stroke-width: 1.6; }
.edge-start { stroke-dasharray: 4 3; }
.edge-back { stroke-dasharray: 6 4; stroke-width: 2; }
.edge-label {
  font-size: 11px; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round;
  pointer-events: none;
}
.label-item { fill: var(--item); }
.label-know { fill: var(--know); }
.label-step { fill: var(--muted); }

/* États de simulation */
.node.sim-done .box { fill: color-mix(in srgb, var(--ok) 16%, var(--node-bg)); stroke: var(--ok); }
.node.sim-available .box { stroke: var(--accent-main); stroke-width: 2.5; animation: pulse 1.6s ease-in-out infinite; }
.node.sim-locked { opacity: .45; }
.node.sim-owned .box { fill: color-mix(in srgb, currentColor 0%, var(--node-bg)); stroke-width: 2.5; }
.node.sim-missing { opacity: .4; }
@keyframes pulse { 50% { stroke-opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .node.sim-available .box { animation: none; } }

/* ---------- Panneau d'édition ---------- */
.panel-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 14px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.panel-head h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.25; word-break: break-word; }
.kind-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent, var(--accent-main)); }
.form-section { padding: 6px 0 4px; }
.form-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; border-top: 1px dashed var(--border); padding-top: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 9px 0; }
.field.check { white-space: normal; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; cursor: pointer; }
.field.check .hint { flex-basis: 100%; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); }
input[type=color] { width: 60px; height: 30px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.row3, .row2 { display: grid; gap: 8px; }
.row3 { grid-template-columns: 1fr 1.3fr .8fr; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 .field, .row2 .field { margin: 0; }
.refs { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px;
  border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
}
.sim-inv .chip { padding-right: 9px; }
.chip-items { border-color: color-mix(in srgb, var(--item) 50%, transparent); color: var(--item); }
.chip-knowledge { border-color: color-mix(in srgb, var(--know) 50%, transparent); color: var(--know); }
.chip-characters { border-color: var(--chip); }
.chip-characters .chip-link::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--chip); margin-right: 5px; }
.chip-link { border: none; background: none; padding: 0; color: inherit; font-size: inherit; }
.chip-link:hover { background: none; text-decoration: underline; }
.chip-x { border: none; background: none; padding: 0 5px; line-height: 1; color: var(--muted); font-size: 15px; }
.chip-x:hover { background: none; color: var(--danger); }
.ref-add { font-size: 12.5px; padding: 3px 6px; color: var(--muted); }
.linklist { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 8px 0; }
.linklist .field-label { flex-basis: 100%; }
.panel-actions { display: flex; gap: 8px; margin: 18px 0 6px; flex-wrap: wrap; }
.relations-edit { display: flex; flex-direction: column; gap: 6px; }
.relation-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 5px; }
button.icon { padding: 2px 9px; }
.issues-inline { margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.stats.wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px; display: flex; flex-direction: column; }
.stat strong { font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.error strong { color: var(--danger); }
.stat.warning strong { color: var(--warning); }
.stat.info strong { color: var(--info); }

/* ---------- Analyse ---------- */
.issue { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 7px 10px; border-radius: 6px; border-left: 3px solid; background: var(--surface); font-size: 13px; }
.issue-error { border-color: var(--danger); }
.issue-warning { border-color: var(--warning); }
.issue-info { border-color: var(--info); }
.issue-level { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.issue-error .issue-level { color: var(--danger); }
.issue-warning .issue-level { color: var(--warning); }
.issue-info .issue-level { color: var(--info); }
.issue-list { display: flex; flex-direction: column; gap: 5px; }
.ok-msg { color: var(--ok); font-weight: 600; }
.waves { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.wave { min-width: 170px; max-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.wave-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.wave-step { text-align: left; border-left: 4px solid var(--accent); font-size: 13px; background: var(--surface); }
.wave-step.coop { border-style: dashed; border-left-style: solid; }
.bars { display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.bar-row { display: grid; grid-template-columns: 200px 1fr 30px; gap: 10px; align-items: center; }
.bar-track { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; background: var(--accent-main); border-radius: 6px; }
.bar-val { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Ressources ---------- */
table.grid { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: 13px; }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.grid th { font-size: 12px; color: var(--muted); background: var(--surface-2); }
table.grid td .link + .link::before { content: ", "; color: var(--muted); }
table.grid tr.selected td { background: var(--accent-soft); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin: 0; }
.tag-ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag-error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.tag-warning { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.tag-info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.cards-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.mini-card { background: var(--surface); border-radius: var(--radius); border-top: 4px solid var(--accent); padding: 10px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.res-item { color: var(--item); }
.res-know { color: var(--know); }

/* ---------- Relations ---------- */
.relations-svg { width: 100%; max-width: 1000px; height: auto; display: block; margin: 0 auto; }
.rel-edge { fill: none; stroke-width: 2; opacity: .8; }
.rel-arrow { fill: var(--muted); }
.rel-label { font-size: 12px; fill: var(--text); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.rel-node { cursor: pointer; }
.rel-node circle { stroke: var(--bg); stroke-width: 3; }
.rel-node.selected circle { stroke: var(--text); }
.rel-node.npc circle { opacity: .55; }
.rel-initials { fill: #fff; font-weight: 700; font-size: 16px; pointer-events: none; }
.rel-name { font-weight: 650; font-size: 13px; fill: var(--text); }
.rel-role { font-size: 11.5px; fill: var(--muted); }
.rel-empty { fill: var(--muted); }
.dim { opacity: .15; }

/* ---------- Simulation ---------- */
.sim-progress { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 6px 0; }
.sim-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.sim-selected { background: var(--accent-soft); border-radius: var(--radius); padding: 8px 12px; margin-top: 10px; }
.sim-selected h3 { margin: 0 0 6px; font-size: 14px; }
.sim-step { display: flex; flex-direction: column; gap: 4px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.actor-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
button.actor { font-size: 12px; padding: 2px 9px; border-color: var(--accent); border-left-width: 4px; }
.sim-inv { border-left: 4px solid var(--accent); padding: 6px 10px; margin-bottom: 8px; background: var(--surface-2); border-radius: 0 6px 6px 0; display: flex; flex-direction: column; gap: 6px; }
.exchange { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 4px; }
.exchange select { font-size: 12px; padding: 3px 4px; }
.exchange button { font-size: 12px; padding: 2px 8px; }
.sim-log { font-size: 12.5px; padding-left: 20px; color: var(--muted); margin: 0; }

/* ---------- Aperçu d'impression ---------- */
.print-preview { background: var(--bg); }
#print-area { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.page {
  width: 210mm; min-height: 297mm; padding: 16mm 16mm;
  background: #fff; color: #1c1917; box-shadow: var(--shadow);
  font-family: Georgia, "Times New Roman", serif; font-size: 11.5pt; line-height: 1.5;
}
.page h1 { font-size: 24pt; margin: 2mm 0; line-height: 1.15; }
.page h4 { font-family: system-ui, sans-serif; font-size: 9pt; text-transform: uppercase; letter-spacing: .08em; color: #7a2e2e; margin: 6mm 0 2mm; }
.page p { margin: 0 0 2mm; }
.page ul, .page ol { margin: 0; padding-left: 6mm; }
.sheet-kicker { font-family: system-ui, sans-serif; font-size: 9pt; color: #78716c; text-transform: uppercase; letter-spacing: .08em; }
.sheet-head { border-bottom: 3px solid var(--accent, #7a2e2e); padding-bottom: 4mm; margin-bottom: 4mm; }
.sheet-role { font-style: italic; color: #57534e; font-size: 13pt; }
.sheet-block.synopsis { font-style: italic; color: #44403c; }
.sheet-block.secret { background: #f5efe6; border-left: 3px solid #7a2e2e; padding: 1mm 4mm 3mm; }
.page.cards { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 85mm; gap: 0; padding: 10mm; align-content: start; }
.card { border: 1px dashed #a8a29e; padding: 5mm; display: flex; flex-direction: column; gap: 2mm; position: relative; }
.card-kind { font-family: system-ui, sans-serif; font-size: 8pt; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.card-item .card-kind { color: #c2410c; }
.card-know .card-kind { color: #047857; }
.card-name { font-size: 14pt; font-weight: bold; line-height: 1.2; }
.card-desc { font-size: 10.5pt; color: #292524; }
.card-code { position: absolute; right: 4mm; bottom: 3mm; font-family: system-ui, sans-serif; font-size: 8pt; color: #a8a29e; }
.page.puzzle h1 { margin-bottom: 8mm; }
.page.puzzle p { font-size: 14pt; }
.meta { font-family: system-ui, sans-serif; color: #57534e; }
.print-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
.print-table th, .print-table td { border: 1px solid #d6d3d1; padding: 1.5mm 2.5mm; text-align: left; vertical-align: top; }
.print-table th { background: #f5f5f4; font-family: system-ui, sans-serif; font-size: 8.5pt; }
.guide-step { border-top: 1px solid #d6d3d1; padding: 3mm 0; font-size: 10pt; break-inside: avoid; }
.guide-step-head { display: flex; justify-content: space-between; gap: 4mm; font-size: 11pt; }
.guide-step-head span { font-family: system-ui, sans-serif; font-size: 8.5pt; color: #78716c; }
.guide-step .lbl { font-family: system-ui, sans-serif; font-size: 8.5pt; color: #7a2e2e; font-weight: 600; }
.guide-step .hints { font-style: italic; color: #57534e; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  #app { display: block; height: auto; }
  .topbar, .sidebar, .panel, .tabs, .print-toolbar, .view:not([data-view="print"]) { display: none !important; }
  .view[data-view="print"] { display: block !important; }
  .view-scroll { overflow: visible; padding: 0; }
  #print-area { display: block; }
  .page { box-shadow: none; margin: 0; break-after: page; min-height: 0; }
  .page:last-child { break-after: auto; }
}

body.dropping::after {
  content: "Déposez le fichier .json pour l'importer";
  position: fixed; inset: 12px; z-index: 50; display: grid; place-items: center;
  border: 3px dashed var(--accent-main); border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 20px; font-weight: 700; color: var(--accent-main); pointer-events: none;
}

/* ---------- Boîtes de dialogue ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 16, 14, .45);
}
.modal {
  width: min(460px, 100%); max-height: 85vh; overflow: auto;
  background: var(--surface); color: var(--text); border-radius: 10px; padding: 18px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 10px;
}
.modal h2 { margin: 0; font-size: 17px; text-wrap: balance; }
.modal p { margin: 0; color: var(--muted); }
.modal ul { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
label.btn {
  display: inline-block; cursor: pointer; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 12px; background: var(--surface); font-weight: 550;
}
label.btn.primary { background: var(--accent-main); border-color: var(--accent-main); color: #fff; }
label.btn:hover { filter: brightness(1.08); }
label.btn:focus-visible { outline: 2px solid var(--accent-main); outline-offset: 2px; }
.modal-actions.start { justify-content: flex-start; }
.modal textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0; }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- Petits écrans ---------- */
@media (max-width: 1100px) {
  #app { grid-template-columns: 230px minmax(0, 1fr) 320px; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 800px) {
  #app { display: flex; flex-direction: column; height: auto; }
  .sidebar { max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .main { height: 75vh; }
  .panel { border-left: none; border-top: 1px solid var(--border); }
  .topbar { padding: 8px 16px; }
  .page { width: 100%; min-height: 0; }
}
