/* Auto-router playground — dark-first, one accent, hairline structure. */

:root {
  color-scheme: dark;
  --plane: #0c0d0f;
  --plane-2: #0f1113;
  --surface: #16181b;
  --surface-2: #1c1f23;
  --ink: #f3f4f5;
  --ink-2: #b6bcc4;
  --muted: #838b95;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --accent: #4f97f0;
  --accent-ink: #0a1220;
  --accent-soft: rgba(79, 151, 240, .14);
  --good: #23b37d;
  --warn: #e0a02a;
  --hot: #e07a4a;
  --frontier: #d7688f;
  --p2p: #9085e9;

  /* chart roles, from the validated categorical palette (dark steps) */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --grid: #2c2c2a;
  --axis: #383835;

  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1180px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --plane: #f7f7f5;
  --plane-2: #f2f2ef;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --ink: #101215;
  --ink-2: #464b52;
  --muted: #6d747d;
  --line: rgba(10, 12, 15, .10);
  --line-strong: rgba(10, 12, 15, .18);
  --accent: #1f6fd0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 111, 208, .10);
  --good: #0d7a55;
  --warn: #9a6b05;
  --hot: #b1521f;
  --frontier: #a8305c;
  --p2p: #5b4bc4;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 50% -180px, rgba(79, 151, 240, .16), transparent 70%)
      no-repeat,
    var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

html[data-theme="light"] body {
  background:
    radial-gradient(900px 420px at 50% -240px, rgba(31, 111, 208, .07), transparent 72%),
    var(--plane);
  background-attachment: scroll, scroll;
  background-repeat: no-repeat, repeat;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5rem; font-weight: 640; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1rem; }

.wrap { width: min(100% - 2.4rem, var(--wrap)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -999px; top: .5rem; z-index: 50;
  background: var(--accent); color: var(--accent-ink); padding: .5rem .8rem; border-radius: 8px;
}
.skip:focus { left: .8rem; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--plane) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 1rem; height: 60px; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 620; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand-text { font-size: .98rem; }
.brand-dim { color: var(--muted); font-weight: 480; }
.nav { display: flex; gap: .2rem; margin-left: auto; white-space: nowrap; }
.nav a {
  color: var(--ink-2); padding: .4rem .66rem; border-radius: 8px; font-size: .92rem;
  font-weight: 520;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.topbar-actions { display: flex; align-items: center; gap: .45rem; }
.icon-btn, .ghost-btn {
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  border-radius: 8px; cursor: pointer; font: inherit; font-size: .88rem;
  padding: .36rem .6rem; display: inline-flex; align-items: center; gap: .35rem;
}
.icon-btn { padding: .36rem .42rem; }
.icon-btn:hover, .ghost-btn:hover { border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.p2p-pill {
  font-size: .76rem; padding: .22rem .55rem; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--p2p) 45%, transparent);
  color: var(--p2p); white-space: nowrap;
}

main { flex: 1 0 auto; padding-bottom: 4rem; }

/* ------------------------------------------------------------------ hero */
.hero { padding: clamp(2.4rem, 7vw, 4.6rem) 0 1.4rem; }
.hero h1 em { font-style: normal; color: var(--accent); }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  color: var(--muted); font-weight: 600; margin-bottom: .7rem;
}
.lede { color: var(--ink-2); font-size: 1.06rem; max-width: 68ch; }
.lede em { font-style: italic; color: var(--ink); }
.page-head { padding: clamp(2rem, 6vw, 3.4rem) 0 1.2rem; }

/* -------------------------------------------------------------- composer */
.composer-wrap { margin-top: .6rem; }
.composer {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem .5rem .5rem; box-shadow: 0 18px 46px -30px rgba(0, 0, 0, .9);
  transition: border-color .15s ease;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.composer textarea {
  width: 100%; border: 0; background: transparent; color: var(--ink); resize: none;
  font: inherit; padding: .7rem .75rem .2rem; outline: none; min-height: 84px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar {
  display: flex; align-items: center; gap: .8rem; padding: .35rem .5rem .2rem;
  flex-wrap: wrap;
}
.counter { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; margin-right: auto; }
.row-gap { display: flex; gap: .5rem; align-items: center; }
.primary-btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px;
  padding: .55rem .95rem; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn[disabled] { opacity: .55; cursor: progress; }

.examples { display: flex; flex-wrap: wrap; gap: .45rem; margin: .9rem 0 .4rem; }
.example {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: .34rem .78rem; font: inherit; font-size: .86rem; cursor: pointer;
}
.example:hover { border-color: var(--line-strong); color: var(--ink); }
.example b { font-weight: 600; color: var(--ink); }
.example span { color: var(--muted); }
.limit-note { color: var(--muted); font-size: .82rem; margin-top: .3rem; }

/* ----------------------------------------------------------------- cards */
.stage { margin-top: 2.2rem; display: grid; gap: 1rem; }
.grid-decision { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .6rem; padding: .78rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.card-head h2 { margin: 0; font-size: .92rem; letter-spacing: -.01em; }
.card-body { padding: 1rem; }
.chip {
  margin-left: auto; font-size: .76rem; padding: .18rem .5rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap;
}
.chip-quiet { color: var(--muted); }
.chip-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.muted { color: var(--muted); }

/* classification */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem .9rem; align-items: center; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; font-size: .92rem; }
.topline { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.topline .big { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; }
.prob-list { display: grid; gap: .3rem; margin: .7rem 0 0; }
.prob {
  display: grid; grid-template-columns: 8.5rem 1fr 3rem; gap: .5rem; align-items: center;
  font-size: .84rem;
}
.prob .bar { height: 7px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.prob .bar i { display: block; height: 100%; border-radius: 4px; background: var(--s1); }
.prob .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { display: flex; gap: 4px; margin-top: .2rem; }
.meter i { height: 8px; flex: 1; border-radius: 3px; background: var(--grid); }
.meter i.on { background: var(--accent); }
.flags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.flag {
  font-size: .78rem; border: 1px solid var(--line); border-radius: 7px; padding: .18rem .5rem;
  color: var(--muted);
}
.flag.on { color: var(--ink); border-color: var(--line-strong); }
.flag.off { opacity: .42; }

/* decision */
.decision-model { display: flex; align-items: center; gap: .6rem; margin-bottom: .2rem; }
.decision-model .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.decision-model strong { font-size: 1.35rem; letter-spacing: -.02em; }
.decision-reason { color: var(--ink-2); font-size: .95rem; }
.saving {
  margin-top: .9rem; padding: .75rem .85rem; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.saving .num { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; }
.saving .sub { color: var(--ink-2); font-size: .85rem; }

/* tables */
.table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
/* A cut-off column has to look cut off, not broken. */
@media (max-width: 900px) {
  .table-scroll { mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); }
}
table.candidates { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.candidates th, table.candidates td {
  padding: .6rem .85rem; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.candidates thead th {
  color: var(--muted); font-weight: 560; font-size: .78rem; white-space: nowrap;
  position: sticky; top: 0; background: var(--surface);
}
.th-sub { display: block; font-weight: 420; color: var(--muted); opacity: .8; font-size: .72rem; }
table.candidates td.num, table.candidates th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.candidates tbody tr.is-chosen { background: var(--accent-soft); }
table.candidates tbody tr.is-chosen td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.candidates tbody tr:last-child td { border-bottom: 0; }
.m-name { display: flex; align-items: center; gap: .5rem; }
.m-name .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.m-name b { font-weight: 600; }
.m-org { display: block; color: var(--muted); font-size: .76rem; }
.badge {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: .1rem .38rem;
  border-radius: 5px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge-free { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.badge-cheap { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge-strong { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge-frontier { color: var(--frontier); border-color: color-mix(in srgb, var(--frontier) 40%, transparent); }
.badge-p2p { color: var(--p2p); border-color: color-mix(in srgb, var(--p2p) 45%, transparent); }
.weak { color: var(--warn); cursor: help; border-bottom: 1px dotted currentColor; }
.table-foot { color: var(--muted); font-size: .8rem; padding: .7rem 1rem 0; margin: 0 0 .8rem; }
td.basis {
  color: var(--muted); font-size: .78rem; max-width: 22rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; cursor: help;
}
table.candidates td:first-child { min-width: 11rem; }
.price-stack { display: block; font-variant-numeric: tabular-nums; }
.price-stack span { color: var(--muted); }

/* answer */
.answer {
  font-size: .96rem; white-space: pre-wrap; word-break: break-word;
  min-height: 2rem;
}
.answer code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .08rem .3rem; border-radius: 5px; }
.answer pre { background: var(--plane-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; overflow-x: auto; }
.answer pre code { background: transparent; padding: 0; }
.answer-foot { color: var(--muted); font-size: .8rem; margin: .9rem 0 0; }
.notice {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--ink-2); border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .86rem;
}
.reasoning { margin-bottom: .8rem; }
.reasoning summary { cursor: pointer; color: var(--muted); font-size: .84rem; }
.reasoning pre {
  white-space: pre-wrap; color: var(--muted); font-size: .82rem; margin: .5rem 0 0;
  max-height: 14rem; overflow: auto; border-left: 2px solid var(--line); padding-left: .7rem;
}
.cursor::after {
  content: ""; display: inline-block; width: .5ch; height: 1.05em; translate: 0 .16em;
  background: var(--accent); animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.skeleton-row { height: 12px; border-radius: 6px; background: var(--surface-2); margin-bottom: .55rem; animation: pulse 1.4s ease-in-out infinite; }
.skeleton-row.short { width: 55%; }
@keyframes pulse { 50% { opacity: .45; } }

/* ------------------------------------------------------------------ chat */
.attachment {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: .8rem .95rem; margin-bottom: 1rem;
}
.attachment .file { display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 600; }
.attachment .file .sz { font-weight: 420; color: var(--muted); font-size: .82rem; }
.attachment p { color: var(--ink-2); font-size: .85rem; margin: .5rem 0 .4rem; }
.attachment pre {
  font-family: var(--mono); font-size: .72rem; color: var(--muted); margin: 0;
  max-height: 6.5rem; overflow: auto; white-space: pre; max-width: 100%;
  border-left: 2px solid var(--line); padding-left: .6rem;
  mask-image: linear-gradient(#000 55%, transparent);
}
.suggest { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem 1.2rem;
  margin: 1rem 0 1.2rem; padding: .9rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.controls label { display: grid; gap: .3rem; font-size: .82rem; color: var(--muted); }
.controls label.check { display: flex; align-items: center; gap: .45rem; align-self: end; }
.controls input[type=range], .pause-control input[type=range] {
  accent-color: var(--accent); width: 100%; height: 4px; background: var(--grid);
  border-radius: 999px; appearance: none; -webkit-appearance: none; cursor: pointer;
}
.controls input[type=range]::-webkit-slider-thumb,
.pause-control input[type=range]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); cursor: grab;
}
.controls input[type=range]::-moz-range-thumb,
.pause-control input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface); cursor: grab;
}
.controls input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 17px; height: 17px; flex: none;
  border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface);
  display: grid; place-content: center; cursor: pointer;
}
.controls input[type=checkbox]::after {
  content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--accent);
  transform: scale(0); transition: transform .12s ease;
}
.controls input[type=checkbox]:checked::after { transform: scale(1); }
.controls input[type=checkbox]:checked { border-color: var(--accent); }
.controls select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) no-repeat right .55rem center/10px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 1rem top 1.05rem, right .65rem top 1.05rem;
  background-size: 6px 6px, 6px 6px;
  color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem 2rem .45rem .6rem; font: inherit; font-size: .9rem; cursor: pointer;
}
.controls select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.controls output { color: var(--ink); font-size: .92rem; font-variant-numeric: tabular-nums; }
.verdict-box {
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: .85rem 1rem; margin-bottom: 1.1rem;
}
.verdict-box .head { display: flex; align-items: center; gap: .55rem; margin-bottom: .25rem; }
.verdict-box .head strong { font-size: 1.15rem; letter-spacing: -.02em; }
.verdict-box .why { color: var(--ink-2); font-size: .9rem; margin: 0; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.chat-col, .chat-side { min-width: 0; }
.chat { display: grid; gap: .8rem; }
.chat:not(:empty) { margin-bottom: 1rem; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .95rem; background: var(--surface); }
.msg.user { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, transparent); }
.msg .who { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .35rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; font-size: .93rem; }
.turn-strip {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem;
  font-size: .78rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: .5rem;
}
.turn-strip .verdict { font-weight: 640; }
.verdict.stay { color: var(--good); }
.verdict.switch { color: var(--hot); }
.pause-control { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); margin-right: auto; }
.pause-control input[type=range] { accent-color: var(--accent); width: 130px; }
.pause-control output { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 4.5rem; }
.curve { display: grid; gap: .3rem; }
.curve-row {
  display: grid; grid-template-columns: 4.6rem 1fr auto; gap: .55rem; align-items: center;
  font-size: .84rem; padding: .28rem .35rem; border-radius: 7px;
}
.curve-row.flip { background: color-mix(in srgb, var(--hot) 14%, transparent); }
.curve-row .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.curve-row .m { display: flex; align-items: center; gap: .4rem; }
.curve-row .m .dot { width: 8px; height: 8px; border-radius: 50%; }
.chat-side { display: grid; gap: 1rem; position: sticky; top: 76px; align-content: start; }

/* --------------------------------------------------------------- results */
/* The measure is set per block, not on the container: the container keeps the
   page's normal gutters so prose starts where every other section starts,
   instead of floating in the middle of the page. */
.prose > * { max-width: 78ch; }
.prose h2 { margin-top: 2.2rem; font-size: 1.35rem; }
.wide-head { margin-top: 2.6rem; font-size: 1.35rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin-bottom: .55rem; color: var(--ink-2); }
.prose p { color: var(--ink-2); }
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: 1.6rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .1rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .9rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.steps > li::after {
  content: ""; position: absolute; left: .87rem; top: 2.1rem; bottom: -1.2rem; width: 1px;
  background: linear-gradient(var(--line), transparent);
}
.steps > li:last-child::after { display: none; }
.code {
  background: var(--plane-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .9rem 1rem; overflow-x: auto; font-family: var(--mono); font-size: .84rem;
  color: var(--ink-2); line-height: 1.6;
}
.limits { max-width: 78ch; }
.limits li { color: var(--ink-2); }

.section { margin: 2.6rem 0; }
.section-head { margin-bottom: 1rem; }
.section-head h2 { font-size: 1.45rem; }
.section-head p { color: var(--ink-2); max-width: 74ch; margin-bottom: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin: 1.2rem 0; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem;
}
.stat .v { font-size: 1.8rem; font-weight: 650; letter-spacing: -.03em; display: block; }
.stat .k { color: var(--muted); font-size: .82rem; }
.stat .s { color: var(--ink-2); font-size: .82rem; margin-top: .25rem; }

.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.chart h3 { margin-bottom: .15rem; }
.chart .sub { color: var(--muted); font-size: .84rem; margin-bottom: 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .82rem; color: var(--ink-2); margin-bottom: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars { display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 13rem) 1fr minmax(3.4rem, auto); gap: .7rem; align-items: center; font-size: .84rem; }
.bar-row .lbl { color: var(--ink-2); }
.bar-row .lbl.strong { color: var(--ink); font-weight: 600; }
.bar-track { position: relative; height: 26px; display: block; }
.bar-fill { display: block; height: 26px; border-radius: 0 4px 4px 0; background: var(--s1); position: relative; min-width: 5px; }
.bar-fill.alt { background: var(--s2); }
.bar-fill.pick { background: var(--s3); }
.bar-val { font-variant-numeric: tabular-nums; color: var(--ink); font-size: .82rem; white-space: nowrap; text-align: right; }

figure { margin: 0; }
figcaption { color: var(--muted); font-size: .8rem; margin-top: .7rem; }
.chart-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th, .tbl td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl thead th { color: var(--muted); font-weight: 560; font-size: .78rem; }
.table-view { margin-top: .9rem; }
.table-view summary {
  color: var(--ink-2); font-size: .82rem; cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); border-radius: 8px; padding: .3rem .65rem; width: max-content;
}
.table-view summary::-webkit-details-marker { display: none; }
.table-view summary::before { content: "▸"; color: var(--muted); }
.table-view[open] summary::before { content: "▾"; }
.table-view summary:hover { border-color: var(--line-strong); color: var(--ink); }
.svg-chart { width: 100%; height: auto; display: block; overflow: visible; margin-bottom: .4rem; }
.svg-chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.svg-chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.svg-chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.svg-chart text.lbl-strong { fill: var(--ink-2); }
.tip {
  position: fixed; pointer-events: none; z-index: 60; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: .45rem .6rem;
  font-size: .8rem; color: var(--ink); box-shadow: 0 10px 30px -12px rgba(0,0,0,.8);
  opacity: 0; transition: opacity .1s ease; max-width: 17rem;
}
.tip.on { opacity: 1; }
.tip b { display: block; margin-bottom: .15rem; }
.tip .t-sub { color: var(--muted); }

.notice-box {
  border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem;
  background: var(--surface); margin: 1rem 0;
}
.notice-box.p2p-on { border-color: color-mix(in srgb, var(--p2p) 45%, transparent); }

/* ---------------------------------------------------------------- footer */
.footer { border-top: 1px solid var(--line); padding: 1.6rem 0 2.4rem; margin-top: auto; }
.footer-inner { display: grid; gap: .3rem; }
.credits { color: var(--muted); font-size: .82rem; margin: 0; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .grid-decision { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-side { position: static; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
}
@media (max-width: 760px) {
  /* The SVG scales with the container, so its type has to grow in viewBox units
     or it lands at 5px on a phone. */
  .svg-chart text { font-size: 19px; }
  .svg-chart text.lbl-strong { font-size: 19px; }
  .code { white-space: pre-wrap; word-break: break-word; }
  .example { text-align: left; }
  .nav { flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
}

@media (max-width: 720px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-block: .5rem; gap: .5rem; }
  .nav { margin-left: 0; }
  .topbar-actions { margin-left: auto; }
  .prob { grid-template-columns: 6.5rem 1fr 2.6rem; }
  /* A card title must not become a five-line column next to its own chip. */
  .card-head { flex-wrap: wrap; }
  .card-head h2 { width: 100%; }
  .card-head .chip { margin-left: 0; }
  table.candidates td:first-child { min-width: 7.5rem; }
  /* The whole point of the table is the two cost columns; the inputs to them
     move to the desktop view rather than pushing the conclusion off-screen. */
  table.candidates th:nth-child(2), table.candidates td:nth-child(2),
  table.candidates th:nth-child(3), table.candidates td:nth-child(3) { display: none; }
  table.candidates th, table.candidates td { padding: .55rem .4rem; }
  #catalog-table th:nth-child(2), #catalog-table td:nth-child(2),
  #catalog-table th:nth-child(5), #catalog-table td:nth-child(5) { display: none; }
  #catalog-table th:nth-child(3), #catalog-table td:nth-child(3) { display: table-cell; }
}

@media (max-width: 560px) {
  /* Last to go is the success probability: the two cost columns are the point. */
  table.candidates th:nth-child(4), table.candidates td:nth-child(4) { display: none; }
  .bar-row { grid-template-columns: 1fr auto; gap: .2rem .6rem; }
  .bar-row .lbl { grid-column: 1 / -1; }
  .hero { padding-top: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
