/* ─────────────────────────────────────────
   APEX Connect · App Styles
   ───────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #08080f;
  --surface:     #0d0d1a;
  --card:        #111128;
  --card2:       #141430;
  --primary:     #00d4ff;
  --primary-dim: rgba(0, 212, 255, 0.12);
  --red:         #ff3366;
  --red-dim:     rgba(255, 51, 102, 0.12);
  --green:       #00ff88;
  --green-dim:   rgba(0, 255, 136, 0.12);
  --orange:      #ff8c00;
  --gold:        #ffd60a;
  --text:        #e2e8f0;
  --text-muted:  #6b7585;
  --border:      rgba(255,255,255,0.07);
  --radius:      18px;
  --radius-sm:   12px;
  --radius-xs:   8px;
  --bottom-nav:  68px;
  --status-h:    44px;
  --header-h:    62px;
  --font-display:'Orbitron', monospace;
  --font-body:   'Inter', sans-serif;
  --transition:  all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ━━━━━━━━━━━━━━━━━━ APP SHELL ━━━━━━━━━━━━━━━━━━ */
#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ━━━━━━━━━━━━━━━━━━ STATUS BAR ━━━━━━━━━━━━━━━━━━ */
#status-bar {
  height: var(--status-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
  background: rgba(8,8,15,0.95);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
#clock {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.sb-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
#connection-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 50px;
  padding: 0.2rem 0.65rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.03em;
}
.conn-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: dotPulse 2s infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#phone-battery { font-size: 0.7rem; color: var(--text-muted); }

/* ━━━━━━━━━━━━━━━━━━ SCREENS ━━━━━━━━━━━━━━━━━━ */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.screen.active { display: flex; }

.screen-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(8,8,15,0.9);
  backdrop-filter: blur(12px);
}
.screen-brand {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.screen-brand span { color: var(--red); }
.screen-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.1rem;
}
.helmet-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-dim);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 50px;
  padding: 0.3rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
}
.helmet-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPulse 2s infinite;
}
.live-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--red-dim);
  border: 1px solid rgba(255,51,102,0.25);
  border-radius: 50px;
  padding: 0.3rem 0.75rem;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: 0.1em;
  font-family: var(--font-display);
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: livePulse 1s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.alerts-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.1rem;
  scrollbar-width: none;
}
.scroll-area::-webkit-scrollbar { display: none; }

.section-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin: 1.25rem 0 0.65rem;
}
.section-label:first-child { margin-top: 0.25rem; }

/* ━━━━━━━━━━━━━━━━━━ BANNER CARD ━━━━━━━━━━━━━━━━━━ */
.banner-card {
  background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(255,51,102,0.04));
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}
.banner-left { flex: 1; }
.banner-divider { width: 1px; height: 50px; background: var(--border); }
.banner-right { flex: 1; text-align: right; }
.banner-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.banner-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--green);
}
.battery-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}
.battery-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--primary));
  border-radius: 2px;
  transition: width 1s ease;
}
.banner-speed {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}
.banner-unit { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ━━━━━━━━━━━━━━━━━━ CARDS GRID ━━━━━━━━━━━━━━━━━━ */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.data-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.data-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  opacity: 0.6;
}
.data-card--pulse::after { background: var(--red); }
.data-card--spo2::after  { background: var(--primary); }
.data-card--temp::after  { background: var(--orange); }
.data-card--drowsy::after{ background: var(--green); }

.card-icon { font-size: 1rem; }
.card-top { display: flex; align-items: baseline; gap: 0.2rem; margin: 0.1rem 0; }
.card-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 900; line-height: 1; }
.card-unit { font-size: 0.65rem; color: var(--text-muted); font-weight: 600; }
.card-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }

.data-card--pulse .card-value { color: var(--red); }
.data-card--spo2  .card-value { color: var(--primary); }
.data-card--temp  .card-value { color: var(--orange); }
.data-card--drowsy .card-value { color: var(--green); }

