:root {
  --paper: #ffffff;
  --paper-2: #f4f1ea;
  --ink: #2b241b;
  --muted: #5c5348;
  --rule: #003e5f;
  --navy: #003e5f;
  --khaki: #a68f6e;
  --internal: #7a1f1f;
  --external: #003e5f;
  --exogenous: #a68f6e;
  --citizen: #003e5f;
  --other: #7a1f1f;
  --gold: #a68f6e;
  --line: rgba(0, 62, 95, 0.16);
  --focus: #003e5f;
  --header-dark: #0e1a24;
  --font-display: "Libre Baskerville", Georgia, serif;
  --font-ui: Montserrat, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --fs-display: clamp(2.1rem, 5.4vw, 4rem);
  --fs-dek: 1.35rem;
  --fs-lede: 1rem;
  --fs-section: 1.5rem;
  --fs-stat: 1.7rem;
  --fs-body: 1rem;
  --fs-caption: 0.8125rem;
  --fs-kicker: 0.6875rem;
  --lh-display: 0.98;
  --lh-lede: 1.5;
  --lh-body: 1.6;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 40px;
  --space-5: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: var(--lh-body);
}

body {
  min-height: 100vh;
  background-image: none;
}

a { color: var(--navy); }
a:hover { text-decoration-thickness: 2px; }

.wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.masthead {
  max-width: 66rem;
  margin: 0 0 var(--space-2);
}

h1 {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-weight: 700;
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  margin: 0 0 10px;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.dek {
  font-family: var(--font-display);
  font-size: var(--fs-dek);
  line-height: 1.4;
  color: var(--ink);
  margin: 0 0 10px;
  max-width: 62rem;
}

.dek strong { font-weight: 700; }

.lede {
  max-width: 56rem;
  font-size: var(--fs-lede);
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 14px;
}

.kicker {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--fs-kicker);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--navy);
  margin: 0 0 var(--space-1);
}

.file-warn {
  border-left: 4px solid var(--rule);
  padding: 8px 14px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* View tabs — underline, never filled buttons. */
nav.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  border-bottom: 1px solid var(--line);
  margin: var(--space-4) 0 var(--space-3);
}

nav.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 2px 9px;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

nav.tabs button:hover { background: transparent; color: var(--ink); border-bottom-color: var(--line); }

nav.tabs button[aria-pressed="true"] {
  background: transparent;
  color: var(--navy);
  border-bottom-color: var(--navy);
}

button, select {
  font-family: inherit;
  font-size: 0.95rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 8px 14px;
  cursor: pointer;
}

button:hover, select:hover { background: rgba(0, 62, 95, 0.07); }

button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

button:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toggle { display: flex; gap: 0; }
.toggle button { border-right-width: 0; }
.toggle button:last-child { border-right-width: 1px; }

.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 6px;
  vertical-align: -1px;
}
.swatch.citizen { background: var(--citizen); }
.swatch.other { background: var(--other); }

/* Compact stat row under the dek: four tiles, never taller than 80px. */
#statline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px var(--space-3);
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

#statline .k {
  display: block;
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
  margin-bottom: 2px;
}

#statline strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.chart-frame {
  width: 100%;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
#chart-bubbles, #chart-area {
  position: relative;
  overflow: visible;
}

