:root {
  --ink: #0f1720;
  --ink-2: rgba(15, 23, 32, 0.66); /* no lighter than 0.65 so it stays readable on glass */
  --ink-3: rgba(15, 23, 32, 0.4);
  --hair: rgba(15, 23, 32, 0.1);
  --tint: rgba(15, 23, 32, 0.045);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --shadow: 0 6px 24px rgba(15, 23, 32, 0.1);
  --focus: #1f4e99;
  /* Corner radii: three tokens, nothing ad hoc.
     --r-sm  controls nested inside a container (segments, rows, small chips, text buttons)
     --r-md  every floating glass element and card
     --r-lg  large surfaces (tour, drawer, phone sheet, dialogs)
     Concentric rule: a control sitting inside a padded container takes
     max(8px, outer radius - padding), so the two curves stay parallel.
     Where corner-shape is supported these tokens scale up (see the squircle block
     near the glass rules) because a squircle reads smaller than a circular arc.
     Circles (50%) and tiny data marks (flags, swatches, bars) stay out of this system. */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --radius: var(--r-md);
  --sidebar-w: 360px;
  --strip-h: 44px; /* measured and updated by app.js */
  --dock-h: 132px; /* strip + floating slider, measured by app.js */
  --scene-right: 0px;
  /* Glass: one token set for every floating surface. */
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-fallback: rgba(255, 255, 255, 0.94);
  --glass-blur: blur(18px) saturate(1.4);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px rgba(15, 23, 32, 0.12);
  --glass-radius: var(--r-md);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  /* Type: Instrument Sans for text, Plus Jakarta Sans for the wordmark and titles (pairing 4, "Postcard").
     --serif is kept as the name the title rules already use; it now points at the display sans. */
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Plus Jakarta Sans', 'Instrument Sans', system-ui, sans-serif;
  --serif: var(--display);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

/* Tracking by size: small text gets more air, large text less.
   Body and UI 13 to 15px: 0.015em. Titles 18px and up: -0.01em. Labels 12px and under: 0.03em.
   The caps wordmark keeps 0.1em (in its own rule). */
body { letter-spacing: 0.015em; }
button, input, output { letter-spacing: inherit; } /* form controls reset tracking by default */
.key-name, .key-sentence, .tour-title, .sheet-title, .sheet-sentence, .tt-name, .dialog-head h2, .pair-name {
  letter-spacing: -0.01em;
}
.key-name, .tour-title, .sheet-title { font-weight: 700; }
.tick-label, .thumb-label, .key-year, .mt-year, .mt-key, .mt-note, .credit, .sheet-year,
.stat-est, .opt-code, .choice-hint, .tt-year, .deck-legend, .tour-svg-label, .tour-svg-note, .tour-svg-tick {
  letter-spacing: 0.03em;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #c9dfea;
}

#harbour {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

button { font: inherit; color: inherit; }
h2, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* Pills inside segmented controls get an inset ring so it doesn't spill over neighbours. */
.tab:focus-visible,
.seg-group button:focus-visible {
  outline-offset: -2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:active { transform: scale(0.97); }
/* Phosphor icons are filled shapes, not strokes; this wins over the older stroke rules. */
svg.ph { fill: currentColor !important; stroke: none !important; }

.text-btn {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.text-btn:active { transform: scale(0.97); }

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover, .text-btn:hover { background-color: var(--tint); }
  .text-btn:hover { background-color: #f1f4f6; }
}

/* ---------- brand ---------- */

.brand {
  position: fixed;
  top: 16px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.brand-mark {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--ink);
  /* Optical alignment: lifts the icon's bounding-box centre onto the caps' centre line (measured 1.4px low at 21px). */
  transform: translateY(-1.5px);
}
.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 21px;
  line-height: 32px;
  letter-spacing: 0.1em;
  text-transform: uppercase; /* the DOM text stays "Afloat" for screen readers */
  color: var(--ink);
}
.badge {
  font-size: 11px;
  font-weight: 600;
  background: #b42318;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ---------- menu button ---------- */

.menu-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  transition: opacity 150ms var(--ease-out), visibility 0s, background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.menu-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
/* "Know more" and Menu side by side, top right. */
.top-actions {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  gap: 8px;
}
.top-actions .menu-btn { position: static; }
/* While the drawer is open the search steps out with Menu. */
body:not(.sidebar-collapsed) .top-actions .map-search { visibility: hidden; }

/* Know more: bottom right, on the line with the radio and the year slider (40px tall like them). */
.know-more {
  position: fixed;
  right: calc(var(--scene-right) + 16px);
  bottom: calc(var(--strip-h) + 14px);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px 0 14px;
  transition: right 250ms var(--ease-out), background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.know-more svg { width: 16px; height: 16px; }
body[data-device='phone'] .know-more { display: none; }

/* The logo turns white over the World Map's deep blue, in step with the camera. */
.brand-mark, .wordmark { transition: color 700ms var(--ease-out); }
body[data-map='true'] .brand-mark,
body[data-map='true'] .wordmark { color: #ffffff; }
/* While the drawer is open its own close control takes over. */
body:not(.sidebar-collapsed) .menu-btn {
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms var(--ease-out), visibility 0s linear 150ms;
}

/* ---------- Project panel ---------- */

/* Drawer type scale: 15px for content, 13px for secondary text. Nothing else. */
.choices {
  margin: 0 24px;
  display: grid;
}
.choice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hair);
}
.choice-label { grid-column: 1; grid-row: 1; font-size: 15px; font-weight: 500; color: var(--ink); }
.choice .seg-group { grid-column: 2; grid-row: 1; }
.choice-hint {
  grid-column: 1;
  grid-row: 2;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
}
.choice:has(.choice-hint) .seg-group { grid-row: 1 / span 2; align-self: center; }
.panel-scroll { overflow-y: auto; }
.about { padding: 4px 24px 24px; }
.about h3 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.about-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
}
.about-list li { padding-left: 14px; position: relative; text-wrap: pretty; }
.about-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-2);
}
.about-small { font-size: 13px; color: var(--ink-2); gap: 6px; }
.about-list a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(15, 23, 32, 0.25);
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .about-list a:hover { text-decoration-color: currentColor; }
}
.about-small li::before { top: 0.55em; width: 4px; height: 4px; }
.about-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.about-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) {
  .about-link:hover { text-decoration: underline; text-underline-offset: 3px; }
}
.seg-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(15, 23, 32, 0.06);
  border-radius: var(--r-sm);
}
.seg-group button {
  padding: 6px 12px;
  border: 0;
  border-radius: max(8px, calc(var(--r-sm) - 2px)); /* concentric: 2px padding */
  background: transparent;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.seg-group button[aria-checked='true'] {
  background: #ffffff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 32, 0.12);
}
.seg-group button:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .seg-group button:not([aria-checked='true']):hover { color: var(--ink); }
}

