/* Table Mountain — viewer chrome.
   ONE-TIME COPY of babylonstoren/css/app.css (tourism-3d's own rule: borrow
   proven code by copy, never by sync) for the boot veil, brand and palette.
   Sitting 3 (2026-09-08) built the explorer panel (desktop) / bottom sheet
   (phone). Sitting 4 (2026-09-08) replaces THAT with a pop-up toolbox: a
   64px rail of coloured discs that each pop one card open beside the rail,
   closed by default so the mountain owns the screen -- see README § "Sitting
   4 -- the toolbox rail" for the measured gate results. */

:root {
  --ink: #1c2226;
  --paper: #f4f6f5;
  --muted: rgba(28, 34, 38, 0.55);
  --line: rgba(28, 34, 38, 0.14);
  --leaf: #2f5730;
  --glass: rgba(244, 246, 245, 0.94);
  /* DARK, not light: the card's type is white (see .tb-card). 26% of a deep
     blue-grey still shows the mountain through it -- a light tint at any
     opacity milks the view toward white, which is what it did before. */
  --card-glass: rgba(14, 21, 30, 0.26);
  --pad: 20px;               /* the one outer margin every fixed element owns */

  /* Sitting 4 -- the toolbox rail's five-hue family, equal chroma. Colour
     lives ONLY on a disc, a card's 4px top bar, its 15% header wash, a
     selected difficulty chip and a checked switch -- nowhere else. */
  --places: #c9953a; --places-wash: #c9953a26;
  --trails: #5fa86a; --trails-wash: #5fa86a26;
  --views:  #5b9bd8; --views-wash:  #5b9bd826;
  --layers: #a98bd3; --layers-wash: #a98bd326;
  --guide:  #e0836b; --guide-wash:  #e0836b26;
  --gps:    #2f7fd6;
  /* Emergency. Outside the five-hue family ON PURPOSE -- this one must
     never read as just another tool. */
  --sos:    #d7443c; --sos-wash: #d7443c26;

  --rail-w: 64px;
  --card-w: 344px;
  --card-top: 72px;
  /* The phone sheet's fixed `bottom` offset -- clear of #phone-bar (66px tall,
     18px inset) with a 12px gap, so the sheet's OWN box never geometrically
     overlaps the bar's, in ANY snap state (see the .tb-card phone rules: the
     sheet's height changes per snap, its `bottom` never does). #gps-fab sits
     higher than this, but it is hidden outright whenever a card is open (see
     `html[data-open] #gps-fab`), so it never has to be cleared here too. */
  --bar-clear: calc(max(18px, env(safe-area-inset-bottom)) + 66px + 12px);
  /* Clears the phone masthead (#brand) and its top-right #compass/#hint
     neighbours, whose bottom edges land around 56-58px down in the worst
     (no-notch) case -- 'full' height is measured against this, not the bare
     viewport, or a tall sheet paints straight over the masthead. */
  --top-clear: 70px;
  --peek-h: 128px;
  --half-h: 55vh;
  /* 90vh, not the ~92vh a bare reading of "full" suggests -- at the smallest
     phone height (360x780) 92vh left the compass only ~2px of clearance
     above the sheet's top edge, which measurement rounding could turn into
     an overlap (Sitting 3's own finding; still true of these same sheets). */
  --sheet-h: 90vh;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #a7bcc5;
  color: var(--ink);
  font: 400 15px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }
/* 🚨 touch-action: none — THE RIG OWNS ALL GESTURES.
   Without it the browser claims the two-finger pinch as PAGE zoom before
   camera-rig.js ever sees it. The page scales, #app's position:fixed framing
   tears off the viewport, and there is no way back out on a phone — reported
   as "pinch breaks the frame and then it's stuck". The rig already implements
   pinch, twist and drag; it simply never received the gesture.
   Copied from the golf sites, which have carried this line since day one. */
#app, #app canvas { touch-action: none; }
#app canvas { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------ boot veil */
/* The loading plate is a render of THIS model (data/boot.jpg -- the front
   face from over the city, tablecloth on), so the first thing a visitor sees
   while the mountain builds is the mountain itself rather than a blank card.
   ⚠️ The background COLOUR under it is dark on purpose: the type over it is
   white, and if the image is slow or 404s, white-on-paper would be invisible.
   Colour first, image over it -- the fallback is legible on its own. */
#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: #1b2430;
  background-image:
    linear-gradient(to bottom,
      rgba(12, 18, 26, 0.30) 0%,
      rgba(12, 18, 26, 0.42) 45%,
      rgba(12, 18, 26, 0.78) 100%),
    url('../data/boot.jpg');
  background-size: cover, cover;
  background-position: center, center;
  z-index: 40;
  transition: opacity 0.7s ease, visibility 0.7s;
}
body.ready #boot { opacity: 0; visibility: hidden; }