.card-status {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  display: inline-block;
  margin-top: 0.25rem;
  width: fit-content;
}
.status-ok    { background: var(--green-dim); color: var(--green); }
.status-warn  { background: rgba(255,140,0,0.12); color: var(--orange); }
.status-alert { background: var(--red-dim); color: var(--red); }

/* ECG canvas */
.pulse-ecg { height: 28px; margin: 0.25rem 0; overflow: hidden; }
#ecg-canvas { width: 100%; height: 28px; }

/* Ring SVG */
.ring-wrap, .attention-arc-wrap { margin: 0.15rem 0; }
.ring-svg { width: 46px; height: 46px; display: block; }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 5; }
.ring-fill {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1s ease;
}
.ring-blue  { stroke: var(--primary); }
.ring-green { stroke: var(--green); }

/* Thermo */
.thermo-wrap { display: flex; justify-content: center; margin: 0.15rem 0; }
.thermo-bar {
  width: 12px;
  height: 40px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.thermo-fill {
  width: 100%;
  background: linear-gradient(to top, var(--orange), var(--gold));
  border-radius: 6px;
  transition: height 1s ease;
}

/* ━━━━━━━━━━━━━━━━━━ TRAFFIC CARD ━━━━━━━━━━━━━━━━━━ */
.traffic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: var(--transition);
}
.traffic-icon { font-size: 1.4rem; }
.traffic-info { flex: 1; }
.traffic-status { font-weight: 700; font-size: 0.92rem; }
.traffic-desc { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.traffic-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}
.traffic-badge.libre     { background: var(--green-dim); color: var(--green); }
.traffic-badge.moderate  { background: rgba(255,200,0,0.1); color: var(--gold); }
.traffic-badge.heavy     { background: var(--red-dim); color: var(--red); }

.pilot-brief-card,
.route-summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.pilot-brief-card {
  background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(255,51,102,0.04));
  border-color: rgba(0,212,255,0.12);
}
.pilot-brief-kicker,
.route-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pilot-brief-title,
.route-value {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.25rem;
}
.pilot-brief-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.5;
}
.pilot-brief-tags,
.custom-chip-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}
.brief-tag,
.mini-chip {
  border: 1px solid rgba(0,212,255,0.15);
  background: rgba(0,212,255,0.07);
  color: var(--primary);
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
}

.route-summary-top,
.route-metrics,
.custom-row,
.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.route-summary-top { margin-bottom: 0.8rem; }
.route-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255,214,10,0.1);
  border: 1px solid rgba(255,214,10,0.18);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
}
.route-metrics {
  align-items: stretch;
}
.route-metric {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 0.7rem;
}
.route-metric-label {
  display: block;
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.route-metric strong {
  font-size: 0.78rem;
  color: var(--text);
}

/* ━━━━━━━━━━━━━━━━━━ CAMERA STRIP ━━━━━━━━━━━━━━━━━━ */
.cam-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.cam-thumb {
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  aspect-ratio: 4/3;
  cursor: pointer;
  transition: var(--transition);
}
.cam-thumb:active { transform: scale(0.96); }
.cam-live-dot {
  position: absolute;
  top: 5px; left: 5px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--red);
  z-index: 2;
  animation: livePulse 1s infinite;
}
.cam-label {
  position: absolute;
  bottom: 3px; left: 0; right: 0;
  text-align: center;
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.5);
  padding: 2px 0;
  z-index: 2;
}