@keyframes enter {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- drawer ---------- */

.sidebar {
  font-size: 15px; /* drawer scale: 15 content, 13 secondary */
  position: fixed;
  top: 0;
  right: 0;
  bottom: var(--strip-h);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  z-index: 6;
  transform: translateX(0);
  visibility: visible;
  transition: transform 260ms var(--ease-out), visibility 0s;
}
.sidebar-collapsed .sidebar {
  transform: translateX(100%);
  visibility: hidden;
  box-shadow: none;
  transition: transform 200ms var(--ease-out), visibility 0s linear 200ms, box-shadow 0s linear 200ms;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 16px 16px 24px;
}
.tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(15, 23, 32, 0.06);
  border-radius: var(--r-sm);
}
.tab {
  padding: 6px 14px;
  border: 0;
  border-radius: max(8px, calc(var(--r-sm) - 2px)); /* concentric: 2px padding */
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.tab[aria-selected='true'] {
  background: #ffffff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 32, 0.12);
}
.tab:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .tab:not([aria-selected='true']):hover { color: var(--ink); }
}
.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel[hidden] { display: none; }
.panel-project { overflow-y: auto; }
.project-links {
  display: grid;
  margin: 0 24px 24px;
}
.project-links::before {
  content: 'Details';
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.project-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hair);
  text-align: left;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
  transition: color 150ms var(--ease-out);
  text-decoration: none;
  font-family: inherit;
}
.project-link svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) {
  .project-link:hover svg { stroke: var(--ink); }
}
.sidebar-sub {
  padding: 0 24px 16px;
  color: var(--ink-2);
  font-size: 13px;
  text-wrap: balance;
}
.cols,
.row-btn {
  display: grid;
  grid-template-columns: 20px 1fr 52px;
  column-gap: 8px;
  align-items: center;
}
.cols {
  padding: 8px 24px;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
  color: var(--ink-2);
}
.cols span:first-child { grid-column: 1 / 3; }
.cols span:nth-child(n + 2) { text-align: right; }
.rows {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  overflow-y: auto;
  flex: 1;
  position: relative;
}
.row { position: relative; }
.row-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 10px 24px 8px;
  row-gap: 6px;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out);
}
.row.hovered .row-btn { background: var(--tint); }
.row.selected .row-btn { box-shadow: inset 2px 0 0 var(--ink); }
.row-flags { display: inline-flex; align-items: center; }
.row-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-age { text-align: right; font-variant-numeric: tabular-nums; }
/* Split bar: children, youth and adults, seniors, in the crew colours. */
.row-bar {
  grid-column: 1 / -1;
  display: flex;
  gap: 2px;
  height: 6px;
}
.row-bar .seg {
  flex: 0 1 0;
  min-width: 0;
  border-radius: 2px;
  transition: flex-grow 250ms var(--ease-out);
}
.seg-c { background: #e69f00; }
.seg-w { background: #7a8794; }
.seg-e { background: #1f4e99; }
.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 0 24px 10px;
  list-style: none;
  font-size: 13px;
  color: var(--ink-2);
}
.bar-legend li { display: inline-flex; align-items: center; gap: 6px; }
.bar-legend i { width: 10px; height: 10px; border-radius: 2px; }

/* ---------- flags ---------- */

.flag {
  display: inline-block;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(15, 23, 32, 0.14);
  vertical-align: middle;
  flex: none;
  background: #e6ebef;
}
.swatch.empty { background: #9aa6b0; }
.flag-pair { display: inline-flex; align-items: center; gap: 4px; }
.flag-sep { color: var(--ink-3); font-size: 12px; }
.tt-flags, .tag-flags, .key-flags { display: inline-flex; align-items: center; }

/* ---------- tags + pennants ---------- */

.tags {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.tag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  will-change: transform;
}
.tag::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: var(--stem, 0px);
  background: rgba(15, 23, 32, 0.35);
}
.tag[hidden] { display: none; }
.tag .flag { width: 16px; height: 12px; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 7;
  min-width: 256px;
  max-width: 320px;
  background: var(--surface-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  font-size: 13px;
  pointer-events: none;
  animation: fade 150ms var(--ease-out);
}
/* `display: flex` on .mini would otherwise beat the hidden attribute and leave the label stuck on screen. */
.tooltip[hidden] { display: none !important; }
.tooltip.pinned { pointer-events: auto; }
.tooltip.mini {
  min-width: 0;
  padding: 6px 10px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  white-space: nowrap;
}
.mini-name { font-weight: 600; }
/* Ship hover card: name and year, average age, people to support, age split, ruler. */
.tooltip.mini { display: block; white-space: normal; width: 256px; padding: 12px 14px; }
.mt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mt-year { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mt-line { margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--ink-2); text-wrap: pretty; }
.mt-line b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
/* Dividers sit inside the card's padding, as wide as the content. */
.mt-rule-line { margin: 8px 0; border: 0; border-top: 1px solid var(--hair); }
.mt-note { margin-top: 4px; font-size: 12px; line-height: 1.35; color: var(--ink-2); text-wrap: pretty; }
/* Three columns: the group named over its share. */
.mt-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-variant-numeric: tabular-nums; }
.mt-split > span { display: grid; gap: 2px; }
.mt-key { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.mt-split b { font-size: 13px; font-weight: 600; color: var(--ink); }
.mt-split i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.mt-rule { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--hair); font-size: 12px; color: var(--ink-2); }
.mini-age { color: var(--ink-2); font-variant-numeric: tabular-nums; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.tt-head { display: flex; align-items: center; gap: 8px; }
.tt-name { font-family: var(--serif); font-weight: 600; font-size: 18px; flex: 1; }
.tt-year { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.tt-close { margin-left: 4px; }
.tt-rule { color: var(--ink-2); font-size: 12px; margin-top: 4px; }
.tt-stats { margin: 8px 0; display: grid; gap: 4px; }
.tt-stats div { display: flex; justify-content: space-between; gap: 16px; }
.tt-stats dt { color: var(--ink-2); }
.tt-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.deckbar { display: flex; height: 8px; border-radius: 2px; overflow: hidden; background: var(--tint); }
.deckbar span { flex-grow: 0; flex-shrink: 0; }
.deck-legend { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tt-more { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--hair); display: grid; gap: 6px; text-wrap: pretty; }

/* ---------- hero caption card ---------- */

/* Positioned under the spotlight circle by app.js. */
.key {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  width: min(380px, calc(100vw - var(--scene-right) - 32px));
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 24px;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.97);
  transform-origin: 50% 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.key.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 250ms var(--ease-out) 80ms, transform 250ms var(--ease-out) 80ms, visibility 0s;
}
body[data-view='overhead'] .key { display: none; }

.spot-close {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms var(--ease-out), visibility 0s linear 200ms, transform 150ms var(--ease-out);
}
.spot-close.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 250ms var(--ease-out) 80ms, visibility 0s, transform 150ms var(--ease-out);
}
.key-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-flags .flag { width: 24px; height: 18px; }
.key-name {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}
.key-year {
  flex-basis: 100%;
  color: var(--ink-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.key-sentence {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.35;
  text-wrap: pretty;
}
.key-sub { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.key-note { color: var(--ink); font-weight: 500; }
/* Close: a quiet text button at the foot of the card (the old floating X is retired). */
.key-close {
  display: block;
  margin: 14px 0 0 auto;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .key-close:hover { background: var(--tint); color: var(--ink); }
}
.spot-close { display: none !important; }

/* The spotlight is the top surface: the top bar and zoom fade back while it is open.
   The bottom row (radio, year slider, Know more) stays whole, since scrubbing the close-up is the point. */
body.spot-open .brand,
body.spot-open .view-toggle,
body.spot-open .top-actions,
body.spot-open .zoom { opacity: 0; pointer-events: none; }

.key-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(15, 23, 32, 0.3);
  text-underline-offset: 3px;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .key-link:hover { text-decoration-color: currentColor; }
}
.key-swatches {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.key-swatches li { display: grid; grid-template-columns: 12px 1fr auto; column-gap: 8px; align-items: center; }
.key-swatches i { width: 12px; height: 12px; border-radius: 3px; }
.key-swatches span { color: var(--ink-2); }
.key-swatches b { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- zoom ---------- */

.zoom {
  position: fixed;
  right: calc(var(--scene-right) + 16px);
  bottom: calc(var(--strip-h) + 14px + 40px + 12px); /* lifted clear of the bottom line (radio, slider, Know more) */
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 4px;
  transition: right 250ms var(--ease-out);
}
.zoom .icon-btn { border-color: transparent; border-radius: max(8px, calc(var(--r-md) - 4px)); /* concentric: 4px padding */ }
body[data-view='overhead'] .zoom { display: none; }

@media (hover: hover) and (pointer: fine) {
  .row-btn:hover { background: var(--tint); }
}

/* ---------- bottom strip: world totals ---------- */

.strip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 44px;
  z-index: 5;
  display: flex;
  align-items: center;
  padding: 0 8px env(safe-area-inset-bottom);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
/* World population and its age split sit together on the left; world GDP on the right. */
.stat {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  white-space: nowrap;
}
.stat + .stat { border-left: 1px solid var(--hair); }
.stat-split { gap: 12px; }
.stat-gdp { margin-left: auto; }
.stat + .stat-gdp { border-left: 0; }
.stat-est { margin-left: 4px; font-weight: 500; color: var(--ink-2); }
/* Credit at the far right, as on the author's other sites. */
.credit {
  display: flex;
  gap: 12px;
  padding: 0 16px;
  border-left: 1px solid var(--hair);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}
.credit a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(15, 23, 32, 0.25);
  text-underline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .credit a:hover { text-decoration-color: currentColor; }
}
@media (max-width: 1100px) {
  .credit span:first-child { display: none; }
}
.stat-label { color: var(--ink-2); }
.stat-value { color: var(--ink); font-weight: 600; }
.split-item { display: inline-flex; align-items: center; gap: 6px; }
.split-item i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.split-sep { width: 1px; height: 14px; background: var(--hair); }
.split-bar {
  display: inline-flex;
  gap: 2px;
  width: 88px;
  height: 6px;
  margin-left: 4px;
}
.split-bar span { flex: 0 1 0; min-width: 0; border-radius: 2px; transition: flex-grow 250ms var(--ease-out); }
@media (max-width: 1100px) {
  .split-bar { display: none; }
  .stat { padding: 0 10px; }
}

/* ---------- year slider: floating capsule over the scene ---------- */

.timeline {
  position: fixed;
  bottom: calc(var(--strip-h) + 14px);
  /* Centred in the scene area left of the drawer, 20% narrower than the old full-width bar. */
  left: calc((100vw - var(--scene-right)) / 2);
  width: max(280px, calc((100vw - var(--scene-right)) * 0.8 - 180px));
  transform: translateX(-50%);
  padding: 12px 22px 0;
  z-index: 5;
  transition: left 250ms var(--ease-out), width 250ms var(--ease-out);
}
.year-big { display: none; }
.slider {
  --p: 0.5;
  --t: 0.5;
  --thumb: 16px;
  position: relative;
  height: 52px;
}
.track {
  position: absolute;
  left: calc(var(--thumb) / 2);
  right: calc(var(--thumb) / 2);
  top: 22px;
  height: 4px;
}
.track-est,
.track-proj {
  position: absolute;
  top: 0;
  height: 4px;
}
.track-est {
  left: 0;
  width: calc(var(--t) * 100%);
  background: var(--ink);
  border-radius: 2px 0 0 2px;
}
.track-proj {
  left: calc(var(--t) * 100%);
  right: 0;
  background: repeating-linear-gradient(90deg, rgba(15, 23, 32, 0.38) 0 6px, transparent 6px 10px);
}
.ticks { position: absolute; inset: 0; pointer-events: none; }
.tick,
.tick-label {
  position: absolute;
  left: calc(var(--x) * (100% - var(--thumb)) + var(--thumb) / 2);
}
.tick {
  top: 30px;
  width: 1px;
  height: 5px;
  background: rgba(15, 23, 32, 0.35);
}
.tick-label {
  top: 36px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
#year {
  position: absolute;
  inset: 8px 0 0 0;
  width: 100%;
  height: 32px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
#year::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: 32px; }
#year::-moz-range-thumb { width: var(--thumb); height: 32px; border: 0; }
.thumb {
  position: absolute;
  top: 16px;
  left: calc(var(--p) * (100% - var(--thumb)) + var(--thumb) / 2);
  width: 0;
  height: 0;
  pointer-events: none;
}
.thumb::before {
  content: '';
  position: absolute;
  left: calc(var(--thumb) / -2);
  top: 0;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 32, 0.2);
  box-sizing: border-box;
}
#year:focus-visible + .thumb::before { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--focus); }
.thumb-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--ink);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Desktop and tablet: one slim line at the media player's 40px height. The year
   rides with the thumb in the label row under the track; app.js hides any decade
   label it would collide with, so only one year reads there. Phones keep their own layout. */
body:not([data-device='phone']) .timeline {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 20px;
  /* One row with the radio and Know more: the slider fills the space between them,
     12px from each (app.js measures their widths into --radio-w and --know-w). */
  left: calc(16px + var(--radio-w, 176px) + 12px);
  right: calc(var(--scene-right) + 16px + var(--know-w, 120px) + 12px);
  width: auto;
  transform: none;
  transition: left 250ms var(--ease-out), right 250ms var(--ease-out);
}
body:not([data-device='phone']) .slider { --thumb: 14px; flex: 1; height: 40px; }
body:not([data-device='phone']) .track { top: 12px; }
body:not([data-device='phone']) .tick { top: 19px; height: 3px; }
body:not([data-device='phone']) .tick-label { top: 23px; font-size: 10px; line-height: 12px; transition: opacity 120ms var(--ease-out); }
body:not([data-device='phone']) .tick-label.is-covered { opacity: 0; }
body:not([data-device='phone']) #year { inset: 0; height: 28px; }
body:not([data-device='phone']) #year::-webkit-slider-thumb { height: 28px; }
body:not([data-device='phone']) .thumb { top: 7px; }
body:not([data-device='phone']) .thumb-label {
  top: 16px;
  bottom: auto;
  padding: 0;
  background: none;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 12px;
}

/* ---------- World Map: the slider as a dock ---------- */

/* At rest the full slider keeps its layout box (app.js measures it) but folds to a year
   pill; .is-open, set by app.js on hover, keyboard focus or a tap, magnifies it back. */
.dock-pill { display: none; }
body[data-map='true']:not([data-device='phone']) .dock-pill {
  position: fixed;
  bottom: calc(var(--strip-h) + 14px);
  left: calc((100vw - var(--scene-right)) / 2);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 14px 0 16px;
  border-radius: var(--r-md);
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out), left 250ms var(--ease-out);
}
body[data-map='true']:not([data-device='phone']) .dock-pill.is-open {
  opacity: 0;
  transform: translateX(-50%) scale(1.15);
}
.dock-year {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* A tiny track with the thumb at the current year, so the pill reads as a control. */
.dock-hint {
  position: relative;
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: rgba(15, 23, 32, 0.22);
}
.dock-hint i {
  position: absolute;
  top: 50%;
  left: calc(var(--p, 0.5) * 100%);
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-sizing: border-box;
}
body[data-map='true']:not([data-device='phone']) .timeline {
  transform: scale(0.6);
  transform-origin: 50% 100%;
  opacity: 0;
  pointer-events: none; /* the folded slider can't be hovered or dragged; the range input stays focusable */
  transition: transform 220ms var(--ease-out), opacity 220ms var(--ease-out), left 250ms var(--ease-out), right 250ms var(--ease-out);
}
body[data-map='true']:not([data-device='phone']) .timeline.is-open {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

/* ---------- notice + dialogs ---------- */

.landscape-notice {
  /* Sits above the floating slider so it never covers the sidebar heading. */
  position: fixed;
  bottom: calc(var(--dock-h) + 16px);
  left: 16px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 8px 8px 16px;
  background: var(--surface-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: enter 200ms var(--ease-out);
}
.landscape-notice[hidden] { display: none; }

.dialog {
  max-width: min(560px, calc(100vw - 32px));
  background: var(--surface-solid);
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 0;
}
.dialog[open] { animation: enter 200ms var(--ease-out); }
.dialog::backdrop { background: rgba(15, 23, 32, 0.3); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px 24px; }
.dialog-head h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; }
.dialog-body { padding: 0 24px 24px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.dialog-body p { color: var(--ink-2); }
.dialog-body ul { padding-left: 16px; display: grid; gap: 8px; margin: 16px 0 0; }

/* ---------- Top 30 | World Map toggle and map search ---------- */

.view-toggle {
  position: fixed;
  top: 14px;
  left: calc((100vw - var(--scene-right)) / 2);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 2px;
  padding: 3px;
  transition: left 250ms var(--ease-out);
}
.view-toggle button {
  padding: 6px 14px;
  border: 0;
  border-radius: max(8px, calc(var(--r-md) - 3px)); /* concentric: 3px padding */
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.view-toggle button[aria-checked='true'] {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 32, 0.12);
}
.view-toggle button:active { transform: scale(0.97); }
.view-toggle button:disabled { cursor: not-allowed; opacity: 0.55; }
.view-toggle button:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .view-toggle button:not([aria-checked='true']):not(:disabled):hover { color: var(--ink); }
}

/* Search sits in the top bar, left of Menu, in both views, always open. It narrows on
   smaller screens to stay 12px clear of the centred toggle (110px half-width) and Menu. */
.map-search {
  position: relative;
  width: clamp(140px, calc(50vw - 234px), 220px);
  height: 36px;
}
.map-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  z-index: 1;
  color: var(--ink-2);
  pointer-events: none;
}
.map-search .search-list {
  position: absolute;
  right: 0;
  width: 280px;
}
body[data-device='phone'] .map-search { display: none; }
.search-input {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 36px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.search-input::placeholder { color: var(--ink-2); }
.search-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.search-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  animation: enter 150ms var(--ease-out);
}
.search-list[hidden] { display: none; }
.search-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: max(8px, calc(var(--r-md) - 4px)); /* concentric: 4px list padding */
  font-size: 14px;
  cursor: pointer;
}
.search-list li[aria-selected='true'] { background: rgba(255, 255, 255, 0.75); }
@media (hover: hover) and (pointer: fine) {
  .search-list li:not(.opt-empty):hover { background: rgba(255, 255, 255, 0.6); }
}
.opt-flag { display: inline-flex; }
.opt-code { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.search-list .opt-empty { display: block; color: var(--ink-2); cursor: default; }

/* ---------- glass ---------- */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--glass-radius);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-fallback); }
}
/* The drawer stays flush to the right edge: rounded on its left side only. */
.sidebar.glass { border-radius: var(--r-lg) 0 0 var(--r-lg); border-right: 0; }
/* The strip runs edge to edge. */
.strip.glass { border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -4px 24px rgba(15, 23, 32, 0.08); }
/* Large glass surfaces. */
.tour.glass, .sheet.glass { border-radius: var(--r-lg); }

