:root {
  --bg: #0b0e13;
  --surface: #121722;
  --surface-2: #0f141c;
  --row-active: #1c2433;
  --border: #232b3a;
  --border-strong: #2a3445;
  --text: #e7ecf3;
  --text-2: #c9d2de;
  --muted: #9aa6b8;
  --faint: #5b6678;
  --accent: #f6a04d;
  --accent-ink: #0b0e13;
  --accent-dim: #5a3a12;
  --blue: #5aa9f6;
  --blue-dim: #17324d;
  --green: #6fd39b;
  --green-dim: #153625;
  --red: #f08a8a;
  --red-dim: #3d1c1f;
  --violet: #b59bf6;
  --violet-dim: #2a2145;
  --bar-track: #1e2633;
  --link: #8cc4fa;
  --radius-card: 14px;
  --radius-input: 10px;
  --radius-chip: 8px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--link); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.accent { color: var(--accent); }
.good { color: var(--green); }
.bad { color: var(--red); }
em { color: var(--accent); font-style: normal; }

.shell { max-width: 1320px; margin: 0 auto; padding: 28px 32px 40px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 13.5px; }
.top-right { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { border: 1px solid var(--border-strong); border-radius: var(--radius-chip); padding: 5px 10px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.chip.accent { border-color: var(--accent); color: var(--accent); }

/* tabs */
.tabs { display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.tabs a { color: var(--muted); text-decoration: none; padding: 10px 14px 12px; font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; align-items: center; gap: 8px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .step { font: 600 11px/1 var(--font-mono); color: var(--faint); border: 1px solid var(--border-strong); border-radius: 6px; padding: 3px 5px; }
.tabs a[aria-selected="true"] .step { color: var(--accent); border-color: var(--accent-dim); }
.tab-context { margin-left: auto; color: var(--muted); font-size: 12.5px; padding-bottom: 12px; }

/* layout */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; min-width: 0; }
.card.tight { padding: 14px 16px; }
.sunken { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { font-size: 18px; font-weight: 700; }
.section-head p { color: var(--muted); max-width: 760px; }
.kicker { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 8px; }
.lede { font-size: 16px; color: var(--text-2); max-width: 880px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.card p + p { margin-top: 6px; }

/* stat tiles */
.stat .v { font: 600 26px/1.15 var(--font-mono); letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat .d { font-size: 12px; margin-top: 6px; }

/* buttons and controls */
.btn { border: 1px solid var(--border-strong); background: transparent; border-radius: var(--radius-input); padding: 8px 14px; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--border-strong); background: transparent; border-radius: var(--radius-chip); padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill small { font-weight: 500; opacity: 0.75; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .label { font-size: 12px; color: var(--muted); }
select, input[type="number"] { background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-input); padding: 7px 10px; }
.toggle { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.toggle input { margin-top: 3px; accent-color: var(--accent); }

/* tags */
.tag { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.tag.trap { color: var(--violet); border-color: var(--violet-dim); background: rgba(181,155,246,0.06); }
.tag.src { color: var(--blue); border-color: var(--blue-dim); background: rgba(90,169,246,0.06); }
.tag.ok { color: var(--green); border-color: var(--green-dim); background: rgba(111,211,155,0.07); }
.tag.no { color: var(--red); border-color: var(--red-dim); background: rgba(240,138,138,0.07); }
.tag.warn { color: var(--accent); border-color: var(--accent-dim); background: rgba(246,160,77,0.07); }
.tag.basis { font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
tr.hl td { background: rgba(246,160,77,0.06); }
tr.group td { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; padding-top: 16px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--row-active); }
tbody tr.sel td { background: var(--row-active); }

/* engagement */
.phases { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.phase { position: relative; padding: 14px 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: inherit; }
.phase:hover { border-color: var(--accent-dim); }
.phase .n { font: 600 12px var(--font-mono); color: var(--accent); }
.phase h4 { font-size: 15px; margin: 4px 0 6px; }
.phase p { color: var(--muted); font-size: 13px; }
.q { display: grid; grid-template-columns: 28px minmax(0, 1fr) 190px 130px; gap: 14px; align-items: start; padding: 13px 0; border-bottom: 1px solid var(--border); }
.q:last-child { border-bottom: none; }
.q .n { font: 600 13px var(--font-mono); color: var(--accent); }
.q .t { font-weight: 600; }
.q .m { color: var(--muted); font-size: 13px; }
.decision { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.decision:last-child { border-bottom: none; }
.decision .k { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 2px; }

/* data tab */
.file-list { max-height: 640px; overflow-y: auto; margin: 0 -8px; }
.file-row { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; margin-bottom: 2px; }
.file-row:hover { background: var(--row-active); }
.file-row[aria-pressed="true"] { background: var(--row-active); border-color: var(--accent-dim); }
.file-row .name { font: 600 13px var(--font-mono); }
.raw { font: 12px/1.6 var(--font-mono); white-space: pre; overflow: auto; max-height: 360px; padding: 12px 0; counter-reset: line; }
.raw div { padding: 0 14px 0 0; }
.raw div::before { counter-increment: line; content: counter(line); display: inline-block; width: 42px; padding-right: 12px; text-align: right; color: var(--faint); }
.raw div.blank { background: rgba(240,138,138,0.06); }
.raw div.header { color: var(--accent); }
.raw div.title { color: var(--violet); }
.raw div.total { color: var(--red); }
.cmp { font: 12px var(--font-mono); }
.cmp td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.matrix td.cell { text-align: center; font: 600 12px var(--font-mono); border-radius: 6px; }

/* pipeline diagram */
.runbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.diagram-card { padding: 10px 14px 12px; }
.diagram { width: 100%; height: auto; display: block; }
.node rect, .node polygon { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.2; transition: stroke 0.25s, fill 0.25s; }
.node.ai rect { stroke: var(--blue-dim); }
.node.people rect { stroke: var(--violet-dim); }
.node.end rect { stroke: var(--green-dim); }
.node.active rect, .node.active polygon { stroke: var(--accent); fill: #1d1710; }
.node.selected rect, .node.selected polygon { stroke: var(--text-2); }
.node text { fill: var(--text); font: 600 12.5px var(--font-ui); }
.node .sub { fill: var(--muted); font: 500 10.5px var(--font-ui); }
.node .count { fill: var(--accent); font: 600 12px var(--font-mono); }
.node .cost { fill: var(--blue); font: 500 10.5px var(--font-mono); }
.node { cursor: pointer; }
.edge { fill: none; stroke: var(--border-strong); stroke-width: 1.4; }
.edge.hot { stroke: var(--accent); stroke-width: 2; }
.edge-label { fill: var(--faint); font: 500 10.5px var(--font-ui); }
.lane-label { fill: var(--faint); font: 600 10px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; }
.token { transition: transform 0.38s cubic-bezier(.4,.1,.2,1); }
.token circle { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.token text { fill: var(--accent); font: 600 10.5px var(--font-mono); }
.token.err circle { fill: var(--red); }
.log { max-height: 430px; overflow-y: auto; font-size: 12.5px; }
.log .ev { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.log .ev .where { font: 600 11px var(--font-mono); color: var(--accent); text-transform: uppercase; }
.log .ev .where.ai { color: var(--blue); }
.log .ev .where.people { color: var(--violet); }
.log .ev .where.end { color: var(--green); }
.log .ev .where.err { color: var(--red); }
.log .ev .c { font: 11.5px var(--font-mono); color: var(--blue); white-space: nowrap; }
.log .file-sep { padding: 10px 0 4px; font: 600 12px var(--font-mono); color: var(--text); border-bottom: 1px solid var(--border-strong); }
.explain h3 { font-size: 15px; }
.explain .how { color: var(--text-2); font-size: 13px; margin-top: 8px; }
.explain ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.route { display: flex; flex-wrap: wrap; gap: 4px; }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--font-ui); }
.chart .axis { stroke: var(--border-strong); }
.chart .gridline { stroke: var(--border); stroke-dasharray: 2 4; }
.chart .val { fill: var(--text); font: 600 11px var(--font-mono); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* evals */
.subnav { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 80%, transparent); padding: 10px 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.subnav a { font-size: 12.5px; color: var(--muted); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; }
.subnav a:hover { color: var(--text); border-color: var(--border-strong); }
.delta { font: 600 12px var(--font-mono); }
.scoreline { display: grid; grid-template-columns: 38px minmax(0, 1fr) 120px 110px 90px; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.scoreline:last-child { border-bottom: none; }
.bar { position: relative; height: 10px; background: var(--bar-track); border-radius: 5px; overflow: visible; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.bar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 1px; }
.verdict { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; }
.verdict p + p { margin-top: 10px; }
.callout { border: 1px solid var(--accent-dim); background: rgba(246,160,77,0.05); border-radius: 12px; padding: 14px 16px; color: var(--text-2); }
.callout.blue { border-color: var(--blue-dim); background: rgba(90,169,246,0.05); }
.heat td.cell { text-align: center; font: 600 12px var(--font-mono); padding: 7px 4px; }

/* hand-off */
.timeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.code { font: 12.5px/1.7 var(--font-mono); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; color: var(--text-2); }

.foot { display: flex; justify-content: space-between; gap: 20px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }
.spinner { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; margin-right: 6px; }
@keyframes pulse { 50% { opacity: 0.25; } }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .q { grid-template-columns: 28px 1fr; }
  .q .m:nth-child(3), .q .m:nth-child(4) { grid-column: 2; }
  .decision { grid-template-columns: 1fr; gap: 6px; }
  .timeline { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .token { transition: none; } }

[hidden] { display: none !important; }

.controls { display: grid; grid-template-columns: auto minmax(0, 1.6fr) minmax(220px, 0.9fr) auto 220px; gap: 10px 22px; align-items: start; padding: 16px 18px 12px; }
.controls .field { margin-bottom: 0; }
.controls #one-wrap, .controls #n-wrap { margin-top: 8px; }
.controls .run-col { gap: 10px; padding-top: 18px; }
.controls .cache-note { grid-column: 1 / -1; font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 10px; }
@media (max-width: 1100px) { .controls { grid-template-columns: 1fr 1fr; } }
.section[id^="sec-"] { scroll-margin-top: 96px; }
.log { padding-right: 10px; }

/* evals: numbered reading order and folded details */
.steps-nav { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 14px; background: linear-gradient(var(--bg) 82%, transparent); }
.steps-nav a { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px 5px 6px; }
.steps-nav a:hover { border-color: var(--border-strong); color: var(--text); }
.steps-nav a span { font: 600 11px/1 var(--font-mono); color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 999px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.step-n { font: 600 13px/1 var(--font-mono); color: var(--accent-ink); background: var(--accent); border-radius: 999px; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; vertical-align: 2px; }
details.more { padding: 0; margin-bottom: 10px; }
details.more summary { cursor: pointer; list-style: none; display: flex; gap: 14px; align-items: baseline; padding: 14px 18px; font-weight: 600; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; font: 600 14px var(--font-mono); color: var(--accent); width: 12px; }
details.more[open] summary::before { content: "−"; }
details.more summary .muted { font-weight: 400; font-size: 13px; }
details.more .more-body { padding: 4px 18px 18px; }
details.more .more-body .card { background: var(--surface-2); }
