/* civsg map app. Paper cards on a walnut gallery table; the map fills the window.
   Tokens live in tokens.css. No UI text under 12 px; tap targets 44 px on touch; no horizontal overflow. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--table);
  color: var(--ink);
  font: var(--weight-regular) var(--text-14) / var(--leading-ui) var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num, .yield-v, .tabular { font-variant-numeric: var(--num); }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; overflow: hidden; --top-h: 64px; --gap: 12px; --panel-w: 0px; }
.map-wrap { position: absolute; inset: 0; z-index: 0; }
.skip-link { position: absolute; z-index: 90; left: var(--gap); top: var(--gap); padding: 10px 14px; border-radius: var(--r-2); background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: var(--e-3); transform: translateY(-200%); }
.skip-link:focus-visible { transform: none; }
.map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.map:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }   /* inset: the map fills the screen */
.map.is-dragging { cursor: grabbing; }
.map.is-pointing { cursor: pointer; }

/* ---------------------------------------------------------------- paper card */
.card, .topbar-inner, .chip, .legend, .mapctl .zoom, .minimap, .panel, .timebar, .pop, .tooltip, .toast, .search-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r-3);
  box-shadow: var(--e-2);
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: absolute; left: var(--gap); right: var(--gap); top: var(--gap);
  height: 52px; display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--paper); border-radius: var(--r-3); box-shadow: var(--e-2);
  z-index: 20; min-width: 0;
}
.brand { display: flex; align-items: center; gap: var(--s-2); color: var(--ink); text-decoration: none; flex: none; min-height: 44px; min-width: 44px; padding-right: var(--s-1); }
.brand-mark { width: 22px; height: 24px; background: var(--accent);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); box-shadow: var(--e-1); }
.brand-word { font: 750 var(--text-20) / 1 var(--font-display); letter-spacing: -0.01em; font-stretch: 92%; }

