:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f3f0;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6; --accent-soft: #e6f0fc; --on-accent: #ffffff;
  --neg: #e34948; --neutral-mark: #c3c2b7;
  --good: #0ca30c; --good-text: #006300; --good-soft: #e5f5e5;
  --bad: #d03b3b; --bad-text: #b02e2e; --bad-soft: #fbe9e9;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-soft: #16263b; --on-accent: #ffffff;
    --neg: #e66767; --neutral-mark: #52514e;
    --good: #0ca30c; --good-text: #0ca30c; --good-soft: #102a12;
    --bad: #e66767; --bad-text: #ee8a8a; --bad-soft: #3a1b1b;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-soft: #16263b; --on-accent: #ffffff;
  --neg: #e66767; --neutral-mark: #52514e;
  --good: #0ca30c; --good-text: #0ca30c; --good-soft: #102a12;
  --bad: #e66767; --bad-text: #ee8a8a; --bad-soft: #3a1b1b;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink);
       font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--page) 88%, transparent);
          backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.brand { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toggles { display: flex; gap: 6px; flex-shrink: 0; }
.chip { font: inherit; font-size: .85rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border);
        border-radius: 999px; padding: 5px 12px; cursor: pointer; text-decoration: none; line-height: 1.4; }
.chip:hover { color: var(--ink); border-color: var(--accent); }

/* hero */
.hero { padding: 40px 0 24px; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.01em; }
.lead { color: var(--ink-2); font-size: 1.08rem; max-width: 720px; margin: 0 0 24px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat-value { display: block; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 650; letter-spacing: -0.01em; }
.stat-label { color: var(--ink-2); font-size: .9rem; }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr; } .stat { display: flex; align-items: baseline; gap: 12px; } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; background: none; border: 0; color: var(--ink-2); padding: 10px 14px; cursor: pointer;
               border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { color: var(--ink); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.2rem; margin: 0 0 4px; }
.card h3 { font-size: 1.05rem; margin: 22px 0 2px; }
.hint { color: var(--ink-2); font-size: .92rem; margin: 0 0 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin-bottom: 0; min-width: 0; }
.grid2 { margin-bottom: 16px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

/* demo inputs */
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .inputs { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; margin-bottom: 6px; }
textarea { width: 100%; min-height: 104px; resize: vertical; padding: 12px 14px; font: inherit; color: var(--ink);
           background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
textarea:focus, button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.examples-title { color: var(--muted); font-size: .85rem; margin: 16px 0 8px; }
.examples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 820px) { .examples { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .examples { grid-template-columns: 1fr; } }
.example { text-align: left; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--border);
           border-radius: 12px; padding: 10px 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.example:hover { border-color: var(--accent); transform: translateY(-1px); }
.example b { display: block; font-size: .88rem; margin-bottom: 2px; }
.example span { display: block; color: var(--ink-2); font-size: .8rem; line-height: 1.35; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 18px; }
button.primary { font: inherit; font-weight: 600; color: var(--on-accent); background: var(--accent); border: 0;
                 border-radius: 999px; padding: 11px 28px; cursor: pointer; }
button.primary:disabled { opacity: .6; cursor: progress; }
.threshold { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .9rem; }
.threshold label { font-weight: 400; margin: 0; }
.threshold input { accent-color: var(--accent); width: 140px; }
.threshold output { font-variant-numeric: tabular-nums; min-width: 2.4em; }
@media (max-width: 520px) { .threshold { margin-left: 0; width: 100%; } .threshold input { flex: 1; } }
.loader { margin-top: 14px; }
.status { color: var(--ink-2); font-size: .9rem; min-height: 1.4em; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .25s; }
.loader.done .bar { display: none; }

/* result */
.verdict-row { display: grid; grid-template-columns: 230px 1fr; gap: 28px; align-items: center; }
@media (max-width: 720px) { .verdict-row { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.gauge { width: 230px; max-width: 100%; }
.gauge-track { stroke: var(--surface-2); }
.gauge-tick { stroke: var(--ink-2); }
.gauge-value { font-size: 32px; font-weight: 650; fill: var(--ink); }
.gauge-label { font-size: 11px; fill: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 650; font-size: 1.1rem; }
.badge.yes { background: var(--good-soft); color: var(--good-text); }
.badge.no { background: var(--bad-soft); color: var(--bad-text); }
.verdict-sub { color: var(--ink-2); margin: 8px 0 14px; }
.compare { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 720px) { .compare { justify-content: center; } }
.compare-item { background: var(--surface-2); border-radius: 12px; padding: 8px 14px; min-width: 120px; }
.compare-k { display: block; color: var(--muted); font-size: .78rem; }
.compare-item > span:last-child { font-weight: 600; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: inherit; }
.tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.row-label { fill: var(--ink); font-size: 13px; }
.row-sub { fill: var(--muted); font-size: 11px; }
.value-label { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.zeroline { stroke: var(--axis); stroke-width: 1; }
.refline { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: none; }
.hit { fill: transparent; cursor: default; }
.hit:hover + .hover-band, .row:hover .hover-band { opacity: 1; }
.hover-band { fill: var(--surface-2); opacity: 0; }
.row:hover .hover-band { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--ink-2); margin: 0 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border);
           border-radius: 10px; padding: 8px 10px; font-size: .82rem; line-height: 1.45; box-shadow: 0 6px 24px rgba(0, 0, 0, .14); max-width: 260px; }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .tt-row span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td:first-child { white-space: normal; min-width: 120px; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hl td { font-weight: 600; }
.delta-up { color: var(--good-text); }
.delta-down { color: var(--bad-text); }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); font-size: .9rem; }

/* data tab */
.sources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .sources { grid-template-columns: 1fr; } }
.source { background: var(--surface-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.source h4 { margin: 0; font-size: 1rem; }
.source code { font-size: .78rem; color: var(--ink-2); word-break: break-all; }
.source p { margin: 0; color: var(--ink-2); font-size: .88rem; }
.source dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 4px 0 0; font-size: .84rem; }
.source dt { color: var(--muted); }
.source dd { margin: 0; }
.source .example-pair { font-size: .84rem; border-left: 2px solid var(--axis); padding-left: 10px; color: var(--ink-2); }

/* how tab */
.flow { display: grid; grid-template-columns: 1fr auto 1.4fr auto 1fr; gap: 12px; align-items: center; margin-top: 12px; }
@media (max-width: 760px) { .flow { grid-template-columns: 1fr; } .flow-arrow { transform: rotate(90deg); justify-self: center; } }
.flow-col { display: flex; flex-direction: column; gap: 10px; }
.flow-arrow { color: var(--muted); font-size: 1.4rem; }
.node { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.node b { display: block; }
.node span { color: var(--ink-2); font-size: .85rem; }
.node-in { text-align: center; font-weight: 600; }
.node-meta { background: var(--accent-soft); border-color: var(--accent); }
.list { margin: 0; padding-left: 20px; color: var(--ink-2); }
.list li { margin-bottom: 8px; }
.list b { color: var(--ink); }

footer { color: var(--muted); font-size: .85rem; text-align: center; padding: 16px 0 40px; }
