*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-strong);
  color: #ffffff;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  border-radius: 6px;
}

/* Header */
.article-header {
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  padding: 18px 24px 16px;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.article-header h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1.18;
  font-weight: 700;
  color: var(--ink);
  max-width: 40ch;
}

.dek {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.48;
  color: var(--ink-muted);
  max-width: 78ch;
}

/* Scrolly layout: desktop split, mobile stacked sticky */
.scrolly-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.narrative-col {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stage-col {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 16px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 20px 14px;
}

.stage-top {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 8px;
}

.scene-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scene-tab {
  appearance: none;
  border: 1px solid var(--rule-strong);
  background: var(--surface-subtle);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.scene-tab:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.scene-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.scene-tab:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.stage-meta {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 7px 0 8px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-glyph {
  display: inline-block;
  flex: none;
}

.legend-point {
  width: 18px;
  height: 10px;
  position: relative;
  border-radius: 2px;
  background: var(--peer-fill);
  border-left: 2px solid var(--peer);
  border-right: 2px solid var(--peer);
}

.legend-point::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--peer);
  transform: translate(-50%, -50%);
}

.legend-focus {
  width: 18px;
  height: 10px;
  position: relative;
  border-radius: 2px;
  background: var(--accent-fill);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}

.legend-focus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.legend-overlap {
  width: 14px;
  height: 12px;
  background: var(--overlap-bg);
  border: 1px dashed var(--overlap-stroke);
  border-radius: 2px;
}

.chart-figure {
  margin: 0;
}

.chart-wrap {
  width: 100%;
  overflow: visible;
}

#chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--font-sans);
}

.stage-caveat {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--surface-subtle);
  border-left: 3px solid var(--accent);
  font-size: 12px;
  line-height: 1.42;
  color: var(--ink);
}

/* Narrative steps */
.story-step {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  padding: 20px 20px 18px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: border-color 180ms ease, opacity 180ms ease;
  opacity: 0.72;
}

.story-step.is-active {
  border-color: var(--accent);
  opacity: 1;
}

.step-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.story-step h2 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.25;
  color: var(--ink);
}

.story-step p {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-muted);
}

.stat-callout {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--overlap-pill-bg);
  border: 1px solid var(--overlap-pill-border);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.stat-callout ul {
  margin: 6px 0 8px;
  padding-left: 18px;
}

.stat-callout li {
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-callout code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--overlap-ink);
}

.callout-note {
  margin: 0 !important;
  font-size: 12.5px !important;
  line-height: 1.45 !important;
  color: var(--ink) !important;
}

/* SVG Typography & Elements */
.axis-tick text {
  font-size: 12px;
  fill: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.axis-grid line {
  stroke: var(--rule);
  stroke-width: 1;
}

.axis-zero {
  stroke: var(--rule-strong);
  stroke-width: 1.25;
}

.row-label {
  font-size: 13px;
  font-weight: 600;
  fill: var(--ink);
}

.row-label.is-focus {
  fill: var(--accent-strong);
  font-weight: 700;
}

.row-value {
  font-size: 12.5px;
  font-weight: 600;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}

.row-range {
  font-size: 12px;
  fill: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.sub-year-label {
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.sub-year-label.is-2025 {
  fill: var(--accent-strong);
  font-weight: 700;
}

.overlap-band {
  fill: var(--overlap-bg);
  stroke: var(--overlap-stroke);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.z-badge-rect {
  fill: var(--overlap-pill-bg);
  stroke: var(--overlap-pill-border);
  stroke-width: 1;
}

.z-badge-text {
  font-size: 12px;
  font-weight: 700;
  fill: var(--overlap-ink);
  font-variant-numeric: tabular-nums;
}

.source-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 28px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.source-footer p {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

/* Reduced motion */
html[data-pique-reduced-motion="reduce"] *,
@media (prefers-reduced-motion: reduce) {
  .scene-tab,
  .story-step {
    transition: none !important;
  }
}

/* Mobile Reflow (<= 899px, including 390x844) */
@media (max-width: 899px) {
  .article-header {
    padding: 14px 14px 12px;
  }

  .article-header h1 {
    font-size: 19px;
    margin-bottom: 6px;
  }

  .dek {
    font-size: 13.5px;
    line-height: 1.42;
  }

  .scrolly-shell {
    display: flex;
    flex-direction: column;
    padding: 8px 10px 24px;
    gap: 12px;
  }

  .stage-col {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .stage-card {
    padding: 10px 10px 8px;
  }

  .stage-top {
    gap: 4px;
    margin-bottom: 5px;
  }

  .scene-tabs {
    gap: 6px;
  }

  .scene-tab {
    font-size: 12px;
    padding: 4px 8px;
  }

  .stage-meta {
    font-size: 12px;
    line-height: 1.28;
  }

  .legend-row {
    gap: 4px 10px;
    padding: 5px 0;
    margin-bottom: 4px;
    font-size: 12px;
    line-height: 1.25;
  }

  .stage-caveat {
    margin-top: 5px;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.32;
  }

  .narrative-col {
    gap: 18px;
  }

  .story-step {
    min-height: 430px;
    padding: 14px 14px;
    opacity: 1;
  }

  .story-step h2 {
    font-size: 17.5px;
    margin-bottom: 8px;
  }

  .story-step p {
    font-size: 14px;
    line-height: 1.48;
    margin-bottom: 10px;
  }

  .source-footer {
    padding: 0 12px 24px;
  }
}