.yields { display: flex; align-items: stretch; gap: 2px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.yield {
  display: grid; grid-template-columns: 24px auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center;
  padding: 4px 8px; border: 0; background: transparent; border-radius: var(--r-2); min-height: 44px; flex: none;
  text-align: left;
}
.yield:hover, .yield:focus-visible { background: var(--paper-2); }
.yield canvas { grid-row: 1 / span 2; width: 24px; height: 24px; }
.yield:not(:has(.yield-l)) { grid-template-rows: auto; }
.yield-v { font-weight: var(--weight-semi); font-size: var(--text-14); line-height: 1.1; white-space: nowrap; }
.yield-l { font-size: var(--text-12); color: var(--ink-3); line-height: 1.1; white-space: nowrap; }

.live-read { display: flex; gap: var(--s-3); align-items: center; flex: none; font-size: var(--text-13); color: var(--ink-2); white-space: nowrap; }
.live-read b { color: var(--ink); font-weight: var(--weight-semi); font-variant-numeric: var(--num); }
.live-read .stale { color: var(--warn); }

.tools { display: flex; gap: 4px; align-items: center; flex: none; }
.search-btn, .tog {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px;
  border-radius: var(--r-2); border: 1px solid var(--hairline); background: var(--paper);
  font-weight: var(--weight-medium); font-size: var(--text-13); color: var(--ink);
  transition: background var(--d-feedback) var(--ease-out), border-color var(--d-feedback);
}
.search-btn svg, .tog svg { width: 18px; height: 18px; flex: none; }
.search-btn { color: var(--ink-2); min-width: 190px; justify-content: flex-start; }
.search-label { flex: 1; text-align: left; }
.kbd { font: 600 12px/1 var(--font-ui); border: 1px solid var(--hairline); border-radius: 5px; padding: 3px 6px; color: var(--ink-3); background: var(--paper-2); }
.search-btn:hover, .tog:hover { background: var(--paper-2); }
.tog[aria-pressed="true"], .tog[aria-expanded="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: none; }
.tog[aria-pressed="true"] .live-dot { background: var(--live); box-shadow: 0 0 0 0 rgb(47 163 107 / 0.6); }
.app[data-live="on"] .tog[aria-pressed="true"] .live-dot { animation: pulse 1.8s var(--ease-out) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(47 163 107 / 0.55); } 100% { box-shadow: 0 0 0 9px rgb(47 163 107 / 0); } }
.menu-btn { display: none; }
/* yields that do not fit whole are hidden by topbar.js (never clipped); the More button then holds them all */
.yields .yield.is-off { display: none; }
.app[data-yieldsclip="on"] .menu-btn { display: inline-flex; }
.yield-u { font-size: var(--text-12); font-weight: 500; color: var(--ink-3); }

/* ---------------------------------------------------------------- lens bar */
.lensbar {
  position: absolute; left: var(--gap); top: calc(var(--gap) + 52px + 8px); z-index: 15;
  display: flex; gap: 6px; align-items: center; max-width: calc(100% - 2 * var(--gap) - var(--panel-w));
}
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; min-width: 0; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
/* the lens strip fades over a chip's width, so its edge never reads as a chip cut in half */
.chips.fade-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 96px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 96px), transparent); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 10px; flex: none;
  border: 0; font-size: var(--text-13); font-weight: var(--weight-medium); white-space: nowrap; box-shadow: var(--e-1);
  scroll-snap-align: start;
}
.chip .sw { width: 18px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.chip[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.chip:hover { filter: brightness(0.97); }
.chip-all { padding: 0 12px; flex: none; background: var(--paper-2); }

/* ---------------------------------------------------------------- pop-overs */
.pop { position: absolute; z-index: 40; padding: var(--s-4); box-shadow: var(--e-3); max-height: calc(100% - 140px); overflow: auto; }
.lens-pop { left: var(--gap); top: calc(var(--gap) + 52px + 56px); width: min(640px, calc(100% - 2 * var(--gap))); }
.lens-group { margin: 0 0 var(--s-4); }
.lens-group h3, .pop h3 { margin: 0 0 var(--s-2); font: 600 var(--text-12) / 1.2 var(--font-ui); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--ink-3); }
.lens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.lens-opt { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 6px 10px; border-radius: var(--r-2); border: 1px solid var(--hairline); background: var(--paper); text-align: left; font-size: var(--text-13); }
.lens-opt[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.lens-opt .sw { width: 28px; height: 14px; border-radius: 3px; flex: none; }
.layers-pop { right: var(--gap); top: calc(var(--gap) + 60px); width: min(340px, calc(100% - 2 * var(--gap))); }
.layer-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px; border-radius: var(--r-2); cursor: pointer; }
.layer-row:hover { background: var(--paper-2); }
.layer-row canvas { width: 28px; height: 28px; flex: none; }
.layer-row .lr-t { flex: 1; font-size: var(--text-14); }
.layer-row .lr-n { font-size: var(--text-12); color: var(--ink-3); display: block; }
.layer-row .lr-disc { all: unset; flex: 1; min-height: 36px; display: flex; flex-direction: column; justify-content: center; cursor: pointer; font-size: var(--text-14); border-radius: var(--r-1, 4px); }
.layer-row .lr-disc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lr-chev { width: 12px; height: 12px; flex: none; color: var(--ink-3); transition: transform var(--d-feedback) var(--ease-out); }
.lr-chev svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
.layer-group.is-open .lr-chev { transform: rotate(90deg); }
.layer-sub { margin: 0 0 6px 38px; padding-left: 10px; border-left: 1px solid var(--paper-3); }
.layer-subrow { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 2px 6px; border-radius: var(--r-2); cursor: pointer; font-size: var(--text-13, 13px); }
.layer-subrow:hover { background: var(--paper-2); }
.layer-subrow canvas { width: 22px; height: 22px; flex: none; }
.layer-subrow .lr-t { flex: 1; }
.layer-subrow .lr-n { display: inline; margin-left: 6px; font-size: var(--text-12); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.switch.switch-s { width: 34px; height: 20px; }
.switch.switch-s::after { width: 14px; height: 14px; }
.switch.switch-s:checked::after { transform: translateX(14px); }
input.switch:indeterminate { background: color-mix(in srgb, var(--accent) 55%, var(--paper-3)); }
input.switch:indeterminate::after { transform: translateX(8px); }
.switch { appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--paper-3); position: relative; flex: none; margin: 0; cursor: pointer; transition: background var(--d-feedback); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); box-shadow: var(--e-1); transition: transform var(--d-feedback) var(--ease-out); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.menu-sheet { right: var(--gap); top: calc(var(--gap) + 60px); width: min(360px, calc(100% - 2 * var(--gap))); }
.menu-yields { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: var(--s-4); }
.menu-yields .yield { width: 100%; }
.menu-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menu-tools .tog { height: 44px; justify-content: center; }
.pop-note { font-size: var(--text-12); color: var(--ink-3); margin: var(--s-3) 0 0; }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 10px 0; min-height: 44px; font-weight: 600; font-size: var(--text-13); }

