/* Pit Wall dashboard — dark "race control" theme. No frameworks.
   Class names here are the ones web/static/app.js emits; keep the two in step. */

:root {
  --bg:        #0b0e13;
  --bg-2:      #11151c;
  --bg-3:      #171c26;
  --line:      #232a37;
  --line-2:    #2f3849;
  --fg:        #e8ecf3;
  --fg-dim:    #9aa5b7;
  --fg-faint:  #6b7688;
  --accent:    #ff3b30;
  --accent-2:  #ff7a45;
  --ok:        #34d399;
  --warn:      #fbbf24;
  --bad:       #f87171;
  /* one colour per data source, shared by the route chips and the tools that read them */
  --c-results:   #3b82f6;
  --c-telemetry: #22d3ee;
  --c-knowledge: #a855f7;
  --c-analysis:  #f59e0b;
  --c-model:     #8fa3bf;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--sans); font-size: 14px;
}

/* the faint checkered strip across the top, like a pit lane */
body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50;
  background: repeating-linear-gradient(90deg, var(--accent) 0 14px, #1a1f28 14px 28px);
}

.app { display: grid; grid-template-columns: 300px 1fr; height: 100%; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); }

/* what each kind of step is coloured with (--kc), used by nodes, bars and the legend */
.k-model   { --kc: var(--c-model); }
.k-tool    { --kc: var(--fg-dim); }
.tk-results   { --kc: var(--c-results); }
.tk-telemetry { --kc: var(--c-telemetry); }
.tk-knowledge { --kc: var(--c-knowledge); }
.k-plan, .k-sub { --kc: var(--c-analysis); }
.k-route   { --kc: var(--route, var(--fg-dim)); }
.k-node    { --kc: var(--route, var(--fg-dim)); }
.k-blocked { --kc: var(--bad); }
.k-guard   { --kc: var(--warn); }
.k-answer  { --kc: var(--accent); }

/* ---------------------------------------------------------------- sidebar */

.side {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 16px 16px; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
}
.brand .logo svg { width: 22px; height: 22px; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.brand p { margin: 2px 0 0; font-size: 11.5px; color: var(--fg-faint); }

.health { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-dim);
}
.chip .dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--fg-faint); }
.chip.on .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.chip.off .dot { background: var(--bad); }
.chip b { color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.warn { border-color: var(--warn); color: var(--warn); }

.side-sec h2 {
  margin: 0 0 8px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--fg-faint); font-weight: 600;
}
.h2-note { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; margin-left: 4px; }

.examples { display: flex; flex-direction: column; gap: 6px; }
.ex {
  text-align: left; font: inherit; font-size: 12.5px; line-height: 1.4; color: var(--fg-dim);
  background: var(--bg-3); border: 1px solid var(--line); border-left: 2px solid var(--rc, var(--line-2));
  border-radius: 7px; padding: 7px 10px; cursor: pointer;
  transition: border-color .12s, color .12s, transform .12s;
}
.ex:hover { color: var(--fg); transform: translateX(2px); }
.ex-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ex-tag { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--rc); }
.ex-trap {
  font: 9.5px var(--mono); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 4px; padding: 0 4px;
}