.boot-inner {
  text-align: center;
  max-width: 22rem;
  padding: 0 1.5rem;
  color: #fff;
  /* the plate has bright cloud in it -- a soft shadow keeps the type off it */
  text-shadow: 0 1px 14px rgba(8, 12, 18, 0.55);
}

.boot-title {
  font-size: clamp(1.05rem, 3.4vw, 1.5rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;      /* tracking adds a phantom space on the right */
  font-weight: 400;
  color: #fff;
}
.boot-sub {
  margin-top: 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: rgba(255, 255, 255, 0.76);
  text-transform: uppercase;
}
.boot-bar {
  margin: 2rem auto 0.9rem;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 34%;
  background: #fff;
  animation: sweep 1.5s ease-in-out infinite;
}
@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(394%); }
}
.boot-msg {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: rgba(255, 255, 255, 0.72);
  min-height: 1em;
}

/* ---------------------------------------------------------------- scrim */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: 7rem;
  z-index: 10;                 /* above the canvas, below all chrome (20+) */
  pointer-events: none;
  background: linear-gradient(to bottom,
    rgba(244, 246, 245, 0.5) 0%,
    rgba(244, 246, 245, 0.28) 45%,
    rgba(244, 246, 245, 0) 100%);
  opacity: 0;
  transition: opacity 0.9s ease 0.3s;
}
body.ready::before { opacity: 1; }

body::after {
  content: '';
  position: fixed;
  inset: auto 0 0 0;
  height: 5rem;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(to top,
    rgba(244, 246, 245, 0.42) 0%,
    rgba(244, 246, 245, 0.2) 45%,
    rgba(244, 246, 245, 0) 100%);
  opacity: 0;
  transition: opacity 0.9s ease 0.3s;
}
body.ready::after { opacity: 1; }

/* --------------------------------------------------------------- brand */
/* The phone masthead. On desktop (>=900px) this is retired -- #brand-pill
   (built by src/ui.js, below) carries the same mark/sub text instead; ui.js
   reads THIS node's textContent/markup once at construction and never
   duplicates it by hand, so the mountain-and-cloth mark drawn into
   `.brand-mark` here (index.html) is the one place its path data lives. */
/* left ONLY, deliberately no `right` -- a fixed-position element with both
   left AND right set spans the FULL viewport width regardless of its (much
   narrower) flex content, and getBoundingClientRect() measures that full
   box, not the visible content. The first cut set both, and mobile_qa.py's
   overlap audit correctly caught #brand's invisible right-hand two-thirds
   "overlapping" #hint and #compass despite nothing being painted there.
   Legibility over the photo comes from .brand-mark's own glass chip plus
   the existing body::before top scrim (z-index 10, beneath this at 20) --
   no separate background needed here now that content is shrink-to-fit. */
#brand {
  position: fixed;
  left: 16px;
  top: max(16px, env(safe-area-inset-top));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.9s ease 0.3s;
  pointer-events: none;
}
body.ready #brand { opacity: 1; }

.brand-mark {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(28, 34, 38, 0.10);
}
.brand-mark svg { width: 26px; height: 26px; display: block; }

.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#brand .mark {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5), 0 0 18px rgba(255, 255, 255, 0.7);
}
#brand .sub {
  margin-top: 0;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5), 0 0 18px rgba(255, 255, 255, 0.7);
}

@media (min-width: 900px) {
  #brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-bar i { animation: none; width: 100%; }
  #boot, #brand { transition: none; }
  #toolbox-rail, #toolbox-rail *, #phone-bar, #phone-bar *,
  #hint, #compass, #compass *, .tb-card { transition: none !important; }
}

/* =====================================================================
   Brand pill -- desktop only. Same mark/sub text as #brand (read by
   ui.js), just repositioned next to the rail instead of pinned top-left.
   ===================================================================== */
#brand-pill { display: none; }
@media (min-width: 900px) {
  #brand-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: calc(var(--pad) + var(--rail-w) + 16px);
    top: 22px;
    z-index: 25;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px 8px 10px;
    box-shadow: 0 3px 10px rgba(28, 34, 38, 0.10);
    opacity: 0;
    transition: opacity 0.9s ease 0.3s;
    pointer-events: none;
  }
  body.ready #brand-pill { opacity: 1; }
  .brand-pill-mark { display: flex; color: var(--ink); }
  .brand-pill-mark svg { width: 22px; height: 22px; display: block; }
  .brand-pill-text {
    font-size: 12.5px; letter-spacing: 0.32em; text-indent: 0.32em; color: var(--ink);
    white-space: nowrap;
  }
  .brand-pill-div { width: 1px; height: 12px; background: var(--line); }
  .brand-pill-sub {
    font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
    white-space: nowrap;
  }
}

