/* ─────────────────────────────────────────────────────────────────────────
   Walklore — Dusk theme
   Editorial, literary. Warm cream paper, ink, oxblood accent. Newsreader
   serif headlines, Inter body, ink-styled sparks, quiet shadows.
   ───────────────────────────────────────────────────────────────────── */

:root {
  /* Dusk palette */
  --bg:             #F4EFE6;
  --bg-deep:        #EBE3D4;
  --surface:        #FDFAF3;
  --on-bg:          #1C1A17;
  --on-bg-2:        #3A352E;
  --on-bg-3:        #746B5E;
  --on-bg-4:        #A89E8D;
  --border:         #D9CFB8;
  --border-light:   #E6DDC8;
  --accent:         #A03B2E;        /* oxblood */
  --accent-deep:    #7D2A20;
  --accent-soft:    #E8C9BE;
  --accent2:        #3F5B4F;        /* pine */
  --accent2-soft:   #D8E2DC;
  --info:           #34557E;        /* muted editorial blue */
  --info-soft:      #D8E0EA;
  --mark:           #B7872A;        /* warm amber (deeper for legibility) */
  --mark-soft:      #F1E2BE;
  --danger:         #A0362A;
  --danger-bg:      #F4DFD9;
  --success:        #3F5B4F;        /* pine (same family as accent2) */
  --success-bg:     #DDE8E2;

  /* Aliases for legacy walk.css class refs */
  --purple:         var(--accent);
  --purple-dark:    var(--accent-deep);
  --purple-dim:     var(--accent-deep);
  --white:          #FFFFFF;

  --player-h:       82px;
  --nav-h:          64px;
  --header-h:       56px;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);

  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      14px;
  --radius-xl:      22px;
  --radius-pill:    999px;

  --shadow-sm:      0 1px 0 rgba(28,26,23,0.04), 0 0 0 1px rgba(28,26,23,0.04);
  --shadow-md:      0 2px 4px rgba(28,26,23,0.04), 0 10px 30px rgba(28,26,23,0.08);
  --shadow-lg:      0 20px 60px rgba(28,26,23,0.15);

  --font-display:   "Newsreader", "Source Serif Pro", Georgia, serif;
  --font-body:      "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:      "JetBrains Mono", ui-monospace, monospace;
  --font-emoji:     "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

/* Newsreader ships no Cyrillic glyphs, so Russian/Ukrainian text falls
   through to Source Serif Pro (loaded via the font link in index.html).
   Its natural x-height is a hair larger than Newsreader's; applying
   `font-size-adjust` to the serif stack forces every font in the chain
   to render at Newsreader's aspect ratio, keeping mixed Latin/Cyrillic
   lines at the same visual size. Body (Inter) and mono (JetBrains Mono)
   have full Cyrillic and don't need this. */
.hdr-logo,
.auth-title, .auth-subtitle,
.ob-heading, .ob-welcome-sub,
.spark-hero-title, .spark-hero-sub,
.spark-title, .spark-teaser,
.spark-script-preview, .spark-script-full,
.lib-story-lead, .lib-story-script, .lib-story-script > p {
  font-size-adjust: 0.49;
}

/* ── Reset + base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

/* ── Portrait lock for mobile (browser + PWA) ─────────────────────────
   Browsers can only truly lock orientation inside the Fullscreen API. As
   a pragmatic fallback, mobile-sized devices rotated to landscape see a
   "rotate your phone" overlay covering the UI — the layout was designed
   around a ~390 px-wide phone and reflows poorly at 844 px wide + short.
   Tablets (min-height 520 px) are allowed to land in landscape since
   they have room. Desktop is not matched (pointer: fine). */
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate-hint {
    position: fixed; inset: 0;
    z-index: 100000;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 24px;
    background: var(--bg);
    color: var(--on-bg);
    font-family: var(--font-body); font-size: 0.95rem;
    text-align: center;
  }
  .rotate-hint-glyph {
    width: 56px; height: 56px;
    color: var(--accent);
    animation: rotate-hint-spin 2.4s ease-in-out infinite;
  }
  .rotate-hint-title {
    font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
    color: var(--on-bg); letter-spacing: -0.02em;
  }
  .rotate-hint-sub { color: var(--on-bg-2); max-width: 320px; line-height: 1.5; }
}
/* Hidden by default; shown only when the landscape media query above matches. */
.rotate-hint { display: none; }
@keyframes rotate-hint-spin {
  0%, 55%  { transform: rotate(-90deg); }
  70%, 100% { transform: rotate(0deg); }
}
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--on-bg);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  position: relative;
}
/* On desktop, let the auth landing scroll naturally and take full page height */
@media (min-width: 900px) {
  body:has(#auth-screen:not([style*="display: none"])) {
    height: auto; min-height: 100dvh; overflow: auto;
  }
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select { font-family: inherit; }
em { font-style: italic; }

/* ── Page backdrop — Dusk paper grain ────────────────────────────────── */
/* Fractal-noise overlay baked into an SVG data URI, fixed to the viewport.
   Matches the design's `texture: 'paper'` spec for Dusk: low-frequency
   multiply at ~60% opacity for a barely-there paper tooth. */
.bg-paper {
  position: fixed; inset: 0; pointer-events: none;
  z-index: 0; opacity: 0.55; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 0.22 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Lift content above paper grain */
#auth-screen, #onboarding-screen, #app, #toast, .overlay { position: relative; z-index: 1; }

/* ── Tap feedback ────────────────────────────────────────────────────── */
.btn-spark:active, .btn-play-spark:active, .btn-another:active,
.btn-retry:active, .btn-suggestion:active, .btn-action-pill:active,
.btn-player-play:active, .btn-player-ctrl:active, .nav-tab:active,
.ob-chip:active, .spark-script-toggle:active, .spark-maps-link:active,
.nearby-card:active, .ob-btn-next:active, .ob-btn-back:active,
.btn-sheet-save:active, .btn-sheet-cancel:active {
  transform: scale(0.97); opacity: 0.92;
  transition: transform 0.1s, opacity 0.1s;
}

/* ── Toast ───────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 96px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(28,26,23,0.94); color: #FFF;
  padding: 11px 22px; border-radius: var(--radius-pill);
  font-size: 0.84rem; font-weight: 500;
  pointer-events: none; opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999; white-space: nowrap; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow-md);
}

/* ─────────────────────────────────────────────────────────────────────────
   AUTH SCREEN
   ───────────────────────────────────────────────────────────────────── */
#auth-screen {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 28px; gap: 22px;
}
.auth-spark { width: 84px; height: 84px; }
.auth-spark svg { width: 100%; height: 100%; fill: var(--accent); overflow: visible; }
.auth-spark .sp { transform-box: fill-box; transform-origin: center; }
@keyframes auth-sp-lg { 0%,100% { transform: scale(0.55); opacity: 0.30; } 45% { transform: scale(1.18); opacity: 1; } }
@keyframes auth-sp-md { 0%,100% { transform: scale(0.45); opacity: 0.20; } 60% { transform: scale(1.25); opacity: 1; } }
@keyframes auth-sp-sm { 0%,100% { transform: scale(0.60); opacity: 0.40; } 34% { transform: scale(1.14); opacity: 1; } }
.auth-spark .sp-lg { animation: auth-sp-lg 2.4s ease-in-out infinite 0s; }
.auth-spark .sp-md { animation: auth-sp-md 1.8s ease-in-out infinite 0.5s; }
.auth-spark .sp-sm { animation: auth-sp-sm 3.0s ease-in-out infinite 0.9s; }

.auth-title {
  font-family: var(--font-display);
  font-size: 2.6rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.04em;
  line-height: 1.1; padding-bottom: 0.1em;
}
.auth-title em { color: var(--accent); font-style: italic; }
.auth-sub {
  font-size: 0.98rem; color: var(--on-bg-2);
  text-align: center; max-width: 320px; line-height: 1.55;
}
.auth-hint {
  font-size: 0.78rem; color: var(--on-bg-3);
  text-align: center; max-width: 280px; line-height: 1.5;
}
#google-signin-btn { min-width: 240px; display: flex; justify-content: center; }
#auth-error {
  font-size: 0.85rem; color: var(--danger); background: var(--danger-bg);
  padding: 10px 18px; border-radius: var(--radius-md);
  display: none; max-width: 320px; text-align: center;
  border: 1px solid rgba(125,42,32,0.18);
}
#auth-error.visible { display: block; }
.auth-location-note {
  font-size: 0.72rem; color: var(--on-bg-3);
  text-align: center; max-width: 300px; line-height: 1.5;
  margin-top: 4px; font-family: var(--font-mono);
}

