:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #f0f2ec;
  --text: #15181b;
  --muted: #5a6168;
  --line: #dde1d8;
  --accent: #4a7a00;        /* NVIDIA-ish green, darkened for contrast on white */
  --accent-bright: #76b900;
  --accent-ink: #ffffff;
  --good: #2f7d32;
  --warn: #9a6200;
  --bad: #b3261e;
  --bar-bg: #e6e9e1;
  --focus: #2b6cb0;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 12px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113; --panel: #171a1d; --panel-2: #1e2226; --text: #e9ecef; --muted: #a2aab2;
    --line: #2b3035; --accent: #8fd11a; --accent-bright: #76b900; --accent-ink: #0d1200;
    --good: #6cc56f; --warn: #e3a63a; --bad: #ff8a80; --bar-bg: #262b30; --focus: #7cb7ff;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1113; --panel: #171a1d; --panel-2: #1e2226; --text: #e9ecef; --muted: #a2aab2;
  --line: #2b3035; --accent: #8fd11a; --accent-bright: #76b900; --accent-ink: #0d1200;
  --good: #6cc56f; --warn: #e3a63a; --bad: #ff8a80; --bar-bg: #262b30; --focus: #7cb7ff;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: var(--panel); }
.top-inner { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
html, body { overflow-x: hidden; }
.logo { width: 36px; height: 36px; flex: none; }
.logo rect { fill: var(--accent-bright); }
.logo path { fill: none; }
h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.top-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--accent-bright); }
.dot.warn { background: var(--warn); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Panels */
main { padding-top: 20px; padding-bottom: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 10px; }
h2.inline { display: inline; font-size: 16px; }
h3 { margin: 0; font-size: 15px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 13px; }

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs button { border: 0; background: transparent; color: var(--text); padding: 7px 14px; font: inherit; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.preset { text-align: left; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 6px; }
.preset:hover { border-color: var(--accent); }
.preset[aria-checked="true"] { border: 2px solid var(--accent); padding: 13px; background: var(--panel); }
.preset .title { font-weight: 650; }
.preset .story { color: var(--muted); font-size: 13.5px; margin: 0; }
.preset .meta { font-size: 12px; color: var(--muted); margin-top: auto; }

.custom { display: grid; gap: 12px; }
.custom label, .opts label { display: grid; gap: 4px; font-weight: 600; font-size: 13.5px; }
.req { font-weight: 400; color: var(--muted); font-size: 12px; }
input, textarea { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea.mono { font-family: var(--mono); font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.run-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.checks { display: grid; gap: 6px; margin-top: 10px; }
.opts label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }
.think { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.think.on { border-color: var(--warn); color: var(--warn); }
.think.photo { border-color: var(--good); color: var(--good); }
.ladder tr.photo-row th, .ladder tr.photo-row td { border-top: 2px dashed var(--line); }
.trunc { display: block; font-size: 11.5px; color: var(--warn); }
.opts summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.opts-grid { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 12px; padding-top: 6px; }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px 22px; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; }
button.primary:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, a.ghost { text-decoration: none; display: inline-block; background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; }
.error { color: var(--bad); margin: 10px 0 0; }
.recorded { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); }

/* Ladder */
.meter { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meter-track { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--bar-bg); overflow: hidden; }
.meter-track span { display: block; height: 100%; width: 0; background: var(--accent-bright); transition: width .3s; }
.story { margin: 0 0 8px; color: var(--muted); }
.bar-line { margin: 0 0 12px; font-weight: 600; }
.replay { margin: 0 0 8px; display: inline-block; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--warn); color: var(--warn); font-variant-numeric: tabular-nums; }
.replay[hidden] { display: none; }
.costs { display: grid; gap: 6px; margin: 0 0 16px; }
.cost { display: grid; grid-template-columns: minmax(150px, 220px) 1fr minmax(120px, 230px); gap: 10px; align-items: center; font-size: 13.5px; }
.cost .cname { font-weight: 650; white-space: nowrap; }
.cost .ctrack { height: 14px; background: var(--bar-bg); border-radius: 4px; overflow: hidden; }
.cost .cfill { display: block; height: 100%; background: color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 4px; transition: width .5s ease; }
.cost.ref .cfill { background: var(--muted); }
.cost.pass .cfill { background: var(--good); }
.cost.fail .cfill { background: var(--warn); }
.cost.run .cfill { background: var(--focus); }
.cost.empty { opacity: .5; }
.cost .cval { font-variant-numeric: tabular-nums; color: var(--muted); }
.cost.pass .cval { color: var(--good); font-weight: 700; }
@media (max-width: 720px) { .cost { grid-template-columns: 1fr; gap: 2px; } }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.ladder { width: 100%; border-collapse: collapse; min-width: 720px; }
.ladder th, .ladder td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.ladder th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ladder .sub { font-weight: 400; }
.ladder .num { text-align: right; font-variant-numeric: tabular-nums; }
.ladder tr.chosen td { background: color-mix(in srgb, var(--accent-bright) 12%, transparent); }
.tier-name { font-weight: 650; }
.tier-model { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.score { display: grid; gap: 4px; min-width: 110px; }
.score .v { font-variant-numeric: tabular-nums; font-weight: 650; }
.score .track { position: relative; height: 6px; background: var(--bar-bg); border-radius: 3px; overflow: visible; }
.score .fill { position: absolute; inset: 0 auto 0 0; background: var(--muted); border-radius: 3px; }
.score .fill.pass { background: var(--good); }
.score .fill.fail { background: var(--warn); }
.score .mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--text); }
.score .fill.ref { background: var(--accent, var(--muted)); }
.score .band { position: absolute; top: -3px; height: 12px; border: 1px solid var(--text); border-radius: 2px; opacity: 0.55; z-index: 1; box-sizing: border-box; }
.score .lbl { font-size: 11.5px; color: var(--muted); }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.chip.run { border-color: var(--accent); color: var(--accent); }
.chip.pass { background: var(--good); border-color: var(--good); color: #fff; }
.chip.fail { border-color: var(--warn); color: var(--warn); }
.chip.ref { background: var(--panel-2); }
@media (prefers-reduced-motion: no-preference) {
  .chip.run::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; animation: pulse 1s infinite alternate; }
}
@keyframes pulse { from { opacity: .25; } to { opacity: 1; } }

