/* Ride Atlas — modern dark map UI
 * Softer slate surfaces and a single calm accent that complement the CartoDB
 * Voyager tiles revealed through the fog overlay.
 */
:root {
  --bg-deep: #0c111b;
  --bg-panel: rgba(20, 27, 40, 0.82);
  --bg-panel-solid: #141b28;
  --bg-elev: #1c2536;          /* hover / raised surfaces */
  --border: rgba(150, 170, 200, 0.16);
  --border-strong: rgba(150, 170, 200, 0.32);
  --text: #e9eef6;
  --text-dim: #93a3bd;
  --accent: #1ed760;           /* Pocket Casts direction — Spotify green */
  --accent-strong: #3be477;
  --accent-contrast: #04140a;  /* text/icons on an accent fill */
  --accent-warm: #ffcf5a;      /* gold — saved/starred */
  --accent-hot: #ff6b6b;
  --good: #34e39a;
  --heat-cool: #1a1a3a;
  --heat-warm: #ff7a18;
  --heat-hot: #ffe066;
  --fog: rgba(7, 9, 15, 0.92);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 12px;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Dock dimensions */
  --rail-w: 48px;
  --panel-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

body { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   DESKTOP DOCK  (icon rail + sliding panels)
   ═══════════════════════════════════════════════════════════════════════════ */

/* The dock is a flex column that sits at the left of the body flex row.
   It owns the rail (always 48px) and whichever panel is active (up to 300px). */
#dock {
  display: flex;
  flex-direction: row;
  flex: 0 0 auto;
  height: 100vh;
  z-index: 700;
  position: relative;
}

/* ── Icon rail ───────────────────────────────────────────────────────────── */
#rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-solid);
  border-right: 1px solid var(--border);
  z-index: 2;
  overflow: hidden;
}

#rail-tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  gap: 4px;
}

.rail-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: background 120ms, border-color 120ms, color 120ms;
  position: relative;
  padding: 0;
}
.rail-btn:hover {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
}
.rail-btn[aria-selected="true"] {
  background: var(--bg-elev);
  border-color: var(--accent);
  color: var(--accent);
}
/* Active indicator — left edge bar */
.rail-btn[aria-selected="true"]::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

#rail-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 10px;
  border-top: 1px solid var(--border);
  gap: 6px;
}

/* Compact mini-stats readout in the rail footer */
#mini-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  line-height: 1.3;
  text-align: center;
}
.mini-stat { color: var(--accent); font-size: 10px; }
/* The rail is too narrow for an inline row, so the readout stacks vertically;
   the "·" separators only make sense horizontally, so hide them here. */
.mini-sep  { display: none; }

/* dock-footer wraps #sync-btn so it's outside #rail (which is display:none on
   mobile) while still sitting visually below the rail on desktop. */
#dock-footer {
  /* On desktop: positioned absolute at the bottom of the rail column */
  position: absolute;
  bottom: 10px;
  left: 0;
  width: var(--rail-w);
  display: flex;
  justify-content: center;
  z-index: 3;
}

/* ── Sync button ─────────────────────────────────────────────────────────── */
/* Desktop: compact icon-only button inside the rail footer area. */
#sync-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: var(--shadow);
  color: var(--accent-contrast);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms, transform 80ms, opacity 140ms;
}
#sync-btn:hover { background: var(--accent-strong); }
#sync-btn:active { transform: translateY(1px); }
#sync-btn:disabled { cursor: progress; opacity: 0.85; }
#sync-btn .sync-icon { font-size: 18px; display: inline-block; }
#sync-btn .sync-label { display: none; }   /* label hidden on desktop */
#sync-btn.syncing .sync-icon { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sliding panels ──────────────────────────────────────────────────────── */

/* All dock panels share a common style when shown inside the dock. */
#rides-sidebar,
#route-panel,
#library-panel,
#panel-stats,
#settings-drawer {
  /* Desktop panel positioning: inline flex child of #dock. */
  flex: 0 0 0;
  width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-panel-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: flex-basis 220ms ease, width 220ms ease;
  /* panels start collapsed; .panel-open expands them */
}

/* When a panel is the active rail tab it expands to full width.
   Only one panel is open at a time on desktop. */