/* ─────────────────────────────────────────────────────────────────────────
   ONBOARDING
   ───────────────────────────────────────────────────────────────────── */
#onboarding-screen {
  display: none;
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  flex-direction: column; overflow: hidden;
  padding: 20px 22px 0;
}
#onboarding-screen.visible { display: flex; }
/* Hide the app shell while onboarding is on top */
body:has(#onboarding-screen.visible) #app,
body:has(#onboarding-screen.visible) header { visibility: hidden; }

/* Inline sparkle glyph inside onboarding greeting (Привет, Ilia! ✦) */
.ob-spark-icon-inline {
  width: 0.9em; height: 0.9em;
  display: inline-block; vertical-align: -0.12em;
  fill: var(--accent); overflow: visible;
  margin-left: 2px;
}

.ob-progress {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 4px 0 20px;
}
.ob-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border);
  transition: width 0.3s, height 0.3s, border-radius 0.3s, background 0.25s;
}
.ob-dot.active {
  width: 22px; height: 7px; border-radius: 999px;
  background: var(--accent);
}

.ob-screens { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.ob-screen { display: none; padding-bottom: 120px; }
.ob-screen.active { display: block; }

.ob-hero {
  padding: 4px 0 18px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.ob-hero-spark {
  position: relative;
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  margin: 6px 0 18px;
}
.ob-hero-aura {
  position: absolute; inset: -20px; border-radius: 50%;
  background: radial-gradient(circle, rgba(160,59,46,0.28) 0%, rgba(160,59,46,0.08) 45%, transparent 70%);
  filter: blur(12px); pointer-events: none;
  animation: ob-aura-pulse 3.6s ease-in-out infinite;
}
@keyframes ob-aura-pulse {
  0%, 100% { transform: scale(0.92); opacity: 0.8; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.ob-hero-spark svg { width: 64px; height: 64px; fill: var(--accent); overflow: visible; position: relative; z-index: 1; }

.ob-heading {
  font-family: var(--font-display);
  font-size: 1.85rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.025em;
  line-height: 1.2; margin-bottom: 14px; padding-bottom: 0.08em;
}
.ob-heading em { color: var(--accent); font-style: italic; font-weight: 600; }
.ob-heading-center { text-align: center; margin: 0 0 12px; }
.ob-welcome-sub {
  text-align: center; font-size: 0.94rem;
  color: var(--on-bg-2); line-height: 1.55;
  max-width: 340px; margin: 0 auto 4px;
}
.ob-sub {
  font-size: 0.92rem; color: var(--on-bg-2);
  line-height: 1.5; margin-bottom: 18px;
}
.ob-section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--on-bg-3); margin: 18px 0 10px;
}

.ob-steps {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 16px 18px 18px;
  margin-bottom: 22px;
  counter-reset: ob-step;
}
.ob-step-label {
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-3); margin-bottom: 12px;
}
.ob-step {
  font-size: 0.9rem; color: var(--on-bg);
  line-height: 1.5; padding: 5px 0 5px 34px; position: relative;
  counter-increment: ob-step;
}
.ob-step::before {
  content: counter(ob-step);
  position: absolute; left: 0; top: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep);
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Chip rows (languages, categories, voices) */
.ob-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ob-chip {
  padding: 7px 12px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 500;
  color: var(--on-bg-2);
  font-family: var(--font-body), var(--font-emoji);
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.ob-chip.selected {
  background: var(--accent); border-color: var(--accent);
  color: #FFF; font-weight: 600;
  box-shadow: 0 4px 12px rgba(160,59,46,0.22);
}
.ob-select {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: 0.95rem;
  color: var(--on-bg);
}

/* Category cards (onboarding step 2) — 2-col icon + label grid */
.ob-cat-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr; gap: 8px;
}
.ob-cat-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ob-cat-card:hover { border-color: var(--accent); }
.ob-cat-card.selected {
  border-color: var(--accent); background: var(--accent-soft);
}
.ob-cat-card.selected .ob-cat-name { color: var(--accent-deep); font-weight: 600; }
.ob-cat-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ob-cat-card.selected .ob-cat-icon { background: var(--accent); }
.ob-cat-card.selected .ob-cat-icon img { filter: brightness(0) invert(1); }
.ob-cat-icon img {
  width: 16px; height: 16px;
  /* SVGs authored with currentColor render black via <img>; keep neutral ink */
  filter: brightness(0) opacity(0.75);
}
.ob-cat-name {
  font-size: 0.86rem; font-weight: 500; color: var(--on-bg);
  line-height: 1.25;
}
/* "Anything" escape hatch — full-width, dashed border; sits above the
   category grid in onboarding step 2. Toggles every category on/off. */
.ob-anything-btn {
  width: 100%; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: left; cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-body);
}
.ob-anything-btn:hover { border-color: var(--accent); }
.ob-anything-btn.selected {
  border-style: solid; border-color: var(--accent);
  background: var(--accent-soft);
}
.ob-anything-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-deep); color: var(--on-bg-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ob-anything-btn.selected .ob-anything-icon { background: var(--accent); color: #FFF; }
.ob-anything-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ob-anything-title {
  font-size: 0.86rem; font-weight: 600; color: var(--on-bg); line-height: 1.2;
}
.ob-anything-btn.selected .ob-anything-title { color: var(--accent-deep); }
.ob-anything-sub {
  font-size: 0.74rem; color: var(--on-bg-3); line-height: 1.3;
}
/* "Or pick topics" divider between Anything and the category grid */
.ob-or-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 12px;
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-3);
}
.ob-or-line { flex: 1; height: 1px; background: var(--border-light); }

/* Toolkit guide cards */
.ob-guide { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ob-guide-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
/* Suggestion-type rows are editorial: no box, just an accent spine + text. */
.ob-guide-item--suggestion {
  background: transparent !important;   /* override .stype-* bg from badge rules */
  border: none; border-left: 3px solid var(--border);
  border-radius: 0; box-shadow: none;
  padding: 4px 12px;
  color: var(--on-bg-2) !important;     /* same: undo badge-only color */
}
.ob-guide-item--suggestion.stype-deeper_dive { border-left-color: var(--info); }
.ob-guide-item--suggestion.stype-spin_off    { border-left-color: var(--mark); }
.ob-guide-item--suggestion.stype-new_spark   { border-left-color: var(--success); }
.ob-guide-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--accent); color: #FFF;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.ob-guide-icon svg, .ob-guide-icon img { display: block; }
.ob-guide-icon svg { fill: #FFF; }
.ob-guide-icon img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.ob-guide-text { flex: 1; min-width: 0; }
.ob-guide-title {
  font-size: 0.94rem; font-weight: 700;
  color: var(--on-bg); margin-bottom: 3px;
  display: flex; align-items: center; gap: 8px;
}
.ob-guide-desc {
  font-size: 0.82rem; color: var(--on-bg-2); line-height: 1.5;
}
/* Tighten suggestion-row title since it hosts just a badge */
.ob-guide-item--suggestion .ob-guide-title { margin-bottom: 4px; }

/* Suggestion type badges (also injected into suggestion buttons by JS) */
.suggestion-type-badge {
  display: inline-block; font-family: var(--font-mono);
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--radius-pill);
  background: var(--bg-deep); color: var(--on-bg-2);
  white-space: nowrap;
}
.stype-deeper_dive { background: var(--info-soft); color: var(--info); }
.stype-spin_off    { background: var(--mark-soft); color: var(--mark); }
.stype-new_spark   { background: var(--success-bg); color: var(--success); }

