/* ════════════════════════════════════════════════════════════════════
   style_v2.css — CityFox UI  (design migration, part 2)
   Tokens: inferred from Figma lzGDJKeEclZr9k9FbHfssT screenshots.
   Full token extraction blocked by Figma Starter rate limit —
   re-run get_variable_defs once plan upgraded.
   Undesigned zones: see DESIGN.md § Undesigned Components
   ════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  /* Top safe-area inset, as a single source every top-anchored element reads.
     On iOS / web the WebView draws behind the status bar, so this is the real
     env() inset. On Android the native shell already pads the WebView below the
     status bar (MainActivity.kt) yet leaves the inset UNconsumed, so env() still
     reports it — adding it again here would double the top padding (Trello #258).
     `body.is-android` zeroes it so the native pad is the only top offset. */
  --safe-top: env(safe-area-inset-top, 0px);
  /* Bottom safe-area inset, single source every bottom-anchored control reads.
     On iOS / web this is the real env() inset. Android WebView does NOT report
     the nav / gesture bar in env(safe-area-inset-bottom) (only display cutouts),
     so the native shell measures it and injects --android-nav-bottom; the
     `body.is-android` rule below maps --safe-bottom onto that value (Trello
     #258). The map still draws edge-to-edge behind the bar; only controls that
     read --safe-bottom lift clear of it. */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Shell — from Figma (light) */
  --c-bg:              #ffffff;
  --c-surface:         #ffffff;
  --c-header-bg:       #ffffff;
  --c-header-border:   #e5e7eb;
  --c-text-primary:    #111827;
  --c-text-secondary:  #6b7280;
  --c-text-placeholder:#9ca3af;
  --c-accent:          #f97316;        /* CityFox brand orange — single source of truth */
  --c-accent-hover:    #ea6c0a;
  --c-waypoint-b:      #a855f7;        /* B-pin / round-route purple */
  --c-input-bg:        #ffffff;
  --c-input-border:    #d1d5db;
  --c-input-focus:     #f97316;
  --c-divider:         #e5e7eb;
  --c-danger:          #ef4444;

  /* Layout — from Figma */
  --sidebar-width:     352px;
  --header-height:     68px;

  /* Undesigned zones — dark fallback from v1, pending Figma screens */
  --c-bg-dark:         #0f0f1a;
  --c-surface-dark:    #1a1a2e;
  --c-border-dark:     #2a2a4a;
  --c-text-dark:       #e0e0e0;
  --c-muted-dark:      #888;
  --c-blue:            #6ab0f5;
  --c-red:             #e94560;
  --c-field-bg:        #12122a;
  --c-field-border:    #333;

  /* Quiz parchment — implicit design, kept from v1 */
  --c-parchment:       #f5f0e8;
  --c-parchment-text:  #1a1208;
  --c-parchment-brown: #7a5c2e;
  --c-parchment-gold:  #c9a96e;
  --c-parchment-green: #4a7c3f;

  /* ── Typography tokens (see .claude/skills/frontend-typography/SKILL.md) ──
     Lexend 700 for headings, Work Sans 400/600 for body. The .t-* classes
     defined below are the only place font-size / font-weight / line-height
     should be set across the codebase. */
  --t-font-heading: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --t-font-body:    "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --t-h1-size: 64px;   --t-h1-lh: 72px;   --t-h1-ps: 64px;   --t-h1-ls: -0.03em;
  --t-h2-size: 48px;   --t-h2-lh: 56px;   --t-h2-ps: 48px;   --t-h2-ls: -0.02em;
  --t-h3-size: 36px;   --t-h3-lh: 44px;   --t-h3-ps: 32px;   --t-h3-ls: -0.01em;
  --t-h4-size: 32px;   --t-h4-lh: 36px;   --t-h4-ps: 20px;   --t-h4-ls: -0.01em;
  --t-h5-size: 24px;   --t-h5-lh: 28px;   --t-h5-ps: 20px;   --t-h5-ls: 0;
  --t-h6-size: 20px;   --t-h6-lh: 24px;   --t-h6-ps: 20px;   --t-h6-ls: 0;
  --t-h7-size: 16px;   --t-h7-lh: 20px;   --t-h7-ps: 20px;   --t-h7-ls: 0;

  --t-body-lg-size:  20px;  --t-body-lg-lh:  32px;
  --t-body-md-size:  16px;  --t-body-md-lh:  20px;
  --t-body-sm-size:  14px;  --t-body-sm-lh:  16px;
  --t-body-xsm-size: 12px;  --t-body-xsm-lh: 16px;
  --t-body-ps:       20px;

  --t-weight-bold:     700;
  --t-weight-semibold: 600;
  --t-weight-regular:  400;

  /* ── Control & elevation tokens — repeated values, kept single-source.
     Add to / change here rather than in component CSS to prevent drift. */
  --ctrl-radius:        10px;     /* default control corner radius (inputs, buttons, popup btns) */
  --ctrl-radius-sm:      6px;     /* compact controls (e.g. length-value box) */
  --ctrl-pad-y:          8px;
  --ctrl-pad-x:         10px;
  --ctrl-gap:           10px;
  --bg-control-hover:   #f3f4f6;  /* secondary btn / popup btn hover */
  --bg-toggle-off:      #d1d5db;  /* off-state track for toggles */
  --shadow-thumb:       0 1px 3px rgba(0,0,0,0.3);   /* slider thumbs */
  --shadow-marker:      0 2px 4px rgba(0,0,0,0.4);   /* POI markers */
  --shadow-pin:         0 2px 4px rgba(0,0,0,0.35);  /* teardrop pins */
  --shadow-popup:       0 6px 18px rgba(0,0,0,0.18); /* leaflet waypoint popup */
  --shadow-panel:       0 -6px 24px rgba(0,0,0,0.16);/* bottom route panel */
}

/* ── Typography classes — type-only by default, no margins.
   Paragraph spacing is opt-in via the .t-flow modifier (see below).
   This avoids accidentally inflating inline labels (button text,
   spans inside flex layouts) with a default 20px bottom margin. */
.t-h1, .t-h2, .t-h3, .t-h4, .t-h5, .t-h6, .t-h7 {
  font-family: var(--t-font-heading);
  font-weight: var(--t-weight-bold);
  margin: 0;
}
.t-h1 { font-size: var(--t-h1-size); line-height: var(--t-h1-lh); letter-spacing: var(--t-h1-ls); --t-flow-ps: var(--t-h1-ps); }
.t-h2 { font-size: var(--t-h2-size); line-height: var(--t-h2-lh); letter-spacing: var(--t-h2-ls); --t-flow-ps: var(--t-h2-ps); }
.t-h3 { font-size: var(--t-h3-size); line-height: var(--t-h3-lh); letter-spacing: var(--t-h3-ls); --t-flow-ps: var(--t-h3-ps); }
.t-h4 { font-size: var(--t-h4-size); line-height: var(--t-h4-lh); letter-spacing: var(--t-h4-ls); --t-flow-ps: var(--t-h4-ps); }
.t-h5 { font-size: var(--t-h5-size); line-height: var(--t-h5-lh); letter-spacing: var(--t-h5-ls); --t-flow-ps: var(--t-h5-ps); }
.t-h6 { font-size: var(--t-h6-size); line-height: var(--t-h6-lh); letter-spacing: var(--t-h6-ls); --t-flow-ps: var(--t-h6-ps); }
.t-h7 { font-size: var(--t-h7-size); line-height: var(--t-h7-lh); letter-spacing: var(--t-h7-ls); --t-flow-ps: var(--t-h7-ps); }

.t-body-lg, .t-body-md, .t-body-sm, .t-body-xsm {
  font-family: var(--t-font-body);
  letter-spacing: 0;
  margin: 0;
  --t-flow-ps: var(--t-body-ps);
}
.t-body-lg, .t-body-md  { font-weight: var(--t-weight-semibold); }
.t-body-sm, .t-body-xsm { font-weight: var(--t-weight-regular); }
.t-body-lg  { font-size: var(--t-body-lg-size);  line-height: var(--t-body-lg-lh);  }
.t-body-md  { font-size: var(--t-body-md-size);  line-height: var(--t-body-md-lh);  }
.t-body-sm  { font-size: var(--t-body-sm-size);  line-height: var(--t-body-sm-lh);  }
.t-body-xsm { font-size: var(--t-body-xsm-size); line-height: var(--t-body-xsm-lh); }

/* Paragraph spacing — opt-in. Picks up --t-flow-ps from the type class. */
.t-flow      { margin-bottom: var(--t-flow-ps, var(--t-body-ps)); }
.t-link      { text-decoration: underline; }
.t-semibold  { font-weight: var(--t-weight-semibold); }
.t-regular   { font-weight: var(--t-weight-regular); }

/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The Android shell offsets the WebView below the status bar itself, so the CSS
   must not add the top inset again — see --safe-top above (Trello #258). Class
   set from window.__nativePlatform in app.js, mirroring body.is-ios.
   For the bottom, Android WebView reports env(safe-area-inset-bottom) as 0
   (it exposes only display cutouts, not the nav bar), so --safe-bottom reads
   the real inset the shell injects as --android-nav-bottom instead. */
body.is-android { --safe-top: 0px; --safe-bottom: var(--android-nav-bottom, 0px); }

body {
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--c-bg);
  color: var(--c-text-primary);
}

/* ── Shared keyframes ───────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:0.6} }
@keyframes unlockPop{ 0%{opacity:0;transform:scale(0.93)} 60%{transform:scale(1.03)} 100%{opacity:1;transform:scale(1)} }

/* ── Header ─────────────────────────────────────────────────────── */
/* Legacy chrome for plain <header> elements (e.g. the featured-filter sheet
   head). Scoped with :not(.cf-top-bar) so it NEVER leaks into the locked
   design-system top bar — that leak (height/align-items/gap) was the original
   reason the app needed a big counter-override block fighting the library. */
header:not(.cf-top-bar) {
  background: var(--c-header-bg);
  border-bottom: 1px solid var(--c-header-border);
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 1000;
}
header:not(.cf-top-bar) h1 {
  font-size: 1.1rem; font-weight: 700; color: var(--c-text-primary);
  white-space: nowrap; letter-spacing: 0.02em; flex-shrink: 0;
}

.settings-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 20px;
  background: var(--c-surface); border: 1px solid var(--c-input-border);
  color: var(--c-text-secondary); font-size: 0.75rem; cursor: pointer;
  white-space: nowrap; flex-shrink: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.15s;
}
.settings-pill:hover { border-color: var(--c-accent); color: var(--c-text-primary); }
.settings-pill .pill-icon { font-size: 0.85rem; flex-shrink: 0; }

.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; flex-wrap: nowrap; }

.btn-logout {
  flex-shrink: 0;
  background: transparent; border: 1px solid var(--c-input-border); color: var(--c-text-secondary);
  padding: 5px 9px; font-size: 1rem; line-height: 1;
}
.btn-logout:hover { border-color: var(--c-danger); color: var(--c-danger); }

/* Coins/gems pill — aligned to the cf-btn row (same height, same radius,
   neutral background) so it doesn't read as a separate visual island. */
.coins-badge {
  display: inline-flex; align-items: center;
  height: var(--scale-1000);
  padding: 0 var(--scale-300);
  gap: var(--scale-200);
  background: var(--surface-page);
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-body);
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  white-space: nowrap; flex-shrink: 0;
}
.coins-badge.gems-clickable { cursor: pointer; transition: background-color .12s ease; }
.coins-badge.gems-clickable:hover { background: var(--surface-action-ghost-hover); }