.omelas-svg { display: block; width: 100%; height: auto; }
.chart-paper { fill: #f7f5f1; }
.grid { stroke: rgba(0, 62, 95, 0.12); stroke-width: 1; }
.grid-year { stroke: rgba(0, 62, 95, 0.08); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }
.axis-title {
  fill: var(--ink);
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.area-citizen { fill: var(--citizen); opacity: 0.92; }
.area-other { fill: var(--other); opacity: 0.88; }
.area-internal { fill: var(--internal); opacity: 0.92; }
.area-external { fill: var(--external); opacity: 0.92; }
.area-exogenous { fill: var(--exogenous); opacity: 0.92; }
.area-stroke { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.label-lead { stroke: var(--gold); stroke-width: 1; }
.event-label {
  fill: var(--ink);
  font-size: 12px;
  font-family: "Libre Baskerville", Georgia, serif;
  font-style: italic;
}
.bar-name { fill: var(--ink); font-size: 13px; font-family: var(--font-display); }
.bar-num { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.bar-citizen { fill: var(--citizen); }
.bar-other { fill: var(--other); }
.ci-whisker { stroke: var(--ink); stroke-width: 1.2; }

.country-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: start;
}

#bmap h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 10px;
}

#bmap ol { padding-left: 1.1em; margin: 0 0 12px; }
#bmap li { margin-bottom: 10px; }
#bmap .years { color: var(--gold); font-size: 0.85rem; }
#bmap .notes { color: var(--muted); font-size: 0.95rem; }

.caption { color: var(--muted); font-size: var(--fs-caption); line-height: 1.45; margin: 0 0 var(--space-2); }

#country-heading {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin: 0 0 8px;
}

#appendix details {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

#appendix summary {
  cursor: pointer;
  font-family: "Libre Baskerville", Georgia, serif;
  font-size: 1.35rem;
  display: flex;
  justify-content: space-between;
}

#appendix summary span { color: var(--muted); font-size: 0.9rem; font-family: var(--font-ui); }

/* Event count as a quiet pill, not a second headline. */
#appendix summary .pill {
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  padding: 2px 11px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

#appendix table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 12px 0 24px;
}

#appendix .appendix-table { min-width: 660px; font-size: 0.8125rem; }
#appendix .table-scroll { margin-bottom: 0; }

#appendix th, #appendix td {
  text-align: left;
  padding: 6px 14px 6px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

#appendix thead th {
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 7px;
  border-bottom: 2px solid var(--navy);
  vertical-align: bottom;
}

#appendix tbody tr:hover td { background: rgba(0, 62, 95, 0.04); }
#appendix .ap-name { font-weight: 600; }
#appendix .ap-kind { white-space: nowrap; color: var(--muted); }
#appendix .ap-type { color: var(--muted); }
#appendix .ap-kind .swatch {
  width: 0.7em;
  height: 0.7em;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: baseline;
}
#appendix .ap-src a { font-size: 0.95em; }

footer.method {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 3px solid var(--rule);
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 46rem;
}

@media (max-width: 860px) {
  #statline { grid-template-columns: 1fr 1fr; }
  .country-layout { grid-template-columns: 1fr; }
  h1 { font-size: 2.4rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .area-citizen, .area-other, .area-internal, .area-external, .area-exogenous, .area-stroke {
    animation: rise 1.1s ease both;
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}

.filter-block .kicker { margin-bottom: 6px; }

.section-title, main h2, .biblio-wrap h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-section);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: var(--space-4) 0 var(--space-1);
}

.century-card h3, .century-card h4 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
  margin: var(--space-2) 0 var(--space-1);
}

.map-actions { display: flex; gap: 8px; margin-left: auto; }