.runs { display: flex; flex-direction: column; gap: 3px; }
.run {
  font: inherit; font-size: 12px; color: var(--fg-dim); text-align: left;
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 5px 7px; cursor: pointer;
  display: grid; grid-template-columns: 8px 1fr; gap: 2px 8px; align-items: center;
}
.run:hover { background: var(--bg-3); border-color: var(--line); color: var(--fg); }
.run .r-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rc, var(--fg-faint)); }
.run .r-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .r-meta { grid-column: 2; font: 10.5px var(--mono); color: var(--fg-faint); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.hint { font-size: 11px; color: var(--fg-faint); line-height: 1.55; margin: 0; }
.hint code { font-family: var(--mono); font-size: 10.5px; color: var(--fg-dim); }
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 4px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-dim);
}
.act {
  font: inherit; font-size: 12px; color: var(--fg-dim); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 11px; cursor: pointer;
}
.act:hover { color: var(--fg); border-color: var(--line-2); }
.act:disabled { opacity: .45; cursor: default; }
.act.primary { color: #fff; border-color: transparent; background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.act.primary:disabled { background: var(--bg-3); border-color: var(--line); color: var(--fg-faint); opacity: 1; }
.act.up.on { border-color: var(--ok); background: rgba(52,211,153,.14); }
.act.down.on { border-color: var(--bad); background: rgba(248,113,113,.14); }

/* ------------------------------------------------------------------- main */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.topbar-title { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-faint); font-weight: 600; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--fg-faint); white-space: nowrap; }
.topbar select {
  font: inherit; font-size: 11.5px; font-family: var(--mono);
  background: var(--bg-3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 7px;
}
.legend { flex: 1; display: flex; flex-wrap: wrap; gap: 5px 12px; justify-content: center; }
.lg { display: inline-flex; align-items: center; gap: 5px; font: 10.5px var(--mono); color: var(--fg-faint); white-space: nowrap; }
.lg::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--kc); }

.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 30px; }

.empty { margin: auto; text-align: center; max-width: 480px; color: var(--fg-faint); }
.empty h3 { color: var(--fg-dim); font-size: 16px; margin: 0 0 8px; }
.empty p { font-size: 12.5px; line-height: 1.6; margin: 0; }

/* ------------------------------------------------------------------- turn */

.turn { width: 100%; max-width: 1080px; align-self: center; display: flex; flex-direction: column; gap: 12px; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ask { display: flex; gap: 10px; align-items: baseline; }
.ask .who { flex: none; font: 10px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--fg-faint); }
.ask .q { font-size: 15.5px; font-weight: 600; letter-spacing: -.1px; line-height: 1.4; }
.ask .meta { font: 11px var(--mono); color: var(--fg-faint); margin-top: 3px; }

.card { border: 1px solid var(--line); border-radius: 13px; background: var(--bg-2); overflow: hidden; }
.card.err { border-color: var(--bad); }