/* =====================================================================
   The toolbox rail -- desktop (>=900px) only. #phone-bar (near the bottom
   of this file) replaces it on phone.
   ===================================================================== */
#toolbox-rail { display: none; }
@media (min-width: 900px) {
  #toolbox-rail {
    position: fixed;
    left: var(--pad);
    top: var(--pad);
    bottom: var(--pad);
    width: var(--rail-w);
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 10px;
    gap: 14px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(28, 34, 38, 0.14);
    opacity: 0;
    transition: opacity 0.7s ease 0.4s;
  }
  body.ready #toolbox-rail { opacity: 1; }
}

.rail-logo {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.rail-logo svg { width: 36px; height: 36px; display: block; }
.rail-hr { flex: 0 0 auto; width: 32px; height: 1px; background: var(--line); }
.rail-discs { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rail-spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------- discs */
.disc {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 3px 8px rgba(28, 34, 38, 0.18);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.disc-ico { display: flex; width: 22px; height: 22px; }
.disc-ico svg { width: 100%; height: 100%; display: block; }

@media (hover: hover) {
  .disc:hover { transform: translateY(-1px); }
}
.disc:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* One colour token per key, shared by the disc AND its matching card (the
   card reads the same custom property for its bar/wash/switch accents --
   see .tb-card below). GPS has no card; it gets --accent only, for its own
   outline/tracking states. */
[data-disc="places"], #card-places { --accent: var(--places); --accent-wash: var(--places-wash); }
[data-disc="trails"], #card-trails { --accent: var(--trails); --accent-wash: var(--trails-wash); }
[data-disc="views"],  #card-views  { --accent: var(--views);  --accent-wash: var(--views-wash); }
[data-disc="layers"], #card-layers { --accent: var(--layers); --accent-wash: var(--layers-wash); }
[data-disc="guide"],  #card-guide  { --accent: var(--guide);  --accent-wash: var(--guide-wash); }
#gps-disc, #gps-fab { --accent: var(--gps); }
[data-disc="sos"], #card-sos { --accent: var(--sos); --accent-wash: var(--sos-wash); }

.disc[data-disc] { background: var(--accent); }

/* Open state: a paper ring + the disc's own colour, and a 6% scale lift --
   never a coloured BORDER at rest (that lives only on the ring). */
.disc[data-disc][aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent);
  transform: scale(1.06);
}
@media (hover: hover) {
  .disc[data-disc][aria-pressed="true"]:hover { transform: scale(1.06) translateY(-1px); }
}

/* GPS -- outline = utility, per the brief: transparent fill, coloured ring
   and icon at rest; filled + white icon once actually tracking (mirrors the
   old #locate[data-on="1"] treatment). */
.disc-outline {
  width: 44px; height: 44px;
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
#gps-disc[aria-pressed="true"], #gps-fab[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --------------------------------------------------------------- #hint */
/* The one stable anchor credits.js mounts its "i" into (unedited -- see
   src/credits.js). Positioned by CSS alone: unlike Sitting 3's collapsible
   panel, nothing in THIS design ever hides or moves the rail/masthead, so
   there is no need to reparent this node at runtime the way Sitting 3 did --
   it stays exactly where index.html put it and just gets a fixed position
   here (foot of the rail on desktop, beside the compass on phone). */
#hint {
  position: fixed;
  z-index: 27;
  margin: 0; padding: 0;
  font-size: 0; line-height: 0;   /* the injected button is the only content */
  pointer-events: none;           /* the injected button re-enables itself */
}
#hint .hint-text { display: none; }   /* the toast reads from the canvas, not here */

/* The floating GPS fab and the guide teaser are a CLOSED-bar-only pairing
   (see the approved phone mockup: neither appears in its "sheet open"
   artboard) -- hidden outright whenever a card/sheet is open rather than
   repositioned, same rule as .toast-hint above. Harmless on desktop, where
   #gps-fab is already display:none. */
html[data-open] #gps-fab { display: none; }

@media (min-width: 900px) {
  #hint {
    left: var(--pad);
    width: var(--rail-w);
    bottom: 30px;
    display: flex;
    justify-content: center;
  }
}
@media (max-width: 899px) {
  #hint {
    right: calc(14px + 44px + 8px);
    top: max(14px, env(safe-area-inset-top));
    width: 44px; height: 44px;
    /* ⚠️ CENTRED, not left to the inline flow. #hint is font-size/line-height
       0 and #creditsbtn carries a -15px vertical margin (its padding is the
       44px thumb target, see credits.js), so in normal flow the button's box
       lands at top -1px -- one pixel of a licence-condition control outside
       the viewport, permanently. It still hit-tests, but it makes the button
       PARTIALLY OFF-SCREEN, which is the condition that makes an automated
       actionability check flaky (mobile_qa's own creditsbtn assertion failed
       intermittently on Everest for exactly this reason, 2026-09-09).
       Centring puts the whole 44px box inside the viewport. Desktop's own
       #hint rule above already flexes for the same reason. */
    display: flex; align-items: center; justify-content: center;
  }
  /* ...and its own 2px left margin has to go with it. That margin exists to
     space the "i" from #hint's text on DESKTOP; inside a 44px flex box it
     just shrinks the thumb target to 42px, which is under the floor and
     which mobile_qa correctly failed. Two IDs, so this beats credits.js's
     own injected rule regardless of which stylesheet the browser saw last. */
  #hint #creditsbtn { margin-left: 0; margin-right: 0; }
}

