/* Model bench board. Colours follow the talk's deck: navy, warm paper, amber. */
:root {
  color-scheme: dark;
  --bg: #121826;
  --surface: #19212f;
  --surface-2: #202a3c;
  --line: #2b3549;
  --line-strong: #3a4660;
  --text: #f6f4ef;
  --text-2: #c2c7d2;
  --muted: #8f98aa;
  --accent: #e8a33d;
  --accent-ink: #e8a33d;
  --accent-wash: rgba(232, 163, 61, 0.14);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-ui: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6f4ef; --surface: #fffdf8; --surface-2: #efebe2; --line: #ddd7ca; --line-strong: #c9c1b0;
    --text: #121826; --text-2: #3b4456; --muted: #667086;
    --accent: #e8a33d; --accent-ink: #8a5a00; --accent-wash: rgba(232, 163, 61, 0.18);
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
    --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4ef; --surface: #fffdf8; --surface-2: #efebe2; --line: #ddd7ca; --line-strong: #c9c1b0;
  --text: #121826; --text-2: #3b4456; --muted: #667086;
  --accent: #e8a33d; --accent-ink: #8a5a00; --accent-wash: rgba(232, 163, 61, 0.18);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding-block: 12px;
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font: 700 18px var(--font-display); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: 6px 6px 0 -2px var(--line-strong); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--text-2); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.snapshot-note { font-size: 13px; color: var(--muted); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; color: var(--text-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); }

