/* mario-rl panel. Tokens shared with docs/guide; see README.md for the plan. */

:root {
  color-scheme: light;
  --bg: #F5F7FA; --bg2: #FFFFFF; --bg3: #E9EDF3;
  --ink: #1B2431; --ink2: #3A4557; --muted: #69748A; --line: #D5DBE5;
  --red: #D23A2A; --sky: #3A7BD5; --pipe: #2E8B57; --brick: #B8865B; --coin: #C99A1E;
  --pipe-bg: #EAF5EE; --sky-bg: #EAF1FB; --red-bg: #FBEAE8; --brick-bg: #F6EEE4; --coin-bg: #FBF3DC;
  --shadow: 0 1px 2px rgba(27,36,49,.08);
  /* chart series: re-stepped brand hues, validated on --bg2 (README §3) */
  --s-sky: #1D76E7; --s-red: #CC3526; --s-pipe: #00713E; --s-coin: #BB8D0C; --s-brick: #915102;
  --s-ink: #69748A; --grid: #EDF0F4; --axis: #C9D0DB;
  --seq-lo: #E4EEFB; --seq-hi: #1D4F9E;
  --focus: var(--sky);
  --link: #2A62B4;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --pixel: "Press Start 2P", monospace;
  --fs-1: 12px; --fs-2: 14px; --fs-3: 17px; --fs-4: 21px; --fs-5: 25px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-btn: 6px; --r-chip: 4px;
  --top-h: 56px;
  --gutter: 24px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12171F; --bg2: #1A2129; --bg3: #232C37;
    --ink: #E8ECF2; --ink2: #C4CBD6; --muted: #8B95A7; --line: #313B48;
    --red: #F0625A; --sky: #6FA6F0; --pipe: #57B77F; --brick: #D2A26F; --coin: #E4B53A;
    --pipe-bg: #17281F; --sky-bg: #172234; --red-bg: #33201E; --brick-bg: #2E271E; --coin-bg: #2E2914;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --s-sky: #3A8DFD; --s-red: #CC3526; --s-pipe: #007E46; --s-coin: #B3880F; --s-brick: #C9740D;
    --s-ink: #8B95A7; --grid: #222B36; --axis: #3A4553;
    --seq-lo: #1C2735; --seq-hi: #8FBCF7;
    --link: #8FBCF7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12171F; --bg2: #1A2129; --bg3: #232C37;
  --ink: #E8ECF2; --ink2: #C4CBD6; --muted: #8B95A7; --line: #313B48;
  --red: #F0625A; --sky: #6FA6F0; --pipe: #57B77F; --brick: #D2A26F; --coin: #E4B53A;
  --pipe-bg: #17281F; --sky-bg: #172234; --red-bg: #33201E; --brick-bg: #2E271E; --coin-bg: #2E2914;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --s-sky: #3A8DFD; --s-red: #CC3526; --s-pipe: #007E46; --s-coin: #B3880F; --s-brick: #C9740D;
  --s-ink: #8B95A7; --grid: #222B36; --axis: #3A4553;
  --seq-lo: #1C2735; --seq-hi: #8FBCF7;
  --link: #8FBCF7;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs-2)/1.45 var(--sans);
  font-feature-settings: "cv05"; /* Plex: single-storey a stays; keep defaults otherwise */
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; text-wrap: balance; }
h2 { font-size: var(--fs-3); }
h3 { font-size: var(--fs-2); }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--pixel); font-size: 8px; line-height: 1; letter-spacing: .08em;
  text-transform: uppercase; color: var(--red); margin-bottom: var(--sp-3);
}
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--bg2); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--sky-bg); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--bg2); color: var(--ink);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--bg3); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"], .btn.on { background: var(--sky-bg); border-color: var(--sky); color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger.confirm { background: var(--red); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--bg3); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn .ic { width: 16px; height: 16px; flex: none; }
.btn.sm { min-height: 26px; padding: 0 8px; font-size: var(--fs-1); }
.q {
  width: 18px; height: 18px; padding: 0; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--muted); font-size: 11px; line-height: 1; font-weight: 600;
  flex: none; display: inline-grid; place-items: center;
}
.q:hover { color: var(--ink); border-color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-chip); border: 1px solid var(--line); background: var(--bg2);
  font-size: var(--fs-1); font-weight: 500; white-space: nowrap; color: var(--ink2);
}
.chip.mock { border-style: dashed; color: var(--muted); }
.chip.warn { border-color: var(--coin); background: var(--coin-bg); color: var(--ink); }
.chip.ok { border-color: var(--pipe); background: var(--pipe-bg); }
.chip .pix { width: 12px; height: 12px; }
input[type="number"], input[type="text"], select, textarea {
  min-height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-btn);
  background: var(--bg2); color: var(--ink);
}
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
textarea { padding: 8px; line-height: 1.45; resize: vertical; }
label.lbl { display: grid; gap: 4px; font-size: var(--fs-1); color: var(--muted); }
label.lbl > span { font-weight: 500; }
.seg { display: inline-flex; align-items: center; gap: var(--sp-2); }
.seg-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.seg-btns { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-btn); overflow: hidden; background: var(--bg2); }
.seg-btns button {
  min-height: 30px; min-width: 40px; padding: 0 8px; border: 0; background: transparent; color: var(--ink2);
  font-family: var(--mono); font-size: var(--fs-1); border-right: 1px solid var(--line);
}
.seg-btns button:last-child { border-right: 0; }
.seg-btns button:hover { background: var(--bg3); }
.seg-btns button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.seg-btns button:focus-visible { outline-offset: -2px; }
.stepper { display: inline-grid; grid-template-columns: 28px 1fr 28px; border: 1px solid var(--line); border-radius: var(--r-btn); overflow: hidden; background: var(--bg2); }
.stepper button { border: 0; background: transparent; color: var(--ink2); display: grid; place-items: center; padding: 0; }
.stepper button:hover { background: var(--bg3); }
.stepper button:focus-visible { outline-offset: -2px; }
.stepper button .ic { width: 12px; height: 12px; }
.stepper input { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; min-height: 30px; width: 100%; min-width: 0; text-align: right; padding: 0 6px; }
.stepper input:focus-visible { outline-offset: -2px; }
.pix { width: 32px; height: 32px; flex: none; }
.pix.s { width: 16px; height: 16px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 30; min-height: var(--top-h);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-5);
  padding: var(--sp-2) var(--gutter); background: var(--bg2); border-bottom: 1px solid var(--line);
}
.top-id { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.runname {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 2px 6px 2px 2px; border: 0; background: none;
  border-radius: var(--r-btn); max-width: 40vw;
}
.runname:hover { background: var(--bg3); }
.runname strong { font-size: var(--fs-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runname small { font-family: var(--mono); font-size: var(--fs-1); color: var(--muted); }
.runname .ic { width: 12px; height: 12px; align-self: center; color: var(--muted); }
.menu {
  position: absolute; z-index: 40; margin-top: 4px; min-width: 260px; max-height: 60vh; overflow: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.menu a, .menu button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--ink); text-decoration: none; border-radius: 6px; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--bg3); }
.menu .chip { height: 18px; font-size: 11px; }
.state { display: inline-flex; align-items: center; gap: 7px; font-family: var(--pixel); font-size: 8px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); white-space: nowrap; }
.state .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.state.running .dot { background: var(--pipe); animation: breathe 2.4s ease-in-out infinite; }
.state.paused .dot { background: var(--coin); }
.state.starting .dot { background: var(--coin); animation: breathe 1.2s ease-in-out infinite; }
.state.crashed .dot { background: var(--red); }
.state.crashed { color: var(--red); }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.sps { font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.sps b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.top-transport, .top-speeds, .top-modes { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.top-modes { margin-left: auto; }
.confirm-row { display: inline-flex; align-items: center; gap: 6px; }
.tabs { display: inline-flex; border-bottom: 0; gap: 2px; padding: 2px; background: var(--bg3); border-radius: var(--r-btn); }
.tabs [role="tab"] { border: 0; background: transparent; padding: 0 12px; min-height: 28px; border-radius: 4px; color: var(--ink2); font-weight: 500; }
.tabs [role="tab"][aria-selected="true"] { background: var(--bg2); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.shell.docs-open { grid-template-columns: minmax(0, 1fr) 40%; }
.main { container-type: inline-size; min-width: 0; padding: var(--sp-5) var(--gutter) var(--sp-7); }
.view { display: block; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
@container (min-width: 1100px) {
  .cols { grid-template-columns: auto minmax(0, 1fr); }
  .stagecol { position: sticky; top: calc(var(--top-h) + var(--sp-4)); }
}

/* ---------- stage ---------- */
.stagecol { display: grid; gap: var(--sp-4); }
.stage { display: grid; gap: var(--sp-2); }
.frame { position: relative; width: max-content; max-width: 100%; border: 2px solid var(--ink); background: #000; }
.frame img { display: block; width: calc(256px * var(--scale, 2)); height: calc(240px * var(--scale, 2)); max-width: 100%; image-rendering: pixelated; image-rendering: crisp-edges; background: #000; }
.frame.dim img { filter: brightness(.4) saturate(.6); }
.frozen, .driving { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #fff; text-shadow: 0 2px 8px #000; font-family: var(--pixel); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.driving { align-content: end; padding-bottom: 14px; font-size: 9px; }
.driving span { background: rgba(210,58,42,.9); padding: 6px 10px; border-radius: 3px; }
.hud { display: flex; flex-wrap: wrap; gap: 4px var(--sp-4); font-size: var(--fs-1); color: var(--muted); }
.hud b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.hud .ret b { font-size: var(--fs-3); }
.mind { display: grid; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); background: var(--bg2); border-radius: 0; }
.mind .h { display: flex; align-items: center; gap: 8px; }
.probs { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.probs li { display: grid; grid-template-columns: 110px 1fr 46px; align-items: center; gap: 8px; font-size: var(--fs-1); }
.probs .nm { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.probs .track { position: relative; height: 10px; background: var(--bg3); }
.probs .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--sky); opacity: .45; }
.probs li.chosen .fill { opacity: 1; }
.probs li.chosen .nm { color: var(--ink); font-weight: 600; }
.probs .v { text-align: right; font-family: var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.probs li.chosen .v { color: var(--ink); }
.mind-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: var(--sp-2) var(--sp-4); }
.stat { display: grid; gap: 2px; }
.stat dt { font-size: var(--fs-1); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat dd { margin: 0; font-family: var(--mono); font-size: var(--fs-3); font-weight: 500; }
.tiles { display: grid; grid-template-columns: repeat(7, 22px); gap: 2px; }
.tiles i { display: block; width: 22px; height: 22px; background: var(--bg3); border: 1px solid var(--line); }
.tiles i.solid { background: var(--brick); border-color: var(--brick); }
.tiles i.mario { box-shadow: inset 0 0 0 2px var(--red); }
.tiles-note { font-size: var(--fs-1); color: var(--muted); max-width: 40ch; }
.takeover { display: grid; gap: 6px; }
.keys { font-size: var(--fs-1); color: var(--muted); }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--bg2); color: var(--ink2); }

/* ---------- board sections ---------- */
.board { display: grid; gap: var(--sp-6); min-width: 0; }
.sec-h { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.sec-h h2 { display: flex; align-items: center; gap: 8px; }
.sec-h .spacer { flex: 1; }

/* run card */
.runcard { border: 1px solid var(--line); background: var(--bg2); padding: var(--sp-4); display: grid; gap: var(--sp-4); }
.runcard .title { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.runcard .title h2 { font-size: var(--fs-4); font-weight: 600; }
.runcard .title input { font-size: var(--fs-4); font-weight: 600; min-width: 12ch; padding: 0 6px; height: 34px; }
.runcard .title small { font-family: var(--mono); color: var(--muted); font-size: var(--fs-1); }
.budget { display: grid; gap: 6px; }
.budget .bar { position: relative; height: 8px; background: var(--bg3); overflow: hidden; }
.budget .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--sky); }
.budget .lbl { display: flex; justify-content: space-between; font-size: var(--fs-1); color: var(--muted); }
.budget .lbl b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2) var(--sp-4); margin: 0; }
.facts div { display: grid; gap: 1px; }
.facts dt { font-size: var(--fs-1); color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd.num { font-weight: 500; }
.ckpts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ckpt { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--r-chip); background: var(--bg); overflow: hidden; }
.ckpt > span { padding: 0 8px; font-family: var(--mono); font-size: var(--fs-1); line-height: 24px; color: var(--ink2); }
.ckpt > span b { color: var(--ink); font-weight: 500; }
.ckpt button { border: 0; border-left: 1px solid var(--line); background: transparent; height: 24px; width: 26px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.ckpt button:hover { background: var(--bg3); color: var(--ink); }
.ckpt button .ic { width: 12px; height: 12px; }
.notes { display: grid; gap: 4px; }
.notes textarea { min-height: 38px; font-size: var(--fs-2); }
.notes .hint { font-size: var(--fs-1); color: var(--muted); }

/* rewards ledger */
.totals { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-1); color: var(--muted); }
.totals b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-size: var(--fs-2); font-variant-numeric: tabular-nums; }
.totals .share { display: inline-flex; align-items: center; gap: 8px; }
.totals .meter { width: 90px; height: 6px; background: var(--bg3); position: relative; overflow: hidden; }
.totals .meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pipe); }
.ledger { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.tile { background: var(--bg2); padding: var(--sp-3) var(--sp-4); display: grid; grid-template-rows: auto auto auto 1fr auto; gap: var(--sp-2); min-width: 0; }
.tile-h { display: flex; align-items: center; gap: 10px; }
.tile-h h3 { flex: 1; font-size: var(--fs-2); font-weight: 600; min-width: 0; }
.tile .fires { font-size: var(--fs-1); color: var(--muted); min-height: 2.9em; }
.knobs { display: grid; gap: 6px; }
.knob { display: grid; grid-template-columns: 1fr; gap: 3px; }
.knob .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.knob label { font-size: var(--fs-1); color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.knob .dflt { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.knob .dflt button { border: 0; background: none; padding: 2px; color: var(--muted); display: grid; place-items: center; border-radius: 4px; }
.knob .dflt button:hover { color: var(--ink); background: var(--bg3); }
.knob .dflt button .ic { width: 12px; height: 12px; }
.knob.changed .stepper { border-color: var(--sky); }
.knob.changed .dflt { color: var(--sky); }
.knob.pending .stepper { border-style: dashed; }
.knob.ctl { margin-top: 2px; padding-top: 6px; border-top: 1px dashed var(--line); }
.knob input::placeholder { color: var(--muted); opacity: 1; }
.vals { display: grid; grid-template-columns: 1fr 1fr 80px; gap: var(--sp-2); align-items: end; margin: 0; }
.vals div { display: grid; gap: 1px; min-width: 0; }
.vals dt { font-size: 11px; color: var(--muted); white-space: nowrap; }
.vals dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vals .ep dd { font-size: var(--fs-3); font-weight: 500; }
.spark svg { width: 80px; height: 24px; overflow: visible; }
.spark path { fill: none; stroke: var(--s-sky); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .base { stroke: var(--axis); stroke-width: 1; }
.spark circle { fill: var(--s-sky); stroke: var(--bg2); stroke-width: 2; }
.applied { min-height: 1.4em; font-size: 11px; color: var(--ink2); display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .3s; }
.applied .ic { color: var(--pipe); }
.applied.show { opacity: 1; }
.applied .ic { width: 12px; height: 12px; }
.plain { display: none; font-size: var(--fs-1); color: var(--ink2); max-width: 60ch; border-left: 2px solid var(--pipe); padding-left: 8px; }
html[data-learn="1"] .plain:not(:empty) { display: block; }
.tile .plain { margin-top: 2px; }

/* charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: var(--sp-3); }
.chart { position: relative; margin: 0; background: var(--bg2); border: 1px solid var(--line); padding: var(--sp-3) var(--sp-4) var(--sp-3); display: grid; gap: var(--sp-2); min-width: 0; }
.chart-h { display: flex; align-items: center; gap: 8px; }
.chart-h .t { font-weight: 600; flex: 1; }
.chart-h .sub { font-size: var(--fs-1); color: var(--muted); }
.plot { position: relative; width: 100%; }
.plot svg { width: 100%; height: auto; display: block; font-family: var(--mono); font-size: 10.5px; overflow: visible; }
.plot .gl { stroke: var(--grid); stroke-width: 1; }
.plot .ax { stroke: var(--axis); stroke-width: 1; }
.plot text { fill: var(--muted); }
.plot text.lbl { fill: var(--ink2); font-family: var(--sans); font-size: 11px; }
.plot text.ev { fill: var(--ink2); font-family: var(--sans); font-size: 10px; }
.plot .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .ar { opacity: .12; }
.plot .st { stroke: var(--bg2); stroke-width: 2; }
.plot .tick-ev { stroke: var(--ink2); stroke-width: 1.5; }
.plot .promo { stroke: var(--axis); stroke-width: 1; stroke-dasharray: none; }
.plot .cross { stroke: var(--ink2); stroke-width: 1; opacity: 0; pointer-events: none; }
.plot .hit { fill: transparent; cursor: crosshair; }
.plot .cell:hover { stroke: var(--ink); stroke-width: 1.5; }
.plot .mk { stroke: var(--bg2); stroke-width: 2; }
.plot .ep { fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-1); color: var(--ink2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.legend i.ln { height: 2px; width: 14px; border-radius: 1px; }
.legend .ev { color: var(--muted); }
.legend .ev i { width: 2px; height: 10px; background: var(--ink2); border-radius: 0; }
.tt {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 260px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.16); font-size: var(--fs-1); color: var(--ink2);
}
.tt .x { font-family: var(--mono); color: var(--muted); margin-bottom: 4px; }
.tt div.r { display: flex; align-items: center; gap: 8px; }
.tt .k { display: inline-block; width: 10px; height: 2px; }
.tt b { margin-left: auto; font-family: var(--mono); font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-1); }
.tbl th, .tbl td { text-align: right; padding: 3px 6px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; font-family: var(--sans); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl-wrap { max-height: 220px; overflow: auto; }
.empty { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: var(--fs-1); text-align: center; padding: var(--sp-3); }

/* library */
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: end; margin-bottom: var(--sp-4); }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-3); }
.agent { background: var(--bg2); border: 1px solid var(--line); display: grid; grid-template-columns: 96px minmax(0, 1fr); }
.agent .thumb { width: 96px; aspect-ratio: 16 / 15; background: var(--bg3); display: grid; place-items: center; color: var(--muted); border-right: 1px solid var(--line); overflow: hidden; }
.agent .thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.agent .thumb .pix { color: var(--muted); opacity: .6; }
.agent .body { padding: var(--sp-3) var(--sp-3) var(--sp-2); display: grid; gap: 6px; min-width: 0; }
.agent .nm { display: flex; align-items: center; gap: 8px; }
.agent .nm h3 { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .nm input { min-width: 0; flex: 1; height: 28px; }
.agent .raw { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-1); color: var(--muted); }
.agent .meta b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.exams { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); }
.exams span { display: inline-flex; align-items: center; gap: 5px; }
.exams i { display: inline-block; width: 36px; height: 5px; background: var(--bg3); position: relative; }
.exams i::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); background: var(--pipe); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.agent .acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.agent .notes-line { font-size: var(--fs-1); color: var(--ink2); }
.agent textarea { font-size: var(--fs-1); min-height: 48px; }