@media (min-width: 768px) {
  #rides-sidebar.panel-open,
  #route-panel.panel-open,
  #library-panel.panel-open,
  #panel-stats.panel-open,
  #settings-drawer.panel-open {
    flex-basis: var(--panel-w);
    width: var(--panel-w);
  }

  /* Remove the hidden attribute effect — visibility controlled by panel-open. */
  #rides-sidebar,
  #route-panel,
  #library-panel,
  #panel-stats,
  #settings-drawer {
    display: flex !important;  /* override HTML hidden attribute on desktop */
  }
}

/* Panel header */
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.panel-head h2 {
  margin: 0;
  flex: 1;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Import GPX button inside Rides panel header */
.panel-import-btn {
  flex-shrink: 0;
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  min-height: 28px;
  display: flex;
  align-items: center;
}

/* Panel body (generic scrollable content area) */
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* ── Rides panel specifics ───────────────────────────────────────────────── */

#sidebar-toggle {
  flex-shrink: 0;
}

/* ── Metrics card — inline in Rides panel ───────────────────────────────── */
.panel-metrics {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  position: relative;
  min-width: 0;
}
.panel-metrics[hidden] { display: none; }

/* Stats panel body */
#panel-stats .panel-body #stats-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}
#stats-panel .stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(120, 200, 255, 0.08);
}
#stats-panel .stat:last-child { border-bottom: none; }
#stats-panel .stat .label {
  color: var(--text-dim);
  font-size: 12px;
}
#stats-panel .stat .value {
  font-family: var(--mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

/* Route panel: body always visible on desktop (the toggle is for mobile). */
#route-panel .route-head {
  width: 100%;
  margin-top: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 12px;
}
#route-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 14px;
  min-width: 0;
}
#route-body[hidden] { display: none; }

/* Settings panel: keep drawer-body layout */
#settings-drawer .drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#settings-drawer .drawer-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.drawer-body {
  padding: 10px 14px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Drawer section: a named group with a little top gap */
.drawer-section {
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(120, 200, 255, 0.08);
  margin-bottom: 2px;
}

/* Range + checkbox accents inside the drawer */
.drawer-body input[type="range"] { accent-color: var(--accent); }
.drawer-body input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Map-layers controls live in Settings on mobile only; desktop draws the
   trails toggle as the first item in the Settings panel (drawer-section above).
   The drawer-mobile-only block stays hidden on desktop. */
.drawer-mobile-only { display: none; }
@media (max-width: 767px) { .drawer-mobile-only { display: block; } }

/* On desktop, hide the desktop-only drawer-section (trails toggle) from mobile
   because mobile uses the drawer-mobile-only duplicate. */
@media (max-width: 767px) { .drawer-section { display: none; } }

.drawer-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  padding: 9px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.drawer-toggle-row input[type="checkbox"] { width: 18px; height: 18px; }

/* ── Map area ────────────────────────────────────────────────────────────── */

#map-area {
  position: relative;
  flex: 1 1 auto;
  height: 100vh;
  min-width: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg-deep);
}

/* Settings cog: kept in DOM for JS, but hidden on desktop (rail ⚙ tab replaces it). */
#settings-cog {
  display: none;
}

/* ── HUD base class ─────────────────────────────────────────────────────── */
.hud {
  position: absolute;
  z-index: 600;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.hud h1, .hud h2, .hud h3 {
  margin: 0 0 10px 0;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
  color: var(--text);
}

/* ── Playback strip ──────────────────────────────────────────────────────── */
#playback-panel {
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms, transform 80ms;
}
.btn:hover { background: #232d40; border-color: var(--border-strong); color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-strong); color: var(--accent-contrast); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--accent); }

/* ── Playback scrubber ───────────────────────────────────────────────────── */
#playback-scrub {
  flex: 1;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--scrub-pct, 0%), rgba(255,255,255,0.12) var(--scrub-pct, 0%));
  border-radius: 2px;
  cursor: pointer;
}
#playback-scrub::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  cursor: grab;
}
#playback-scrub::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  border: none;
}

#date-label {
  font-family: var(--mono);
  font-size: 13px;
  min-width: 110px;
  text-align: center;
  color: var(--accent);
}

#speed-select {
  background: var(--bg-panel-solid);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 1200;
  max-width: min(440px, calc(100vw - 32px));
  padding: 10px 16px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(255, 107, 107, 0.5); color: #ffb0b0; }
#toast.success { border-color: rgba(95, 220, 160, 0.45); color: var(--good); }

