:root {
  --bg: #f7f7f5;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #1f6feb;
  --card: #ffffff;
  --card-hover: #f3f6fa;
  --border: #d8dee4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --text: #e6edf3;
    --muted: #9198a1;
    --accent: #4493f8;
    --card: #161b22;
    --card-hover: #1c2330;
    --border: #30363d;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117;
  --text: #e6edf3;
  --muted: #9198a1;
  --accent: #4493f8;
  --card: #161b22;
  --card-hover: #1c2330;
  --border: #30363d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

a { color: var(--accent); }

h1 { margin: 0 0 4px; font-size: 2rem; line-height: 1.25; }
h2 { font-size: 1.2rem; }

.subtitle { margin: 0 0 32px; color: var(--muted); }

.breadcrumbs {
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--muted);
}
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs span { margin: 0 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; }

/* A whole card that acts as a link */
a.card {
  display: block;
  color: inherit;
  text-decoration: none;
}
a.card:hover { background: var(--card-hover); border-color: var(--accent); }
a.card h2 { color: var(--accent); margin-bottom: 4px; }
a.card p { margin: 0; color: var(--muted); }

.empty { color: var(--muted); font-style: italic; }

ul { padding-left: 20px; }

footer { margin-top: 32px; color: var(--muted); font-size: 0.9rem; }

/* ---------- Study guide pages ---------- */

:root {
  --term-bg: rgba(31, 111, 235, 0.08);
  --term-bg-hover: rgba(31, 111, 235, 0.18);
  --panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  --update-bg: #fff8e6;
  --update-border: #e0b64a;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --farmland: #008300;
  --desert: #ddd4bf;
  --grid-line: #e4e7eb;
  --neutral-bar: #8c959f;
  --gap-fill: rgba(42, 120, 214, 0.14);
  --stage-a: rgba(31, 111, 235, 0.05);
  --stage-hover: rgba(31, 111, 235, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --term-bg: rgba(68, 147, 248, 0.12);
    --term-bg-hover: rgba(68, 147, 248, 0.26);
    --panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --update-bg: #2b2412;
    --update-border: #8a6d1f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --farmland: #008300;
    --desert: #4a4538;
    --grid-line: #2a3038;
    --neutral-bar: #6e7681;
    --gap-fill: rgba(57, 135, 229, 0.2);
    --stage-a: rgba(68, 147, 248, 0.07);
    --stage-hover: rgba(68, 147, 248, 0.2);
  }
}
:root[data-theme="dark"] {
  --term-bg: rgba(68, 147, 248, 0.12);
  --term-bg-hover: rgba(68, 147, 248, 0.26);
  --panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --update-bg: #2b2412;
  --update-border: #8a6d1f;
  --series-1: #3987e5;
  --series-2: #d95926;
  --farmland: #008300;
  --desert: #4a4538;
  --grid-line: #2a3038;
  --neutral-bar: #6e7681;
  --gap-fill: rgba(57, 135, 229, 0.2);
  --stage-a: rgba(68, 147, 248, 0.07);
  --stage-hover: rgba(68, 147, 248, 0.2);
}

.guide main { max-width: 760px; }

.how-to {
  font-size: 0.95rem;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
  margin: 0 0 32px;
}

.guide h2 {
  font-size: 1.5rem;
  margin: 48px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.guide h3 { font-size: 1.15rem; margin: 32px 0 8px; }

.pages {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  margin-left: 8px;
  vertical-align: middle;
}

/* Clickable words and sentences */
.term {
  font: inherit;
  color: inherit;
  background: var(--term-bg);
  border: 0;
  border-bottom: 2px dotted var(--accent);
  border-radius: 3px 3px 0 0;
  padding: 0 2px;
  cursor: pointer;
  text-align: inherit;
}
.term:hover, .term:focus-visible { background: var(--term-bg-hover); outline: none; }
.term.key { font-weight: 600; }

/* Asides */
.field-note, .figure-card, .update {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 20px 0;
  background: var(--card);
}
.field-note .label, .figure-card .label, .update .label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.update { background: var(--update-bg); border-color: var(--update-border); }
.figure-card { cursor: pointer; }
.figure-card:hover { border-color: var(--accent); }
.figure-card p { margin: 4px 0 0; }

/* Charts */
.chart {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 16px 18px 10px;
  margin: 24px 0;
}
.chart h4 { margin: 0 0 2px; font-size: 1rem; }
.chart .chart-sub { margin: 0 0 12px; font-size: 0.85rem; color: var(--muted); }
.bars { display: grid; gap: 4px; }
.bar-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 4.5rem;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
}
.bar-row[data-note], .bar-track [data-note] { cursor: pointer; }
.bar-row[data-note]:hover { background: var(--card-hover); }
.bar-row[data-note]:focus-visible, .bar-track [data-note]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.bar-label { font-size: 0.9rem; text-align: right; line-height: 1.25; }
.bar-val { font-size: 0.85rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.bar-track { display: flex; height: 18px; }
.bar-track.stack { gap: 2px; height: 26px; }
.bar { height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; }
.bar-track.stack .bar { border-radius: 4px; }
.bar-track.stack .bar:hover { opacity: 0.85; }
.bar.s1 { background: var(--series-1); }
.bar.s2 { background: var(--series-2); }
.bar.farmland { background: var(--farmland); }
.bar.desert { background: var(--desert); }
.bar.range-low { opacity: 0.3; border-radius: 0; }
.bar-group-label { font-weight: 600; font-size: 0.9rem; margin: 8px 0 0 6px; }
@media (max-width: 480px) {
  .bar-row { grid-template-columns: 5.8rem 1fr 3.9rem; gap: 8px; padding: 4px 2px; }
  .bar-label { font-size: 0.82rem; }
}
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.85rem; color: var(--muted); margin: 0 0 10px; }
.legend span::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--swatch);
}
.chart .tap-hint { font-size: 0.8rem; color: var(--muted); margin: 8px 0 0; }