/* ------------------------------------------------------------- compass */
#compass {
  position: fixed;
  z-index: 22;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(28, 34, 38, 0.10);
  opacity: 0;
  transition: opacity 0.9s ease 0.6s;
}
body.ready #compass { opacity: 1; }
/* The needle rotates, not the button -- see ui.js's compassNeedle comment.
   Rotating the OUTER button measured bigger than its true box in Sitting 3's
   overlap audit: getBoundingClientRect() returns a rotated element's
   axis-aligned box, larger than the unrotated one even though a rotated
   CIRCLE reads identically on screen. */
.compass-needle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  transition: transform 0.2s linear;
}
.compass-needle svg { width: 20px; height: 20px; }
#compass:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (min-width: 900px) { #compass { right: var(--pad); top: var(--pad); } }
@media (max-width: 899px) { #compass { right: 14px; top: max(14px, env(safe-area-inset-top)); } }

/* ---------------------------------------------------------------- toast */
.toast-hint {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.9s ease 0.6s;
  pointer-events: none;
  white-space: nowrap;
}
body.ready .toast-hint { opacity: 1; }
.toast-hint.faded { opacity: 0; transition: opacity 0.6s ease; }
/* Hidden whenever a card/sheet is open -- pointless under an open card, and
   on phone the sheet would otherwise sit on top of it anyway (the exact
   overlap Sitting 3's own gate 3 caught once, on the old always-open sheet). */
html[data-open] .toast-hint { display: none; }

@media (min-width: 900px) {
  .toast-hint { bottom: 22px; }
  /* Centring on the WHOLE viewport collides with #guide-teaser at the first
     paint (both visible together only in the rail-rest, pre-interaction
     state -- the teaser survives until Guide is opened once, the toast
     until the first drag/wheel or 6s): teaser's rightmost extent is
     left(94px) + its own max-width(280px) = 374px, so recentre the toast on
     the free canvas to the right of that instead of the raw viewport --
     half of 374, rounded up. Same fix Sitting 3 used for its old panel vs
     this same toast, generalised: shift right by half of whatever occupies
     the left edge. */
  .toast-hint { left: calc(50% + 190px); }
}
@media (max-width: 899px) { .toast-hint { bottom: 154px; } }

/* ----------------------------------------------------------- guide teaser */
#guide-teaser {
  position: fixed;
  z-index: 21;
  display: flex; align-items: center; gap: 10px;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(28, 34, 38, 0.14);
  opacity: 0;
  transition: opacity 0.9s ease 0.8s;
  pointer-events: none;   /* decorative -- reached via its disc, not the bubble */
}
body.ready #guide-teaser { opacity: 1; }
#guide-teaser[hidden] { display: none; }
html[data-open] #guide-teaser { display: none; }
.teaser-ico {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--guide);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.teaser-ico svg { width: 14px; height: 14px; }

@media (min-width: 900px) {
  #guide-teaser { left: calc(var(--pad) + var(--rail-w) + 10px); bottom: 26px; }
}
@media (max-width: 899px) {
  #guide-teaser { right: 14px; bottom: 98px; border-radius: 14px 14px 4px 14px; }
  .teaser-ico { width: 24px; height: 24px; }
  .teaser-ico svg { width: 13px; height: 13px; }
}

/* -------------------------------------------------------------- gps note */
/* Status feedback for the GPS disc/fab (locating/away/error/tracking) --
   anchored on the opposite (right) side from the rail/cards on desktop and
   clear of the bar/teaser on phone, so it can never collide with an open
   card or the teaser regardless of viewport width. */