.btn-profile {
  background: none; border: 1px solid var(--c-input-border); border-radius: 50%;
  width: 32px; height: 32px; font-size: 1rem; cursor: pointer;
  color: var(--c-text-secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-profile:hover { background: #f3f4f6; border-color: var(--c-accent); }

@media (max-width: 480px) {
  #pillLabel { display: none; }
  .btn { padding: 6px 10px; font-size: 0.75rem; }
  header h1 { font-size: 1.1rem; }
  .settings-pill { font-size: 0.7rem; padding: 4px 8px; }

  /* Mobile header: shrink all icon buttons + coins pill so the six header
     items (featured-routes / my-quizzes / coins / profile / feedback / logout)
     fit on one row from ~320px upwards. Without this, coins gets pushed
     off-screen and the visible right-most slot becomes feedback/logout —
     read as "profile replaced by sign out". */
  header             { padding: 0 var(--scale-300); gap: var(--scale-100); }
  .header-actions    { gap: var(--scale-100); }
  .header-actions .cf-btn {
    height: var(--scale-800);          /* 32px (was 40) */
    padding: 0 var(--scale-200);       /* 8px (was 16) */
  }
  .header-actions .cf-btn .ph { font-size: var(--scale-500); } /* 20px (was 24) */
  .header-actions .coins-badge {
    height: var(--scale-800);             /* 32px — matches mobile cf-btn */
    padding: 0 var(--scale-200);
    font-size: var(--text-body-xsm-size);
    gap: var(--scale-100);
  }
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  padding: 6px 14px; border: none; border-radius: 7px; cursor: pointer;
  font-size: 0.8rem; font-weight: 600; transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active  { transform: scale(0.97); }
.btn:disabled{ opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary   { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: var(--c-accent-hover); }
.btn-secondary { background: #f3f4f6; color: var(--c-text-secondary); border: 1px solid var(--c-divider); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-quiz      { background: var(--c-parchment-brown); color: #fff8ee; }
.btn-icon      { padding: 6px 10px; font-size: 1rem; }

/* ── Map area ────────────────────────────────────────────────────── */
.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  transition: flex 0.25s ease;
}
#map { width: 100%; height: 100%; }

/* Floating "center on my location" control — bottom-right of the map, above
   Leaflet panes but below modals/popovers. Circular white button with the
   brand-orange navigation glyph, matching the app's icon-button language. */
/* .schedule-picker-locate = the same control inside the area picker (its own
   class so the "hide over panels" rules below never hit it). */
.app-locate-btn,
.schedule-picker-locate {
  position: absolute;
  right: var(--scale-400);
  /* Clear the Android gesture/nav bar: the WebView draws edge-to-edge at the
     bottom, so without the inset the control hides behind the system bar
     (Trello #258). --safe-bottom is the real inset (env() on iOS/web, the
     shell-injected value on Android); 0 in the browser / iOS with no bottom bar. */
  bottom: calc(var(--scale-600) + var(--safe-bottom));
  z-index: 1000;                                   /* above leaflet panes, below the top sheet (1100) */
  width: var(--scale-1100); height: var(--scale-1100);   /* 44 — comfortable tap target */
  display: grid; place-items: center;
  padding: 0;
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-full, 999px);
  background: var(--surface-page);
  color: var(--icon-brand, #ff8c00);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.app-locate-btn:active,
.schedule-picker-locate:active { transform: scale(0.96); }
.app-locate-btn i,
.schedule-picker-locate i { font-size: var(--scale-600); }
.app-locate-btn.is-locating { opacity: 0.6; pointer-events: none; }
/* Only meaningful over the map. Hidden in goals/quiz modes where map-tap
   picking is off (mirrors the tap hint), on any SPA screen (profile,
   settings, routes, …), and behind the Featured routes panel — anywhere
   the map isn't the active view. */
body.goals-mode      .app-locate-btn,
body.onboarding-mode .app-locate-btn,
body.featured-open   .app-locate-btn,
body.spa-screen-open .app-locate-btn { display: none !important; }

/* Route (quiz) mode keeps the control at bottom-right, but lifts it to sit just
   above the quiz bottom sheet so the sheet never covers it (Trello #261).
   --quiz-sheet-h is the sheet's live on-screen height, published from app.js as
   it snaps between collapsed / expanded / full; the fallback matches the sheet's
   min-height for the pre-JS frame. */
body.quiz-open .app-locate-btn {
  bottom: calc(var(--quiz-sheet-h, 220px) + var(--scale-400));
  top: auto;
}

/* Send-feedback control — bottom-LEFT mirror of the locate button (Trello #316).
   Same size/shape/shadow/visibility as .app-locate-btn, only the horizontal
   anchor flips to the left. Opens the profile feedback modal via app.js. */
.app-feedback-btn {
  position: absolute;
  left: var(--scale-400);
  bottom: calc(var(--scale-600) + var(--safe-bottom));
  z-index: 1000;
  width: var(--scale-1100); height: var(--scale-1100);
  display: grid; place-items: center;
  padding: 0;
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-full, 999px);
  background: var(--surface-page);
  color: var(--icon-brand, #ff8c00);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.app-feedback-btn:active { transform: scale(0.96); }
.app-feedback-btn i { font-size: var(--scale-600); }
/* Hidden anywhere the map isn't the active view — mirrors the locate button. */
body.goals-mode      .app-feedback-btn,
body.onboarding-mode .app-feedback-btn,
body.featured-open   .app-feedback-btn,
body.spa-screen-open .app-feedback-btn { display: none !important; }
/* Lift above the quiz bottom sheet in route mode, same as the locate button. */
body.quiz-open .app-feedback-btn {
  bottom: calc(var(--quiz-sheet-h, 220px) + var(--scale-400));
  top: auto;
}

body.quiz-open { overflow: hidden; }
/* New navigation layout: the map fills the viewport below the top bar; the
   quiz UI is a bottom-anchored sheet that floats over the map (the old quiz
   chrome shrank the map to 38vh and pushed the quiz body below it as a
   sibling flex child). The "Close" X is gone — users swipe / tap Back. */
body.quiz-open .map-wrap { flex: 1 1 auto; min-height: 0; }
/* Route panel is position:fixed and would float over the quiz parchment
   without this. Hidden for the duration of the quiz. */
body.quiz-open .route-panel { display: none; }

/* ── Top-bar / Type=Navigation while a quiz is open ─────────────────────────
   The app top bar is the Index-with-city-goal variant outside a quiz. In quiz
   mode JS swaps `.index-city-goal` → `.navigation` and moves the resource
   counter to be a direct child of the bar (see _enterQuizNavigationTopBar in
   app.js), so the library's cf-top-bar.navigation rules (padding 4/24 +
   counter centering) take over. This selector set only hides the Index pieces
   (goal pill + avatar, tabs) and surfaces the Back btn. The counter's vertical
   position needs no re-pin: both variants centre it in the 48-tall row. */
.app-top-bar .app-quiz-back-btn { display: none; }       /* hidden outside quiz */
body.quiz-open .app-top-bar .cf-top-bar-goal-right,
body.quiz-open .app-top-bar .app-tabs-row { display: none !important; }
body.quiz-open .app-top-bar .app-quiz-back-btn { display: inline-flex; gap: var(--scale-200); }
/* No map-wrap override needed in quiz mode: the shell shrinks to its single
   Navigation row and map-wrap (flex:1) reclaims the freed space automatically. */

/* ── Map sidebar panel (from Figma: Desktop 1-5) ─────────────────── */
.map-sidebar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--c-surface);
  border-right: 1px solid var(--c-divider);
  box-shadow: 2px 0 8px rgba(0,0,0,.06);
  z-index: 500;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.map-sidebar-heading {
  font-size: 1.25rem; font-weight: 700; color: var(--c-text-primary);
  padding: 24px 24px 16px;
}
.map-sidebar-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--c-divider);
}
.map-sidebar-label {
  font-size: 0.8rem; font-weight: 600; color: var(--c-text-primary); margin-bottom: 4px;
}
.map-sidebar-hint { font-size: 0.75rem; color: var(--c-text-secondary); margin-bottom: 10px; }
.map-sidebar-footer { padding: 16px 24px; margin-top: auto; }

/* Waypoint items (from Figma) */
.waypoint-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px;
  border: 1px solid var(--c-input-border); border-radius: 8px;
  background: var(--c-input-bg); margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.waypoint-item:last-child  { margin-bottom: 0; }
.waypoint-item:hover       { border-color: var(--c-accent); }
.waypoint-badge {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c-text-primary); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.waypoint-text {
  font-size: 0.875rem; color: var(--c-text-placeholder);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.waypoint-text--set { color: var(--c-text-primary); }
.waypoint-connector { width: 2px; height: 12px; background: var(--c-divider); margin: 0 21px; }

/* Waypoint context popup (from Figma Desktop-2) */
.waypoint-popup {
  background: var(--c-surface); border: 1px solid var(--c-divider);
  border-radius: 12px; padding: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12); min-width: 240px;
}
.waypoint-popup-title {
  font-size: 1rem; font-weight: 700; color: var(--c-text-primary); margin-bottom: 12px;
}
.waypoint-popup-action {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; cursor: pointer; border-radius: 6px; transition: background 0.12s;
}
.waypoint-popup-action + .waypoint-popup-action { border-top: 1px solid var(--c-divider); }
.waypoint-popup-action:hover { background: #f9fafb; }
.waypoint-popup-label { font-size: 0.875rem; color: var(--c-text-primary); }

/* Route length slider */
.route-slider { width: 100%; accent-color: var(--c-accent); }

/* Round route toggle */
.round-route-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.round-route-row label { font-size: 0.85rem; color: var(--c-text-secondary); cursor: pointer; }

/* ════════════════════════════════════════════════════════════════════
   AGGREGATED BASE CLASSES
   (shared foundations replacing duplicated selectors from v1)
   ════════════════════════════════════════════════════════════════════ */

/* ── .overlay — replaces: #auth-overlay, .modal-overlay, .profile-overlay, #feedbackOverlay ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
}
.overlay.open   { display: flex; }
.overlay--top   { z-index: 9000; }
.overlay--cover { background: var(--c-bg-dark); z-index: 9999; } /* auth-overlay variant */

/* ── .field-input — replaces: .auth-input, inline form inputs in setting-row / submit-field / qa-pair ── */
/* TODO: auth/settings screens not in Figma yet — keeping dark palette as fallback */
.field-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--c-field-bg);
  border: 1px solid var(--c-field-border);
  border-radius: 8px;
  color: var(--c-text-dark);
  font-size: 0.875rem;
  outline: none;
}
.field-input:focus       { border-color: var(--c-blue); }
.field-input::placeholder{ color: #555; }
.field-input--sm         { font-size: 0.82rem; padding: 7px 9px; }
.field-input--area       { min-height: 72px; resize: vertical; }

/* ── .alert — replaces: .auth-alert + modifiers, .auth-error, .auth-info (legacy) ── */
.alert {
  border-radius: 6px; padding: 8px 10px;
  font-size: 0.8rem; margin-bottom: 10px;
  border-width: 1px; border-style: solid;
}
.alert--error { background: rgba(233,69,96,.15); border-color: rgba(233,69,96,.4);  color: #f08; }
.alert--info  { background: rgba(106,176,245,.1); border-color: rgba(106,176,245,.3); color: var(--c-blue); }

/* ── .status-text — replaces: .loading-text, .loading-error, .gem-error-text, .gem-empty-text ── */
.status-text         { font-size: 0.82rem; }
.status-text--muted  { color: var(--c-muted-dark); }
.status-text--error  { color: #c55; }
.status-text--warn   { color: #f0c040; }

/* ── .quiz-btn — replaces: .quiz-serif-btn + modifiers, .quiz-check-btn, .riddle-btn, .unlock-btn, .quiz-finish-btn ── */
.quiz-btn {
  border: none; border-radius: 4px; cursor: pointer;
  font-family: Georgia, serif; font-weight: bold;
  transition: background 0.2s, transform 0.1s;
}
.quiz-btn:active              { transform: scale(0.96); }
.quiz-btn--brown              { background: var(--c-parchment-brown); color: #fff8ee; }
.quiz-btn--brown:hover        { background: #5a3c1e; }
.quiz-btn--green              { background: var(--c-parchment-green); color: #fff; }
.quiz-btn--green:hover        { background: #355a2e; }
.quiz-btn--green:disabled     { background: #9a9a9a; cursor: default; }
/* Size modifiers */
.quiz-btn--check  { padding: 6px 14px;  font-size: 0.8rem; }
.quiz-btn--riddle { padding: 10px 32px; font-size: 0.92rem; letter-spacing: 0.06em; }
.quiz-btn--unlock { padding: 9px 28px;  font-size: 0.88rem; letter-spacing: 0.04em; }
.quiz-btn--finish { padding: 10px 28px; font-size: 0.9rem;  letter-spacing: 0.05em; }
.quiz-btn--unlock:disabled { background: #b0a090; cursor: not-allowed; }

/* ── .station-context — replaces: .station-context, .hidden-place-hint, .final-quiz-hint ── */
.station-context     { font-size: 0.88rem; color: #5a4020; font-style: italic; line-height: 1.5; margin-bottom: 10px; }
.station-context--lg { margin-bottom: 12px; }
.station-no-info     { font-size: 0.88rem; color: #9a7c50; }

/* ── .quiz-text-input — replaces: .quiz-text-input, .hidden-place-input, .final-quiz-input (identical) ── */
.quiz-text-input {
  width: 100%; max-width: 300px; font-size: 0.95rem;
  padding: 6px 10px; border-radius: 4px;
  border: 1px solid #4a3a2a; background: #1a1a2e; color: #e0d5c5;
}

/* ════════════════════════════════════════════════════════════════════
   BACKWARD-COMPAT ALIASES
   Keep old names working until HTML / app.js are updated.
   Each alias is a one-liner pointing at the base class values.
   Remove after HTML migration (tracked in DESIGN.md).
   ════════════════════════════════════════════════════════════════════ */
/* Per-field validation message rendered right after the offending input. */
.cf-error-msg.is-form-feedback { display:block; margin-top:4px; margin-bottom:6px; font-size:.78rem; }

/* Referral-code blur feedback under the register-form field. The element is
   always present; copy + colour swap on validation state. Empty content =>
   nothing visible. */
.auth-referral-feedback { display:block; min-height:1em; margin-top:-6px; margin-bottom:10px; font-size:.78rem; }
.auth-referral-feedback.is-valid   { color: var(--text-success); }
.auth-referral-feedback.is-invalid { color: var(--text-error); }

.auth-error { border-radius:var(--radius-md); padding:8px 10px; font-size:.8rem; margin-bottom:10px; background:var(--surface-error); border:var(--border-w-sm) solid var(--error-200); color:var(--text-error); }
.auth-info  { border-radius:var(--radius-md); padding:8px 10px; font-size:.8rem; margin-bottom:10px; background:var(--secondary-50); border:var(--border-w-sm) solid var(--secondary-200); color:var(--text-information); }

.hidden-place-input { width:100%; max-width:300px; font-size:.95rem; padding:6px 10px; border-radius:4px; border:1px solid #4a3a2a; background:#1a1a2e; color:#e0d5c5; }
.final-quiz-input   { width:100%; max-width:300px; font-size:.95rem; padding:6px 10px; border-radius:4px; border:1px solid #4a3a2a; background:#1a1a2e; color:#e0d5c5; }

.hidden-place-hint { font-size:.88rem; color:#5a4020; font-style:italic; margin-bottom:12px; line-height:1.5; }
.final-quiz-hint   { font-size:.88rem; color:#5a4020; font-style:italic; margin-bottom:12px; line-height:1.5; }

/* All quiz buttons (Check / Riddle / Unlock / Finish) are library `cf-btn`
   variants now. The legacy parchment-serif button styles (.quiz-serif-btn,
   .riddle-btn, .unlock-btn, .quiz-finish-btn, .quiz-check-btn) were removed —
   only `.quiz-check-btn` / `.quiz-finish-btn` survive as bare JS hooks. */

.loading-text  { color:#666; font-size:.85rem; }
.loading-error { color:#c55; font-size:.85rem; }
.gem-error-text{ color:#f08; font-size:.82rem; }
.gem-empty-text{ color:#999; font-size:.82rem; }

/* ════════════════════════════════════════════════════════════════════
   UNDESIGNED ZONES  (dark v1 fallback — TODO: get Figma screens)
   ════════════════════════════════════════════════════════════════════ */

/* ── Boot loader (dim full-viewport overlay during the boot waterfall) ──
   Sits above #auth-overlay so the dim is also applied while the auth check
   itself runs. Fade-out is driven by the .is-hidden class set by
   app.js::_hideBootLoader; transitionend removes it from the layout entirely
   so the loader can't catch clicks after it's faded. */
.boot-loader {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity .3s ease-out;
}
.boot-loader.is-hidden { opacity: 0; pointer-events: none; }
.boot-loader-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: boot-loader-spin .9s linear infinite;
}
@keyframes boot-loader-spin { to { transform: rotate(360deg); } }

/* ── Brand loader (designer 5-frame crossfade) ───────────────────────────────
   Cloned from #cf-loader-template into the auth-card boot state and the
   full-screen boot loader during the login/boot flow. Faithful to the
   designer's timing (2.85 s cycle, 5 frames staggered by 1/5). */
.cf-loader {
  position: relative;
  width: var(--cf-loader-stage, 180px); height: var(--cf-loader-stage, 180px);
  --cf-cycle: 2.85s;
  margin: 0 auto;
}
.cf-loader img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  opacity: 0; will-change: opacity, filter;
  animation: cf-fade-blur var(--cf-cycle) cubic-bezier(.16, 1, .3, 1) infinite;
}
.cf-loader img:nth-child(1) { animation-delay: 0s; }
.cf-loader img:nth-child(2) { animation-delay: calc(var(--cf-cycle) * -0.8); }
.cf-loader img:nth-child(3) { animation-delay: calc(var(--cf-cycle) * -0.6); }
.cf-loader img:nth-child(4) { animation-delay: calc(var(--cf-cycle) * -0.4); }
.cf-loader img:nth-child(5) { animation-delay: calc(var(--cf-cycle) * -0.2); }
@keyframes cf-fade-blur {
  0%   { opacity: 0; filter: blur(10px); }
  7%   { opacity: 1; filter: blur(0); }
  20%  { opacity: 1; filter: blur(0); }
  27%  { opacity: 0; filter: blur(10px); }
  100% { opacity: 0; filter: blur(10px); }
}
@media (prefers-reduced-motion: reduce) {
  .cf-loader img { animation: none; opacity: 0; }
  .cf-loader img:nth-child(1) { opacity: 1; }
}

/* Auth-card boot state: the brand loader (designer crossfade) is THE loader for
   the whole boot/login flow — plain session checks ("Checking session…") and
   federated (?code) logins alike. app.js mounts it into .cf-loader-mount. */
#auth-boot-loading .cf-loader-mount { display: block; }
#auth-boot-loading .cf-loader { --cf-loader-stage: 150px; margin-bottom: 8px; }

/* Full-screen boot loader: the brand variant (set by _showBootLoader({brand}))
   swaps the spinner for the loader on a light panel — the illustrations are
   drawn for a light background, so they need it against the dark dim. */
#boot-loader .cf-loader-mount { display: none; }
#boot-loader.boot-loader--brand .boot-loader-spinner { display: none; }
#boot-loader.boot-loader--brand .cf-loader-mount {
  display: block;
  background: var(--surface-page);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

/* ── Auth overlay (light theme, cf-* tokens) ── */
#auth-overlay {
  position: fixed; inset: 0;
  background: var(--surface-background);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
#auth-overlay.hidden { display: none; }

.auth-card {
  position: relative;
  background: var(--surface-page);
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 24px var(--alpha-black-8);
}
.auth-card--narrow { max-width: 340px; width: 92%; }
/* Direct child ONLY: this is the boot state's CuriFox lockup. As a descendant
   selector it also caught the wizard's <h2 class="cf-fs-modal-title h4"> and
   centred it at 24px — `.auth-card h2` (0,1,1) outranks `.h4` (0,1,0), which is
   why every wizard title used to read centred instead of left at 28/32. */
.auth-card > h2 {
  font-family: var(--font-family-headings);
  color: var(--text-headings);
  font-size: 1.5rem; font-weight: var(--font-weight-bold);
  margin-bottom: 6px; text-align: center;
}
.auth-card > .subtitle {
  color: var(--text-label); font-size: .875rem;
  text-align: center; margin-bottom: 24px;
}
.auth-card > .subtitle.confirm-subtitle { margin-bottom: 16px; }

.auth-tabs {
  display: flex; margin-bottom: 20px;
  border-bottom: var(--border-w-sm) solid var(--border-subtle);
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  color: var(--text-label); font-size: .875rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active {
  color: var(--text-action);
  border-bottom-color: var(--text-action);
}

/* ── v11 email-first auth wizard (one .auth-screen visible at a time) ────────
   Each screen IS the library's full-screen modal — `.cf-modal.full-screen`
   (Top bar → fs-modal header → content → pinned actions), the same shell the
   onboarding wizard uses. That is what the v11 mockups draw: a full-bleed
   393-wide page with a 44px nav bar and a 24px content gutter, NOT a card.
   Consequently this block owns no component styling at all — fields are
   `.cf-field.lg`, labels `.cf-label`, buttons `.cf-btn`, the address chip
   `.cf-tag.lg`. Only the composition the library has no class for lives here:
   the chip↔Edit row and the code screens' illustration row.
   (The old `.auth-input` / `.auth-btn` / `.auth-h1` aliases this replaced were
   the BACKWARD-COMPAT block above — see its "Remove after HTML migration".) */
.auth-wizard { position: relative; height: 100%; }
/* Out-specifies `.cf-modal.full-screen { display: flex }` (0,2,0) so a hidden
   screen stays hidden — a bare `.auth-screen[hidden]` (0,1,1) would lose. */
.auth-wizard .auth-screen[hidden] { display: none; }

/* Wizard mode: the auth CARD is only the boot state (spinner + CuriFox lockup).
   The moment the wizard is up, the overlay becomes the full-bleed page the
   mockups show. The lockup, subtitle and ✕ are hidden with it — the wizard's
   own Back button is the identical escape hatch (authEmailBack →
   closeAuthOverlay), so nothing is lost. Toggled by _showAuthForms() /
   closeAuthOverlay() in js/app.js. */
#auth-overlay.is-wizard { align-items: stretch; background: var(--surface-page); }
#auth-overlay.is-wizard .auth-card {
  max-width: none; width: 100%; height: 100%;
  padding: 0; border: 0; border-radius: 0; box-shadow: none;
}
#auth-overlay.is-wizard .auth-card > h2,
#auth-overlay.is-wizard .auth-card > .subtitle { display: none; }
/* The ✕ lives inside #auth-forms, not next to the lockup, so it needs its own
   selector. Without it the nav bar merely happens to paint over it — invisible
   AND unclickable by accident. Hide it outright: the mockups have no ✕, and
   the Back button already calls closeAuthOverlay(). */
#auth-overlay.is-wizard .cf-modal-close { display: none; }
#auth-overlay.is-wizard #auth-forms { height: 100%; }

/* Figma sits the title 24px below the 44px nav bar (content y=52 + frame y=16);
   the library's fs-modal header pads 16, and there is no pagination row here. */
.auth-screen .cf-fs-modal-header { padding-top: var(--scale-600); }

/* Content stack — 24px between blocks, 24px gutter, matching the mockups. */
.auth-body {
  display: flex; flex-direction: column; gap: var(--scale-600);
  padding: 0 var(--scale-600) var(--scale-600);
}
.auth-body > p { margin: 0; }

/* Address chip + its Edit button (Figma: Tag/lg 36 tall, Button 56×44, 4px gap).
   The chip shrinks and ellipsizes so a long address never pushes Edit off-screen. */
.auth-emailtag-row { display: flex; align-items: center; gap: var(--scale-100); }
.auth-emailtag     { min-width: 0; }
.auth-emailtag-val { overflow: hidden; text-overflow: ellipsis; }

/* Code screens — 80×80 illustration, 24px gutter, copy takes the rest and is
   centred against it: Figma 4059:3946 sits the 60-tall copy at y=10 in the
   80-tall row, i.e. (80−60)/2. */
.auth-figure { display: flex; align-items: center; gap: var(--scale-600); }
.auth-figure img { width: var(--scale-2000); height: var(--scale-2000); flex-shrink: 0; }

/* Resend + its cooldown notice live INSIDE the code field's .cf-field-wrap so
   they inherit its tight rhythm — Figma 4059:3947 puts Resend 8px under the
   field block, not the 24 that separates top-level blocks. The wrap is a
   stretch-aligned column, so the button must opt out or it spans the full 345;
   the mockup's instance is 125 wide. Its 12px label inset is `.cf-btn`'s own
   padding, which that centred 125-wide button reproduces — do NOT zero it. */
.cf-field-wrap > .auth-resend { align-self: flex-start; }

/* "Forgot password?" is a Ghost-primary `lg` button (user decision — the
   mockups draw it as a bare text node at x=0, but it is a button everywhere
   else in the flow, so the component wins and the frame follows). Nothing here
   restyles it; .auth-body is a stretch-aligned column, so it only has to opt
   out of stretching or the 16px label would centre itself across all 345. */
.auth-body > .auth-forgot-link { align-self: flex-start; }

/* The inline error slot collapses when empty — the mockups hide the Hint text
   node rather than reserving its line (Figma 4030:3297 is 56 tall with no
   error, 4059:3948 is 104 with one), so a reserved line would open a visible
   gap on the screens where the slot is not tucked under a field. `.is-visible`
   is toggled by _authShowErr/_authClearErr. */
.auth-err:not(.is-visible) { display: none; }

.auth-btn-google {
  width: 100%; padding: 11px;
  display: flex; align-items: center; justify-content: center; gap: var(--scale-300);
  border: var(--border-w-sm) solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-page); color: var(--text-body);
  font-size: .875rem; font-weight: var(--font-weight-semibold);
  cursor: pointer; margin-top: 10px;
  transition: background .15s, border-color .15s;
}
.auth-btn-google .auth-google-icon { width: 20px; height: 20px; flex-shrink: 0; }
.auth-btn-google:hover:not(:disabled) {
  background: var(--neutral-15);
  border-color: var(--text-action);
}
.auth-btn-google:disabled {
  background: var(--surface-page);
  color: var(--text-label);
  border-color: var(--border-disabled);
  opacity: 0.55;
  cursor: not-allowed;
}

/* Sign in with Apple — App Store Guideline 4.8. Hidden by default; only the
   iOS shell (which adds body.is-ios via window.__nativePlatform) reveals it, so
   web/Android keep Google + email only. Apple HIG: solid black, white label. */
.auth-btn-apple {
  width: 100%; padding: 11px;
  display: none;
  align-items: center; justify-content: center; gap: var(--scale-300);
  border: var(--border-w-sm) solid #000;
  border-radius: var(--radius-lg);
  background: #000; color: #fff;
  font-size: .875rem; font-weight: var(--font-weight-semibold);
  cursor: pointer; margin-top: 10px;
  transition: opacity .15s;
}
body.is-ios .auth-btn-apple { display: flex; }
/* Official Apple logo artwork (i/apple-logo.svg) — Guideline 4 requires Apple's
   own mark, not a redrawn icon. Height-driven so the taller-than-wide glyph
   keeps its aspect ratio; ~18px reads as slightly larger than the 14px label,
   matching the SIWA button proportions. */
.auth-btn-apple .auth-apple-icon { height: 18px; width: auto; flex-shrink: 0; }
.auth-btn-apple:hover:not(:disabled) { opacity: .85; }

.auth-divider {
  text-align: center; color: var(--text-label);
  font-size: .75rem; margin: 14px 0;
}

/* Terms agreement row — sits above the gated submit button */
.auth-terms {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 6px 0 12px;
  font-size: .8125rem; line-height: 1.4;
  color: var(--text-label);
  cursor: pointer;
  user-select: none;
}
.auth-terms input[type="checkbox"] {
  margin: 2px 0 0;
  width: 16px; height: 16px;
  flex-shrink: 0;
  accent-color: var(--surface-action);
  cursor: pointer;
}
.auth-terms a {
  color: var(--text-action);
  text-decoration: underline;
}
.auth-terms a:hover { text-decoration: none; }

/* Small disclaimer below the Google button on the Sign-in tab — informs
   first-time Google sign-ups that continuing implies acceptance of the
   Terms / Privacy. No checkbox; Terms re-acceptance only on /register. */
.auth-disclaimer {
  margin: 6px 0 0;
  font-size: .75rem;
  line-height: 1.4;
  color: var(--text-label);
  text-align: center;
}
.auth-disclaimer a {
  color: var(--text-action);
  text-decoration: underline;
}
.auth-disclaimer a:hover { text-decoration: none; }

/* ── Guest CTA popup — "Get your free account" soft registration wall.
   A centered single-column card (distinct from the head/actions split every
   other cf-modal uses), shown at the end of the tutorial and whenever a guest
   hits a registered-only action. Reuses .auth-btn-google / .auth-divider /
   .cf-btn; only the layout + the benefit list are bespoke here. */
/* Centered popup: logo + title + subline + action, stacked and centered.
   Shared by the guest CTA and the location gate; guest-cta layers its
   benefits/auth buttons on top. Single source for the padding + centering so
   the two modals can't drift apart. */
.cf-modal.centered {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--scale-800) var(--scale-600) var(--scale-600);
  text-align: center;
}
/* A direct-child action button fills the width like the guest CTA's do — but
   NOT the absolutely-positioned close X (.cf-modal-close), which must keep its
   own 40×40 footprint pinned top-right. */
.cf-modal.centered > .cf-btn:not(.cf-modal-close) { width: 100%; }
/* Only the location gate uses .cf-modal-title inside a centered modal (the
   guest CTA uses .guest-cta-title), and it has no close button — so cancel the
   title's reserved close-slot padding to keep it centred. */
.cf-modal.centered > .cf-modal-title { padding-right: 0; }
.cf-modal.centered > .cf-modal-subline { margin-bottom: var(--scale-300); }
.cf-modal.centered > .cf-modal-note { margin: 0 0 var(--scale-600); color: var(--text-body-light); }

.guest-cta-logo {
  width: var(--scale-1100); height: var(--scale-1100);   /* 44 */
  margin: var(--scale-200) auto var(--scale-400);
  display: block;
}
.guest-cta-title.h3 { margin: 0 0 var(--scale-700); }

/* Not enough coins / gems popup (#321). Centered cf-modal reusing the guest-CTA
   benefits list. Currency icon + adaptive copy are set in showInsufficientFunds. */
.insufficient-funds-icon {
  width: var(--scale-1100); height: var(--scale-1100);   /* 44 */
  margin: var(--scale-200) auto var(--scale-400);
  display: block;
}
.insufficient-funds-title.h3 { margin: 0 0 var(--scale-300); }
.insufficient-funds-sub { margin: 0 0 var(--scale-600); color: var(--text-body-light); }
.insufficient-funds-list { margin-bottom: var(--scale-600); }
/* The shared `.guest-cta-benefits li { display:flex }` outranks the UA
   [hidden] rule, so toggling li.hidden alone won't hide the exchange row —
   this scoped override restores it. */
.insufficient-funds-list li[hidden] { display: none; }
.insufficient-funds .cf-modal-actions { padding: 0; }

/* Scheduled routes (#319) — third planner tab. The panel reuses .featured-panel
   positioning; these are the card + editor specifics. */
.schedule-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--scale-300); padding: var(--scale-1200) var(--scale-400);
}
.schedule-empty-icon { font-size: 2.5rem; color: var(--icon-action); }
.schedule-empty .cf-btn { margin-top: var(--scale-300); }
.schedule-empty p { color: var(--text-body-light); margin: 0; max-width: 28ch; }

.schedule-card .cf-card-header,
.schedule-rotd .cf-card-header { margin-bottom: var(--scale-300); }
.schedule-card-rows { display: flex; flex-direction: column; gap: var(--scale-200); }
.schedule-card-row {
  display: flex; align-items: center; gap: var(--scale-200);
  font-size: var(--text-body-md-size); color: var(--text-body);
}
.schedule-card-row i { color: var(--icon-action); font-size: 1.1em; }
.schedule-card-actions { display: flex; gap: var(--scale-300); margin-top: var(--scale-400); }
.schedule-card-actions .cf-btn { flex: 1; }
.schedule-rotd-empty { margin: 0; text-align: center; color: var(--text-body-light); }
/* Section headings in the scheduled tab ("Saved Schedule" · "Your daily routes").
   The panel body (.featured-panel .cf-page-body) is a flex column with a gap, so
   the heading just needs its default margins cleared. A touch more space above
   the second heading separates the two groups. */
.scheduled-list .schedule-section-title { margin: 0; color: var(--text-headings); }
.scheduled-list .schedule-section-title ~ .schedule-section-title { margin-top: var(--scale-200); }

/* ── Daily-route editor (Figma "- scheduled routes") ─────────────────────────
   Full-screen view above the app chrome: library Nav bar · scrolling body ·
   pinned bottom bar. Every block's visibility derives from ONE attribute,
   #scheduledEditor[data-area] (none · checking · ok · locked · unlocking) —
   see the state machine in js/app.js. z 1500: above the top bar (1100) and
   the route sheet, below modals (9100) so the "not enough gems" popup and
   toasts still land on top. */
.schedule-editor {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; flex-direction: column;
  background: var(--surface-page);
  padding-top: var(--safe-top);
}
.schedule-editor[hidden] { display: none; }
.schedule-editor-body {
  flex: 1; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: var(--scale-600);   /* 24 */
  padding: var(--scale-400) var(--scale-600) var(--scale-600);    /* 16 · 24 · 24 */
}
.schedule-editor-foot {
  flex-shrink: 0;
  padding: var(--scale-400) var(--scale-600) calc(var(--scale-800) + var(--safe-bottom));
  background: var(--surface-page);
  border-top: var(--border-w-sm) solid var(--border-subtle);
}
.schedule-editor-foot .cf-btn { width: 100%; }
.schedule-intro { color: var(--text-body-light); margin: 0; }
.schedule-section { display: flex; flex-direction: column; gap: var(--scale-300); }   /* 12 */
.schedule-form { gap: var(--scale-400); }                                              /* 16 */
.schedule-section > .schedule-section-title { margin: 0; color: var(--text-headings); }
.schedule-error { color: var(--text-error); margin: 0; }
.schedule-delete { align-self: center; }
.schedule-gem-ico { height: 1.5em; vertical-align: middle; }

/* State → visibility. Form (time/length) only once the area is usable. */
.schedule-editor:not([data-area="ok"]):not([data-area="unlocking"]) .schedule-form { display: none; }
.schedule-editor:not([data-area="locked"]):not([data-area="unlocking"]) .schedule-notice { display: none; }
.schedule-editor[data-area="unlocking"] .schedule-notice-actions { display: none; }
.schedule-editor[data-area="none"] .schedule-area-row,
.schedule-editor:not([data-area="none"]) .schedule-use-location,
.schedule-editor:not([data-area="none"]) .schedule-choose-btn,
.schedule-editor:not([data-area="none"]) .schedule-map-preview-veil,
.schedule-editor:not([data-area="locked"]) .schedule-map-badge { display: none; }

/* Walking-area mini map (136 tall, radius 16). */
.schedule-map-preview {
  position: relative; height: 136px;
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-xlg);
  overflow: hidden; cursor: pointer;
}
/* z-index 0 = own stacking context, so Leaflet's panes (z 400+) stay under the
   veil / button / badge layered on top. */
.schedule-map-preview-map { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.schedule-map-preview-veil { position: absolute; inset: 0; background: var(--surface-page); opacity: 0.6; }
.schedule-choose-btn,
.schedule-map-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 1;
}
.schedule-choose-btn { pointer-events: none; }   /* the whole preview is the tap target */
/* Deviation from Figma (transparent): an opaque fill keeps the label legible
   over real map labels showing through the veil. */
.schedule-map-preview .cf-btn.schedule-choose-btn { background: var(--surface-page); }
.schedule-map-badge {
  display: grid; place-items: center;
  padding: 6px; border-radius: var(--radius-round);
  background: var(--surface-page); box-shadow: var(--shadow-md);
  color: var(--icon-disabled);
}
.schedule-map-badge i { font-size: var(--scale-800); }   /* 32 */
.schedule-use-location { align-self: flex-start; }
.schedule-area-row { display: flex; align-items: center; gap: var(--scale-300); }
.schedule-area-field { flex: 1; min-width: 0; }
.cf-field.schedule-area-field .ph { font-size: var(--scale-600); }   /* 24 (library field icons are 20) */
.schedule-area-field span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Area shape — preview + picker share it (Leaflet path classNames). Orange =
   usable; grey while the area has no points yet. */
.schedule-area-circle { fill: var(--surface-action); fill-opacity: 0.2; stroke: var(--border-action); stroke-width: 2; }
.schedule-area-center { fill: var(--surface-action); fill-opacity: 1; stroke: var(--surface-page); stroke-width: 3; }
.schedule-editor[data-area="locked"] .schedule-area-circle { fill: var(--neutral-600); stroke: var(--neutral-400); }
.schedule-editor[data-area="locked"] .schedule-area-center { display: none; }

/* Area notice — "No points here yet" (locked) / "Unlocking this area". */
.schedule-notice {
  display: flex; flex-direction: column; gap: var(--scale-300);
  padding: var(--scale-400);
  border-radius: var(--radius-xlg);
  background: var(--surface-action-background);
}
.schedule-notice p { margin: 0; color: var(--text-body); }
.schedule-notice-title { display: flex; align-items: center; gap: var(--scale-200); }
.schedule-notice-title i { font-size: var(--scale-800); color: var(--icon-action); }   /* 32 */
.schedule-notice-title span { margin: 0; color: var(--text-headings); }
.schedule-notice-actions { display: flex; flex-direction: column; gap: var(--scale-300); }
.schedule-notice-actions .cf-btn { width: 100%; }
.schedule-kids { display: inline-flex; align-items: center; gap: var(--scale-300); cursor: pointer; align-self: flex-start; }
.schedule-kids .body-md { margin: 0; color: var(--text-body); }
.schedule-notice .schedule-balance { text-align: center; color: var(--text-body-light); }

/* "When to send a new route". */
.schedule-row { display: flex; align-items: center; justify-content: space-between; gap: var(--scale-300); }
.schedule-row > .body-md { margin: 0; color: var(--text-body); }
.schedule-time { display: flex; align-items: center; gap: 6px; }
.schedule-time > .body-md { margin: 0; }
.schedule-time-select { width: var(--scale-2000); min-width: 0; position: relative; }   /* 80 */
.schedule-time-select select { padding-right: var(--scale-500); }
.schedule-time-select .caret { position: absolute; right: var(--scale-300); pointer-events: none; }
.schedule-divider { border: 0; height: var(--border-w-sm); background: var(--border-subtle); margin: 0; }
.schedule-weekdays { display: flex; justify-content: space-between; }
.cf-chip.schedule-weekday {
  width: var(--scale-1100); height: var(--scale-1100);    /* 44 circle (library chip is 28 tall) */
  padding: 0; border-radius: var(--radius-round);
}
.schedule-summary { margin: 0; color: var(--text-body-light); }

/* ── "Choose your area" picker over the real map ─────────────────────────────
   Mirrors #onboarding-map-ui: fixed chrome, empty middle passes drags to the
   map. body.schedule-area-mode strips the app chrome so the map fills the
   screen under it. */
.schedule-picker {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; flex-direction: column;
  pointer-events: none;
}
.schedule-picker[hidden] { display: none; }
.schedule-picker > .cf-top-bar,
.schedule-picker-panel { pointer-events: auto; flex-shrink: 0; }
.schedule-picker > .cf-top-bar.nav-bar { padding-top: var(--safe-top); }
.schedule-picker-window { position: relative; flex: 1; min-height: 0; }
.schedule-picker-hint {
  position: absolute; top: var(--scale-400); left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}
.schedule-picker-locate { pointer-events: auto; right: var(--scale-600); bottom: var(--scale-600); }
.schedule-picker-panel {
  display: flex; flex-direction: column; gap: var(--scale-500);   /* 20 */
  padding: var(--scale-500) var(--scale-600) calc(var(--scale-800) + var(--safe-bottom));
  background: var(--surface-page);
  box-shadow: var(--shadow-up);
}
.schedule-picker-panel .cf-btn { width: 100%; }
.schedule-picker-info { display: flex; align-items: center; gap: var(--scale-300); }
.schedule-picker-info > i { font-size: var(--scale-800); color: var(--icon-action); flex-shrink: 0; }   /* 32 */
.schedule-picker-info p { margin: 0; }
.schedule-picker-info .body-md-semibold { color: var(--text-headings); }
.schedule-picker-radius { color: var(--text-body-light); }
body.schedule-area-mode .app-top-bar-shell,
body.schedule-area-mode #locateBtn,
body.schedule-area-mode #mapFeedbackBtn,
body.schedule-area-mode .leaflet-control-container { display: none !important; }

/* Steps recap popup (app start) — see js/app.js::_showStepsRecap.
   Standard head/content .cf-modal; the close X is anchored by
   `.cf-modal-overlay .cf-modal { position: relative }` (app.css). Only the
   step count is emphasised (semibold orange, Figma 2665:7592). */
.steps-recap-count { color: var(--text-action); font-weight: var(--font-weight-semibold); }

/* Register-popup pitch paragraph. Replaces the old benefits checklist there;
   it owns the gap above the Google button (auth-btn-google zeroes its own
   margin-top — see the action-buttons comment below). The checklist classes
   stay: the insufficient-funds modal still uses them. */
.guest-cta-pitch {
  margin: 0 0 var(--scale-600);
  font-size: var(--text-body-md-size); line-height: var(--text-body-md-line-height);
  color: var(--text-body);
}

.guest-cta-benefits {
  list-style: none; margin: 0 0 var(--scale-600); padding: 0;
  display: flex; flex-direction: column; gap: var(--scale-400);
  text-align: left;
}
.guest-cta-benefits li {
  display: flex; align-items: flex-start; gap: var(--scale-300);
  font-size: var(--text-body-md-size); line-height: var(--text-body-md-line-height);
  color: var(--text-body);
}
/* Top-align the check to the FIRST text line (Figma), not the centre of a
   wrapped two-line item. The 24px circle equals the 24px line box, so
   flex-start centres it on line 1; single-line items are unaffected. */
.guest-cta-check {
  flex-shrink: 0;
  width: var(--scale-600); height: var(--scale-600);     /* 24 */
  border-radius: var(--radius-round);
  background: var(--surface-information);                 /* light purple */
  color: var(--icon-information);                         /* Secondary/default purple check */
  display: grid; place-items: center;
  font-size: .8125rem;
}

/* Action buttons stack full-width; explicit rhythm since we're not inside
   .cf-modal-actions. Scoped to primary/outlined ONLY — a blanket
   `.guest-cta .cf-btn` would also stretch the absolutely-positioned
   .cf-modal-close (icon-only) button, and which rule wins is CSS-load-order
   fragile (differs between index.html and tutorial.html). auth-btn-google's
   own margin-top is zeroed so the gap above it is owned by the benefit list. */
.guest-cta .auth-btn-google { margin-top: 0; }
.guest-cta .cf-btn.primary,
.guest-cta .cf-btn.outlined { width: 100%; }
.guest-cta .cf-btn.primary { margin-top: var(--scale-100); }
.guest-cta .cf-btn.outlined { margin-top: var(--scale-300); }

.guest-cta-continue {
  border: 0; background: transparent; cursor: pointer;
  margin-top: var(--scale-600);
  color: var(--text-action);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-body-md-size); line-height: var(--text-body-md-line-height);
}
.guest-cta-continue:hover { color: var(--text-action-hover); }

.guest-cta-note {
  margin: var(--scale-300) 0 0;
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-label);
}
.guest-cta-note strong { color: var(--text-body); font-weight: var(--font-weight-semibold); }

.guest-cta-terms {
  margin: var(--scale-600) 0 0;
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-label);
}
.guest-cta-terms a { color: var(--text-action); text-decoration: none; }
.guest-cta-terms a:hover { text-decoration: underline; }

/* Terms reader modal — wider than the default 386px so the iframe content is
   readable. Z-index must beat both .cf-modal-overlay (9100, app.css) and
   #auth-overlay (9999, this file) — use a compound selector so app.css's
   later-in-cascade rule doesn't win on equal specificity. */
.cf-modal-overlay.terms-modal-overlay { z-index: 10001; }
.terms-modal-overlay .terms-modal {
  width: 720px; max-width: 100%;
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--scale-1200));
}
.terms-modal-content {
  padding: 0;
  flex: 1; min-height: 0;
  display: flex;
}
.terms-modal-content iframe {
  flex: 1;
  width: 100%;
  height: 70vh;
  border: 0;
  background: var(--surface-page);
}
#auth-boot-loading {
  text-align: center; padding: 16px 0 8px;
  color: var(--text-label); font-size: .875rem;
}

.city-wrap { position: relative; margin-bottom: 12px; }
.city-wrap .auth-input { margin-bottom: 0; }
.city-drop {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  z-index: 9999;
  background: var(--surface-page);
  border: var(--border-w-sm) solid var(--border-default);
  border-radius: var(--radius-md);
  max-height: 200px; overflow-y: auto; display: none;
  box-shadow: 0 8px 24px var(--alpha-black-16);
}
.city-drop.open { display: block; }
.city-opt {
  padding: 8px 12px; font-size: .875rem;
  color: var(--text-body); cursor: pointer;
  border-bottom: var(--border-w-sm) solid var(--border-subtle);
}
.city-opt:last-child { border-bottom: none; }
.city-opt:hover, .city-opt.active {
  background: var(--neutral-15); color: var(--text-headings);
}

/* ── Toast notifications ── */
#notifyContainer { position:fixed; top:60px; left:50%; transform:translateX(-50%); z-index:9999; display:flex; flex-direction:column; align-items:center; gap:8px; pointer-events:none; }
.toast { pointer-events:auto; min-width:260px; max-width:420px; padding:11px 16px; border-radius:6px; font-size:.82rem; line-height:1.45; color:var(--c-text-dark); box-shadow:0 4px 18px rgba(0,0,0,.5); display:flex; align-items:flex-start; gap:10px; animation:toastIn .2s ease; cursor:pointer; }
.toast.info    { background:#1e3a5f; border-left:4px solid #4a9eff; }
.toast.success { background:#1a3d2e; border-left:4px solid #4caf50; }
.toast.warning { background:#3d2e0a; border-left:4px solid #f0c040; color:#f5e0a0; }
.toast.error   { background:#3d1010; border-left:4px solid var(--c-red); color:#f5c0c0; }
.toast-icon    { flex-shrink:0; font-size:1rem; margin-top:1px; }
.toast-close   { margin-left:auto; flex-shrink:0; opacity:.6; font-size:1rem; line-height:1; }
.toast-close:hover { opacity: 1; }
/* Welcome toast (library cf-toast · with-illustration) — pinned bottom-center,
   slides up on show. The cf-toast component owns its own look (white surface,
   purple info text, fox image); this only positions/animates it. */
.app-welcome-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--scale-600) + var(--safe-bottom));
  transform: translate(-50%, calc(100% + var(--scale-1600)));
  max-width: calc(100vw - 2 * var(--scale-600));
  z-index: 3000;
  opacity: 0;
  transition: transform 0.32s cubic-bezier(.2,.8,.2,1), opacity 0.32s ease;
}
.app-welcome-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .app-welcome-toast { transition: opacity 0.2s ease; transform: translate(-50%, 0); }
}
.poll-spinner  { display:inline-block; width:11px; height:11px; border:2px solid var(--c-field-border); border-top-color:var(--c-red); border-radius:50%; animation:spin .8s linear infinite; margin-right:5px; vertical-align:middle; }

/* ── Modals ── */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:2000; align-items:center; justify-content:center; padding:16px; }
.modal-overlay.open { display: flex; }
.modal-card { background:#13131f; border:1px solid var(--c-border-dark); border-radius:14px; padding:20px; width:100%; max-width:360px; box-shadow:0 20px 60px rgba(0,0,0,.6); }
.modal-card h3 { font-size:.85rem; letter-spacing:.1em; text-transform:uppercase; color:var(--c-blue); margin-bottom:16px; }
.modal-card--profile  { max-width:480px; max-height:90vh; overflow-y:auto; }
.modal-card--featured { max-width:480px; width:92%; }
.modal-close  { float:right; background:none; border:none; color:#666; font-size:1.2rem; cursor:pointer; line-height:1; margin-top:-2px; }
.modal-close:hover { color: #ccc; }
.modal-footer { margin-top:16px; display:flex; justify-content:flex-end; }

/* ── Settings rows ── */
.setting-row { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.setting-row label { font-size:.78rem; color:#999; width:90px; flex-shrink:0; }
.setting-row select, .setting-row input[type=number] { flex:1; padding:7px 10px; background:var(--c-field-bg); border:1px solid var(--c-field-border); border-radius:8px; color:#eee; font-size:.85rem; }
.setting-row .unit { font-size:.75rem; color:#666; flex-shrink:0; }
.hint-text { font-size:.75rem; color:#9a7c50; }

/* Submit node modal: migrated to cf-modal — see component-library.css.
   .qa-pair flex layout for JS-generated rows lives in app.css. */
.audio-rec-btn.recording { background:var(--c-red) !important; animation:pulse 1s infinite; }
.label-optional { color:#555; font-size:.7rem; }

/* ── Featured routes ── */
/* .route-card: layout moved to app.css (uses cf-* tokens). */
/* .route-card-price / .route-card-btn: see app.css. */
.featured-routes-list { margin-top:14px; display:flex; flex-direction:column; gap:10px; }

/* ── Gem store ── */
.gem-store-notice  { color:#999; font-size:.82rem; margin-top:8px; }
.gem-store-list    { margin-top:16px; display:flex; flex-direction:column; gap:10px; }
.gem-store-item    { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:10px 12px; background:var(--c-field-bg); border:1px solid var(--c-field-border); border-radius:10px; }
.gem-store-item-info  { flex:1; }
.gem-store-item-title { color:#fff; font-weight:700; font-size:.9rem; }
.gem-store-item-desc  { color:#999; font-size:.78rem; margin-top:4px; }

/* ── Coat of arms ── */
.coat-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:3px; width:72px; height:72px; border-radius:6px; overflow:hidden; border:2px solid var(--c-field-border); flex-shrink:0; }
.coat-grid--complete { border-color:var(--c-blue); box-shadow:0 0 8px rgba(106,176,245,.4); }
.coat-part { background:#1e1e3a; position:relative; overflow:hidden; }
.coat-part img { position:absolute; object-fit:cover; }
.coat-part.owned img { opacity:1; }
.coat-part:not(.owned) img { opacity:0; }
.coat-part:not(.owned)::after { content:''; position:absolute; inset:0; background:#1a1a2e; }
.coat-label { font-size:.65rem; color:var(--c-muted-dark); text-align:center; margin-top:4px; text-transform:capitalize; }
.coat-item  { display:flex; flex-direction:column; align-items:center; }
.city-pill  { background:#1e2a3a; border:1px solid #2a4a6a; border-radius:12px; padding:3px 10px; font-size:.78rem; color:var(--c-blue); }

/* ── Profile modal ── */
.profile-section        { margin-top:16px; }
.profile-section--coat  { margin-bottom:8px; }
.profile-section-title  { font-size:.78rem; color:var(--c-muted-dark); text-transform:uppercase; letter-spacing:.06em; margin-bottom:8px; }
.profile-section-body   { font-size:.85rem; color:#ccc; }
.profile-cities-list    { display:flex; flex-wrap:wrap; gap:6px; }
.profile-coats-list     { display:flex; flex-wrap:wrap; gap:14px; }
.profile-empty          { color:#555; font-size:.82rem; }
.profile-overlay        { position:fixed; inset:0; background:rgba(0,0,0,.7); z-index:9000; display:none; align-items:center; justify-content:center; }
.profile-overlay.open   { display: flex; }
.welcome-heading        { margin-bottom:6px; }

/* Feedback modal: migrated to cf-modal — see component-library.css. */

/* ── Leaflet ── */
.map-pin-start { background: #4caf50; }
.map-pin-end   { background: var(--c-red); }
.leaflet-control-attribution { display: none !important; }

/* ── City popup ── */
.city-popup       { min-width:180px; }
.city-popup-title { font-weight:700; margin-bottom:8px; }
.city-popup-btn   { width:100%; }
.city-popup-btn--target { margin-bottom:8px; }

/* ── Leaderboard ── */
.leaderboard-table     { width:100%; border-collapse:collapse; font-size:.8rem; }
.leaderboard-row       { color:#bbb; }
.leaderboard-row--me   { color:var(--c-blue); font-weight:700; }
.leaderboard-cell-rank { padding:2px 6px 2px 0; width:24px; }
.leaderboard-cell-name { padding:2px 0; }
.leaderboard-cell-score{ padding:2px 0 2px 8px; text-align:right; color:var(--c-muted-dark); }
.leaderboard-ellipsis  { color:#555; }
.leaderboard-ellipsis td { padding:2px 0; font-size:.7rem; }

/* ── Misc utility ── */
.nimda-badge { position:fixed; bottom:60px; left:12px; z-index:9999; background:var(--c-red); color:#fff; font-size:.7rem; font-weight:700; padding:4px 10px; border-radius:6px; cursor:pointer; letter-spacing:.08em; }
.loot-layer  { position:fixed; inset:0; pointer-events:none; z-index:9998; }

/* ════════════════════════════════════════════════════════════════════
   QUIZ SECTION  (CityFox design system — light surfaces, brand orange)
   Tokens sourced from component-library.css:
     - Surface/* + Border/* for layout
     - Text/* + Icon/* for content
     - Scale/* for spacing/sizing
     - Border-radius/* + Border-width/* aliases for corners/strokes
     - Body/H* typography classes for text styles
   Buttons inside the quiz reuse the cf-btn primitive (set in app.js).
   ════════════════════════════════════════════════════════════════════ */
/* Quiz section is now a fixed bottom-anchored overlay over the map (Figma:
   Type=Navigation bottom sheet). The map underneath is intentionally bigger;
   only the sheet body scrolls. Pointer-events fall through everywhere except
   the sheet itself so map gestures keep working in the visible map area. */
#quizSection {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1100;
  justify-content: center;
  pointer-events: none;
  color: var(--text-body);
  font-family: var(--font-family-text);
}
body.quiz-open #quizSection { display: flex; }

/* Full-bleed: the quiz sheet stretches edge-to-edge (no desktop max-width cap),
   so the Navigation bottom sheet spans the whole screen width like the bar. */
.quiz-page  { width: 100%; pointer-events: auto; }

/* ── Sheet shell — diff from library defaults ────────────────────────────────
   The library's .cf-bottom-sheet.navigation sets a fixed 393-px width and a
   360-px max-height; the quiz needs to stretch responsively to the quiz-page
   container and let the user pull the sheet up further to read long stop
   descriptions. Everything else (padding, shadow, drag handle, header layout,
   scrollable body + scrollbar styling) comes straight from the library. */
/* Specificity-bumped to .cf-bottom-sheet.navigation.app-quiz-sheet so these
   rules beat the library's .cf-bottom-sheet.navigation defaults (3-class
   selectors), since the library stylesheet loads AFTER style_v2.css. */
/* Cap the sheet at half the viewport height so the map keeps the top half
   visible; the Navigation body scrolls within. */
.cf-bottom-sheet.navigation.app-quiz-sheet { width: 100%; max-height: 50vh; min-height: 220px; transition: max-height 0.18s ease; }
/* Collapsed — swiping the handle / header downward hides the scrollable
   body. The handle + header stay parked above the bottom of the screen so
   the user can swipe up to expand again. The library's flex column already
   stacks handle / header / body, so just hiding the body is enough. */
.cf-bottom-sheet.navigation.app-quiz-sheet.is-collapsed { max-height: none; min-height: 0; }
.cf-bottom-sheet.navigation.app-quiz-sheet.is-collapsed .cf-bottom-sheet-body { display: none; }
/* Full — swiping/tapping past the default 50vh cap grows the sheet up toward
   the top bar, which in quiz mode is always the single-row Navigation variant
   (Scale/1200 = 48px) plus its safe-area strip. A Scale/1600 (64px) gap is
   left below the bar so the sheet doesn't butt up against it. Mirrors the
   calc() pattern used by .cf-top-sheet.app-top-sheet above, but with the
   correct 1-row height for quiz mode instead of the 2-row Index bar. */
.cf-bottom-sheet.navigation.app-quiz-sheet.is-full {
  max-height: calc(100vh - var(--scale-1200) - max(var(--safe-top), var(--scale-200)) - var(--scale-1600));
}
/* Make the handle + header obviously tappable (cursor for desktop / large
   hit area for touch). Drag-to-toggle is bound in JS. */
.app-quiz-sheet .cf-bottom-sheet-handle,
.app-quiz-sheet .cf-bottom-sheet-header { cursor: grab; touch-action: none; user-select: none; }
.app-quiz-sheet .cf-bottom-sheet-handle:active,
.app-quiz-sheet .cf-bottom-sheet-header:active { cursor: grabbing; }

/* Sheet header layout comes 1:1 from the library: the renderer emits the
   canonical .cf-bottom-sheet-header → .cf-bottom-sheet-heading (title +
   .cf-bottom-sheet-stats) + .cf-progress-segments structure, so
   component-library.css owns the title, stat, dot, reward and progress-bar
   styling. The only app rules below are behaviour glue the library cannot
   carry: the reward stat is a <button> here (it opens "What You'll Earn"),
   which needs the UA button chrome stripped — everything visual still comes
   from the library's .cf-bottom-sheet-reward rule. */
.app-quiz-sheet button.cf-bottom-sheet-reward {
  background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
/* The header is a drag surface (see _wireSheetSwipeToggle), so its interactive
   children must opt back into pointer gestures. */
.app-quiz-sheet .cf-bottom-sheet-header button { touch-action: manipulation; }

/* ── Card-stop state hook ──────────────────────────────────────────────────
   The library already styles .cf-card-stop, .locked (gray badge), .unlocked
   (purple bg "tap to unlock"), and the example markup for the opened head.
   The state lifecycle for the quiz is driven by the .locked class on the
   card root — JS removes it when the station opens, and swaps the badge icon
   in place. CSS just hides the "not there yet" copy and the distance when
   the card no longer carries .locked. Inline display on the unlock CTA and
   the opened body is owned by the existing JS contract (gps-lock-{i} /
   qtb{i}) so the unlock flow keeps working unchanged. */
/* The library treats locked + unlocked + opened as three card states. Subtitle
   ("not there yet" / "tap to unlock") + distance arrow are only meaningful
   before the user has opened the stop — hide them once the .locked AND
   .unlocked classes are both off. */
.cf-card-stop[data-station]:not(.locked):not(.unlocked) > .cf-card-stop-head > .cf-card-stop-titles > .cf-card-stop-subtitle,
.cf-card-stop[data-station]:not(.locked):not(.unlocked) > .cf-card-stop-head > .cf-card-stop-distance { display: none; }
/* Stretch the stops edge-to-edge: the library card is locked to width:345
   (mobile frame); on the full-bleed quiz sheet that leaves gutters, so fill
   the body's width. The body is a flex column (align-items:stretch), so 100%
   spans the whole available area. Vertical rhythm is the library's own
   gap:16 (Scale/400) — no override, so head/text/question/quiz/rating sit at
   the same spacing as the Opened — Default component. */
.app-quiz-sheet .cf-card-stop { width: 100%; }
.cf-card-stop-head.has-hints { cursor: pointer; }
/* The opened body and the post-riddle block nest the texts that the library
   keeps as direct children of the card. Mirror the card's flex column + gap:16
   on both wrappers so the text-to-text rhythm matches the component exactly.
   (Both are revealed via style.removeProperty('display'), falling back to
   these flex rules.) */
.app-stop-opened-body,
.app-stop-qpart { display: flex; flex-direction: column; gap: var(--scale-400); }

/* Unlock CTA — appears at the bottom of the head row when GPS gets the user
   close to a locked stop. Just a vertical stack inside a card. */
.app-stop-locked-cta { display: flex; flex-direction: column; gap: var(--scale-200); }

/* Final-quiz + hidden-place cards reuse cf-card-stop. The library already
   ships .cf-card-stop.unlocked = purple surface, which fits "find the hidden
   place" perfectly; final quiz uses the default neutral. The "FINAL"/"HIDDEN"
   label is a cf-card-stop-title with a small role-specific class for the
   uppercase eyebrow. */
.cf-card-stop .app-stop-pill {
  align-self: flex-start;
  padding: var(--scale-50) var(--scale-200);
  background: var(--surface-action);
  color: var(--text-on-color);
  border-radius: var(--radius-md);
  font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.1em; text-transform: uppercase;
}

/* ── Cover ───────────────────────────────────────────────────────────── */
.quiz-cover {
  position: relative;
  text-align: center;
  padding: var(--scale-1000) var(--scale-600) var(--scale-800);
  border-bottom: var(--border-w-sm) solid var(--border-subtle);
  margin-bottom: var(--scale-1100);
}
/* Quiz Close (BUGS.md bug 5): mirrors the modal close treatment —
   .cf-btn.neutral.icon-only handles the 40×40 ghost; this rule only positions
   it at the top-right of the cover. */
.quiz-cover-close {
  position: absolute;
  top: var(--scale-400);
  right: var(--scale-200);
}
.quiz-cover .eyebrow {
  font-family: var(--font-family-text);
  font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: var(--scale-300);
}
.quiz-cover h2 {
  font-family: var(--font-family-headings);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-h4-size); line-height: var(--text-h4-line-height);
  letter-spacing: var(--text-h4-letter-spacing);
  color: var(--text-headings);
  margin: 0 0 var(--scale-300);
}
.quiz-cover .route-info {
  display: inline-block;
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-label);
  background: var(--surface-page);
  border: var(--border-w-sm) solid var(--border-subtle);
  border-radius: var(--radius-round);
  padding: var(--scale-100) var(--scale-400);
}
/* "What You'll Earn" reward list (Figma 2338:926). Each row is a fixed-width
   reward-type column (amount + icon, 56px) and a description; the list is a
   flat column with 20-gap. Chrome (modal head padding, close) comes from the
   library .cf-modal. */

/* Local correction, scoped to this one modal: the Figma modal component puts
   Scale/500 (20) above the content slot — 32 total below the subline with the
   head's Scale/300 (12) — while the library's .cf-modal-content ships
   Scale/100 (4). We do not touch the library here, that padding is shared by
   every modal in the app. Overriding padding-top (not adding a margin) keeps
   this correct-by-construction: if the library is ever brought in line with
   Figma this rule becomes a no-op and can simply be deleted, whereas a margin
   would then stack into 36. */
#quizInfoOverlay .cf-modal-content { padding-top: var(--scale-500); }

.app-rewards-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--scale-500);   /* 20 */
}
/* items-start, not center: a label that wraps to two lines (long translations,
   the gem row) keeps its icon+amount on the first line instead of floating to
   the middle. Single-line rows are unaffected — both columns are 20px tall. */
.app-reward { display: flex; align-items: flex-start; gap: var(--scale-400); }  /* 16 */
.app-reward-type {
  display: flex; align-items: center; gap: var(--scale-100);      /* 4 */
  width: var(--scale-1400); flex-shrink: 0;                       /* 56 */
}
.app-reward-icon { width: var(--scale-400); height: var(--scale-400); flex-shrink: 0; display: block; }  /* 16 */
.app-reward-amount,
.app-reward-label {
  font-family: var(--font-family-text); font-weight: var(--font-weight-regular);
  font-size: var(--text-body-md-size); line-height: var(--scale-500);   /* Body md desktop 16/20 */
  color: var(--text-body);
}
.app-reward-label { flex: 1; min-width: 0; }
/* Amount leads the pair ("+1 <coin>") and is right-aligned in a fixed 36-wide
   box, so the digits stack on their right edge and the icon that follows sits
   on one vertical line whatever the payout is — including a two-digit one, if
   LOOT_CONFIG is ever retuned. 36 + gap 4 + icon 16 fills .app-reward-type's
   56px exactly, which is what pins the label column at 72. */
.app-reward-amount { width: var(--scale-900); text-align: right; }   /* 36 */

/* ── Station block ───────────────────────────────────────────────────── */
.quiz-station        { margin-bottom: var(--scale-1100); }
.quiz-station-header { display: flex; align-items: baseline; gap: var(--scale-300); margin-bottom: var(--scale-200); }
.quiz-station-num {
  font-family: var(--font-family-text);
  font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-on-color);
  background: var(--surface-action);
  padding: var(--scale-100) var(--scale-300);
  border-radius: var(--radius-md);
}
.quiz-station-num--hidden { background: var(--secondary-default); }
.quiz-station-num--final  { background: var(--success-default); }

.quiz-station-loc {
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-label);
  font-style: italic;
  margin-bottom: var(--scale-400);
}
.quiz-hr {
  border: none;
  border-top: var(--border-w-sm) solid var(--border-subtle);
  margin: var(--scale-800) 0 var(--scale-600);
}

/* The question paragraph is the library `.cf-card-stop-question`; the only
   app addition is honoring \n from LLM-authored questions. (.quiz-task-q is
   also a JS hook used by rotateQuestion.) */
.quiz-task-q { white-space: pre-line; }

/* ── Choices ─────────────────────────────────────────────────────────────
   Layout comes entirely from the library: `.cf-quiz` (row: options + Check,
   align-items flex-start, gap 12) and `.cf-quiz .cf-quiz-options` (column,
   gap 12, flex:1). `.quiz-answer-row` / `.quiz-choices` are kept only as JS
   hooks (save/restore/rotate) and carry no layout of their own. */

/* ── Feedback / inline result ─────────────────────────────────────────── */
.quiz-feedback {
  padding: var(--scale-200) var(--scale-300);
  border-radius: var(--radius-md);
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  display: none;
}
.quiz-feedback.correct { background: var(--surface-success); color: var(--text-success); display: block; }
.quiz-feedback.wrong   { background: var(--surface-error);   color: var(--text-error);   display: block; }
/* Inside a stop card the Correct/Wrong banner is redundant — the option rows
   already recolor (library Opened — Correct/False). Keep the element as the
   answered-state flag for save/restore, but never render it. (Hidden-place and
   final-quiz feedback live outside .app-stop-qpart, so they still show.) */
.app-stop-qpart > .quiz-feedback { display: none; }

/* Explanation revealed after the user submits an answer. Hidden by default;
   .is-visible is toggled in _revealExplanation when the CMS provided text. */
.quiz-explanation {
  display: none;
  padding: var(--scale-300) var(--scale-400);
  background: var(--secondary-50);
  border-left: var(--border-w-md) solid var(--text-information);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-body);
}
.quiz-explanation.is-visible { display: block; }

/* ── Vote / report row ───────────────────────────────────────────────── */
.quiz-vote-row {
  display: flex; align-items: center;
  gap: var(--scale-200);
  margin-top: var(--scale-300);
  padding-top: var(--scale-300);
  border-top: var(--border-w-sm) solid var(--border-subtle);
}
.quiz-vote-prompt {
  font-family: var(--font-family-text);
  font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height);
  color: var(--text-label);
}
.quiz-report-btn  { margin-left: auto; color: var(--text-error) !important; }
.quiz-report-btn:hover { background: var(--surface-error); }

/* ── Hidden-place callout (under the hidden-place question) ──────────── */
.quiz-context-box {
  margin-top: var(--scale-300);
  padding: var(--scale-300) var(--scale-400);
  background: var(--secondary-50);
  border-left: var(--border-w-md) solid var(--text-information);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-text);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-body);
}

/* ── Free-text input (hidden-place / final-quiz) ─────────────────────── */
.quiz-text-input {
  width: 100%; max-width: 320px;
  padding: var(--scale-200) var(--scale-300);
  font-family: var(--font-family-text);
  font-size: var(--text-body-md-size);
  background: var(--surface-page);
  color: var(--text-body);
  border: var(--border-w-sm) solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .12s ease;
}
.quiz-text-input:focus       { border-color: var(--text-action); }
.quiz-text-input::placeholder{ color: var(--text-label-light); }

/* ── Finish / footer ─────────────────────────────────────────────────── */
/* The in-body Finish row is gone: "Finish route" now lives in the sheet
   header (library Bottom sheet, Type = Navigation finish) and completion is
   reported by the full-screen Route-complete screen further down this file. */
.quiz-check-row  { margin-top: var(--scale-300); }
.quiz-footer {
  margin-top: var(--scale-1100);
  padding-top: var(--scale-300);
  border-top: var(--border-w-sm) solid var(--border-subtle);
  text-align: center;
  font-family: var(--font-family-text);
  font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height);
  font-style: italic;
  color: var(--text-label);
}

/* ── Unlock pop animation ────────────────────────────────────────────── */
.unlock-reveal { animation: unlockPop .35s ease both; }

/* ── Print ── */
@media print {
  header, .map-wrap { display: none !important; }
  body { height: auto; overflow: visible; background: white; }
  #quizSection { overflow: visible !important; }
  .quiz-check-btn, .quiz-feedback { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════════
   Route panel — always-visible bottom overlay (mobile-first)
   Replaces the legacy Settings modal + Route/Reset/Quiz topbar buttons.
   See adr/routing/NEW_ROUTE_FLOW.md for the spec.
   ════════════════════════════════════════════════════════════════════ */

.route-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 1100;                          /* above leaflet controls (1000) */
  background: var(--c-surface);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow-panel);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--c-text-primary);
  max-height: 70vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.route-panel__title {
  /* Typography comes from .t-h6 on the element. Keep only layout here. */
  margin: 0 0 14px;
}

.route-panel__section { margin-bottom: 14px; }
.route-panel__section:last-of-type { margin-bottom: 0; }

.route-panel__section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.route-panel__section-title {
  /* Apply .t-body-md (Body md-semibold) via the HTML class. */
  color: var(--c-text-primary);
}
.route-panel__hint {
  /* Apply .t-body-xsm via the HTML class. Layout/colour only here. */
  margin: 0 0 10px;
  color: var(--c-text-secondary);
}

.route-panel__waypoint {
  display: flex; align-items: center; gap: var(--ctrl-gap);
  padding: var(--ctrl-pad-y) var(--ctrl-pad-x);
  border: 1px solid var(--c-input-border);
  border-radius: var(--ctrl-radius);
  background: var(--c-input-bg);
  margin-bottom: 8px;
  position: relative;
}
.route-panel__waypoint:nth-child(3)::before {
  /* connecting line between A and B inputs */
  content: "";
  position: absolute;
  left: 22px;
  top: 100%;
  height: 8px;
  width: 1px;
  background: var(--c-divider);
}
.route-panel__waypoint-badge {
  /* Letter A/B inside circle. Glyph; sized by .t-body-xsm.t-semibold via HTML. */
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  color: #fff;
  flex-shrink: 0;
}
.route-panel__waypoint-badge--a { background: var(--c-accent); }
.route-panel__waypoint-badge--b { background: var(--c-waypoint-b); }
.route-panel__waypoint-input {
  /* Apply .t-body-md via HTML. Default UI text. */
  flex: 1;
  border: none;
  background: transparent;
  color: var(--c-text-primary);
  outline: none;
  min-width: 0;                         /* allow flex shrink in narrow viewports */
}
.route-panel__waypoint-input::placeholder { color: var(--c-text-placeholder); }

.route-panel__toggle {
  display: flex; align-items: center; gap: var(--ctrl-gap);
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
}
.route-panel__toggle input { display: none; }
.route-panel__toggle-track {
  position: relative;
  width: 36px; height: 20px;
  background: var(--bg-toggle-off);
  border-radius: 999px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.route-panel__toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-thumb);
  transition: transform 0.15s;
}
.route-panel__toggle input:checked + .route-panel__toggle-track { background: var(--c-accent); }
.route-panel__toggle input:checked + .route-panel__toggle-track .route-panel__toggle-thumb { transform: translateX(16px); }
.route-panel__toggle-label { color: var(--c-text-primary); }      /* .t-body-md via HTML */

.route-panel__length-header {
  display: flex; align-items: baseline; gap: 6px;
  margin-bottom: 6px;
}
.route-panel__length-header .route-panel__section-title { margin-right: auto; }
.route-panel__length-unit { color: var(--c-text-secondary); }     /* .t-body-xsm via HTML */
.route-panel__length-value {
  /* Apply .t-body-sm via HTML. */
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border: 1px solid var(--c-input-border);
  border-radius: var(--ctrl-radius-sm);
  text-align: center;
}
.route-panel__slider {
  --slider-fill: 26%;                   /* updated by JS to mirror current value */
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--c-accent) 0%,
    var(--c-accent) var(--slider-fill),
    #1f2937 var(--slider-fill),
    #1f2937 100%);
  outline: none;
}
.route-panel__slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid #fff;
  box-shadow: var(--shadow-thumb);
  cursor: pointer;
}
.route-panel__slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid #fff;
  box-shadow: var(--shadow-thumb);
  cursor: pointer;
}

.route-panel__actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 14px;
}
.route-panel__actions[hidden] { display: none; }
.route-panel__btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--ctrl-radius);
  /* Button label uses .t-body-md via inner span (per skill) */
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, opacity 0.12s;
}
.route-panel__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.route-panel__btn--primary {
  background: var(--c-accent);
  color: #fff;
}
.route-panel__btn--primary:hover:not(:disabled) { background: var(--c-accent-hover); }
.route-panel__btn--secondary {
  background: #fff;
  color: var(--c-text-primary);
  border-color: var(--c-input-border);
}
.route-panel__btn--secondary:hover:not(:disabled) { background: var(--bg-control-hover); }

/* ── Map markers: A/B route pins + brand-orange POI dots ──
   Leaflet's default `leaflet-div-icon` background+border is suppressed
   because we pass our own className on the divIcon (no leaflet-div-icon
   added when className is set explicitly). */
/* Teardrop A/B pins.
   Built from SVG so the tip is sharp and aligns exactly with the GPS
   coordinate (Leaflet iconAnchor at [16, 40] = tip). The bulb's fill
   uses `currentColor`, set per kind via the wrapper class — keeps colour
   selection in CSS rather than in JS-generated SVG attributes.
   The wrapper drops Leaflet's default white bg/border via filter:none
   on .leaflet-div-icon (none added when className is provided). */
.route-pin {
  width: 32px;
  height: 40px;
  filter: drop-shadow(var(--shadow-pin));
  background: transparent;
  border: 0;
  line-height: 0;
}
.route-pin--start { color: var(--c-accent); }
.route-pin--end   { color: var(--c-waypoint-b); }
.route-pin__letter {
  /* SVG glyph exception (see SKILL.md "Hard rules" — graphic icons are
     a recognised exception to the no-raw-font-size rule). The letter
     here lives inside an <svg><text> element generated in app.js, not
     in HTML body text. Keep these values aligned with .t-body-sm size
     and Lexend bold weight to feel consistent with the design system. */
  fill: #fff;
  font-weight: var(--t-weight-bold);
  font-size: var(--t-body-sm-size);
  font-family: var(--t-font-heading);
}

.poi-marker {
  /* Number is wrapped in a <span class="t-body-xsm t-semibold"> inside the
     divIcon html (set in app.js renderPlaces). Marker class owns shape. */
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--c-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-marker);
  text-align: center;
  line-height: 1;
}

/* Small discovery dots for DB nodes on the map (loadDbNodes in app.js). */
.db-place-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6ab0f5;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
/* Visited nodes stay on the map but read as "seen": an inactive grey instead
   of the active blue (#292). Kept fully opaque with the white ring so the grey
   is legible on any basemap (a translucent blue dot was nearly invisible and
   still read as "active"). They are still excluded from generated routes
   server-side, so a greyed dot never re-enters a track route. */
.db-place-dot--visited {
  background: #9aa3ad;
  border-color: #fff;
  box-shadow: none;
}

/* ── Route panel loader + overlay (shown during /api/generate-route) ──
   Overlay is a semi-transparent layer over the entire panel that swallows
   pointer events on every control during the XHR. The loader sits with
   higher z-index so the spinner + text remain visible above the overlay. */
.route-panel__loader {
  /* Loader text uses .t-body-sm via the HTML span. Layout/colour only here. */
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--c-text-secondary);
  position: relative;
  z-index: 6;
}
.route-panel__overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  z-index: 5;
  cursor: progress;
}
.route-panel.is-loading .route-panel__overlay { display: block; }
.route-panel.is-loading .route-panel__loader  { display: flex; }
.route-panel__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-input-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: route-panel-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes route-panel-spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive: landscape & wider viewports ──
   Panel stays anchored to the bottom and full-width. We just trim padding
   and cap content max-width so the form doesn't stretch into one ugly
   1-row strip on landscape phones / tablets. */
@media (orientation: landscape) and (max-height: 500px) {
  .route-panel { max-height: 80vh; padding-top: 12px; padding-bottom: calc(12px + var(--safe-bottom)); }
}
@media (min-width: 768px) {
  .route-panel { padding-left: 24px; padding-right: 24px; }
  .route-panel__title,
  .route-panel__section,
  .route-panel__actions { max-width: 720px; margin-left: auto; margin-right: auto; }
}

/* ════════════════════════════════════════════════════════════════════
   MAIN FLOW redesign — Figma "- main flow" page (node 2056:240)
   Top bar (logo + centered resource counter + avatar + tabs),
   centered map hint, restyled leaflet waypoint popup as cf-popover,
   restructured bottom-sheet route panel.
   Layout glue only — all visual primitives come from component-library.css.
   ════════════════════════════════════════════════════════════════════ */

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

/* ── App top bar · viewport-placement shell ──────────────────────────────
   The locked cf-top-bar component owns ALL of its internal layout (horizontal
   padding, counter centering, row heights) through its variants — Index,
   Type=Navigation (quiz), Goals. The app only needs to PLACE the bar in the
   viewport: stretch it edge-to-edge and carry the status-bar / notch inset.
   Those two concerns live here on a wrapper, never on the component, so they
   can't collide with the component's own `padding` shorthand. (That collision
   was the original bug: the app's safe-area `padding-top` fought the library's
   `.navigation` padding reset at equal specificity, so entering a quiz zeroed
   the inset and the whole bar jumped up.)
   The shell is a normal in-flow flex item in the body column and `.map-wrap`
   (flex:1) takes the rest — so the differing heights of the Index (2-row) vs
   Navigation/Goals (1-row) states need NO magic clearance offset on the map. */
.app-top-bar-shell {
  flex-shrink: 0;
  position: relative;                                /* positioned → z-index applies */
  z-index: 1100;                                     /* bar shadow paints over the top sheet (1000) */
  background: var(--surface-background);             /* fills the safe-area strip above the bar */
  /* iOS: opaque status bar in the safe area → real inset (~44). Browser /
     Android-without-notch: env() is 0 → small fallback so the icon row isn't
     flush against the very top edge. */
  padding-top: max(var(--safe-top), var(--scale-200));
}
/* The published bar is locked to the 393 mobile frame; fill the shell width.
   No variant sets `width`, so this never competes with one. */
.app-top-bar-shell > .cf-top-bar { width: 100%; }
/* Avatar rendered as a <button> — strip default button chrome */
.app-avatar-btn {
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
       appearance: none;
}
.app-avatar-btn:focus-visible {
  outline: var(--border-w-md) solid var(--border-focus);
  outline-offset: var(--scale-50);
}

/* No clearance offset needed: the top-bar shell is an in-flow flex item in the
   body column and .map-wrap (flex:1, see above) consumes the remaining height.
   This self-adjusts to the Index (2-row) vs Navigation/Goals (1-row) bar
   heights — replacing the old hard-coded 94px calc that broke when the tabs
   row was hidden. */

/* ── Map hint (Figma frame 2100:2414) ─────────────────────────────── */
/* Position fixed against the viewport. With the top sheet always visible
   now, the visible map area is the slice below the sheet — `top` is set
   by JS each render to the centre of that slice (see _refreshMainFlow).
   Default fallback: 50% so the pill is still vaguely centred if JS hasn't
   measured yet. */
.app-map-hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 600;                                       /* above leaflet (≤500), below sheet */
  pointer-events: none;
  white-space: nowrap;
}
.app-map-hint[hidden] { display: none; }

/* ── Top sheet route panel (cf-top-sheet, library symbol 424:2814) ──
   Inherits padding (pt-24 px-24 pb-12), rounded bottom corners (radius/xlg),
   Elevation/sm shadow, and the slot/handle layout from the canonical
   cf-top-sheet. We only override the locked 393-px width and add fixed
   positioning under the top bar.

   `.cf-top-sheet.app-top-sheet` (double-class) beats the library's own
   `.cf-top-sheet { width: 393px }` at equal specificity since
   component-library.css loads after style_v2.css; without this the sheet
   would stay locked to 393 on wider mobile viewports.

   `bottom: auto; height: auto; border-radius` overrides defeat the legacy
   `.route-panel { bottom: 0; border-top-*-radius: 16 }` rule (the class is
   still on this element for back-compat). */
.cf-top-sheet.app-top-sheet {
  position: fixed;
  left: 0; right: 0;
  top: calc(94px + max(var(--safe-top), var(--scale-200)));
  bottom: auto;
  height: auto;
  width: 100%;
  z-index: 1000;
  border-top-left-radius:  var(--radius-none);
  border-top-right-radius: var(--radius-none);
  border-bottom-left-radius:  var(--radius-xlg);
  border-bottom-right-radius: var(--radius-xlg);
  /* When the slot grows tall enough to fill the viewport, scroll inside
     the slot — never inside .cf-top-sheet itself (the library transitions
     padding + gap when collapsing, which jitters if the host scrolls).
     `overflow: visible` retires the legacy `.route-panel { overflow-y: auto }`
     that contradicted this: it clipped both the drag handle's 44-px tap target
     and the waypoint dropdown at the sheet's bottom edge. */
  overflow: visible;
  max-height: calc(100vh - 94px - max(var(--safe-top), var(--scale-200)));
  transition: transform 0.24s ease,
              padding-top 200ms ease,
              padding-bottom 200ms ease,
              gap 200ms ease;
}
.cf-top-sheet.app-top-sheet .cf-top-sheet-slot {
  overflow-y: auto;
  /* Anchor thumb visually overflows the sheet by ~8 px — clip horizontally. */
  overflow-x: hidden;
}
/* Hidden state no longer used — the new flow keeps the top sheet on
   screen at all times (Figma frames 2100:2414 etc.). Kept here as a
   no-op fallback in case anything still flips the class. */
.cf-top-sheet.app-top-sheet.app-sheet-hidden { transform: none; pointer-events: auto; }
.app-sheet-body {
  display: flex;
  flex-direction: column;
  gap: var(--scale-500);                              /* 20 — Figma column gap */
}
.app-sheet-section {
  display: flex;
  flex-direction: column;
  gap: var(--scale-400);                              /* 16 between rows inside a section */
}

/* Waypoints header was removed (Figma frames 2100:2395/2401 deleted the
   "Your route" title and moved the swap button to float over the fields).
   The element kept around as #routePanelWaypointsTitle is sr-only/hidden
   solely for the i18n localiser. */
.app-state-form[hidden],
.app-state-summary[hidden] { display: none; }

/* The rest of the planner (A/B fields + Start-route action), revealed once a
   route flow starts. Hidden on the fresh screen where only the length chips
   show (REDESIGN_ROUTE_PLANNER.md First screen §1). Same column rhythm as the
   sheet body so the revealed sections keep the Scale/500 spacing. */
.app-adjust-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--scale-500);
}
.app-adjust-wrap[hidden] { display: none; }

/* Waypoints header was removed; the route length block is the form's only
   content now, so no explicit inter-block gap is needed. */
.app-state-form {
  display: flex;
  flex-direction: column;
  gap: var(--scale-400);
}

/* Summary block (Figma frame 2093:1334 — Route length / Walking time /
   City quiz columns laid out across the sheet with space-between). */
.app-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--scale-300);
}
.app-summary-cell {
  display: flex;
  flex-direction: column;
  gap: var(--scale-0);
  min-width: 0;
}
.app-summary-label {
  color: var(--text-label);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-regular);
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line-height);
}
/* Summary value row: each number sits next to its measurement on the same
   typography baseline (so "6" and "km" share their bottom edge). The gap
   between every number / icon and its measurement is Scale/100 (4). For
   walking time, two (num + unit) pairs are nested so each pair is glued
   with the 4-px gap and the two pairs separate by a normal flex gap. */
.app-summary-value {
  display: inline-flex;
  align-items: baseline;
  gap: var(--scale-100);                              /* 4 — between num & unit / pair & pair */
  height: var(--scale-800);                           /* 32 — Figma value line */
  color: var(--text-headings);
}
.app-summary-pair {
  display: inline-flex;
  align-items: baseline;
  gap: var(--scale-100);                              /* 4 between this pair's num & unit */
}
.app-summary-num {
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-body-lg-size);                /* 20 */
  line-height: var(--text-body-lg-line-height);       /* 32 */
}
.app-summary-unit {
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-regular);
  font-size: var(--text-body-sm-size);                /* 14 */
  line-height: var(--text-body-sm-line-height);       /* 16 */
  color: var(--text-label);
}
.app-summary-value-quiz {
  display: inline-flex;
  /* center-align here (NOT baseline): the Phosphor check is an inline-block
     glyph with no real text baseline, so baseline-alignment lets it drop
     to the bottom of its box and sit visually below the "included" text.
     Centring both children inside the 32-px value line keeps the check
     and the label optically on the same horizontal line. */
  align-items: center;
  gap: var(--scale-100);                              /* 4 between check and "included" */
  height: var(--scale-800);
  color: var(--text-label);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-regular);
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line-height);
}
.app-summary-quiz-icon {
  font-size: var(--scale-400);                        /* 16 — matches Figma 16×16 check */
  color: var(--text-body);
  line-height: 1;
}
/* When city quiz is OFF, hide the check and just show "not included" */
.app-summary-quiz-icon[hidden] { display: none; }
.app-state-summary {
  display: flex;
  flex-direction: column;
  gap: var(--scale-500);                              /* 20 between summary and Generate btn */
}