/* ---------- squircle corners ---------- */

/* iOS-style continuous-curvature corners on every token-radius element. Browsers
   without corner-shape keep the plain rounded corners above. A squircle at the same
   radius reads tighter than a circular arc, so the tokens scale up here to keep the
   visible corner the same size. Circles (radius 50%) are never listed. */
@supports (corner-shape: squircle) {
  :root {
    --r-sm: 16px;
    --r-md: 24px;
    --r-lg: 32px;
  }
  .glass,
  .icon-btn,
  .text-btn,
  .seg-group, .seg-group button,
  .tabs, .tab,
  .tag,
  .tooltip,
  .key,
  .landscape-notice,
  .dialog,
  .view-toggle button,
  .search-list li,
  .phone-clear,
  .p-row-label,
  .phone-about,
  .tour-skip,
  .tour-pill,
  .view-tip,
  .view-toast,
  .radio-name,
  .radio-bar {
    corner-shape: squircle;
  }
}
@media (hover: hover) and (pointer: fine) {
  .menu-btn.glass:hover { background-color: rgba(255, 255, 255, 0.75); }
}

/* ---------- devices ---------- */

body[data-device='tablet'],
body[data-device='tablet-portrait'] { --sidebar-w: min(360px, 85vw); }

body[data-device='phone'] .sidebar,
body[data-device='phone'] .menu-btn,
body[data-device='phone'] .tooltip,
body[data-device='phone'] .tags,
body[data-device='phone'] .zoom,
body[data-device='phone'] .stat-gdp,
body[data-device='phone'] .split-bar,
body[data-device='phone'] .thumb-label { display: none !important; }

