: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;
}

* { 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); }

/* ==================== 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; }

/* ==================== 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; }

/* ==================== 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;
}
.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; }

.nav-arrow-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}
.nav-arrow {
  width: 220px;
  height: 220px;
  transition: transform 0.25s ease-out;
}
.nav-arrow polygon {
  fill: var(--accent-secondary);
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2;
  stroke-linejoin: round;
}
.nav-arrow.stale polygon { fill: var(--text-muted); stroke: rgba(255,255,255,0.4); }
.arrow-hint { font-size: 15px; color: var(--text-secondary); }

.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); }

/* ==================== 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); }
