:root,
[data-theme='light'] {
  /* Surfaces — cool clinical white with a whisper of teal */
  --color-bg: #f4f7f7;
  --color-surface: #ffffff;
  --color-surface-2: #edf2f2;
  --color-border: #d8e2e2;
  --color-divider: #e2eaea;

  /* Text */
  --color-text: #16292b;
  --color-text-muted: #5b7274;
  --color-text-faint: #9bacad;
  --color-text-inverse: #f4f7f7;

  /* Primary — calming teal (authority, trust) */
  --color-primary: #0f6e76;
  --color-primary-hover: #0b5259;
  --color-primary-highlight: #d7e8e9;

  /* U.S. accent — warm terracotta (the story's focal point) */
  --color-us: #c1502e;
  --color-us-hover: #a03f22;
  --color-us-highlight: #f3ddd3;

  /* Peer / neutral series */
  --color-peer: #9db3b5;
  --color-peer-dark: #6e8688;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 200 / 0.06);
  --shadow-md: 0 4px 16px oklch(0.2 0.02 200 / 0.08);
  --shadow-lg: 0 16px 40px oklch(0.2 0.02 200 / 0.12);

  --content-wide: 1180px;

  --font-display: 'Space Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'IBM Plex Sans', 'Helvetica Neue', sans-serif;
}

[data-theme='dark'] {
  --color-bg: #0f1a1b;
  --color-surface: #142425;
  --color-surface-2: #182b2c;
  --color-border: #2a4142;
  --color-divider: #223839;

  --color-text: #dce9e9;
  --color-text-muted: #8ea8a9;
  --color-text-faint: #5e7778;
  --color-text-inverse: #16292b;

  --color-primary: #59c2c9;
  --color-primary-hover: #7fd2d8;
  --color-primary-highlight: #1d3a3c;

  --color-us: #e3835f;
  --color-us-hover: #ec9d7f;
  --color-us-highlight: #3d2a22;

  --color-peer: #557072;
  --color-peer-dark: #7f9799;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.25);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.45);
}

:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.3rem + 2.2vw, 3.125rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
}

/* ---------- Layout shell ---------- */

.wrap {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

header.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
}

.brand svg {
  width: 32px;
  height: 32px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.brand-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: block;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ---------- Hero ---------- */

.hero {
  padding-block: var(--space-16) var(--space-12);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-us);
  margin-bottom: var(--space-4);
}
.eyebrow::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-us);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: 18ch;
  margin-bottom: var(--space-5);
}

.hero p.lede {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 62ch;
  margin-bottom: var(--space-2);
}

.byline {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-6);
}

/* ---------- KPI strip ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  padding-block: var(--space-4) var(--space-16);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.kpi-value.us {
  color: var(--color-us);
}

.kpi-label {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.kpi-context {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---------- Chart sections ---------- */

.section {
  padding-block: var(--space-16);
  border-top: 1px solid var(--color-divider);
}

.section-head {
  max-width: 68ch;
  margin-bottom: var(--space-8);
}

.section-kicker {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-3);
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.section-head p {
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.source-note {
  margin-top: var(--space-5);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.source-note a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Timing chart — custom stacked bar */
.timing-bar {
  display: flex;
  width: 100%;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-6);
}
.timing-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-inverse);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding-inline: var(--space-1);
}
.timing-labels {
  display: flex;
  width: 100%;
  gap: var(--space-1);
}
.timing-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

/* ---------- Story / closing ---------- */

.story-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-10);
  align-items: start;
}

.story-grid h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

.story-grid p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.story-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.story-item {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.story-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-us);
  flex-shrink: 0;
}

.story-item p {
  font-size: var(--text-sm);
  margin-bottom: 0;
  color: var(--color-text);
}

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-10);
}

footer h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

.ref-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ref-list li {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 90ch;
}

.ref-list a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-meta {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .story-grid {
    grid-template-columns: 1fr;
  }
  .timing-labels {
    display: none;
  }
}

@media (max-width: 540px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .chart-card {
    padding: var(--space-5);
  }
}