/* Swap btn-disabled handling (still applies once both points are picked
   it un-disables). Reset is now a full text button inside the action row
   — sized by cf-btn lg, not by these rules. */
#swapBtn[hidden] { display: none; }
#swapBtn:disabled { opacity: 0.5; }

/* State-4 action row (Figma frame 2100:2401 → 2100:3167): primary
   Generate route flexes to fill the row, outlined Reset is content-width,
   gap Scale/400 (16) between them. */
.app-state-actions {
  display: flex;
  gap: var(--scale-400);
  align-items: stretch;
  width: 100%;
}
/* `display: flex` on the class otherwise beats the browser's default
   `[hidden] { display: none }`. Explicit override so JS can hide the row
   in pre-state-4 (only one or no waypoints picked). */
.app-state-actions[hidden] { display: none; }
.app-state-actions .app-generate-btn { flex: 1 1 0; min-width: 0; }

/* Waypoints fields stack with vertical connector dots.
   `position: relative` anchors the absolutely-positioned swap button that
   now floats on the right between the two field rows. */
.app-waypoints-fields {
  display: flex;
  flex-direction: column;
  gap: var(--scale-400);                              /* 16 between A and B */
  position: relative;
}
/* Swap A/B button — overlay on the right, vertically centred on the gap
   between Field A and Field B (Figma frame 2100:2395 button at slot
   left=309 / top=38). Surface/page background (cf-btn outlined ships
   `background: transparent` so the 3-class selector beats it) — gives the
   chip a solid surface on top of the field column. */
