/* ── Theme tokens (validated data-viz palette) ─────────────────────────────── */
:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f2f2ef;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --axis:        #c3c2b7;
  --border:      rgba(11,11,11,0.10);

  /* categorical series (fixed order, never cycled) */
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#4a3aa7; --s8:#e34948;

  /* status (fixed, never themed) */
  --good:#0ca30c; --warning:#fab219; --serious:#ec835a; --critical:#d03b3b;
  --neutral:#898781;

  --radius:12px;
  --shadow:0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:#0d0d0d; --surface:#1a1a19; --surface-2:#232320;
    --ink:#ffffff; --ink-2:#c3c2b7; --muted:#898781; --grid:#2c2c2a; --axis:#383835;
    --border:rgba(255,255,255,0.10);
    --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
    --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:#0d0d0d; --surface:#1a1a19; --surface-2:#232320;
  --ink:#ffffff; --ink-2:#c3c2b7; --muted:#898781; --grid:#2c2c2a; --axis:#383835;
  --border:rgba(255,255,255,0.10);
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
  --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
h1 { font-size: 1.7rem; margin: .1rem 0 0; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h3 { font-size: 1.02rem; margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem;
  color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.sub { color: var(--ink-2); font-size: .88rem; margin: .35rem 0 0; }
.hidden { display: none !important; }
code { background: var(--surface-2); padding: .05rem .35rem; border-radius: 5px;
  font-size: .85em; }

/* ── Header ────────────────────────────────────────────────────────────────── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; padding: 1.4rem 1.25rem; flex-wrap: wrap; }
.run-meta { color: var(--ink-2); margin: .5rem 0 0; font-size: .88rem; }
.btn { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .8rem; font: inherit; font-size: .85rem;
  cursor: pointer; }
.btn:hover { background: var(--grid); }
.btn.small { padding: .25rem .6rem; font-size: .78rem; }

/* ── Banner ────────────────────────────────────────────────────────────────── */
.banner { background: color-mix(in srgb, var(--warning) 18%, var(--surface));
  border-bottom: 1px solid var(--border); font-size: .9rem; }
.banner .wrap { padding: .7rem 1.25rem; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.section { padding: 2.2rem 0 .5rem; }
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem;
  margin: 0 0 1.3rem; }
.card-head { margin-bottom: 1rem; }
.card-head .head-row { display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; flex-wrap: wrap; }

/* ── Stat tiles ────────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .9rem; margin-bottom: 1.3rem; }
.tile { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; }
.tile .val { font-size: 1.7rem; font-weight: 650; letter-spacing: -.02em; }
.tile .lbl { color: var(--muted); font-size: .8rem; margin-top: .15rem; }

/* ── Technical-details toggle ────────────────────────────────────────────────
   Jargon is hidden by default so the page reads plainly. `body.show-tech`
   (set by the toggle) reveals it. */
.tech-only { display: none; }
.tech-only-block { display: none; }
body.show-tech .tech-only { display: inline-block; }
body.show-tech .tech-only-block { display: block; }
/* Authoritative hide when the toggle is off — beats component rules like .tag
   (equal specificity, defined later) that would otherwise force display. */
body:not(.show-tech) .tech-only,
body:not(.show-tech) .tech-only-block { display: none !important; }

/* ── Intro / plain-language framing ──────────────────────────────────────────── */
.intro { padding-top: 2rem; }
.intro .lead { font-size: 1.12rem; line-height: 1.6; color: var(--ink); max-width: 68ch;
  margin: .4rem 0 1.1rem; }
.intro .lead b { font-weight: 650; }
.how-to { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr));
  gap: .8rem; margin-top: .5rem; }
.how-to .step { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem; }
.how-to .step .n { display:inline-flex; width:22px; height:22px; border-radius:50%;
  background: var(--s1); color:#fff; font-size:.8rem; font-weight:700;
  align-items:center; justify-content:center; margin-bottom:.4rem; }
.how-to .step p { margin: 0; font-size: .88rem; color: var(--ink-2); }

