/* Velox: futuristic GPS speedometer. Mobile first; landscape and desktop layouts below. */

/* Fonts are served from this site (SIL Open Font License), so the app starts with no connection. */
@font-face { font-family: 'Orbitron'; font-style: normal; font-weight: 500 900; font-display: swap; src: url(fonts/orbitron-latin.woff2) format('woff2'); }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/rajdhani-500-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/rajdhani-500-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/rajdhani-600-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/rajdhani-600-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/rajdhani-700-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Rajdhani'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/rajdhani-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #05070d;
  --bg-2: #0a0f1c;
  --panel: rgba(13, 21, 38, 0.72);
  --panel-solid: #0d1526;
  --panel-hi: rgba(26, 40, 68, 0.8);
  --line: rgba(120, 200, 255, 0.14);
  --line-hi: rgba(34, 228, 255, 0.45);
  --text: #e8f4ff;
  --text-2: #9db0cc;
  --muted: #5d6f91;
  --accent: #22e4ff;
  --accent-dim: #0b8aa8;
  --accent-ice: #d9fbff;
  --hot: #ff2bd6;
  --rec: #ff3358;
  --warn: #ffb020;
  --ok: #3dffa8;
  --radius: 18px;
  --radius-sm: 12px;
  --top-h: 56px;
  --tab-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Rajdhani', system-ui, sans-serif;
  --font-num: 'Orbitron', 'Rajdhani', system-ui, sans-serif;
  --streak-speed: 0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 600 16px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
