/* Palette and chrome follow the dataviz reference palette (light and dark steps validated separately). */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a65;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-other: #8a8983;
  --human: #52514e;
  --frontier: #52514e;
  --banner-bg: #fff4d6;
  --banner-border: #eda100;
  --row-hover: #f0efec;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9991;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #6da7ec;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-other: #8a8983;
    --human: #c3c2b7;
    --frontier: #c3c2b7;
    --banner-bg: #3a2e0d;
    --banner-border: #c98500;
    --row-hover: #262624;
  }
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page);
}
a { color: var(--accent); }
code { font-size: 0.92em; }

.viz-root { max-width: 1180px; margin: 0 auto; padding: 24px 24px 48px; }

.page-header h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 12px; font-weight: 650; }
.meta {
  display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 12px;
  color: var(--text-secondary); font-size: 0.9rem;
}
.meta div { display: flex; gap: 6px; }
.meta dt { color: var(--text-muted); }
.meta dd { margin: 0; }
.lead { max-width: 78ch; color: var(--text-secondary); margin: 0 0 16px; }
.banner {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 8px;
  background: var(--banner-bg); border: 1px solid var(--banner-border);
}

.controls {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 10px 0; margin-bottom: 16px;
  background: var(--page); border-bottom: 1px solid var(--grid);
}
.segmented { display: flex; gap: 0; border: 0; margin: 0; padding: 0; align-items: center; }
.segmented[hidden] { display: none; }
.segmented legend { float: left; margin-right: 10px; color: var(--text-secondary); font-size: 0.9rem; }
.segmented label {
  position: relative; padding: 6px 12px; cursor: pointer; font-size: 0.9rem;
  border: 1px solid var(--axis); background: var(--surface);
}
.segmented label:first-of-type { border-radius: 6px 0 0 6px; }
.segmented label:last-of-type { border-radius: 0 6px 6px 0; border-left: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--text-primary); color: var(--surface); border-color: var(--text-primary); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-secondary); }
select {
  font: inherit; color: var(--text-primary); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 6px; padding: 5px 8px;
}
.check { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 24px 16px; margin-bottom: 24px;
}
.card h2 { font-size: 1.2rem; margin: 0 0 4px; font-weight: 650; }
.card h3 { font-size: 1.02rem; margin: 28px 0 4px; font-weight: 650; }
.rate p:last-child { margin: 0; }
.button {
  display: inline-block; padding: 9px 18px; border-radius: 8px; background: var(--accent);
  color: var(--surface); font-weight: 600; text-decoration: none;
}
.button:hover { filter: brightness(1.08); }
.page-footer { margin: 0 0 32px; color: var(--text-muted); font-size: 0.85rem; }
.sub { margin: 0 0 12px; color: var(--text-secondary); font-size: 0.92rem; max-width: 80ch; }
.footnote { margin: 8px 0 0; color: var(--text-secondary); font-size: 0.85rem; max-width: 90ch; }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 6px;
  font-size: 0.85rem; color: var(--text-secondary);
}
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { flex: none; overflow: visible; }

.chart { width: 100%; min-height: 300px; }
.chart svg { --plot-background: var(--surface); color: var(--text-secondary); background: transparent; }
.chart svg text { font-family: var(--font); }

.slider { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; font-size: 0.92rem; }
.slider input { width: min(320px, 60vw); accent-color: var(--accent); }
.slider output { font-variant-numeric: tabular-nums; min-width: 4ch; font-weight: 600; }

.table-wrap { overflow-x: auto; border: 1px solid var(--grid); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
td.text, th.text { text-align: left; }
thead th { font-weight: 600; color: var(--text-secondary); vertical-align: bottom; }
tbody td { font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
th button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; text-align: inherit;
}
th[aria-sort] button { color: var(--text-primary); }
th button .arrow { font-size: 0.75em; width: 1em; display: inline-block; }
.ci { display: block; color: var(--text-muted); font-size: 0.8em; line-height: 1.2; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 4px;
  font-size: 0.75rem; border: 1px solid var(--axis); color: var(--text-secondary);
}
.swatch { display: inline-block; vertical-align: -1px; margin-right: 6px; }
tr.human td { color: var(--text-secondary); font-style: italic; }
/* Main table: long column names wrap so the table fits the card without scrolling. */
#table-main thead th { white-space: normal; }
#table-main th, #table-main td { padding: 7px 8px; }
#table-main th button .arrow:empty { display: none; }
/* v1.0: a rule separates the human originals of the items from the models. */
#table-main tr.human td { border-top: 2px solid var(--axis); }
/* v1.0 has more columns: tighter cells keep the table within the card. */
#table-main.compact th, #table-main.compact td { padding: 7px 5px; }
#table-main.compact th:first-child, #table-main.compact td:first-child { padding-left: 8px; }
/* Style diagnostics: long column names wrap; a rule separates the human baseline from the models. */
#table-style thead th { white-space: normal; min-width: 7.5em; }
#table-style thead th:first-child { min-width: 0; }
#table-style tr.human td { border-top: 2px solid var(--axis); }
.muted { color: var(--text-muted); }
.notes { margin: 16px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 0.85rem; }

@media (max-width: 640px) {
  .viz-root { padding: 16px 12px 32px; }
  .page-header h1 { font-size: 1.35rem; }
  .card { padding: 14px 12px 12px; border-radius: 10px; }
  .controls { gap: 8px 16px; }
  .segmented legend { display: none; }
}
@media (forced-colors: active) {
  .segmented label:has(input:checked) { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