.atlas-frame { width: 100%; margin-bottom: var(--space-2); overflow: hidden; }
.atlas-ocean { fill: #d7e3ea; }
.atlas-graticule { stroke: rgba(0, 62, 95, 0.12); stroke-width: 1; }
.atlas-landmass { fill: #c5d0d6; stroke: none; }
.atlas-land { fill: #9aa8b0; stroke: #f7f5f1; stroke-width: 0.8; }
.atlas-plate.is-on .atlas-land { fill: var(--navy); stroke: #f7f5f1; }
.atlas-plate:hover .atlas-land, .atlas-plate:focus .atlas-land { fill: #5a1a1a; }
.atlas-plate.is-on:hover .atlas-land, .atlas-plate.is-on:focus .atlas-land { fill: #002a42; }
.atlas-label {
  font-size: 10px;
  font-family: var(--font-ui);
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(247, 245, 241, 0.9);
  stroke-width: 3px;
}
.atlas-plate.is-on .atlas-label { fill: var(--paper); stroke: rgba(0, 42, 66, 0.55); }
.atlas-plate { cursor: pointer; }
.atlas-plate:focus { outline: none; }
.atlas-plate:focus .atlas-land { stroke: var(--focus); stroke-width: 1.8; }

.chip-row, .arena-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chart-stage {
  position: relative;
  min-height: 360px;
  overflow: visible;
}
.chart-stage .chart-layer {
  transition: opacity 0.7s ease, transform 0.8s ease;
}
.chart-stage[data-chart="bubbles"] #chart-area {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}
.chart-stage[data-chart="area"] #chart-bubbles {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(28px) scale(0.96);
}
.bubble-node {
  cursor: pointer;
  /* keyed updates: a persisting bubble travels to its new place, never rebuilt */
  transition: transform 0.6s ease, opacity 0.35s ease;
}
.chart-stage[data-chart="area"] .bubble-node {
  opacity: 0;
}
.bubble-circle {
  stroke: rgba(14, 26, 36, 0.35);
  stroke-width: 0.6;
  transition: r 0.6s ease, stroke-width 0.18s ease, stroke 0.18s ease;
}
.bubble-node.is-focus { opacity: 1; }
.conflict-hover {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  min-width: 196px;
  max-width: 300px;
  padding: 10px 14px 12px;
  background: #ffffff;
  border-left: 3px solid var(--navy);
  box-shadow: 0 10px 28px rgba(14, 26, 36, 0.14);
}
.conflict-hover[hidden] { display: none; }
.hover-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.15;
  margin: 0 0 4px;
  color: var(--ink);
}
.hover-detail {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  margin: 0;
  color: var(--ink);
}
.hover-deaths {
  font-family: var(--font-ui);
  font-size: var(--fs-kicker);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 0 0;
}
.swatch-internal { background: var(--internal); }
.swatch-external { background: var(--external); }
.swatch-exogenous { background: var(--exogenous); }

.footnotes-drawer {
  margin-top: 48px;
  padding: 12px 0;
  border-top: 3px solid var(--navy);
}
.footnotes-drawer summary {
  cursor: pointer;
  font-family: Montserrat, sans-serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--navy);
}
.footnotes-drawer[open] summary { margin-bottom: 12px; }

.wiki-link { font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85rem; }

.chip-row button[aria-pressed="true"] { background: var(--rule); color: var(--paper); border-color: var(--rule); }
.check { font-size: 0.95rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.check input { accent-color: var(--rule); width: 1.1em; height: 1.1em; }

/* ==========================================================================
   Tables — one scanning vocabulary: right-aligned tabular numbers, compact
   ranges, a sticky head on the comparison table, rules instead of prose.
   The body never scrolls sideways; a wide table scrolls inside .table-scroll.
   ========================================================================== */

.table-scroll { margin-bottom: 28px; }

@media (max-width: 900px) {
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Every numeric cell in every table reads the same way. */
.compare .num,
.century-table .num,
#appendix .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nil { color: rgba(92, 83, 72, 0.45); }

/* --- Comparison table ---------------------------------------------------- */
.compare {
  width: 100%;
  min-width: 680px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.compare th,
.compare td {
  text-align: left;
  padding: 9px 16px 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

.compare th:last-child, .compare td:last-child { padding-right: 0; }

.compare thead th,
.compare thead td {
  position: sticky;
  z-index: 2;
  background: var(--paper);
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: bottom;
}

.compare thead tr.compare-groups th,
.compare thead tr.compare-groups td {
  top: 0;
  height: 22px;
  padding-top: 2px;
  padding-bottom: 4px;
  border-bottom: 0;
}

.compare thead tr.compare-groups th.group-head {
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.compare thead tr.compare-cols th {
  top: 22px;
  padding-bottom: 7px;
  border-bottom: 2px solid var(--navy);
}

.compare .kind-col .swatch {
  width: 0.7em;
  height: 0.7em;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: baseline;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.th-sort:hover { color: var(--navy); }
.compare .sortable.is-sorted { color: var(--navy); }
.compare .sortable:not(.is-sorted) .caret { opacity: 0.22; }
.caret { font-size: 0.7em; line-height: 1; }

.compare tbody tr:hover th,
.compare tbody tr:hover td { background: rgba(0, 62, 95, 0.05); }
.compare tbody tr:last-child th,
.compare tbody tr:last-child td { border-bottom: 0; }

.c-name {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--ink);
}

.compare .kind-col { color: var(--muted); }

/* The Sacrificed cell carries its own magnitude: a navy bar under the number. */
.cell-mag { min-width: 128px; }
.mag-val { display: block; }
.mag-bar {
  display: block;
  height: 4px;
  margin-top: 4px;
  background: rgba(0, 62, 95, 0.1);
}
.mag-bar i {
  display: block;
  height: 100%;
  margin-left: auto;
  background: var(--navy);
}

/* --- Century summaries: one table per century ---------------------------- */
.century-card {
  border-top: 1px solid var(--line);
  padding: 8px 0 22px;
}
.century-card h3 span { color: var(--gold); font-size: 0.9rem; margin-left: 8px; }
.century-card .table-scroll { margin-bottom: 0; }

.century-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.8125rem;
  table-layout: fixed;
}

.century-table thead th {
  text-align: left;
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 16px 7px 0;
  border-bottom: 2px solid var(--navy);
}

.century-table thead .swatch {
  width: 0.7em;
  height: 0.7em;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: baseline;
}

.century-table tbody th,
.century-table tbody td {
  vertical-align: top;
  padding: 9px 16px 9px 0;
  border-bottom: 1px solid var(--line);
}

.century-table tbody tr:hover th,
.century-table tbody tr:hover td { background: rgba(0, 62, 95, 0.04); }

.rank-col {
  width: 56px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
}

.rank-name { display: block; font-weight: 700; line-height: 1.3; }
.rank-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.rank-item.is-tie {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.tie-mark {
  display: block;
  margin-bottom: 2px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.rank-cell.is-empty { color: rgba(92, 83, 72, 0.45); }

/* A section heading that carries its own control on the right. */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}
.section-head .section-title { margin-bottom: 0; }

.muted { color: var(--muted); }

.fn { font-size: 0.75em; }
.fn a { text-decoration: none; }

.biblio-wrap { margin-top: 36px; }
#bibliography { font-size: 0.88rem; color: var(--muted); }
#bibliography cite { color: var(--ink); font-style: normal; }


/* ==========================================================================
   Hierarchy pass — masthead, filter band, chart header, control system.
   One look per control type: tabs = underline, chips = pills,
   segmented = joined + filled active, kind chips = checkbox + swatch (legend).
   ========================================================================== */

/* --- Filter band: map left, centuries + kinds right ---------------------- */
.filter-band {
  border-top: 3px solid var(--rule);
  border-bottom: 1px solid var(--line);
  padding: 10px 0 12px;
  margin: 0 0 var(--space-2);
}

.band-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  margin-bottom: 10px;
}

.band-kicker { margin: 0; }

.band-note {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-caption);
}

.map-actions { display: flex; gap: 8px; margin-left: auto; }

.map-actions button {
  border-radius: 999px;
  border-color: var(--line);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 13px;
}

.band-grid {
  display: grid;
  grid-template-columns: minmax(0, 540px) minmax(260px, 1fr);
  gap: var(--space-3);
  align-items: start;
}

.atlas-frame { width: 100%; max-width: 540px; margin: 0; }
.atlas-frame .omelas-svg { max-height: 260px; }

.band-filters { display: grid; gap: 14px; }
.band-gloss { margin: 8px 0 0; }

/* --- Chips (centuries) --------------------------------------------------- */
.chip-row button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--navy);
  font-size: 0.8rem;
  padding: 6px 13px;
  letter-spacing: 0.03em;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip-row button:hover { background: rgba(0, 62, 95, 0.08); }

.chip-row button[aria-pressed="true"] {
  background: var(--navy);
  color: var(--paper);
  border-color: var(--navy);
}

#btn-centuries-all {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* --- Kind chips: checkbox + color swatch. These are the chart legend. ----- */
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 5px 14px 5px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip-check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--navy);
}

.chip-check .swatch {
  width: 0.8em;
  height: 0.8em;
  margin: 0;
  border-radius: 2px;
  vertical-align: baseline;
}

.chip-check:hover { background: rgba(0, 62, 95, 0.06); }
.chip-check:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip-check:has(input:checked) {
  color: var(--ink);
  border-color: rgba(0, 62, 95, 0.4);
  background: rgba(0, 62, 95, 0.05);
}

/* --- Chart section ------------------------------------------------------- */
.chart-section { margin: 0 0 var(--space-2); }

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 20px;
  margin-bottom: 8px;
}

.chart-head-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

.chart-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-section);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.chart-hint {
  flex: 0 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-caption);
  text-align: right;
}