.cf-btn.outlined.app-swap-btn {
  position: absolute;
  top: calc(var(--scale-1100) + var(--scale-400) / 2);/* field-A height (44) + half the 16-gap = 52 */
  right: var(--scale-200);                            /* 8 — matches Figma right inset */
  transform: translateY(-50%);
  z-index: 2;                                         /* lifts above both fields */
  background: var(--surface-page);
  width: var(--scale-700);
  height: var(--scale-700);
  padding: 0;
  gap: 0;
}
.app-waypoint-field { gap: var(--scale-200); min-width: 0; }
/* Editable text input inside the Field/Dropdown — type an address (autocomplete)
   or pick "My location" from the dropdown. Transparent so the cf-field border
   shows through. */
.app-waypoint-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text-body);
  font-family: inherit;
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line-height);
}
.app-waypoint-input::placeholder { color: var(--text-label-light); }
/* type="search" lets us opt out of Chrome credential/address autofill, but it
   adds a native "clear" affordance + iOS rounding — strip both so only our
   custom .app-field-clear X shows and the field stays flat. */
.app-waypoint-input { -webkit-appearance: none; appearance: none; }
.app-waypoint-input::-webkit-search-cancel-button,
.app-waypoint-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
/* Clear (X) button on the right — shown only when the field has a value. */
.app-field-clear {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--scale-500);
  height: var(--scale-500);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--icon-label);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.app-field-clear:hover  { color: var(--icon-default); }