/* Onboarding nav */
.ob-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 10px; align-items: center;
  padding: 16px 22px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent 0%, var(--bg) 35%, var(--bg) 100%);
  border-top: 1px solid var(--border-light);
}
.ob-btn-back {
  padding: 12px 18px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1.5px solid var(--border);
  font-size: 0.88rem; font-weight: 600; color: var(--on-bg-2);
}
.ob-btn-next {
  flex: 1; padding: 14px 20px; border-radius: var(--radius-pill);
  background: var(--accent); color: #FFF;
  font-size: 0.95rem; font-weight: 700;
  box-shadow: 0 6px 18px rgba(160,59,46,0.32);
}
.ob-btn-skip {
  position: absolute; top: calc(14px + var(--safe-top, 0px)); right: 16px;
  padding: 6px 10px;
  background: transparent; border: none;
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.02em; color: var(--on-bg-3);
  z-index: 5;
}
.ob-btn-skip:hover { color: var(--accent); }
.ob-shortcut, .pref-restart-btn {
  width: 100%; padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--bg-deep); border: 1px solid var(--border-light);
  font-size: 0.9rem; font-weight: 600; color: var(--on-bg-2);
}

/* ─────────────────────────────────────────────────────────────────────────
   APP SHELL
   ───────────────────────────────────────────────────────────────────── */
#app { display: none; flex-direction: column; flex: 1; overflow: hidden; }
#app.visible { display: flex; }

/* Header */
header {
  height: var(--header-h);
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center;
  padding: 0 18px; gap: 10px;
  flex-shrink: 0; z-index: 10;
}
.hdr-logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.025em;
  line-height: 1; padding-bottom: 0.05em;
  text-decoration: none;
}
/* Wordmark — "Walklore" with the first letter in accent red. The <em> here
   is a styling hook, not a semantic emphasis; flat red only, no italic or
   weight change, so the letter reads as part of the same word. */
.wordmark em {
  color: var(--accent);
  font-style: normal;
  font-weight: inherit;
}
.hdr-spark { width: 18px; height: 18px; fill: var(--accent); overflow: visible; flex-shrink: 0; }
/* Static header sparkle — animated mark is used elsewhere; the header stays calm. */
.hdr-spark .sp-lg,
.hdr-spark .sp-md,
.hdr-spark .sp-sm { animation: none; }
.hdr-spacer { flex: 1; }
.hdr-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 6px 10px;
  font-size: 0.78rem; color: var(--on-bg-2);
  display: flex; align-items: center; justify-content: center;
}
.hdr-btn-settings {
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  color: var(--on-bg-2);
}
.hdr-btn-settings:hover { background: var(--bg-deep); color: var(--accent); }

/* Content area */
#content {
  flex: 1; overflow-y: auto; min-height: 0;
  padding-bottom: calc(var(--player-h) + var(--nav-h) + var(--safe-bottom));
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─────────────────────────────────────────────────────────────────────────
   SPARK TAB
   ───────────────────────────────────────────────────────────────────── */

/* Hero */
.spark-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 22px 24px; gap: 16px; text-align: center;
}
.spark-hero-icon {
  width: 108px; height: 108px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.spark-hero-icon::before {
  content: ''; position: absolute; inset: -28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160,59,46,0.28) 0%, rgba(160,59,46,0.10) 40%, transparent 70%);
  filter: blur(16px); pointer-events: none;
  animation: hero-aura-pulse 3.6s ease-in-out infinite;
}
@keyframes hero-aura-pulse {
  0%, 100% { transform: scale(0.92); opacity: 0.85; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.spark-hero-icon svg {
  width: 100%; height: 100%; fill: var(--accent); overflow: visible;
  position: relative; z-index: 1;
}
.spark-hero-title {
  font-family: var(--font-display);
  font-size: 1.85rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.03em;
  line-height: 1.15; padding-bottom: 0.08em;
}
.spark-hero-title .accent { color: var(--accent); font-style: italic; font-weight: 600; }
.spark-hero-sub {
  font-size: 0.92rem; color: var(--on-bg-2);
  max-width: 280px; line-height: 1.5;
}

/* Spark icon — universal animation */
.icon-spark { overflow: visible; fill: currentColor; display: block; }
.icon-spark .sp,
svg .sp { transform-box: fill-box; transform-origin: center; }
@keyframes sp-lg { 0%,100% { transform: scale(0.55); opacity: 0.35; } 45% { transform: scale(1.18); opacity: 1; } }
@keyframes sp-md { 0%,100% { transform: scale(0.45); opacity: 0.25; } 60% { transform: scale(1.25); opacity: 1; } }
@keyframes sp-sm { 0%,100% { transform: scale(0.60); opacity: 0.40; } 34% { transform: scale(1.14); opacity: 1; } }
.sp-lg { animation: sp-lg 2.4s ease-in-out infinite 0s; }
.sp-md { animation: sp-md 1.8s ease-in-out infinite 0.5s; }
.sp-sm { animation: sp-sm 3.0s ease-in-out infinite 0.9s; }

/* Big Spark CTA */
.btn-spark {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; padding: 0 32px; height: 60px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #FFF; font-size: 1.05rem; font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 26px rgba(160,59,46,0.35), 0 2px 6px rgba(28,26,23,0.12);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  overflow: visible;
}
.btn-spark::before {
  content: ''; position: absolute; inset: -4px; border-radius: inherit;
  background: inherit; filter: blur(20px); opacity: 0.45; z-index: -1;
  transition: opacity 0.3s;
}
.btn-spark:hover::before { opacity: 0.7; }
.btn-spark::after {
  content: ''; position: absolute; inset: -10px; border-radius: inherit;
  background: conic-gradient(from 0deg, transparent 0deg, currentColor 30deg, transparent 60deg, transparent 360deg);
  opacity: 0.10; animation: burst-spin 6s linear infinite;
  pointer-events: none; z-index: -1;
}
@keyframes burst-spin { to { transform: rotate(360deg); } }
.btn-spark .icon-spark { width: 22px; height: 22px; fill: #FFF; }
.btn-spark.loading { opacity: 0.7; pointer-events: none; }

/* Action pills — segmented pill (Dusk) */
.explore-actions {
  padding: 4px 22px 10px;
  display: flex; justify-content: center;
}
.explore-actions-group {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); overflow: hidden;
  box-shadow: var(--shadow-sm);
  max-width: 420px; width: 100%;
}
.btn-action-pill {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px;
  background: transparent; border: none;
  font-size: 0.88rem; font-weight: 500; color: var(--on-bg-2);
  position: relative;
}
.btn-action-pill + .btn-action-pill {
  border-left: 1px solid var(--border);
}
.btn-action-pill:hover { color: var(--accent); }
.btn-action-pill img {
  width: 15px; height: 15px;
  filter: brightness(0) opacity(0.6);
}

/* Nearby section */
.nearby-section { padding: 22px 18px 8px; }
.nearby-section-header {
  display: flex; flex-wrap: nowrap;
  align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.nearby-title {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-refresh-nearby {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 7px;
  background: transparent; border: 1px solid var(--border-soft, var(--border-light));
  border-radius: var(--radius-pill); cursor: pointer;
  color: var(--on-bg-3); font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  flex-shrink: 0;
}
.btn-refresh-nearby:hover { color: var(--accent); border-color: var(--accent); }
.nearby-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  font-size: 0.85rem; color: var(--on-bg-2);
}
.nearby-loading-icon { width: 22px; height: 22px; fill: var(--accent); overflow: visible; }
.nearby-loading-text { flex: 1; }
.nearby-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px; grid-auto-rows: 1fr;
}
.nearby-card {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); padding: 11px 12px 10px;
  text-align: left; box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 78px; height: 100%;
}
.nearby-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.nearby-card-name {
  font-size: 0.82rem; font-weight: 600;
  color: var(--on-bg); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nearby-card-addr {
  font-size: 0.7rem; color: var(--on-bg-3); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nearby-card-dist {
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.02em; font-weight: 600;
  color: var(--on-bg-2); margin-top: auto;
  white-space: nowrap;
}

/* ── Spark result ────────────────────────────────────────────────────── */
.spark-result { display: none; padding: 14px 16px 18px; }
.spark-result.visible { display: block; }
/* Back to Spark idle. Ghost button sits above the story card; hidden during
   skeleton (the loading toast has its own cancel ✕). */
.spark-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 2px; margin: 0 0 6px;
  background: transparent; border: none; cursor: pointer;
  color: var(--on-bg-2);
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 600;
}
.spark-back-btn:hover { color: var(--accent); }
.spark-back-btn svg { flex-shrink: 0; }
.spark-result.skeleton .spark-back-btn { display: none; }
/* Skeleton shimmer comes from per-element rules below; don't dim the whole
   card — the floating loading pill lives inside the card and would inherit
   the 70% alpha, compositing below the shimmer. */

.spark-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-md);
}
.spark-img-wrap {
  position: relative; aspect-ratio: 16/10;
  background: var(--bg-deep); overflow: hidden;
}
.spark-img-placeholder {
  position: absolute; inset: 0;
  background: linear-gradient(120deg, var(--bg-deep) 0%, var(--accent-soft) 50%, var(--bg-deep) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
#spark-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity 0.4s;
}
#spark-img.loaded { opacity: 1; }
.spark-img-source {
  position: absolute; top: 8px; right: 10px;
  font-family: var(--font-mono); font-size: 0.65rem;
  color: rgba(255,255,255,0.85); background: rgba(28,26,23,0.55);
  padding: 3px 8px; border-radius: var(--radius-pill);
  backdrop-filter: blur(4px);
}

.spark-card-body { padding: 18px 18px 16px; }
.spark-meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-block;
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent-deep);
}
.chip-green { background: var(--success-bg); color: var(--success); }