#gps-note {
  position: fixed;
  z-index: 24;
  max-width: 220px;
  margin: 0;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 16px rgba(28, 34, 38, 0.14);
  pointer-events: none;
}
#gps-note[hidden] { display: none; }

@media (min-width: 900px) { #gps-note { right: var(--pad); top: 74px; } }
@media (max-width: 899px) { #gps-note { right: 14px; top: 66px; } }

/* =====================================================================
   The cards -- one per disc (Places/Trails/Views/Layers/Guide). Same
   markup and class names at both widths; only position/size/orientation
   change (desktop: a side card beside the rail; phone: a bottom sheet) --
   the same "one chrome, two layouts" rule Sitting 3 set for its old
   #explorer. Closed by default (`hidden`); ui.js's open/close choreography
   clears `hidden`, flushes layout, then toggles `.is-open` so the CSS
   transition below actually has two distinct frames to animate between.
   ===================================================================== */
.tb-card {
  position: fixed;
  z-index: 25;
  display: flex;
  flex-direction: column;
  /* Luke, 2026-09-08: "completely white... I want to see through them so I
     can see what I'm still looking at" -- a near-opaque fill (--glass is
     94%) reads as solid over the mountain. --card-glass drops that to ~8%
     and leans on a light blur to keep the list text readable, rather than
     var(--glass) itself, since the rail/brand pills that also use --glass
     were not part of the complaint and stay as they were. */
  /* 🚨 THE CARD RUNS ITS OWN PALETTE, and it is the INVERSE of the page's.
     Luke, 2026-09-09: "that writing should be in white most of the time
     because the mountains are dark... a little bit more see-through, and then
     just make the lettering white."
     A light fill is what forced dark type, and a light fill over a dark
     mountain is exactly what he was seeing wash out. So the three tokens the
     whole card interior is built on (--ink / --muted / --line) are redefined
     HERE, on the card itself, and every child rule that already reads them
     flips for free rather than being chased down one by one. --paper flips
     with them so `.row[aria-pressed]`, which paints ink-on-paper, comes out
     as a white chip with dark type -- still the strongest thing in the list. */
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.68);
  --line: rgba(255, 255, 255, 0.20);
  --paper: #16202b;
  background: var(--card-glass);
  /* Less blur than before (10px) as part of "more see-through" -- blur is
     what was eating the view behind, more than the fill was. */
  backdrop-filter: blur(7px) saturate(125%);
  -webkit-backdrop-filter: blur(7px) saturate(125%);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  color: var(--ink);
  /* the drape behind runs from bright cloud to near-black gorge -- a soft
     shadow is what keeps white type readable across both */
  text-shadow: 0 1px 10px rgba(6, 10, 16, 0.55);
  /* Motion is transform + opacity ONLY -- never width/height/padding/margin.
     This page runs two concurrent raymarched cloud volumes against a frame
     budget the quality ladder exists to protect; a layout-thrashing popup
     transition is a genuine stutter risk here, not a lint nitpick (the exact
     mistake Sitting 3 made and had to strip out of the old #explorer's own
     collapse transition -- see the file header). */
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease;
}
.tb-card[hidden] { display: none; }

.card-notch {
  position: absolute;
  left: -7px; top: 50%;
  width: 12px; height: 12px;
  /* Matches .tb-card's fill -- a solid --paper notch on a see-through card
     would read as a floating white diamond. */
  background: var(--card-glass);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
.card-bar { height: 4px; flex: 0 0 auto; background: var(--accent); }
.card-handle {
  display: none;
  flex: 0 0 auto;
  width: 100%;
  min-height: 22px;
  align-items: center; justify-content: center;
  border: 0; background: none; padding: 6px 0 0;
  cursor: grab;
  touch-action: none;
}
.card-handle .grip { display: block; width: 34px; height: 4px; border-radius: 999px; background: var(--line); }

.card-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 16px;
  background: var(--accent-wash);
  border-bottom: 1px solid var(--line);
}
.card-head-ico {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.card-head-ico svg { width: 16px; height: 16px; display: block; }
.card-title {
  flex: 1 1 auto;
  font-size: 12px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--ink);
}
.card-close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: 0; background: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
}
.card-close svg { width: 16px; height: 16px; }
.card-close:hover { color: var(--ink); }

.card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.4rem 0 0.6rem;
  display: flex;
  flex-direction: column;
}

.tb-card button:focus-visible, .tb-card input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