/* Phone: the toggle and search sit under the wordmark. */
body[data-device='phone'] .view-toggle { top: 52px; left: 50%; }
body[data-device='phone'] .map-search { top: 96px; left: 50%; width: calc(100vw - 32px); }

body[data-device='phone'] .timeline {
  left: 50%;
  width: calc(100vw - 32px);
  padding: 8px 18px 0;
}
/* Phone strip: population on one line, the three-way split under it. */
body[data-device='phone'] .strip {
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  font-size: 12px;
}
body[data-device='phone'] .stat { padding: 0; }
body[data-device='phone'] .stat + .stat { border-left: 0; }
body[data-device='phone'] .stat-split { gap: 8px; }
body[data-device='phone'] .year-big {
  display: block;
  text-align: center;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
body[data-device='phone'] .key { padding: 8px 16px 12px; }
body[data-device='phone'] .key-name { font-size: 22px; }
body[data-device='phone'] .key-sentence { margin-top: 4px; font-size: 16px; }
body[data-device='phone'] .key-swatches { margin-top: 8px; gap: 4px; font-size: 12px; }
body[data-device='phone'] .key-swatches b { font-size: 13px; }
body[data-device='phone'] .spot-close { display: none; }

/* ---------- phones: the scrolling fleet ---------- */

.phone[hidden],
.phone-world { display: none; }
body[data-device='phone'] .view-toggle,
body[data-device='phone'] .map-search,
body[data-device='phone'] .key,
body[data-device='phone'] .strip,
body[data-device='phone'] .landscape-notice { display: none !important; }

.phone { --row-h: 168px; }
.phone-search {
  position: fixed;
  top: 52px;
  left: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 6px 0 14px;
}
.phone-search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.phone-search-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; }
.phone-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  color: var(--ink);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.phone-search input::placeholder { color: var(--ink-2); }
.phone-search input::-webkit-search-cancel-button { display: none; }
.phone-clear {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: max(8px, calc(var(--r-md) - 6px)); /* concentric: 6px padding in .phone-search */
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.phone-clear[hidden] { display: none; }
.phone-clear svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.phone-list {
  position: fixed;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 108px 0 calc(var(--dock-h) + 16px);
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.p-row {
  position: relative;
  height: var(--row-h);
  margin-bottom: 6px;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.p-row-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent; /* the ship and its sea are drawn on the canvas behind */
  text-align: left;
  cursor: pointer;
}
.p-row-btn:focus-visible { outline-offset: -4px; }
.p-row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 13px;
}
.p-flag { display: inline-flex; }
.p-flag .flag { width: 18px; height: 13.5px; }
.p-name { font-weight: 600; color: var(--ink); }
.p-age { color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* Leaving rows lift out of the flow and fold away; new rows rise in. */
.p-leaving { position: absolute; left: 0; right: 0; transform-origin: 50% 0; pointer-events: none; }
.p-leaving.p-gone { opacity: 0; transform: scaleY(0.4); }
.p-entering { opacity: 0; transform: translateY(14px); }
.phone-about-item { padding: 16px 16px 8px; text-align: center; }
.phone-about {
  padding: 8px 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(15, 23, 32, 0.3);
  text-underline-offset: 3px;
  cursor: pointer;
}

body[data-device='phone'] .phone-world {
  display: block;
  margin: 0 -8px 2px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  text-wrap: balance; /* wraps onto two even lines instead of cutting off */
}
/* World population across the top, then three even columns: label over its percentage. */
body[data-device='phone'] .phone-world {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 8px;
  row-gap: 2px;
}
.phone-world span { white-space: nowrap; text-align: center; }
.phone-world span:first-child { grid-column: 1 / -1; }
.phone-world b { display: block; font-weight: 600; color: var(--ink); }
.phone-world i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; vertical-align: 0; }

/* Bottom sheet */
/* The sheet and its backdrop stop above the year dock, so scrubbing works while it's open. */
.sheet-backdrop {
  position: fixed;
  inset: 0 0 var(--dock-h) 0;
  z-index: 8;
  background: rgba(15, 23, 32, 0.25);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}
.sheet-backdrop.is-open { opacity: 1; }
.sheet-backdrop[hidden] { display: none; }
.sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--dock-h) + 8px);
  z-index: 9;
  max-height: calc(100vh - var(--dock-h) - 120px);
  padding: 0 20px 18px;
  overflow-y: auto;
  transform: translateY(calc(100% + var(--dock-h) + 24px));
  transition: transform 260ms var(--ease-out);
}
.sheet.glass { background: rgba(255, 255, 255, 0.82); }
.sheet.is-open { transform: none; }
.sheet[hidden] { display: none; }
.sheet-top {
  position: sticky;
  top: 0;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
}
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(15, 23, 32, 0.25); }
.sheet-close { position: absolute; right: -6px; top: 6px; border-color: transparent; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-flags { display: inline-flex; }
.sheet-flags .flag { width: 24px; height: 18px; }
.sheet-title { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; }
.sheet-year { margin-top: 4px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sheet-sentence { margin-top: 10px; font-family: var(--serif); font-size: 18px; line-height: 1.35; text-wrap: pretty; }
.sheet-split { margin-top: 14px; }
.sheet-about { font-size: 14px; }
.sheet-about h3 { margin: 14px 0 6px; font-size: 15px; }

/* Spotlight: a lit close-up of the open sheet's ship, floating above the sheet. */
.phone-spot {
  position: fixed;
  left: 50%;
  z-index: 9;
  pointer-events: none; /* a tap here lands on the backdrop and closes the sheet */
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255, 243, 214, 0.95), 0 0 40px 8px rgba(255, 240, 200, 0.5);
  opacity: 0;
  transform: translateX(-50%) scale(0.92);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}
.phone-spot.is-open { opacity: 1; transform: translateX(-50%) scale(1); }
.phone-spot[hidden] { display: none; }
.phone-spot canvas { display: block; width: 100%; height: 100%; }

body.no-webgl #harbour { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sidebar, .row, .row-fill, .tooltip, .key, .spot-close, .dialog[open], .landscape-notice, .menu-btn, .zoom, .timeline, .split-bar span,
  .p-row, .sheet, .sheet-backdrop, .phone-spot, .dock-pill {
    transition: none !important;
    animation: none !important;
  }
}

