:root {
  --bg: var(--paper);
  --panel: #fff;
  --s1: #247fd8;
  --s2: #eda100;
  --s3: #d95d91;
  --s4: #008300;
  --s1-ink: #0b0b0b;
  --s2-ink: #0b0b0b;
  --s3-ink: #0b0b0b;
  --s4-ink: #fff;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --s1-text: #1c5cab;
  --s3-text: #a52b60;
  --chart-accent-text: #a63b12;
  --control-active-bg: #1c5cab;
  --control-active-ink: #fff;
  --control-border: #56595c;
}

:root[data-theme="dark"] {
  --bg: var(--paper);
  --panel: #1d2025;
  --s1: #3987e5;
  --s2: #c98500;
  --s3: #d55181;
  --s4: #008300;
  --viz-grid: #47453f;
  --viz-axis: #aaa69e;
  --s1-text: #86b6ef;
  --s3-text: #ef8caf;
  --chart-accent-text: #ff7540;
  --control-active-bg: #86b6ef;
  --control-active-ink: #0b0b0b;
  --control-border: #aaa69e;
}

/* The post now uses the site's ordinary .article-body markup. Keep only the
   visualisation components page-specific; prose, headings and lists inherit
   the shared article theme. */
:root[data-theme="dark"] .article-body .viz text { fill: var(--body-copy); }

.article-body > div[id^="fig-"] { margin-bottom: 30px; margin-top: 30px; }
.article-body div[id^="fig-"] .figkicker {
  color: var(--chart-accent-text);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: .08em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.article-body div[id^="fig-"] h3.figtitle {
  font-size: 1.3rem;
  margin: 0 0 4px;
}
.article-body div[id^="fig-"] > p.why,
.article-body div[id^="fig-"] > div > p.why {
  color: var(--muted);
  font-family: var(--sans);
  font-size: .82rem;
  line-height: 1.55;
  margin: 0 0 12px;
  max-width: none;
}
.article-body .chart-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 18px;
  min-width: 0;
  overflow: hidden;
  padding: 18px 20px;
  position: relative;
  width: 100%;
}
.article-body .chart-wrap canvas {
  background: var(--panel);
  display: block;
  max-width: 100%;
  width: 100% !important;
}
.article-body .chart-wrap svg { background: var(--panel); }
.article-body div[id^="fig-"] details { font-family: var(--sans); font-size: .78rem; margin: 10px 0 24px; }
.article-body div[id^="fig-"] summary { color: var(--muted); cursor: pointer; }
.article-body div[id^="fig-"] table { font-size: .75rem; margin: 10px 0 0; }
.article-body div[id^="fig-"] .validation-rate-note td {
  color: var(--muted);
  line-height: 1.5;
  padding-top: 1rem;
  text-align: left;
}
.article-body .tier-toggle button,
.article-body div[id^="fig-"] button,
.article-body div[id^="fig-"] select {
  background: var(--panel);
  border: 1px solid var(--control-border);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--sans);
  min-height: 32px;
}
.article-body div[id^="fig-"] button:hover { border-color: var(--ink); }
.article-body div[id^="fig-"] button:focus-visible,
.article-body div[id^="fig-"] select:focus-visible {
  outline: 2px solid var(--chart-accent-text);
  outline-offset: 2px;
}

@media (max-width: 767.98px) {
  .article-body .chart-wrap { padding: 14px 12px; }
}

.article-body .additional-charts {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-bottom: 3rem;
  padding: 1rem 0;
}
.article-body .additional-charts > summary {
  color: var(--ink);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
}
.article-body .additional-charts[open] > summary { margin-bottom: 1.5rem; }

.article-body .dataset-stats {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.5rem 0;
  background: var(--line);
  border: 1px solid var(--line);
}
.article-body .dataset-stats > div {
  background: var(--paper);
  min-width: 0;
  padding: 1.1rem;
}
.article-body .dataset-stats dt {
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 400;
  line-height: 1;
  margin-bottom: .45rem;
}
.article-body .dataset-stats dd {
  color: var(--muted);
  font-family: var(--sans);
  font-size: .76rem;
  line-height: 1.45;
  margin: 0;
}

@media (max-width: 767.98px) {
  .article-body .dataset-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 419.98px) {
  .article-body .dataset-stats { grid-template-columns: 1fr; }
}