/* ── Icon button ─────────────────────────────────────────────────────────── */
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--border); }

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 2px;
}
.segmented input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.segmented label {
  text-align: center;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: background 140ms, color 140ms;
}
.segmented label:hover { color: var(--text); }
.segmented input:checked + label {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}
.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Settings toggle (collapsible section header) ────────────────────────── */
.settings-toggle {
  margin-top: 4px;
  padding: 9px 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 120ms;
  width: 100%;
}
.settings-toggle:hover { border-color: var(--border-strong); }
.settings-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.settings-toggle .chev { transition: transform 150ms; font-size: 14px; }

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed rgba(120, 200, 255, 0.12);
  margin-top: 2px;
}
.settings-section[hidden] { display: none; }

.settings-section .slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.settings-section .slider input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 2px 0 0;
  accent-color: var(--accent);
}
.settings-section .slider output {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-size: 11px;
  min-width: 40px;
  text-align: right;
}

.settings-reset {
  margin-top: 4px;
  font-size: 11px;
  padding: 5px 8px;
}

/* ── Integrations ─────────────────────────────────────────────────────────── */
#integrations-list { display: flex; flex-direction: column; gap: 8px; }

.intg-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.intg-head { display: flex; align-items: center; justify-content: space-between; }
.intg-name { font-weight: 600; font-size: 12px; letter-spacing: 0.04em; }

.intg-badge {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.intg-badge.on   { color: #6ef0a8; border-color: rgba(110, 240, 168, 0.4); }
.intg-badge.warn { color: var(--accent-warm); border-color: rgba(255, 174, 58, 0.4); }
.intg-badge.off  { color: var(--text-dim); }

.intg-note { font-size: 11px; color: var(--text-dim); margin: 0; }
.intg-note code, .intg-help code { font-family: var(--mono); color: var(--accent); font-size: 10px; }

.intg-input {
  width: 100%;
  background: var(--bg-panel-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
  box-sizing: border-box;
}
.intg-input:focus { outline: none; border-color: var(--border-strong); }

.intg-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.intg-actions .btn { font-size: 11px; padding: 5px 9px; }

.intg-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0;
  font-size: 11px;
}
.intg-stats dt { color: var(--text-dim); }
.intg-stats dd { margin: 0; font-family: var(--mono); color: var(--accent); }

.intg-switch { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); cursor: pointer; }
.intg-switch input { accent-color: var(--accent); }

.intg-help { font-size: 11px; color: var(--text-dim); }
.intg-help summary { cursor: pointer; color: var(--accent); }
.intg-help ol { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }

.intg-msg { font-size: 11px; color: var(--text-dim); min-height: 14px; padding-top: 2px; }
.intg-msg.error { color: var(--accent-hot); }

/* ---------- Admin panel (settings drawer) ---------- */
.admin-create { display: flex; flex-direction: column; gap: 6px; }
.admin-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); }
.admin-field input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  background: rgba(10, 16, 26, 0.8);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 8px;
  min-height: 36px;
}
.admin-field input[type="email"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.admin-create-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-admin-toggle { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.admin-hint { font-size: 10px; color: var(--text-dim); margin: 0; }

.admin-users { display: flex; flex-direction: column; gap: 8px; }
.admin-user {
  border: 1px solid rgba(120, 200, 255, 0.14);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Tinted wash instead of opacity: dimming the whole card via opacity dragged
   --text-dim below 3:1 against the panel background (fails WCAG AA). The
   "disabled" badge text already carries the meaning; this is a supporting
   visual cue only, so full-strength text stays readable. */
.admin-user.disabled { background: rgba(255, 107, 107, 0.05); border-color: rgba(255, 107, 107, 0.3); }
.admin-user-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.admin-user-email {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.admin-badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 4px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.admin-badge.admin { color: var(--accent); border-color: var(--accent); }
.admin-badge.off { color: var(--accent-hot); border-color: var(--accent-hot); }
.admin-badge.pending { color: var(--accent-warm); border-color: var(--accent-warm); }
.admin-user-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 10px;
  color: var(--text-dim);
}
.admin-user-you { font-size: 10px; color: var(--text-dim); font-style: italic; }
.admin-user-actions { display: flex; gap: 8px; }
/* 34px is the drawer's compact-button floor elsewhere (.btn default ~34px);
   the old 3px/8px padding here rendered at ~20px tall — well under any tap
   target in the app, let alone the 48px mobile guideline. */
.admin-user-actions .btn { flex: 1; font-size: 11px; padding: 8px 10px; min-height: 34px; }

/* ── Rides list ───────────────────────────────────────────────────────────── */
#rides-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 16px;
  min-width: 0;
}
.rides-summary {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0 2px 6px;
}
.rides-empty { font-size: 11px; color: var(--text-dim); margin: 2px; }

.rides-ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ride-item {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  padding: 9px 11px;
}
.ride-item.is-hidden { opacity: 0.45; }
.ride-item.selected {
  border-color: var(--border-strong);
  background: rgba(76, 201, 255, 0.08);
}

.ride-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: transparent;
  border: none;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: var(--sans);
}
.ride-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ride-main:hover .ride-name { color: var(--accent); }
.ride-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Pocket Casts list "art": a colour-coded circular coin holding a mini trace of
   the ride/route's real shape. */
.ride-thumb, .lib-thumb {
  flex: 0 0 auto;
  width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent);
  border: 2px solid var(--c, var(--accent));
  display: grid; place-items: center;
}
.lib-thumb { width: 44px; height: 44px; }
.ride-thumb svg, .lib-thumb svg { width: 100%; height: 100%; display: block; }
.ride-thumb path, .lib-thumb path {
  fill: none; stroke: #eef2f7; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; opacity: .96;
}
.ride-src { color: var(--accent); text-transform: uppercase; }

