/* ---------- tokens ---------- */
:root {
  --paper: #FBF8F2;
  --paper-2: #F3ECE0;
  --ink: #1F1B16;
  --ink-2: #3D3630;
  --muted: #6B6258;
  --rule: #E4DCCF;
  --accent: #8A4B24;
  --accent-ink: #6E3A1A;
  --stripe: rgba(138, 75, 36, .05);
  --shadow: rgba(31, 27, 22, .22);
  --focus: #B5832F;
  --axis: #C9BFB0;
  /* chart series: validated categorical palette, light surface */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  --serif: "Source Serif 4", "Iowan Old Style", Charter, "Bitstream Charter", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 46rem;
  --wide: 74rem;
  --gutter: 1.25rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15120F;
    --paper-2: #1F1A15;
    --ink: #EDE6DA;
    --ink-2: #D6CCBD;
    --muted: #A89C8C;
    --rule: #332C25;
    --accent: #E3A673;
    --accent-ink: #F0BC8E;
    --stripe: rgba(227, 166, 115, .05);
    --shadow: rgba(0, 0, 0, .6);
    --focus: #E3B35E;
    --axis: #4A4138;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15120F; --paper-2: #1F1A15; --ink: #EDE6DA; --ink-2: #D6CCBD; --muted: #A89C8C;
  --rule: #332C25; --accent: #E3A673; --accent-ink: #F0BC8E; --stripe: rgba(227, 166, 115, .05); --shadow: rgba(0, 0, 0, .6); --focus: #E3B35E;
  --axis: #4A4138;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 48rem) { body { font-size: 1.1875rem; } }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-ink); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
img, svg { max-width: 100%; height: auto; }

/* ---------- header / footer ---------- */
.site-header { border-top: 6px solid var(--accent); border-bottom: 1px solid var(--rule); }
.site-header__inner, .site-footer__inner {
  max-width: var(--wide); margin: 0 auto; padding: 1rem var(--gutter);
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem;
}
.brand { text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.brand:hover { color: var(--ink); }
.brand__name { font-weight: 700; font-size: clamp(1.25rem, 4.6vw, 1.6rem); letter-spacing: -0.01em; line-height: 1.1; }
.brand__tag { font-family: var(--sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-family: var(--sans); font-size: .9rem; }
.site-nav a { color: var(--ink-2); text-decoration: none; padding: .25rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 currentColor; }
.site-footer { border-top: 1px solid var(--rule); margin-top: 4rem; }
.site-footer__inner { display: block; font-family: var(--sans); font-size: .85rem; color: var(--muted); padding-block: 2rem 3rem; }
.site-footer__inner p { margin: .35rem 0; max-width: 46rem; }
.site-footer a { color: var(--muted); }

/* ---------- shared bits ---------- */
.kicker {
  font-family: var(--sans); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .6rem; display: flex; flex-wrap: wrap; gap: .45rem;
}
.kicker > :first-child { color: var(--accent); font-weight: 600; }
.kicker a { text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
.section-head { padding: 2.5rem 0 1.5rem; margin-bottom: 2rem; border-bottom: 2px solid var(--ink); max-width: 42rem; }
.section-head h1 { font-size: clamp(2.1rem, 6.5vw, 3rem); line-height: 1.07; letter-spacing: -0.02em; margin: 0 0 .75rem; }
.section-intro { font-size: .95rem; color: var(--ink-2); margin-top: 1rem; }
.section-feed { font-family: var(--sans); font-size: .85rem; margin: 1rem 0 0; }
.section-label {
  font-family: var(--sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--rule); padding-bottom: .5rem; margin: 0 0 1.5rem;
}

/* ---------- home ---------- */
.home { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.home__intro { font-size: 1.05rem; color: var(--muted); max-width: 38rem; margin: 2rem 0 2.5rem; font-style: italic; }
.lead { padding-bottom: 2.5rem; margin-bottom: 2.5rem; border-bottom: 2px solid var(--ink); }
.lead h2 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 1rem; max-width: 22ch; }
.lead h2 a { color: var(--ink); text-decoration: none; }
.lead h2 a:hover { color: var(--accent); }
.lead__dek { font-size: clamp(1.1rem, 2.4vw, 1.4rem); line-height: 1.45; color: var(--ink-2); max-width: 40rem; margin: 0 0 1.25rem; }
.lead__more { font-family: var(--sans); font-size: .95rem; margin: 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem 3rem; }
@media (min-width: 48rem) { .cards { grid-template-columns: 1fr 1fr; } }
.card h3 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 .6rem; letter-spacing: -0.01em; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.card__dek { margin: 0; color: var(--ink-2); font-size: 1rem; line-height: 1.55; }

/* ---------- article ---------- */
.article { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }
.article__header { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.article__header h1 { font-size: clamp(2.1rem, 6.5vw, 3.2rem); line-height: 1.07; letter-spacing: -0.02em; margin: 0 0 1rem; }
.dek { font-size: clamp(1.15rem, 2.6vw, 1.35rem); line-height: 1.45; color: var(--ink-2); margin: 0 0 1.25rem; }
.byline { font-family: var(--sans); font-size: .9rem; color: var(--muted); margin: 0 0 1rem; }
.byline span { color: var(--ink); font-weight: 600; }
.note {
  font-family: var(--sans); font-size: .82rem; line-height: 1.5; color: var(--ink-2);
  background: var(--paper-2); border-left: 3px solid var(--accent); padding: .7rem .9rem; margin: .75rem 0 0;
}
/* contents: a box without JS; a sticky "Contents" bar on phones/tablets; a pinned sidebar on wide screens */
.toc { font-family: var(--sans); font-size: .88rem; margin: 0 0 2.5rem; padding: 1rem 1.25rem; border: 1px solid var(--rule); }
.toc__title { margin: 0 0 .5rem; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.toc__toggle { display: none; }
.toc__list { margin: 0; padding: 0; list-style: none; }
.toc__list li { margin: 0; }
.toc__list a { display: block; padding: .3rem 0 .3rem .85rem; border-left: 2px solid var(--rule); color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.toc__list a:hover { color: var(--accent); }
.toc__list a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (max-width: 69.99rem) {
  .js .toc { position: sticky; top: 0; z-index: 10; margin: 0 calc(-1 * var(--gutter)) 2rem; padding: 0; border: 0; border-bottom: 1px solid var(--rule); background: var(--paper); }
  .js .toc__title { display: none; }
  .js .toc__toggle {
    display: flex; align-items: baseline; gap: .6rem; width: 100%; padding: .7rem var(--gutter); border: 0; background: none;
    font: 600 .82rem var(--sans); color: var(--ink); text-align: left; cursor: pointer;
  }
  .toc__label { letter-spacing: .1em; text-transform: uppercase; font-size: .72rem; color: var(--accent); flex: none; }
  .toc__current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 400; }
  .toc__toggle::after { content: "▾"; flex: none; color: var(--muted); }
  .js .toc.is-open .toc__toggle::after { content: "▴"; }
  .js .toc:not(.is-open) .toc__list { display: none; }
  .js .toc.is-open { box-shadow: 0 10px 18px rgba(0, 0, 0, .08); }
  .js .toc.is-open .toc__list { max-height: 60vh; overflow-y: auto; padding: 0 var(--gutter) .9rem; }
  .js .prose h2, .js .prose h3 { scroll-margin-top: 3.75rem; }
}
@media (min-width: 70rem) {
  .article--toc { max-width: var(--wide); display: grid; grid-template-columns: 15rem minmax(0, var(--measure)); column-gap: 3.5rem; justify-content: center; }
  .article--toc > * { grid-column: 2; }
  .article--toc > .toc { grid-column: 1; grid-row: 2 / span 5; align-self: start; position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; margin: 0; padding: 0; border: 0; }
}

.prose > * + * { margin-top: 1.1em; }
.prose p { margin: 0; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.prose p + p { margin-top: 1.1em; }
.prose h2 {
  font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.01em; margin: 2.75em 0 0;
  padding-top: 1.25rem; border-top: 1px solid var(--rule); scroll-margin-top: 1rem;
}
.prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: 1.2rem; line-height: 1.3; margin: 2em 0 0; scroll-margin-top: 1rem; }
.prose h2 + *, .prose h3 + * { margin-top: .9em; }
.prose hr { border: 0; text-align: center; margin: 2.5em 0; }
.prose hr::after { content: "· · ·"; color: var(--muted); letter-spacing: .5em; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .45em; }
.prose blockquote { margin-left: 0; padding-left: 1.1rem; border-left: 3px solid var(--accent); color: var(--ink-2); font-style: italic; }
.prose strong { font-weight: 700; }
.prose code { font-size: .9em; background: var(--paper-2); padding: .1em .3em; border-radius: 3px; }

/* tables: sans, tabular figures, scroll on small screens */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 1.5em; margin-bottom: .5em; border-top: 2px solid var(--ink);
  /* scroll shadows: appear only when there is more table to the left or right */
  background:
    linear-gradient(to right, var(--paper) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--shadow), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--shadow), transparent) right center / 14px 100% no-repeat scroll;
}
.prose table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .82rem; line-height: 1.4; font-variant-numeric: tabular-nums; }
.prose th { text-align: left; font-weight: 600; color: var(--ink); padding: .55rem .6rem; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
.prose td { padding: .5rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose tbody tr:nth-child(even) { background: var(--stripe); }
@media (max-width: 40rem) { .prose table { min-width: 34rem; } }

/* figures */
.prose figure { margin: 2em 0; }
.prose figcaption { font-family: var(--sans); font-size: .8rem; color: var(--muted); margin-top: .6rem; line-height: 1.45; }
.flow { color: var(--ink); display: block; width: 100%; max-width: 440px; margin: 0 auto; }
.flow .box { fill: var(--paper-2); stroke: var(--rule); }
.flow .box--accent { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
.flow .t { font-family: var(--sans); font-size: 14px; fill: var(--ink); }
.flow .t--b { font-weight: 700; }
.flow .t--m { fill: var(--muted); font-size: 11.5px; }
.flow .t--a { fill: var(--accent); font-weight: 700; }
.flow .arrow { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.flow .arrowhead { fill: var(--muted); }
.flow .band { font-family: var(--sans); font-size: 11px; letter-spacing: .12em; fill: var(--muted); font-weight: 600; }

/* sources: smaller type after the Sources heading */
.prose h2#sources ~ ul, .prose h2#sources ~ p { font-size: .88rem; line-height: 1.5; }
.prose h2#sources ~ ul li + li { margin-top: .35em; }

/* updates, share, related */
.updates { margin-top: 3rem; padding: 1rem 1.25rem; background: var(--paper-2); font-family: var(--sans); font-size: .88rem; }
.updates h2 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 .5rem; color: var(--muted); }
.updates ul { margin: 0; padding-left: 1.1rem; }
.updates time { font-weight: 600; margin-right: .35rem; }
.share {
  margin-top: 3rem; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; font-family: var(--sans); font-size: .9rem;
}
.share__label { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-right: .25rem; }
.share a, .share button {
  font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--rule); border-radius: 999px;
  padding: .35rem .85rem; text-decoration: none; cursor: pointer; line-height: 1.3;
}
.share a:hover, .share button:hover { border-color: var(--accent); color: var(--accent); }
.related { margin-top: 2.5rem; }
.related h2 { font-family: var(--sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 1rem; }
.related ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; }
.related a { text-decoration: none; display: block; }
.related__type { display: block; font-family: var(--sans); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.related__title { display: block; font-size: 1.2rem; line-height: 1.25; color: var(--ink); font-weight: 600; margin-top: .15rem; }
.related a:hover .related__title { color: var(--accent); }
.related p { margin: .3rem 0 0; font-size: .95rem; color: var(--ink-2); line-height: 1.5; }

/* ---------- charts (built by lib/charts.mjs) ---------- */
.chart { margin: 2.5em 0 2em; font-family: var(--sans); }
.chart__head { margin: 0; }
.chart__title { font-weight: 700; font-size: 1rem; line-height: 1.35; color: var(--ink); margin: 0; hyphens: none; }
.chart__sub { font-size: .85rem; line-height: 1.45; color: var(--ink-2); margin: .35rem 0 0; hyphens: none; }
.chart__legend { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; padding: 0; margin: .8rem 0 0; font-size: .8rem; color: var(--ink-2); }
.prose .chart__legend { padding: 0; }
.prose .chart__legend li + li { margin-top: 0; }
.prose .chart p { hyphens: none; }
.prose .chart p + p { margin-top: .35rem; }
.chart__key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.chart__key--line { width: 16px; height: 3px; border-radius: 2px; vertical-align: 3px; }
.chart__svg { display: block; width: 100%; height: auto; margin-top: .75rem; overflow: visible; }
.chart__svg--narrow { display: none; }
@media (max-width: 34rem) { .chart__svg--wide { display: none; } .chart__svg--narrow { display: block; } }
.chart__foot { margin-top: .75rem; font-size: .78rem; line-height: 1.5; color: var(--muted); }
.chart__foot p { margin: 0 0 .35rem; hyphens: none; }
.chart__source a { color: var(--muted); }
.chart__data { margin-top: .5rem; }
.chart__data summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.chart__data .table-wrap { margin-top: .5rem; }
.chart__csv { display: inline-block; margin-top: .4rem; color: var(--ink-2); font-weight: 600; }
.ch-grid { stroke: var(--rule); stroke-width: 1; }
.ch-base { stroke: var(--axis); stroke-width: 1; }
.ch-tick { fill: var(--muted); font: 11px var(--sans); font-variant-numeric: tabular-nums; }
.ch-cat { fill: var(--ink-2); font: 12px var(--sans); }
.ch-val { fill: var(--ink); font: 600 12px var(--sans); font-variant-numeric: tabular-nums; }
.ch-endlabel { fill: var(--ink-2); font: 600 12px var(--sans); }
.ch-ref { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.ch-reflabel { fill: var(--ink-2); font: 600 11.5px var(--sans); }
.ch-ann { fill: var(--ink); font: 700 13px var(--sans); }
.ch-arrow { stroke: var(--ink-2); stroke-width: 1.25; }
.ch-arrowhead { fill: var(--ink-2); }
.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { stroke: var(--paper); stroke-width: 2; }
.ch-mark { outline: none; transition: opacity .12s; }
.ch-mark:hover, .ch-mark:focus-visible { opacity: .8; }
.ch-mark:focus-visible { stroke: var(--ink); stroke-width: 1.5; }
.ch-hitg { outline: none; }
.ch-hit { fill: transparent; }
.ch-xhair { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.ch-hitg:hover .ch-xhair, .ch-hitg:focus .ch-xhair { opacity: 1; }
.chart-tip {
  position: fixed; z-index: 30; display: none; pointer-events: none; max-width: 16rem;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12); padding: .45rem .6rem; font: .78rem/1.4 var(--sans);
}
.chart-tip__t { color: var(--muted); font-size: .72rem; margin-bottom: .2rem; }
.chart-tip__row { display: flex; align-items: center; gap: .45rem; }
.chart-tip__k { flex: none; width: 12px; height: 3px; border-radius: 2px; }
.chart-tip__v { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-tip__l { color: var(--ink-2); }

@media print {
  .site-header nav, .share, .toc, .skip, .site-footer { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: inherit; }
}
