/* ==========================================================================
   OneBike (๑ปั่น) — Pure Cycling Computer & Action-Cam HUD Stylesheet
   Vanilla CSS3 | 3 Themes: Light Sport, Sunlight High-Contrast, Dark OLED
   ========================================================================== */

:root,
[data-theme="light"] {
  --brand-orange: #F97316;
  --brand-orange-dark: #EA580C;
  --brand-orange-soft: rgba(249, 115, 22, 0.14);
  --accent-green: #22C55E;
  --accent-red: #EF4444;
  --accent-amber: #F59E0B;
  --accent-cyan: #06B6D4;

  --bg-primary: #F5F7FA;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #EEF2F6;
  --bg-pill: rgba(255, 255, 255, 0.92);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --divider-line: rgba(148, 163, 184, 0.22);

  --home-map-top: #DCFCE7;
  --home-map-mid: #ECFDF5;
  --home-road-river: #BAE6FD;
  --home-road-line: #FFFFFF;
  --home-road-sub: #CBD5E1;

  --road-watermark-fill: rgba(148, 163, 184, 0.06);
  --road-watermark-line: rgba(148, 163, 184, 0.14);

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 14px 34px rgba(249, 115, 22, 0.30);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --font-ui: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'Rubik', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* โหมดสู้แดดสว่างจัด (High-Contrast Sunlight Mode) */
[data-theme="sunlight"] {
  --brand-orange: #EA580C;
  --brand-orange-dark: #C2410C;
  --brand-orange-soft: rgba(234, 88, 12, 0.2);
  --accent-green: #15803D;
  --accent-red: #DC2626;
  --accent-amber: #D97706;
  --accent-cyan: #0284C7;

  --bg-primary: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-pill: #FFFFFF;

  --text-primary: #000000;
  --text-secondary: #111827;
  --text-muted: #1F2937;
  --border-color: #0F172A;
  --divider-line: rgba(0, 0, 0, 0.28);

  --home-map-top: #E0F2FE;
  --home-map-mid: #F0FDF4;
  --home-road-river: #7DD3FC;
  --home-road-line: #FFFFFF;
  --home-road-sub: #64748B;

  --road-watermark-fill: rgba(0, 0, 0, 0.03);
  --road-watermark-line: rgba(0, 0, 0, 0.08);

  --shadow-sm: 0 0 0 1.5px #0F172A;
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* โหมดมืดประหยัดพลังงานหน้าจอ (OLED Dark Mode) */
[data-theme="dark"] {
  --brand-orange: #FB923C;
  --brand-orange-dark: #F97316;
  --brand-orange-soft: rgba(251, 146, 60, 0.18);
  --accent-green: #22C55E;
  --accent-red: #F87171;
  --accent-amber: #FBBF24;
  --accent-cyan: #22D3EE;

  --bg-primary: #06090F;
  --bg-surface: #111622;
  --bg-elevated: #192030;
  --bg-subtle: #1E293B;
  --bg-pill: rgba(17, 22, 34, 0.90);

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --border-color: #263248;
  --divider-line: rgba(148, 163, 184, 0.16);

  --home-map-top: #0B192C;
  --home-map-mid: #0F172A;
  --home-road-river: #1E3A5F;
  --home-road-line: #1E293B;
  --home-road-sub: #334155;

  --road-watermark-fill: rgba(255, 255, 255, 0.03);
  --road-watermark-line: rgba(255, 255, 255, 0.07);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

button:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-primary);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
}

@media (min-width: 561px) {
  body {
    background: #0B1120;
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* ==========================================================================
   SCREEN 1: Home Dashboard & Garage
   ========================================================================== */

.home-map-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.home-road-svg {
  width: 100%;
  height: 100%;
}

.home-map-pin-wrap {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-map-pin-pulse {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.22);
  animation: pulseRing 2.4s ease-out infinite;
}

.home-map-pin {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  background: var(--brand-orange);
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(249, 115, 22, 0.4);
}

.home-map-pin-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #FFFFFF;
}

@keyframes pulseRing {
  0% {
    transform: scale(0.55);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

.home-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-top) + 12px) 16px 8px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.86rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.unit-pill {
  color: var(--brand-orange);
}

.circle-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brand-badge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.brand-title {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.pro-tag {
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.pro-tag.free {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.pro-tag.pro {
  background: linear-gradient(135deg, #F97316, #F59E0B);
  color: #FFFFFF;
}

.route-card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 6px 10px;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-size: 0.76rem;
  font-weight: 700;
  gap: 2px;
}

.home-main {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 18px calc(var(--safe-bottom) + 20px);
  overflow-y: auto;
}

.home-hero-stats {
  margin-top: 4px;
}

.total-dist-trigger {
  text-align: left;
  display: block;
  width: 100%;
}

.hero-odometer-num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 12vw, 4.1rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-odometer-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.chevron-arrow {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-orange);
}

.home-mini-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mini-stat-chip {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.weather-chip {
  color: var(--brand-orange-dark);
}

/* Ghost Active Banner on Home */
.ghost-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1.5px solid var(--brand-orange);
  box-shadow: var(--shadow-sm);
  margin: 8px 0;
}

.ghost-banner-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-emoji {
  font-size: 1.4rem;
}

.ghost-banner-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.ghost-banner-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.icon-close-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.85rem;
}

/* My Bike Garage Pill & E-Bike Pre-Ride Bar */
.garage-dock-card {
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  margin: 10px 0;
}

.garage-pill-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.bike-type-emoji {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--brand-orange-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.garage-pill-text {
  flex: 1;
  min-width: 0;
}

.garage-pill-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.garage-bike-name {
  font-weight: 700;
  font-size: 1.04rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maint-dot-badge {
  font-size: 0.9rem;
  animation: blinkAlert 1.5s infinite;
}

@keyframes blinkAlert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.garage-bike-odo {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.garage-chevron {
  font-size: 1rem;
  color: var(--text-muted);
}

.ebike-preride-strip {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
}

.ebike-strip-left {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.ebike-strip-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ebike-inline-input {
  width: 68px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-family: var(--font-num);
  font-weight: 700;
  text-align: right;
}

.ebike-unit-select {
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-weight: 700;
}

.ebike-spec-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-orange);
}

/* Center Start Action Zone */
.home-launch-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 6px;
}

.goal-capsule-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-size: 0.98rem;
  font-weight: 700;
}

.start-btn-ring-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-btn-pulse {
  position: absolute;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.20);
  animation: startPulse 2.2s ease-in-out infinite;
}

@keyframes startPulse {
  0%, 100% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 0.25; }
}

.start-ride-btn {
  position: relative;
  width: 98px;
  height: 98px;
  border-radius: 50%;
  background: linear-gradient(145deg, #FB923C, #F97316 55%, #EA580C);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.start-ride-btn:active {
  transform: scale(0.93);
}

.demo-ride-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   SCREEN 2: Full-Screen Orange Countdown (3 -> 2 -> 1)
   ========================================================================== */

.countdown-screen {
  background: linear-gradient(160deg, #FB923C 0%, #F97316 50%, #EA580C 100%);
  color: #FFFFFF;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.countdown-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  padding: 24px;
}

.countdown-bike-pill {
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-weight: 700;
  font-size: 1rem;
}

.countdown-digit {
  font-family: var(--font-num);
  font-size: clamp(6.5rem, 28vw, 9.5rem);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: countPop 0.85s ease-out infinite;
}

@keyframes countPop {
  0% { transform: scale(0.72); opacity: 0.4; }
  35% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.countdown-sub {
  font-size: 1.15rem;
  font-weight: 600;
  opacity: 0.95;
}

.countdown-skip-btn {
  margin-top: 24px;
  padding: 10px 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ==========================================================================
   SCREEN 3: Live Riding Cockpit & Custom Data Grid
   ========================================================================== */

.cockpit-screen {
  background: var(--bg-primary);
  overflow: hidden;
}

.cockpit-visual-stage {
  position: relative;
  width: 100%;
  height: 38%;
  min-height: 210px;
  background: #DCE8E2;
  transition: height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  flex-shrink: 0;
}

/* เมื่อย่อแผงตัวเลขเพื่อดูแผนที่หรือกล้องใหญ่ขึ้น */
.cockpit-screen.sheet-collapsed .cockpit-visual-stage {
  height: 64%;
}

/* เมื่อดึงแผงตัวเลขขึ้นเต็มจอ */
.cockpit-screen.sheet-expanded .cockpit-visual-stage {
  height: 20%;
  min-height: 125px;
}

/* มุมมองคลีนเต็มจอสำหรับอัดหน้าจอมือถือ */
.cockpit-screen.clean-fullscreen .cockpit-visual-stage {
  height: 100%;
}

.cockpit-screen.clean-fullscreen .cockpit-telemetry-sheet,
.cockpit-screen.clean-fullscreen .cockpit-top-right,
.cockpit-screen.clean-fullscreen .map-quick-controls,
.cockpit-screen.clean-fullscreen .cam-floating-bar {
  display: none !important;
}

.live-map-wrapper,
.live-cam-wrapper,
.map-canvas {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ปรับสีแผนที่ให้นุ่มสายตาในโหมดมืด */
[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(0.84) contrast(1.08) saturate(0.88);
}

.leaflet-control-attribution {
  font-size: 9px !important;
  opacity: 0.65;
}

/* Action-Cam HUD Stage */
.live-cam-wrapper {
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hidden-raw-video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.cam-hud-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-floating-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
}

.cam-rec-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #EF4444;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.82rem;
}

.cam-rec-btn.recording {
  background: #DC2626;
  animation: blinkRec 1.1s infinite;
}

@keyframes blinkRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.68; }
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFFFFF;
}

.rec-timer {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.cam-mini-btn {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Floating Status Pills (Top Left) */
.cockpit-top-left {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  z-index: 450;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.gps-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}

.gps-bars i {
  display: block;
  width: 3px;
  background: #CBD5E1;
  border-radius: 1px;
}

.gps-bars i:nth-child(1) { height: 4px; }
.gps-bars i:nth-child(2) { height: 7px; }
.gps-bars i:nth-child(3) { height: 11px; }

.gps-bars.good i { background: var(--accent-green); }
.gps-bars.fair i:nth-child(1),
.gps-bars.fair i:nth-child(2) { background: var(--accent-amber); }
.gps-bars.weak i:nth-child(1) { background: var(--accent-red); }

/* Live Wind Direction Pill */
.wind-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
}

.wind-pill[data-wind="tailwind"] .wind-dot { background: var(--accent-green); }
.wind-pill[data-wind="crosswind"] .wind-dot { background: var(--accent-amber); }
.wind-pill[data-wind="headwind"] .wind-dot { background: var(--accent-red); }

.wind-arrow {
  transition: transform 0.35s ease;
}

.ghost-pill[data-ahead="true"] {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.ghost-pill[data-ahead="false"] {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
}

/* Floating Tool Buttons (Top Right) */
.cockpit-top-right {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  right: 12px;
  z-index: 450;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floating-round-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  backdrop-filter: blur(8px);
}

.floating-round-btn.voice-listening {
  background: var(--brand-orange);
  color: #FFFFFF;
  border-color: var(--brand-orange);
  box-shadow: 0 0 0 5px rgba(249, 115, 22, 0.28);
}

.floating-rec-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #EF4444;
  border: 1.5px solid #FFFFFF;
}

.map-quick-controls {
  position: absolute;
  bottom: 24px;
  left: 12px;
  z-index: 450;
  display: flex;
  gap: 8px;
}

.map-mini-fab {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.map-mini-fab.active {
  border-color: var(--brand-orange);
}

.exit-clean-pill {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 12px;
  z-index: 520;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 700;
}

/* Bottom Telemetry Panel (Huawei Health Clean Card Style — Zero Heart Rate) */
.cockpit-telemetry-sheet {
  position: relative;
  z-index: 460;
  flex: 1;
  margin-top: -18px;
  border-radius: 26px 26px 0 0;
  background: var(--bg-surface);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
  padding: 8px 20px calc(var(--safe-bottom) + 14px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.sheet-road-watermark {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 75%;
  pointer-events: none;
  z-index: 0;
}

.sheet-handle-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 26px;
}

.sheet-badges-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.state-chip {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.autopause-chip {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-amber);
}

.demo-speed-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--brand-orange-soft);
}

.demo-tag {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--brand-orange);
}

.demo-step-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-surface);
  font-weight: 800;
  line-height: 1;
}

.sheet-grabber-btn {
  padding: 6px 18px;
  display: flex;
  justify-content: center;
}

.sheet-grabber-bar {
  width: 38px;
  height: 4.5px;
  border-radius: 999px;
  background: var(--border-color);
}

.edit-metrics-link {
  justify-self: end;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--brand-orange);
  padding: 3px 8px;
  border-radius: 8px;
}