/* ==========================================================================
   Onboarding tour (onboarding.js) and view-toggle tips
   ========================================================================== */

/* ---------- tour dialog ---------- */

.tour {
  --glass-bg: rgba(255, 255, 255, 0.8); /* a touch more opaque than other glass so body text reads over the scene */
  --spot: 212px; /* spotlight diameter */
  --tour-col: 400px; /* one text column for every step, so no card reads wider than another */
  width: min(520px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto; /* last resort: only scrolls on very short windows */
  overscroll-behavior: contain;
}
@media (max-width: 900px), (max-height: 760px) {
  .tour { --spot: 172px; }
}
/* The live region sits at the top so its 1px box never adds a scrollbar. */
.tour > .sr-only { top: 0; left: 0; }
.tour::backdrop { background: rgba(15, 23, 32, 0.28); }
.tour[open] { animation: tour-in 260ms var(--ease-out); }
.tour[open]::backdrop { animation: fade 260ms var(--ease-out); }
@keyframes tour-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* Skip, alone at the top right, out of the flow so the top and bottom space match.
   Vertical rhythm: 36 above the spotlight, 32 to the title, 12 to the body (always two
   lines tall), 32 to the footer, 36 below the arrows. */
.tour-top {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
}
.tour-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tour-dots li {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: background-color 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.tour-dots li.is-current { background: var(--ink); transform: scale(1.35); }
.tour-skip {
  padding: 6px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}

/* Every step sits in the same grid cell, so the dialog keeps the height of the tallest one. */
.tour-stage {
  display: grid;
  padding: 36px 28px 0;
}
.tour-slide {
  grid-area: 1 / 1;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(16px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms;
}
.tour-slide.is-before { transform: translateX(-16px); }
.tour-slide.is-current {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s;
}
.tour-instant .tour-slide,
.tour-instant .tour-dots li { transition: none; }

/* The spotlight: a lit disc of sea and sky with a warm rim and halo, as in the
   close-up view, and a faint beam falling from it toward the title. */
.tour-fig {
  position: relative;
  width: var(--spot);
  height: var(--spot);
  margin: 0 auto;
}
.tour-spot {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(#a9d0ee, #d8ecf8 58%);
  box-shadow: 0 0 0 2px rgba(255, 243, 214, 0.95), 0 0 40px 8px rgba(255, 240, 200, 0.5);
}
.tour-spot svg { display: block; width: 100%; height: 100%; }
.tour-beam {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: calc(100% - 12px);
  width: calc(var(--spot) * 1.3);
  height: 76px;
  transform: translateX(-50%);
  background: linear-gradient(rgba(255, 240, 200, 0.6), rgba(255, 240, 200, 0));
  clip-path: polygon(31% 0, 69% 0, 100% 100%, 0 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 32%, #000 68%, transparent);
  pointer-events: none;
}
/* World Map step: the search pill on the disc's top edge. */
.tour-pill {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: -10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 10px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(15, 23, 32, 0.12);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  transform: translateX(-50%);
}
.tour-pill svg { width: 12px; height: 12px; flex: none; }
.tour-svg-label { font-size: 11px; font-weight: 500; fill: #ffffff; }
.tour-svg-note { font-size: 11px; font-weight: 500; fill: var(--ink); }
.tour-svg-tick { font-size: 10px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }

/* World Map step: ripple rings around the hovered ship. */
.tour-ripple {
  transform-box: fill-box;
  transform-origin: center;
  animation: tour-ripple 2.4s var(--ease-out) infinite;
}
.tour-ripple-2 { animation-delay: 1.2s; }
.tour-slide:not(.is-current) .tour-ripple { animation-play-state: paused; }
@keyframes tour-ripple {
  from { transform: scale(0.7); opacity: 1; }
  to { transform: scale(1.5); opacity: 0; }
}

.tour-title {
  position: relative;
  z-index: 1;
  max-width: var(--tour-col);
  margin: 32px auto 12px;
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 26px);
  line-height: 1.2;
  text-wrap: pretty; /* fills the shared column; no lone last word */
}
.tour-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  max-width: var(--tour-col);
  min-height: calc(2 * 1.55em); /* every body holds two lines, so every step has the same shape */
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}
.tour-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--ink-2);
}
.tour-legend li { display: inline-flex; align-items: center; gap: 6px; }
.tour-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* Footer: [back]  dots  [next], the dots centred between the two arrows. */
.tour-foot {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  padding: 32px 28px 36px;
}
.tour-arrow {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.tour-arrow svg { width: 20px; height: 20px; display: block; }
.tour-back {
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(15, 23, 32, 0.14);
  color: var(--ink);
}
.tour-back.is-hidden { visibility: hidden; }
.tour-next {
  border: 1px solid #0f1720;
  background: #0f1720;
  color: #ffffff;
}
.tour-next .tour-i-done,
.tour-next.is-last .tour-i-next { display: none; }
.tour-next.is-last .tour-i-done { display: block; }
.tour-arrow:active { transform: scale(0.97); }
.tour-arrow:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .tour-skip:hover { background: var(--tint); color: var(--ink); }
  .tour-back:hover { background: rgba(255, 255, 255, 0.85); }
  .tour-next:hover { background: #26313b; }
}

/* Step 3: the ship swings from front-down (young crew) to back-down (old crew). */
.tour-pair { display: none; }
.tour-tilt {
  transform-origin: 0 0;
  animation: tour-tilt 7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.tour-anim .tour-young { animation: tour-young 7s linear infinite; }
.tour-anim .tour-old { animation: tour-old 7s linear infinite; }
.tour-slide:not(.is-current) .tour-tilt,
.tour-slide:not(.is-current) .tour-young,
.tour-slide:not(.is-current) .tour-old { animation-play-state: paused; }
@keyframes tour-tilt {
  0%, 30% { transform: rotate(-8deg); }
  50%, 80% { transform: rotate(8deg); }
  100% { transform: rotate(-8deg); }
}
@keyframes tour-young {
  0%, 32% { opacity: 1; }
  40%, 84% { opacity: 0; }
  92%, 100% { opacity: 1; }
}
@keyframes tour-old {
  0%, 32% { opacity: 0; }
  40%, 84% { opacity: 1; }
  92%, 100% { opacity: 0; }
}

/* Reopen link in About: a button dressed as .about-link. */
.about-tour {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- view "i": what each view shows, on hover or tap ---------- */

.view-info {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: -3px;
  opacity: 0.6;
  cursor: help;
  transition: opacity 150ms var(--ease-out);
}
.view-info svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .view-info:hover { opacity: 1; }
}
.view-tip {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 1;
  width: max-content;
  max-width: 260px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  text-wrap: balance;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.view-tip[data-side='top'] { left: 0; }
.view-tip[data-side='map'] { right: 0; }
.view-tip.is-on { opacity: 1; transform: none; }
/* The tip sits over the map search while it shows. */
.view-toggle:has(.view-tip.is-on) { z-index: 7; }

/* ---------- view toast: what the current view shows ---------- */

/* Centred above the year slider; once per view, on a viewer's first visit to it. */
.view-toast {
  position: fixed;
  left: calc((100vw - var(--scene-right)) / 2);
  bottom: calc(var(--dock-h) + 12px);
  z-index: 6;
  width: max-content;
  max-width: min(480px, calc(100vw - var(--scene-right) - 32px));
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  text-align: center;
  text-wrap: balance;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.view-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
body[data-device='phone'] .view-toast { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tour[open], .tour[open]::backdrop, .tour-slide, .tour-dots li, .tour-arrow, .tour-ripple, .view-toast, .view-tip {
    transition: none !important;
    animation: none !important;
  }
  .tour-anim { display: none; }
  .tour-pair { display: inline; }
}

/* ---------- radio: bottom left, beside the year slider ---------- */

.radio {
  position: fixed;
  left: 16px;
  bottom: calc(var(--strip-h) + 14px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0;
  height: 40px;
  padding: 0 4px;
  border-radius: var(--r-md); /* matches the year slider beside it */
}
/* Exactly three controls: play/pause, the station name, the speaker. */
.radio-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out), opacity 150ms var(--ease-out);
}
.radio-btn svg.ph { width: 16px; height: 16px; } /* grid items, so already block; no display here or it beats the show/hide rules */
.radio-btn:active { transform: scale(0.97); }
.radio-btn:focus-visible { outline-offset: 0; }
.radio-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .radio-btn:not(:disabled):hover { background-color: var(--tint); }
}
.radio-play .i-pause,
.radio-play[aria-pressed='true'] .i-play { display: none; }
.radio-play[aria-pressed='true'] .i-pause { display: block; }
.radio-play[aria-busy='true'] { opacity: 0.55; cursor: progress; }

/* Rings: thin circles drawn just inside each round control. */
.radio-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.radio-ring circle { fill: none; stroke: var(--ink); stroke-width: 1.5; }
/* Play: radio.js swells this ring with the music's loudness while playing. */
#radio-pulse { stroke-opacity: 0.18; }

/* Station name: click for the next station. Never hides; truncates instead, so the
   pill always clears the centred year slider (its left edge, minus the pill's own buttons). */
.radio-name {
  /* A fixed width, so switching stations never changes the pill's size or nudges the slider. */
  flex: none;
  width: 104px;
  min-width: 0;
  max-width: 104px;
  text-align: left;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: max(8px, calc(var(--r-md) - 4px)); /* concentric: 4px padding in .radio */
  background: transparent;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.radio-name:focus-visible { outline-offset: 0; }
.radio-name-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  .radio-name:hover { background-color: var(--tint); color: var(--ink); }
}

/* Volume: the speaker shows the level and mutes on click. Hovering or focusing it
   slides a volume bar out to its right while the station name folds away by the
   same width (--vol-w, set by radio.js), so the pill never grows or collides. */
.radio-volume { display: flex; align-items: center; }
.radio-vol .i-vol-none, .radio-vol .i-vol-low, .radio-vol .i-vol-high { display: none; }
.radio-vol[data-level='none'] .i-vol-none,
.radio-vol[data-level='low'] .i-vol-low,
.radio-vol[data-level='high'] .i-vol-high { display: block; }
.radio-name { transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out), max-width 220ms var(--ease-out), opacity 160ms var(--ease-out), padding 220ms var(--ease-out); }
.radio.vol-open .radio-name { max-width: 0 !important; padding: 0; opacity: 0; pointer-events: none; }
.radio-bar {
  position: relative;
  width: 0;
  height: 32px;
  opacity: 0;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  transition: width 220ms var(--ease-out), opacity 160ms var(--ease-out);
}
.radio.vol-open .radio-bar { width: var(--vol-w, 80px); opacity: 1; }
.radio-bar:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: max(8px, calc(var(--r-md) - 4px)); }
.radio-bar-track {
  position: absolute;
  left: 8px;
  right: 10px;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: rgba(15, 23, 32, 0.16);
}
.radio-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; border-radius: 2px; background: var(--ink); }
.radio-bar-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--ink);
  box-sizing: border-box;
}
.radio.vol-dragging .radio-bar { cursor: grabbing; }

