/* ============================================================
   MyMoto — Dark theme, mobile-first
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --bg2: #1a1a1a;
  --bg3: #262626;
  --accent: #ff5500;
  --accent2: #ff8800;
  --text: #f0f0f0;
  --text2: #aaaaaa;
  --green: #00e676;
  --red: #ff1744;
  --yellow: #ffea00;
  --blue: #2979ff;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* ============================================================
   Screens
   ============================================================ */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  overflow-y: auto;
}
.screen.active { display: flex; }

/* ============================================================
   Auth Screen
   ============================================================ */
#screen-auth {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a0a00 0%, var(--bg) 70%);
}

.auth-container {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.5rem;
}

.logo {
  text-align: center;
  margin-bottom: 3rem;
}
.logo-icon { font-size: 4rem; display: block; }
.logo h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.5px; color: var(--accent); }
.logo p { color: var(--text2); margin-top: 0.25rem; }

.auth-buttons { display: flex; flex-direction: column; gap: 0.75rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.85rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-google   { background: #fff;      color: #333; }
.btn-facebook { background: #1877f2;   color: #fff; }
.btn-apple    { background: #000;      color: #fff; border: 1px solid #333; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary{ background: var(--bg3); color: var(--text); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--bg3); }
.btn-danger   { background: var(--red); color: #fff; }
.btn-icon     { background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: 0.4rem; }

/* ============================================================
   Burger menu
   ============================================================ */
.burger-wrap {
  position: relative;
  flex-shrink: 0;
}

.burger-toggle {
  font-size: 1.5rem;
  padding: 0.4rem 0.55rem;
  line-height: 1;
}

.burger-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 200;
  overflow: hidden;
}

.burger-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.burger-item:active,
.burger-item:hover { background: var(--bg3); }

.burger-item svg { flex-shrink: 0; opacity: 0.8; }

.burger-item-exit   { color: var(--red); }
.burger-item-exit svg { stroke: var(--red); }
.burger-item-danger { color: #e53e3e; }

.burger-item-admin { color: var(--yellow); }
.burger-item-admin svg { stroke: var(--yellow); }
a.burger-item-admin { text-decoration: none; }

.burger-version {
  padding: 0.45rem 1.1rem;
  font-size: 0.78rem;
  color: var(--text2);
  letter-spacing: 0.03em;
}

/* ============================================================
   Debug Overlay (admin only)
   ============================================================ */
#audio-debug {
  position: fixed;
  top: 80px;
  left: 10px;
  width: min(340px, calc(100vw - 20px));
  min-width: 260px;
  min-height: 180px;
  overflow: auto;
  resize: both;
  z-index: 9999;
  background: rgba(13,13,13,0.97);
  border: 1.5px solid var(--yellow);
  border-radius: 12px;
  padding: 0;
  font-size: 0.88rem;
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.8);
  user-select: none;
}
#audio-debug.hidden { display: none; }

/* Drag handle — title row above tabs */
#audio-debug-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 6px;
  cursor: grab;
  border-bottom: 1px solid var(--bg3);
  border-radius: 12px 12px 0 0;
  touch-action: none;
}
#audio-debug-handle:active { cursor: grabbing; }

/* Tab bar — no drag behaviour */
#audio-debug-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--bg3);
}

#audio-debug-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 0.05em;
}

#audio-debug-close {
  background: none;
  border: 1px solid var(--bg3);
  border-radius: 6px;
  color: var(--text2);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  min-height: 36px;
}

/* Two-column key/value grid */
.dbg-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin-bottom: 12px;
}
.dbg-label {
  color: var(--text2);
  white-space: nowrap;
  line-height: 1.5;
}
.dbg-val {
  font-weight: 700;
  line-height: 1.5;
  word-break: break-all;
}

/* Debug section layout */
.dbg-section-body { padding: 6px 12px 8px; }
.dbg-divider { height: 1px; background: var(--bg3); margin: 4px 0; }

/* Multi-line sections (peers, remote audio) */
.dbg-section-label {
  color: var(--text2);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px 2px;
  margin: 0;
}
.dbg-section-audio { color: var(--green);  }
.dbg-section-mock  { color: var(--yellow); }
.dbg-multi {
  font-weight: 700;
  line-height: 1.6;
  padding-left: 4px;
  min-height: 1.4em;
}

/* Mock section */
.dbg-mock-btn {
  flex: 1;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}
.dbg-mock-danger { background: rgba(229,62,62,0.2);  border: 1px solid #e53e3e; color: #e53e3e; }
.dbg-mock-warn   { background: rgba(237,137,54,0.2); border: 1px solid #ed8936; color: #ed8936; }
.dbg-mock-ok     { background: rgba(56,161,105,0.2); border: 1px solid #38a169; color: #38a169; }

.dbg-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 0;
  line-height: 1.4;
}
.dbg-toggle input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--yellow); }

/* Debug tabs */
.dbg-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  margin: 0;
}
.dbg-tab {
  flex: 1;
  padding: 4px 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
}
.dbg-tab.dbg-tab-active {
  background: rgba(255,234,0,0.12);
  border-color: var(--yellow);
  color: var(--yellow);
}
.dbg-tab-panel.hidden { display: none; }

.dbg-ok    { color: var(--green); }
.dbg-warn  { color: var(--yellow); }
.dbg-err   { color: var(--red); }
.dbg-off   { color: var(--text2); }

