:root {
  color-scheme: light;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --ink: #17191C;
  --muted: #5A6068;
  --line: #D9DCE1;
  --accent: #2457C5;        /* focus ring, slider, filled button */
  --on-accent: #FFFFFF;
  --label-bg: rgba(243, 244, 246, 0.9);
  --select: #C9D7F4;
  --shadow: 0 8px 24px rgba(23, 25, 28, 0.12);
  --glass: rgba(243, 244, 246, 0.42);
  --chip: rgba(255, 255, 255, 0.45);     /* glass controls on the glass bars */
  --chip-line: rgba(23, 25, 28, 0.10);
  --chip-on: rgba(23, 25, 28, 0.10);
  --track: rgba(23, 25, 28, 0.06);
  --thumb: #FFFFFF;
  --thumb-ink: #17191C;
  --thumb-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);   /* the slider's pill thumb */
  --glass-line: rgba(23, 25, 28, 0.08);
  --radius: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --t12: 12px; --t14: 14px; --t16: 16px; --t20: 20px; --t28: 28px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Dark: same components, flipped roles. Follows the system unless the switcher pinned a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1014; --surface: #1A1D23; --ink: #E8EAED; --muted: #A3A9B1; --line: #2E333B;
    --accent: #8AAEF7; --on-accent: #0E1014; --label-bg: rgba(14, 16, 20, 0.85); --select: #2D4A8A; --shadow: 0 8px 24px rgba(0, 0, 0, 0.5); --glass: rgba(14, 16, 20, 0.40); --chip: rgba(255, 255, 255, 0.07); --chip-line: rgba(255, 255, 255, 0.12); --chip-on: rgba(255, 255, 255, 0.18); --glass-line: rgba(255, 255, 255, 0.08); --track: rgba(255, 255, 255, 0.08); --thumb: #E8EAED; --thumb-ink: #0E1014;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1014; --surface: #1A1D23; --ink: #E8EAED; --muted: #A3A9B1; --line: #2E333B;
  --accent: #8AAEF7; --on-accent: #0E1014; --label-bg: rgba(14, 16, 20, 0.85); --select: #2D4A8A; --shadow: 0 8px 24px rgba(0, 0, 0, 0.5); --glass: rgba(14, 16, 20, 0.40); --chip: rgba(255, 255, 255, 0.07); --chip-line: rgba(255, 255, 255, 0.12); --chip-on: rgba(255, 255, 255, 0.18); --glass-line: rgba(255, 255, 255, 0.08); --track: rgba(255, 255, 255, 0.08); --thumb: #E8EAED; --thumb-ink: #0E1014;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: var(--t16);
  line-height: 1.5;
  overflow: hidden;
  accent-color: var(--accent);
}
::selection { background: var(--select); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar and dock are frosted glass over the live scene, so objects stay visible as they pass behind */
/* unslop-waive EFF-4 · the scene behind is real content that keeps moving under both bars · requested: "make it glass with blurred background" */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 3;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--glass); border-bottom: 1px solid var(--glass-line);
  /* unslop-waive EFF-4 · the top bar floats over the live scene, objects pass behind it · requested glass top bar */
  -webkit-backdrop-filter: blur(8px) saturate(1.3); backdrop-filter: blur(8px) saturate(1.3);
}
.bar > * { pointer-events: auto; }
.wordmark { margin: 0; font-size: var(--t20); font-weight: 600; line-height: 40px; white-space: nowrap; }
.search { position: relative; display: flex; flex: 1 1 auto; min-width: 0; max-width: 420px; margin-right: auto; }
.theme-toggle { flex: none; }
.search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 var(--s3);
  font: inherit; font-size: var(--t14); color: var(--ink);
  background: var(--chip); border: 1px solid var(--chip-line); border-radius: var(--radius);
}
button {
  height: 40px; padding: 0 var(--s4);
  font: inherit; font-size: var(--t14); font-weight: 600;
  color: var(--on-accent); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius); cursor: pointer;
}
button.ghost { color: var(--ink); background: var(--chip); border-color: var(--chip-line); }
.search-msg { position: absolute; left: 0; top: 100%; margin: 4px 0 0; font-size: var(--t12); color: var(--muted); }   /* floats under the field, never pushes the bar taller */

