/* Layout: one reading column (~68ch) for prose, charts and tables run to 1080px. Cool blue-grey neutrals; the two series colors are the only saturated ink. */
:root {
  color-scheme: light;
  --page: #f6f7f9;
  --surface: #fcfcfd;
  --ink: #0e1116;
  --ink-2: #4a505b;
  --muted: #7d828c;
  --line: #e0e3e8;
  --axis: #c3c7cf;
  --accent: #1c5cab;
  --s1: #2a78d6;           /* pgrustj */
  --s2: #eb6834;           /* C */
  --good: #006300;
  --good-wash: #e7f3e7;
  --bad: #b3261e;
  --bad-wash: #fbeceb;
  --code-bg: #eef0f4;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e1014;
    --surface: #171a1f;
    --ink: #eef0f3;
    --ink-2: #b9bec8;
    --muted: #8a909b;
    --line: #2a2e35;
    --axis: #3a3f48;
    --accent: #7fb0ee;
    --s1: #3987e5;
    --s2: #d95926;
    --good: #4cc24c;
    --good-wash: #15261a;
    --bad: #f08a80;
    --bad-wash: #2c1717;
    --code-bg: #22262d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1014;
  --surface: #171a1f;
  --ink: #eef0f3;
  --ink-2: #b9bec8;
  --muted: #8a909b;
  --line: #2a2e35;
  --axis: #3a3f48;
  --accent: #7fb0ee;
  --s1: #3987e5;
  --s2: #d95926;
  --good: #4cc24c;
  --good-wash: #15261a;
  --bad: #f08a80;
  --bad-wash: #2c1717;
  --code-bg: #22262d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 56px;
}
@media (max-width: 480px) { main { padding: 28px 16px 48px; gap: 40px; } }

h1, h2, h3, h4 { text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: clamp(28px, 4.2vw, 42px); font-weight: 700; letter-spacing: -0.015em; max-width: 22ch; }
h2 { font-size: 24px; font-weight: 600; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, summary:focus-visible, pre:focus-visible, .hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 3px; }
strong { font-weight: 600; }

/* Masthead */
.masthead { display: grid; gap: 20px; }
.kicker { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); letter-spacing: 0.02em; }
.kicker code { background: none; padding: 0; }
.lede { font-size: 18px; max-width: 68ch; color: var(--ink); }
.ratio-key { font-size: 14px; color: var(--ink-2); max-width: 68ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 6px;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.tile.good { border-left-color: var(--good); }
.tile.bad { border-left-color: var(--bad); }
.tile-label { font-size: 13px; color: var(--ink-2); }
.tile-value { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.tile-note { font-size: 13px; color: var(--ink-2); }

/* Prose */
.prose { max-width: 68ch; margin-bottom: 14px; }
.dagger, .footnote { font-size: 14px; color: var(--ink-2); }
.footnote { margin-top: 12px; }

/* Compared */
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.facts dt { font-weight: 600; font-size: 14px; padding-top: 2px; }
.facts dd { margin: 0; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 10px; } }
.name-note { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; display: grid; gap: 10px; font-size: 15px; }

/* Charts */
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; color: var(--ink-2); margin-bottom: 20px; }
.key { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.s1 { background: var(--s1); }
.swatch.s2 { background: var(--s2); }
.chart { margin: 0 0 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 22px 22px 16px; display: grid; gap: 14px; }
@media (max-width: 480px) { .chart { padding: 16px 12px 12px; } }
.chart figcaption { display: grid; gap: 6px; }
.chart figcaption p { color: var(--ink-2); font-size: 15px; max-width: 72ch; }
.row-label { color: var(--ink); margin-top: 6px; }
.row-label span { font-weight: 400; color: var(--muted); }
.panels { display: grid; gap: 16px; }
.panels.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panels.two { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .panels.three, .panels.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .panels.three, .panels.two { grid-template-columns: 1fr; } }
.panel h5 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
svg.viz { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-body); }
svg.viz .grid { stroke: var(--line); stroke-width: 1; }
svg.viz .base { stroke: var(--axis); stroke-width: 1; }
svg.viz .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.viz .axis-title { fill: var(--muted); font-size: 11px; }
svg.viz .lbl { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.viz .lbl-strong { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
svg.viz .row-name { fill: var(--ink); font-size: 12px; }
svg.viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.viz .s1 { stroke: var(--s1); }
svg.viz .s2 { stroke: var(--s2); }
svg.viz .dot.s1, svg.viz .bar.s1 { fill: var(--s1); }
svg.viz .dot.s2, svg.viz .bar.s2 { fill: var(--s2); }
svg.viz .dot { stroke: var(--surface); stroke-width: 2; }
svg.viz .hl { fill: none; stroke: var(--ink-2); stroke-width: 1.5; opacity: 0; }
svg.viz .hl.on { opacity: 1; }
svg.viz .cross { stroke: var(--axis); stroke-width: 1; opacity: 0; }
svg.viz .cross.on { opacity: 1; }
svg.viz .hit { fill: transparent; cursor: crosshair; }
svg.viz .rowhit { fill: transparent; }
svg.viz .rowhit.on { fill: var(--code-bg); }

.tip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(10, 20, 40, 0.14);
  padding: 8px 10px; font-size: 13px; line-height: 1.4; min-width: 180px;
}
.tip .t-head { font-weight: 600; margin-bottom: 4px; }
.tip .t-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.tip .t-row span:last-child { text-align: right; }
.tip .t-sw { width: 10px; height: 10px; border-radius: 2px; }
.tip .t-ratio { color: var(--ink-2); margin-top: 4px; font-variant-numeric: tabular-nums; }

details { font-size: 14px; }
summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 4px 0; }
details[open] summary { margin-bottom: 10px; }

/* Tables */
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
#headline-tables .table-wrap { margin-bottom: 28px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); }
caption { text-align: left; font-weight: 600; font-size: 16px; padding: 0 0 8px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; font-size: 12.5px; color: var(--ink-2); background: var(--page); border-bottom: 1px solid var(--axis); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.ratio { font-weight: 600; }
tr.matched td { background: var(--code-bg); }
tr.matched td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.other h3, #other h3 { margin: 18px 0 10px; font-size: 16px; }

/* Ledger */
.ledger ul { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ledger li { padding: 10px 14px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.col-good h3 .mark { color: var(--good); }
.col-bad h3 .mark { color: var(--bad); }
.col-good li { border-left: 3px solid var(--good); }
.col-bad li { border-left: 3px solid var(--bad); }
.col-bad li.worst { background: var(--bad-wash); }
.ledger.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .ledger.two-col { grid-template-columns: 1fr; } }

/* Why */
.why, .limits { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; max-width: 80ch; }
.why li { padding-left: 0; }
.tag { display: inline-block; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 7px; border-radius: 3px; border: 1px solid; margin-right: 4px; vertical-align: 1px; }
.tag.cause { color: var(--ink); border-color: var(--ink-2); background: var(--surface); }
.tag.lead { color: var(--ink-2); border-color: var(--axis); border-style: dashed; }
.limits li { padding-left: 16px; position: relative; }
.limits li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }

pre.code { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 6px 0 0; }
pre.code code { background: none; padding: 0; font-size: inherit; }

footer { border-top: 1px solid var(--line); padding-top: 18px; color: var(--muted); font-size: 13px; max-width: 80ch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