/* Cluster cards */
.clusters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 20px 0; }
.cluster {
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
}
.cluster:hover, .cluster:focus-visible { border-color: var(--accent); outline: none; }
.cluster .rank { font-size: 0.75rem; font-weight: 700; color: var(--accent); letter-spacing: 0.05em; }
.cluster strong { display: block; font-size: 1.05rem; margin: 2px 0; }
.cluster span { font-size: 0.85rem; color: var(--muted); }

/* Hover tooltip for chart marks */
.tip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
}
.tip.show { opacity: 1; }

/* Explanation panel: right drawer on wide screens, bottom sheet on phones */
.panel {
  position: fixed;
  z-index: 20;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--panel-shadow);
  transform: translateX(105%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.panel.open { transform: none; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; padding: 0; border: 0; font-size: 1.2rem; }
.panel-close {
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}
.panel-body { overflow-y: auto; padding: 4px 20px 24px; }
.panel-body h3 {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 4px;
}
.panel-body p { margin: 4px 0 8px; }
.panel-body .ap { border-left: 3px solid var(--accent); padding-left: 10px; }
.panel-body .update { margin: 12px 0; }

@media (max-width: 700px) {
  .panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 75vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    transform: translateY(105%);
  }
}

/* Quiz checklist */
.checklist { list-style: none; padding: 0; }
.checklist li { margin: 6px 0; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { margin-top: 5px; flex-shrink: 0; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }

/* Visually hidden, still read by screen readers (chart data tables) */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Neutral / reference bars and cut-off bars */
.bar.bar-neutral { background: var(--neutral-bar); }
.bar-row.broken .bar {
  border-radius: 0;
  -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 88%, transparent 90%, #000 90%, #000 94%, transparent 94%, transparent 96%, #000 96%);
  mask-image: linear-gradient(to right, #000 88%, transparent 88%, transparent 90%, #000 90%, #000 94%, transparent 94%, transparent 96%, #000 96%);
}

/* Numbered timeline */
ol.timeline { padding-left: 22px; }
ol.timeline > li { margin-bottom: 10px; }

/* Calculator */
.calc {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 16px 18px;
  margin: 24px 0;
}
.calc h4 { margin: 0 0 2px; font-size: 1rem; }
.calc-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.calc-presets button, .dtm-buttons button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.calc-presets button:hover { border-color: var(--accent); }
.calc-inputs { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; }
.calc-inputs label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 4px; }
.calc-inputs input {
  font: inherit;
  font-size: 1rem;
  width: 8rem;
  padding: 6px 8px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.calc-out { display: grid; gap: 6px; }
.calc-out > div { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.calc-label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); min-width: 9rem; }
.calc-out span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Population pyramids */
.pyramids { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.pyramid {
  font: inherit;
  color: inherit;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px 12px;
  cursor: pointer;
}
.pyramid:hover, .pyramid:focus-visible { border-color: var(--accent); outline: none; }
.pyramid strong { display: block; font-size: 0.95rem; }
.pyramid .psub { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; }
.prows { display: grid; gap: 2px; }
.prow { display: grid; grid-template-columns: 1fr 3rem 1fr; align-items: center; height: 13px; }
.pbar { display: block; height: 11px; }
.pbar.m { justify-self: end; background: var(--series-1); border-radius: 3px 0 0 3px; }
.pbar.f { justify-self: start; background: var(--series-2); border-radius: 0 3px 3px 0; }
.page { font-size: 0.68rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Demographic transition chart */
.chart.dtm svg { display: block; width: 100%; height: auto; }
.dtm .gridline { stroke: var(--grid-line); stroke-width: 1; }
.dtm .axis { stroke: var(--muted); stroke-width: 1; }
.dtm .tick { fill: var(--muted); font-size: 13px; }
.dtm-stage { fill: transparent; cursor: pointer; }
.dtm-stage.odd { fill: var(--stage-a); }
.dtm-stage:hover, .dtm-stage:focus-visible { fill: var(--stage-hover); outline: none; }
.dtm-gap { fill: var(--gap-fill); pointer-events: none; }
.dtm-line { fill: none; stroke-width: 3; stroke-linecap: round; pointer-events: none; }
.dtm-line.birth { stroke: var(--series-1); }
.dtm-line.death { stroke: var(--series-2); }
.dtm-buttons {
  display: grid;
  grid-template-columns: 40fr repeat(5, 100fr) 10fr;
  gap: 0;
  margin-top: 6px;
}
.dtm-buttons button {
  border-radius: 6px;
  padding: 6px 2px;
  margin: 0 2px;
  line-height: 1.2;
}
.dtm-buttons button:first-child { grid-column: 2; }
.dtm-buttons button:hover, .dtm-buttons button:focus-visible { border-color: var(--accent); outline: none; }
.dtm-buttons strong { display: block; font-size: 0.8rem; }
.dtm-buttons span { display: block; font-size: 0.7rem; color: var(--muted); }
@media (max-width: 480px) {
  .dtm-buttons span { display: none; }
  .dtm-buttons strong { font-size: 0.72rem; }
}

/* Data table */
.table-wrap { overflow-x: auto; margin: 16px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table caption { text-align: left; font-size: 0.85rem; color: var(--muted); padding-bottom: 6px; }
.data-table th, .data-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.data-table td:nth-child(n+2), .data-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .dtm .tick { font-size: 20px; }
  .calc-out > div { flex-direction: column; gap: 0; }
}

/* Site header: breadcrumbs on the left, theme toggle on the right */
.site-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
}
.site-header .breadcrumbs { margin: 0; }
.guide .site-header { max-width: 760px; }
main { padding-top: 16px; }

/* Theme toggle (same behavior as the main site). Hidden in the markup and revealed by its
   script, so a visitor with JS off never sees a control that cannot do anything. Which icon
   shows is decided here from data-theme, so it is right in the first frame. */
.theme-toggle {
  flex: none; appearance: none; border: 0; background: none; cursor: pointer;
  padding: 7px; margin: -7px 0 -7px auto; border-radius: 10px; line-height: 0;
  color: var(--muted); transition: color .15s ease, background-color .15s ease;
}
.theme-toggle:hover { color: var(--text); background: var(--card-hover); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-toggle svg { width: 19px; height: 19px; display: none; }
html:not([data-theme]) .theme-toggle .i-light,
html[data-theme="light"] .theme-toggle .i-light,
html[data-theme="dark"] .theme-toggle .i-dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-toggle .i-light { display: none; }
  html:not([data-theme]) .theme-toggle .i-dark { display: block; }
}

/* ---------- Hover and press feedback for every button ----------
   Hover rules sit inside (hover: hover) so a tap on a phone does not leave an element
   stuck in its hover state; :active and :focus-visible work everywhere. */
.panel-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: -4px -6px 0 0;
  border-radius: 8px;
  transition: color .15s ease, background-color .15s ease;
}
.panel-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel-close:active { background: var(--term-bg-hover); }

.figure-card, .cluster, .pyramid, .calc-presets button, .dtm-buttons button, .checklist label, a.card, .bar-row[data-note] {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.figure-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.calc-presets button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.checklist label { border-radius: 6px; padding: 2px 6px; margin: 0 -6px; }

.figure-card:active, .cluster:active, .pyramid:active,
.calc-presets button:active, .dtm-buttons button:active { background: var(--term-bg-hover); }

@media (hover: hover) {
  .panel-close:hover { color: var(--text); background: var(--card-hover); }
  .figure-card:hover, .cluster:hover, .pyramid:hover,
  .calc-presets button:hover, .dtm-buttons button:hover { background: var(--card-hover); border-color: var(--accent); }
  .checklist label:hover { background: var(--card-hover); }
}

/* ---------- "Apply it" boxes (under charts and inside notes) ---------- */
.apply {
  margin: 14px 0 4px;
  padding: 10px 14px;
  border-left: 3px solid var(--series-2);
  background: var(--term-bg);
  border-radius: 0 6px 6px 0;
}
.apply .label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.apply p { margin: 0; font-size: 0.93rem; }
.panel-body .apply-p { border-left: 3px solid var(--series-2); padding-left: 10px; }
.panel-body .note-src, .note-src { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }

/* ---------- SVG line chart (world population) ---------- */
.svgchart svg { display: block; width: 100%; height: auto; }
.svgchart .gridline { stroke: var(--grid-line); stroke-width: 1; }
.svgchart .tick { fill: var(--muted); font-size: 12px; }
.wp-line { fill: none; stroke: var(--series-1); stroke-width: 2.5; stroke-linejoin: round; }
.wp-line.proj { stroke-dasharray: 5 5; }
.wp-dot { fill: var(--series-1); stroke: var(--card); stroke-width: 2; }
.wp-dot.proj { fill: var(--card); stroke: var(--series-1); stroke-width: 2; }
.wp-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.svgchart .hit { fill: transparent; cursor: pointer; }
.svgchart [data-note] { cursor: pointer; }
.svgchart [data-note]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 480px) {
  .svgchart .tick { font-size: 17px; }
  .wp-label { font-size: 16px; }
}

/* ---------- Book pyramids (17 age groups) ---------- */
.pyramid .prows { gap: 1px; }
.pyramid .prow { height: 10px; }
.pyramid .pbar { height: 8px; }
.pyramid .page { font-size: 0.62rem; line-height: 1; }
.paxis {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- DTM additions ---------- */
.dtm-mark { fill: var(--series-2); stroke: var(--card); stroke-width: 2.5; pointer-events: none; }
.dtm .hit { fill: transparent; cursor: pointer; }
.dtm g[data-note]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.legend .dot-key::before { border-radius: 50%; }
.dtm-buttons .cent { display: block; font-style: normal; font-size: 0.66rem; color: var(--muted); }
@media (max-width: 480px) { .dtm-buttons .cent { display: none; } }

/* ---------- Scatter: India's states ---------- */
.scatter { position: relative; padding: 6px 10px 34px 46px; }
.sc-plot {
  position: relative;
  aspect-ratio: 16 / 10;
  border-left: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
}
.sc-y, .sc-x { position: absolute; pointer-events: none; }
.sc-y { left: 0; right: 0; height: 0; border-top: 1px solid var(--grid-line); }
.sc-x { top: 0; bottom: 0; width: 0; border-left: 1px solid var(--grid-line); }
.sc-y em, .sc-x em { position: absolute; font-style: normal; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sc-y em { right: calc(100% + 6px); transform: translateY(-50%); }
.sc-y:first-child em { transform: translateY(-50%); }
.sc-x em { top: calc(100% + 4px); transform: translateX(-50%); white-space: nowrap; }
.sc-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: 0 0 -6px -6px;
  border-radius: 50%;
  border: 2px solid var(--card);
  cursor: pointer;
  z-index: 1;
}
.sc-dot.s1 { background: var(--series-1); }
.sc-dot.s2 { background: var(--series-2); }
.sc-dot::after { content: ""; position: absolute; inset: -9px; }  /* bigger tap target */
.sc-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .sc-dot:hover { transform: scale(1.35); z-index: 2; } }
.sc-lbl {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}
.sc-lbl.lbl-r { left: 12px; }
.sc-lbl.lbl-l { right: 12px; }
.sc-ylab, .sc-xlab { position: absolute; margin: 0; font-size: 0.75rem; color: var(--muted); }
.sc-xlab { bottom: 4px; right: 10px; }
.sc-ylab { top: -2px; left: 46px; transform: translateY(-100%); }
.sc-table { margin-top: 10px; font-size: 0.9rem; }
.sc-table summary { cursor: pointer; color: var(--accent); }
@media (max-width: 480px) {
  .sc-plot { aspect-ratio: 4 / 3.4; }
  .sc-lbl { font-size: 0.64rem; }
}
.sc-lbl.lbl-t, .sc-lbl.lbl-b { left: 50%; top: auto; transform: translateX(-50%); }
.sc-lbl.lbl-t { bottom: 11px; }
.sc-lbl.lbl-b { top: 11px; }
.scatter { padding-top: 26px; }
.sc-ylab { top: 4px; transform: none; }

/* A closed panel is fully hidden (not just moved off-screen), so it can't peek in during
   iOS rubber-band scrolling and can't be reached with Tab. visibility waits for the slide-out
   to finish before hiding, and shows immediately on open. */
.panel { visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; }
.panel.open { visibility: visible; transition: transform 0.2s ease, visibility 0s linear 0s; }

/* Subject card that isn't live yet */
.card.card-soon { opacity: 0.6; }
.card.card-soon h2 { margin-top: 0; margin-bottom: 4px; }
.card.card-soon p { margin: 0; color: var(--muted); }
/* Breadcrumbs wrap between items, never inside one ("Reading 2.1–2.2" stays whole) */
.breadcrumbs a, .breadcrumbs .here { white-space: nowrap; }
.breadcrumbs span:not(.here) { margin: 0 6px; }
.breadcrumbs .here { margin: 0; }