/* Corner marker tooltip (legacy / review mode) */
.corner-tt { background: rgba(13,13,13,0.88); border: 1px solid #e53e3e; color: #fff; font-weight: 700; font-size: 0.75rem; white-space: nowrap; }
.corner-tt::before { border-top-color: #e53e3e; }

/* Corner speed marker — rotated DivIcon */
.corner-marker {
  width: 34px;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.corner-marker-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid #e53e3e;
  margin-bottom: 1px;
  flex-shrink: 0;
}
.corner-marker-speed {
  width: 30px;
  height: 30px;
  background: #ffea00;
  border: 2px solid #e53e3e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #111;
  line-height: 1;
  flex-shrink: 0;
}

.burger-divider {
  height: 1px;
  background: var(--bg3);
  margin: 0;
}

/* ============================================================
   App Header
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--bg3);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.logo-small {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  padding-right: 0.5rem;
}
.session-info { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; letter-spacing: 2px; }

/* Session code button — tappable, shows QR icon hint */
.session-code-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 2px;
  padding: 0.4rem 0.75rem;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.session-code-btn:active { opacity: 0.7; }

.ride-name-wrap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ride-name-hud {
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  max-width: calc(100vw - 200px);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.ride-name-input-hud { pointer-events: auto; }
.ride-name-hud:active { opacity: 0.6; }

.ride-name-input-hud {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  outline: none;
}

.trip-share-btn {
  padding: 0.5rem 0.65rem;
  min-height: 44px;
  flex-shrink: 0;
}

/* Audio debug item in burger menu */
.burger-item-debug { color: var(--yellow); }
.burger-item-debug svg { stroke: var(--yellow); }

/* Right-side HUD group: burger + radio flush together */
.hud-right-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Radio HUD button active/buffering states */
.hud-btn.radio-active {
  background: rgba(255,85,0,0.22);
  color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.hud-btn.radio-buffering {
  color: var(--yellow);
}

/* Prevent text selection on radio button (long-press) */
#btn-radio {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.trip-share-btn.shared {
  color: var(--green);
  background: rgba(0,230,118,0.15);
  box-shadow: 0 0 0 1.5px var(--green);
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-disconnected { background: var(--red); }
.status-connecting   { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ============================================================
   Home Screen
   ============================================================ */
.home-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.user-greeting { color: var(--text2); padding: 0.25rem 0; }

/* ============================================================
   Stats card — home screen aggregate stats
   ============================================================ */
.stats-grid {
  display: flex;
  gap: 0.5rem;
}
.stats-chip {
  flex: 1;
  background: var(--bg3);
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.stats-chip-icon { font-size: 1.1rem; line-height: 1; }
.stats-chip-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
.stats-chip-unit {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text2);
  margin-left: 2px;
}
.stats-chip-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text2);
  font-weight: 600;
}

.card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.card h2 { font-size: 1rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }

input[type="text"] {
  background: var(--bg3);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  width: 100%;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }

/* ============================================================
   Dashboard Screen
   ============================================================ */
.own-panel {
  background: var(--bg2);
  padding: 1rem;
  flex-shrink: 0;
}

.gauge-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gauge {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.gauge-value {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}
.gauge-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text2);
  margin-top: 0.25rem;
  letter-spacing: 0.5px;
}

/* Lean angle visual bar */
.lean-gauge { position: relative; }
.lean-indicator {
  position: absolute;
  top: 0; left: 50%;
  width: 3px;
  height: 100%;
  background: var(--accent);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  transition: transform 0.15s ease-out;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ */
/* Flag button                                                         */
/* ------------------------------------------------------------------ */
.btn-flag {
  font-size: 1.2rem;
  padding: 0.9rem 0.7rem;
  min-height: 52px;
  min-width: 52px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/* Flag radial menu                                                    */
/* ------------------------------------------------------------------ */
.flag-radial-menu {
  position: fixed;
  z-index: 600;
  pointer-events: none;
}
.flag-radial-menu:not(.hidden) {
  pointer-events: auto;
}
.flag-radial-item {
  position: absolute;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  background: rgba(20,20,20,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity   0.18s ease;
  touch-action: manipulation;
}
.flag-radial-item span {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.8;
  margin-top: 1px;
}
/* Fan-out: 5 items, 140° arc centred on straight-up, r=130px */
/* angles: -70°, -35°, 0°, +35°, +70° from top  x=r·sin(a), y=-r·cos(a) */
.flag-radial-menu:not(.hidden) .flag-radial-item:nth-child(1) { transform: translate(calc(-50% + -122px), calc(-50% + -44px)) scale(1); opacity: 1; transition-delay: 0.00s; }
.flag-radial-menu:not(.hidden) .flag-radial-item:nth-child(2) { transform: translate(calc(-50% +  -75px), calc(-50% + -107px)) scale(1); opacity: 1; transition-delay: 0.03s; }
.flag-radial-menu:not(.hidden) .flag-radial-item:nth-child(3) { transform: translate(calc(-50% +    0px), calc(-50% + -130px)) scale(1); opacity: 1; transition-delay: 0.06s; }
.flag-radial-menu:not(.hidden) .flag-radial-item:nth-child(4) { transform: translate(calc(-50% +   75px), calc(-50% + -107px)) scale(1); opacity: 1; transition-delay: 0.09s; }
.flag-radial-menu:not(.hidden) .flag-radial-item:nth-child(5) { transform: translate(calc(-50% +  122px), calc(-50% +  -44px)) scale(1); opacity: 1; transition-delay: 0.12s; }

/* ------------------------------------------------------------------ */
/* Flag confirmation toast                                             */
/* ------------------------------------------------------------------ */
.flag-toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,20,20,0.88);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 1.1rem;
  z-index: 700;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.flag-toast.hidden { opacity: 0; }

/* ------------------------------------------------------------------ */
/* Review event pins on Leaflet map                                   */
/* ------------------------------------------------------------------ */
.review-event-pin {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  background: rgba(20,20,20,0.85);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.55);
}
.review-event-pin.user_start   { border-color: #00e676; background: rgba(0,200,80,0.18); }
.review-event-pin.user_stop    { border-color: #fff;    background: rgba(80,80,80,0.5);  }
.review-event-pin.user_mark    { border-color: #aaa;    background: rgba(60,60,60,0.7);  }
.review-event-pin.user_danger  { border-color: #ffea00; background: rgba(180,160,0,0.22); }
.review-event-pin.user_accident{ border-color: #ff1744; background: rgba(180,0,30,0.22); }
.review-event-pin.hard_brake   { border-color: #ff1744; background: rgba(180,0,30,0.22); }
.review-event-pin.hard_accel   { border-color: #00e676; background: rgba(0,180,80,0.18); }
.review-event-pin.lean_spike   { border-color: #ffea00; background: rgba(180,160,0,0.22); }

/* Directional wrapper for review (and live-ride) event/flag markers */
.rev-evt-wrap {
  width: 52px;
  height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 26px 36px; /* rotate around circle centre */
}
.rev-evt-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
  margin-bottom: 1px;
}

/* ride map flag pins (dropped during active ride) */
.ride-flag-pin {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(20,20,20,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.remote-speaking-hud {
  padding: 0.28rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--green);
  background: rgba(0, 200, 100, 0.08);
  border-top: 1px solid rgba(0, 200, 100, 0.25);
  border-bottom: 1px solid rgba(0, 200, 100, 0.12);
  animation: dot-pulse 0.7s ease-in-out infinite alternate;
}
.session-controls {
  display: flex;
  gap: 0.5rem;
}
.session-controls .btn { flex: 1; padding: 0.9rem; font-size: 1rem; min-height: 52px; }
/* Mic button states */
.btn-mic {
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
  gap: 0.5rem;
  /* Default / voice not started — neutral grey */
  background: var(--bg3) !important;
  color: var(--text2) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Mic live — green: voice is connected and transmitting */
.btn-mic.mic-active {
  background: rgba(0,230,118,0.18) !important;
  color: var(--green) !important;
  border-color: var(--green) !important;
  box-shadow: 0 0 0 1.5px var(--green) !important;
}
/* Mic muted (or voice off) — red: no audio going out; tap to unmute/start */
.btn-mic.mic-muted {
  background: rgba(255,23,68,0.18) !important;
  color: var(--red) !important;
  border-color: var(--red) !important;
  box-shadow: none !important;
}
/* Mic reconnecting — amber pulse: mic is open but LiveKit link is recovering */
.btn-mic.mic-reconnecting {
  background: rgba(255,165,0,0.18) !important;
  color: #fa6 !important;
  border-color: #fa6 !important;
  box-shadow: none !important;
  animation: pulse 1.8s ease-in-out infinite;
}
/* Speaking — orange glow */
.btn-mic.mic-speaking {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
  animation: mic-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes mic-pulse {
  from { box-shadow: 0 0 8px  rgba(255,85,0,0.6), 0 0 16px rgba(255,85,0,0.3); }
  to   { box-shadow: 0 0 18px rgba(255,85,0,0.95), 0 0 36px rgba(255,85,0,0.55); }
}

/* Blue speaking dot in rider list */
.speaking-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.speaking-dot.active {
  opacity: 1;
  animation: dot-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes dot-pulse {
  from { box-shadow: 0 0 4px rgba(41,121,255,0.6); }
  to   { box-shadow: 0 0 10px rgba(41,121,255,1); }
}

/* ============================================================
   Riders Panel
   ============================================================ */
.riders-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.riders-panel h3 { font-size: 0.85rem; text-transform: uppercase; color: var(--text2); margin-bottom: 0.75rem; letter-spacing: 0.5px; }

.rider-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.3s;
  border: 1px solid transparent;
}
.rider-card.leader { border-color: var(--accent); }
.rider-card.self   { border-color: var(--blue); }

.rider-rank {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text2);
  min-width: 2rem;
  text-align: center;
}
.rider-rank.first { color: var(--accent); }

.rider-info { flex: 1; min-width: 0; }
.rider-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rider-stats { display: flex; gap: 0.75rem; margin-top: 0.25rem; font-size: 0.8rem; color: var(--text2); }
.rider-stat-val { color: var(--text); font-weight: 600; }

.rider-distance {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text2);
  min-width: 3rem;
}
.rider-distance .dist-val { font-size: 1rem; font-weight: 700; color: var(--text); display: block; }

/* ============================================================
   Map Panel
   ============================================================ */
#map-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
#map { flex: 1; }
.map-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--bg);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  z-index: 101;
  font-size: 1.2rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-content {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}
.modal-content h3 { font-size: 1.1rem; }
#qr-code canvas, #qr-code img { border-radius: 8px; background: #fff; padding: 8px; }
#share-url { font-size: 0.8rem; color: var(--text2); word-break: break-all; }
.modal-btn-row { display: flex; gap: 0.75rem; width: 100%; }
.modal-btn-row .btn { flex: 1; }

#qr-video { width: 100%; border-radius: 8px; background: #000; }

/* ============================================================
   Voice Settings Modal
   ============================================================ */
#voice-settings-modal .modal-content {
  gap: 1rem;
}
.voice-mode-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}
.voice-mode-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
}
.voice-mode-row input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}
.voice-settings-hint {
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.4;
}

/* ============================================================
   Trip list
   ============================================================ */
.trip-item {
  background: var(--bg3);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.trip-row-header { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-row-details { font-size: 0.8rem; color: var(--text2); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.trip-row-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.05rem; }
.trip-footer-left { display: flex; align-items: center; min-width: 1.8rem; }
.trip-vehicle-icon { font-size: 1.1rem; opacity: 0.55; line-height: 1; }
.trip-stat { display: inline-flex; align-items: center; gap: 0.25rem; }
.trip-stat-icon { width: 0.85em; height: 0.85em; flex-shrink: 0; opacity: 0.7; }
.trip-item-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

.trip-edit-panel {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--bg3);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.trip-edit-panel.hidden { display: none; }
.trip-rename-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
}
.trip-edit-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; min-height: unset; }

.btn-import-gpx {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  cursor: pointer;
}

.trip-share-panel {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--bg3);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.trip-share-panel.hidden { display: none; }
.trip-share-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent2);
  margin-bottom: 0.15rem;
}
.share-participants { display: flex; flex-direction: column; gap: 0.5rem; }
.share-participant { display: flex; flex-direction: column; gap: 0.2rem; }
.share-participant-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.share-self-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0,230,118,0.14);
  color: var(--green);
  border-radius: 20px;
  padding: 0.05rem 0.45rem;
  letter-spacing: 0.04em;
}
.share-trip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0 0.15rem 0.5rem;
}
.share-trip-stats { font-size: 0.82rem; color: var(--text2); }
.share-stats-row {
  display: flex;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text2);
  padding-left: 0.5rem;
}
.share-review-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; padding-left: 0.4rem; margin-top: 0.1rem; }
.share-badge {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 20px;
  padding: 0.05rem 0.45rem;
}
.share-badge-speed { background: rgba(255,160,0,0.15); color: #ffa000; }
.share-badge-lean  { background: rgba(41,182,246,0.15); color: #29b6f6; }
.share-badge-km    { background: rgba(0,230,118,0.14);  color: var(--green); }

.trip-share-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.38;
  color: var(--text);
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trip-share-btn:hover { opacity: 0.85; background: rgba(255,255,255,0.08); }
.trip-share-btn.active { opacity: 1; color: var(--accent2); }

.trip-share-invite-btn { display: flex; align-items: center; justify-content: center; gap: 0.4rem; width: 100%; margin-top: 0.5rem; }

.trip-ghost-btn, .trip-lock-btn, .trip-edit-btn, .trip-delete-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s, box-shadow 0.15s;
}
.trip-edit-btn, .trip-delete-btn { opacity: 0.5; }
.trip-edit-btn:hover   { opacity: 1; background: rgba(255,255,255,0.08); }
.trip-delete-btn:hover:not(:disabled) { opacity: 1; background: rgba(255,23,68,0.15); }
.trip-delete-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* Lock button: faint when unlocked, amber glow when active */
.trip-lock-btn { opacity: 0.28; }
.trip-lock-btn:hover { opacity: 0.7; background: rgba(255,234,0,0.1); }
.trip-lock-btn.active {
  opacity: 1;
  background: rgba(255,234,0,0.15);
  box-shadow: 0 0 0 1.5px rgba(255,234,0,0.5);
}

/* Ghost button: faint by default, glowing when active */
.trip-ghost-btn {
  opacity: 0.28;
}
.trip-ghost-btn:hover {
  opacity: 0.7;
  background: rgba(120,80,255,0.12);
}
.trip-ghost-btn.active {
  opacity: 1;
  background: rgba(120,80,255,0.18);
  box-shadow: 0 0 0 1.5px rgba(120,80,255,0.55);
}


/* ============================================================
   Dashboard — map-centric HUD layout
   ============================================================ */

/* Dashboard — full-screen with absolute overlays */
#screen-dashboard.active {
  display: block;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* Map area — fills entire screen, sits at z-index 0 */
#map-area {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Rotating map wrapper — expanded 180% to avoid corners on rotation.
   pointer-events: none prevents the oversized wrapper from shadowing HUD
   controls; #ride-map re-enables them for the actual map tile area. */
#map-rotate-wrapper {
  position: absolute;
  top: -40%;
  left: -40%;
  width: 180%;
  height: 180%;
  z-index: 0;
  transition: transform 0.4s ease-out;
  transform-origin: center center;
  pointer-events: none;
}