.ride-tools { display: flex; gap: 2px; flex-shrink: 0; }
.ride-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.ride-icon:hover { color: var(--accent); border-color: var(--border); }
.ride-icon[aria-pressed="true"] { color: var(--text-dim); }
.ride-icon.danger:hover { color: var(--accent-hot); border-color: rgba(255, 91, 91, 0.4); }

/* Inline delete confirmation (replaces window.confirm) */
.ride-confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 6px;
  font-size: 11px;
  width: 100%;
  margin-top: 4px;
}
.ride-confirm-msg { flex: 1; min-width: 0; color: var(--text-dim); }
.ride-confirm-msg em { color: var(--text); font-style: normal; }
.ride-confirm-yes {
  background: var(--accent-hot);
  border-color: var(--accent-hot);
  color: #fff;
  padding: 3px 8px;
  font-size: 11px;
  min-height: 26px;
}
.ride-confirm-yes:hover { background: #ff4040; }
.ride-confirm-no { padding: 3px 8px; font-size: 11px; min-height: 26px; }

/* Inline error message on a ride row */
.ride-inline-err {
  width: 100%;
  font-size: 10px;
  color: var(--accent-hot);
  padding: 2px 4px;
}

/* Eye toggle */
.ride-icon.eye svg { display: block; }
.ride-icon.eye[aria-pressed="false"] { color: var(--accent); }
.ride-icon.eye[aria-pressed="true"]  { color: var(--text-dim); opacity: 0.65; }

/* ── Ride metrics card (inline in Rides panel) ────────────────────────────── */
#metrics-card {
  position: relative;
  width: 100%;
  padding: 12px 14px;
}
#metrics-card[hidden] { display: none; }
.metrics-close {
  position: absolute;
  top: 7px;
  right: 9px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
}
.metrics-close:hover { color: var(--accent-hot); }
.metrics-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  padding: 0 18px 6px 0;
  border-bottom: 1px dashed var(--border);
}
.metrics-grid {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 4px;
}
.metrics-grid dt {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center;
}
.metrics-grid dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
  text-align: right;
}

/* ── File input (hidden; triggered by label in panel header) ──────────────── */
#file-input { display: none; }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 9, 15, 0.7);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  pointer-events: none;
  transition: opacity 300ms;
  text-align: center;
  padding: 24px;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-overlay.empty {
  background: transparent;
  pointer-events: none;
  align-items: flex-start;
  padding-top: 84px;
}