.conflict-panel { margin: var(--space-2) 0 0; }
.conflict-panel[hidden] { display: none; }

/* --- Segmented controls (Show as, Deaths / %) ---------------------------- */
.seg-wrap { display: flex; align-items: center; gap: 10px; }

.seg-label {
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--navy);
  border-radius: 999px;
  background: var(--paper);
  overflow: hidden;
}

.seg-thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background: var(--navy);
  transition: transform 0.22s ease;
  z-index: 0;
}

body[data-chart="area"] .segmented[data-seg="chart"] .seg-thumb { transform: translateX(100%); }
body[data-mode="percent"] .segmented[data-seg="mode"] .seg-thumb { transform: translateX(100%); }
body[data-rank="percent"] .segmented[data-seg="rank"] .seg-thumb { transform: translateX(100%); }

.segmented button {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 6px 16px;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.segmented button:hover { background: rgba(0, 62, 95, 0.08); }
.segmented button[aria-pressed="true"] { background: transparent; color: var(--paper); }
.segmented button[aria-pressed="true"]:hover { background: transparent; }
.segmented button:focus-visible { outline-offset: -3px; }

.seg-glyph { width: 18px; height: 14px; fill: currentColor; flex: none; }

.seg-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.seg-sub {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

/* --- Misc ---------------------------------------------------------------- */
.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-label select {
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  border-radius: 999px;
  border-color: var(--line);
}

.how-counted { margin: 0 0 14px; }

.how-counted summary {
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
}

.how-counted p { margin: 10px 0 0; }

@media (max-width: 980px) {
  .band-grid { grid-template-columns: 1fr; }
  .atlas-frame { max-width: none; }
}

@media (max-width: 720px) {
  .seg-sub { display: none; }
  .chart-head { align-items: flex-start; }
  .toolbar { align-items: flex-start; }
}

@media (max-width: 520px) {
  #statline { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .seg-wrap { width: 100%; flex-wrap: wrap; gap: 6px 10px; }
  .segmented { width: 100%; }
  .map-actions { margin-left: 0; }
  nav.tabs { gap: 4px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .seg-thumb,
  nav.tabs button,
  .chip-row button,
  .chip-check,
  .chart-stage .chart-layer { transition: none; }
}

/* ==========================================================================
   Bubble selection pass — hit targets, hover ping, persistent selection,
   keyed updates, the size legend and the inline event panel.
   ========================================================================== */

/* --- Hit target: the invisible circle is the mouse/tap surface ------------ */
.bubble-hit { fill: transparent; pointer-events: all; }
.bubble-halo, .bubble-ring, .bubble-circle { pointer-events: none; }

/* The outer group carries the position; the inner group carries the lift. */
.bubble-inner {
  transform-box: view-box;
  transform-origin: 0 0;
  transition: transform 0.18s ease-out;
}

.bubble-halo {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}

.bubble-ring {
  fill: none;
  stroke-width: 1.6;
  opacity: 0;
  transition: opacity 0.18s ease, r 0.6s ease;
}

/* --- Hover / focus: lift, ring, and the rest of the field steps back ------ */
.bubble-node:hover .bubble-inner,
.bubble-node:focus .bubble-inner,
.bubble-node.is-hot .bubble-inner { transform: scale(1.12); }

.bubble-node:hover .bubble-ring,
.bubble-node:focus .bubble-ring,
.bubble-node.is-hot .bubble-ring,
.bubble-node.is-selected .bubble-ring { opacity: 0.85; }

.bubble-node:hover .bubble-circle,
.bubble-node:focus .bubble-circle,
.bubble-node.is-hot .bubble-circle { stroke: var(--ink); stroke-width: 1.5; }

/* The focus indicator is the ring, not a rectangle around a circle. */
.bubble-node:focus { outline: none; }
.bubble-node:focus-visible .bubble-ring { opacity: 1; stroke-width: 2.5; }
.bubble-node:focus-visible .bubble-circle { stroke: var(--focus); stroke-width: 2; }

.bubble-node.is-dim { opacity: 0.35; }
.bubble-node.is-kin { opacity: 0.7; }
.bubble-node.is-hot { opacity: 1; }

/* The atlas isolates harder than a bubble hover does. */
body[data-focus-country] .bubble-node.is-dim { opacity: 0.14; }

/* --- Selection: it persists after the pointer leaves --------------------- */
.bubble-node.is-selected .bubble-circle { stroke: var(--ink); stroke-width: 2; }
.bubble-node.is-selected.is-dim,
.bubble-node.is-selected.is-kin { opacity: 0.85; }

/* --- Enter / exit -------------------------------------------------------- */
.bubble-node.is-exit { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
  .bubble-node:hover .bubble-halo,
  .bubble-node:focus .bubble-halo,
  .bubble-node.is-hot .bubble-halo,
  .bubble-node.is-selected .bubble-halo { animation: bubble-ping 1.4s ease-out infinite; }
  .bubble-node.is-enter .bubble-inner { animation: bubble-in 0.5s ease-out; }
  .conflict-panel .panel-in { animation: panel-in 0.22s ease-out both; }
}

@keyframes bubble-ping {
  0% { opacity: 0.5; transform: scale(1); }
  70% { opacity: 0; transform: scale(var(--halo-scale, 1.8)); }
  100% { opacity: 0; transform: scale(var(--halo-scale, 1.8)); }
}

@keyframes bubble-in {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Hover card: fades and rises in 150ms -------------------------------- */
.hover-body { animation: hover-card-in 0.15s ease-out both; }

@keyframes hover-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --- Size legend: drawn with the bubble scale, so it cannot lie ---------- */
.size-legend { pointer-events: none; }
.legend-circle { fill: none; stroke: rgba(43, 36, 27, 0.5); stroke-width: 1; }
.legend-lead { stroke: rgba(43, 36, 27, 0.35); stroke-width: 1; }
.legend-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.legend-kicker {
  fill: var(--muted);
  font-size: 9px;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* --- Inline event detail, directly under the chart stage ----------------- */
.conflict-panel {
  margin: var(--space-2) 0 0;
  padding: 12px 18px 16px;
  background: var(--paper-2);
  border-left: 4px solid var(--navy);
}
.conflict-panel[data-arena="internal"] { border-left-color: var(--internal); }
.conflict-panel[data-arena="external"] { border-left-color: var(--external); }
.conflict-panel[data-arena="exogenous"] { border-left-color: var(--exogenous); }

/* Focused by a deep link; keyboard users still get a ring. */
.conflict-panel:focus { outline: none; }
.conflict-panel:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--fs-kicker);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-kicker .swatch { width: 0.8em; height: 0.8em; margin: 0; border-radius: 2px; }

.panel-close {
  border-radius: 999px;
  border-color: var(--line);
  color: var(--navy);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  flex: none;
}

.panel-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.2;
  margin: 6px 0 2px;
}

.panel-when { margin: 0; color: var(--muted); font-size: var(--fs-caption); }

.panel-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 44px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.panel-figures .k {
  display: block;
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.panel-figures strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.panel-link { margin: 12px 0 0; }

/* The stage reserves room for the taller of the two charts; below ~720px the
   svg scales down, so the reserve has to come down with it. */
@media (max-width: 720px) {
  .chart-stage { min-height: 240px; }
}

@media (max-width: 520px) {
  .panel-figures { gap: 8px 24px; }
  .chart-stage { min-height: 170px; }
  .panel-head { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble-node,
  .bubble-inner,
  .bubble-circle,
  .bubble-ring { transition: none; }
  .bubble-node:hover .bubble-inner,
  .bubble-node:focus .bubble-inner,
  .bubble-node.is-hot .bubble-inner { transform: none; }
  .bubble-halo { animation: none; }
  .hover-body, .conflict-panel .panel-in { animation: none; }
}