svg { display: block; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* Icons drawn with strokes share one look. */
.chip svg, .btn svg, .ctl-btn svg, .tabbar svg, .icon-btn svg, .map-back svg, .map-fab svg {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.backdrop-glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 30% at 50% 28%, rgba(34, 228, 255, 0.16), transparent 70%),
    radial-gradient(35% 25% at 85% 90%, rgba(255, 43, 214, 0.10), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
.backdrop-grid {
  position: absolute; left: -50%; right: -50%; bottom: -10%; height: 55%;
  background-image:
    linear-gradient(rgba(34, 228, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 228, 255, 0.16) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(320px) rotateX(62deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(to bottom, transparent, #000 45%);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 45%);
  opacity: 0.5;
  animation: grid-run 1.6s linear infinite;
  animation-play-state: paused;
}
body.moving[data-view="drive"] .backdrop-grid { animation-play-state: running; }
body:not([data-view="drive"]) .streaks { display: none; }
@keyframes grid-run { to { background-position: 0 48px, 0 0; } }

.streaks { position: absolute; inset: 0; opacity: calc(var(--streak-speed) * 0.9); transition: opacity 0.6s; }
.streaks i {
  position: absolute; top: 0; width: 1px; height: 22vh;
  background: linear-gradient(to bottom, transparent, rgba(34, 228, 255, 0.7), transparent);
  animation: streak 1.1s linear infinite;
}
.streaks i:nth-child(1) { left: 6%; animation-delay: -0.1s; animation-duration: 0.9s; }
.streaks i:nth-child(2) { left: 14%; animation-delay: -0.5s; }
.streaks i:nth-child(3) { left: 27%; animation-delay: -0.8s; animation-duration: 1.3s; }
.streaks i:nth-child(4) { left: 41%; animation-delay: -0.3s; animation-duration: 0.8s; }
.streaks i:nth-child(5) { left: 59%; animation-delay: -0.9s; }
.streaks i:nth-child(6) { left: 72%; animation-delay: -0.2s; animation-duration: 1.4s; }
.streaks i:nth-child(7) { left: 86%; animation-delay: -0.6s; animation-duration: 0.95s; }
.streaks i:nth-child(8) { left: 95%; animation-delay: -0.4s; }
@keyframes streak { from { transform: translateY(-30vh); } to { transform: translateY(130vh); } }

/* ---------- Top bar ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.92), rgba(5, 7, 13, 0.55));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; filter: drop-shadow(0 0 6px rgba(34, 228, 255, 0.7)); }
.brand-word {
  font: 900 18px/1 var(--font-num); letter-spacing: 0.22em; color: var(--text);
  text-shadow: 0 0 12px rgba(34, 228, 255, 0.45);
}
.top-tools { display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
  font: 700 12px/1 var(--font-ui); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-2); white-space: nowrap;
}
.chip svg { width: 15px; height: 15px; }
.chip-btn { color: var(--accent); border-color: var(--line-hi); }
.chip-btn:active { transform: scale(0.96); }

.gps-chip .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.gps-chip .bars i { width: 3px; border-radius: 1px; background: var(--muted); opacity: 0.45; }
.gps-chip .bars i:nth-child(1) { height: 4px; }
.gps-chip .bars i:nth-child(2) { height: 7px; }
.gps-chip .bars i:nth-child(3) { height: 10px; }
.gps-chip .bars i:nth-child(4) { height: 13px; }
.gps-chip[data-level="1"] .bars i:nth-child(-n+1),
.gps-chip[data-level="2"] .bars i:nth-child(-n+2),
.gps-chip[data-level="3"] .bars i:nth-child(-n+3),
.gps-chip[data-level="4"] .bars i:nth-child(-n+4) { background: currentColor; opacity: 1; }
.gps-chip[data-state="good"] { color: var(--accent); border-color: var(--line-hi); }
.gps-chip[data-state="weak"] { color: var(--warn); }
.gps-chip[data-state="wait"] { color: var(--text-2); }
.gps-chip[data-state="wait"] .bars i { animation: bar-wait 1.2s ease-in-out infinite; }
.gps-chip[data-state="wait"] .bars i:nth-child(2) { animation-delay: 0.15s; }
.gps-chip[data-state="wait"] .bars i:nth-child(3) { animation-delay: 0.3s; }
.gps-chip[data-state="wait"] .bars i:nth-child(4) { animation-delay: 0.45s; }
.gps-chip[data-state="denied"], .gps-chip[data-state="nosignal"], .gps-chip[data-state="unavailable"] { color: var(--rec); }
@keyframes bar-wait { 50% { opacity: 1; background: currentColor; } }

/* ---------- Views ---------- */
#views {
  position: fixed; z-index: 1;
  top: calc(var(--top-h) + var(--safe-t));
  bottom: calc(var(--tab-h) + var(--safe-b));
  left: 0; right: 0;
}
.view {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  opacity: 0; visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s 0.22s;
}
body[data-view="drive"] .view-drive,
body[data-view="routes"] .view-routes,
body[data-view="route"] .view-route,
body[data-view="settings"] .view-settings {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s;
}
.page { max-width: 760px; margin: 0 auto; padding: 18px 16px 32px; }
.page-title {
  margin: 4px 0 16px; font: 700 22px/1 var(--font-num); letter-spacing: 0.14em; text-transform: uppercase;
}

/* ---------- Drive ---------- */
.drive-layout {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px 16px;
  gap: 10px;
}
.gauge-wrap {
  position: relative;
  width: min(92vw, 46vh, 440px);
  aspect-ratio: 1;
  flex-shrink: 0;
  container-type: inline-size;
}
.gauge { width: 100%; height: 100%; overflow: visible; }
.gauge-ring-outer { fill: none; stroke: var(--line); stroke-width: 1; }
.gauge-track { fill: none; stroke: rgba(120, 200, 255, 0.10); stroke-width: 18; stroke-linecap: round; }
.gauge-max-arc { fill: none; stroke: var(--hot); stroke-width: 3; stroke-linecap: round; opacity: 0.85; }
.gauge-arc { fill: none; stroke-width: 18; stroke-linecap: round; transition: stroke 0.3s; }
.gauge-tip { fill: var(--accent-ice); }
.tick { stroke: rgba(157, 176, 204, 0.4); stroke-width: 1.5; }
.tick.major { stroke: rgba(232, 244, 255, 0.75); stroke-width: 2.5; }
.tick.lit { stroke: var(--accent); }
.gauge-label { fill: var(--text-2); font: 700 15px var(--font-num); text-anchor: middle; dominant-baseline: middle; }

.gauge-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  padding-top: 4%;
}
/* Digits are sized from the dial (cqw = 1% of the gauge width), so they clear the arc in every
   layout. Three digits (100+) step down to fit inside it. The px values are for old browsers. */
.speed-readout {
  font: 900 clamp(64px, 25vw, 132px)/0.9 var(--font-num);
  font-size: 27cqw;
  color: var(--text);
  text-shadow: 0 0 18px rgba(34, 228, 255, 0.55), 0 0 2px rgba(255, 255, 255, 0.8);
  display: flex;
}
.speed-readout.three { font-size: 21cqw; }
.speed-readout.four { font-size: 16cqw; }
.speed-readout .digits { display: inline-flex; }
.speed-readout .d { display: inline-block; width: 0.8em; text-align: center; }
.speed-unit {
  margin-top: 6px;
  font: 700 14px/1 var(--font-num); letter-spacing: 0.35em; color: var(--accent);
  padding-left: 0.35em;
}
.speed-sub { margin-top: 12px; display: flex; gap: 10px; }
.heading {
  font: 700 13px/1 var(--font-num); letter-spacing: 0.12em; color: var(--text-2);
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(5, 7, 13, 0.5);
}
.alert-badge {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  font: 900 12px/1 var(--font-num); letter-spacing: 0.2em;
  color: #1a0700; background: var(--warn); padding: 7px 12px; border-radius: 999px;
  box-shadow: 0 0 20px rgba(255, 176, 32, 0.6);
}
body.over-limit .gauge-arc { stroke: var(--warn); }
body.over-limit .speed-readout { color: var(--warn); text-shadow: 0 0 22px rgba(255, 176, 32, 0.7); }
body.over-limit .gauge-wrap { animation: limit-pulse 0.9s ease-in-out infinite; }
@keyframes limit-pulse { 50% { filter: drop-shadow(0 0 22px rgba(255, 176, 32, 0.55)); } }

.drive-side { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 10px; }

.session-strip { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.rec-state {
  display: inline-flex; align-items: center; gap: 8px;
  font: 700 12px/1 var(--font-num); letter-spacing: 0.2em; color: var(--text-2);
}
.rec-state i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.rec-state[data-state="rec"] { color: var(--rec); }
.rec-state[data-state="rec"] i { background: var(--rec); box-shadow: 0 0 10px var(--rec); animation: blink 1.2s steps(2, start) infinite; }
.rec-state[data-state="paused"] { color: var(--warn); }
.rec-state[data-state="paused"] i { background: var(--warn); }
@keyframes blink { to { visibility: hidden; } }
.session-time { font-size: 20px; font-weight: 700; letter-spacing: 0.06em; }

.mode-chip { gap: 6px; padding: 0 10px 0 9px; min-width: 0; }
.mode-chip svg { width: 18px; height: 18px; flex: none; }
.mode-chip span { overflow: hidden; text-overflow: ellipsis; }
.session-strip .mode-chip { height: 34px; }
.session-strip .mode-chip[aria-disabled="true"] { color: var(--text-2); border-color: var(--line); }

/* GPS problems: what is wrong and what to do about it, under the session strip. */
.gps-banner {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 12px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 176, 32, 0.45); background: rgba(40, 26, 4, 0.72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text);
}
.gps-banner > svg { width: 22px; height: 22px; flex: none; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gps-banner-body { flex: 1; min-width: 0; }
.gps-banner b { display: block; font: 700 15px/1.2 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--warn); }
.gps-banner span { display: block; margin-top: 3px; font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--text-2); }
.gps-banner .chip { flex: none; align-self: center; }
.gps-banner[data-level="bad"] { border-color: rgba(255, 51, 88, 0.5); background: rgba(44, 6, 14, 0.72); }
.gps-banner[data-level="bad"] > svg { stroke: var(--rec); }
.gps-banner[data-level="bad"] b { color: #ff8aa0; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  position: relative;
  padding: 10px 12px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}
.stat::before {
  content: ''; position: absolute; left: 12px; right: 12px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-hi), transparent);
}
.stat-label {
  display: block; font: 700 11px/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value { display: flex; align-items: baseline; gap: 4px; margin-top: 7px; white-space: nowrap; }
.stat-value b { font: 700 20px/1 var(--font-num); font-variant-numeric: tabular-nums; color: var(--text); }
.stat-value small { font: 600 12px/1 var(--font-ui); color: var(--text-2); }
.stat-hot b { color: var(--text); text-shadow: 0 0 12px rgba(255, 43, 214, 0.6); }
.stat-hot::before { background: linear-gradient(90deg, transparent, rgba(255, 43, 214, 0.7), transparent); }

.live-map-card {
  position: relative; height: 34vh; min-height: 200px;
  border: 1px solid var(--line-hi); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 30px rgba(34, 228, 255, 0.12);
}
.map { position: absolute; inset: 0; background: #0b0f17; }
.map-fab {
  position: absolute; right: 10px; bottom: 10px; z-index: 500;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-hi); background: rgba(5, 7, 13, 0.85); color: var(--accent);
}
.map-fab svg { width: 20px; height: 20px; }
.map-fab[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

.controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 4px; }
.ctl-btn {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
  font: 700 10px/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase;
  transition: transform 0.12s, color 0.2s, border-color 0.2s;
}
.ctl-btn svg { width: 22px; height: 22px; }
.ctl-btn:active { transform: scale(0.94); }
.ctl-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--line-hi); box-shadow: 0 0 16px rgba(34, 228, 255, 0.25); }