.empty-state {
  max-width: 460px;
  padding: 28px 32px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.empty-state__cta { margin-top: 18px; width: 100%; }
.empty-state__title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 8px;
}
.empty-state__hint {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
}
.empty-state__hint code {
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(76, 201, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Ride detail popup ────────────────────────────────────────────────────── */
.leaflet-popup.ride-popup-wrap .leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.leaflet-popup.ride-popup-wrap .leaflet-popup-content {
  margin: 12px 14px;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
}
.leaflet-popup.ride-popup-wrap .leaflet-popup-tip {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
}
.leaflet-popup.ride-popup-wrap a.leaflet-popup-close-button { color: var(--text-dim); }
.ride-popup__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.ride-popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 2px;
}
.ride-popup dt {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center;
}
.ride-popup dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* ── Leaflet overrides ────────────────────────────────────────────────────── */
.leaflet-control-attribution {
  background: rgba(7, 9, 15, 0.7) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-bar a {
  background: var(--bg-panel-solid) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* ── Canvas overlays ──────────────────────────────────────────────────────── */
.heat-canvas, .fog-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}

/* ── Route planner (panel variant) ───────────────────────────────────────── */
.route-modes { grid-template-columns: 1fr 1fr; }
.route-modes label { padding: 6px 4px; font-size: 11px; }
.route-slider[hidden] { display: none; }

.route-home-editor { font-size: 11px; color: var(--text-dim); }
.route-home-editor > summary {
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-home-editor > summary::-webkit-details-marker { display: none; }
.route-home-row { display: flex; gap: 6px; margin: 4px 0; }
.route-home-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
}
.route-home-row input:focus-visible { outline: none; border-color: var(--accent); }
.route-home-row .btn { padding: 5px 10px; }
#route-use-home.no-home { opacity: 0.7; }

.route-hint {
  margin: 0;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
  min-height: 26px;
}

.route-slider {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.route-slider input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.route-slider output { font-family: var(--mono); color: var(--accent); font-size: 11px; text-align: right; }

.route-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
}
.route-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

.route-pick {
  text-align: left;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-pick.armed { border-color: var(--accent); color: var(--accent); }

.route-actions { display: flex; gap: 6px; }
.route-actions .btn { flex: 1; }

.route-status { font-size: 11px; color: var(--text-dim); min-height: 14px; }
.route-status.error { color: var(--accent-hot); }

/* ── Draw-your-own route builder ─────────────────────────────────────────── */
.route-draw { display: flex; flex-direction: column; gap: 8px; }
.route-draw[hidden] { display: none; }
.draw-stats {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--accent);
}
.draw-stats #draw-count { color: var(--text-dim); }
.draw-save-row { display: flex; gap: 6px; }
.draw-save-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
}
.draw-save-row input:focus-visible { outline: none; border-color: var(--accent); }
.draw-save-row .btn { padding: 5px 10px; white-space: nowrap; }

.draw-legend { font-size: 10px; color: var(--text-dim); line-height: 1.4; }
.draw-legend .dot { color: #4cc9ff; }
.draw-legend .mid { color: rgba(255, 255, 255, 0.85); }

/* Waypoint dots on the map: a small visual dot centered in a larger invisible
   hit box (the Leaflet divIcon), so touch can grab them reliably. */
.draw-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.draw-dot {
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4cc9ff;
  border: 2px solid #0b1220;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}
.draw-dot.start { background: #6ef0a8; }
.draw-dot.end { background: #ff5b5b; }
.draw-mid {
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #4cc9ff;
  opacity: 0.75;
}

.route-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(120, 200, 255, 0.12);
}
.route-result[hidden] { display: none; }
.route-stats {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--accent);
}
.route-dl { text-align: center; text-decoration: none; }

.route-qr-wrap { display: flex; gap: 10px; align-items: center; }
.route-qr-wrap[hidden] { display: none; }
.route-qr { background: #fff; padding: 5px; border-radius: 6px; line-height: 0; flex-shrink: 0; }
.route-qr img { display: block; width: 92px; height: 92px; image-rendering: pixelated; }
.route-qr-side { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.route-qr-label { font-size: 10px; color: var(--text-dim); }

/* ── Focus ring (keyboard nav) ────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Mobile backdrop ──────────────────────────────────────────────────────── */
#mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 690;
  background: rgba(7, 9, 15, 0.55);
  backdrop-filter: blur(2px);
}
#mobile-backdrop.visible { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE / TOUCH LAYOUT  (≤ 767px)
   Pattern: full-screen map + bottom nav bar + bottom sheets.
   The dock uses display:contents so its children can act as overlays.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* Reset body flex */
  body {
    display: block;
    overflow: hidden;
  }

  /* Dock becomes invisible as a layout box; its children flow normally. */
  #dock {
    display: contents;
  }

  /* dock-footer contains #sync-btn — it needs fixed top-right on mobile. */
  #dock-footer {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: auto;
    left: auto;
    width: auto;
    z-index: 600;
  }

  /* Rail is hidden on mobile — bottom nav replaces it. */
  #rail { display: none; }

  /* Sync button becomes the pill-shaped floating button it was originally. */
  #sync-btn {
    width: auto;
    height: 40px;
    border-radius: 999px;
    gap: 8px;
    padding: 0 16px;
    font-size: 14px;
  }
  #sync-btn .sync-label { display: inline; }

  /* Panels collapse on mobile: slides in as overlays. */
  #rides-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 88vw);
    height: 100dvh;
    flex: none;
    flex-basis: auto !important;
    z-index: 710;
    transform: translateX(-100%);
    transition: transform 240ms ease;
    overflow: hidden;
    display: flex !important;
  }
  #rides-sidebar.mobile-open {
    transform: translateX(0);
  }
  /* On mobile, the sidebar-toggle X closes the panel */
  #sidebar-toggle { display: flex; }

  /* Settings drawer: slide in from right on mobile */
  #settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 80vw) !important;
    flex-basis: auto !important;
    height: 100dvh;
    flex: none;
    z-index: 1100;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 220ms ease, visibility 220ms ease;
    border-right: none;
    border-left: 1px solid var(--border);
    box-shadow: -14px 0 36px rgba(0, 0, 0, 0.5);
    display: flex !important;
  }
  #settings-drawer.open {
    transform: translateX(0);
    visibility: visible;
  }

  /* Route panel becomes a bottom sheet */
  #route-panel {
    position: fixed !important;
    top: auto !important;
    left: 0;
    right: 0;
    bottom: 64px;
    width: auto !important;
    flex-basis: auto !important;
    max-height: 70dvh;
    border-radius: 14px 14px 0 0;
    z-index: 696;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 240ms ease, visibility 240ms ease;
    border-right: none;
    border-top: 1px solid var(--border);
    display: flex !important;
  }
  #route-panel.mobile-show {
    transform: translateY(0);
    visibility: visible;
  }
  /* Draw mode needs the map, not the sheet: cap the sheet low so most of the
     screen stays free for tapping and dragging waypoints. */
  #route-panel.draw-mode {
    max-height: 40dvh;
    overflow-y: auto;
  }

  /* Stats panel lives in sheet-stats on mobile */
  #panel-stats { display: none !important; }

  /* Desktop sidebar-toggle arrow is hidden on mobile */
  .panel-import-btn { display: none; }

  /* Map area fills the whole screen */
  #map-area {
    position: fixed;
    inset: 0;
    bottom: 64px;
    height: auto;
  }

  /* No zoom buttons on mobile */
  .leaflet-control-zoom { display: none; }

  /* Playback is a bottom sheet on mobile */
  #playback-panel { display: none; }

  /* settings-cog stays hidden everywhere */
  #settings-cog { display: none; }

  /* Mini-stats only for desktop */
  #mini-stats { display: none; }

  /* Bottom navigation bar */
  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 700;
    background: var(--bg-panel-solid);
    border-top: 1px solid var(--border);
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 44px;
    min-height: 44px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 8px 4px;
    position: relative;
    transition: color 140ms;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-btn:active,
  .nav-btn[aria-expanded="true"] {
    color: var(--accent);
  }
  .nav-btn[aria-expanded="true"]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 28%;
    right: 28%;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
  }
  .nav-icon {
    font-size: 24px;
    line-height: 1;
    display: block;
  }
  .nav-label {
    font-size: 11px;
    font-family: var(--sans);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1;
  }

  /* Bottom sheets */
  .mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 64px;
    z-index: 695;
    background: var(--bg-panel-solid);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    transform: translateY(100%);
    transition: transform 260ms ease, visibility 260ms ease;
    visibility: hidden;
    max-height: 60dvh;
    display: flex;
    flex-direction: column;
    display: flex !important;
  }
  .mobile-sheet.sheet-open {
    transform: translateY(0);
    visibility: visible;
  }

  .sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .sheet-title {
    margin: 0;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .sheet-subtitle {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }
  .sheet-close {
    /* ≥48px touch target (WCAG 2.5.5 / Material) */
    width: 48px;
    height: 48px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .sheet-body {
    padding: 14px 16px 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  /* Stats sheet */
  #sheet-stats .stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(120, 200, 255, 0.08);
  }
  #sheet-stats .stat:last-child { border-bottom: none; }
  #sheet-stats .label {
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  #sheet-stats .value {
    font-family: var(--mono);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
  }

  #sheet-layers .segmented { font-size: 13px; }
  #sheet-layers .segmented label { padding: 10px 8px; font-size: 12px; }
  .sheet-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-dim);
    padding: 2px 0;
  }
  .sheet-toggle-row input[type="checkbox"] { accent-color: var(--accent); width: 20px; height: 20px; }
  .sheet-divider { height: 1px; background: var(--border); margin: 2px 0; }

  /* Playback sheet */
  .sheet-playback-body { gap: 14px; }
  .sheet-playback-scrub { display: flex; flex-direction: column; gap: 4px; }
  .sheet-playback-scrub input[type="range"] {
    width: 100%;
    appearance: none;
    height: 6px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--scrub-pct, 0%), rgba(255,255,255,0.12) var(--scrub-pct, 0%));
    border-radius: 3px;
    cursor: pointer;
    accent-color: var(--accent);
  }
  .sheet-playback-scrub input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    cursor: grab;
  }
  .sheet-playback-scrub input[type="range"]::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
  }
  .sheet-date-label {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    text-align: center;
  }
  .sheet-playback-controls { display: flex; gap: 10px; align-items: center; }
  .sheet-play-btn { flex: 1; padding: 10px 12px; font-size: 14px; min-height: 44px; }
  #m-speed-select {
    background: var(--bg-panel-solid);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 8px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12px;
    min-height: 44px;
  }
  #m-reset-btn { min-height: 44px; padding: 10px 14px; }

  /* Landscape / tablet tweaks */
  @media (orientation: landscape) and (max-height: 500px) {
    #map-area { bottom: 48px; }
    #mobile-nav { height: 48px; }
    .mobile-sheet { max-height: 80dvh; }
  }
}