#ride-map {
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* HUD base — all overlays are absolute within #map-area or #screen-dashboard */
.hud {
  position: absolute;
  z-index: 20;
}

/* Top bar */
.hud-top {
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  background: rgba(13,13,13,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.65rem 1rem;
  min-height: 52px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  -webkit-tap-highlight-color: transparent;
}
.hud-btn:active { opacity: 0.7; }

/* Follow indicator */
.follow-indicator {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(0,230,118,0.15);
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
}
.follow-indicator.hidden { display: none; }

/* Followed leaderboard row */
.lb-followed { background: rgba(0,230,118,0.08); border-radius: 6px; }
.lb-followed .lb-name { color: var(--green); }

/* Left column — compass + zoom centered vertically on the map */
.hud-left-controls {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  /* avoid overlapping bottom panel (~200px) and top bar (~80px) */
  max-height: calc(100% - 280px);
  justify-content: center;
}

.hud-compass {
  width: 44px;
  height: 44px;
  background: rgba(13,13,13,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.1);
}

.hud-compass-n {
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0;
  transition: transform 0.4s ease-out;
  transform-origin: center;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.hud-compass-n::before {
  content: "▲";
  font-size: 0.55rem;
  color: var(--accent);
}

/* Compass — tappable; touch-action: manipulation eliminates 300ms tap delay on mobile */
.hud-compass { cursor: pointer; touch-action: manipulation; }
.hud-compass.north-up {
  border-color: rgba(41,121,255,0.55);
  box-shadow: 0 0 0 1.5px rgba(41,121,255,0.3);
}

/* Corner speed advisory — speed-limit sign style, right column is now clear */
.hud-corner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 80px);
  right: 0.75rem;
  z-index: 20;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #f2f2f2;
  border: 5px solid #e53e3e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: 0 3px 14px rgba(0,0,0,0.55);
  font-family: -apple-system, sans-serif;
  transition: transform 0.3s ease;
}
/* Direction indicator — small dot at top of ring, rotates with the outer circle */
.hud-corner::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  background: #e53e3e;
  border-radius: 50%;
}
/* Inner wrapper counter-rotates so text stays upright */
.hud-corner-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}
.hud-corner-dist {
  font-size: 0.68rem;
  font-weight: 700;
  color: #666;
  line-height: 1;
  margin-bottom: 2px;
}
.hud-corner-speed {
  font-size: 2.3rem;
  font-weight: 900;
  color: #111;
  line-height: 1;
}
.hud-corner-unit {
  font-size: 0.6rem;
  font-weight: 700;
  color: #666;
  line-height: 1;
  margin-top: 2px;
  letter-spacing: 0.05em;
}
.hud-corner.warn   { border-color: #c07000; }
.hud-corner.danger { background: #ffe8e8; box-shadow: 0 0 0 3px rgba(229,62,62,0.4), 0 3px 14px rgba(0,0,0,0.55); }
.hud-corner.hidden { display: none; }

/* Speed / lean gauge — upper left of map, same size and top offset as hud-corner */
.hud-gauge {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 80px);
  left: 0.75rem;
  z-index: 20;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(13,13,13,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 3px 14px rgba(0,0,0,0.5);
}
.hud-gauge.hidden { display: none; }
.hud-gauge-review {
  top: calc(env(safe-area-inset-top, 0px) + 174px);
}

/* Zoom buttons — inside .hud-left-controls, no absolute positioning needed */
.hud-zoom {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Panning crosshair — centered in map area, pointer-events none */
#hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

/* Corner speed pill — inline inside .review-header flex row */
#hud-corner-review {
  position: static !important;
  display: inline-flex !important;
  flex-shrink: 0;
  width: auto;
  height: auto;
  border-radius: 14px;
  padding: 0.2rem 0.65rem;
}
#hud-corner-review.hidden { display: none !important; }
#hud-corner-review::before { display: none; }
#hud-corner-review .hud-corner-inner {
  flex-direction: row;
  align-items: baseline;
  gap: 0.25rem;
}
#hud-corner-review .hud-corner-speed { font-size: 1.1rem; }
#hud-corner-review .hud-corner-dist  { font-size: 0.7rem; color: #555; margin-bottom: 0; }
#hud-corner-review .hud-corner-unit  { font-size: 0.65rem; margin-top: 0; }
.hud-zoom-btn {
  width: 52px;
  height: 52px;
  font-size: 1.6rem;
  justify-content: center;
  background: rgba(13,13,13,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 10px;
  touch-action: manipulation;
}

/* Bottom panel — always-visible bar anchored to the bottom, above the map */
#bottom-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ------------------------------------------------------------ */
/* Leaderboard strip — always-visible compact rider rows        */
/* ------------------------------------------------------------ */
.leaderboard-strip {
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--bg3);
  padding-bottom: 0.4rem;
}

.lb-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr 3.4rem 3rem 2.6rem 3.2rem;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.lb-row:last-child { border-bottom: none; }

.lb-pos {
  font-size: 1rem;
  text-align: center;
  font-weight: 800;
}
.lb-ahead .lb-pos { color: var(--accent2); }
.lb-self  .lb-pos { color: var(--blue); }
.lb-behind .lb-pos { color: var(--text2); }

.lb-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lb-self .lb-name { color: var(--blue); }

.lb-dist {
  font-size: 0.95rem;
  color: var(--text2);
  text-align: right;
  white-space: nowrap;
}
.lb-ahead .lb-dist { color: var(--accent2); }

.lb-speed {
  font-weight: 800;
  font-size: 1.15rem;
  text-align: right;
  color: var(--text);
}
.lb-unit {
  font-size: 0.78rem;
  color: var(--text2);
  align-self: flex-end;
  padding-bottom: 2px;
}
.lb-lean {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text2);
  text-align: right;
}