.app-field-clear[hidden] { display: none; }
.app-field-clear .ph { font-size: var(--scale-500); line-height: 1; }
/* "My location" / address dropdown spans the full field width (Figma 345) —
   the extra class beats the library's fixed .cf-menu width (247).

   Positioning is the library's own `.cf-combobox-menu` (absolute, top: 100% +
   Scale/100), so the menu always hangs DIRECTLY under its field and rides with
   it — no viewport measuring. An earlier attempt pinned it to the field with
   position:fixed and JS coordinates; iOS moves the coordinate frame of fixed
   elements while the soft keyboard is up, so the menu drifted off its field.
   What made the popup need escaping in the first place is the sheet clipping
   it — that is handled by .app-menu-open below instead. */
.cf-menu.app-waypoint-menu {
  width: 100%;
  z-index: 20;                        /* over the sibling field + the A/B connector (2) */
  /* Fallback cap only — app.js::_capWaypointMenuHeight owns max-height and
     narrows it to the room actually left under the field. */
  max-height: calc(var(--scale-1400) * 5);  /* 5 rows; the rest scrolls */
  overflow-y: auto;
  overscroll-behavior: contain;       /* scrolling the list must not scroll the map */
  box-shadow: var(--shadow-sm);       /* Elevation/sm — it overhangs the sheet now */
}
.app-waypoint-menu[hidden] { display: none; }