/* ━━━━━━━━━━━━━━━━━━ VISOR HUD ━━━━━━━━━━━━━━━━━━ */
.visor-stage {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.visor-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.visor-kicker {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.visor-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin-top: 0.2rem;
}
.visor-mode-button {
  border: 1px solid rgba(0,212,255,0.18);
  background: rgba(0,212,255,0.08);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  font-size: 0.7rem;
  font-weight: 700;
}
.visor-shell {
  background: linear-gradient(180deg, #05050a 0%, #0d1020 100%);
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 20px;
  padding: 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.visor-world {
  position: relative;
  min-height: 430px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #11243a 0%, #1f4b79 24%, #667e45 48%, #2d3625 69%, #121212 100%);
}
.visor-full-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.visor-sky-glow {
  position: absolute;
  inset: 8% auto auto 20%;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,210,120,0.35), rgba(255,210,120,0) 70%);
}
.visor-road {
  position: absolute;
  left: 50%;
  bottom: -8%;
  transform: translateX(-50%);
  width: 70%;
  height: 68%;
  clip-path: polygon(40% 0, 60% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(40,40,45,0.6), #0d0d0f 55%, #040405 100%);
}
.visor-road::before,
.visor-road::after {
  content: '';
  position: absolute;
  top: 12%;
  bottom: 0;
  width: 4px;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.85) 0 16px, transparent 16px 32px);
  animation: roadFlow 1.2s linear infinite;
}
.visor-road::before { left: 44%; }
.visor-road::after { left: 54%; }
@keyframes roadFlow {
  from { transform: translateY(-16px); }
  to { transform: translateY(32px); }
}
.visor-lane {
  position: absolute;
  bottom: 10%;
  width: 18%;
  height: 1px;
  background: rgba(255,255,255,0.15);
}
.visor-lane--left { left: 23%; transform: rotate(12deg); }
.visor-lane--right { right: 26%; transform: rotate(-10deg); }
.visor-mountain {
  position: absolute;
  bottom: 38%;
  width: 42%;
  height: 24%;
  background: linear-gradient(180deg, rgba(20,26,28,0.1), rgba(10,15,12,0.8));
  clip-path: polygon(0 100%, 25% 50%, 50% 75%, 70% 35%, 100% 100%);
}
.visor-mountain--left { left: -4%; }
.visor-mountain--right { right: 22%; width: 34%; }
.visor-car {
  position: absolute;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, #e63946, #6d0e18);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
}
.visor-car--front {
  width: 30px;
  height: 20px;
  left: 48%;
  bottom: 32%;
}
.visor-car--right {
  width: 20px;
  height: 14px;
  right: 32%;
  bottom: 28%;
  background: linear-gradient(180deg, #00d4ff, #024967);
}
.visor-road-sign {
  position: absolute;
  top: 24%;
  left: 13%;
  background: rgba(12,18,25,0.8);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
}
.visor-top-overlay,
.visor-bottom-overlay {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem;
  z-index: 2;
}
.visor-top-overlay { top: 0; }
.visor-bottom-overlay { bottom: 0; align-items: flex-end; }
.visor-chip {
  background: rgba(5,7,14,0.62);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
}
.visor-chip--accent { color: var(--primary); }
.visor-warning {
  position: absolute;
  top: 19%;
  left: 6%;
  right: 32%;
  z-index: 2;
  background: rgba(255,214,10,0.12);
  border: 1px solid rgba(255,214,10,0.2);
  color: var(--gold);
  padding: 0.5rem 0.7rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.visor-speed-block,
.visor-nav-block,
.visor-side-panel,
.hud-data-card {
  background: rgba(4,7,12,0.64);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
}
.visor-speed-block {
  border-radius: 16px;
  padding: 0.75rem;
  min-width: 92px;
}
.visor-speed-block span,
.visor-nav-block span,
.hud-data-card span,
.hud-panel-kicker {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.visor-speed-block strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--primary);
  line-height: 1;
  margin-top: 0.3rem;
}
.visor-speed-block small,
.visor-nav-block small {
  color: var(--text-muted);
  font-size: 0.62rem;
}
.visor-nav-block {
  margin-left: auto;
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  min-width: 180px;
}
.visor-nav-block strong {
  display: block;
  font-size: 0.92rem;
  margin: 0.2rem 0;
}
.visor-side-panel {
  position: absolute;
  top: 16%;
  right: 3%;
  width: 29%;
  border-radius: 18px;
  padding: 0.7rem;
  z-index: 2;
}
.hud-panel-header strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.9rem;
}
.mini-map-card {
  position: relative;
  height: 130px;
  margin-top: 0.75rem;
  margin-bottom: 0.7rem;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(0,212,255,0.05), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.06);
}
.mini-map-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 1;
}
.mini-map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 18px 18px;
}
.route-line {
  position: absolute;
  border-radius: 999px;
}
.route-line--main {
  width: 75%;
  height: 5px;
  left: 10%;
  top: 55%;
  transform: rotate(-26deg);
  background: linear-gradient(90deg, var(--green), var(--primary));
}
.route-line--alt {
  width: 45%;
  height: 4px;
  left: 34%;
  top: 37%;
  transform: rotate(18deg);
  background: rgba(255,214,10,0.7);
}
.map-pin,
.map-user {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.52rem;
  font-weight: 800;
}
.map-pin {
  padding: 0.18rem 0.35rem;
  background: rgba(5,7,14,0.85);
  border: 1px solid rgba(255,255,255,0.08);
}
.map-pin--start { left: 11%; top: 68%; }
.map-pin--fuel { right: 16%; top: 18%; color: var(--gold); }
.map-pin--finish { right: 10%; bottom: 18%; color: var(--primary); }
.map-user {
  width: 12px;
  height: 12px;
  left: 42%;
  top: 49%;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255,51,102,0.15);
}
.hud-data-stack {
  display: grid;
  gap: 0.45rem;
}
.hud-data-card {
  border-radius: 12px;
  padding: 0.5rem 0.55rem;
}
.hud-data-card strong {
  display: block;
  font-size: 0.76rem;
  margin-top: 0.2rem;
  line-height: 1.35;
}
.visor-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
.visor-info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
}
.visor-info-card span {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.visor-info-card strong {
  display: block;
  font-size: 0.84rem;
  margin: 0.25rem 0;
}
.visor-info-card small {
  color: var(--text-muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

/* ━━━━━━━━━━━━━━━━━━ CAMERA SCENES ━━━━━━━━━━━━━━━━━━ */
.cam-scene {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
/* Front camera: road perspective */
.cam-scene--front {
  background: linear-gradient(180deg, #0a1a2a 0%, #0d2545 30%, #1a3a1a 60%, #2a4a1a 80%, #3a5a1a 100%);
}
.cam-scene--front::before {
  content: '';
  position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 35% solid transparent;
  border-right: 35% solid transparent;
  border-bottom: 65% solid rgba(255,220,100,0.07);
}
.cam-scene--front::after {
  content: '';
  position: absolute;
  bottom: 20%; left: 49%; right: 49%;
  height: 40%;
  background: rgba(255,255,255,0.5);
  box-shadow: -8px 0 0 rgba(255,255,255,0.5);
  animation: roadLines 1.5s linear infinite;
}
@keyframes roadLines {
  from { bottom: 20%; }
  to   { bottom: 60%; opacity: 0; }
}

/* Rear camera */
.cam-scene--rear {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 40%, #4a3a2a 70%, #5a4a3a 100%);
}
.cam-scene--rear::before {
  content: '';
  position: absolute;
  top: 30%; left: 20%; right: 20%; bottom: 30%;
  border: 1px solid rgba(255,51,102,0.3);
  border-radius: 2px;
  box-shadow: inset 0 0 10px rgba(255,51,102,0.1);
}

/* Left camera */
.cam-scene--left {
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 40%, #2a2a1a 70%, #3a3a2a 100%);
}
/* Right camera */
.cam-scene--right {
  background: linear-gradient(225deg, #0a0a1a 0%, #1a1a3a 40%, #2a1a2a 70%, #3a2a3a 100%);
}

/* Noise overlay for all cam scenes */
.cam-scene--lg {
  width: 100%;
  height: 100%;
}

/* ━━━━━━━━━━━━━━━━━━ CAMERA GRID (full) ━━━━━━━━━━━━━━━━━━ */
.cam-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.cam-full {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  aspect-ratio: 16/10;
}
.cam-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.3) 100%);
}
.cam-overlay-badge {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--red);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
}
.cam-overlay-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  font-family: var(--font-display);
  letter-spacing: 0.1em;
}
.cam-hud-lines {
  position: absolute;
  inset: 20% 20%;
  border: 1px solid rgba(0,212,255,0.25);
  border-radius: 2px;
}
.cam-hud-lines::before, .cam-hud-lines::after {
  content: '';
  position: absolute;
  background: rgba(0,212,255,0.5);
}
.cam-hud-lines::before { width: 8px; height: 1px; top: 50%; left: -4px; }
.cam-hud-lines::after  { width: 1px; height: 8px; top: -4px; left: 50%; }

.cam-info-strip {
  display: flex;
  justify-content: space-around;
  padding: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 0.65rem;
}
.cam-info-item { font-size: 0.7rem; color: var(--text-muted); }
.cam-info-item strong { color: var(--primary); }

/* ━━━━━━━━━━━━━━━━━━ TRIP CARD ━━━━━━━━━━━━━━━━━━ */
.trip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.trip-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}
.trip-row:last-child { border-bottom: none; }
.trip-cell {
  padding: 0.75rem 0.85rem;
  border-right: 1px solid var(--border);
}
.trip-cell:last-child { border-right: none; }
.trip-cell-label { font-size: 0.62rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.trip-cell-value { font-size: 0.88rem; font-weight: 700; }
.speed-highlight { color: var(--primary); font-family: var(--font-display); }
.green-highlight { color: var(--green); font-family: var(--font-display); }
.blue-highlight  { color: var(--primary); font-family: var(--font-display); }

/* ━━━━━━━━━━━━━━━━━━ ALERTS ━━━━━━━━━━━━━━━━━━ */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.empty-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.empty-sub { font-size: 0.75rem; margin-top: 0.25rem; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 0.5rem;
}
.alert-item.alert-warning { border-color: rgba(255,140,0,0.25); background: rgba(255,140,0,0.05); }
.alert-item.alert-danger  { border-color: rgba(255,51,102,0.25); background: rgba(255,51,102,0.05); }
.alert-item.alert-success { border-color: rgba(0,255,136,0.2); background: rgba(0,255,136,0.04); }
.alert-item.alert-info    { border-color: rgba(0,212,255,0.15); background: rgba(0,212,255,0.03); }
.alert-item-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 0.05rem; }
.alert-item-body { flex: 1; }
.alert-item-title { font-size: 0.85rem; font-weight: 600; }
.alert-item-desc { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }
.alert-item-time { font-size: 0.65rem; color: var(--text-muted); flex-shrink: 0; font-family: var(--font-display); }