.stage { position: fixed; inset: 0; overflow: hidden; background: var(--bg); touch-action: none; cursor: ns-resize; }
.obj {
  position: absolute; left: 0; top: 0;
  display: block; padding: 0; height: auto;
  background: transparent; border: 0; border-radius: var(--radius);
  color: var(--ink); cursor: pointer;
  transform-origin: 0 0;
}
.obj[hidden] { display: none; }
.obj img { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.obj .ph {
  display: none; width: 100%; aspect-ratio: 1; border: 1px dashed var(--line); border-radius: 50%;
}
.obj.missing img { display: none; }
/* unslop-waive MOT-6 · hides an object whose image failed to load, set by its error handler, not a load-time reveal · drawing nothing beats a broken-image box */
.obj.missing { visibility: hidden; }
/* unslop-waive RSP-2 · objects are drawn at true scale and shrink to a dot as you zoom out, so some are always under 24px; this margin gives each a 24px+ hit area, measured: taps 6px outside isolated small objects land on them · scale is the content */
.obj::before { content: ""; position: absolute; inset: -12px; }   /* invisible 12px hit margin: small objects stay easy to tap */
.obj:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }  /* keyboard only; mouse hover just shows the name */
.labels { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0;
  padding: 2px var(--s2); border-radius: var(--radius);
  background: var(--label-bg);
  white-space: nowrap; text-align: center;
  font-size: var(--t14); line-height: 1.3; font-weight: 600;
}
.lbl span { display: block; font-size: var(--t12); font-weight: 400; color: var(--muted); }
/* unslop-waive MOT-6 · label of an off-screen or tiny object, toggled by zoom state not a load-time reveal · tiny objects would bury each other in names; tap opens the tip with the same name */
.lbl.off { visibility: hidden; }

/* Small info tip pinned beside the clicked object; follows it while zooming, closes on any click elsewhere. */
.tip {
  position: fixed; z-index: 4; left: 0; top: 0;
  width: min(260px, calc(100% - 2 * var(--s4)));
  padding: var(--s3); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tip h2 { margin: 0; font-size: var(--t16); line-height: 1.3; }
.tip-size { margin: 0 0 var(--s2); font-size: var(--t12); color: var(--muted); }
.tip-fact { margin: 0; font-size: var(--t14); line-height: 1.45; }

.dock {
  position: fixed; inset: auto 0 0 0; z-index: 3;
  display: grid; grid-template-columns: 12.5rem 1fr; gap: var(--s2) var(--s4); align-items: center;
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--glass); border-top: 1px solid var(--glass-line);
  /* unslop-waive EFF-4 · the dock floats over the live scene, which scrolls and zooms beneath it · requested: "make it glass with blurred background" */
  -webkit-backdrop-filter: blur(8px) saturate(1.3); backdrop-filter: blur(8px) saturate(1.3);
}
.readout { min-width: 0; }  /* fixed-width column: the changing number must never push the slider around */
.readout p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-main { font-size: var(--t16); line-height: 1.3; font-variant-numeric: tabular-nums; }
.readout-sci { font-size: var(--t12); color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { grid-column: 1 / -1; margin: 0; font-size: var(--t12); color: var(--muted); }

@media (max-width: 600px) {
  .bar { gap: 4px; padding: var(--s2) var(--s3); }   /* one line on a phone: smaller icon buttons, the field takes the rest */
  .icon-btn { width: 32px; height: 36px; }
  .search input { height: 36px; padding: 0 var(--s2); }
  /* the suggestions arrow kept its width even when hidden and clipped "Find"; suggestions still show as you type */
  .search input::-webkit-calendar-picker-indicator { display: none !important; width: 0 !important; margin: 0 !important; padding: 0 !important; }
  .seg { gap: 0; }
  .wordmark { line-height: 1.3; }
  .search { margin-left: 0; }
  .dock { grid-template-columns: 1fr; }}

}

/* Shown only in the empty stretch at either end of the loop */
.edge-note {
  position: fixed; z-index: 2; left: 50%; top: 45%; transform: translate(-50%, -50%);
  width: min(36ch, calc(100% - 2 * var(--s4))); margin: 0;
  text-align: center; font-size: var(--t16); color: var(--muted); pointer-events: none;
}


/* Line view: every object stands on one ground line; names sit just under it */
.axis { position: fixed; z-index: 1; left: 0; right: 0; top: 0; height: 1px; background: var(--muted); opacity: 0.45; pointer-events: none; }
.axis[hidden] { display: none; }

