/* Layout: sticky instrument header with a two-step phase switch.
   Phase 1 = side index + parameter sheets. Phase 2 = KPI strip over a
   three-column bench (ideas | projects | readouts). */
:root {
  --bg: #eceff4;
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --ink: #131a26;
  --ink-2: #465265;
  --muted: #727d90;
  --line: #d5dbe4;
  --line-strong: #b4bfce;
  --accent: #2350b5;
  --accent-soft: #e2e9fa;
  --accent-ink: #ffffff;
  --launch: #cf5520;
  --launch-ink: #ffffff;
  --good: #11753a;
  --good-soft: #def2e5;
  --warn: #9a6200;
  --warn-soft: #f8edd3;
  --bad: #be2f2d;
  --bad-soft: #fae2e1;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #6250d6;
  --s8: #e34948;
  --font-display: 'IBM Plex Sans Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 6px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1118;
    --panel: #151b25;
    --panel-2: #1a2130;
    --ink: #e5eaf2;
    --ink-2: #a6b0c0;
    --muted: #7c8698;
    --line: #262f40;
    --line-strong: #364259;
    --accent: #7d9df3;
    --accent-soft: #1c2848;
    --accent-ink: #0d1118;
    --launch: #f07a43;
    --launch-ink: #0d1118;
    --good: #45c172;
    --good-soft: #12301e;
    --warn: #e2a83c;
    --warn-soft: #33270e;
    --bad: #f26c69;
    --bad-soft: #3b1818;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1118;
  --panel: #151b25;
  --panel-2: #1a2130;
  --ink: #e5eaf2;
  --ink-2: #a6b0c0;
  --muted: #7c8698;
  --line: #262f40;
  --line-strong: #364259;
  --accent: #7d9df3;
  --accent-soft: #1c2848;
  --accent-ink: #0d1118;
  --launch: #f07a43;
  --launch-ink: #0d1118;
  --good: #45c172;
  --good-soft: #12301e;
  --warn: #e2a83c;
  --warn-soft: #33270e;
  --bad: #f26c69;
  --bad-soft: #3b1818;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --s7: #9085e9;
  --s8: #e66767;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--panel);
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
code, kbd, output, input[type="number"], textarea { font-family: var(--font-mono); }
code { font-size: 0.85em; color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line); padding: 0 4px; border-radius: 3px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- buttons, pills, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 10px 18px; font-size: 15px; font-weight: 600; }
.btn.launch { background: var(--launch); border-color: var(--launch); color: var(--launch-ink); font-weight: 600; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--panel); }
.btn kbd { font-size: 11px; padding: 0 5px; border-radius: 3px; border: 1px solid currentColor; opacity: 0.7; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.neutral { background: var(--panel-2); }

.callout { padding: 10px 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.callout.bad { background: var(--bad-soft); border-color: transparent; color: var(--ink); }
.callout.bad b { color: var(--bad); }

input[type="number"] {
  width: 100%; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--panel); font-size: 13px; font-variant-numeric: tabular-nums;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1600px; margin: 0 auto;
  padding-block: 10px; padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px;
  background: var(--ink); color: var(--panel); font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.brand-tag { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.phases { display: flex; align-items: center; gap: 6px; }
.phase-arrow { color: var(--muted); }
.phase-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.phase-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.phase-num {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--ink-2); font-size: 12px;
}
.phase-tab[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.phase-tab[aria-selected="true"] .phase-num { background: var(--accent); color: var(--accent-ink); }

.page { max-width: 1600px; margin: 0 auto; padding-block: 20px 64px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }

.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: var(--radius);
  background: var(--ink); color: var(--panel); font-weight: 500; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.toast[data-kind="bad"] { background: var(--bad); }
.toast[data-kind="warn"] { background: var(--warn); }

/* ---------- phase 1: config ---------- */
.config-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 28px; align-items: start; }
.config-index { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); display: grid; gap: 10px; }
.config-index nav { display: grid; gap: 2px; border-left: 2px solid var(--line); }
.index-link {
  text-align: left; background: none; border: 0; padding: 5px 12px; margin-left: -2px;
  border-left: 2px solid transparent; color: var(--ink-2); cursor: pointer; font-size: 13px;
}
.index-link:hover { color: var(--accent); border-left-color: var(--accent); }
.config-main { display: grid; gap: 20px; min-width: 0; }

.config-intro {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px 32px; align-items: start;
  padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.config-intro h1 { font-size: 26px; margin-bottom: 8px; }
.config-intro p { color: var(--ink-2); max-width: 62ch; }
.config-status { display: grid; gap: 12px; }
#status-dyn { display: grid; gap: 10px; }
.status-line { display: flex; gap: 8px; flex-wrap: wrap; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
.status-actions .btn.primary { padding: 9px 22px; font-size: 15px; font-weight: 600; }
.seed-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seed-row label { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--ink-2); }
.seed-row input { width: 130px; }
.seed-row .spacer { flex: 1; }
.json-panel { display: grid; gap: 8px; }
.json-panel label { font-weight: 500; font-size: 13px; }
.json-panel textarea { width: 100%; padding: 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--panel-2); font-size: 12px; resize: vertical; }
.json-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; scroll-margin-top: 80px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.sheet-head h2 { font-size: 19px; }
.doc-ref { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.sheet-note { color: var(--ink-2); max-width: 80ch; }

.param-list { display: grid; }
.param {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 6px 24px; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line); position: relative;
}
.param:last-child { border-bottom: 0; }
.param[data-modified="true"]::before {
  content: ""; position: absolute; left: -12px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--launch);
}
.param-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.param-label label { font-weight: 500; }
.param-desc { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.param-control { display: grid; grid-template-columns: minmax(80px, 1fr) 150px 28px; gap: 10px; align-items: center; }
.param-control.is-bool { grid-template-columns: 1fr 28px; }
.param-value { display: flex; align-items: center; gap: 6px; }
.param-value .unit { font-size: 11px; color: var(--muted); white-space: nowrap; max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
.reset {
  width: 28px; height: 28px; border-radius: 4px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; visibility: hidden;
}
.param[data-modified="true"] .reset { visibility: visible; }
.reset:hover { border-color: var(--line-strong); color: var(--accent); }

.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.formula { display: grid; gap: 8px; align-content: start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); min-width: 0; }
.formula[data-modified="true"] { border-color: var(--launch); }
.formula-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; }
.formula-head h3 { font-size: 15px; margin-right: auto; }
.formula textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--panel);
  font-size: 13px; line-height: 1.5; resize: vertical; min-height: 56px;
}
.formula-vars { font-size: 12px; color: var(--ink-2); }
.formula-status { font-size: 12px; font-weight: 500; }
.formula-status.ok { color: var(--good); }
.formula-status.ok::before { content: "✓ "; }
.formula-status.err { color: var(--bad); font-family: var(--font-mono); font-weight: 400; }
.formula-status.err::before { content: "✕ "; font-family: var(--font-body); font-weight: 600; }
.formula-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12px; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.quick-card { display: grid; gap: 6px; align-content: start; min-width: 0; }
.quick-card h3 { font-size: 15px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
thead th { font-family: var(--font-display); font-weight: 600; color: var(--muted); font-size: 12px; }
tbody th, table th:first-child { text-align: left; font-weight: 500; color: var(--ink-2); }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px 14px; }
.bot-field { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.bot-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.progress-track { flex: 1; min-width: 120px; max-width: 320px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.bot-result { display: grid; gap: 12px; }
.bot-headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; justify-items: start; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.1; }
.stackbar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--panel); }
.stackbar .seg { display: block; flex-basis: 0; }
.seg.won, .stack-legend i.won { background: var(--good); }
.seg.stalled, .stack-legend i.stalled { background: var(--warn); }
.seg.lost, .stack-legend i.lost { background: var(--bad); }
.stack-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.stack-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.bot-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 8px 16px; margin: 0; }
.bot-stats div { display: grid; }
.bot-stats dt { font-size: 12px; color: var(--muted); }
.bot-stats dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { position: relative; min-width: 0; }
.chart-plot { position: relative; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-zero { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .series { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .endpoint { stroke: var(--panel); stroke-width: 2; }
.chart .hover-dot { stroke: var(--panel); stroke-width: 2; }
.chart .crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .ref { stroke: var(--launch); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .ref-label { fill: var(--launch); font-size: 11px; font-family: var(--font-mono); }
.chart-empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend-item i, .tip-row i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.chart-tip {
  position: absolute; top: 4px; z-index: 5; pointer-events: none; min-width: 120px;
  padding: 6px 10px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line-strong);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); font-size: 12px;
}
.tip-head { font-weight: 600; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.tip-row span { color: var(--ink-2); margin-right: auto; padding-right: 10px; }
.tip-row b { font-variant-numeric: tabular-nums; }

/* ---------- phase 2: play ---------- */
#phase-play { display: grid; gap: 16px; }
.dash { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tile { display: grid; gap: 2px; padding: 12px 14px; border-right: 1px solid var(--line); min-width: 0; }
.tile:last-child { border-right: 0; }
.tile-label { font-family: var(--font-display); font-weight: 600; font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.tile-value { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-sub { font-size: 11px; color: var(--muted); line-height: 1.35; }
.tile.tone-good .tile-value { color: var(--good); }
.tile.tone-warn .tile-value { color: var(--warn); }
.tile.tone-bad .tile-value { color: var(--bad); }
.tile .pill { font-size: 10px; padding: 0 6px; margin-left: 4px; }

.play-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.play-controls .reveal { margin-left: auto; font-size: 13px; color: var(--ink-2); }

.bench { display: grid; grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr) minmax(300px, 1.1fr); gap: 16px; align-items: start; }
.col { display: grid; gap: 12px; min-width: 0; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.col-head h2 { font-size: 17px; }

.idea-list { display: grid; gap: 8px; }
.idea { display: grid; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.idea header, .project header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.idea h3 { font-size: 15px; }
.cat { font-size: 12px; color: var(--muted); }
.idea .btn { justify-self: start; }
.riskbar { display: inline-block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin-right: 6px; vertical-align: 1px; overflow: hidden; }
.riskbar i { display: block; height: 100%; background: var(--warn); }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.facts.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.facts div { display: grid; min-width: 0; }
.facts dt { font-size: 11px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd .muted { font-weight: 400; font-size: 11px; }
.facts dd.up { color: var(--good); }
.facts dd.down { color: var(--bad); }
.hidden-vals { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 8px; border-radius: 4px; background: var(--warn-soft); font-size: 12px; color: var(--ink-2); }
.hidden-vals b { color: var(--ink); font-variant-numeric: tabular-nums; }

.project-list { display: grid; gap: 12px; }
.project {
  display: grid; gap: 12px; padding: 14px 16px; background: var(--panel);
  border: 1px solid var(--line); border-top: 3px solid var(--proj); border-radius: var(--radius);
}
.project h3 { font-size: 17px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--proj); flex: none; }
.project .pill.status { margin-left: auto; }
.status-launched .pill.status { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-takeoff .pill.status { background: var(--good-soft); color: var(--good); border-color: transparent; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.meter-head b { font-variant-numeric: tabular-nums; color: var(--ink); }
.meter-track { position: relative; height: 8px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); }
.meter-track > span { display: block; height: 100%; border-radius: 3px; background: var(--proj); }
.meter.hype .meter-track > span { background: var(--accent); opacity: 0.8; }
.meter-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--launch); }
.steppers { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper-label { font-size: 13px; color: var(--ink-2); min-width: 70px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--panel-2);
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.stepper button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper output { min-width: 26px; text-align: center; font-weight: 600; font-size: 15px; }
.spark { border-top: 1px solid var(--line); padding-top: 6px; }
.project-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-actions .btn.launch { margin-right: auto; }
.confirm { font-size: 13px; color: var(--bad); font-weight: 500; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.events { margin: 0; padding: 8px 12px 8px 28px; background: var(--accent-soft); border-radius: var(--radius); font-size: 13px; }
.events.pending { background: var(--panel); border: 1px solid var(--line); }

.closed { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.closed summary { cursor: pointer; font-weight: 500; color: var(--ink-2); }
.closed ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.closed li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.closed li .swatch { background: var(--proj, var(--muted)); }

.readout { display: grid; gap: 6px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.readout h3 { font-size: 14px; }
.trace { border-top: 1px solid var(--line); padding: 6px 0; }
.trace summary { cursor: pointer; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.trace summary span { color: var(--muted); }
.trace[open] { display: grid; gap: 8px; }
.trace table { font-size: 12px; }
.trace td { text-align: right; }
.trace td.muted { text-align: left; white-space: normal; min-width: 120px; }
.trace .company th { width: 55%; }
.trace-proj h4 { font-size: 13px; margin: 4px 0; }
.trace-proj { overflow-x: auto; }

.overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgb(10 14 22 / 0.55);
  padding: calc(16px + env(safe-area-inset-top, 0px)) var(--gutter-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
}
.overlay-card {
  width: min(520px, 100%); display: grid; gap: 14px; padding: 24px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--good); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
.overlay-card.lost { border-top-color: var(--bad); }
.overlay-card h2 { font-size: 28px; }
.overlay-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .bench { grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.6fr); }
  .col-readouts { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
  .col-readouts .col-head { grid-column: 1 / -1; }
  .dash { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile:nth-child(4) { border-right: 0; }
  .tile:nth-child(-n + 4) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .config-layout { grid-template-columns: minmax(0, 1fr); }
  .config-index { position: static; }
  .config-index nav { display: flex; flex-wrap: wrap; border-left: 0; gap: 4px; }
  .index-link { border: 1px solid var(--line); border-radius: 999px; margin: 0; padding: 3px 10px; }
  .config-intro { grid-template-columns: minmax(0, 1fr); }
  .param { grid-template-columns: minmax(0, 1fr); }
  .bench { grid-template-columns: minmax(0, 1fr); }
  .play-controls .reveal { margin-left: 0; }
}
@media (max-width: 560px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { border-bottom: 1px solid var(--line); }
  .tile:nth-child(odd) { border-right: 1px solid var(--line); }
  .tile:nth-child(even) { border-right: 0; }
  .param-control { grid-template-columns: minmax(0, 1fr) 120px 28px; }
  .meters { grid-template-columns: minmax(0, 1fr); }
  .facts.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