/* ── Tablets: 768–1023px ──────────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  /* ≥48px touch targets. The rail widens so 48px buttons fit inside its
     border-box (48px rail − 1px border would clip them). */
  :root      { --rail-w: 56px; }
  .icon-btn  { width: 48px; height: 48px; }
  .rail-btn  { width: 48px; height: 48px; min-height: 48px; }
  .nav-btn   { min-width: 48px; min-height: 48px; }
  .btn       { min-height: 36px; }
}

/* ── Desktop: hide mobile-only elements ───────────────────────────────────── */
@media (min-width: 768px) {
  #mobile-nav      { display: none; }
  .mobile-sheet    { display: none !important; }
  #mobile-backdrop { display: none !important; }
  /* sidebar-toggle on desktop is the X close button inside the panel head */
  #sidebar-toggle  { display: flex; }
}

/* ── Reduced motion: disable slide transitions ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #rides-sidebar,
  #route-panel,
  #library-panel,
  #settings-drawer,
  #panel-stats,
  .mobile-sheet,
  .settings-toggle .chev,
  .rail-btn {
    transition: none;
  }
  #sync-btn.syncing .sync-icon { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Phase E — familiarity slider readout, destination options, route library,
   device key. Reuses .btn / .route-slider / .route-check / tokens.
   ═════════════════════════════════════════════════════════════════════════ */