.spark-title {
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.025em;
  line-height: 1.2; margin-bottom: 8px; padding-bottom: 0.04em;
}
/* POI / address row — canonical styles live in the SPARK RESULT section
   further down (grid 2×2 for #spark-poi-row, flex fallback for the library
   story's `.spark-poi-row`). `.spark-poi-info` is kept as a utility for the
   library story card. */
.spark-poi-info {
  flex: 1; min-width: 0;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}

.spark-play-row { display: flex; align-items: center; gap: 12px; }
.spark-compass {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--on-bg-3);
}
.compass-needle-wrap { display: flex; align-items: center; }
.compass-direction { font-weight: 600; color: var(--on-bg-2); font-family: var(--font-mono); font-size: 0.72rem; }
.compass-dist-text { font-family: var(--font-mono); font-size: 0.72rem; }

.btn-play-spark {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px; border-radius: var(--radius-pill);
  background: var(--on-bg); color: #FFF;
  font-size: 0.92rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(28,26,23,0.25);
}

.gen-stats {
  display: none; margin-top: 12px;
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--on-bg-3); line-height: 1.5;
}
.gen-stats.visible { display: block; }

.spark-script-section {
  margin-top: 6px;
}
.spark-script-preview, .spark-script-full {
  font-family: var(--font-display);
  font-size: 1.02rem; line-height: 1.65;
  color: var(--on-bg-2); position: relative;
  max-height: 220px; overflow: hidden;
}
.spark-script-full { max-height: none; overflow: visible; }
/* Drop-cap on the first letter of the story body.
   The script is injected into .spark-script-* via textContent (no <p>s),
   so we target the container itself; the library detail wraps in <p>s so
   we target its first non-lead paragraph. */
/* Drop-cap sized to exactly 2 body lines. Box height must be ≤ 2 × body
   line-height (body = 1.02rem × 1.65 ≈ 26.9px, so 2 lines ≈ 53.9px).
   At 3.6em × 0.82 line-height the glyph box is ~48.2px; padding-top 2px
   leaves it at 50.2px — inside the 2-line budget — so no wrap spills
   into the third line. */
.spark-script-preview::first-letter,
.spark-script-full::first-letter,
.lib-story-script > p:first-child:not(.lib-story-lead)::first-letter,
.lib-story-script > .lib-story-lead + p::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.6em; line-height: 0.82;
  float: left; padding: 2px 12px 0 0;
  margin-top: 0;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* Pulled-out opening line for library story detail */
.lib-story-lead {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 500;
  color: var(--on-bg); line-height: 1.45;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.lib-story-script > p { font-family: var(--font-display); font-size: 1rem; line-height: 1.7; color: var(--on-bg-2); margin-bottom: 14px; }
/* Pulled-out opening line — first paragraph, larger & bolder */
.spark-teaser {
  font-family: var(--font-display);
  font-size: 1.08rem; font-weight: 500;
  color: var(--on-bg); letter-spacing: -0.01em;
  line-height: 1.45; margin-bottom: 14px;
}
.spark-script-preview::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 56px; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, var(--surface) 90%);
}
.spark-script-toggle {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: transparent; border: 1.5px solid var(--accent);
  color: var(--accent); font-size: 0.78rem; font-weight: 600;
}
.spark-script-toggle.expanded .spark-script-chevron { transform: rotate(90deg); }
.spark-script-chevron { transition: transform 0.2s; }

/* Suggestions */
.suggestions-section { margin-top: 22px; }
.suggestions-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 4px;
}
.suggestions-label {
  font-family: var(--font-mono);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-3);
}
.btn-refresh-suggestions {
  font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--on-bg-3);
  padding: 4px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
}
.btn-refresh-suggestions:hover { color: var(--accent); border-color: var(--accent); }
.suggestions-loading {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 14px; font-size: 0.84rem; color: var(--on-bg-3);
}

.suggestions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  grid-auto-rows: 1fr;
}
.btn-suggestion {
  text-align: left; padding: 12px 12px 10px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm); min-height: 92px; height: 100%;
  transition: box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}