@media (min-width: 900px) {
  .tb-card {
    left: calc(var(--pad) + var(--rail-w) + 16px);
    top: var(--card-top);
    width: var(--card-w);
    max-height: calc(100vh - var(--card-top) - var(--pad));
    box-shadow: 0 14px 36px rgba(28, 34, 38, 0.18);
    opacity: 0;
    transform: translateX(-8px);
  }
  .tb-card.is-open { opacity: 1; transform: translateX(0); }
  .card-notch { display: block; }
  #card-guide { height: 470px; }
}

@media (max-width: 899px) {
  .tb-card {
    left: 0; right: 0;
    /* Fixed, and the actual fix (see the long comment below) -- never 0.
       #gps-fab sits higher than this, but it is hidden outright whenever a
       card is open (`html[data-open] #gps-fab`), so only #phone-bar's own
       66px + 18px inset + a 12px gap need clearing here. */
    bottom: var(--bar-clear);
    height: var(--peek-h);      /* fallback; a snap rule below wins once open */
    border-radius: 20px 20px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    box-shadow: 0 -10px 30px rgba(28, 34, 38, 0.16);
    opacity: 0;
    /* Only the OPEN/CLOSE motion is transform+opacity (a small vertical
       nudge) -- the snap-to-height below is deliberately NOT in this list. */
    transform: translateY(16px);
    touch-action: pan-y;
  }
  .tb-card.is-open { opacity: 1; transform: translateY(0); }

  /* Peek/half/full change HEIGHT, with `bottom` held fixed at --bar-clear in
     every one of them -- NOT a width/height transition (the file header's
     rule against those is about never putting them in a smooth
     `transition:`; these are discrete, untransitioned values, same
     category as any other static CSS length). This replaces a first cut
     that reused Sitting 3's old #explorer mechanics verbatim -- bottom:0,
     height:90vh, translateY(sheetHeight - snapHeight) -- which worked
     there because NOTHING else lived at the very bottom of the screen. Here
     #phone-bar does, permanently, and translateY moves the sheet's WHOLE
     box (both edges) uniformly: at 'peek' the box's bottom edge still sat
     at the viewport's bottom edge, so its rect geometrically overlapped
     #phone-bar's rect (and covered #card-close under it, making it
     untappable) in every snap state, not just full. Anchoring `bottom` at
     --bar-clear and letting height vary keeps the sheet's bottom edge
     permanently above the bar instead. ui.js's drag handler sets `height`
     directly during a drag (1:1 finger tracking, transition:none while
     dragging, exactly as this repo's other drag handles already do) and
     snaps to one of these three rules on release. */
  html[data-sheet="peek"] .tb-card.is-open { height: var(--peek-h); }
  html[data-sheet="half"] .tb-card.is-open { height: var(--half-h); }
  html[data-sheet="full"]  .tb-card.is-open { height: calc(100vh - var(--bar-clear) - var(--top-clear)); }

  .card-notch { display: none; }
  .card-handle { display: flex; }
  .card-body { touch-action: pan-y; padding-bottom: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-card { transition: none !important; }
}

/* ------------------------------------------------------------- search */
.search-wrap {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  margin: 12px 12px 4px;
  padding: 0 12px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.10);
}
.search-ico { flex: 0 0 auto; width: 16px; height: 16px; color: var(--muted); display: flex; }
.search-ico svg { width: 100%; height: 100%; }
#explorer-search {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; background: none; padding: 0;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
#explorer-search::placeholder { color: var(--muted); }
#explorer-search::-webkit-search-cancel-button { cursor: pointer; }

.places-list { flex: 1 1 auto; min-height: 0; }