.own-gauges-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gauge-hud {
  background: rgba(38,38,38,0.95);
  border-radius: var(--radius);
  padding: 0.6rem 0.4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.gauge-hud-value {
  font-size: 1.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.gauge-hud-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--text2);
  margin-top: 0.2rem;
  letter-spacing: 0.5px;
}

.gauge-hud-max {
  font-size: 0.6rem;
  color: var(--accent2);
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-top: 0.1rem;
}

.gauge-hud-lean {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}
.gauge-hud-lean:active { opacity: 0.75; }
.gauge-hud-lean.calibrated { background: rgba(0,230,118,0.25); }

@keyframes cal-flash {
  0%   { background: rgba(0,230,118,0.45); }
  100% { background: rgba(38,38,38,0.95); }
}
.gauge-hud-lean.calibrated { animation: cal-flash 0.6s ease-out forwards; }

.lean-cal-icon {
  font-size: 0.65rem;
  opacity: 0.55;
  vertical-align: middle;
}

/* Slide-up panels — anchored inside #map-area (position: absolute, inset:0) */
.hud-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 30;  /* above #bottom-panel's z-index: 20 */
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 80%;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 32px rgba(0,0,0,0.6);
}

.hud-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.hud-panel-header h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text2);
  letter-spacing: 0.5px;
}

