:root {
  --bg-primary: #000000; /* pure black = transparent on the additive display */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #707080;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  /* Native Meta Maps palette */
  --route: #2b8cff;   /* blue route line */
  --me: #19e0d2;      /* teal/cyan "me" disc */
  --star: #ffd23d;    /* gold destination/POI star */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 24px; font-weight: 600; flex: 1; }
.header-meta { font-size: 14px; color: var(--text-secondary); }
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}
.status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(255, 170, 0, 0.18);
  color: var(--warning);
}
.status-pill.ok { background: rgba(0, 255, 136, 0.18); color: var(--success); }
.status-pill.bad { background: rgba(255, 68, 102, 0.18); color: var(--danger); }

/* --- Content --- */
.content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.content.centered { align-items: center; justify-content: center; text-align: center; gap: 20px; }

/* --- Focus (critical for D-pad) --- */
.focusable {
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* --- Nav bar --- */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary { background: rgba(0, 212, 255, 0.18); color: var(--accent-primary); }
.nav-item.danger { background: rgba(255, 68, 102, 0.22); color: var(--danger); }
.nav-item.danger.armed { background: var(--danger); color: #fff; animation: pulse 0.9s ease-in-out infinite; }
.nav-item.is-fav { color: var(--accent-secondary); }
/* Loupe (zoom) button engaged + its on-map hint. */
.nav-item.active { background: var(--accent-primary); color: #001b22; font-weight: 700; }
/* POI ("Lieux") is a pedestrian-only feature — hide the button in car mode. */
#nav.car #nav-poi { display: none; }
/* POI overlay: upright labels floating above the (rotating) map. Positioned by JS. */
.mm-poi-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.poi { position: absolute; top: 0; left: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; will-change: transform; }
.poi-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #0a0c10; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,.6); }
.poi-name { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000, 0 0 3px #000; }
.loupe-hint {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: rgba(8, 10, 14, .86); border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px; padding: 10px 18px; text-align: center;
  font-size: 18px; font-weight: 700; color: #fff; z-index: 60; pointer-events: none;
}
.loupe-hint b { color: var(--accent-primary); margin: 0 2px; }
.loupe-hint span { display: block; margin-top: 4px; font-size: 13px; font-weight: 600; color: #9aa3ad; }

/* ==================== TRANSPORT MODE (preview) ==================== */
.mode-row { display: flex; gap: 10px; justify-content: center; }
.mode-btn { padding: 10px 18px; border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-secondary); font-size: 16px; font-weight: 700; border: 2px solid transparent; }
.mode-btn.active { background: rgba(0, 212, 255, 0.18); color: var(--accent-primary); }

/* ==================== SEARCH (home) ==================== */
.big-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 22px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-align: left;
}
.big-btn.primary { background: rgba(0, 212, 255, 0.16); }
.big-btn-icon { font-size: 34px; line-height: 1; }
.big-btn-text { font-size: 20px; font-weight: 600; }

.list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 4px;
}
.dest-list { display: flex; flex-direction: column; gap: 8px; }
.dest-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}
.dest-item .di-name { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.dest-item .di-sub { font-size: 13px; color: var(--text-secondary); }
.empty-hint { font-size: 14px; color: var(--text-muted); padding: 6px 2px; }
.gps-banner { display: flex; flex-direction: column; gap: 6px; }
.gps-banner .big-btn { background: rgba(255, 170, 0, 0.16); }
.gps-banner #gps-hint { color: var(--text-secondary); }

/* ==================== KEYBOARD (on-glasses entry) ==================== */
.kb-text-wrap {
  padding: 12px 20px;
  margin: 0 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  min-height: 50px;
  display: flex;
  align-items: center;
  word-break: break-word;
}
#kb-text { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
#kb-text.kb-placeholder { color: var(--text-muted); font-weight: 500; }
.kb-grid { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 2px; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.kb-key {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  height: 50px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kb-key:focus { background: var(--bg-card); }
.kb-key.kb-act { font-size: 16px; font-weight: 600; }
.kb-key.primary { background: rgba(0, 212, 255, 0.18); color: var(--accent-primary); }
.kb-hint { text-align: center; font-size: 13px; color: var(--text-secondary); padding: 6px; }

/* ==================== LISTENING ==================== */
.pulse-mic {
  font-size: 96px;
  animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}
.big-status { font-size: 34px; font-weight: 700; color: var(--accent-primary); }
.sub-status { font-size: 17px; color: var(--text-secondary); max-width: 460px; line-height: 1.4; }
.sub-status.err { color: var(--danger); min-height: 20px; }

/* ==================== ACCESS LOCK (pairing code) ==================== */
.pin { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.digit { width: 56px; height: 76px; background: var(--bg-card); border-radius: var(--radius-md); font-size: 42px; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; color: var(--text-primary); }
.pin-ok { height: 76px; padding: 0 22px; border-radius: var(--radius-md); font-size: 34px; font-weight: 800; background: rgba(0, 212, 255, 0.18); color: var(--accent-primary); border: none; display: flex; align-items: center; justify-content: center; }

/* ==================== PREVIEW ==================== */
.dest-name { font-size: 26px; font-weight: 700; color: var(--text-primary); max-width: 520px; line-height: 1.3; }
.route-summary {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--bg-card);
  padding: 22px 34px;
  border-radius: var(--radius-lg);
}
.rs-block { text-align: center; }
.rs-value { font-size: 54px; font-weight: 800; color: var(--accent-primary); font-variant-numeric: tabular-nums; line-height: 1; }
.rs-label { font-size: 15px; color: var(--text-secondary); margin-top: 6px; }
.rs-sep { width: 2px; height: 64px; background: var(--bg-tertiary); }

/* ==================== NAV (live) ==================== */
#nav { padding: 0; }
.nav-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px 12px;
  flex-shrink: 0;
}
.maneuver-icon {
  font-size: 70px;
  line-height: 1;
  color: var(--accent-secondary);
  width: 84px;
  text-align: center;
  flex-shrink: 0;
}
/* Thick filled maneuver arrow (matches the left "go" arrow's weight). */
.maneuver-icon .man-arrow { display: inline-block; width: 66px; height: 66px; }
.maneuver-icon .man-arrow polygon, .maneuver-icon .man-arrow path { fill: var(--accent-secondary); }
.maneuver-text { flex: 1; min-width: 0; }
.man-dist { font-size: 46px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1; }
.man-instr { font-size: 22px; font-weight: 600; color: var(--accent-primary); margin-top: 8px; line-height: 1.25; }

/* Split: left = current-street panel (fixed up-arrow + name), right = a STATIC
   north-up mini-map (no rotation, no sensors) with the route in blue and a red
   "me" dot at the centre. Same layout for car & foot. */
.nav-mid {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 12px;
  min-height: 0;
  padding: 8px 12px;
}
/* Left column = a COMPACT street card, plus (car only) the speed filling the rest. */
.nav-street { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 4px; }
.ns-card { flex: 0 0 auto; background: var(--bg-card); border: 1px solid rgba(255,255,255,.08); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: row; align-items: center; gap: 14px; }
/* Simple green "go ahead" arrow, in its own column left of the current street. */
.ns-arrow { width: 32px; height: 64px; flex-shrink: 0; }
.ns-arrow polygon { fill: var(--accent-secondary); }
.ns-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.ns-label { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted); }
.street-name { font-size: 25px; font-weight: 800; color: var(--text-primary); line-height: 1.2; overflow-wrap: anywhere; }
.ns-next { font-size: 15px; font-weight: 600; color: var(--accent-primary); line-height: 1.25; overflow-wrap: anywhere; }
.ns-next:empty { display: none; }
/* Speed: a car-style circular speedometer (gauge + centred value) — car mode only. */
.ns-speed { display: none; flex: 1; align-items: center; justify-content: center; min-height: 0; }
.speedo { width: 100%; height: 100%; max-width: 100%; max-height: 100%; display: block; }
.speedo-track { fill: none; stroke: rgba(255, 255, 255, .16); stroke-width: 13; stroke-linecap: round; }
.speedo-arc { fill: none; stroke: var(--accent-primary); stroke-width: 13; stroke-linecap: round; }
.speedo-val { fill: var(--text-primary); font-size: 64px; font-weight: 800; text-anchor: middle; font-variant-numeric: tabular-nums; }
.speedo-unit { fill: var(--text-secondary); font-size: 22px; font-weight: 700; text-anchor: middle; }
/* Car view: big speedometer on the LEFT, map on the right; no current-street card. */
#nav.car .ns-card { display: none; }
#nav.car .nav-street { padding: 0; justify-content: center; }   /* flex:1 → fills the left */
#nav.car .ns-speed { display: flex; height: 100%; }
#nav.car .mini-map { flex: 0 0 240px; align-items: stretch; justify-content: stretch; }
#nav.car .mm-clip { width: 100%; height: 100%; perspective: 540px; perspective-origin: 50% 50%; }

/* FOOT view: a single full-bleed, heading-up map (no street card). Its edges fade
   to nothing (mask) so it melts into the dark screen and looks like it overflows. */
#nav:not(.car) .nav-mid { padding: 0; gap: 0; }
#nav:not(.car) .nav-street { display: none; }
#nav:not(.car) .mini-map { flex: 1; align-items: stretch; justify-content: stretch; }
#nav:not(.car) .mm-clip {
  width: 100%; height: 100%;
  border: none; border-radius: 0;
  perspective: 560px; perspective-origin: 50% 50%;
  -webkit-mask-image: radial-gradient(ellipse 132% 116% at 50% 46%, #000 50%, rgba(0,0,0,.45) 75%, transparent 100%);
          mask-image: radial-gradient(ellipse 132% 116% at 50% 46%, #000 50%, rgba(0,0,0,.45) 75%, transparent 100%);
}

/* Foot keeps the previous centred square map; car overrides to a full-height one. */
.mini-map { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.mm-clip { position: relative; width: 300px; height: 300px; border-radius: 14px; overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.25); background: #000; }
/* Ground-plane layer (tiles + route). JS sets rotateX(tilt) rotate(-heading) so the
   map turns under a fixed up-arrow. A rAF loop interpolates the rotation in JS for
   real-time smoothness (no CSS transition, which would add lag/mush). */
.mm-world { position: absolute; inset: 0; transform-origin: 50% 50%; }
.mm-tiles { position: absolute; inset: 0; }
/* Boost the basemap so the faint grey streets read on the additive display
   (brightness lifts the dark-grey roads toward white). */
.mm-tile { position: absolute; width: 256px; height: 256px; opacity: 0.95; filter: brightness(1.9) saturate(1.1); }
.mm-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#mm-route { stroke: var(--route); stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 3px rgba(43,140,255,.7)); }
.mm-dest { fill: var(--star); stroke: #000; stroke-width: 1.5; filter: drop-shadow(0 0 3px rgba(255,210,61,.8)); }
/* Direction cone (like native Maps): a translucent white beam pointing UP from the
   marker (the map is heading-up, so "forward" is always up). Sits under the arrow
   and fades out at its tip. Foot only — car has no cone. */
.mm-cone { position: absolute; left: 50%; top: 50%; width: 150px; height: 168px; transform: translate(-50%, -50%); transform-origin: center center; pointer-events: none; z-index: 1; }
.mm-cone.hidden { display: none; }
/* "me" = a navigation arrow (chevron) fixed at the centre pointing up; the map
   rotates under it. Default (car): white chevron with a blue rim, no disc. */
.mm-me { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); transform-origin: center center; pointer-events: none; z-index: 2; }
.mm-me polygon { fill: #fff; stroke: #0a84ff; stroke-width: 1.6; stroke-linejoin: round; }
/* Disc backing for the arrow — shown in FOOT view only. */
.mm-disc { display: none; }
/* Native "me": a glowing teal disc with a white rim + a subtle white forward chevron. */
#nav:not(.car) .mm-me { width: 44px; height: 44px; filter: drop-shadow(0 0 7px rgba(25, 224, 210, .85)) drop-shadow(0 1px 3px rgba(0,0,0,.5)); }
#nav:not(.car) .mm-disc { display: inline; fill: var(--me); stroke: #fff; stroke-width: 1.4; }
#nav:not(.car) .mm-fwd { fill: #ffffff; stroke: none; transform: scale(.6); transform-origin: 12px 12px; }
/* Wrong-way: the chevron becomes a red "demi-tour" (U-turn) symbol — no forward
   arrow over a backward-sliding map. */
.mm-uturn { display: none; fill: none; stroke: var(--danger); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mm-me.wrong { width: 38px; height: 38px; }
.mm-me.wrong .mm-fwd { display: none; }
.mm-me.wrong .mm-uturn { display: inline; }

.nav-foot {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  flex-shrink: 0;
}
.nf-block {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
}
.nf-value { font-size: 28px; font-weight: 700; color: var(--accent-primary); font-variant-numeric: tabular-nums; line-height: 1; }
.nf-label { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }
.nf-block.rerouting .nf-value { color: var(--warning); }
/* Traffic colour for the car duration (preview .rs-value + nav .nf-value):
   fluid green / slow orange / jammed red. */
.t-fluid { color: var(--accent-secondary); }
.t-mod { color: var(--warning); }
.t-heavy { color: var(--danger); }

/* Both views now show two tiles — remaining distance + ETA. The old 3rd tile is
   gone (speed moved under the street name in car mode; GPS accuracy no longer shown). */

/* Start button while the route is still computing */
.nav-item.loading { opacity: 0.5; }

/* Wrong-way warning banner (shown when you move backward along the route). */
.wrong-way { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--danger); color: #fff; font-size: 18px; font-weight: 800; padding: 11px 22px; border-radius: 22px; box-shadow: 0 4px 20px rgba(0,0,0,.55); white-space: nowrap; animation: wwpulse 1s ease-in-out infinite; }
.wrong-way.hidden { display: none; }
@keyframes wwpulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

/* ==================== ARRIVED ==================== */
.arrived-icon { font-size: 110px; line-height: 1; }

/* ==================== PHONE WAIT ==================== */
.phone-url {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-secondary);
  background: var(--bg-card);
  padding: 14px 22px;
  border-radius: var(--radius-md);
  word-break: break-all;
  max-width: 540px;
}
.pulse-dot-row { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--text-secondary); }
.pulse-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 1.2s ease-in-out infinite;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