.btn-suggestion:hover { box-shadow: var(--shadow-md); }
.btn-suggestion:has(.stype-deeper_dive) { border-left-color: var(--info); }
.btn-suggestion:has(.stype-spin_off)    { border-left-color: var(--mark); }
.btn-suggestion:has(.stype-new_spark)   { border-left-color: var(--success); }
.suggestion-title {
  font-size: 0.8rem; font-weight: 600;
  color: var(--on-bg); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Single mono footer line: "POI · distance" */
.suggestion-poi-name, .suggestion-poi-loc, .suggestion-meta {
  font-family: var(--font-mono); font-size: 0.62rem;
  color: var(--on-bg-3); letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-transform: none;
}
.suggestion-meta { margin-top: auto; }
.btn-suggestion .suggestion-type-badge {
  align-self: flex-start; font-size: 0.55rem; padding: 2px 6px;
  letter-spacing: 0.08em;
}

#spark-telemetry { padding: 0 4px; }

.another-spark-row { display: flex; padding: 18px 0 4px; }
.btn-another, .btn-another-inline {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: transparent; border: 1px dashed var(--border);
  color: var(--on-bg-2); font-size: 0.9rem; font-weight: 600;
}
.btn-another:hover, .btn-another-inline:hover {
  border-color: var(--accent); color: var(--accent);
}
.btn-another .icon-spark, .btn-another-inline .icon-spark {
  width: 16px; height: 16px; fill: var(--accent);
}

/* Loading + error — .spark-loading floats inside .spark-img-wrap as an
   overlay pill on top of the skeleton hero; the sibling-positioned variant
   was retired when the chip moved into the image wrap. */
.spark-loading {
  display: none;
  position: absolute; left: 50%; top: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  z-index: 10;
  pointer-events: auto;
}
.spark-loading.visible { display: block; }
.loading-step { font-family: var(--font-mono); }
.loading-dots::after {
  content: ''; display: inline-block; width: 1em;
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0%,20% { content: '·'; } 40% { content: '··'; } 60% { content: '···'; } 80%,100% { content: ''; } }

.spark-error {
  display: none; margin: 18px;
  padding: 18px 20px; background: var(--danger-bg);
  border: 1px solid rgba(125,42,32,0.18); border-radius: var(--radius-md);
  text-align: center;
}
.spark-error.visible { display: block; }
.spark-error-msg { font-size: 0.92rem; color: var(--danger); margin-bottom: 8px; font-weight: 500; }
.spark-quota-hint { font-size: 0.8rem; color: var(--on-bg-3); margin-top: 6px; }
.btn-retry {
  margin-top: 12px; padding: 10px 22px;
  border-radius: var(--radius-pill);
  background: var(--accent); color: #FFF;
  font-size: 0.86rem; font-weight: 700;
  box-shadow: 0 4px 12px rgba(160,59,46,0.30);
}

/* ─────────────────────────────────────────────────────────────────────────
   DISCOVER TAB
   ───────────────────────────────────────────────────────────────────── */
/* ── Discover header ────────────────────────────────────────────────── */
.discover-header {
  padding: 10px 18px 12px;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
}
.discover-heading {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.02em; line-height: 1.1;
}
.discover-subheading {
  font-family: var(--font-mono);
  font-size: 0.7rem; color: var(--on-bg-3);
  letter-spacing: 0.04em;
}

#map-container {
  margin: 0 12px 14px;
  height: 240px; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
#map { width: 100%; height: 100%; }

.discover-loading {
  display: none; padding: 24px 18px; text-align: center;
}
.discover-loading.visible { display: block; }
.discover-loading-icon {
  width: 36px; height: 36px;
  fill: var(--accent); overflow: visible;
  margin: 0 auto 10px; display: block;
}

.discover-error {
  display: none; margin: 18px;
  padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--danger-bg); color: var(--danger);
  font-size: 0.86rem; text-align: center;
}
.discover-error.visible { display: block; }

/* Card list — stacked with coloured left accent per category. */
.discover-list {
  padding: 0 12px 22px;
  display: flex; flex-direction: column; gap: 8px;
}
.discover-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-left: 4px solid var(--on-bg-4);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 10px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
}
.discover-card:hover { box-shadow: var(--shadow-md); }
.discover-card-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.discover-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.discover-card-thumb .ph {
  color: var(--on-bg-4); font-size: 1.4rem;
}
.discover-card-body {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.discover-card-meta {
  display: flex; align-items: center; gap: 6px;
}
.discover-card-chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 0.58rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px;
  line-height: 1.2;
}
.discover-card-dist {
  font-family: var(--font-mono); font-size: 0.66rem;
  letter-spacing: 0.04em; color: var(--on-bg-3);
}
.discover-card-title {
  font-size: 0.88rem; font-weight: 600; color: var(--on-bg);
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.discover-card-teaser {
  font-size: 0.75rem; color: var(--on-bg-2); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Category-accent colours mirror the Spark-result suggestion palette so
   "deep_dive" / "spin_off" / "new_spark" read consistently across screens.
   The LLM picks the angle; server maps angle → stype class on render. */
.discover-card.stype-history,
.discover-card.stype-deeper_dive { border-left-color: var(--info); }
.discover-card.stype-history .discover-card-chip,
.discover-card.stype-deeper_dive .discover-card-chip {
  background: rgba(52,85,126,0.14); color: var(--info);
}
.discover-card.stype-folklore,
.discover-card.stype-spin_off { border-left-color: var(--mark); }
.discover-card.stype-folklore .discover-card-chip,
.discover-card.stype-spin_off .discover-card-chip {
  background: rgba(183,135,42,0.16); color: var(--mark);
}
.discover-card.stype-architecture,
.discover-card.stype-new_spark { border-left-color: var(--success); }
.discover-card.stype-architecture .discover-card-chip,
.discover-card.stype-new_spark .discover-card-chip {
  background: rgba(63,91,79,0.14); color: var(--success);
}
.discover-card.stype-art       { border-left-color: var(--info); }
.discover-card.stype-art .discover-card-chip {
  background: rgba(52,85,126,0.14); color: var(--info);
}
.discover-card.stype-nature    { border-left-color: var(--ink2, var(--on-bg-2)); }
.discover-card.stype-nature .discover-card-chip {
  background: rgba(58,53,46,0.10); color: var(--on-bg-2);
}
.discover-card.stype-food      { border-left-color: var(--mark); }
.discover-card.stype-food .discover-card-chip {
  background: rgba(183,135,42,0.16); color: var(--mark);
}

.btn-rediscover {
  display: none; margin: 14px 18px 22px;
  padding: 11px 18px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1.5px solid var(--accent);
  color: var(--accent); font-size: 0.86rem; font-weight: 700;
}
.btn-rediscover.visible { display: block; }

/* ─────────────────────────────────────────────────────────────────────────
   PERSISTENT PLAYER BAR
   ───────────────────────────────────────────────────────────────────── */
#player-bar {
  display: none;
  position: absolute;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 0; right: 0;
  height: var(--player-h);
  background: var(--surface); color: var(--on-bg);
  border-top: 1px solid var(--border-light);
  flex-direction: column; padding: 0 14px 8px;
  box-shadow: 0 -6px 20px rgba(28,26,23,0.06);
  z-index: 20;
}
#player-bar.visible { display: flex; }

.player-track-wrap {
  position: relative; height: 18px;
  display: flex; align-items: center;
}
.player-track-fill {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 3px; background: var(--accent);
  border-radius: 999px; pointer-events: none;
  width: 0%; transition: width 0.1s linear;
}
.player-track-wrap::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%); height: 3px;
  background: var(--border-light); border-radius: 999px;
}
#player-range {
  position: absolute; inset: 0; width: 100%;
  opacity: 0; cursor: pointer;
}