/* Layout switch: three joined buttons, the active one marked */
.seg { display: flex; flex: none; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.seg button[aria-pressed="true"] { background: var(--chip-on); }

/* Grid view: masonry wall of tiles, laid out by app.js (positions, widths, crops) */
.grid { position: fixed; left: 0; right: 0; top: 72px; bottom: 120px; overflow-y: auto; overflow-x: hidden; }
.grid[hidden], .stage[hidden], .labels[hidden] { display: none; }
.grid-end { position: absolute; left: 0; width: 1px; height: 32px; }   /* gives the scroll area its full height */
.tile {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; padding: 10px;
  background: transparent; border: 0; border-radius: var(--radius);
  color: var(--ink); text-align: center; cursor: pointer;
}
.tile:focus-visible { outline: 2px solid var(--accent); }
.crop { position: relative; display: block; overflow: hidden; flex: none; margin: auto auto 0; }   /* centred, standing on the label */
.crop img { position: absolute; display: block; height: auto; max-width: none; }
.tile-name { width: 100%; margin-top: 6px; font-size: var(--t14); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-size { font-size: var(--t12); color: var(--muted); line-height: 1.3; }

/* Icon-only buttons: square, icon centred; the name lives in aria-label and the hover title */
.icon-btn { flex: none; width: 40px; padding: 0; display: grid; place-items: center; }
.icon-btn svg { display: block; }

/* Scale bar: the slider with landmark sizes under it; a landmark jumps there */
.scale { position: relative; }
/* The capsule itself is drawn behind everything; landmark names sit inside it, and the slider on top has
   a clear track, so its white pill thumb slides over the names. */
.scale::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 36px; border-radius: 18px;
  background: var(--track); box-shadow: inset 0 0 0 1px var(--glass-line);
}
.scale #zoom { display: block; width: 100%; }
/* Capsule slider: a glass track with a white pill thumb; the pill shows the power of ten (.thumb-label,
   placed over the thumb by app.js). Thumb and label share THUMB_W so they stay locked together. */
#zoom {
  -webkit-appearance: none; appearance: none;
  height: 36px; margin: 0; background: transparent; cursor: grab;
}
#zoom:active { cursor: grabbing; }
#zoom { position: relative; z-index: 2; }
#zoom::-webkit-slider-runnable-track { height: 36px; border-radius: 18px; background: transparent; }
#zoom::-moz-range-track { height: 36px; border-radius: 18px; background: transparent; }
#zoom::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 84px; height: 30px; margin-top: 3px; border: 0; border-radius: 15px;
  background: var(--thumb); box-shadow: var(--thumb-shadow);
}
#zoom::-moz-range-thumb {
  width: 84px; height: 30px; border: 0; border-radius: 15px;
  background: var(--thumb); box-shadow: var(--thumb-shadow);
}
#zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 18px; }
#zoom:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }
#zoom:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--accent); }
.thumb-label {
  position: absolute; z-index: 3; top: 18px; transform: translate(-50%, -50%); pointer-events: none;
  font-size: var(--t14); font-weight: 600; line-height: 1; color: var(--thumb-ink); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.thumb-label sup { font-size: 10px; font-weight: 600; vertical-align: 5px; }
.thumb-label small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 36px; z-index: 1; pointer-events: none; }
.tick {
  position: absolute; top: 0; transform: translateX(-50%);
  line-height: 36px; color: var(--muted); font-size: var(--t12); white-space: nowrap;
}

/* Scatter and grid views drift gently while you rest on a level; line view stays still */
/* unslop-waive MOT-1 · requested float, paused while zooming, transform-only, off for reduced motion · Nick asked for it back in scatter */
@media (prefers-reduced-motion: no-preference) {
  .stage.floaty .obj img { animation: drift var(--dur, 7s) ease-in-out var(--delay, 0s) infinite alternate; }
  .stage.floaty.zooming .obj img { animation-play-state: paused; }
}
@keyframes drift {
  from { transform: translate(-0.6%, 1%) rotate(-0.8deg); }
  to   { transform: translate(0.6%, -1.5%) rotate(0.8deg); }
}
@media (max-width: 600px) {
}
.tick.off { visibility: hidden; }   /* dropped by fitTicks when it would collide with a neighbour */
#float-toggle[aria-pressed="true"],
#music-toggle[aria-pressed="true"] { background: var(--chip-on); }   /* shaded while floating or music is on, like the selected view */
@media (max-width: 600px) {
  .icon-btn { width: 32px; height: 36px; }   /* after the base .icon-btn rule so it wins on a phone */
}

/* Button tooltips: a small glass label under the button, after a short hover */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); z-index: 10;
  transform: translate(-50%, -2px); padding: 5px 9px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--chip-line); box-shadow: var(--shadow);   /* solid so it stays readable over busy images */
  color: var(--ink); font-size: var(--t12); font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 0.35s; }
.bar > [data-tip]:last-child::after { left: auto; right: 0; transform: translateY(-2px); }   /* the far-right one opens inward */
.bar > [data-tip]:last-child:hover::after { transform: none; }
@media (prefers-reduced-motion: reduce) { [data-tip]::after { transition: none; } }