/* plain-language question title + why-line + how-to-read */
.q-title { font-size: 1.12rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.why-line { color: var(--ink-2); font-size: .92rem; margin: .5rem 0 0; max-width: 72ch; }
.read-note { background: var(--surface-2); border-radius: 8px; padding: .55rem .8rem;
  font-size: .85rem; color: var(--ink-2); margin: .9rem 0; max-width: 74ch; }
.read-note b { color: var(--ink); }

/* verdict banner */
.verdict { display: flex; gap: .7rem; align-items: flex-start; border-radius: 10px;
  padding: .7rem .9rem; margin: .3rem 0 1rem; font-size: .92rem; border: 1px solid var(--border); }
.verdict .badge { flex: none; font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .2rem .55rem; border-radius: 20px; color:#fff; margin-top:.05rem; }
.verdict.good  { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.verdict.warn  { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); }
.verdict.bad   { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); }
.verdict.good .badge { background: var(--good); }
.verdict.warn .badge { background: var(--serious); }
.verdict.bad  .badge { background: var(--critical); }
.verdict .vtext b { color: var(--ink); }

/* ── Tags / chips ──────────────────────────────────────────────────────────── */
.tag { display: inline-block; font-size: .7rem; padding: .12rem .5rem; border-radius: 20px;
  border: 1px solid var(--border); color: var(--ink-2); margin-left: .35rem;
  vertical-align: middle; }
.tag.origin-US { border-color: color-mix(in srgb, var(--s1) 50%, var(--border)); }
.tag.origin-CN { border-color: color-mix(in srgb, var(--s2) 50%, var(--border)); }
.pill { display:inline-flex; align-items:center; gap:.3rem; font-size:.74rem;
  padding:.1rem .5rem; border-radius:20px; font-weight:600; }

/* ── Heatmap ───────────────────────────────────────────────────────────────── */
.heatmap-wrap { overflow-x: auto; }
table.heatmap { border-collapse: separate; border-spacing: 4px; width: 100%; }
table.heatmap th { font-size: .78rem; color: var(--ink-2); font-weight: 600;
  text-align: center; padding: .3rem; vertical-align: bottom; }
table.heatmap th.row-h { text-align: left; white-space: nowrap; }
table.heatmap td { text-align: center; border-radius: 8px; padding: .55rem .3rem;
  font-variant-numeric: tabular-nums; font-size: .82rem; font-weight: 600;
  color: #0b0b0b; min-width: 74px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .9rem;
  font-size: .78rem; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 13px; height: 13px; border-radius: 3px; display: inline-block;
  border: 1px solid var(--border); }

/* ── Charts ────────────────────────────────────────────────────────────────── */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .val-label { fill: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grp-label { fill: var(--ink-2); font-size: 12px; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.whisker { stroke: var(--ink-2); stroke-width: 1.5; }
.bar-seg { transition: opacity .12s; }
.bar-seg:hover, .barmark:hover { opacity: .82; cursor: default; }
.mark-ring { paint-order: stroke; }

/* HTML/CSS bar charts */
.bar-group { margin: 0 0 1rem; }
.bar-group > .grp-title { font-size: .82rem; color: var(--ink-2); font-weight: 600;
  margin: 0 0 .35rem; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 92px; align-items: center;
  gap: .6rem; margin: 3px 0; }
.bar-name { font-size: .8rem; color: var(--ink-2); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; background: var(--surface-2); border-radius: 4px;
  height: 17px; overflow: visible; }
.bar-track.stacked { display: flex; gap: 2px; background: transparent; }
.bar-fill { height: 100%; border-radius: 4px; min-width: 2px; }
.bar-seg { height: 17px; border-radius: 3px; min-width: 0; }
.bar-seg:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.bar-seg:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.bar-whisker { position: absolute; top: 50%; height: 7px; transform: translateY(-50%);
  border-left: 1.5px solid var(--ink-2); border-right: 1.5px solid var(--ink-2); }
.bar-whisker::before { content:""; position:absolute; top:50%; left:0; right:0;
  border-top:1.5px solid var(--ink-2); }
.bar-val { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--ink);
  white-space: nowrap; }
.bar-val .ci { color: var(--muted); font-size: .72rem; }
.axis-ticks { display:grid; grid-template-columns: 150px 1fr 92px; gap:.6rem;
  margin-top:.3rem; }
.axis-ticks .ticks { display:flex; justify-content:space-between; font-size:.7rem;
  color: var(--muted); }
.panel-title { font-size:.92rem; margin: 1.1rem 0 .5rem; display:flex; gap:.4rem;
  align-items:center; flex-wrap:wrap; }
.erased-tag { color:#fff; background:var(--critical); font-size:.66rem; font-weight:700;
  padding:.05rem .4rem; border-radius: 4px; }

.callout { background: var(--surface-2); border-left: 3px solid var(--s1);
  border-radius: 8px; padding: .55rem .85rem; margin: .9rem 0 0; font-size: .86rem;
  color: var(--ink-2); }
.callout.bad { border-left-color: var(--critical); }
.callout b { color: var(--ink); }

/* ── Data tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: .8rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .84rem; }
table.data th, table.data td { border: 1px solid var(--border); padding: .35rem .55rem;
  text-align: left; }
table.data th { background: var(--surface-2); font-weight: 600; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.status-good { color: var(--good); font-weight: 600; }
.status-bad { color: var(--critical); font-weight: 600; }
.status-warn { color: var(--serious); font-weight: 600; }

/* ── Legends inline ────────────────────────────────────────────────────────── */
.series-legend { display: flex; gap: .9rem; flex-wrap: wrap; margin: 0 0 .3rem;
  font-size: .8rem; color: var(--ink-2); }

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface);
  color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: .5rem .65rem; font-size: .82rem; max-width: 280px; }
.tooltip .tt-title { font-weight: 650; margin-bottom: .2rem; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 1rem; }

.site-footer { border-top: 1px solid var(--border); margin-top: 1.5rem;
  padding: 1.4rem 0 3rem; color: var(--ink-2); font-size: .84rem; }