.ctl-main {
  --hold: 0;
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  border: 0; padding: 0;
  background: radial-gradient(circle at 50% 35%, #2af0ff, #0aa6c9 70%);
  color: #021018;
  box-shadow: 0 0 0 6px rgba(34, 228, 255, 0.12), 0 0 34px rgba(34, 228, 255, 0.55);
  transition: transform 0.12s, box-shadow 0.3s;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.ctl-main:active { transform: scale(0.96); }
.ctl-main-label { position: relative; z-index: 1; font: 900 15px/1 var(--font-num); letter-spacing: 0.14em; padding-left: 0.14em; }
.ctl-main-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  background: conic-gradient(var(--text) calc(var(--hold) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 50px, #000 51px);
  mask: radial-gradient(circle, transparent 50px, #000 51px);
}
.ctl-main.is-rec {
  background: radial-gradient(circle at 50% 35%, #ff5677, #c4123a 70%);
  color: #fff;
  box-shadow: 0 0 0 6px rgba(255, 51, 88, 0.14), 0 0 34px rgba(255, 51, 88, 0.55);
}
.ctl-main.is-rec .ctl-main-label { font-size: 12px; }

.drive-hint { margin: 2px 8px 0; text-align: center; font-size: 13px; font-weight: 500; color: var(--muted); }

/* HUD: bigger digits, nothing else; optionally mirrored for windscreen reflection. */
body.hud .top, body.hud .tabbar, body.hud .stat-grid, body.hud .drive-hint, body.hud .live-map-card, body.hud .backdrop { display: none; }
body.hud #views { top: var(--safe-t); bottom: var(--safe-b); }
body.hud .drive-layout { justify-content: center; }
body.hud .gauge-wrap { width: min(96vw, 80vh, 720px); }
body.hud.mirror .gauge-wrap, body.hud.mirror .session-strip { transform: scaleX(-1); }
/* Recording is started and stopped from the main screen only; in HUD just the exit button stays. */
body.hud #startBtn, body.hud #pauseBtn, body.hud #mapToggle, body.hud .mode-chip, body.hud .gps-banner { display: none; }
body.hud .controls { opacity: 0.35; }

/* ---------- Routes list ---------- */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.route-list { display: flex; flex-direction: column; gap: 10px; }
.month { margin: 12px 4px 2px; font: 700 12px/1 var(--font-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.route-card {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center;
  padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); text-decoration: none;
  transition: border-color 0.2s, transform 0.12s;
}
.route-card:active { transform: scale(0.985); }
.route-card:hover { border-color: var(--line-hi); }
.route-thumb {
  width: 72px; height: 72px; border-radius: 12px;
  background: radial-gradient(circle at 50% 50%, rgba(34, 228, 255, 0.10), transparent 70%), #070b14;
  border: 1px solid var(--line);
}
.route-thumb path { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px rgba(34, 228, 255, 0.8)); }
.route-thumb circle { fill: var(--accent-ice); }
.route-card-title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; line-height: 1.15; overflow: hidden; }
.route-card-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-card-date { font-size: 13px; color: var(--text-2); font-weight: 500; margin-top: 2px; }
.route-card-stats { display: flex; gap: 14px; margin-top: 8px; font: 700 13px/1 var(--font-num); color: var(--text); flex-wrap: wrap; }
.route-card-stats small { font: 600 11px var(--font-ui); color: var(--text-2); margin-left: 2px; }
.cloud-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); flex-shrink: 0; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty svg { width: 120px; height: 120px; margin: 0 auto 12px; stroke: var(--accent); fill: var(--accent); }
.empty svg path { fill: none; }
.empty h2 { margin: 0 0 6px; font: 700 18px var(--font-num); letter-spacing: 0.08em; color: var(--text); }
.empty p { margin: 0 0 20px; }

/* ---------- Route detail ---------- */
body[data-view="route"] #views { bottom: 0; }
body[data-view="route"] .tabbar { transform: translateY(110%); }
.route-map-wrap { position: relative; height: 52vh; min-height: 260px; border-bottom: 1px solid var(--line-hi); }
.map-back {
  position: absolute; top: 12px; left: 12px; z-index: 500;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(5, 7, 13, 0.85); border: 1px solid var(--line-hi); color: var(--accent);
}
.map-back svg { width: 22px; height: 22px; }
.map-legend {
  position: absolute; left: 12px; right: 12px; bottom: 26px; z-index: 500;
  max-width: 300px;
  padding: 8px 12px 9px; border-radius: 12px;
  background: rgba(5, 7, 13, 0.82); border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.legend-title { font: 700 10px/1 var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-2); margin-bottom: 6px; }
.legend-bar { height: 6px; border-radius: 3px; }
.legend-scale { display: flex; justify-content: space-between; margin-top: 5px; font: 700 11px/1 var(--font-num); color: var(--text); }

.route-page { padding-top: 16px; }
.route-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.route-name { margin: 0; font: 700 22px/1.15 var(--font-ui); letter-spacing: 0.02em; word-break: break-word; }
.route-date { margin: 4px 0 0; color: var(--text-2); font-weight: 500; }
.icon-btn {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2);
}
.icon-btn svg { width: 19px; height: 19px; }
.stat-grid-route { margin-bottom: 14px; }

.chart-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 12px 10px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding: 0 2px; }
.chart-head h2 { margin: 0; font: 700 13px/1 var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-2); }
.chart { position: relative; height: 180px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: rgba(157, 176, 204, 0.12); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font: 600 11px var(--font-ui); }
.chart .speed-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .avg-line { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .avg-text { fill: var(--text-2); font: 700 11px var(--font-ui); paint-order: stroke; stroke: var(--panel-solid); stroke-width: 4px; stroke-linejoin: round; }
.chart .cross { stroke: var(--text); stroke-width: 1; }
.chart .cross-dot { fill: var(--accent); stroke: var(--panel-solid); stroke-width: 2; }
.chart-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none;
  padding: 7px 10px; border-radius: 10px;
  background: rgba(5, 7, 13, 0.94); border: 1px solid var(--line-hi);
  white-space: nowrap; transform: translateX(-50%);
}
.chart-tip b { display: block; font: 700 16px/1.1 var(--font-num); color: var(--text); }
.chart-card + .chart-card { margin-top: 12px; }
.chart-sum { font-size: 13px; font-weight: 600; color: var(--text-2); }
.chart-ele { height: 130px; }
.chart .ele-line { fill: none; stroke: var(--accent-ice); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ele-dot { fill: var(--accent-ice); stroke: var(--panel-solid); stroke-width: 2; }
.chart-empty { margin: 4px 2px 6px; font-size: 14px; color: var(--text-2); }
.chart-tip span { font-size: 12px; color: var(--text-2); }

.table-view { margin-top: 8px; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--text-2); padding: 6px 2px; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.table-view th, .table-view td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

.route-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.route-actions .btn { flex: 1 1 140px; }

/* Leaflet markers and tooltip skin */
.leaflet-container { background: #0b0f17; font-family: var(--font-ui); }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.74) contrast(1.15) saturate(0.28); }
.leaflet-control-attribution { background: rgba(5, 7, 13, 0.7) !important; color: var(--muted) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-control-zoom a { background: rgba(5, 7, 13, 0.85) !important; color: var(--accent) !important; border-color: var(--line) !important; }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #05070d; box-shadow: 0 0 0 2px currentColor, 0 0 12px currentColor; background: currentColor; }
.pin-start { color: var(--accent-ice); }
.pin-end { color: var(--hot); }
.pin-me { color: var(--accent); width: 20px; height: 20px; }
.pin-me::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; border: 2px solid var(--accent); animation: ping 1.8s ease-out infinite; }
@keyframes ping { from { transform: scale(0.4); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }
.pin-max {
  display: inline-block; transform: translate(-50%, -100%); margin-top: -10px;
  padding: 4px 8px; border-radius: 8px; white-space: nowrap;
  background: var(--hot); color: #12000d; font: 800 11px/1 var(--font-num); letter-spacing: 0.04em;
  box-shadow: 0 0 14px rgba(255, 43, 214, 0.7);
}
.pin-max::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--hot); }
.pin-scrub { color: var(--text); width: 16px; height: 16px; }

/* ---------- Settings ---------- */
.set-group { margin-bottom: 22px; }
.set-group h2 { margin: 0 4px 8px; font: 700 12px/1 var(--font-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 60px; padding: 10px 14px;
  border: 1px solid var(--line); background: var(--panel);
  margin-top: -1px;
}
.set-group h2 + .set-row { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.set-group > .set-row:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.set-group h2 + .set-row:last-child { border-radius: var(--radius-sm); }
.set-label { font-size: 16px; font-weight: 600; }
.set-label small { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 1px; }
.set-note { margin: 0 4px 12px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.set-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.set-actions .btn { flex: 1 1 150px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: rgba(5, 7, 13, 0.6); }
.seg button {
  border: 0; background: none; padding: 7px 14px; border-radius: 999px;
  font: 700 13px/1 var(--font-num); color: var(--text-2);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--bg); box-shadow: 0 0 12px rgba(34, 228, 255, 0.5); }

.select {
  appearance: none; -webkit-appearance: none;
  padding: 9px 34px 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(5, 7, 13, 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2322e4ff' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  font-weight: 700;
}
.select option { background: var(--panel-solid); }

.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 52px; height: 30px; border-radius: 999px; margin: 0;
  background: rgba(93, 111, 145, 0.35); border: 1px solid var(--line);
  position: relative; transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--text-2); transition: transform 0.2s, background 0.2s;
}
.switch:checked { background: rgba(34, 228, 255, 0.3); border-color: var(--line-hi); }
.switch:checked::after { transform: translateX(22px); background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-hi); background: rgba(5, 7, 13, 0.6); color: var(--accent);
  font: 700 20px/1 var(--font-ui);
}
.stepper output { min-width: 92px; text-align: center; font: 700 15px var(--font-num); }

.sync-code {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-hi); background: var(--panel); margin-bottom: 10px;
}
.sync-code .set-label { flex-basis: 100%; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); }
.sync-code code { flex: 1; font: 700 20px/1.2 var(--font-num); letter-spacing: 0.08em; color: var(--accent); text-shadow: 0 0 10px rgba(34, 228, 255, 0.5); word-break: break-all; }