/* While a waypoint dropdown is open the slot must not clip it: the menu hangs
   past the sheet's bottom edge onto the map. The slot is the sheet's safety
   valve when the planner outgrows the viewport, so its scrolling is only
   suspended for as long as the menu is up. app.js::_syncSheetMenuState owns
   the class. */
.route-panel.app-menu-open .cf-top-sheet-slot { overflow: visible; }
/* Tip line under the fields ("Tap on the map to pick a point"). */
.app-waypoint-hint { display: block; }
/* Field group (fields + tip) uses an 8-px gap (Figma 2399:7236 Frame 4),
   tighter than the 16-px default between sheet-section rows. */
.app-waypoints-section { gap: var(--scale-200); }
/* The dotted A↔B connector only renders when the destination field is shown
   (Loop route OFF). `.app-waypoint-connector` sets display:flex, so an explicit
   [hidden] guard is needed to override it. */
.app-waypoint-connector[hidden] { display: none; }
.app-waypoint-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--scale-500);                            /* 20 */
  height: var(--scale-500);
  border-radius: var(--radius-round);
  color: var(--text-on-color);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-regular);
  font-size: var(--text-body-md-size);
  line-height: 1;
  flex-shrink: 0;
}
.app-waypoint-badge--a { background: var(--icon-start-point); }
.app-waypoint-badge--b { background: var(--icon-destination); }