/* Destination options (planner) */
.route-options { margin-top: 10px; }
.route-options-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); margin-bottom: 6px;
}
.option-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 8px 10px; margin-bottom: 7px;
}
.option-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.option-label { font-weight: 600; font-size: 13px; }
.option-badge {
  font-family: var(--mono); font-size: 11px; color: var(--accent-contrast);
  background: var(--good); border-radius: 999px; padding: 1px 8px;
}
.option-meta { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin: 2px 0 7px; }
.option-actions { display: flex; gap: 6px; }
.option-actions .btn { flex: 1; padding: 5px 8px; font-size: 12px; }

/* Route library panel */
.library-body { display: flex; flex-direction: column; gap: 10px; }
.library-list { display: flex; flex-direction: column; gap: 9px; }
.lib-empty { color: var(--text-dim); font-size: 12px; padding: 10px 2px; text-align: center; }
.lib-empty.error { color: var(--accent-hot); }

/* Roomy Pocket-Casts rows: circular art + title + star on top, actions below —
   an explicit two-part stack so nothing bunches or wraps on a 300px panel. */
.lib-row {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); padding: 12px 14px;
}
.lib-top { display: flex; align-items: center; gap: 12px; }
.lib-star {
  background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;
  color: var(--text-dim); padding: 0; flex: 0 0 auto;
}
.lib-star.on { color: var(--accent-warm); }
.lib-info { flex: 1 1 auto; min-width: 0; }
.lib-name {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-sub {
  font-size: 12px; color: var(--text-dim); font-family: var(--mono);
  margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.lib-fam {
  color: var(--accent); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 1px 8px; font-family: var(--sans); font-size: 11px;
}
/* Second line: actions each fill evenly and are finger-sized. */
.lib-actions { display: flex; align-items: stretch; gap: 8px; }
.lib-act {
  flex: 1; text-align: center;
  background: var(--bg-panel-solid); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; cursor: pointer;
  font-size: 13px; padding: 8px 10px; text-decoration: none; line-height: 1.4;
}
.lib-act:hover { border-color: var(--border-strong); background: var(--bg-elev); }
.lib-del { flex: 0 0 auto; color: var(--accent-hot); padding: 8px 14px; }

/* Build-a-set + chips */
.set-builder-body { display: flex; flex-direction: column; gap: 8px; }
.set-builder-body[hidden] { display: none; }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.set-summary { font-size: 11px; color: var(--text-dim); min-width: 0; overflow-wrap: anywhere; }
.set-cog { flex-shrink: 0; }
.set-config { display: flex; flex-direction: column; gap: 8px; }
.set-config[hidden] { display: none; }
.set-builder-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); margin-top: 2px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--bg-panel-solid);
  color: var(--text-dim); border-radius: 999px; cursor: pointer;
  font-size: 12px; padding: 4px 11px;
}
.chip.on { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.lib-filter { margin: 0; }

/* Device / watch key */
.device-section { display: flex; flex-direction: column; gap: 8px; }
.device-head { font-weight: 600; font-size: 13px; }
.device-hint { font-size: 11px; color: var(--text-dim); margin: 0; line-height: 1.4; }
.device-key-out {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  background: var(--bg-panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.device-qr {
  background: #fff; padding: 10px; border-radius: 10px;
  align-self: center; line-height: 0;
}
.device-qr img { display: block; width: 176px; height: 176px; image-rendering: pixelated; }
.device-key-manual { display: flex; align-items: center; gap: 6px; }
.device-key-manual code { flex: 1; }
#device-key-value {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11px;
  color: var(--accent); word-break: break-all;
}
.device-key-note { flex-basis: 100%; font-size: 10px; color: var(--text-dim); }

/* Minimalist stroke nav icons (SVG sprite via <use>). currentColor follows the
   button's colour, so active/hover states just work. */
svg.rail-icon { width: 22px; height: 22px; display: block; }
svg.nav-icon { width: 24px; height: 24px; display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   Phase F — modal (help / cue sheet), account row, cue list, empty-state alt.
   Reuses .btn / .icon-btn / tokens.
   ═════════════════════════════════════════════════════════════════════════ */

/* ── Modal (shared by help + cue sheet) ──────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 9, 15, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(440px, 100%);
  max-height: min(72dvh, 580px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.modal-body p { margin: 0 0 10px; }

/* Help modal content */
.help-list {
  margin: 0 0 10px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-dim);
}
.help-list b { color: var(--text); }
.help-keys { color: var(--text-dim); font-size: 12px; }
.help-keys kbd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.help-footer {
  color: var(--text-dim);
  font-size: 11px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-bottom: 0;
}
.help-footer a { color: var(--accent); }

/* Rail footer "?" help button — a compact sibling of the rail tabs. */
#rail-footer .rail-help {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--mono);
}

/* ── Account row (Settings) ──────────────────────────────────────────────── */
.account-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.account-section[hidden] { display: none; }
.account-email {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#account-signout { font-size: 11px; padding: 5px 9px; flex-shrink: 0; }

/* ── Cue sheet (turn-by-turn list) ───────────────────────────────────────── */
.cue-sub {
  padding: 8px 16px 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.cue-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cue-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-bottom: 1px dashed rgba(120, 200, 255, 0.08);
}
.cue-row:last-child { border-bottom: none; }
.cue-glyph {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  color: var(--accent);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cue-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cue-text { font-size: 13px; font-weight: 500; }
.cue-next { font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); }
.cue-dist {
  flex-shrink: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-dim);
}
.cue-empty {
  padding: 14px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

/* ── Empty-state second line (Import GPX alternative) ────────────────────── */
.empty-state__alt {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
.empty-state__import {
  font-size: 12px;
  padding: 2px 6px;
  color: var(--accent);
  text-decoration: underline;
  border: none;
}