.about { margin: 26px 4px 0; font-size: 13px; font-weight: 500; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line-hi); background: var(--panel); color: var(--text);
  font: 700 15px/1 var(--font-ui); letter-spacing: 0.06em; text-decoration: none; text-align: center;
  cursor: pointer; transition: transform 0.12s, background 0.2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #021018; box-shadow: 0 0 22px rgba(34, 228, 255, 0.35); }
.btn-danger { border-color: rgba(255, 51, 88, 0.45); color: #ff8aa0; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: space-around;
  background: linear-gradient(0deg, rgba(5, 7, 13, 0.96), rgba(5, 7, 13, 0.75));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  transition: transform 0.25s ease;
}
.tabbar a {
  position: relative; flex: 1; max-width: 160px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); text-decoration: none;
  font: 700 11px/1 var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] svg { filter: drop-shadow(0 0 6px rgba(34, 228, 255, 0.8)); }
.tabbar a[aria-current="page"]::before {
  content: ''; position: absolute; top: -1px; left: 28%; right: 28%; height: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent); border-radius: 2px;
}

/* ---------- Sheets, dialogs, toast ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(2, 4, 8, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 16px 16px calc(16px + var(--safe-b));
  animation: fade 0.2s ease;
}
.sheet {
  width: 100%; max-width: 440px;
  padding: 24px 20px 20px; border-radius: 22px;
  background: linear-gradient(180deg, #111c33, #0a1222);
  border: 1px solid var(--line-hi);
  box-shadow: 0 0 40px rgba(34, 228, 255, 0.18);
  animation: rise 0.25s ease;
}
.sheet h2 { margin: 0 0 8px; font: 700 20px/1.2 var(--font-num); letter-spacing: 0.06em; }
.sheet p { margin: 0 0 18px; color: var(--text-2); font-weight: 500; }
.sheet-art { width: 120px; height: 80px; margin: 0 auto 14px; stroke: var(--accent); fill: var(--accent); filter: drop-shadow(0 0 10px rgba(34, 228, 255, 0.7)); }
.sheet-art path:first-child { fill: none; }
.sheet-error { color: #ff8aa0 !important; margin: 12px 0 0 !important; font-size: 14px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; }
.sheet-actions .btn { flex: 1; }

.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.mode-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 74px; padding: 10px 4px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(5, 7, 13, 0.55); color: var(--text-2);
  font: 700 13px/1.1 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase;
}
.mode-opt svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-opt small { font: 600 11px/1 var(--font-ui); letter-spacing: 0.04em; text-transform: none; color: var(--muted); }
.mode-opt[aria-checked="true"] { color: var(--accent); border-color: var(--line-hi); background: rgba(34, 228, 255, 0.08); box-shadow: 0 0 16px rgba(34, 228, 255, 0.18); }
.mode-opt:active { transform: scale(0.97); }
.route-mode { display: inline-flex; flex: none; color: var(--accent); }
.route-mode svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.text-input {
  width: 100%; margin: 0 0 18px; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line-hi); background: rgba(5, 7, 13, 0.7);
  font: 600 17px var(--font-ui);
}
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 228, 255, 0.2); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; z-index: 1100;
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 11px 16px; border-radius: 12px;
  background: rgba(13, 21, 38, 0.96); border: 1px solid var(--line-hi);
  box-shadow: 0 0 24px rgba(34, 228, 255, 0.2);
  font-weight: 600; text-align: center;
  animation: rise 0.2s ease;
}

/* ---------- Landscape phones: dial left, data right ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --top-h: 44px; --tab-h: 52px; }
  .tabbar a { flex-direction: row; gap: 8px; }
  .drive-layout { flex-direction: row; align-items: center; justify-content: center; gap: 20px; padding: 8px 16px; }
  .gauge-wrap { width: min(46vw, calc(100vh - var(--top-h) - var(--tab-h) - 24px)); }
  .drive-side { max-width: 460px; }
  .drive-hint { display: none; }
  .controls { margin-top: 0; }
  .ctl-btn { width: 52px; height: 52px; }
  .ctl-main { width: 76px; height: 76px; }
  .ctl-main-ring { -webkit-mask: radial-gradient(circle, transparent 40px, #000 41px); mask: radial-gradient(circle, transparent 40px, #000 41px); }
  .live-map-card { height: 46vh; }
  .route-map-wrap { height: 70vh; }
  body.hud .gauge-wrap { width: min(70vw, 92vh); }
}

/* ---------- Larger screens ---------- */
@media (min-width: 900px) {
  .drive-layout { flex-direction: row; justify-content: center; align-items: center; gap: 48px; padding: 32px; }
  .gauge-wrap { width: min(44vw, 70vh, 520px); }
  .drive-side { max-width: 460px; }
  .live-map-card { height: 300px; }
  .route-map-wrap { height: 58vh; }
}

@media (prefers-reduced-motion: reduce) {
  .streaks, .backdrop-grid { animation: none !important; }
  .streaks { display: none; }
  .view { transition: none; }
  body.over-limit .gauge-wrap { animation: none; outline: 3px solid var(--warn); border-radius: 50%; }
}

@media (forced-colors: active) {
  .gauge-arc, .speed-line { stroke: Highlight; }
}