.group-head {
  margin: 12px 16px 4px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-head:first-child { margin-top: 8px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: calc(100% - 16px);
  margin: 0 8px;
  height: 40px;
  padding: 0 16px;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.row:hover { background: rgba(255, 255, 255, 0.12); }
.row[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.row-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;   /* elevation/km/climb figures align */
}
.row[aria-pressed="true"] .row-meta { color: rgba(22, 32, 43, 0.66); }
.row-caption {
  display: block;
  flex-basis: 100%;
  margin-top: 0.15rem;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  white-space: normal;
}
.view-row, .view-fly { height: auto; min-height: 40px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.view-fly { font-weight: 500; }
.view-fly .ico, .view-fly .ico svg { width: 16px; height: 16px; }

.trail-meta { display: flex; align-items: center; gap: 8px; }
.diff-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  border: 1px solid var(--muted);
}
/* Difficulty chips keep their OWN colour regardless of the row's selected
   (ink-on-paper) state -- see renderSwitch's comment in ui.js for the same
   rule applied to switches. Gentle reuses the Trails disc's own green,
   tying the two together on purpose. */
.diff-gentle   { color: var(--trails); border-color: var(--trails); }
.diff-moderate { color: #b07a2a; border-color: #b07a2a; }
.diff-steep    { color: #c0503c; border-color: #c0503c; }

.empty-note, .shortcuts-note {
  margin: 12px 16px;
  font-size: 12px;
  color: var(--muted);
}
.shortcuts-note {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  letter-spacing: 0.02em;
}

.card-divider { flex: 0 0 auto; height: 1px; background: var(--line); margin: 0 16px 6px; }
.card-foot-note {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.foot-note-bar { flex: 0 0 auto; width: 22px; height: 4px; border-radius: 2px; background: var(--accent); }

.row-wrap { display: flex; flex-direction: column; }
.detail {
  position: relative;
  margin: 0.1rem 8px 0.6rem;
  padding: 0.8rem 2.2rem 0.9rem 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.detail-close {
  position: absolute;
  top: 0.4rem; right: 0.4rem;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted); cursor: pointer;
}
.detail-close svg { width: 12px; height: 12px; }
.detail-kind {
  margin: 0 0 0.4rem;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.detail-blurb { margin: 0; font-size: 13.5px; line-height: 1.6; }
.detail-dist {
  margin: 0.7rem 0 0;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--leaf);
}
.detail-dist[hidden] { display: none; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 44px;
  margin: 0 8px;
  padding: 0 16px;
  cursor: pointer;
  flex: 0 0 auto;
}
.switch-label { font-size: 13.5px; color: var(--ink); }
.switch-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 38px; height: 22px;
  margin: 0;
  cursor: pointer;
}
.switch-track {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
  transition: background 0.15s ease;
  flex: 0 0 auto;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
/* The on-colour is whichever card this switch lives inside (--accent) --
   see renderSwitch's own comment in ui.js. */
.switch-row input:checked + .switch-track { background: var(--accent); }
.switch-row input:checked + .switch-track::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch-track { outline: 2px solid var(--ink); outline-offset: 2px; }

/* select-row -- the same 44px row rhythm as switch-row, for a Layers control
   with more than two states (the Season picker). Native <select>: free
   keyboard operation and free mobile picker UI, no custom widget to build. */
.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 44px;
  margin: 0 8px;
  padding: 0 16px;
  flex: 0 0 auto;
}
.select-row select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
.select-row select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* -------------------------------------------------------------- guide */
.guide-body { padding: 0; }
.guide-messages {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
}
.guide-bubble {
  align-self: flex-start;
  max-width: 86%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
}
.guide-bubble p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.guide-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--guide);
  background: var(--guide-wash);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}
@media (hover: hover) {
  .chip:hover { background: var(--guide); color: #fff; }
}

.guide-input-row {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  margin: 12px;
  padding: 0 6px 0 14px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
}
.guide-input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: 0; background: none; padding: 0;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
.guide-input::placeholder { color: var(--muted); }
.guide-send {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--guide);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.guide-send svg { width: 16px; height: 16px; }

@media (max-width: 899px) {
  .guide-input-row { height: 48px; margin: 12px 14px 14px; }
  .guide-send { width: 36px; height: 36px; }
}

/* =====================================================================
   Phone (<900px) -- a bottom thumb bar replaces the rail; each disc opens
   the SAME .tb-card, styled as a bottom sheet above (see the .tb-card
   phone media query). #app/#app canvas keep touch-action: none untouched;
   the sheet itself keeps its own pan-y gesture (see .card-body above).
   ===================================================================== */
#phone-bar { display: none; }
#gps-fab { display: none; }

@media (max-width: 899px) {
  #phone-bar {
    position: fixed;
    left: 14px; right: 14px;
    bottom: max(18px, env(safe-area-inset-bottom));
    height: 66px;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    padding: 0 8px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 10px 26px rgba(28, 34, 38, 0.18);
    opacity: 0;
    transition: opacity 0.7s ease 0.4s;
  }
  body.ready #phone-bar { opacity: 1; }
  #phone-bar .disc { width: 46px; height: 46px; }
  .pbar-hr { flex: 0 0 auto; width: 1px; height: 28px; background: var(--line); }

  #gps-fab {
    display: flex;
    position: fixed;
    left: 14px;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 66px + 14px);
    width: 46px; height: 46px;
    z-index: 25;
    box-shadow: 0 6px 16px rgba(28, 34, 38, 0.14);
    opacity: 0;
    transition: opacity 0.7s ease 0.5s;
  }
  body.ready #gps-fab { opacity: 1; }
}