main { padding-block: 24px 64px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); max-width: 1480px; margin: 0 auto; }
h1 { font: 700 30px/1.15 var(--font-display); margin: 0; letter-spacing: -0.015em; }
h2 { font: 700 20px/1.2 var(--font-display); margin: 0 0 12px; }
h3 { font: 600 15px var(--font-ui); margin: 0 0 8px; color: var(--text-2); }
.lede { color: var(--text-2); margin: 6px 0 0; font-size: 17px; }
.page-head { display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .meta { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }
.empty { padding: 48px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.running { color: var(--accent-ink); background: var(--accent-wash); }
.pill.running .dot { animation: pulse 1.2s ease-in-out infinite; }
.pill.done { color: var(--text); }
.pill.failed { color: var(--critical); }
.pill.first { color: #121826; background: var(--accent); }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .pill.running .dot { animation: none; } }

/* Race */
.lanes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.lane { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; }
.lane::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--series); }
.lane-head { display: flex; align-items: flex-start; gap: 12px; }
.lane-name { font: 700 24px/1.15 var(--font-display); letter-spacing: -0.01em; }
.lane-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.lane-head .pill { margin-left: auto; }
.big-row { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 12px; }
.big { display: flex; flex-direction: column; gap: 2px; }
.big .v { font: 600 26px/1.1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big .v small { font-size: 14px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.big .k { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.score-big .v { font-size: 36px; }
.budget { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.budget > span { display: block; height: 100%; background: var(--series); border-radius: 999px; transition: width 1.5s linear; }
.rounds { display: flex; gap: 8px; flex-wrap: wrap; }
.round-chip { display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
.round-chip .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.round-chip .v { font: 600 18px var(--font-mono); }
.round-chip.now { border-color: var(--series); }
.round-chip.later { opacity: 0.45; }
.action { display: flex; gap: 10px; align-items: baseline; font-size: 14px; min-height: 40px; }
.action .kind { flex: none; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); width: 64px; }
.action .what { font-family: var(--font-mono); font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.small-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); border-top: 1px solid var(--line); padding-top: 12px; }
.small-stats b { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.lane-shot { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.lane-shot img { display: block; width: 100%; height: auto; }
.lane a.more { font-size: 14px; color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.race-list { margin-top: 32px; }
.race-list a { text-decoration: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th { text-align: left; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--series); vertical-align: middle; margin-right: 8px; }
.model-cell b { font-weight: 600; }
.model-cell .sub { display: block; color: var(--muted); font-size: 13px; }
.range { color: var(--muted); font-size: 13px; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; font-size: 14px; color: var(--text-2); }
.tab.on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-wash); font-weight: 600; }
.tab .size { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-left: 6px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } .big-row { grid-template-columns: repeat(2, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* Chart */
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text, .chart .tick { fill: var(--muted); font: 12px var(--font-ui); }
.chart .axis-title { fill: var(--muted); font: 12.5px var(--font-ui); }
.chart .label { fill: var(--text); font: 600 12.5px var(--font-ui); }
.chart .dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart .label { pointer-events: none; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .dot, .chart .hit:focus + .dot { stroke: var(--text); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--series); margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); max-width: 320px; }
.tip b { font-family: var(--font-mono); font-size: 15px; }
.tip .row { display: flex; gap: 8px; align-items: center; }

/* Run detail */
.score-head { display: flex; align-items: baseline; gap: 10px; }
.score-head .v { font: 700 56px/1 var(--font-mono); letter-spacing: -0.03em; }
.score-head .of { color: var(--muted); font: 500 20px var(--font-mono); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px 18px; }
.fact .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.fact .v { font: 600 18px var(--font-mono); font-variant-numeric: tabular-nums; }
.fact .v small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.sec { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 4px 12px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.sec .bar { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.sec .bar span { display: block; height: 100%; background: var(--text-2); border-radius: 999px; }
.sec .n { text-align: right; font-family: var(--font-mono); }
.fails { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.fails li { display: flex; gap: 10px; }
.fails .id { font-family: var(--font-mono); font-size: 12.5px; color: var(--critical); flex: none; width: 34px; padding-top: 2px; }
.fails .d { display: block; color: var(--muted); font-size: 13px; font-family: var(--font-mono); word-break: break-word; }
.shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.shot img { display: block; width: 100%; height: auto; }

/* Transcript */
.tx-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.chip .n { font-family: var(--font-mono); font-size: 12px; margin-left: 4px; color: var(--muted); }
.tx-tools input[type=search] { margin-left: auto; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); min-width: 220px; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #121826; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn.ghost { background: none; color: var(--accent-ink); }
.btn:disabled { opacity: 0.5; cursor: default; }
.events { display: flex; flex-direction: column; gap: 6px; }
.round-sep { margin: 18px 0 6px; font: 700 16px var(--font-display); display: flex; gap: 10px; align-items: baseline; }
.round-sep .muted { font: 400 13.5px var(--font-ui); }
.ev { display: grid; grid-template-columns: 64px 92px minmax(0, 1fr); gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.ev .t { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); padding-top: 1px; }
.ev .kind { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 2px; }
.ev.thinking { background: transparent; border-style: dashed; }
.ev.thinking .body { color: var(--text-2); font-style: italic; }
.ev.text .body { color: var(--text); }
.ev.error { border-color: var(--critical); }
.ev .title { font-family: var(--font-mono); font-size: 13.5px; word-break: break-word; }
.ev .title b { font-family: var(--font-ui); font-weight: 600; margin-right: 8px; }
.ev.fail .title::after { content: 'error'; margin-left: 8px; font: 600 11px var(--font-ui); text-transform: uppercase; color: var(--critical); }
.ev details { margin-top: 6px; }
.ev summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.ev pre { margin: 6px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: 6px; font: 12.5px/1.5 var(--font-mono); white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
.ev .body { white-space: pre-wrap; word-break: break-word; }
.ev .body.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ev.side { opacity: 0.6; }
.ev.new { animation: arrive 0.5s ease-out; }
@keyframes arrive { from { background: var(--accent-wash); } }
@media (prefers-reduced-motion: reduce) { .ev.new { animation: none; } }

/* Start form */
.form { display: flex; flex-direction: column; gap: 22px; max-width: 980px; }
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.choice { display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice .t { font-weight: 600; }
.choice .d { color: var(--muted); font-size: 13.5px; }
.choice.off { opacity: 0.5; cursor: default; }
.row-fields { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.row-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--muted); }
.row-fields input, .row-fields select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 120px; }
.note { font-size: 14px; color: var(--muted); }
.error-note { color: var(--critical); font-size: 14px; }

@media (max-width: 640px) {
  .top { padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 12px; flex-wrap: wrap; }
  main { padding-block: 16px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .ev { grid-template-columns: 52px minmax(0, 1fr); }
  .ev .kind { display: none; }
  .lanes { grid-template-columns: 1fr; }
  .page-head .meta { margin-left: 0; text-align: left; }
}
.error-note:empty { display: none; }