/* Goal Progress Strip inside Cockpit */
.cockpit-goal-bar {
  position: relative;
  z-index: 1;
  margin: 2px 0 4px;
}

.goal-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.goal-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.goal-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #F97316, #22C55E);
  transition: width 0.3s ease;
}

/* Primary Hero Metric (Slot 0) */
.hero-metric-box {
  position: relative;
  z-index: 1;
  padding: 2px 0 6px;
  cursor: pointer;
}

.hero-metric-val {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.3rem, 13.5vw, 4.6rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-metric-lbl {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* 6-Cell Secondary Metrics Grid */
.cockpit-metrics-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--divider-line);
}

.grid-metric-cell {
  padding: 10px 6px;
  border-bottom: 1px solid var(--divider-line);
  cursor: pointer;
}

.grid-metric-cell:nth-child(odd) {
  padding-right: 12px;
  border-right: 1px solid var(--divider-line);
}

.grid-metric-cell:nth-child(even) {
  padding-left: 14px;
}

.grid-metric-val {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.65rem, 6.6vw, 2.15rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.grid-metric-lbl {
  margin-top: 2px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom Cockpit Action Bar */
.cockpit-controls-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
}

.cockpit-side-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.cockpit-center-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cockpit-main-btn {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.pause-btn {
  background: #EF5350;
}

.paused-btn-pair {
  display: flex;
  align-items: center;
  gap: 22px;
}

.resume-btn {
  background: #4CAF50;
}

.finish-btn-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.finish-btn {
  background: #EF5350;
}

.finish-progress-svg {
  position: absolute;
  inset: -4px;
  width: 82px;
  height: 82px;
  transform: rotate(-90deg);
  pointer-events: none;
}

.finish-ring-bg {
  fill: none;
  stroke: transparent;
  stroke-width: 4;
}

.finish-ring-fill {
  fill: none;
  stroke: #F97316;
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 226.2;
  stroke-dashoffset: 226.2;
  transition: stroke-dashoffset 0.05s linear;
}

.hold-hint-text {
  position: absolute;
  bottom: -17px;
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Screen Lock Overlay Shield */
.cockpit-lock-shield {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

.unlock-hold-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.96rem;
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   SCREEN 4: History Overview & Monthly Cards
   ========================================================================== */

.subpage-screen {
  background: var(--bg-primary);
}

.subpage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.nav-back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-subtle);
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.subpage-title-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.subpage-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bike-filter-select {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 0.84rem;
  font-weight: 600;
  max-width: 150px;
}

.subpage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.subpage-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(var(--safe-bottom) + 24px);
}

.overview-summary-banner {
  background: var(--bg-surface);
  border-radius: 20px;
  padding: 16px 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.overview-heading {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.overview-4col-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
}

.ov-stat-item {
  padding: 0 4px;
  border-right: 1px solid var(--divider-line);
}

.ov-stat-item:last-child {
  border-right: none;
}

.ov-stat-num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 1.38rem;
  font-weight: 700;
}

.ov-stat-lbl {
  margin-top: 3px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Monthly Collapsible Cards */
.history-months-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.month-group-card {
  background: var(--bg-surface);
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.month-group-header {
  width: 100%;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.month-title-txt {
  font-size: 1.15rem;
  font-weight: 800;
}

.month-sub-stats {
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.month-chevron {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.month-group-card.collapsed .month-chevron {
  transform: rotate(180deg);
}

.month-group-card.collapsed .month-sessions-wrap {
  display: none;
}

.month-sessions-wrap {
  border-top: 1px solid var(--divider-line);
}

.session-row-btn {
  width: 100%;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  border-bottom: 1px solid var(--divider-line);
}

.session-row-btn:last-child {
  border-bottom: none;
}

.session-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F43F5E, #F97316);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.session-icon-circle.ebike {
  background: linear-gradient(135deg, #F97316, #EAB308);
}

.session-row-main {
  flex: 1;
  min-width: 0;
}

.session-row-top {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-row-metrics {
  margin-top: 3px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.session-dist-strong {
  font-family: var(--font-num);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.session-meta-num {
  font-family: var(--font-num);
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-box {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

/* ==========================================================================
   SCREEN 5: Post-Ride Summary (4 Tabs + Dynamic Replay + Export)
   ========================================================================== */

.summary-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.summary-tab-btn {
  position: relative;
  padding: 12px 6px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.summary-tab-btn.active {
  color: var(--brand-orange);
}

.summary-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 18%;
  width: 64%;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand-orange);
}

.summary-body-scroll {
  flex: 1;
  overflow-y: auto;
}

.summary-tab-panel {
  display: none;
}

.summary-tab-panel.active {
  display: block;
}

/* Tab 1: Route & Dynamic Replay */
.summary-map-wrapper {
  position: relative;
  width: 100%;
  height: 330px;
  background: #DCE8E2;
}

.summary-map-fabs {
  position: absolute;
  top: 14px;
  right: 12px;
  z-index: 450;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sum-map-fab {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-pill);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-size: 0.82rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sum-map-fab.active {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
}

.replay-hud-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 460;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.88);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  backdrop-filter: blur(8px);
}

.replay-hud-stats {
  display: flex;
  gap: 14px;
  font-family: var(--font-num);
  font-size: 1.05rem;
}

.replay-hud-controls {
  display: flex;
  gap: 6px;
}

.replay-chip-btn {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.82rem;
}

.replay-chip-btn.stop {
  background: #EF4444;
}

.summary-route-card {
  padding: 18px 18px 24px;
  background: var(--bg-surface);
}

.sum-route-hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sum-big-dist {
  font-family: var(--font-num);
  font-size: 2.9rem;
  font-weight: 700;
  line-height: 1;
}

.sum-dist-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
}

.dynamic-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--brand-orange);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.32);
}

.sum-datetime-line {
  margin: 8px 0 16px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.sum-route-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--divider-line);
}

.sum-3col-lbl {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.sum-3col-val {
  margin-top: 3px;
  font-family: var(--font-num);
  font-size: 1.28rem;
  font-weight: 700;
}

.sum-photos-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--divider-line);
}

.sum-photo-thumb {
  width: 92px;
  height: 92px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Tab 2: Speed Splits Horizontal Bars */
.splits-card,
.chart-card,
.details-card {
  margin: 14px;
  padding: 18px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.splits-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.splits-sub-lbl {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.splits-avg-num {
  font-family: var(--font-num);
  font-size: 2.2rem;
  font-weight: 700;
}

.splits-avg-unit {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.splits-interval-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 999px;
}

.split-toggle-btn {
  min-width: 38px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.split-toggle-btn.active {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.splits-list-header {
  display: flex;
  gap: 16px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.splits-bars-container {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.split-bar-track {
  position: relative;
  width: 100%;
  height: 32px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.split-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FDBA74, #F97316);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: #FFFFFF;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 0.92rem;
  min-width: 96px;
}

.split-bar-fill.fastest {
  background: linear-gradient(90deg, #F97316, #EA580C);
}

.split-bar-remainder {
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Tab 3: Smooth Area Charts */
.chart-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.chart-unit-muted {
  font-weight: 600;
  color: var(--text-muted);
}

.chart-2stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  text-align: center;
  margin-bottom: 12px;
}

.chart-stat-lbl {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.chart-stat-val {
  font-family: var(--font-num);
  font-size: 1.7rem;
  font-weight: 700;
}

.canvas-chart-box {
  width: 100%;
  height: 195px;
  position: relative;
}

.canvas-chart-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tab 4: Details & E-Bike Report */
.details-datetime {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.details-bike-pill {
  margin: 8px auto;
  width: fit-content;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.88rem;
}

.details-hero-dist {
  text-align: center;
  margin: 6px 0 18px;
}

.details-big-num {
  font-family: var(--font-num);
  font-size: 3rem;
  font-weight: 700;
}

.details-big-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.ebike-summary-box {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 16px;
  background: var(--brand-orange-soft);
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.ebike-sum-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--brand-orange-dark);
}

.ebike-sum-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.details-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
  padding-top: 14px;
  border-top: 1px solid var(--divider-line);
}

.det-metric-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.det-metric-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.det-metric-lbl {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.det-metric-val {
  font-family: var(--font-num);
  font-size: 1.22rem;
  font-weight: 700;
}

/* Summary Export Footer */
.summary-export-bar {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.1fr;
  gap: 8px;
  padding: 10px 14px calc(var(--safe-bottom) + 12px);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

.export-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.88rem;
}

.export-action-btn.primary {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
  color: #FFFFFF;
}

/* ==========================================================================
   SCREEN 6: Full-Screen SOS Rear Strobe Light
   ========================================================================== */

.sos-screen {
  z-index: 90;
}

.sos-strobe-bg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #DC2626;
}

.sos-strobe-bg.mode-morse {
  animation: sosMorseFlash 3.6s infinite;
}

.sos-strobe-bg.mode-rapid {
  animation: sosRapidFlash 0.28s infinite;
}

.sos-strobe-bg.mode-solid {
  background: #EF4444;
}

@keyframes sosMorseFlash {
  0%, 8%, 16%, 24% { background: #FF0000; }
  4%, 12%, 20%, 28% { background: #1A0000; }
  34%, 52%, 70% { background: #FF3B00; }
  44%, 62%, 80%, 100% { background: #140000; }
}

@keyframes sosRapidFlash {
  0%, 49% { background: #FF0000; }
  50%, 100% { background: #F97316; }
}

.sos-content-card {
  width: 100%;
  max-width: 380px;
  padding: 24px 20px;
  border-radius: 24px;
  background: rgba(10, 10, 14, 0.84);
  color: #FFFFFF;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.sos-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #EF4444;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.sos-heading {
  margin: 10px 0 6px;
  font-size: 1.35rem;
}

.sos-coords {
  font-family: var(--font-num);
  font-size: 0.95rem;
  color: #FDBA74;
  margin-bottom: 16px;
}

.sos-pattern-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.sos-mode-btn {
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 700;
}

.sos-mode-btn.active {
  background: #FFFFFF;
  color: #DC2626;
}

.sos-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sos-action-btn {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sos-action-btn.primary {
  background: #22C55E;
  color: #FFFFFF;
}

.sos-close-btn {
  margin-top: 6px;
  padding: 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #CBD5E1;
  font-weight: 700;
}

/* ==========================================================================
   Modals, Bottom Sheets & Custom Data Grid Picker (Screenshot 3)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  background: var(--bg-surface);
  border-radius: 26px 26px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
  animation: slideUpSheet 0.22s ease-out;
}

.modal-sheet.full-height-sheet {
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  padding-top: var(--safe-top);
}

@keyframes slideUpSheet {
  from { transform: translateY(40px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-card {
  width: calc(100% - 32px);
  max-width: 400px;
  margin: auto;
  padding: 24px 20px;
  border-radius: 24px;
  background: var(--bg-surface);
  text-align: center;
  box-shadow: var(--shadow-md);
}

.modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
}

.icon-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-subtle);
  font-weight: 700;
}

.text-link-btn {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-orange);
}

.modal-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 22px;
}

/* Edit Metrics Modal (Screenshot 3 Style) */
.slot-selector-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 18px;
}

.slot-tab-chip {
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-secondary);
}

.slot-tab-chip.active {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.edit-slot-preview {
  padding: 8px 22px 14px;
}

.edit-preview-num {
  font-family: var(--font-num);
  font-size: 3.3rem;
  font-weight: 700;
  line-height: 1;
}

.edit-preview-label {
  margin-top: 4px;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.edit-instruction-lbl {
  padding: 0 22px 10px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.metrics-picker-grid {
  flex: 1;
  overflow-y: auto;
  margin: 0 16px;
  padding: 18px 12px;
  border-radius: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 8px;
}

.metric-pick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.metric-pick-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  transition: all 0.15s ease;
}

.metric-pick-item.selected .metric-pick-circle {
  background: var(--brand-orange);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
}

.metric-pick-item.in-use:not(.selected) .metric-pick-circle {
  border: 2px solid var(--brand-orange);
}

.metric-pick-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

.modal-bottom-bar {
  padding: 14px 18px calc(var(--safe-bottom) + 14px);
}

/* Forms, Buttons, Garage & Settings */
.primary-orange-btn {
  width: 100%;
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--brand-orange);
  color: #FFFFFF;
  font-size: 1.04rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.28);
}

.secondary-outline-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.92rem;
}

.full-width-btn {
  width: 100%;
  margin-bottom: 12px;
}

.garage-bikes-list,
.saved-routes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.garage-bike-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-subtle);
  border: 1.5px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.garage-bike-card.active {
  border-color: var(--brand-orange);
  background: var(--brand-orange-soft);
}

.garage-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.garage-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-action-btn {
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 700;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

.form-section-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 800;
}

.garage-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.88rem;
  font-weight: 600;
}

.form-field input,
.form-field select {
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.form-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.ebike-form-box {
  padding: 12px;
  border-radius: 14px;
  background: var(--brand-orange-soft);
  border: 1px dashed var(--brand-orange);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ebike-box-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--brand-orange-dark);
}

.form-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.form-btn-row > button {
  flex: 1;
}

/* Post-ride E-Bike Modal */
.modal-card-icon {
  font-size: 2.4rem;
}

.modal-card-title {
  margin: 8px 0 6px;
  font-size: 1.2rem;
}

.modal-card-desc {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.ebike-post-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}

.ebike-big-input,
.goal-big-input {
  width: 130px;
  height: 54px;
  border-radius: 16px;
  border: 2px solid var(--brand-orange);
  background: var(--bg-subtle);
  font-family: var(--font-num);
  font-size: 1.9rem;
  font-weight: 700;
  text-align: center;
}

.ebike-big-unit,
.goal-unit-lbl {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.modal-card-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 10px;
}

/* Goal Modal */
.goal-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.goal-type-btn {
  padding: 12px 10px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1.5px solid transparent;
  font-weight: 700;
}

.goal-type-btn.active {
  border-color: var(--brand-orange);
  background: var(--brand-orange-soft);
  color: var(--brand-orange);
}

.goal-value-section {
  margin-bottom: 18px;
  text-align: center;
}

.goal-presets-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.goal-preset-chip {
  padding: 6px 15px;
  border-radius: 999px;
  background: var(--bg-subtle);
  font-family: var(--font-num);
  font-weight: 700;
}

.goal-preset-chip.active {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.goal-custom-input-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Settings List & Toggle Rows */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pro-promo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1E293B, #0F172A);
  color: #FFFFFF;
}

.pro-promo-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: #FDBA74;
  letter-spacing: 0.06em;
}

.pro-promo-title {
  font-weight: 800;
  font-size: 0.98rem;
}

.pro-promo-sub {
  font-size: 0.78rem;
  color: #CBD5E1;
}

.pro-upgrade-btn {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand-orange);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 0.94rem;
}

.setting-item select,
.setting-num-input {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-weight: 700;
  max-width: 185px;
}

.setting-num-input {
  width: 82px;
  text-align: right;
  font-family: var(--font-num);
}

.inline-ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-subtle);
  cursor: pointer;
}

.toggle-row.highlight-toggle {
  background: var(--brand-orange-soft);
  border: 1px solid rgba(249, 115, 22, 0.35);
  margin-bottom: 12px;
}

.toggle-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand-orange);
  flex-shrink: 0;
}

.advanced-map-box {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-footer-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-footer-links a {
  color: var(--brand-orange);
  text-decoration: none;
  font-weight: 700;
}

/* 10-Language Grid */
.language-grid {
  padding: 16px 18px 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.lang-option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1.5px solid transparent;
  font-weight: 700;
  text-align: left;
}

.lang-option-btn.active {
  border-color: var(--brand-orange);
  background: var(--brand-orange-soft);
}

/* Voice Help & Paywall */
.voice-cmd-card {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.paywall-hero {
  text-align: center;
  padding: 10px 0 14px;
}

.paywall-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-orange-soft);
  color: var(--brand-orange);
  font-size: 0.75rem;
  font-weight: 800;
}

.paywall-price {
  margin: 8px 0 4px;
  font-family: var(--font-num);
  font-size: 2.8rem;
  color: var(--text-primary);
}

.paywall-features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-weight: 600;
}

.paywall-buy-btn {
  margin-bottom: 10px;
}

.dev-sim-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--accent-amber);
  color: var(--accent-amber);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Share Card Preview */
.share-card-canvas {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 14px;
  display: block;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

/* Custom Leaflet DivIcons (Rider, Ghost, KM Milestones) */
.onebike-rider-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #F97316;
  border: 3px solid #FFFFFF;
  box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.28), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.onebike-ghost-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #6366F1;
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.onebike-km-pin {
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: #334155;
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}

.toast-msg {
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: toastFadeIn 0.2s ease-out;
}

@keyframes toastFadeIn {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}