/* ---------------------------------------------------------------- legend */
.legend {
  position: absolute; left: var(--gap); bottom: var(--gap); z-index: 15; width: 300px; padding: 12px 14px 12px;
}
.lg-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lg-title { font: 700 var(--text-16) / 1.2 var(--font-display); }
.lg-unit { font-size: var(--text-12); color: var(--ink-3); }
.lg-hist { display: block; width: 100%; height: 64px; margin: 8px 0 2px; }
.lg-axis { display: flex; justify-content: space-between; font-size: var(--text-12); color: var(--ink-2); font-variant-numeric: var(--num); }
.lg-read { min-height: 18px; font-size: var(--text-13); margin-top: 6px; color: var(--ink); font-variant-numeric: var(--num); }
.lg-read b { font-weight: 600; }
.lg-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 8px; }
.lg-cat { display: flex; align-items: center; gap: 6px; font-size: var(--text-12); min-width: 0; }
.lg-cat span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-cat canvas { width: 18px; height: 14px; flex: none; border-radius: 3px; }
.lg-note { font-size: var(--text-12); color: var(--ink-3); margin-top: 6px; }
.lg-src { font-size: var(--text-12); color: var(--ink-3); margin-top: 4px; }
.lg-src a { color: inherit; }
.lg-close { border: 0; background: none; width: 44px; height: 44px; margin: -12px -14px -12px 0; color: var(--ink-3); }
.lg-close svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- map controls */
.mapctl { position: absolute; right: calc(var(--gap) + var(--panel-w)); bottom: var(--gap); z-index: 15; display: flex; align-items: flex-end; gap: 8px; transition: right var(--d-enter) var(--ease-out); }
.credit { align-self: flex-end; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: color-mix(in srgb, var(--paper) 88%, transparent); color: var(--ink); font: 600 12px/1 var(--font-ui); text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,.18); white-space: nowrap; }
.credit:hover { background: var(--paper); text-decoration: underline; }
.credit:focus-visible { outline: 2px solid var(--accent, #d8664a); outline-offset: 2px; }
.minimap { display: block; width: 180px; height: 120px; cursor: pointer; background: var(--table-2); }
.zoom { display: flex; flex-direction: column; overflow: hidden; }
.zoom button { width: 44px; height: 44px; border: 0; background: var(--paper); font: 600 20px/1 var(--font-ui); color: var(--ink); display: grid; place-items: center; }
.zoom button + button { border-top: 1px solid var(--hairline); }
.zoom button:hover { background: var(--paper-2); }
.zoom svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- panel host */
.panel {
  position: absolute; z-index: 30; right: var(--gap); top: calc(var(--gap) + 52px + 8px); bottom: var(--gap);
  width: 400px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--e-3);
  transform: translateX(0); transition: transform var(--d-enter) var(--ease-out), opacity var(--d-enter);
}
.panel.is-entering { transform: translateX(24px); opacity: 0; }
.panel-grip { display: none; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; padding: 14px 8px 8px 18px; border-bottom: 1px solid var(--hairline); }
.panel-title { flex: 1; min-width: 0; }
.panel-title h2 { margin: 0; font: 750 var(--text-24) / 1.1 var(--font-display); letter-spacing: -0.01em; }
.panel-title .sub { margin-top: 2px; font-size: var(--text-13); color: var(--ink-3); }
.panel-close { width: 44px; height: 44px; border: 0; background: none; border-radius: var(--r-2); display: grid; place-items: center; flex: none; color: var(--ink-2); }
.panel-close:hover { background: var(--paper-2); }
.panel-close svg { width: 20px; height: 20px; }
.panel-body { flex: 1; overflow: auto; padding: 14px 18px 24px; overscroll-behavior: contain; }
.pb-kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 14px; font-size: var(--text-14); }
.pb-kv dt { color: var(--ink-2); }
.pb-kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: var(--num); }
.pb-big { font: 750 var(--text-44) / 1 var(--font-display); font-variant-numeric: var(--num); letter-spacing: -0.02em; }
.pb-big-l { font-size: var(--text-13); color: var(--ink-3); margin: 2px 0 14px; }
.pb-head { font-weight: 700; font-family: var(--font-display); font-size: var(--text-18); margin: 6px 0 4px; }
.pb-why { font-size: var(--text-14); color: var(--ink-2); margin: 0 0 14px; }
.pb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.pb-tag { font-size: var(--text-12); font-weight: 600; padding: 4px 8px; border-radius: var(--r-pill); background: var(--paper-2); }
.pb-src { font-size: var(--text-12); color: var(--ink-3); }
.pb-na { font-weight: 400; color: var(--ink-3); font-style: italic; }
.pb-quote { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--paper-2); border-radius: 0 var(--r-2) var(--r-2) 0; font: italic var(--text-14) / 1.45 var(--font-ui); color: var(--ink); }
.pb-quote cite { display: block; margin-top: 4px; font: normal var(--text-12) / 1.3 var(--font-ui); color: var(--ink-3); }
.pb-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; }
.pb-link { font-size: var(--text-13, 13px); color: var(--accent); text-decoration: underline; text-underline-offset: 2px; min-height: 28px; display: inline-flex; align-items: center; }
.pb-foot { margin: 6px 0 0; line-height: 1.45; }
.pb-kv dd { overflow-wrap: anywhere; }
.pb-lines { display: flex; gap: 4px; }
.pb-lines i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.pb-live { border-top: 1px solid var(--hairline); padding-top: 10px; margin-top: 4px; }
.pb-live h4 { margin: 0 0 6px; font-size: var(--text-12); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--live); }