/* ============================================================
   Trip Review Screen
   ============================================================ */

#screen-review.active {
  display: block;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#review-map-wrapper {
  position: absolute;
  top: -40%;
  left: -40%;
  width: 180%;
  height: 180%;
  z-index: 0;
  transition: transform 0.4s ease-out;
  transform-origin: center center;
}

#review-map {
  width: 100%;
  height: 100%;
}

/* Stats HUD — top overlay */
.review-stats {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(13,13,13,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.review-title {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.review-time {
  font-size: 0.78rem;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex-shrink: 0;
}

.review-gauges {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.4rem;
}

.review-gauge {
  background: rgba(38,38,38,0.9);
  border-radius: 8px;
  padding: 0.45rem 0.3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Lean needle inside review gauge */
.review-gauge-lean { position: relative; }
.review-lean-indicator {
  position: absolute;
  top: 0; left: 50%;
  width: 3px;
  height: 100%;
  background: var(--accent);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  transition: transform 0.2s ease-out;
  border-radius: 2px;
  opacity: 0.85;
}

.review-gauge-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.review-gauge-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  color: var(--text2);
  margin-top: 0.15rem;
  letter-spacing: 0.4px;
}

/* Player bar — bottom */
.review-player {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

.player-progress {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 5px;
  background: var(--bg3);
  outline: none;
  cursor: pointer;
}

.player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 8px rgba(255,85,0,0.7);
}

.player-progress::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid #fff;
}

.player-pos {
  font-size: 0.72rem;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Row 1: counter + scrubber — full width */
.player-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.player-slider-row .player-progress {
  flex: 1;
  min-width: 0;
}

/* Row 2: controls — 3 equal buttons centred */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.player-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 72px;
  font-size: 1.6rem;
  user-select: none;
  -webkit-user-select: none;
}
.player-btn:active { opacity: 0.6; }

/* Play/pause — stands out */
.player-btn-play {
  background: var(--accent);
  font-size: 2rem;
  flex: 1.8;
  border-radius: 16px;
}

/* Speed hints active state in burger menu */
.burger-item.player-btn-active {
  color: var(--accent) !important;
}
.burger-item.player-btn-active svg {
  stroke: var(--accent);
}

/* Speed graph canvas scrubber */
.review-speed-graph {
  width: 100%;
  height: 44px;
  display: block;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  cursor: pointer;
}

/* Trip stats strip */
.review-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  justify-content: center;
}
.rs-chip {
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text2);
  white-space: nowrap;
}
.rs-val {
  font-weight: 700;
  color: var(--text);
}
/* ============================================================
   Multi-Rider Review Screen
   ============================================================ */