/* Rounds */
.tier-rounds { margin-top: 12px; }
.tier-rounds h3 { margin-bottom: 6px; }
.round { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 8px; background: var(--panel-2); }
.round-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.cands { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.cand { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: start; }
.cand .s { font-weight: 700; font-variant-numeric: tabular-nums; }
.cand .s.best { color: var(--good); }
.cand details summary { cursor: pointer; font-size: 13.5px; }
.cand pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }

/* Verdict */
.verdict { border-width: 2px; border-color: var(--accent); }
.headline { font-size: clamp(24px, 4vw, 34px); font-weight: 750; letter-spacing: -.02em; margin: 0 0 6px; }
.sentence { font-size: 16px; margin: 0 0 16px; max-width: 75ch; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0 0 16px; }
.stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stats dt { font-size: 12.5px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats dd .vs { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.savings { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; }
.savings label { display: grid; gap: 4px; font-weight: 600; font-size: 13.5px; flex: 0 1 200px; }
.savings input { font-variant-numeric: tabular-nums; }
.sav-out { margin: 0; flex: 1 1 320px; font-size: 15px; font-variant-numeric: tabular-nums; }
.sav-big { display: block; margin-top: 4px; font-size: 18px; font-weight: 700; color: var(--good); }
.sav-note { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.prompt-box summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; margin: 6px 0 0; }
#v-prompt { white-space: pre-wrap; word-break: break-word; }
.snippet { margin-top: 12px; }
.snippet-head { display: flex; justify-content: space-between; align-items: center; }
.ft { border: 1px dashed var(--warn); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.ft p { margin: 0 0 8px; }
.share { font-size: 14px; }

.log { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding-left: 22px; margin: 10px 0 0; max-height: 280px; overflow-y: auto; }
details > summary { list-style-position: inside; }
.foot { color: var(--muted); font-size: 13px; padding-bottom: 32px; }

@media (max-width: 720px) {
  .row2, .opts-grid { grid-template-columns: 1fr; }
  .run-bar { flex-direction: column; align-items: stretch; }
  button.primary { width: 100%; }
  .panel { padding: 14px; }
}

.photo-check { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; }
.photo-check.fail { border-left-color: var(--warn); }
.photo-check h3 { margin: 0 0 4px; font-size: 15px; }
.photo-check p { margin: 4px 0; }
.photo-check .pc-call { font-weight: 700; font-size: 17px; }
.photo-check.pass .pc-call { color: var(--good); }

.guess-check { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; }
.guess-check.fail { border-left-color: var(--bad); }
.guess-check h3 { margin: 0 0 4px; font-size: 15px; }
.guess-check.fail h3 { color: var(--bad); }
.guess-check p { margin: 4px 0; }
.savings[hidden], .squeeze[hidden], .cert[hidden], .photo-check[hidden], .guess-check[hidden], .snippet[hidden], .prompt-box[hidden] { display: none; }

.squeeze { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; }
.squeeze.fail { border-left-color: var(--warn); }
.squeeze h3 { margin: 0 0 4px; font-size: 15px; }
.squeeze p { margin: 4px 0; }
.squeeze .sq-call { font-weight: 700; font-size: 17px; }
.squeeze.pass .sq-call { color: var(--good); }
.squeeze ol { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.squeeze li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; padding: 6px 8px; border-radius: 6px; background: var(--panel); }
.squeeze li.drop { opacity: .55; }
.squeeze li .sq-l { font-weight: 600; }
.squeeze li .sq-c { font-variant-numeric: tabular-nums; text-align: right; }
.squeeze li .sq-t { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* escalation chain: share of rows the cheap pair settles vs sends to Ultra */
.chain .split { display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin: 8px 0 4px; background: var(--bar-bg); }
.chain .split .ag { background: var(--good); }
.chain .split .es { background: var(--warn); }
.chain .key { font-size: 12px; color: var(--muted); }
.audit-ex { font-size: 12.5px; margin: 6px 0 0; padding-left: 18px; }
.audit-ex li { margin: 2px 0; }
.audit-ex code { font-size: 12px; }

/* proof certificate: the one card to share */
.cert { border: 2px solid var(--good); border-radius: 12px; padding: 16px 18px; margin: 0 0 18px; background: var(--panel); }
.cert.keep { border-color: var(--warn); }
.cert.none { border-color: var(--bad); }
.cert .c-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.cert .c-kick { font: 700 12px var(--mono); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.cert .c-call { font-size: 24px; font-weight: 800; margin: 4px 0 12px; line-height: 1.2; }
.cert.pass .c-call { color: var(--good); }
.cert.keep .c-call { color: var(--warn); }
.cert .c-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; }
.cert .c-col { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.cert .c-col h4 { margin: 0 0 6px; font: 700 11.5px var(--mono); letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.cert .c-big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--good); }
.cert ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 13.5px; }
.cert li::before { content: "✓ "; color: var(--good); font-weight: 700; }
.cert li.x::before { content: "✗ "; color: var(--bad); }
.cert .c-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) { .cert .c-grid { grid-template-columns: 1fr; } }
body.cert-only main > section:not(#verdict-panel), body.cert-only #verdict-panel > :not(.cert):not(.panel-head) { display: none !important; }