/* ---------------------------------------------------------------- history timebar */
.timebar {
  position: absolute; z-index: 18; left: 50%; bottom: var(--gap); transform: translateX(-50%);
  width: min(760px, calc(100% - 2 * var(--gap) - 2 * 316px)); padding: 10px 14px 12px; min-width: 360px;
}
.tb-row { display: flex; align-items: center; gap: 12px; }
.tb-play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; box-shadow: var(--e-1); }
.tb-play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.tb-year { font: 750 var(--text-32) / 1 var(--font-display); font-variant-numeric: var(--num); width: 4.2ch; flex: none; }
/* the knob is 20 px wide and centred on the year: inset the track so it never covers the year label */
.tb-track { position: relative; flex: 1; height: 44px; margin: 0 10px 0 12px; }
.tb-note { font-size: var(--text-12); color: var(--ink-3); margin-top: 4px; line-height: 1.35; }
.tb-dim { font-style: normal; color: var(--ink-3); }
.tb-track input { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; height: 44px; }
.tb-rail { position: absolute; left: 0; right: 0; top: 20px; height: 4px; border-radius: 2px; background: var(--paper-3); }
.tb-fill { position: absolute; left: 0; top: 20px; height: 4px; border-radius: 2px; background: var(--ink); }
.tb-knob { position: absolute; top: 12px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: var(--paper); box-shadow: var(--e-2), inset 0 0 0 3px var(--ink); pointer-events: none; }
.tb-tick { position: absolute; top: 14px; width: 2px; height: 16px; margin-left: -1px; background: var(--accent); border-radius: 1px; pointer-events: none; }
.tb-tick.rail { background: var(--line-ns); }
.tb-ends { display: flex; justify-content: space-between; gap: 8px; font-size: var(--text-12); color: var(--ink-3); margin-top: -6px; padding-left: calc(44px + 12px + 3.2ch * 2.6 + 12px); font-variant-numeric: var(--num); }
.tb-ms:empty { display: none; }
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) { .tb-ends { padding-left: calc(44px + 12px + 76px); } .tb-ends span:nth-child(2) { display: none; } }
.tb-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--text-13); color: var(--ink-2); margin-top: 6px; }
.tb-stats b { color: var(--ink); font-weight: 600; font-variant-numeric: var(--num); }
.tb-ms { font-size: var(--text-13); margin-top: 6px; min-height: 20px; color: var(--ink); }
.tb-ms .src { color: var(--ink-3); font-size: var(--text-12); }

/* ---------------------------------------------------------------- tooltip, toast */
.tooltip { position: absolute; z-index: 50; pointer-events: none; padding: 10px 12px; max-width: 300px; font-size: var(--text-13); box-shadow: var(--e-3); }
.tt-t { font: 700 var(--text-16) / 1.15 var(--font-display); }
.tt-s { color: var(--ink-3); font-size: var(--text-12); margin-bottom: 6px; }
.tt-kv { display: grid; grid-template-columns: auto auto; gap: 2px 12px; }
.tt-kv span:nth-child(2n) { text-align: right; font-weight: 600; font-variant-numeric: var(--num); }
.tt-lens { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--hairline); }
.tt-tip { font-size: var(--text-13); line-height: 1.45; }
.tt-tip .f { margin-top: 6px; color: var(--ink-2); font-size: var(--text-12); }
.toast { position: absolute; z-index: 60; left: 50%; top: 128px; /* under the lens bar, never over it */ transform: translateX(-50%); padding: 10px 16px; font-size: var(--text-14); max-width: calc(100% - 32px); }