/* =====================================================================
   44px minimum touch targets, in PX -- deliberately last in the file.
   Root font here is 15px, so 2.75rem is 41px and quietly misses the floor
   (the trap this repo already paid for once, README § Session 2, phone).
   Placed after EVERY other rule on purpose: .view-row/.view-fly's own
   `min-height: 40px` (in the search/rows section above) has the same
   specificity as a same-breakpoint override placed earlier would, and the
   first cut of this block sat inside the .tb-card media query above that
   rule -- same specificity, earlier source order, so the 40px value silently
   won the cascade and 'Fly the mountain' measured under the floor in gate 2.
   Source order is the tiebreaker at equal specificity; last wins here.
   ===================================================================== */
@media (max-width: 899px) {
  .row, .switch-row, .card-close, .card-handle, .chip, .guide-send,
  .disc, #compass {
    min-height: 44px;
  }
  .disc, #compass, .card-close, .guide-send { min-width: 44px; }
}


/* ----------------------------------------------------------------- SOS */
/* The emergency card. Deliberately the plainest thing in the app: big tap
   targets, no motion, nothing clever between a thumb and a phone call. */
.sos-lede {
  margin: 12px 16px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.sos-call {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  text-decoration: none;
}
.sos-call:hover { background: rgba(255, 255, 255, 0.14); }
/* The one number to try first, so a person who reads nothing else still
   presses the right thing. */
.sos-call.sos-primary {
  background: var(--sos);
  border-color: var(--sos);
  color: #fff;
  text-shadow: none;
}
.sos-call.sos-primary:hover { background: #c23a33; }
.sos-call-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sos-call-name { font-size: 14px; font-weight: 500; }
.sos-call-note { font-size: 11.5px; color: var(--muted); }
.sos-call.sos-primary .sos-call-note { color: rgba(255, 255, 255, 0.85); }
.sos-call-num {
  flex: 0 0 auto;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.sos-pos { padding: 0 16px 4px; }
.sos-coords {
  margin: 2px 0 4px;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  /* a rescue operator is being read this aloud off a phone at arm's length */
  user-select: all;
}
.sos-pos-meta { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.sos-pos-off { margin: 2px 0 8px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.sos-locate { width: 100%; margin: 0; }

/* The phone FAB. Mirrors #gps-fab's own geometry exactly but sits on the
   OPPOSITE edge -- the two are the pair a person in trouble reaches for, and
   stacking them on the same corner is how you get a mis-tap. Hidden with a
   card open, same rule as #gps-fab. */
#sos-fab { display: none; }
@media (max-width: 899px) {
  #sos-fab {
    display: flex;
    position: fixed;
    right: 14px;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 66px + 14px);
    width: 46px; height: 46px;
    z-index: 25;
    box-shadow: 0 6px 16px rgba(28, 34, 38, 0.14);
    opacity: 0;
    transition: opacity 0.7s ease 0.5s;
  }
  body.ready #sos-fab { opacity: 1; }
}
html[data-open] #sos-fab { display: none; }

/* The disarmed (testing) state of the emergency card. Loud enough that nobody
   demoing this mistakes it for a working line -- see COURSE.sos in course.js. */
.sos-testing {
  margin: 12px 8px 10px;
  padding: 10px 12px;
  border: 1px dashed var(--sos);
  border-radius: 10px;
  background: var(--sos-wash);
  font-size: 12.5px;
  line-height: 1.45;
}
.sos-testing strong { color: #ffb3ad; }
/* Inert numbers: visibly present, deliberately un-pressable. */
.sos-call.sos-inert { cursor: default; opacity: 0.72; }
.sos-call.sos-inert:hover { background: rgba(255, 255, 255, 0.08); }
.sos-call.sos-primary.sos-inert { background: rgba(215, 68, 60, 0.55); border-color: rgba(215, 68, 60, 0.6); }
.sos-call.sos-primary.sos-inert:hover { background: rgba(215, 68, 60, 0.55); }


/* ---- routes: the picked route's detail (everest) ------------------------ */
.trail-detail .stage-list { list-style: none; margin: 8px 0 4px; padding: 0; }
.trail-detail .stage-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0 5px 14px; position: relative; font-size: 13px;
}
.trail-detail .stage-list li::before {
  content: ""; position: absolute; left: 2px; top: 11px; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; opacity: 0.55;
}
.trail-detail .stage-list li + li::after {
  content: ""; position: absolute; left: 4.5px; top: -9px; width: 1px; height: 14px;
  background: currentColor; opacity: 0.3;
}
.trail-detail .stage-ele { font-variant-numeric: tabular-nums; opacity: 0.75; white-space: nowrap; }
.trail-detail .climb-go { margin-top: 8px; font-weight: 600; justify-content: flex-start; gap: 8px; }
.trail-detail .climb-go .ico { width: 16px; height: 16px; margin-right: 6px; display: inline-flex; }
