/* Design tokens. Light by default; dark from the OS setting or the theme toggle. */
:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #8a8984;
  --line: #e6e5e1;
  --accent: #2a78d6;
  --accent-soft: #e8f0fb;
  --shade-window: #efede7;
  --shade-day: #d6d3ca;
  --spike: #e34948;
  --radius: 12px;
  --maxw: 1080px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #8f8e86;
    --line: #2f2e2b;
    --accent: #3987e5;
    --accent-soft: #1d2b3d;
    --shade-window: #24241f;
    --shade-day: #3a3933;
    --spike: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #8f8e86;
  --line: #2f2e2b;
  --accent: #3987e5;
  --accent-soft: #1d2b3d;
  --shade-window: #24241f;
  --shade-day: #3a3933;
  --spike: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 2.8rem); }
h2 { font-size: 1.5rem; margin-top: 2.2em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 0.92rem; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 8px; width: 36px; height: 32px; cursor: pointer; flex: none; font-size: 1rem;
}

/* Hero */
.hero { padding: 56px 0 24px; }
.eyebrow { color: var(--ink-3); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 720px; }
.links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.button {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.92rem;
}
.button:hover { border-color: var(--ink-3); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 24px 0 48px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none;
}
a.card:hover { border-color: var(--ink-3); }
.card .tag { font-size: 0.78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.card h3 { margin: 0; }
.card p { color: var(--ink-2); margin: 0; font-size: 0.95rem; }
.card .metric { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.card .metric small { font-size: 0.85rem; font-weight: 400; color: var(--ink-2); display: block; letter-spacing: 0; }
.card.muted { background: transparent; border-style: dashed; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 24px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi .label { color: var(--ink-2); font-size: 0.88rem; }

/* Panels and controls */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
@media (min-width: 720px) { .panel { padding: 20px 24px; } }
.panel h3 { margin-bottom: 4px; }
.panel .sub { color: var(--ink-2); font-size: 0.92rem; margin-bottom: 12px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 8px 0 12px; }
.control-label { font-size: 0.8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 6px; }
.segmented { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; background: var(--surface); color: var(--ink-2); padding: 6px 12px; cursor: pointer; font: inherit; font-size: 0.88rem;
  white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip[aria-pressed="false"] .dot { background: transparent !important; outline: 1.5px solid var(--ink-3); }
select {
  font: inherit; font-size: 0.88rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px;
}
.chart { width: 100%; height: 380px; }
.chart.tall { height: 440px; }
.chart.short { height: 300px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.legend-note { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82rem; color: var(--ink-2); margin-top: 6px; }
.legend-note span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.ring { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--spike); display: inline-block; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 600; font-size: 0.82rem; }
tr.best td { background: var(--accent-soft); font-weight: 600; }

/* Prose */
.prose { max-width: 760px; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin: 0.3em 0; }
.steps { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 10px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 12px 48px; position: relative; }
.steps li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 14px; top: 12px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--ink);
  font-size: 0.8rem; font-weight: 700; display: grid; place-items: center;
}

.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0 40px; color: var(--ink-3); font-size: 0.88rem; }
.site-footer a { color: var(--ink-2); }
.noscript { background: var(--surface-2); padding: 12px; border-radius: 8px; }