.card-head { display: flex; align-items: center; gap: 11px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.card-head .title { font-size: 13.5px; font-weight: 600; }
.card-head .sub { font: 11px var(--mono); color: var(--fg-faint); margin-top: 2px; }
.card-head .ch-text { flex: 1; min-width: 0; }
.spin {
  width: 13px; height: 13px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.card:not(.live) .card-head .spin { display: none; }

.trace-link {
  font: 11.5px var(--mono); color: #93c5fd; text-decoration: none; white-space: nowrap;
  border: 1px solid color-mix(in srgb, #60a5fa 45%, transparent); border-radius: 7px; padding: 5px 9px;
}
.trace-link:hover { background: rgba(96,165,250,.12); color: #bfdbfe; }

/* the numbers a trace gives you, as tiles */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stat { background: var(--bg-2); padding: 9px 16px; min-width: 0; }
.stat .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-faint); font-weight: 600; }
.stat .v { font: 600 15px var(--mono); margin-top: 3px; white-space: nowrap; }
.stat .v small { font-size: 10.5px; font-weight: 400; color: var(--fg-faint); margin-left: 3px; }

/* ----------------------------------------------------- the router fan-out */

/* --route is set on the card once the router has decided; until then the rail is grey */
.chart {
  --rail: color-mix(in srgb, var(--route, var(--line-2)) 55%, var(--line));
  --surface: var(--bg-2);
  padding: 14px 18px 20px;
}

.router { display: flex; justify-content: center; }
.router svg { display: block; width: 100%; max-width: 720px; height: auto; overflow: visible; }
.router .edge, .router .merge { fill: none; stroke: var(--line-2); stroke-width: 1.6; transition: stroke .3s, opacity .3s, stroke-width .3s; }
.router .merge { opacity: 0; }
.router .box { fill: var(--bg-3); stroke: var(--line-2); stroke-width: 1.4; transition: fill .3s, stroke .3s; }
.router text { font-family: var(--mono); fill: var(--fg-faint); transition: fill .3s; }
.router .t1 { font-size: 12px; font-weight: 600; fill: var(--fg-dim); }
.router .t2 { font-size: 9.5px; }
.router .cls .box { stroke: var(--fg-faint); }
.router .cls .t1 { fill: var(--fg); }
.router .chip { transition: opacity .3s; }

/* waiting for the router's decision: every branch is still possible */
.router svg.deciding .edge { stroke-dasharray: 3 6; animation: dash9 1s linear infinite; }
.router svg.deciding .cls .box { animation: breathe 1.2s ease-in-out infinite; }
@keyframes dash9 { to { stroke-dashoffset: -9; } }
@keyframes dash12 { to { stroke-dashoffset: -12; } }
@keyframes breathe { 50% { stroke: var(--accent-2); } }

/* decided: the chosen branch lights up in its route colour, the rest fall back */
.router svg.decided .chip:not(.on) { opacity: .45; }
.router svg.decided .edge:not(.on) { opacity: .3; }
.router .chip.on .box {
  stroke: var(--rc); stroke-width: 2;
  fill: color-mix(in srgb, var(--rc) 24%, var(--bg-3));
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--rc) 75%, transparent));
}
.router .chip.on .t1 { fill: #fff; }
.router .chip.on .t2 { fill: color-mix(in srgb, var(--rc) 70%, #fff); }
.router .edge.on, .router .merge.on { stroke: var(--rc); stroke-width: 2.6; opacity: 1; }
.card.live .router .edge.on, .card.live .router .merge.on { stroke-dasharray: 7 5; animation: dash12 .5s linear infinite; }

/* ------------------------------------------------- the steps, as a flow */

/* A lane is one agent's steps, top to bottom. The rail is a single line drawn behind
   the whole column; opaque nodes cover it, so it only shows in the gaps. */
.flow {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  background: linear-gradient(var(--rail), var(--rail)) center top / 2px 100% no-repeat;
}
.flow > * { position: relative; }
.flow > * + *::before, .flow.main > :first-child::before {
  content: ""; position: absolute; left: 50%; top: -8px; margin-left: -5px;
  border: 5px solid transparent; border-bottom-width: 0; border-top-color: var(--rail);
}
.flow.main:empty { height: 26px; }

.fn {
  width: min(100%, 640px); background: var(--bg-3);
  border: 1px solid var(--line-2); border-left: 3px solid var(--kc, var(--line-2));
  border-radius: 9px; padding: 8px 12px; font-size: 12.5px;
}
.fn-head { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.fn-kind {
  flex: none; font: 700 9.5px var(--mono); letter-spacing: .08em; padding: 2px 6px; border-radius: 4px;
  color: var(--kc, var(--fg-dim)); background: color-mix(in srgb, var(--kc, #fff) 15%, transparent);
}
.fn-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.fn-title b { color: #fff; }
.fn-title .dim { color: var(--fg-dim); font-weight: 400; }
.fn-dur { flex: none; font: 10.5px var(--mono); color: var(--fg-faint); white-space: nowrap; }
.fn-sub { margin-top: 3px; font-size: 11.5px; color: var(--fg-dim); line-height: 1.45; overflow-wrap: anywhere; }
.fn-sub.mono { font-size: 10.5px; color: var(--fg-faint); }
.fn-res { margin-top: 3px; font: 10.5px var(--mono); color: var(--fg-faint); }
.fn-foot { margin-top: 9px; font: 10.5px var(--mono); color: var(--fg-faint); }
.fn-foot .hit { color: var(--warn); }
.fn-sub:empty, .fn-res:empty, .fn-foot:empty { display: none; }
.fn-more { margin-top: 8px; border-top: 1px dashed var(--line-2); padding-top: 8px; }
.fn.open > .fn-head .fn-title::after, .fn.can-open > .fn-head .fn-title::after { content: " ▸"; color: var(--fg-faint); font-weight: 400; }
.fn.open > .fn-head .fn-title::after { content: " ▾"; }

.fn.running { border-color: color-mix(in srgb, var(--kc, #fff) 60%, var(--line-2)); animation: glow 1.3s ease-in-out infinite; }
.fn.running > .fn-head .fn-dur::after {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 5px; vertical-align: -1px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--kc, var(--accent)); animation: spin .7s linear infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--kc, #fff) 16%, transparent); } }
.flash { animation: flash 1.1s ease-out; border-radius: 9px; }  /* clicked from the waterfall */
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-2); } 100% { box-shadow: 0 0 0 3px transparent; } }

.fn.k-model { padding: 6px 12px; }
.fn.k-blocked, .fn.k-guard { border-style: dashed; border-left-style: solid; }
.fn.k-blocked .fn-sub { color: var(--bad); }
.fn.k-route .fn-title { font-family: var(--mono); font-size: 13.5px; }
.fn.k-route .fn-title b { color: var(--route); }
.fn.k-answer { width: 100%; padding: 12px 16px; }
.fn.k-answer > .fn-head { cursor: default; }
.fn.k-answer .fn-title { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }

/* tool calls the model asked for in one turn run concurrently: drawn side by side */
.grp { align-self: stretch; display: flex; flex-direction: column; align-items: center; }
.grp-label { display: none; }
.grp-in { display: contents; }
.grp.par {
  align-items: stretch; background: var(--surface);
  border: 1px dashed var(--rail); border-radius: 11px; padding: 8px 10px 10px;
}
.grp.par > .grp-label {
  display: block; text-align: center; margin-bottom: 7px;
  font: 600 9.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-faint);
}
.grp.par > .grp-in { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 9px; align-items: start; }
.grp.par.wide > .grp-in { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grp.par .fn, .flow.sub .fn { width: 100%; }

/* a subagent is a node with its own lane inside it */
.fn.k-sub { --surface: var(--bg-3); width: 100%; padding: 10px 12px 11px; }
.fn.k-sub > .fn-head .fn-title { font-family: var(--mono); }
.fn.k-sub > .fn-sub { cursor: pointer; }
.flow.sub { --rail: color-mix(in srgb, var(--c-analysis) 45%, var(--line)); margin-top: 11px; gap: 15px; }
.flow.sub .fn { background: var(--bg-2); }
.flow.sub:empty { display: none; }

.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }

.todos { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.todos li { display: flex; gap: 7px; align-items: baseline; font-size: 11.5px; color: var(--fg-dim); }
.todos .tick { flex: none; width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--fg-faint); position: relative; top: 1.5px; }
.todos .st-in_progress .tick { border-color: var(--c-analysis); background: linear-gradient(90deg, var(--c-analysis) 50%, transparent 50%); }
.todos .st-completed .tick { border-color: var(--ok); background: var(--ok); }
.todos .st-completed { color: var(--fg-faint); text-decoration: line-through; text-decoration-color: var(--line-2); }

/* expanded detail: what went in and what came back */
.io-k { font: 600 9.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fg-faint); margin: 8px 0 4px; }
.io-k:first-child { margin-top: 0; }
.out {
  margin: 0; font: 11px/1.5 var(--mono); color: var(--fg-dim); white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; max-height: 240px; overflow: auto;
}
.trunc { font: 10.5px var(--mono); color: var(--fg-faint); margin-top: 4px; }

/* retrieved passages: one compact row each, text clamped until clicked */
.passages { display: flex; flex-direction: column; gap: 6px; }
.passage { border: 1px solid var(--line); border-radius: 7px; background: var(--bg); padding: 7px 10px; cursor: pointer; }
.passage:hover { border-color: var(--line-2); }
.p-head { display: flex; align-items: center; gap: 7px; font: 10.5px var(--mono); color: var(--fg-faint); }
.p-src { color: var(--fg); font-weight: 600; }
.p-sec { border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; color: var(--c-knowledge); }
.p-hits { color: var(--warn); }
.p-bar { width: 54px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.p-bar i { display: block; height: 100%; background: var(--c-knowledge); }
.p-text { margin-top: 5px; font-size: 11.5px; line-height: 1.5; color: var(--fg-dim); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.passage.open .p-text { display: block; }

/* the answer */
.md { font-size: 13.5px; line-height: 1.65; color: var(--fg); margin-top: 8px; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h4 { margin: 12px 0 4px; font-size: 13.5px; }
.md h4:first-child { margin-top: 0; }
.md ul { margin: 6px 0; padding-left: 20px; }
.md li { margin: 3px 0; }
.md b { color: #fff; }
.md code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.md .cite { font: 11px var(--mono); color: var(--c-knowledge); white-space: nowrap; }
.fn-more .md { font-size: 12px; color: var(--fg-dim); margin-top: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font: 10.5px var(--mono); border-radius: 999px; padding: 2px 9px;
  border: 1px solid color-mix(in srgb, var(--bc) 45%, transparent); background: color-mix(in srgb, var(--bc) 12%, transparent); color: var(--bc);
}
.badge.pass { --bc: var(--ok); }
.badge.fail { --bc: var(--bad); }
.badge .why { color: var(--fg-faint); }

/* --------------------------------------------------------------- sections */

.sec { border-top: 1px solid var(--line); }
.sec > summary {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; cursor: pointer; list-style: none; user-select: none;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: "▸"; color: var(--fg-faint); font-size: 11px; width: 9px; }
.sec[open] > summary::before { content: "▾"; }
.sec h4 { margin: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--fg-dim); font-weight: 600; }
.sec .count { font: 10.5px var(--mono); color: var(--fg-faint); }
.sec-body { padding: 0 16px 14px; }

/* trace waterfall: one row per span, bars on a shared time axis */
.wf { font: 10.5px var(--mono); max-height: 330px; overflow-y: auto; }
.wf-axis, .wf-row { display: grid; grid-template-columns: minmax(150px, 250px) 1fr 52px; gap: 10px; align-items: center; }
.wf-axis { color: var(--fg-faint); position: sticky; top: 0; background: var(--bg-2); padding-bottom: 4px; z-index: 1; }
.wf-ticks { display: flex; justify-content: space-between; }
.wf-row { height: 19px; border-radius: 4px; cursor: pointer; }
.wf-row:hover { background: var(--bg-3); }
.wf-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-dim); }
.wf-l::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; background: var(--kc, var(--fg-faint)); }
.wf-t {
  position: relative; height: 9px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 25%) , rgba(255,255,255,.02);
}
.wf-b { position: absolute; top: 0; bottom: 0; min-width: 2px; border-radius: 2px; background: var(--kc, var(--fg-faint)); }
.wf-b.running { animation: breatheBar 1s ease-in-out infinite; }
@keyframes breatheBar { 50% { opacity: .45; } }
.wf-row.depth0 .wf-b { opacity: .55; }
.wf-d { text-align: right; color: var(--fg-faint); }
.wf-meta { margin-top: 10px; font: 10.5px var(--mono); color: var(--fg-faint); line-height: 1.7; overflow-wrap: anywhere; }
.wf-meta b { color: var(--fg-dim); font-weight: 400; }

/* router comparison */
.cmp { display: flex; flex-direction: column; gap: 6px; }
.cmp-row {
  display: grid; grid-template-columns: 170px 1fr 22px; gap: 12px; align-items: start;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3); padding: 8px 11px; font-size: 12px;
}
.cmp-row.win { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.cmp-row .who { font: 600 12px var(--mono); }
.cmp-row .who small { display: block; font-weight: 400; font-size: 10.5px; color: var(--fg-faint); margin-top: 2px; }
.cmp-row .why { color: var(--fg-dim); line-height: 1.5; }
.cmp-row .why .rt { font: 600 12px var(--mono); }
.cmp-row .mark { font-size: 13px; color: var(--fg-faint); text-align: center; }
.cmp-row.win .mark { color: var(--ok); }
.cmp-note { margin: 9px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--fg-faint); }
.cmp-note code { font-family: var(--mono); font-size: 10.5px; color: var(--fg-dim); }
.cmp-note b { color: var(--fg-dim); }

.foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 16px; border-top: 1px solid var(--line); }
.foot .runid { font: 10.5px var(--mono); color: var(--fg-faint); cursor: pointer; }
.foot .runid:hover { color: var(--fg-dim); }

.err-box {
  border: 1px solid var(--bad); border-left: 3px solid var(--bad); border-radius: 9px; padding: 10px 13px;
  font: 12px var(--mono); color: var(--bad); background: rgba(248,113,113,.06); width: min(100%, 640px); overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- composer */

.composer { display: flex; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--bg-2); }
.composer input {
  flex: 1; font: inherit; font-size: 14px; color: var(--fg); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; outline: none;
}
.composer input:focus { border-color: var(--line-2); box-shadow: 0 0 0 3px rgba(255,59,48,.12); }
.composer button {
  font: inherit; font-size: 14px; font-weight: 600; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border: none; border-radius: 9px; padding: 11px 22px; cursor: pointer;
}
.composer button:hover { filter: brightness(1.08); }
.composer button:disabled { opacity: .5; cursor: default; filter: none; }

/* ----------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: 10px 13px; font-size: 12px; max-width: 380px;
  box-shadow: 0 8px 26px rgba(0,0,0,.45); animation: rise .2s ease-out;
}
.toast b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-faint); margin-bottom: 3px; }
.toast .sub { color: var(--fg-dim); line-height: 1.45; overflow-wrap: anywhere; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side, .legend { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ------------------------------------------------------------ tabs & views */

.tabs { display: flex; gap: 4px; }
.tab {
  font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--fg-faint);
  background: none; border: 1px solid transparent; border-radius: 7px; padding: 6px 12px; cursor: pointer;
}
.tab:hover { color: var(--fg-dim); background: var(--bg-3); }
.tab.on { color: var(--fg); background: var(--bg-3); border-color: var(--line-2); }
.tab-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; }
.view { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }

/* ------------------------------------------------------------- evals view */
/* Chart tokens: the validated pair for the two router prompts (fixed per prompt),
   chart chrome one step off the dark surface. See the dataviz notes in evals.js. */
:root { --series-1: #3987e5; --series-2: #d95926; --deemph: #3a4252; --grid: #1f2633; --axis: #383f4d; }

.ev-page { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.ev-intro h2 { margin: 0 0 4px; font-size: 18px; }
.ev-sub { margin: 0; font-size: 12px; color: var(--fg-faint); line-height: 1.5; }
.ev-note { margin: 8px 0; font-size: 12px; color: var(--warn); line-height: 1.5; }
.ev-empty { color: var(--fg-faint); font-size: 12.5px; }
.ev-sec { border: 1px solid var(--line); border-radius: 13px; background: var(--bg-2); padding: 16px 18px 18px; }
.ev-head { margin-bottom: 12px; }
.ev-head h3 { margin: 0 0 3px; font-size: 14px; }
.ev-sec h4 { margin: 0 0 8px; font-size: 12.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ev-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }

.ev-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ev-tile { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); padding: 14px 16px; }
.ev-tile-k { font-size: 12px; color: var(--fg-dim); }
.ev-tile-v { font-size: 26px; font-weight: 600; margin: 6px 0 4px; letter-spacing: -.3px; }
.ev-tile-d { font-size: 11.5px; color: var(--fg-faint); line-height: 1.45; }

.ev-chart { display: block; width: 100%; height: auto; overflow: visible; }
.ev-chart.narrow { max-width: 460px; }
.ev-grid { stroke: var(--grid); stroke-width: 1; }
.ev-mark { stroke: var(--axis); stroke-width: 1; }
.ev-axis { fill: var(--fg-faint); font-size: 10.5px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.ev-end { fill: var(--fg-dim); font-size: 11px; font-family: var(--sans); font-weight: 600; }
.ev-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ev-dot { stroke-width: 2; }
.ev-hit { fill: transparent; cursor: pointer; outline: none; }
.ev-hit:focus-visible { stroke: var(--fg-dim); stroke-width: 1; }
.ev-col { fill: var(--deemph); }
.ev-col.best { fill: var(--series-1); }
.ev-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 11.5px; color: var(--fg-dim); }
.ev-lg { display: inline-flex; align-items: center; gap: 6px; }
.ev-lg-line { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }
.ev-lg-ring { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--fg-faint); display: inline-block; box-sizing: border-box; }
.ev-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: 0; }

