/* top-countries.alxevt.com
   One dark instrument surface shared with world-population.alxevt.com and
   world-population-playback.alxevt.com: same tokens, same three skins, same
   header. All visual decisions live here; JS writes state via classes,
   attributes and custom properties only (CSP: no inline styles). */

[hidden] { display: none !important; }

:root {
  --bg: #0b0e11;
  --surface: #11161b;
  --surface-2: #161c22;
  --line: rgba(240, 246, 250, 0.09);
  --line-strong: rgba(240, 246, 250, 0.25);
  --ink: #f2f5f7;
  --ink-2: #9aa5ae;
  --ink-3: #7d8892;
  --accent: #1e9ad4;
  --accent-text: #5ec1ee;
  --accent-ink: #06202e;
  --accent-wash: rgba(30, 154, 212, 0.10);
  --pos: #65d6bd;
  --neg: #ff7e6b;
  --focus: #8ed0f2;
  --radius: 16px;
  --radius-s: 10px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 180ms;
  --pad-x: clamp(1.1rem, 4.5vw, 3.5rem);
  --gap: clamp(2rem, 5.5vw, 4rem);
  --max: 62rem;
  --wide: 86rem;
  --ff: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ff-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ff-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --ff-hero: var(--ff);
  --hero-weight: 750;
  --hero-tracking: -0.04em;
  --ground: radial-gradient(120% 90% at 50% -10%, #10161d 0%, var(--bg) 55%), var(--bg);
  /* The map ladder: one hue, dark to bright. Band 0 is the top of a ranking
     and takes the brightest step, so "where the top is" reads at a glance.
     Lightness is monotone across the seven steps (OKLCH L 0.31 → 0.88). */
  --mp-none: #161b22;
  --mp-edge: #0b0e11;
  --mp-5: #17324b;
  --mp-4: #1a4c73;
  --mp-3: #16689c;
  --mp-2: #1186c4;
  --mp-1: #23a5e0;
  --mp-0: #4fc4f2;
  --sp-ocean: #0f151c;
  --sp-limb: #2a3947;
  color-scheme: dark;
}

/* SOLARI — a mechanical departure board: warm near-black, amber, monospace. */
:root[data-skin="solari"] {
  --bg: #0d0e10;
  --surface: #16181c;
  --surface-2: #1d2025;
  --line: rgba(245, 232, 205, 0.10);
  --line-strong: rgba(245, 232, 205, 0.28);
  --ink: #f3ecdd;
  --ink-2: #bcae94;
  --ink-3: #948868;
  --accent: #f3a51f;
  --accent-text: #ffc65e;
  --accent-ink: #241800;
  --accent-wash: rgba(243, 165, 31, 0.10);
  --pos: #86d68f;
  --neg: #ff9152;
  --focus: #ffc65e;
  --ff-hero: var(--ff-mono);
  --hero-weight: 600;
  --hero-tracking: 0.01em;
  --ground: radial-gradient(120% 90% at 50% -10%, #16171a 0%, var(--bg) 60%), var(--bg);
  --mp-none: #17181a;
  --mp-edge: #0d0e10;
  --mp-5: #3a2a10;
  --mp-4: #5a3f12;
  --mp-3: #7c5615;
  --mp-2: #a06f19;
  --mp-1: #c48b23;
  --mp-0: #ddaa46;
  --sp-ocean: #121314;
  --sp-limb: #3a3b3e;
  color-scheme: dark;
}

/* INK — electronic ink on warm paper: light, high-contrast, quiet indigo. */
:root[data-skin="ink"] {
  --bg: #efece3;
  --surface: #f6f3ea;
  --surface-2: #e8e3d6;
  --line: rgba(28, 24, 16, 0.16);
  --line-strong: rgba(28, 24, 16, 0.35);
  --ink: #1b1a15;
  --ink-2: #514d43;
  --ink-3: #5f5b4f;
  --accent: #2f3f86;
  --accent-text: #2b3a7d;
  --accent-ink: #ffffff;
  --accent-wash: rgba(47, 63, 134, 0.10);
  --pos: #1f7a4d;
  --neg: #b23a2e;
  --focus: #2f3f86;
  --ff-hero: var(--ff-serif);
  --hero-weight: 620;
  --hero-tracking: -0.02em;
  --ground: var(--bg);
  --mp-none: #e9e5da;
  --mp-edge: #efece3;
  --mp-5: #d8e4ea;
  --mp-4: #b9d2de;
  --mp-3: #93bad0;
  --mp-2: #6a9fc0;
  --mp-1: #4a81a8;
  --mp-0: #2f6389;
  --sp-ocean: #f3f1ea;
  --sp-limb: #b9b2a0;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  font-family: var(--ff);
  font-size: clamp(1rem, 0.5vw + 0.92rem, 1.125rem);
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
a { color: var(--ink-2); text-underline-offset: 0.2em; }
a:hover { color: var(--ink); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.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; }
.skip { position: absolute; left: 1rem; top: -3rem; z-index: 30; padding: 0.6rem 1rem; background: var(--surface-2); border-radius: var(--radius-s); transition: top var(--dur) var(--ease); }
.skip:focus-visible { top: 1rem; }

/* ---- the label voice: mono, small, spaced ---- */
.micro { font-family: var(--ff-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }

/* ---- header: one row, however many clusters ----
   Ported from the playback site so the three tools share one top line. */
.top {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, max-content);
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: clamp(0.9rem, 2.5vw, 1.4rem) var(--pad-x);
}
.top-controls { justify-self: end; display: flex; align-items: center; gap: 0.5rem; }
@media (max-width: 1023px) {
  .top { grid-auto-flow: row; grid-template-columns: 1fr auto; grid-template-areas: "wordmark controls" "nav nav"; row-gap: 0.55rem; }
  .top .wordmark { grid-area: wordmark; }
  .top .pagenav { grid-area: nav; justify-self: center; }
  .top-controls { grid-area: controls; }
}
@media (max-width: 560px) {
  .top { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); grid-template-areas: none; justify-items: center; row-gap: 0.5rem; }
  .top > *, .top .wordmark, .top .pagenav, .top .top-controls { grid-area: auto; max-width: 100%; }
  .pagenav { justify-content: center; flex-wrap: wrap; max-width: 100%; }
  .top-controls { justify-self: center; justify-content: center; flex-wrap: wrap; }
}
@media (max-width: 430px) {
  .wordmark-text { display: none; }
  .skin-word, .skin-sep { display: none; }
  .top-controls { gap: 0.35rem; }
}
.wordmark { font-family: var(--ff-mono); font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2); }
.wordmark a { color: inherit; text-decoration: none; }
.wordmark-dot { display: inline-block; width: 8px; height: 8px; margin-right: 0.5rem; border-radius: 50%; background: var(--accent); vertical-align: 0.05em; }

.pagenav { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.pagenav-link {
  position: relative; padding: 0.35rem 0.8rem; border-radius: 999px;
  font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3); text-decoration: none; white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.pagenav-link::after { content: ""; position: absolute; inset: -6px; }
.pagenav-link:hover { color: var(--ink); }
.pagenav-link[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.cross-out { color: var(--accent-text); font-size: 0.85em; margin-left: 0.25rem; }

.skin-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 34px;
  padding: 0.3rem 0.7rem 0.3rem 0.55rem; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.skin-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.skin-btn:active { transform: scale(0.97); }
.skin-ic { width: 16px; height: 16px; color: var(--accent-text); flex: none; }
.skin-word { color: var(--ink-3); }
.skin-sep { color: var(--ink-3); opacity: 0.5; }
.skin-btn #skin-name { color: var(--ink); }

.lang { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang-btn {
  position: relative; font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.1em; color: var(--ink-3);
  padding: 0.35rem 0.7rem; border-radius: 999px;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.lang-btn::after { content: ""; position: absolute; inset: -6px; }
.lang-btn[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }
.lang-btn:hover { color: var(--ink); }

/* ---- stage ---- */
.stage { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: clamp(0.5rem, 3vh, 2.5rem) var(--pad-x) var(--gap); display: flex; flex-direction: column; gap: var(--gap); }
.stage-wide { max-width: var(--wide); }
.noscript { padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2); }
.section-title { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; font-family: var(--ff-mono); margin: 0 0 0.6rem; }

/* ---- chips ---- */
.chip { display: inline-block; font-family: var(--ff-mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; padding: 0.22rem 0.55rem; border-radius: 999px; line-height: 1.2; border: 1px solid currentColor; color: var(--ink-3); white-space: nowrap; }
.chip-accent { color: var(--accent-text); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px; padding: 0.34rem 0.8rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  font-family: var(--ff-mono); font-size: 0.76rem; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform 90ms var(--ease);
}
.chip-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.chip-btn:active { transform: scale(0.96); }
.chip-ic { width: 16px; height: 16px; color: var(--accent-text); flex: none; }
.rot-slot { display: inline-grid; }
.rot-label { grid-area: 1 / 1; visibility: hidden; text-align: center; }
.rot-label.is-active { visibility: visible; }

/* ---- hero (index) ---- */
.hero { text-align: center; padding-top: clamp(0.5rem, 3vh, 2rem); }
.hero h1 { font-family: var(--ff-hero); font-weight: var(--hero-weight); letter-spacing: var(--hero-tracking); font-size: clamp(2rem, 5.5vw, 3.6rem); line-height: 1.05; max-width: 22ch; margin: 0 auto 0.8rem; }
.hero-lede { max-width: 58ch; margin: 0 auto 1.2rem; color: var(--ink-2); font-size: clamp(1rem, 1.6vw, 1.15rem); }
.hero-stats { display: flex; justify-content: center; gap: 0.6rem 1.6rem; flex-wrap: wrap; }
.hero-stat { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.hero-stat-n { font-family: var(--ff-mono); font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.hero-stat-l { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-family: var(--ff-mono); }

/* ---- the chooser: every rating, by category ---- */
.chooser { display: flex; flex-direction: column; gap: 2rem; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.cat-title { font-size: clamp(1.15rem, 2.4vw, 1.5rem); font-weight: 650; letter-spacing: -0.01em; }
.cat-desc { color: var(--ink-2); font-size: 0.92rem; margin-top: 0.2rem; max-width: 62ch; }
.cat-count { font-family: var(--ff-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.chooser-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem 1.2rem; flex-wrap: wrap; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.cards { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.8rem; }
.rating-card {
  display: flex; flex-direction: column; gap: 0.55rem; height: 100%;
  padding: 0.95rem 1rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.rating-card:hover, .rating-card:focus-visible { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); }
.rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.4rem 0.6rem; flex-wrap: wrap; }
.rc-top .chip { white-space: normal; text-align: right; }
.rc-name { font-size: 1.02rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; color: var(--ink); }
.rc-what { color: var(--ink-2); font-size: 0.86rem; line-height: 1.45; }
.rc-meta { font-family: var(--ff-mono); font-size: 0.66rem; letter-spacing: 0.06em; color: var(--ink-3); margin-top: auto; overflow-wrap: anywhere; }
.podium { display: flex; gap: 0.5rem 0.8rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--ink-2); }
.podium span { white-space: nowrap; }
.podium .p-rank { font-family: var(--ff-mono); color: var(--ink-3); font-size: 0.66rem; margin-right: 0.15rem; }

/* ---- learn strip (index) ---- */
.learn { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.8rem; }
.learn-card { padding: 0.9rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-s); background: var(--surface); color: inherit; text-decoration: none; }
.learn-card:hover { background: var(--surface-2); }
.learn-card h3 { font-size: 0.95rem; font-weight: 650; margin-bottom: 0.3rem; }
.learn-card p { color: var(--ink-2); font-size: 0.85rem; line-height: 1.45; }

/* ---- the rating page head ---- */
.crumb { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.crumb a { text-decoration: none; }
.rating-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 2rem; align-items: start; }
.rating-head h1 { font-family: var(--ff-hero); font-weight: var(--hero-weight); letter-spacing: var(--hero-tracking); font-size: clamp(1.7rem, 4.5vw, 2.8rem); line-height: 1.08; }
.rating-lede { color: var(--ink-2); max-width: 62ch; margin-top: 0.6rem; font-size: clamp(0.98rem, 1.5vw, 1.1rem); }
.rating-meta { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-end; text-align: right; font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.06em; color: var(--ink-3); }
.rating-meta .chips { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.rating-meta a { color: var(--accent-text); }
@media (max-width: 720px) {
  .rating-head { grid-template-columns: minmax(0, 1fr); }
  .rating-meta { align-items: flex-start; text-align: left; }
  .rating-meta .chips { justify-content: flex-start; }
}

/* ---- the map ----
   Borrowed from the playback site's world map: Equal Earth, one hue, and a band
   as a data attribute rather than a style string. Band 0 is the top of the
   ranking. */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(1.2rem, 3vw, 2rem); }
@media (min-width: 900px) { .map-wrap { grid-template-columns: minmax(0, 2.6fr) minmax(19rem, 0.7fr); align-items: start; } }
.map-fig { margin: 0; }
.worldmap { display: block; width: 100%; height: auto; cursor: default; }
.mp-country { fill: var(--mp-none); stroke: var(--mp-edge); stroke-width: 0.004; vector-effect: non-scaling-stroke; transition: fill var(--dur) var(--ease); cursor: pointer; }
.mp-country[data-band="0"] { fill: var(--mp-0); }
.mp-country[data-band="1"] { fill: var(--mp-1); }
.mp-country[data-band="2"] { fill: var(--mp-2); }
.mp-country[data-band="3"] { fill: var(--mp-3); }
.mp-country[data-band="4"] { fill: var(--mp-4); }
.mp-country[data-band="5"] { fill: var(--mp-5); }
.mp-country:hover { stroke: var(--accent); stroke-width: 1.6; }
.mp-country[data-selected] { stroke: var(--accent); stroke-width: 2.2; }

/* The globe model shares the ladder; only the ocean and the limb are its own.
   Square, so capped by height as well as width. */
.viz-host { display: grid; justify-items: center; min-height: 12rem; }
.viz-host[data-viz="map"] { justify-items: stretch; }
.worldsphere { display: block; width: 100%; max-width: min(100%, 40rem, 60vh); height: auto; touch-action: none; cursor: grab; }
.worldsphere:active { cursor: grabbing; }
.worldsphere:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 50%; }
.sp-ocean { fill: var(--sp-ocean); }
.sp-limb { fill: none; stroke: var(--sp-limb); stroke-width: 0.8; }
.sp-country { fill: var(--mp-none); stroke: var(--mp-edge); stroke-width: 0.25; transition: fill var(--dur) var(--ease); cursor: pointer; }
.sp-country[data-band="0"] { fill: var(--mp-0); }
.sp-country[data-band="1"] { fill: var(--mp-1); }
.sp-country[data-band="2"] { fill: var(--mp-2); }
.sp-country[data-band="3"] { fill: var(--mp-3); }
.sp-country[data-band="4"] { fill: var(--mp-4); }
.sp-country[data-band="5"] { fill: var(--mp-5); }
.sp-country:hover { stroke: var(--accent); stroke-width: 0.9; }
.sp-country[data-selected] { stroke: var(--accent); stroke-width: 1.3; }
.viz-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.viz-hint { font-family: var(--ff-mono); font-size: 0.68rem; letter-spacing: 0.06em; color: var(--ink-3); }

/* ---- segmented control: one choice among a few, always visible ---- */
.seg { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.seg button, .seg a {
  font-family: var(--ff-mono); font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-2); text-decoration: none;
  padding: 0.34rem 0.7rem; min-height: 32px; border-radius: 999px; white-space: nowrap;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg [aria-pressed="true"], .seg [aria-current="true"] { color: var(--accent-ink); background: var(--accent); font-weight: 700; }

/* ---- the switch: a real checkbox, drawn as a toggle ---- */
.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; font-size: 0.82rem; color: var(--ink-2); min-height: 40px; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); position: relative; margin: 0; cursor: pointer; transition: background-color var(--dur) var(--ease); flex: none; }
.switch input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-2); transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::before { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-note { font-size: 0.72rem; color: var(--ink-3); }

/* ---- flags: real artwork, the same box everywhere ---- */
.flag { width: 1.5em; height: 1.125em; border-radius: 2px; object-fit: cover; vertical-align: -0.2em; box-shadow: 0 0 0 1px var(--line); flex: none; background: var(--surface-2); }
.b-flag .flag { width: 1.4em; height: 1.05em; }
.detail-flag .flag, .country-flag .flag { width: 1.5em; height: 1.125em; }
.p-flag { margin-right: 0.3rem; }

/* ---- a fold for what is read second ---- */
.fold { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.fold summary { cursor: pointer; padding: 0.7rem 1rem; font-family: var(--ff-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "▸"; color: var(--accent-text); transition: transform var(--dur) var(--ease); }
.fold[open] summary::before { transform: rotate(90deg); }
.fold-body { padding: 0 1rem 0.9rem; display: grid; gap: 0.6rem; }
.fold-body p { color: var(--ink-2); font-size: 0.88rem; line-height: 1.5; margin: 0; }
.fold-body b { color: var(--ink); font-weight: 650; }
.fold-body a { color: var(--accent-text); overflow-wrap: anywhere; }

/* ---- a notice that stands in for hidden content ---- */
.notice { padding: 0.9rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-s); background: var(--surface); display: flex; gap: 0.8rem 1.4rem; align-items: center; flex-wrap: wrap; }
.notice p { color: var(--ink-2); font-size: 0.88rem; margin: 0; flex: 1 1 18rem; }

/* ---- the brand line ---- */
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink-2); text-decoration: none; font-family: var(--ff-mono); font-size: 0.72rem; letter-spacing: 0.08em; }
.brand img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.brand:hover { color: var(--ink); }
.map-caption { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.mp-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; }
.mp-key { display: flex; align-items: center; gap: 0.35rem; font-size: 0.74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mp-key-swatch { width: 0.9rem; height: 0.9rem; border-radius: 3px; display: inline-block; background: var(--mp-none); border: 1px solid var(--line); flex: none; }
.mp-key[data-band="0"] .mp-key-swatch { background: var(--mp-0); }
.mp-key[data-band="1"] .mp-key-swatch { background: var(--mp-1); }
.mp-key[data-band="2"] .mp-key-swatch { background: var(--mp-2); }
.mp-key[data-band="3"] .mp-key-swatch { background: var(--mp-3); }
.mp-key[data-band="4"] .mp-key-swatch { background: var(--mp-4); }
.mp-key[data-band="5"] .mp-key-swatch { background: var(--mp-5); }
.mp-key-range { color: var(--ink-3); font-family: var(--ff-mono); font-size: 0.66rem; }
.mp-note { font-size: 0.78rem; color: var(--ink-2); border-left: 2px solid var(--accent); padding-left: 0.6rem; line-height: 1.45; }

/* ---- the side column: the selected country's card ---- */
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.2rem; align-content: start; }
.side-title { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 0.5rem; font-weight: 600; font-family: var(--ff-mono); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.9rem 1rem 1rem; }
.card-empty { color: var(--ink-3); font-size: 0.86rem; line-height: 1.45; }
.detail-name { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 0.5rem; }
.detail-flag { font-size: 1.3rem; line-height: 1; }
.detail-where { margin-top: 0.15rem; font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--ink-3); }
.detail-rank { margin: 0.7rem 0 0.2rem; padding: 0.6rem 0.7rem; border-radius: 8px; background: var(--accent-wash); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.1rem 0.8rem; align-items: baseline; }
.detail-rank-n { font-family: var(--ff-mono); font-size: 1.5rem; font-weight: 650; color: var(--accent-text); font-variant-numeric: tabular-nums; grid-row: span 2; align-self: center; }
.detail-rank-l { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); font-family: var(--ff-mono); }
.detail-rank-v { font-family: var(--ff-mono); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.detail-rows { margin-top: 0.8rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 0.8rem; }
.detail-rows dt { font-size: 0.8rem; color: var(--ink-3); }
.detail-rows dd { font-family: var(--ff-mono); font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; }
/* The card holds two kinds of figure: readings interpolated for today, and
   fixed present-day facts. The divider keeps them from being read as one. */
.detail-split { grid-column: 1 / -1; margin-top: 0.5rem; padding-top: 0.55rem; border-top: 1px solid var(--line); font-family: var(--ff-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.detail-links { margin-top: 0.9rem; display: flex; gap: 0.5rem 1rem; flex-wrap: wrap; font-size: 0.8rem; }
.detail-links a { color: var(--accent-text); }

/* ---- the board: every ranked country ---- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem 1rem; flex-wrap: wrap; }
.board-title { font-size: clamp(1.1rem, 2.4vw, 1.4rem); font-weight: 650; letter-spacing: -0.01em; }
.board-unit { font-family: var(--ff-mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--ink-3); margin-top: 0.15rem; }
.board-controls { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.search {
  min-height: 40px; padding: 0.34rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink);
  font-family: var(--ff-mono); font-size: 0.78rem; width: min(100%, 15rem);
}
.search::placeholder { color: var(--ink-3); }
.board-list { list-style: none; margin-top: 1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.15rem 1.2rem; }
/* Two columns on a wide screen, ranks running down the left column first —
   the row count is handed over as --rows so 1..k sit left and k+1..n right. */
@media (min-width: 900px) { .board-list.is-split { grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 1), auto); } }
.board-list li { position: relative; min-width: 0; }
.board-row {
  position: relative; display: grid; grid-template-columns: 2.1em 1.4em minmax(0, 1fr) auto; align-items: center; gap: 0.45rem;
  width: 100%; min-height: 44px; padding: 0.38rem 0.6rem; border-radius: var(--radius-s); text-align: left; overflow: hidden; cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.board-row::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--w, 0) * 100%); background: var(--accent-wash); pointer-events: none; }
.board-row > * { position: relative; }
.board-row:hover, .board-row:focus-visible { background: var(--surface-2); outline: none; }
.board-row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.board-row[aria-current="true"] { outline: 1px solid var(--line-strong); background: var(--surface-2); }
.b-rank { font-family: var(--ff-mono); font-size: 0.7rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.b-flag { font-size: 1rem; line-height: 1; }
.b-id { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.b-name { font-size: 0.9rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-sub { font-family: var(--ff-mono); font-size: 0.64rem; letter-spacing: 0.03em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.b-sub .pos { color: var(--pos); }
.b-sub .neg { color: var(--neg); }
/* Present-day reference facts behind a "today" tag, dimmer than the sub-line:
   single readings from the packaged facts, not the rating's own figures. */
.b-refs { font-family: var(--ff-mono); font-size: 0.58rem; letter-spacing: 0.02em; color: var(--ink-3); opacity: 0.8; font-variant-numeric: tabular-nums; line-height: 1.35; }
.b-refs-tag { text-transform: uppercase; letter-spacing: 0.09em; border: 1px solid currentColor; border-radius: 999px; padding: 0 0.28rem; margin-right: 0.15rem; opacity: 0.75; }
.b-val { font-family: var(--ff-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.b-val-year { display: block; font-size: 0.58rem; color: var(--ink-3); letter-spacing: 0.06em; }
.board-empty { padding: 0.6rem; color: var(--ink-3); font-size: 0.82rem; }
.board-foot { margin-top: 0.8rem; color: var(--ink-3); font-size: 0.8rem; line-height: 1.45; }

/* ---- method strip: how it is made, read with care, source ---- */
.method { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.8rem; }
.method-card { padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.method-card h3 { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-family: var(--ff-mono); font-weight: 600; margin-bottom: 0.45rem; }
.method-card p { color: var(--ink-2); font-size: 0.88rem; line-height: 1.5; }
.method-card a { color: var(--accent-text); overflow-wrap: anywhere; }
.method-card.is-caveat { border-left: 3px solid var(--neg); }

/* ---- the country page ---- */
.country-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (min-width: 900px) { .country-head { grid-template-columns: minmax(0, 1.6fr) minmax(19rem, 0.8fr); } }
.country-head h1 { font-family: var(--ff-hero); font-weight: var(--hero-weight); letter-spacing: var(--hero-tracking); font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.05; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.country-flag { font-size: 0.9em; line-height: 1; }
.country-lede { color: var(--ink-2); margin-top: 0.6rem; max-width: 60ch; }
.profile { list-style: none; display: flex; flex-direction: column; gap: 1.3rem; }
.profile-cat > h2 { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-family: var(--ff-mono); font-weight: 600; margin-bottom: 0.4rem; }
.profile-cat ul { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
.crow {
  display: grid; grid-template-columns: minmax(0, 1fr) 6rem auto; gap: 0.6rem; align-items: center;
  padding: 0.45rem 0.6rem; border-radius: var(--radius-s); color: inherit; text-decoration: none; min-height: 44px;
  transition: background-color var(--dur) var(--ease);
}
.crow:hover, .crow:focus-visible { background: var(--surface-2); }
.crow-id { display: block; min-width: 0; }
.crow-name { display: block; font-size: 0.9rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-sub { font-family: var(--ff-mono); font-size: 0.62rem; letter-spacing: 0.04em; color: var(--ink-3); }
.pct { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pct::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); background: var(--accent); }
.crow-rank { font-family: var(--ff-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.crow-rank small { display: block; font-size: 0.6rem; color: var(--ink-3); letter-spacing: 0.06em; }
.crow-val { font-size: 0.66rem; color: var(--ink-2); }
@media (max-width: 480px) { .crow { grid-template-columns: minmax(0, 1fr) auto; } .crow .pct { display: none; } }

/* ---- footer ---- */
.foot { max-width: var(--max); width: 100%; margin: 0 auto; padding: var(--gap) var(--pad-x) clamp(1.4rem, 4vw, 2.2rem); display: flex; flex-direction: column; gap: 0.55rem; text-align: center; }
.foot .micro { letter-spacing: 0.08em; text-transform: none; }
.foot-meta { overflow-wrap: anywhere; }

/* ---- info page prose ---- */
.prose { max-width: 46rem; }
.prose h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 0.6rem; }
.prose h2 { font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 650; letter-spacing: -0.01em; margin: 2.2rem 0 0.7rem; }
.prose h3 { font-size: 1.02rem; font-weight: 650; margin: 1.5rem 0 0.5rem; color: var(--ink-2); }
.prose p { margin-bottom: 0.9rem; color: var(--ink-2); }
.prose .lede { font-size: 1.08rem; color: var(--ink); }
.prose strong { color: var(--ink); font-weight: 650; }
.prose em { color: var(--ink); }
.prose ul, .prose ol { margin: 0 0 1rem 1.1rem; color: var(--ink-2); }
.prose li { margin-bottom: 0.5rem; }
.prose a { color: var(--accent-text); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.2rem; font-size: 0.88rem; table-layout: fixed; }
.prose th, .prose td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
/* A three-column table cannot fit a phone: below 560px every row becomes a
   stacked block and the header row is dropped, the cells still in order. */
@media (max-width: 560px) {
  .prose table, .prose tbody, .prose tr, .prose td { display: block; width: 100%; }
  .prose thead { display: none; }
  .prose tr { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
  .prose td { border: 0; padding: 0.1rem 0; }
  .prose td:first-child { color: var(--ink); font-weight: 650; }
}
.prose th { font-family: var(--ff-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.prose td { color: var(--ink-2); }
.note-warn { padding: 0.9rem 1.1rem; border: 1px solid var(--line); border-left: 3px solid var(--neg); border-radius: var(--radius-s); background: var(--surface); margin-bottom: 1rem; }
.note-warn p:last-child { margin-bottom: 0; }
.docs { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; margin: 0 0 1.2rem; }
.doc-card { padding: 0.8rem 0.95rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); font-size: 0.86rem; }
.doc-card h3 { margin: 0 0 0.25rem; font-size: 0.98rem; color: var(--ink); display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.doc-card p { margin: 0 0 0.3rem; }
.doc-card .doc-meta { font-family: var(--ff-mono); font-size: 0.66rem; letter-spacing: 0.06em; color: var(--ink-3); overflow-wrap: anywhere; }
.doc-card .doc-meta a { color: var(--accent-text); }

/* ---- nothing here is a text field ---- */
.hero, .board-row, .detail-rank, .wordmark, .foot, .chip { cursor: default; }
.board-row { cursor: pointer; }

/* ---- motion discipline ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print { .top, .foot, .board-controls, .detail-links { display: none; } }