.player-main-row {
  display: flex; align-items: center; gap: 12px;
  padding-top: 4px;
}
.player-info-block { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-title {
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 600; color: var(--on-bg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-sub-row {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.64rem;
  color: var(--on-bg-3); margin-top: 2px;
}
.player-step { color: var(--accent); }

.player-ctrl-block { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.btn-player-ctrl {
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; color: var(--on-bg-2);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.74rem; font-weight: 700;
}
.btn-player-speed { width: auto; padding: 0 10px; border-radius: var(--radius-pill); font-family: var(--font-mono); }
.btn-player-play { background: var(--accent); color: #FFF; border-color: var(--accent); width: 38px; height: 38px; box-shadow: 0 4px 10px rgba(160,59,46,0.35); }
.btn-player-play.playing { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-player-stop { background: transparent; font-size: 0.88rem; color: var(--on-bg-3); }

/* ─────────────────────────────────────────────────────────────────────────
   BOTTOM NAV
   ───────────────────────────────────────────────────────────────────── */
#bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  /* Add safe-area-inset-bottom on top of the nav height so the icons/labels
     keep their breathing room on devices with a home indicator. */
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(253,250,243,0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-light);
  display: flex;
  z-index: 15;
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px 10px;
  font-size: 0.72rem; font-weight: 600; color: var(--on-bg-3);
  background: none; border: none;
  font-family: var(--font-body); letter-spacing: 0.01em;
  position: relative;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-tab.active { color: var(--accent); }
/* Active tab indicator — subtle 3px pill at the top edge */
.nav-tab.active::before {
  content: ''; position: absolute; top: 0; left: 32%; right: 32%;
  height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.nav-tab-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.nav-tab-icon svg { width: 100%; height: 100%; fill: currentColor; }

/* ─────────────────────────────────────────────────────────────────────────
   PREFERENCES SHEET
   ───────────────────────────────────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(28,26,23,0.50);
  z-index: 100; align-items: flex-end; justify-content: center;
}
.overlay.visible { display: flex; }
.sheet {
  width: 100%; max-width: 520px;
  max-height: 92dvh;
  background: var(--bg); color: var(--on-bg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  display: flex; flex-direction: column;
  box-shadow: 0 -20px 60px rgba(28,26,23,0.30);
  animation: sheet-up 0.28s ease;
}
@keyframes sheet-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0;
}
.sheet h2 {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 600;
  letter-spacing: -0.02em; padding: 14px 22px 8px;
  display: flex; align-items: center; gap: 8px;
}
.sheet h2 .sheet-close {
  margin-left: auto;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-deep); color: var(--on-bg-3);
  border: none; font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.sheet h2 .sheet-close:hover { color: var(--accent); }
.sheet-body { padding: 6px 22px 16px; overflow-y: auto; flex: 1; }
/* Emoji fallback font so flags render on Windows / headless browsers */
.sheet select, .sheet option,
.ob-chip, .ob-chip .flag,
.lang-select, .lang-select option {
  font-family: var(--font-body), var(--font-emoji);
}
.sheet-actions {
  display: flex; gap: 10px; padding: 14px 22px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}
.btn-sheet-cancel, .btn-sheet-save {
  flex: 1; padding: 13px 18px; border-radius: var(--radius-pill);
  font-size: 0.92rem; font-weight: 700;
}
.btn-sheet-cancel { background: var(--bg-deep); color: var(--on-bg-2); }
.btn-sheet-save   { background: var(--accent); color: #FFF; box-shadow: 0 6px 14px rgba(160,59,46,0.30); }

.pref-section-title {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin: 18px 0 10px;
}
.pref-row { margin-bottom: 12px; }
.pref-row label {
  display: block; font-size: 0.86rem; font-weight: 600;
  color: var(--on-bg); margin-bottom: 6px;
}
.pref-row select {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: 0.9rem; color: var(--on-bg);
}
.pref-hint {
  font-size: 0.76rem; color: var(--on-bg-3);
  line-height: 1.45; margin-top: 6px;
}
.pref-radio-group { display: flex; flex-direction: column; gap: 8px; }
.pref-radio-label {
  font-size: 0.86rem; font-weight: 500; color: var(--on-bg);
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.pref-radio-hint { font-size: 0.74rem; color: var(--on-bg-3); }

.pref-user-block {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.pref-user-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--border); object-fit: cover;
}
.pref-user-name { font-size: 0.92rem; font-weight: 600; color: var(--on-bg); }

.pref-categories {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 4px;
}
.pref-category-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--surface); border: 1.5px solid var(--border);
  font-size: 0.84rem; color: var(--on-bg-2); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pref-category-item.selected {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-deep); font-weight: 600;
}

.badge-experimental {
  display: inline-block; font-family: var(--font-mono);
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(246,196,83,0.30); color: #8A6B12;
  margin-left: 4px;
}

.pref-debug-section { margin-top: 14px; }
.pref-debug-section summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.pref-debug-section summary::-webkit-details-marker { display: none; }
.dev-arrow { font-size: 0.65rem; color: var(--on-bg-3); transition: transform 0.2s; }
.pref-debug-section[open] .dev-arrow { transform: rotate(90deg); }

.pref-logout-btn {
  width: 100%; padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--surface); border: 1.5px solid var(--danger);
  color: var(--danger); font-size: 0.9rem; font-weight: 700;
}

/* Voice card grid (when JS injects ob-voice-card / ob-voice-grid) */
#ob-voice-grid, .ob-voice-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px;
}
.ob-voice-card {
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--surface); border: 1.5px solid var(--border);
  font-size: 0.84rem; color: var(--on-bg-2);
  text-align: left; cursor: pointer;
}
.ob-voice-card.selected {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-deep); font-weight: 600;
}

/* Simplified voice picker — name only, flow-wrap as small chips */
#pref-voice-chips { gap: 6px; }
#pref-voice-chips .ob-chip {
  padding: 6px 11px; font-size: 0.8rem;
}
#pref-voice-chips .voice-chip-desc { display: none; }

/* ─────────────────────────────────────────────────────────────────────────
   AUTH / LOGIN — Dusk (mobile + responsive web landing)
   Layout: #auth-screen is a flex column that fills the viewport. .auth-inner
   grows to center its content; .auth-legal-foot sticks at the bottom edge
   so Terms/Privacy are always anchored there regardless of content height.
   ───────────────────────────────────────────────────────────────────── */
#auth-screen {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 36px 24px 20px;
  overflow-y: auto;
  gap: 16px;
}
.auth-inner {
  width: 100%; max-width: 380px;
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  text-align: center;
  padding: 8px 0;
}
.auth-legal-foot {
  flex-shrink: 0; width: 100%; max-width: 480px;
  text-align: center;
  padding: 8px 12px 4px;
}

/* Responsive web landing — >= 900px the auth screen becomes a paper-spread */
@media (min-width: 900px) {
  #auth-screen {
    padding: 64px 56px 24px;
    gap: 24px;
  }
  .auth-inner {
    max-width: 1080px; width: 100%;
    display: grid; grid-template-columns: 1.1fr 0.9fr;
    gap: 72px; align-items: center;
    text-align: left;
    padding: 40px 0;
  }
  .auth-inner .auth-mark {
    grid-column: 1 / 2; justify-self: start;
    width: 72px; height: 72px; margin-bottom: 0;
  }
  .auth-inner .auth-mark svg { width: 68px; height: 68px; }
  .auth-title {
    grid-column: 1 / 2;
    font-size: clamp(3.2rem, 5.4vw, 5.2rem);
    line-height: 1; text-align: left;
    margin: 0; letter-spacing: -0.05em;
  }
  .auth-tagline {
    grid-column: 1 / 2;
    font-size: 1.4rem; max-width: 520px;
    text-align: left; padding: 0;
    margin-top: 4px;
  }
  .auth-cta {
    grid-column: 2 / 3; grid-row: 1 / 6;
    justify-self: stretch; align-self: center;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-md);
    gap: 18px; margin: 0;
    max-width: 420px; width: 100%;
  }
  .auth-location-note {
    grid-column: 1 / 2;
    font-size: 0.82rem; text-align: left; max-width: 460px;
    font-family: var(--font-body); color: var(--on-bg-3);
    margin-top: 8px;
  }
  .auth-location-hint {
    grid-column: 1 / 2;
    text-align: left; max-width: 460px;
    font-size: 0.82rem;
  }
  .auth-legal-foot { text-align: center; max-width: 640px; }
}
.auth-mark {
  position: relative;
  width: 92px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.auth-mark-glow {
  position: absolute; inset: -10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(160,59,46,0.35) 0%, transparent 65%);
  filter: blur(14px); animation: auth-glow 3s ease-in-out infinite;
}
@keyframes auth-glow { 0%,100% { opacity: 0.6; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.06); } }
.auth-mark svg {
  width: 88px; height: 88px;
  fill: var(--accent); overflow: visible;
  position: relative; z-index: 1;
}
.auth-mark .sp { transform-box: fill-box; transform-origin: center; }

.auth-legal {
  font-size: 0.7rem; color: var(--on-bg-3);
  text-align: center; max-width: 280px; line-height: 1.5;
  margin-top: 6px;
}
.auth-legal a {
  color: var(--on-bg-2); text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}