/* ━━━━━━━━━━━━━━━━━━ PROFILE ━━━━━━━━━━━━━━━━━━ */
.profile-card {
  background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(255,51,102,0.04));
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), #ff6600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  border: 2px solid rgba(255,255,255,0.1);
}
.profile-name { font-size: 1.05rem; font-weight: 700; }
.profile-role {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}
.profile-since { font-size: 0.7rem; color: var(--text-muted); }

.helmet-info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.hi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.hi-row:last-child { border-bottom: none; }
.hi-label { font-size: 0.75rem; color: var(--text-muted); }
.hi-value { font-size: 0.82rem; font-weight: 600; }
.hi-mono  { font-family: var(--font-display); font-size: 0.68rem; color: var(--primary); }
.up-to-date {
  font-size: 0.65rem;
  background: var(--green-dim);
  color: var(--green);
  padding: 0.1rem 0.45rem;
  border-radius: 50px;
  margin-left: 0.35rem;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.stat-mini-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.stat-mini-val { font-family: var(--font-display); font-size: 1.1rem; font-weight: 900; color: var(--primary); }
.stat-mini-label { font-size: 0.58rem; color: var(--text-muted); margin-top: 0.25rem; line-height: 1.3; }

.preferences-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}
.pref-card {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  color: var(--text);
}
.pref-card.active {
  border-color: rgba(0,212,255,0.3);
  background: linear-gradient(135deg, rgba(0,212,255,0.08), rgba(255,51,102,0.03));
}
.pref-kicker {
  display: block;
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pref-card strong {
  display: block;
  margin: 0.2rem 0 0.15rem;
  font-size: 0.92rem;
}
.pref-card small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.customization-card,
.favorites-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}
.custom-row {
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.custom-row:last-of-type { border-bottom: none; }
.custom-row span,
.favorite-item small {
  color: var(--text-muted);
  font-size: 0.7rem;
}
.custom-row strong,
.favorite-item strong {
  font-size: 0.8rem;
}
.mini-chip {
  cursor: pointer;
  font-family: var(--font-body);
}
.mini-chip.active {
  background: rgba(0,212,255,0.18);
  border-color: rgba(0,212,255,0.28);
}
.favorites-card {
  display: grid;
  gap: 0.65rem;
}
.favorite-item {
  align-items: center;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.favorite-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.favorite-item span {
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--primary);
}

.settings-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.setting-item:last-child { border-bottom: none; }
.setting-left { display: flex; align-items: center; gap: 0.75rem; }
.setting-icon { font-size: 1.1rem; }
.setting-name { font-size: 0.82rem; font-weight: 600; }
.setting-desc { font-size: 0.67rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Toggle switch */
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 11px;
  transition: 0.3s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

.btn-logout {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.9rem;
  background: transparent;
  border: 1px solid rgba(255,51,102,0.25);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: var(--transition);
}
.btn-logout:active { background: var(--red-dim); }

/* ━━━━━━━━━━━━━━━━━━ BOTTOM NAV ━━━━━━━━━━━━━━━━━━ */
#bottom-nav {
  height: var(--bottom-nav);
  display: flex;
  align-items: center;
  background: rgba(8,8,15,0.97);
  border-top: 1px solid var(--border);
  padding: 0 0.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  backdrop-filter: blur(20px);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0.4rem 0;
  position: relative;
  transition: var(--transition);
}
.bn-item.active { color: var(--primary); }
.bn-icon { font-size: 1.2rem; }
.bn-label { font-size: 0.58rem; font-weight: 600; letter-spacing: 0.03em; }
.bn-badge {
  position: absolute;
  top: 0.2rem; right: calc(50% - 16px);
  background: var(--red);
  color: #fff;
  width: 14px; height: 14px;
  border-radius: 50%;
  font-size: 0.55rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ━━━━━━━━━━━━━━━━━━ APP TOAST ━━━━━━━━━━━━━━━━━━ */
.app-toast {
  position: fixed;
  top: calc(var(--status-h) + var(--header-h) + 0.6rem);
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(17,17,40,0.95);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.6rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  z-index: 3000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  max-width: 85%;
  text-align: center;
}
.app-toast.show { transform: translateX(-50%) translateY(0); }

/* ━━━━━━━━━━━━━━━━━━ DROWSINESS ALERT ━━━━━━━━━━━━━━━━━━ */
.drowsy-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,51,102,0.15);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: alertFlash 0.5s ease;
}
@keyframes alertFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.drowsy-alert-box {
  background: var(--surface);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  max-width: 280px;
  box-shadow: 0 0 40px rgba(255,51,102,0.3);
}
.drowsy-alert-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.drowsy-alert-title { font-size: 1.1rem; font-weight: 800; color: var(--red); margin-bottom: 0.5rem; }
.drowsy-alert-msg { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.drowsy-alert-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.7rem 1.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  width: 100%;
}

/* Scan lines overlay on cam scenes */
.cam-scene::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 420px) {
  .route-metrics,
  .visor-info-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
  .route-summary-top,
  .visor-headline,
  .custom-row,
  .favorite-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .visor-world {
    min-height: 520px;
  }
  .visor-warning {
    right: 6%;
  }
  .visor-side-panel {
    position: relative;
    top: auto;
    right: auto;
    width: auto;
    margin: 11.5rem 0.75rem 0.75rem auto;
    max-width: 42%;
  }
  .visor-bottom-overlay {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }
  .visor-nav-block {
    margin-left: 0;
    min-width: 0;
  }
}