/* Vertical "dotted" connector between A and B fields.
   Centered on the badge: cf-field has 1-px border + padding-left Scale/300
   (12) and the badge is Scale/500 (20) wide → badge horizontal centre sits
   at 1 + 12 + 10 = 23 from the field's left edge. translateX(-50%)
   re-centres the 2-px connector on that line. */
.app-waypoint-connector {
  position: absolute;
  left: calc(var(--border-w-sm) + var(--scale-300) + var(--scale-500) / 2);
  top: calc(var(--scale-1100) + var(--scale-100));    /* below field A (44) + ~4 */
  transform: translateX(-50%);
  width: var(--scale-50);                             /* 2 */
  height: var(--scale-300);                           /* 12 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.app-waypoint-connector span {
  display: block;
  width: var(--scale-50);
  height: var(--scale-100);
  background: var(--neutral-300);
  border-radius: var(--radius-sm);
}

/* Route length section */
.app-length-section { gap: var(--scale-200); }
.app-length-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--scale-300);
}
.app-length-title { color: var(--text-headings); }
.app-length-unit  { color: var(--text-label); }
/* Route length section — title above + chip strip (Figma frame 2100:2414).
   Slider was deleted; chips behave like radios with one selected at a time. */
.app-length-section {
  display: flex;
  flex-direction: column;
  gap: var(--scale-300);                              /* 12 between title and chips */
}
.app-length-chips {
  display: flex;
  gap: var(--scale-200);                              /* 8 between chips */
  width: 100%;
}
.app-length-chips .cf-chip {
  flex: 1 1 0;
  min-width: 0;
  /* Chip label flexes; we center it and only show the check on selected. */
  justify-content: center;
}
/* Keep the trailing check icon mounted on every chip (selected or not) so
   the label doesn't reflow when selection moves between chips. On
   unselected (and hover) the icon is transparent — same Scale/100 gap
   and 16-px glyph, just invisible — so the label stays fixed in place. */
.app-length-chips .cf-chip:not(.is-selected) .app-chip-check,
.app-length-chips .cf-chip:hover:not(.is-selected) .app-chip-check { color: transparent; }
/* (Removed: .app-field-action — the right-side crosshair/clear icon button.
   My-location is now a Menu item on the Field/Dropdown; points are cleared
   via the Reset button.) */
/* Anchor thumb pinned to the start of the track (Figma frames 3 & 4 show a
   range-slider with two orange thumbs; the left one stays at the minimum). */
.app-slider-thumb-anchor { left: 0; }
/* Show the slider fill flush against the left edge so it tucks under the
   anchor thumb (otherwise it starts at the cf-slider 8px inset). */
.app-slider-visual .cf-slider-fill { left: 0; }

/* Generate route primary button — orange, with coin badge on the right.
   The label/cost spans must not wrap (otherwise "Generate route" breaks
   into two lines when sharing the action row with the Reset button). */
.app-generate-btn {
  width: 100%;
  position: relative;
  white-space: nowrap;
}
.app-generate-btn > * { white-space: nowrap; }
/* [hidden] beats cf-btn's display: inline-flex (otherwise the button stays
   visible when JS sets the hidden attribute). */
.app-generate-btn[hidden] { display: none; }

/* Reserve a band over the sheet for the map hint so it doesn't sit behind the
   bottom sheet at the initial state (sheet is visible but pre-route flow). */

/* ── Waypoint popover — plain cf-popover anchored over the map ──── */
/* The element is appended directly into leaflet's map container by JS
   (not as an L.popup), so it carries NO leaflet chrome — single popover
   on screen. JS positions it via map.latLngToContainerPoint() and the
   transform below anchors the popover bottom-center on the click point
   (cf-popover-tail.center hangs 12px further down to touch the point). */
.waypoint-popover {
  position: absolute;
  /* (left/top set inline by JS as map moves) */
  transform: translate(-50%, calc(-100% - var(--scale-300)));
  /* Topmost overlay on the page so it can never be hidden by the top bar
     (1100) or the top sheet (1000) — the popover always belongs above
     everything while it's open. */
  z-index: 2000;
}
.waypoint-popover__slot {
  display: flex;
  flex-direction: column;
  gap: var(--scale-200);                              /* 8 between Set as start / Set as destination */
}
/* Area-unlock prompt (shown instead of A/B when the tapped spot has no points).
   Short explanatory line above the one-line "Unlock · <gem> N" button. */
.waypoint-popup__note {
  font-size: var(--scale-350, 14px);
  line-height: 1.4;
  color: var(--text-secondary, #5b5b5b);
  text-align: center;
}
.waypoint-unlock-gem {                                /* trailing gem icon, matches .cf-card-cta img */
  height: 1.15em;
  width: auto;
  flex-shrink: 0;
  vertical-align: -0.2em;
}
/* "Also for children" checkbox row in the unlock prompt. */
.waypoint-unlock-children {
  display: flex;
  align-items: center;
  gap: var(--scale-200, 8px);
  font-size: var(--scale-350, 14px);
  color: var(--text-secondary, #5b5b5b);
  cursor: pointer;
  user-select: none;
}
.waypoint-unlock-children input { flex-shrink: 0; margin: 0; }
/* Action button — full-width md outlined. Reset the cf-btn default
   centering so the badge sits flush-left while the label remains
   centered with the icon (matches Figma popover buttons). */
.waypoint-popup__btn {
  width: 100%;
  justify-content: center;
  gap: var(--scale-300);
  white-space: nowrap;                                /* "Set as destination" must fit on one line */
}
.waypoint-popup__btn > span { white-space: nowrap; }
.waypoint-popup__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--scale-500);                            /* 20 */
  height: var(--scale-500);
  border-radius: var(--radius-round);
  color: var(--text-on-color);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-regular);
  font-size: var(--text-body-md-size);
  line-height: 1;
  flex-shrink: 0;
}
.waypoint-popup__badge--a { background: var(--icon-start-point); }
.waypoint-popup__badge--b { background: var(--icon-destination); }

/* ── Profile modal — feedback + sign-out moved out of the top bar ─ */
.app-profile-secondary {
  display: flex;
  flex-direction: column;
  gap: var(--scale-200);
  margin-top: var(--scale-500);
  padding-top: var(--scale-400);
  border-top: var(--border-w-sm) solid var(--border-subtle);
}
.app-profile-secondary .cf-btn { justify-content: flex-start; }

/* ─── Goals mode (profile → map: pick or review a goal) ──────────────────────
   Driven by body.goals-mode. Strips the route-planner chrome down to a clean
   map with a "‹ Goals" header; pick mode adds a bottom "Set as goal" bar. */
/* Hidden outside goals mode. The :not() bumps specificity above the library's
   `.cf-top-bar .cf-top-bar-row { display:flex }` (loaded after this file), which
   would otherwise keep the row visible on the normal map. */
body:not(.goals-mode) .goals-mode-row { display: none; }
body.goals-mode .app-top-bar > .cf-top-bar-row:not(.goals-mode-row),
body.goals-mode .app-top-bar > .app-tabs-row { display: none; }
/* The header IS the library Nav bar component: enterGoalsMap toggles `.nav-bar`
   on the app top bar, so padding (8), row height (44), white surface + hairline
   divider and the back·title·action `space-between` layout all come from
   `.cf-top-bar.nav-bar`. The trailing slot has no action button — an empty
   spacer mirroring the 28-px ghost-icon back button keeps the title centred. */
.cf-top-bar-nav-spacer { width: var(--scale-700); flex-shrink: 0; }
/* Match the shell's safe-area strip to the Nav bar's white surface (no seam). */
body.goals-mode .app-top-bar-shell { background: var(--surface-page); }
body.goals-mode .leaflet-control-container { display: none !important; }

/* The normal map-tabs view (route-planner sheet, map hint, Featured + Scheduled
   tab panels) is a single layer, tagged `.map-tab-layer`. Any full-screen
   surface that takes over the map hides the whole layer in ONE place — add the
   class to a new panel and it is covered everywhere, with no per-mode ID list to
   keep in sync. Visibility of an individual tab stays owned by its `hidden`
   attribute (the tab-group functions), so leaving the takeover restores whatever
   tab was open without re-introducing the overlap. */
body.goals-mode         .map-tab-layer,
body.onboarding-mode    .map-tab-layer,
body.schedule-area-mode .map-tab-layer,
body.spa-screen-open    .map-tab-layer { display: none !important; }

.goals-confirm-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
  padding: var(--scale-400);
  padding-bottom: calc(var(--scale-400) + var(--safe-bottom));
  background: var(--surface-page);
  border-top: var(--border-w-sm) solid var(--border-subtle);
  display: flex;
}
.goals-confirm-bar[hidden] { display: none; }
.goals-confirm-bar .cf-btn { width: 100%; }