.auth-legal a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.auth-title {
  font-family: var(--font-display);
  font-size: 2.8rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.045em;
  line-height: 1.05; padding-bottom: 0.06em;
}
.auth-title em { color: var(--accent); font-style: italic; font-weight: 600; }
.auth-tagline {
  font-family: var(--font-display);
  font-size: 1.18rem; font-weight: 500;
  color: var(--on-bg-2); font-style: italic;
  line-height: 1.4; max-width: 340px; padding: 0 6px;
  margin-top: -2px;
}
.auth-leads {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px;
}
.auth-leads p {
  font-size: 0.92rem; color: var(--on-bg-2);
  line-height: 1.55; max-width: 320px; margin: 0;
}
.auth-features {
  list-style: none; padding: 0; margin: 14px 0 4px;
  display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start; align-self: stretch;
}
.auth-features li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.86rem; color: var(--on-bg-2); font-weight: 500;
  text-align: left; line-height: 1.4;
  box-shadow: var(--shadow-sm);
}
.af-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-cta {
  margin-top: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#google-signin-btn { min-width: 240px; display: flex; justify-content: center; }
#auth-error {
  font-size: 0.85rem; color: var(--danger); background: var(--danger-bg);
  padding: 10px 18px; border-radius: var(--radius-md);
  display: none; max-width: 320px; text-align: center;
  border: 1px solid rgba(125,42,32,0.18);
}
#auth-error.visible { display: block; }
.auth-location-note {
  font-size: 0.72rem; color: var(--on-bg-3);
  text-align: center; max-width: 320px; line-height: 1.5;
  margin-top: 10px; font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
/* Location-permission hint sits just under the walking tip, plain body. */
.auth-location-hint {
  font-size: 0.76rem; color: var(--on-bg-2);
  text-align: center; max-width: 340px; line-height: 1.55;
  margin-top: 2px;
}

/* ─────────────────────────────────────────────────────────────────────────
   SPARK — magic wand button icon
   ───────────────────────────────────────────────────────────────────── */
.btn-spark .icon-wand {
  width: 22px; height: 22px; color: #FFF; overflow: visible;
}

/* ─────────────────────────────────────────────────────────────────────────
   SPARK LOADING — status chip (floating pill over skeleton hero image)
   ───────────────────────────────────────────────────────────────────── */
.sl-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 6px 8px 10px;
  background: rgba(253, 250, 243, 0.82);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.06);
  animation: sl-chip-pop 0.35s ease-out;
}
@keyframes sl-chip-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sl-chip-icon {
  position: relative; width: 18px; height: 18px;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.sl-chip-aura {
  position: absolute; inset: -6px; border-radius: 50%;
  background: radial-gradient(circle, rgba(160,59,46,0.45) 0%, transparent 65%);
  filter: blur(3px);
  animation: sl-aura 1.6s ease-in-out infinite;
}
@keyframes sl-aura { 0%,100% { opacity: 0.55; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.15); } }
.sl-chip-icon svg {
  width: 18px; height: 18px; fill: var(--accent);
  overflow: visible; position: relative; z-index: 1;
}
.sl-chip-text {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0;
}
.sl-chip-status {
  font-family: var(--font-mono);
  font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-3);
}
.sl-chip-sep { color: var(--on-bg-4); font-size: 0.7rem; }
.sl-chip-msg {
  font-size: 0.76rem; color: var(--on-bg);
  font-weight: 500; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
  animation: sl-msg-in 0.4s ease-out;
}
@keyframes sl-msg-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.sl-chip-cancel {
  background: none; border: none; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-bg-3); padding: 0; margin-left: 2px;
  flex-shrink: 0;
}
.sl-chip-cancel:hover { color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────────────
   SPARK RESULT — restructured (floating Play, compass under title)
   ───────────────────────────────────────────────────────────────────── */
.spark-card-body { position: relative; padding: 18px 18px 18px; }

/* Floating Play pill — straddles image edge / card body, top-right */
.btn-play-floating {
  position: absolute !important;
  top: -22px; right: 16px;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 9px;
  background: var(--accent); color: #FFF;
  border: none; border-radius: var(--radius-pill);
  font-size: 0.84rem; font-weight: 700; letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(160,59,46,0.40), 0 2px 6px rgba(28,26,23,0.12);
  z-index: 4;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-play-floating:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(160,59,46,0.50), 0 3px 8px rgba(28,26,23,0.15); }
.btn-play-floating:disabled { opacity: 0.85; cursor: default; }
.btn-play-floating .play-circle {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-play-floating .play-circle svg { margin-left: 1px; }
.btn-play-floating .play-label { line-height: 1; }
/* Tolerate JS-injected raw SVG + text (when button content is overwritten) */
.btn-play-floating > svg { width: 14px; height: 14px; }

/* Title needs right padding so it never collides with the floating Play */
.spark-title { padding-right: 96px; }

/* Compass block — 2×2 grid for the spark result card.
   Columns: [compass] [ direction / distance (left) ] │ [ POI name / Maps link (right) ]
   No address string — the POI title above already names the place.
   The right column sizes to content so it can't starve a long localized
   direction like "Северо-Восток" or "Nord-Ouest".
   The library story card reuses `.spark-poi-row` with different children,
   so we scope the grid override to `#spark-poi-row` via the ID selector. */
.spark-poi-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0 14px; margin-bottom: 10px;
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.86rem; color: var(--on-bg-2);
}
#spark-poi-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  column-gap: 8px; row-gap: 3px;
  align-items: center;
}
.spark-compass-col {
  grid-column: 1; grid-row: 1 / span 2;
  display: flex; align-items: center; justify-content: center;
  width: 34px;
}
.spark-compass-col .compass-needle-wrap { display: flex; align-items: center; }
.spark-compass-col .compass-needle-wrap svg { width: 28px; height: 28px; }
/* Left column is `auto`, sized to content but capped on the children so a
   long localized bearing (e.g. "Северо-Восток") can't eat the POI name's
   space — the divider line stays close to the compass. */
.spark-poi-direction {
  grid-column: 2; grid-row: 1;
  font-weight: 600; color: var(--on-bg);
  font-size: 0.92rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; max-width: 110px;
}
.spark-poi-dist {
  grid-column: 2; grid-row: 2;
  font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--on-bg-3); letter-spacing: 0.02em; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; max-width: 110px;
}
.spark-poi-name {
  grid-column: 3; grid-row: 1;
  text-align: right;
  border-left: 1px solid var(--border-light); padding-left: 10px;
  font-weight: 600; color: var(--on-bg);
  font-size: 0.92rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.spark-maps-link {
  grid-column: 3; grid-row: 2;
  text-align: right;
  border-left: 1px solid var(--border-light); padding-left: 10px;
  font-size: 0.82rem; font-weight: 700; color: var(--accent);
  text-decoration: none; white-space: nowrap;
  line-height: 1.3;
}
.spark-maps-link:hover { color: var(--accent-deep); }

/* ─────────────────────────────────────────────────────────────────────────
   PLAYER — Dusk: light surface + dark ink controls, animated waveform
   ───────────────────────────────────────────────────────────────────── */
#player-bar { padding: 0 14px 8px; }
.player-main-row { gap: 12px; padding: 10px 0 0; }

/* Default control button — small 30×30 rounded-square with thin ink border */
.btn-player-ctrl {
  background: transparent;
  color: var(--on-bg-3);
  border: 1px solid var(--border);
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.66rem; font-weight: 700;
}
.btn-player-ctrl:hover { color: var(--accent); border-color: var(--accent); }

/* Primary play/pause — 36×36 round oxblood button with soft shadow */
.btn-player-play {
  background: var(--accent); color: #FFF;
  border: none;
  width: 36px; height: 36px; border-radius: 50%;
  box-shadow: 0 4px 12px rgba(160,59,46,0.28);
}
.btn-player-play.playing { background: var(--accent-deep); }
.btn-player-play:hover { color: #FFF; background: var(--accent-deep); }

/* Speed 1×/1.25× — auto-width pill, monospace */
.btn-player-speed {
  width: auto; padding: 0 10px;
}

/* Close ✕ — same 30×30 chrome as ctrl, heavier glyph */
.btn-player-stop {
  font-family: var(--font-body); font-size: 0.86rem; font-weight: 600;
  color: var(--on-bg-3);
}
.btn-player-stop:hover { color: var(--accent); }

/* Waveform thumbnail on the left of the player bar.
   Matches refresh/src/Screens.jsx PlayerBar spec exactly:
   - 36×36 accent-soft square, radius-sm (4px)
   - inner 16px-tall strip of six 2px bars at heights [0.4, 0.8, 0.5, 0.9, 0.6, 0.3]
   - pb-pulse 0.8s scaleY(0.4) ↔ scaleY(1), staggered by i*0.12s */
.player-waveform {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.player-waveform-bars { display: flex; align-items: center; gap: 2px; height: 16px; }
.player-waveform-bars span {
  width: 2px; background: var(--accent); border-radius: 1px;
  transform-origin: center;
  /* Idle state: bars sit at their authored heights with no scale transform */
}
.player-waveform-bars span:nth-child(1) { height: 40%; }
.player-waveform-bars span:nth-child(2) { height: 80%; }
.player-waveform-bars span:nth-child(3) { height: 50%; }
.player-waveform-bars span:nth-child(4) { height: 90%; }
.player-waveform-bars span:nth-child(5) { height: 60%; }
.player-waveform-bars span:nth-child(6) { height: 30%; }

#player-bar.visible.playing .player-waveform-bars span {
  animation: pb-pulse 0.8s ease-in-out infinite;
}
#player-bar.visible.playing .player-waveform-bars span:nth-child(1) { animation-delay: 0s; }
#player-bar.visible.playing .player-waveform-bars span:nth-child(2) { animation-delay: 0.12s; }
#player-bar.visible.playing .player-waveform-bars span:nth-child(3) { animation-delay: 0.24s; }
#player-bar.visible.playing .player-waveform-bars span:nth-child(4) { animation-delay: 0.36s; }
#player-bar.visible.playing .player-waveform-bars span:nth-child(5) { animation-delay: 0.48s; }
#player-bar.visible.playing .player-waveform-bars span:nth-child(6) { animation-delay: 0.60s; }

@keyframes pb-pulse {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1); }
}
.player-main-row { padding-top: 6px; }