.ev-cm { border-collapse: separate; border-spacing: 2px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ev-cm caption { caption-side: top; text-align: left; font-size: 11.5px; color: var(--fg-faint); padding-bottom: 6px; }
.ev-cm th { font-weight: 500; color: var(--fg-faint); font-family: var(--mono); font-size: 10.5px; padding: 3px 6px; text-align: right; }
.ev-cm tr:first-child th { text-align: center; }
.ev-cm th.ev-cm-corner { font-family: var(--sans); }
.ev-cell { width: 46px; height: 32px; text-align: center; border-radius: 4px; background: var(--bg-3); font-weight: 600; cursor: default; outline: none; }
.ev-cell:hover, .ev-cell:focus-visible { box-shadow: 0 0 0 2px var(--fg-dim); }
.ev-cm.small .ev-cell { width: 70px; }

.ev-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ev-table th { text-align: left; font-weight: 600; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-faint); padding: 7px 8px; border-bottom: 1px solid var(--line); }
.ev-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--fg-dim); }
.ev-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-table td.mono, .ev-table .mono { font-family: var(--mono); font-size: 11.5px; }
.ev-row { cursor: pointer; }
.ev-row:hover td, .ev-row:focus-visible td { background: var(--bg-3); outline: none; }
.ev-row.on td { background: rgba(57,135,229,.10); }
.ev-table tr.used td { color: var(--fg); }
.ev-q td { font-size: 12px; }
.ev-id { color: var(--fg-faint); font-size: 10.5px; }
.ev-reason { font-size: 11.5px; color: var(--fg-dim); line-height: 1.5; white-space: pre-wrap; }
.ev-ref { margin: 6px 0 0; font-size: 11.5px; color: var(--fg-faint); line-height: 1.5; }
.ev-pill { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; font-family: var(--mono); }
.ev-pill.pass { background: rgba(52,211,153,.16); color: var(--ok); }
.ev-pill.fail { background: rgba(248,113,113,.16); color: var(--bad); }
.ev-chip { display: inline-block; margin-left: 6px; font-family: var(--mono); font-size: 10px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--fg-dim); }
.ev-chip.warn { border-color: rgba(251,191,36,.5); color: var(--warn); }
.ev-bar { display: inline-block; width: 44px; height: 4px; border-radius: 2px; background: var(--grid); margin-right: 6px; vertical-align: middle; overflow: hidden; }
.ev-bar i { display: block; height: 100%; background: var(--series-1); }
.ev-detail { margin-top: 16px; }
.ev-detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ev-detail-head h4 { margin: 0; }
.ev-filter { font-size: 12px; color: var(--fg-dim); display: inline-flex; align-items: center; gap: 4px; }
.ev-filter select { font: inherit; font-size: 12px; background: var(--bg-3); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.ev-filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.ev-disagree details { border-top: 1px solid var(--line); padding: 7px 0; font-size: 12px; }
.ev-disagree summary { cursor: pointer; color: var(--fg-dim); }
.ev-disagree p { margin: 6px 0 0; font-size: 11.5px; color: var(--fg-dim); line-height: 1.5; }
.ev-prompt { margin: 0; max-height: 280px; overflow: auto; font: 11px/1.55 var(--mono); color: var(--fg-dim); white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.ev-live-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.ev-live-stat { font-size: 12px; color: var(--fg-dim); margin-bottom: 8px; }
.ev-live-stat b { font-size: 20px; color: var(--fg); margin-right: 4px; }

/* the one shared tooltip: value first, label after, line-key swatch */
.tip {
  position: fixed; z-index: 200; pointer-events: none; max-width: 320px;
  background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); font-size: 12px;
}
.tip-title { color: var(--fg-faint); font-size: 11px; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-row b { color: var(--fg); font-variant-numeric: tabular-nums; }
.tip-label { color: var(--fg-dim); }
.tip-key { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
