:root {
  --paper: #f5f2ea;
  --paper-2: #ece8de;
  --ink: #1d2426;
  --muted: #687173;
  --line: #c9c7bd;
  --line-dark: #7c8585;
  --accent: #174f5c;
  --accent-soft: #dbe7e7;
  --ochre: #a66724;
  --rust: #9a4436;
  --violet: #675879;
  --green: #446b55;
  --blue: #335f87;
  --focus: #0b6575;
  --error: #8b2d25;
  --max-width: 1480px;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.45;
}
a { color: var(--accent); text-underline-offset: 0.18em; }
button, input, select { font: inherit; }
button, select, input { border-radius: 0; }

.site-header {
  border-bottom: 1px solid var(--ink);
  padding: 42px 34px 34px;
  background: var(--paper);
}
.header-inner { max-width: var(--max-width); margin: 0 auto; }
.eyebrow, .section-rule {
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: start;
}
h1 {
  margin: 10px 0 12px;
  max-width: 1050px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.05rem, 4.2vw, 4.35rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.lede { max-width: 980px; margin: 0; font-size: 1.02rem; color: #354043; }
.source-line { margin: 14px 0 0; font-size: 0.9rem; }
.language-toggle {
  margin-top: 10px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  min-width: 48px;
  height: 38px;
  cursor: pointer;
}
.language-toggle:hover, .language-toggle:focus-visible { background: var(--ink); color: white; }

.layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 54px;
}
.controls {
  align-self: start;
  position: sticky;
  top: 16px;
  border-top: 1px solid var(--ink);
  padding-top: 13px;
}
.controls h2, .results h2 { font-family: var(--font-serif); font-weight: 500; margin: 7px 0 22px; }
.controls h2 { font-size: 1.75rem; }
.field { display: block; margin: 0 0 16px; }
.field > span { display: block; margin-bottom: 6px; font-weight: 650; font-size: 0.88rem; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 0.72rem; }
.field input, .field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-dark);
  background: #fbfaf6;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(11,101,117,.12); }
.parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.unit { color: var(--muted); font-weight: 400; font-size: 0.78em; }
.intro-readout {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin: 8px 0 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--muted);
}
.intro-readout strong { color: var(--ink); font-size: 1.02rem; }
.intro-readout small { color: var(--muted); line-height: 1.35; margin-top: 3px; }
.run-button, .export-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  padding: 10px 15px;
  cursor: pointer;
}
.run-button { width: 100%; }
.run-button:hover, .export-button:hover { background: var(--accent); border-color: var(--accent); }
.run-button:disabled, .export-button:disabled { opacity: .45; cursor: not-allowed; }
.status { min-height: 22px; margin-top: 8px; color: var(--muted); font-size: 0.78rem; }
.status.error { color: var(--error); }
.data-facts { border-top: 1px solid var(--ink); margin-top: 26px; padding-top: 13px; }
.data-facts h3 { font-family: var(--font-serif); font-size: 1.05rem; margin: 0 0 10px; font-weight: 500; }
.data-facts dl { margin: 0; }
.data-facts dl div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.data-facts dt { color: var(--muted); font-size: 0.78rem; }
.data-facts dd { margin: 0; font-variant-numeric: tabular-nums; font-size: 0.84rem; }
.micro-note { color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.model-note { border-top: 1px solid var(--line-dark); margin-top: 22px; padding-top: 10px; font-size: 0.8rem; }
.model-note summary { cursor: pointer; font-weight: 650; }
.model-note p { color: #4f595a; }

.results { min-width: 0; }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-top: 1px solid var(--ink); padding-top: 13px; }
.results h2 { font-size: 2rem; margin-bottom: 0; }
.results-explanation { max-width: 780px; margin: 8px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.export-button { background: transparent; color: var(--ink); white-space: nowrap; }
.headline-result {
  margin: 30px 0 34px;
  padding: 17px 0 19px;
  border-top: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
  display: grid;
  grid-template-columns: minmax(180px, .65fr) minmax(150px, .45fr) minmax(260px, 1fr);
  gap: 30px;
  align-items: end;
}
.result-label { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .08em; }
.headline-result strong { display: block; font-family: var(--font-serif); font-size: clamp(2.3rem, 5vw, 4.4rem); font-weight: 500; line-height: 1; margin-top: 4px; }
.result-context { color: var(--muted); font-size: .85rem; padding-bottom: 5px; }

.chart-block { border-top: 1px solid var(--ink); padding-top: 16px; margin-top: 34px; }
.chart-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.chart-heading h3 { margin: 0; font-family: var(--font-serif); font-size: 1.4rem; font-weight: 500; }
.chart-heading p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px 13px; font-size: .76rem; }
.legend button { border: 0; padding: 2px 0; background: transparent; color: var(--ink); cursor: pointer; }
.legend button::before { content: ""; display: inline-block; width: 18px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--series-color); }
.legend button.area-key::before { height: 9px; border: 1px solid var(--series-color); background: var(--series-color); }
.legend button.total-key::before { height: 0; background: transparent; border-top: 2px dashed var(--series-color); }
.legend button.off { opacity: .35; text-decoration: line-through; }
.chart-shell {
  position: relative;
  width: 100%;
  margin-top: 10px;
  aspect-ratio: 12 / 5.5;
  min-height: 290px;
}
.science-chart { width: 100%; height: 100%; display: block; overflow: visible; }
.science-chart text { font-family: var(--font-sans); fill: var(--muted); font-size: 12px; }
.science-chart .axis { stroke: var(--line-dark); stroke-width: 1; shape-rendering: crispEdges; }
.science-chart .grid { stroke: var(--line); stroke-width: 1; opacity: .58; shape-rendering: crispEdges; }
.science-chart .series { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.science-chart .stack-area { stroke: none; opacity: .78; }
.science-chart .stack-area.infectious-area { opacity: .88; }
.science-chart .stack-boundary { fill: none; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.science-chart .series.total { stroke-dasharray: 7 5; stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.science-chart .model-outside { fill: var(--paper-2); opacity: .55; }
.science-chart .model-boundary { stroke: var(--line-dark); stroke-width: 1; stroke-dasharray: 2 5; opacity: .7; vector-effect: non-scaling-stroke; }
.science-chart .threshold-line { stroke: var(--ochre); stroke-width: 1.3; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.science-chart .threshold-label { fill: var(--ochre); font-size: 11px; }
.science-chart .t0-line { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.science-chart .t0-point { stroke: var(--paper); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.science-chart .crosshair { stroke: var(--muted); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.science-chart .hit-area { fill: transparent; cursor: crosshair; }
.axis-slider {
  position: absolute;
  left: var(--slider-left, 8.75%);
  width: var(--slider-width, 88.75%);
  bottom: 11.5%;
  height: 18px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
  z-index: 4;
}
.axis-slider::-webkit-slider-runnable-track { height: 2px; background: transparent; }
.axis-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 20px; margin-top: -9px; border: 1px solid var(--ink); background: var(--paper); }
.axis-slider::-moz-range-track { height: 2px; background: transparent; }
.axis-slider::-moz-range-thumb { width: 11px; height: 18px; border-radius: 0; border: 1px solid var(--ink); background: var(--paper); }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  min-width: 145px;
  background: rgba(245,242,234,.96);
  border: 1px solid var(--ink);
  padding: 7px 9px;
  font-size: .72rem;
  box-shadow: 2px 2px 0 rgba(29,36,38,.08);
}
.chart-tooltip strong { display: block; margin-bottom: 3px; }
.chart-tooltip span { display: block; font-variant-numeric: tabular-nums; }
.method-strip { margin-top: 28px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line-dark); border-bottom: 1px solid var(--line-dark); }
.method-strip div { padding: 11px 12px 11px 0; }
.method-strip div + div { border-left: 1px solid var(--line); padding-left: 14px; }
.method-strip span { display: block; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.method-strip strong { display: block; font-size: .78rem; margin-top: 2px; }

.site-footer {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding: 28px 34px 44px;
  border-top: 1px solid var(--ink);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, .8fr);
  gap: 40px;
}
.credits-copy p { margin: 8px 0 0; font-size: .82rem; color: #485254; }
.funders { display: grid; grid-template-columns: 1fr 1fr 1.4fr; align-items: center; gap: 16px; }
.funders a { display: block; }
.funders img { display: block; width: 100%; max-height: 72px; object-fit: contain; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; gap: 34px; padding: 24px; }
  .controls { position: static; }
  .site-header { padding: 32px 24px 28px; }
  .site-footer { grid-template-columns: 1fr; padding: 24px; }
}
@media (max-width: 640px) {
  .title-row { grid-template-columns: 1fr; }
  .language-toggle { position: absolute; right: 20px; top: 20px; }
  .site-header { position: relative; padding: 72px 18px 24px; }
  .layout { padding: 18px; }
  .parameter-grid { grid-template-columns: 1fr; }
  .results-head, .chart-heading { flex-direction: column; align-items: stretch; }
  .legend { justify-content: flex-start; }
  .headline-result { grid-template-columns: 1fr; gap: 12px; }
  .method-strip { grid-template-columns: 1fr; }
  .method-strip div + div { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .chart-shell { min-height: 250px; aspect-ratio: 1.55 / 1; }
  .funders { grid-template-columns: 1fr 1fr; }
}

/* v1.4: year and department selection */
.selection-grid {
  display: grid;
  grid-template-columns: minmax(92px, .42fr) minmax(0, 1fr);
  gap: 0 12px;
}
@media (max-width: 640px) {
  .selection-grid { grid-template-columns: 1fr; }
}