body[data-device='phone'] .radio { display: none; }

@media (prefers-reduced-motion: reduce) {
  .radio-btn, .radio-name, .radio-bar { transition: none !important; }
}

/* Top bar: one 40px line from 16px down, the same height as the bottom row, so the logo,
   the toggle, search and Menu share one centre line (36px from the top). */
body:not([data-device='phone']) .brand { top: 16px; height: 40px; }
body:not([data-device='phone']) .wordmark { line-height: 40px; }
body:not([data-device='phone']) .view-toggle { top: 16px; height: 40px; padding: 3px; align-items: center; } /* 1px glass border + 3px = 4px around the 32px segments */
body:not([data-device='phone']) .view-toggle button { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; }
.map-search,
.search-input { height: 40px; }
.top-actions .menu-btn { height: 40px; padding: 0 16px 0 14px; }

/* Spotlight fade: each element keeps its own transitions and adds opacity (last, so it wins). */
.brand, .top-actions { transition: opacity 220ms var(--ease-out); }
.view-toggle { transition: left 250ms var(--ease-out), opacity 220ms var(--ease-out); }
.zoom { transition: right 250ms var(--ease-out), opacity 220ms var(--ease-out); }
.know-more { transition: right 250ms var(--ease-out), background-color 150ms var(--ease-out), transform 150ms var(--ease-out), opacity 220ms var(--ease-out); }