#screen-multireview.active {
  display: block;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#mrv-map-wrapper {
  position: absolute;
  top: -40%;
  left: -40%;
  width: 180%;
  height: 180%;
  z-index: 0;
  transition: transform 0.4s ease-out;
  transform-origin: center center;
}

#mrv-map {
  width: 100%;
  height: 100%;
}

#mrv-legend-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(13,13,13,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top, 0px);
}

#mrv-header {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.5rem;
  gap: 0.25rem;
}

#mrv-leader-panel {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 0.35rem 1rem 0.25rem;
}
#mrv-rideboard {
  margin: 0;
  padding: 0;
  border-bottom: none;
}
/* Multi-review left controls reuse live ride HUD controls */
.mrv-left-controls {
  z-index: 30;
  max-height: calc(100% - 300px);
}
/* Map HUD gauges — same language as ride/review gauge, one per visible rider */
#mrv-gauge-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 78px);
  right: 0.65rem;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.mrv-map-gauge {
  position: relative;
  width: 96px;
  height: 112px;
  border: 0;
  padding: 0;
  border-radius: 50px 50px 16px 16px;
  background: rgba(13,13,13,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 3px 14px rgba(0,0,0,0.5);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  overflow: hidden;
}
.mrv-map-gauge--followed {
  box-shadow: 0 0 0 2px var(--rider-color, var(--accent)), 0 3px 14px rgba(0,0,0,0.5);
}
.mrv-map-gauge-dot {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rider-color, var(--accent));
  box-shadow: 0 0 8px var(--rider-color, var(--accent));
}
.mrv-map-gauge-name {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 13px;
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mrv-map-gauge-lean {
  position: absolute;
  right: 7px;
  top: 62px;
  font-size: 0.62rem;
  font-weight: 800;
  color: rgba(255,255,255,0.62);
  font-variant-numeric: tabular-nums;
}

/* One row per rider — color · name · speed · unit · lean · dist */
.mrv-board-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr 3rem 2.6rem 3.2rem 3.4rem;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.mrv-board-row:last-child { border-bottom: none; }
.mrv-board-row--followed {
  background: rgba(255,255,255,0.09);
  border-left: 3px solid var(--accent);
  padding-left: 0.5rem;
  border-radius: 4px;
}

.mrv-player {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.65rem 1rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.mrv-dist {
  color: rgba(255,255,255,0.45);
  font-size: 0.88rem;
  text-align: right;
}

@media (max-height: 720px) {
  #mrv-leader-panel { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  #mrv-gauge-panel { gap: 0.4rem; }
  .mrv-map-gauge { width: 82px; height: 96px; }
  .mrv-map-gauge svg { width: 82px; height: 82px; }
  .mrv-map-gauge-name { font-size: 0.55rem; bottom: 10px; }
  .mrv-map-gauge-lean { top: 53px; font-size: 0.56rem; }
}



/* ============================================================
   Ghost Rider indicator (hidden — kept for legacy cleanup only)
   ============================================================ */
#ghost-indicator {
  display: none;
}
#ghost-indicator-clear {
  display: none;
  flex-shrink: 0;
}

/* ============================================================
   Trip list — bulk select & admin toolbar
   ============================================================ */
#trip-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  justify-content: flex-end;
}

.trip-checkbox-wrap {
  display: flex;
  align-items: center;
  padding-right: 0.5rem;
  flex-shrink: 0;
  cursor: pointer;
}
.trip-checkbox {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.trip-bulk-mode {
  user-select: none;
}

#trip-bulk-bar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  color: var(--text1);
  white-space: nowrap;
}

.trip-user-badge {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

.trip-shared-badge, .trip-car-badge {
  margin-left: 0.3rem;
  font-size: 0.8rem;
  vertical-align: middle;
  opacity: 0.8;
}

.trip-item-longpress {
  background: color-mix(in srgb, var(--accent) 20%, var(--bg2)) !important;
  transition: background 0.1s;
}

.trip-code-badge {
  display: inline-flex;
  align-items: center;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.04em;
}

/* ============================================================
   Continue Ride Panel
   ============================================================ */
#continue-ride-panel {
  background: var(--bg3);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.continue-ride-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.continue-ride-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.continue-ride-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.continue-ride-code {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.continue-ride-name {
  font-size: 0.85rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   PWA Update Banner
   ============================================================ */
#update-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  color: var(--text1);
  white-space: nowrap;
}
#btn-update-reload {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
#btn-update-dismiss {
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.2rem;
}

/* ============================================================
   Nearby rider invite card (shown while riding, below top HUD)
   ============================================================ */
.nearby-toast {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 1rem;
  right: 1rem;
  z-index: 30;
  background: var(--bg2);
  border: 1.5px solid var(--accent2);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.8);
}
.nearby-toast-dismiss-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.nearby-toast-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent2);
}
.nearby-toast-dismiss {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  min-height: 36px;
}
.nearby-toast-code {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}
.nearby-toast-meta {
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 0.1rem;
  overflow-wrap: break-word;
}

/* ============================================================
   Nearby rides card (home view)
   ============================================================ */
.nearby-rides-card { border-color: var(--accent2); }
.nearby-rides-card h2 { color: var(--accent2); }

.nearby-rides-badge {
  display: inline-block;
  background: var(--accent2);
  color: #000;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.nearby-ride-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--bg3);
}
.nearby-ride-item:last-child { border-bottom: none; }