/* a History milestone: a card standing on the time bar, its tail on the year's knob */
.toast.is-ms { top: auto; bottom: calc(var(--timebar-top, 170px) + 12px); left: clamp(180px, var(--tb-knob-x, 50%), calc(100% - 180px)); max-width: min(360px, calc(100% - 32px)); }
.toast.is-ms::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: var(--paper); transform: translateX(-50%) rotate(45deg); box-shadow: 3px 3px 4px rgb(0 0 0 / 0.08); }
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) { .toast.is-ms { left: 50%; } .toast.is-ms::after { display: none; } }

/* ---------------------------------------------------------------- live notes: a feed that is down or out of date says so quietly */
.live-notes { position: absolute; z-index: 14; right: calc(var(--gap) + var(--panel-w)); top: calc(var(--gap) + 52px + 8px + 52px + 4px); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; transition: right var(--d-enter) var(--ease-out); }
.live-notes[hidden] { display: none; }
.lnote { margin: 0; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--paper) 92%, transparent); color: var(--ink-2); font-size: var(--text-12); line-height: 1.3; box-shadow: var(--e-1, 0 1px 2px rgb(0 0 0 / 0.15)); pointer-events: auto; max-width: min(340px, calc(100vw - 2 * var(--gap))); }
.lnote-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.lnote-stale .lnote-dot { background: var(--warn); }
.app[data-mode="opening"] .live-notes, .app[data-mode="loading"] .live-notes { display: none; }