/* ─────────────────────────────────────────────────────────────────────────
   BOTTOM NAV — 3 tabs (Spark / Discover / Library)
   ───────────────────────────────────────────────────────────────────── */
.nav-tab-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
/* Spark tab uses filled sparkle; restore fill for it */
#nav-spark .nav-tab-icon svg { fill: currentColor; stroke: none; }

/* ─────────────────────────────────────────────────────────────────────────
   LIBRARY TAB
   ───────────────────────────────────────────────────────────────────── */
.lib-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 18px 18px 10px;
}
.lib-title {
  font-family: var(--font-display);
  font-size: 1.85rem; font-weight: 600;
  color: var(--on-bg); letter-spacing: -0.025em;
  line-height: 1.05;
}
.lib-meta {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--on-bg-3); letter-spacing: 0.04em;
  margin-top: 4px;
}
.lib-filter-row {
  display: flex; gap: 6px; padding: 0 18px 12px;
  overflow-x: auto; scrollbar-width: none;
}
.lib-filter-row::-webkit-scrollbar { display: none; }
.lib-chip {
  padding: 7px 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-light); background: var(--surface);
  color: var(--on-bg-2); font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
  font-family: var(--font-body);
}
.lib-chip.active {
  border-color: var(--accent); background: var(--accent); color: #FFF;
  box-shadow: 0 4px 10px rgba(160,59,46,0.25);
}

.lib-loading {
  display: none; padding: 36px 0; text-align: center;
}
.lib-loading.visible { display: block; }
.lib-empty {
  padding: 32px 24px; text-align: center;
  font-size: 0.92rem; color: var(--on-bg-3); line-height: 1.55;
  font-style: italic;
}
.lib-groups { padding: 0 14px 24px; }
.lib-group { margin-bottom: 18px; }
.lib-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 8px;
}
.lib-group-label {
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--on-bg-2);
}
.lib-group-rule {
  flex: 1; height: 1px; background: var(--border-light);
}
.lib-group-loc {
  font-family: var(--font-mono); font-size: 0.6rem;
  color: var(--on-bg-3); letter-spacing: 0.04em;
}

.lib-group-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.lib-row {
  width: 100%; background: transparent;
  border: none; border-bottom: 1px solid var(--border-light);
  padding: 12px 14px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-body);
}
.lib-row:last-child { border-bottom: none; }
.lib-row:active { background: var(--bg); }
.lib-row-thumb {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: var(--radius-sm); overflow: hidden;
  position: relative; background: var(--bg-deep);
}
.lib-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-row-thumb-overlay {
  position: absolute; inset: 0; background: rgba(28,26,23,0.18);
  display: flex; align-items: center; justify-content: center;
}
.lib-row-thumb-overlay span {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.94);
  display: flex; align-items: center; justify-content: center;
}
.lib-row-thumb-overlay svg { fill: var(--on-bg); margin-left: 1px; }
.lib-row-meta { flex: 1; min-width: 0; }
.lib-row-cat {
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 2px;
}
.lib-row-title {
  font-size: 0.92rem; font-weight: 600; color: var(--on-bg);
  line-height: 1.3; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-row-poi-line {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.74rem; color: var(--on-bg-3);
}
.lib-row-poi-line svg { flex-shrink: 0; stroke: currentColor; fill: none; }
.lib-row-poi-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-row-when { font-family: var(--font-mono); font-size: 0.7rem; }
.lib-row-right {
  flex-shrink: 0; display: flex; flex-direction: column;
  align-items: flex-end; gap: 6px; min-width: 48px;
}
.lib-row-dur {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--on-bg-3);
}
.lib-row-progress {
  width: 44px; height: 2px; background: var(--border-light);
  border-radius: 999px; overflow: hidden;
}
.lib-row-progress-fill {
  height: 100%; background: var(--accent);
}
.lib-row-progress-fill.finished { background: var(--success); }

/* Library Story (detail) */
.lib-story-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
}
.lib-back-btn {
  background: transparent; border: none;
  font-size: 0.86rem; font-weight: 600; color: var(--on-bg-2);
  padding: 4px 0;
}
.lib-story-stamp {
  flex: 1; text-align: right;
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--on-bg-3); letter-spacing: 0.04em;
}
#lib-story-img-wrap {
  position: relative; aspect-ratio: 16/10; overflow: hidden;
}
#lib-story-img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.lib-pin {
  flex-shrink: 0; color: var(--accent);
}

/* Library story — long-form narration body */
.lib-story-script {
  display: block;
  font-family: var(--font-display);
  color: var(--on-bg-2);
  font-size: 1rem; line-height: 1.7;
  padding-top: 4px;
}
.lib-story-script p { margin: 0 0 14px; }
.lib-story-script p:last-child { margin-bottom: 0; }
.lib-story-script .lib-story-lead {
  font-size: 1.12rem; font-weight: 500; color: var(--on-bg);
  letter-spacing: -0.01em; line-height: 1.5;
  margin-bottom: 16px;
}
/* Lead-paragraph drop cap — body line is 1.12rem × 1.5 = 26.9px,
   2 lines = 53.8px. At 3.4em × 0.86 the glyph box is ~52.4px, so
   padding-top/margin-top are both 0 to stay inside 2 lines. */
.lib-story-script .lib-story-lead::first-letter {
  font-family: var(--font-display);
  font-weight: 700; font-size: 3.4em; line-height: 0.86;
  float: left; padding: 0 10px 0 0; margin-top: 0; margin-left: -2px;
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────────────────
   SKELETON SHIMMER — applied to .spark-result.skeleton during loading
   ───────────────────────────────────────────────────────────────────── */
.spark-result.skeleton .spark-img-wrap {
  background: linear-gradient(120deg, var(--bg-deep) 0%, var(--accent-soft) 50%, var(--bg-deep) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
.spark-result.skeleton .spark-title,
.spark-result.skeleton .spark-teaser,
.spark-result.skeleton .spark-poi-row {
  background: linear-gradient(90deg, var(--bg-deep) 0%, var(--accent-soft) 50%, var(--bg-deep) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
  color: transparent !important;
  border-radius: var(--radius-sm);
  min-height: 14px;
}
.spark-result.skeleton .spark-title { min-height: 28px; margin-bottom: 10px; }
.spark-result.skeleton .spark-teaser { min-height: 38px; }
.spark-result.skeleton .btn-play-floating { opacity: 0.6; pointer-events: none; }