/* City shield markers in goals mode (Leaflet divIcon): heraldic shield + a
   name pill below. Selected (pick) → peach tint; current goal (review) →
   green. Mirrors the profile/Figma shield language. */
/* Map marker = thin placement wrapper around the library Goal progress tracker
   (.cf-goal-tracker.md). No glows/halos and no custom shield/label CSS — the
   component owns every visual (orange/gray shield, coat, progress ring, chip). */
.goal-coat-marker { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.goal-coat-marker.is-readonly { cursor: default; }

/* ─── Onboarding flow ───────────────────────────────────────────────────────
   Step 1 (Welcome) = a full-screen modal inside .onboarding-overlay: kill the
   overlay's centering padding + the card max-height so it truly fills. Steps
   2–3 reveal the real #map with onboarding chrome (body.onboarding-mode),
   reusing the goals-mode chrome-strip approach. */
.cf-modal-overlay.onboarding-overlay { padding: 0; }
.onboarding-overlay .cf-modal.full-screen { max-height: none; }
.onboarding-overlay[hidden] { display: none !important; }
/* Welcome content is a form column (not the demo's edge-to-edge image slot). */
.onb-welcome-content { display: flex; flex-direction: column; gap: var(--scale-500); padding: 0 var(--scale-600); }

/* Steps 2–3: strip the route-planner shell so only the map + onboarding
   header/CTA show (mirrors body.goals-mode). */
body.onboarding-mode .app-top-bar-shell,
body.onboarding-mode .leaflet-control-container { display: none !important; }

/* Onboarding map chrome (#onboarding-map-ui): header pinned top, CTA pinned
   bottom; the empty middle passes taps through to the map underneath. z above
   the map, below the welcome/success toasts. */
#onboarding-map-ui { position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column; pointer-events: none; }
#onboarding-map-ui[hidden] { display: none; }
#onboarding-map-ui > * { pointer-events: auto; }
.onb-map-topbar, .onb-map-header { background: var(--surface-page); flex-shrink: 0; }
/* Keep the skip ("Not now") pinned to the right regardless of whether the
   step-dependent Back button occupies the left slot (#293/#295). */
.onb-map-skip { margin-left: auto; }
.onb-map-actions {
  margin-top: auto;
  padding: var(--scale-600);
  padding-bottom: calc(var(--scale-600) + var(--safe-bottom));
}
.onb-map-actions .cf-btn { width: 100%; }

/* Status badge on a city shield: is-locked (orange +) = a not-yet-unlocked
   city; is-selected (green ✓) = the city selected on the current onboarding
   step. Unlocked cities carry no badge — their coloured coat is the signal. */
.cf-goal-head { position: relative; }
.cf-coat-badge {
  position: absolute; top: -2px; right: -2px;
  width: var(--scale-500); height: var(--scale-500);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.cf-coat-badge.is-locked   { background: var(--surface-action); }
.cf-coat-badge.is-selected { background: var(--icon-success, #2e9e5b); }

/* Normal-map city shield popup (unlock / set-target), rendered as a DS Popover.
   The .cf-popover frame carries its own surface, radius, shadow and tail, so we
   strip Leaflet's default bubble chrome and let the DS component show through. */
.city-coat-cf-popup .leaflet-popup-content-wrapper { background: transparent; box-shadow: none; padding: 0; border-radius: 0; }
.city-coat-cf-popup .leaflet-popup-content { margin: 0; width: auto !important; }
.city-coat-cf-popup .leaflet-popup-tip-container,
.city-coat-cf-popup .leaflet-popup-close-button { display: none; }
.city-coat-popup-note { font-size: 13px; color: var(--text-label); margin: -4px 0 8px; }
.city-coat-popup-btn { width: 100%; }
.city-coat-popup-btn + .city-coat-popup-btn { margin-top: 8px; }
/* Inline gem asset inside the unlock label — sized to the button text (0.8rem)
   so it replaces the old 💎 emoji at the same visual scale. */
.city-coat-popup-gem { width: 1.15em; height: 1.15em; vertical-align: -0.2em; }

/* Registration home-city live note (which city gets unlocked free). */
#profile-home-city-note { display: block; margin-top: 4px; }
.cf-ok-msg   { color: var(--text-success); font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height); }
.cf-note-msg { color: var(--text-label);   font-size: var(--text-body-xsm-size); line-height: var(--text-body-xsm-line-height); }

/* Granted city inside the first-city unlock modal — a link that recenters the
   map (same action as the CTA). */
.first-city-link { color: var(--text-action); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ── Route-complete screen (Figma 3944:1826 / 3946:3699) ───────────────────
   Full-screen success state after "Finish route". The chrome is the library
   .cf-modal.full-screen inside the standard .cf-modal-overlay; everything
   below is the app-specific content slot Figma draws inside that component's
   Slot, so there is no library class to reuse for it.
   Both Figma variants share this markup — only the answers subline differs. */
.cf-modal-overlay.route-finish-overlay { padding: 0; }
.route-finish-overlay .cf-modal.full-screen {
  max-height: none;
  /* The design has no bottom action row, so the component's 40px safe-area
     reservation would only push the (already centered) slot off-centre. */
  padding-bottom: 0;
  gap: var(--scale-600);
  padding-top: var(--scale-600);
}
/* Slot: stretches to fill and centres its column, exactly like the Figma
   Slot (flex-1, justify-center, px-24, gap-24). */
.route-finish-slot {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--scale-600);                       /* 24 */
  width: 100%;
  padding: 0 var(--scale-600);
  overflow-y: auto;
}
.route-finish-illus {
  width: 240px; height: 240px;                  /* published slot size — off-Scale */
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 0;
}
.route-finish-heading {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--scale-200);                       /* 8 */
  width: 100%;
}
.route-finish-title {
  font-family: var(--font-family-headings); font-weight: var(--font-weight-bold);
  font-size: var(--text-h6-size); line-height: var(--text-h6-line-height);
  letter-spacing: var(--text-h6-letter-spacing);
  color: var(--text-body); text-align: center; margin: 0;
}
/* "Custom route · 3 km · 4 stops" — the separator dots are the Bottom-sheet
   stat dots (same 2px Text/Body-light circle), emitted by the renderer. */
.route-finish-meta {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: var(--scale-200);                       /* 8 */
  margin: 0;
  font-family: var(--font-family-text); font-weight: var(--font-weight-regular);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-body-light);
}
/* Steps card */
.route-finish-steps {
  width: 100%;
  display: flex; flex-direction: column;
  gap: var(--scale-300);                       /* 12 */
  padding: var(--scale-400);                   /* 16 */
  border-radius: var(--scale-200);             /* 8 — Figma uses the Scale token here */
  background: var(--surface-background);
}
.route-finish-steps[hidden] { display: none; }
.route-finish-steps-count {
  display: flex; align-items: center; justify-content: center;
  gap: var(--scale-400);                       /* 16 */
  margin: 0;
  font-family: var(--font-family-headings); font-weight: var(--font-weight-bold);
  font-size: var(--text-h3-size); line-height: var(--text-h3-line-height);
  letter-spacing: var(--text-h3-letter-spacing);
  color: var(--text-body); text-align: center;
}
.route-finish-steps-count i { font-size: var(--scale-800); color: var(--icon-information); }  /* 32 */
.route-finish-steps-note {
  margin: 0; text-align: center;
  font-family: var(--font-family-text); font-weight: var(--font-weight-regular);
  font-size: var(--text-body-ml-size); line-height: var(--text-body-ml-line-height);
  color: var(--text-body);
}
/* Outcome rows — seamless list, hairline between rows (Figma: py-16, no gap,
   Border/Subtle bottom on every row but the last). */
.route-finish-rows { list-style: none; margin: 0; padding: 0; width: 100%; }
.route-finish-row {
  display: flex; align-items: center;
  gap: var(--scale-400);                       /* 16 */
  padding: var(--scale-400) 0;                 /* 16 */
}
.route-finish-row + .route-finish-row { border-top: var(--border-w-sm) solid var(--border-subtle); }
.route-finish-row[hidden] { display: none; }
.route-finish-row-icon {
  width: var(--scale-1000); height: var(--scale-1000);   /* 40 */
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--radius-round);
  background: var(--surface-background);
}
.route-finish-row-icon.is-check i { font-size: var(--scale-600); color: var(--icon-success); }  /* 24 */
.route-finish-row-text { display: flex; flex-direction: column; gap: var(--scale-100); min-width: 0; }
.route-finish-row-title {
  font-family: var(--font-family-headings); font-weight: var(--font-weight-bold);
  font-size: var(--text-h7-size); line-height: var(--text-h7-line-height);
  letter-spacing: var(--text-h7-letter-spacing);
  color: var(--text-body);
}
.route-finish-row-sub {
  font-family: var(--font-family-text); font-weight: var(--font-weight-regular);
  font-size: var(--text-body-sm-size); line-height: var(--text-body-sm-line-height);
  color: var(--text-body-light);
}

/* ─── City goal (Top bar · Index with city goal) ─────────────────────────────
   #goalPill is the library City progress pill rendered as a <button>
   (js/city-goal.js). Only button-chrome reset + state plumbing live here; every
   visual (ring, crest filter, set-goal dashed border) is the library's. The
   pill carries BOTH crests statically; the state class picks one. */
.app-goal-pill {
  border: 0;                         /* .cf-city-pill.set-goal re-adds its dashed border (higher specificity) */
  cursor: pointer;
  font: inherit;
  -webkit-appearance: none;
       appearance: none;
}
.app-goal-pill[hidden] { display: none; }   /* library inline-flex would beat the UA [hidden] */
.app-goal-pill.set-goal .app-goal-pill-coat,
.app-goal-pill:not(.set-goal) .app-goal-pill-empty { display: none; }
.app-goal-pill:focus-visible {
  outline: var(--border-w-md) solid var(--border-focus);
  outline-offset: var(--scale-50);
}

/* Goals-map intro — library Top sheet laid over the top of the map (inside
   .map-wrap, so it sits right under the Nav bar without a height offset).
   Only exists in goals mode. z above Leaflet panes/popups (≤ 700). Double
   class: component-library.css loads after this file and its
   `.cf-top-sheet { display:flex }` would otherwise win. */
.cf-top-sheet.goals-info-sheet {
  display: none;
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 1000;
}
body.goals-mode .cf-top-sheet.goals-info-sheet { display: flex; }
.goals-info-text { margin: 0; color: var(--text-body); }

/* ─── City reached modal (Modal · With bigger illustration) ──────────────────
   Layout/typography come from .cf-modal.with-illustration.bigger. This block
   only builds the live illustration in the 120-tall picture slot (Figma
   4211:2620): purple halo + two counter-rotating ray layers that drift and
   shimmer, a white disc whose green ring fills clockwise 0→100 % on open, the
   city crest on top — plus a confetti shower over the whole modal. Sizes are
   the published illustration's (off-Scale by intent). */
.goal-reached-art {
  position: relative;
  overflow: visible;                 /* halo/rays (≈172) are larger than the 120 slot */
}
.goal-reached-art > * {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
.goal-reached-halo {
  width: 172.8px; height: 172.8px;
  animation: goal-halo-breathe 3.2s ease-in-out infinite alternate;
}
.goal-reached-rays {
  width: 171.6px; height: 171.6px;
  animation: goal-rays-spin 40s linear infinite,
             goal-rays-shimmer 2.8s ease-in-out infinite alternate;
}
/* Second ray layer: offset by half a ray gap (12 rays → 15°), turning the
   other way, out of phase — where the layers cross the rays "flow". */
.goal-reached-rays.is-counter {
  animation: goal-rays-spin-rev 56s linear infinite,
             goal-rays-shimmer 3.6s ease-in-out -1.8s infinite alternate;
}
.goal-reached-ring {
  width: 96px; height: 96px;
  overflow: visible;
  filter: drop-shadow(0 0 9.6px rgba(165, 102, 255, 0.14));   /* Figma purple glow */
}
.goal-reached-ring-disc { fill: var(--surface-page); }
.goal-reached-ring-fill {
  fill: none;
  stroke: var(--border-success-green);       /* #16B364 — same green as the City progress pill */
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-dasharray: 100;                     /* pathLength=100 */
  stroke-dashoffset: 0;                      /* closed / reduced motion: full ring */
  transform: rotate(-90deg);                 /* start at 12 o'clock; SVG circles run clockwise */
  transform-origin: center;
  transform-box: fill-box;
}
.goal-reached-overlay.is-playing .goal-reached-ring-fill {
  animation: goal-ring-fill 1.6s cubic-bezier(0.4, 0, 0.2, 1) 0.25s both;
}
.goal-reached-crest {
  width: var(--scale-1400); height: var(--scale-1400);   /* 56 */
  object-fit: contain;
}

.goal-reached-confetti {
  /* Figma confetti palette (illustration colours, no semantic tokens). */
  --confetti-1: #fbbf00;
  --confetti-2: #a566ff;
  --confetti-3: #ff5c8a;
  --confetti-4: #3d8bff;
  --confetti-5: var(--primary-default);      /* #fe6930 */
  --confetti-6: #1db46a;
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;                      /* the modal stays tappable underneath */
  z-index: 1;                                /* over the modal */
}
.goal-confetti {
  position: absolute; top: calc(-1 * var(--scale-300)); left: var(--x);
  background: var(--color);
  border-radius: 1.5px;
  opacity: 0;
  animation: goal-confetti-fall var(--dur) cubic-bezier(0.3, 0.5, 0.5, 1) var(--delay) forwards;
}
.goal-confetti.strip { width: var(--scale-100); height: 10px; }
.goal-confetti.chip  { width: var(--scale-200); height: var(--scale-100); }
.goal-confetti.dot   { width: 6px; height: 6px; border-radius: 50%; }

@keyframes goal-ring-fill   { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes goal-rays-spin   { from { transform: translate(-50%, -50%) rotate(0deg); }  to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes goal-rays-spin-rev { from { transform: translate(-50%, -50%) rotate(15deg); } to { transform: translate(-50%, -50%) rotate(-345deg); } }
@keyframes goal-rays-shimmer {
  from { opacity: 0.45; filter: hue-rotate(-18deg) brightness(1); }
  to   { opacity: 1;    filter: hue-rotate(18deg)  brightness(1.25); }
}
@keyframes goal-halo-breathe {
  from { transform: translate(-50%, -50%) scale(0.92); opacity: 0.8; }
  to   { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
}
@keyframes goal-confetti-fall {
  0%   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(calc(var(--drift) * -0.5), 55vh, 0) rotate(calc(var(--spin) * 0.5)); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift), 105vh, 0) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  .goal-reached-halo,
  .goal-reached-rays,
  .goal-reached-overlay.is-playing .goal-reached-ring-fill { animation: none; }
  .goal-reached-rays.is-counter { display: none; }
}

/* ── Team events (adr/product/TEAM_EVENTS.md) ─────────────────────────────── */
/* Captain-only chip in the top bar's wallet slot while a team-event quiz is
   open. body.team-mode hides the resource counter (gems are irrelevant
   mid-race) and the chip flows left in its place. */
body.team-mode .app-top-bar #coinsDisplay { display: none; }
.team-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--scale-200);                        /* 8 */
  padding: var(--scale-200) var(--scale-400);   /* 8 / 16 */
  border-radius: 999px;                         /* pill */
  background: var(--surface-card, #fff);
  font-family: var(--font-family-text);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-line-height);
  color: var(--text-body);
}
.team-badge[hidden] { display: none; }
.team-badge-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #9aa0a6;                           /* neutral until a colour is known */
}
.team-badge--red  .team-badge-dot { background: #e5484d; }
.team-badge--blue .team-badge-dot { background: #3b6fe5; }

/* Penalty countdown overlay: blocking, no close button (markup omits the X). */
.team-penalty-count {
  font-family: var(--font-family-headings);
  font-weight: var(--font-weight-bold);
  font-size: 72px;
  line-height: 1;
  color: var(--text-body);
}
.team-penalty-unit {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Result overlay rides the default translucent cf-modal-overlay backdrop, so
   the route/map stays visible behind it (keep exploring after dismiss). */
.team-result .route-finish-slot { padding-top: var(--scale-600); }