/* ---------------------------------------------------------------- search */
.search { position: absolute; inset: 0; z-index: 70; background: rgb(20 16 12 / 0.35); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search-card { width: min(580px, 100%); overflow: hidden; box-shadow: var(--e-4); }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--hairline); }
.search-field svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.search-field input { flex: 1; min-width: 0; height: 56px; border: 0; background: none; font-size: var(--text-18); outline: none; }
.search-esc { height: 36px; padding: 0 10px; border-radius: var(--r-1); border: 1px solid var(--hairline); background: var(--paper-2); font-size: var(--text-12); color: var(--ink-2); }
.search-list { list-style: none; margin: 0; padding: 6px; max-height: min(60vh, 520px); overflow: auto; }
.search-list li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px; border-radius: var(--r-2); cursor: pointer; }
.search-list li[aria-selected="true"] { background: var(--paper-2); }
.search-list .k { width: 76px; flex: none; font-size: 11px; line-height: 1.2; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.search-list .n { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-list .m { font-size: var(--text-12); color: var(--ink-3); white-space: nowrap; max-width: 42%; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: var(--num); }
.search-list .dots { display: flex; gap: 3px; }
.search-list .dots i { width: 9px; height: 9px; border-radius: 50%; }
.search-empty { padding: 18px; color: var(--ink-3); }

/* ---------------------------------------------------------------- opening */
.opening {
  position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(120% 90% at 22% 8%, rgb(255 214 140 / 0.18), transparent 60%), var(--table);
  transition: opacity 700ms var(--ease-out), background-color 700ms;
}
/* while the island assembles, the title rides at the top of the screen over a dark scrim, at full contrast */
.opening.is-assembling { background: linear-gradient(180deg, rgb(15 12 9 / 0.86) 0, rgb(15 12 9 / 0.6) 20%, rgb(15 12 9 / 0) 40%); }
.opening.is-gone { opacity: 0; }
.opening-card { text-align: center; color: #fffaf0; padding: 0 24px; transition: transform 900ms var(--ease-out), opacity 900ms; }
.opening.is-assembling .opening-card { transform: translateY(-37vh) scale(0.78); }
.opening.is-assembling :is(.opening-sub, .opening-bar) { opacity: 0; transition: opacity 400ms; }
.opening-kicker { font: 650 var(--text-18) / 1.2 var(--font-ui); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: #f6d98f; text-shadow: 0 1px 8px rgb(0 0 0 / 0.6); }
.opening-title { margin: 10px 0 8px; font: 800 clamp(64px, 13vw, 140px) / 0.95 var(--font-display); letter-spacing: -0.03em; font-stretch: 88%; text-shadow: 0 4px 28px rgb(0 0 0 / 0.55); }
.opening-sub { margin: 0 0 18px; font-size: var(--text-16); color: #d9cfbd; min-height: 1.5em; }
.opening-bar { width: min(320px, 70vw); height: 6px; margin: 0 auto; border-radius: 3px; background: rgb(247 242 232 / 0.15); overflow: hidden; }
.opening-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d42e12, #fa9e0d, #009645, #005ec4, #9900aa); transition: width 200ms var(--ease-out); }
.opening-skip { position: absolute; right: 16px; bottom: 16px; pointer-events: auto; height: 44px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid rgb(247 242 232 / 0.35); background: rgb(20 16 12 / 0.45); color: #f7f2e8; font-weight: 600; }
.opening-error { color: #ffb4a6; }
.opening-sub.is-slow { color: #f6d98f; }
/* boot failed: the title card turns into a small paper note with Try again */
.opening-card.opening-failed { pointer-events: auto; max-width: 460px; margin: 0 16px; padding: 28px 28px 26px; border-radius: var(--r-4, 20px); background: var(--paper); color: var(--ink); box-shadow: var(--e-4, 0 20px 50px rgb(0 0 0 / 0.45)); text-align: left; }
.opening-failed .opening-kicker { color: var(--accent, #c8402a); text-shadow: none; font-size: var(--text-13); }
.opening-title.opening-title-sm { font-size: clamp(30px, 7vw, 40px); text-shadow: none; margin: 6px 0 10px; letter-spacing: -0.02em; }
.opening-failed .opening-sub { color: var(--ink); font-size: var(--text-16); margin: 0 0 8px; min-height: 0; }
.opening-hint { margin: 0 0 20px; color: var(--ink-2); font-size: var(--text-14); line-height: 1.5; }
.opening-retry { height: 48px; padding: 0 24px; border: 0; border-radius: var(--r-pill, 999px); background: var(--ink); color: var(--paper); font: 650 var(--text-16) / 1 var(--font-ui); cursor: pointer; }
.opening-retry:focus-visible { outline: 3px solid var(--focus, #2f7de1); outline-offset: 3px; }
.opening-retry:disabled { opacity: 0.6; }
.tb-fail { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tb-retry { min-height: 44px; padding: 0 14px; border-radius: var(--r-pill, 999px); border: 1px solid var(--hairline); background: var(--paper-2); color: var(--ink); font-weight: 600; }
.noscript { color: #f7f2e8; padding: 24px; }

/* ---------------------------------------------------------------- the app while loading */
.app[data-mode="loading"] .topbar, .app[data-mode="loading"] .lensbar, .app[data-mode="loading"] .mapctl,
.app[data-mode="opening"] .topbar, .app[data-mode="opening"] .lensbar, .app[data-mode="opening"] .mapctl { opacity: 0; pointer-events: none; }
.topbar, .lensbar, .mapctl { transition: opacity var(--d-enter) var(--ease-out); }

/* ---------------------------------------------------------------- medium widths */
@media (max-width: 1280px) {
  .yield { padding: 4px 6px; }
  .search-btn { min-width: 0; }
  .search-label { display: none; }
  .timebar { width: min(680px, calc(100% - 2 * var(--gap) - 2 * 200px)); }
}
@media (max-width: 1060px) {
  .tog > span:not(.live-dot) { display: none; }
  .tog { padding: 0 11px; }
  .timebar { left: var(--gap); right: var(--gap); transform: none; width: auto; bottom: calc(var(--gap) + 132px); min-width: 0; }
}

/* the smallest phones: the residents yield drops its icon so "4.2m residents" is never cut */
@media (max-width: 360px) { .yields .yield canvas { display: none; } .yields .yield { grid-template-columns: auto; } }
/* ---------------------------------------------------------------- phone */
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .app { --gap: 8px; }
  .topbar { height: 52px; padding: 0 4px 0 10px; gap: 6px; }
  .brand-word { font-size: var(--text-18); }
  .yields { gap: 0; }
  .yield { padding: 4px 4px; grid-template-columns: 20px auto; column-gap: 4px; }
  .yield canvas { width: 20px; height: 20px; }
  .yield-v { font-size: var(--text-13); }
  .tools #togNight, .tools #togHistory, .tools #togLayers, .live-read { display: none; }
  /* Live lives in the More sheet on phones; while it is on, a labelled pill says so */
  .tools #togLive { display: none; }
  .app[data-liveui="on"] .tools #togLive { display: inline-flex; width: auto; padding: 0 10px; gap: 6px; }
  .app[data-liveui="on"] .tools #togLive > span:not(.live-dot) { display: inline; font-size: var(--text-13); }
  .menu-btn { display: inline-flex; }
  .search-btn, .tog { height: 44px; width: 44px; padding: 0; justify-content: center; border-color: transparent; }
  .search-btn .kbd { display: none; }
  .tog[aria-pressed="true"] { border-color: var(--ink); }
  .lensbar { top: calc(var(--gap) + 52px + 6px); left: 0; right: 0; max-width: none; padding: 0 var(--gap); }
  .chip { height: 44px; }
  .chip-all { display: none; }
  .legend { left: var(--gap); right: var(--gap); width: auto; bottom: calc(var(--gap) + env(safe-area-inset-bottom)); padding: 10px 12px; }
  .app[data-panel="on"] .legend { bottom: calc(var(--sheet-h, 44vh) + 8px); }
  .app[data-panel="on"] .timebar { display: none; }
  .lg-hist { height: 40px; }
  .lg-cats { grid-template-columns: 1fr 1fr; }
  .mapctl { right: var(--gap); bottom: calc(var(--gap) + env(safe-area-inset-bottom)); }
  .app[data-legend="on"] .mapctl { bottom: calc(var(--gap) + var(--legend-h, 120px) + 8px); }
  .minimap { display: none; }
  .credit { min-height: 44px; }
  .zoom { display: none; }
  .panel {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; height: var(--sheet-h, 44vh); max-height: calc(100% - 64px);
    border-radius: var(--r-4) var(--r-4) 0 0; padding-bottom: env(safe-area-inset-bottom);
    transition: transform var(--d-enter) var(--ease-out), height var(--d-enter) var(--ease-out);
  }
  .panel.is-entering { transform: translateY(40px); }
  .panel.is-dragging { transition: none; }
  .panel-grip { display: flex; justify-content: center; align-items: center; height: 24px; flex: none; touch-action: none; cursor: grab; }
  .panel-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--paper-3); }
  .panel-head { padding: 0 6px 8px 16px; touch-action: none; }
  .panel-title h2 { font-size: var(--text-20); }
  .panel-body { padding: 10px 16px 24px; }
  .timebar { left: var(--gap); right: var(--gap); bottom: var(--gap); transform: none; width: auto; min-width: 0; padding: 8px 10px 10px; }
  .app[data-history="on"] .legend { bottom: calc(var(--gap) + var(--timebar-h, 130px) + 8px); }
  .app[data-history="on"] .mapctl { bottom: calc(var(--gap) + var(--timebar-h, 130px) + 8px); }
  .tb-year { font-size: var(--text-24); }
  .tb-stats { gap: 4px 12px; font-size: var(--text-12); }
  .lens-pop, .layers-pop, .menu-sheet { left: var(--gap); right: var(--gap); width: auto; top: calc(var(--gap) + 52px + 8px); max-height: calc(100% - 80px); }
  .tooltip { display: none; }
  .toast { top: 128px; }
  .search { padding: 8px; }
  .live-notes { right: auto; left: var(--gap); top: calc(var(--gap) + 52px + 6px + 50px + 4px); align-items: flex-start; }
}
@media (pointer: coarse) {
  .chip { height: 44px; }
  .lens-opt { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation: none !important; }
}

/* unfiltered edition: a small strip at the foot of the screen (public build: never shown) */
.ed-banner { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 25; max-width: calc(100% - 32px);
  padding: 4px 12px; border-radius: 999px; background: var(--ink); color: var(--paper); font: 600 11px/1.35 var(--font-ui, system-ui);
  letter-spacing: .01em; opacity: .86; pointer-events: none; text-align: center; }
@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  .ed-banner { left: var(--gap); right: var(--gap); transform: none; max-width: none; border-radius: 12px; font-size: 10.5px;
    bottom: calc(var(--gap) + 60px + env(safe-area-inset-bottom)); }
  .app[data-panel="on"] .ed-banner, .app[data-history="on"] .ed-banner, .app[data-legend="on"] .ed-banner { display: none; }
}