.nearby-ride-info { flex: 1; min-width: 0; }
.nearby-ride-code {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--text);
  line-height: 1.1;
}
.nearby-ride-name {
  font-size: 0.88rem;
  color: var(--text2);
  margin-top: 0.1rem;
  overflow-wrap: break-word;
}
.nearby-ride-meta {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 0.15rem;
}
.nearby-ride-join {
  flex-shrink: 0;
  align-self: center;
  width: auto;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  min-height: unset;
}

/* ============================================================
   Utilities
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   Settings screen — sliders, labels, controls
   ============================================================ */
.settings-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 0.35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Settings sub-section group label */
.settings-group-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent2);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Mount calibration wizard */
.settings-hint {
  font-size: 0.8rem;
  color: var(--text2);
  margin: 0 0 1rem;
  line-height: 1.5;
}
.mount-cal-steps {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
}
.mount-cal-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem 0.65rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.08);
  transition: border-color 0.2s;
}
.mount-cal-col.done {
  border-color: #00e676;
}
.mount-cal-visual {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 60px;
  margin-bottom: 0.2rem;
}
.mount-cal-visual svg {
  height: 100%;
  width: auto;
  max-width: 52px;
}
.mount-cal-step-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}
.mount-cal-step-sub {
  font-size: 0.71rem;
  color: var(--text2);
  text-align: center;
  line-height: 1.35;
}
.mount-cal-capture-btn {
  width: 100%;
  margin-top: 0.4rem;
  background: rgba(255,160,0,0.13);
  border-color: rgba(255,160,0,0.55);
  color: #ffa000;
  font-weight: 700;
}
.mount-cal-capture-btn:disabled {
  background: transparent;
  border-color: rgba(255,255,255,0.15);
  color: var(--text2);
  font-weight: 400;
  opacity: 0.5;
}
.mount-cal-col.done .mount-cal-capture-btn {
  background: rgba(0,230,118,0.12);
  border-color: rgba(0,230,118,0.45);
  color: #00e676;
}
.mount-cal-status {
  font-size: 0.82rem;
  margin-top: 0.65rem;
  min-height: 1.2em;
  color: var(--text2);
}
.mount-cal-status.ok {
  color: #00e676;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(0,230,118,0.4);
}
.mount-cal-status.err { color: #ff5252; }

/* Duck mode segmented pill toggle */
.duck-mode-pills {
  display: flex;
  height: 48px;
  background: var(--bg3);
  border-radius: 24px;
  padding: 4px;
  gap: 4px;
}
.duck-pill {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 20px;
  transition: background .2s, color .2s;
  padding: 0 0.5rem;
  -webkit-tap-highlight-color: transparent;
}
.duck-pill.active { background: var(--accent); color: #fff; }

/* Offline tile zoom cap pills */
.tile-zoom-pills {
  display: flex;
  gap: 0.4rem;
}
.tile-zoom-pill {
  background: var(--bg3);
  border: 1.5px solid #444;
  border-radius: 20px;
  color: var(--text2);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  line-height: 1.2;
  text-align: center;
  transition: background .2s, border-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.tile-zoom-pill-sub { font-weight: 400; font-size: 0.74rem; display: block; }
.tile-zoom-pill.active { background: rgba(0,230,118,.13); border-color: var(--accent); color: var(--accent); }

/* Tile cache management row in settings */
.tile-cache-stats-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}
.tile-cache-stat { font-size: 0.82rem; color: var(--text2); }
.tile-cache-stat-sep { color: #555; }
.tile-cache-delete-btn {
  margin-left: auto;
  background: transparent;
  border: 1.5px solid #c0392b;
  border-radius: 16px;
  color: #e74c3c;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.22rem 0.75rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, color .2s;
}
.tile-cache-delete-btn:active { background: rgba(231,76,60,.15); }

/* Tile caching progress toast — shown at top of screen */
.tile-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: rgba(30,30,40,.95);
  color: #fff;
  font-size: 0.82rem;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  z-index: 9999;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
}
.tile-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Undo-delete toast — bottom-centre, above nav */
.undo-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(30,30,40,.97);
  color: #fff;
  font-size: 0.86rem;
  padding: 0.45rem 0.6rem 0.45rem 1rem;
  border-radius: 22px;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
.undo-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.undo-toast-counter {
  font-size: 0.78rem;
  color: var(--text2);
  min-width: 1ch;
  text-align: center;
}
.undo-toast-btn {
  background: var(--accent);
  border: none;
  border-radius: 16px;
  color: #000;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.28rem 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  box-sizing: border-box;
}
.settings-input:focus { outline: none; border-color: var(--accent); }

/* Tall pill slider with fill + centred value label */
.slider-wrap { position: relative; display: block; }

.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 48px;
  cursor: pointer;
  background: transparent;
}
.settings-slider::-webkit-slider-runnable-track {
  height: 48px;
  border-radius: 24px;
  background: linear-gradient(
    to right,
    var(--accent) var(--slider-pct, 0%),
    var(--bg3)    var(--slider-pct, 0%)
  );
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 40px;
  height: 40px;
  margin-top: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.settings-slider::-moz-range-track {
  height: 48px;
  border-radius: 24px;
  background: var(--bg3);
}
.settings-slider::-moz-range-progress {
  height: 48px;
  border-radius: 24px 0 0 24px;
  background: var(--accent);
}
.settings-slider::-moz-range-thumb {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

/* Two-part label+value inside the slider track */
.slider-val {
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.slider-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0,0,0,.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.slider-num {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0,0,0,.85);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Toggle switch (checkbox → pill) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-knob {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: var(--bg3);
  cursor: pointer;
  transition: background .2s;
  border: 1px solid #444;
}
.toggle-knob::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-knob { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-knob::before { transform: translateX(24px); }

/* Station search results */
.settings-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.station-search-results {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.5rem 0;
  border-bottom: 1px solid #2a2a2a;
}
.search-result-name  { flex: 1; font-size: 0.95rem; }
.search-result-country { font-size: 0.8rem; color: var(--text2); }

.station-searching { font-size: 0.9rem; color: var(--text2); padding: 0.5rem 0; }

/* My-stations list */
.my-stations-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.my-station-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid #333;
  min-height: 44px;
}
.my-station-name { flex: 1; font-size: 0.95rem; }
.my-station-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

.custom-station-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Settings tab bar */
.settings-tabs {
  display: flex;
  gap: 0;
  background: var(--bg2);
  border-bottom: 2px solid var(--bg3);
  position: sticky;
  top: 0;
  z-index: 10;
}
.settings-tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
  -webkit-tap-highlight-color: transparent;
}
.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.settings-tab-panel { display: block; }
.settings-tab-panel.hidden { display: none; }

/* Settings build date footer */
.settings-build-date {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text2);
  padding: 1rem 0 0.5rem;
  letter-spacing: 0.04em;
}

/* Review screen burger positioning */
.review-burger-wrap { position: relative; }

/* ============================================================
   Radio modal
   ============================================================ */
.radio-modal-content {
  max-width: 400px;
  align-items: stretch;
  text-align: left;
}

.radio-transport {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.radio-transport-btn {
  flex: 1;
  min-height: 56px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.radio-now-block {
  font-size: 0.95rem;
  color: var(--text2);
  min-height: 1.2em;
  text-align: center;
  word-break: break-word;
}

.radio-station-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
}

.radio-station-btn {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 1rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg3);
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.radio-station-btn:active { background: var(--bg2); }
.radio-station-btn.active {
  border-color: var(--accent);
  background: rgba(255,85,0,.12);
  color: var(--accent);
}

.radio-station-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
}
.radio-station-btn.active .radio-station-dot { background: var(--accent); }
.radio-station-name { flex: 1; }

/* ============================================================
   Mic test button — full-width with overlaid VU bar
   ============================================================ */
.mic-test-btn {
  min-height: 56px;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
  justify-content: flex-start;
  padding-left: 1.25rem;
  gap: 0.75rem;
}
.mic-test-icon, .mic-test-label { position: relative; z-index: 1; }
.mic-test-bar-inner {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: rgba(0,230,118,0.22);
  border-radius: var(--radius);
  transition: width 0.04s linear;
  pointer-events: none;
}
/* VAD active — speaking detected */
.mic-test-btn.mic-test-vad { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.mic-test-btn.mic-test-vad .mic-test-bar-inner { background: rgba(255,85,0,0.28); }

/* ============================================================
   Station list — drag handle + action buttons
   ============================================================ */
.drag-handle {
  cursor: grab;
  color: var(--text2);
  font-size: 1.2rem;
  padding: 0.45rem 0.2rem;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  line-height: 1;
}
.drag-handle:active { cursor: grabbing; color: var(--text); }

.my-station-row.dragging { opacity: 0.4; }
.my-station-row.drag-over { border-top: 2px solid var(--accent); }

.btn-station-remove {
  background: rgba(255,23,68,0.1);
  border: 1px solid rgba(255,23,68,0.25);
  color: var(--red);
  border-radius: 8px;
  padding: 0 0.55rem;
  min-height: 36px;
  min-width: 36px;
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-station-remove:active { background: rgba(255,23,68,0.25); }

.btn-add-preset {
  background: rgba(0,230,118,0.1);
  border: 1px solid rgba(0,230,118,0.25);
  color: var(--green);
  border-radius: 8px;
  padding: 0 0.55rem;
  min-height: 36px;
  min-width: 36px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add-preset:active { background: rgba(0,230,118,0.2); }
.btn-add-preset.added,
.btn-add-preset[disabled] { background: transparent; border-color: #333; color: var(--text2); cursor: default; }

.preset-stations-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  padding: 0.6rem 0 0.25rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--bg3);
}
.preset-row { background: rgba(255,255,255,0.03); }

/* ============================================================
   Search — icon button + clear button
   ============================================================ */
.search-icon-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--bg3);
  color: var(--text);
  background: var(--bg3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.search-icon-btn:active { opacity: 0.7; }
.search-clear-btn {
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--text2);
}

/* Make search result add button a prominent + circle */
.btn-add-station-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,230,118,0.12);
  border: 1px solid rgba(0,230,118,0.3);
  color: var(--green);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  line-height: 1;
}
.btn-add-station-icon:active { background: rgba(0,230,118,0.25); }
.btn-add-station-icon:disabled { opacity: 0.35; cursor: default; }

/* Share ride feedback in burger */
.burger-item-shared { color: var(--green) !important; }

/* ============================================================
   Admin Stats Screen
   ============================================================ */
.stats-kpi {
  background: var(--bg3);
  border-radius: 12px;
  padding: 0.9rem 0.75rem;
  text-align: center;
}
.stats-kpi-val {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stats-kpi-label {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 0.25rem;
}
.stats-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1rem 0 0.4rem;
}
.stats-section-label:first-child { margin-top: 0; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.stats-table th {
  text-align: left;
  padding: 5px 8px;
  color: var(--text2);
  font-weight: 600;
  border-bottom: 1px solid var(--bg3);
}
.stats-table td { padding: 5px 8px; }
.stats-table tr + tr td { border-top: 1px solid var(--bg3); }
.stats-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 6px;
}
.stats-badge-live  { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.stats-badge-off   { background: var(--bg3); color: var(--text2); }
.stats-badge-admin { background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); }
.stats-refresh-hint {
  font-size: 0.72rem;
  color: var(--text2);
  text-align: right;
  margin-top: 0.6rem;
}
.stats-close-btn {
  font-size: 0.7rem;
  padding: 2px 7px;
  background: color-mix(in srgb, #e53e3e 85%, transparent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.stats-close-btn:active { opacity: 0.75; }
.stats-table th[data-sk]:hover { color: var(--accent); }
.stats-trip-row { cursor: pointer; user-select: none; }
.stats-trip-row:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.stats-trip-row:active td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.stats-trip-ctx-menu {
  position: fixed;
  z-index: 9000;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  min-width: 150px;
}
.stats-ctx-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text1);
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 7px;
}
.stats-ctx-btn:hover { background: var(--bg3); }
.stats-ctx-btn-danger { color: #e53e3e; }