/* LAN address, QR, harness */
.net .lock { width: 12px; height: 12px; color: var(--coin); }
.net #net-label { font-family: var(--mono); font-size: var(--fs-1); }
.netpop { right: auto; left: 0; top: calc(100% + 6px); position: absolute; width: min(320px, calc(100vw - 32px)); display: grid; gap: 10px; }
.netpop .qr { display: grid; place-items: center; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.netpop .qr svg { width: 100%; max-width: 232px; height: auto; }
.netpop .url { font-size: var(--fs-1); overflow-wrap: anywhere; color: var(--ink); }
.netpop .foot { display: flex; align-items: center; gap: 8px; }
.netpop .foot .spacer { flex: 1; }
.harness-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); margin: var(--sp-3) 0; }
.hcard { border: 1px solid var(--line); background: var(--bg2); padding: var(--sp-3) var(--sp-4); display: grid; gap: 6px; align-content: start; }
.hcard p { font-size: var(--fs-1); }
.hcard .btn { justify-self: start; margin-top: 4px; }
.harness .cmd, .cmd { font-family: var(--mono); font-size: var(--fs-1); background: var(--bg3); padding: 10px 12px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* docs pane, drawer, popover, sheet, toast */
.docs { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg2); }
.docs-bar { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 12px; border-bottom: 1px solid var(--line); }
.docs-bar strong { flex: 1; }
.docs iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 50;
  background: var(--bg2); border-left: 1px solid var(--line); box-shadow: -8px 0 32px rgba(0,0,0,.18);
  padding: var(--sp-4) var(--sp-5); overflow: auto; display: grid; gap: var(--sp-3); align-content: start;
  line-height: 1.6;
}
.drawer .bar { display: flex; align-items: center; gap: 8px; }
.drawer .bar h2 { flex: 1; font-size: var(--fs-4); }
.drawer .short { font-weight: 600; }
.drawer .deep { color: var(--ink2); max-width: 62ch; }
.drawer .plain { display: block; }
.drawer .plain:empty { display: none; }
.pop {
  position: fixed; z-index: 50; top: calc(var(--top-h) + 4px); right: var(--gutter); width: min(360px, calc(100vw - 32px));
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: var(--sp-3) var(--sp-4);
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.pop h2 { font-size: var(--fs-2); margin-bottom: 8px; }
.pop dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: var(--fs-1); }
.pop dt { display: flex; gap: 4px; }
.pop dd { margin: 0; color: var(--ink2); }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(27,36,49,.45); display: grid; place-items: center; padding: var(--sp-4); }
.sheet {
  width: min(680px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: var(--sp-5); display: grid; gap: var(--sp-4);
}
.sheet .bar { display: flex; align-items: center; gap: 8px; }
.sheet .bar h2 { flex: 1; font-size: var(--fs-4); }
.sheet .form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3) var(--sp-4); }
.sheet .form .wide { grid-column: 1 / -1; }
.sheet .diff { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet .cmd { font-family: var(--mono); font-size: var(--fs-1); background: var(--bg3); padding: 10px 12px; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet .foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.sheet .foot .spacer { flex: 1; }
.presets-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.preset { text-align: left; display: grid; gap: 4px; align-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); color: var(--ink); cursor: pointer; min-height: 96px; }
.preset:hover { background: var(--bg3); }
.preset[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.preset .nm { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.preset .nm .chip { margin-left: auto; height: 18px; font-size: 11px; }
.preset .story { font-size: var(--fs-1); color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.preset .prov { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.wgrid .w { display: grid; grid-template-columns: minmax(0, 1fr) 72px; align-items: center; gap: 6px; padding: 2px 0; }
.wgrid .w .l { font-size: var(--fs-1); color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wgrid .w .l small { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.wgrid .w input { min-height: 28px; padding: 0 6px; text-align: right; width: 72px; }
.wgrid .w.changed input { border-color: var(--sky); background: var(--sky-bg); }
.wgrid .w.changed .l { color: var(--ink); font-weight: 500; }
.sheet details.teach { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: var(--bg); }
.sheet details.teach summary { cursor: pointer; font-size: var(--fs-1); color: var(--ink2); font-weight: 500; }
.sheet details.teach[open] summary { margin-bottom: 8px; }
.sheet .choice { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--coin); background: var(--coin-bg); border-radius: 6px; }
.sheet .choice p { max-width: 60ch; }
.sheet .choice .row { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet .choice .err { color: var(--red); }
.presets { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.presets button { min-height: 26px; padding: 0 8px; border: 1px solid var(--line); background: var(--bg2); border-radius: 4px; font-family: var(--mono); font-size: var(--fs-1); }
.presets button:hover { background: var(--bg3); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: var(--fs-1); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: min(90vw, 60ch); }
.toast.show { opacity: 1; }
.term { border-bottom: 1px dotted var(--muted); cursor: help; position: relative; }
.term:hover::after, .term:focus::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 4px); z-index: 55; width: max-content; max-width: 280px;
  white-space: normal; background: var(--bg2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: var(--fs-1); font-weight: 400; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.16);
}
.offline { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--red); background: var(--red-bg); border-radius: 6px; font-size: var(--fs-1); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .top { gap: var(--sp-2) var(--sp-3); }
  .top-modes { margin-left: 0; }
  .shell.docs-open { grid-template-columns: minmax(0, 1fr); }
  .docs { position: fixed; inset: var(--top-h) 0 0 0; height: auto; z-index: 45; border-left: 0; }
  .runname { max-width: 60vw; }
  .chart-grid { grid-template-columns: 1fr; }
  .ledger { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .probs li { grid-template-columns: 96px 1fr 42px; }
  .frame { width: 100%; }
  .frame img { width: 100%; height: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print { .top, .docs, .drawer, .pop, .scrim, .toast { display: none !important; } }
