:root {
  --bg-deep: #05080f;
  --bg-panel: #0b1220;
  --bg-card: #101a2e;
  --bg-elevated: #16233d;
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #00e5ff;
  --accent-secondary: #3b82f6;
  --accent-glow: rgba(0, 229, 255, 0.26);

  --safe: #10b981;
  --warn: #f59e0b;
  --danger: #ff3355;
  --danger-glow: rgba(255, 51, 85, 0.35);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', ui-monospace, monospace;
}

/* Themes */
[data-theme="sport"] {
  --accent: #ff4757;
  --accent-secondary: #ff7f50;
  --accent-glow: rgba(255, 71, 87, 0.3);
}

[data-theme="eco"] {
  --accent: #10b981;
  --accent-secondary: #22d3ee;
  --accent-glow: rgba(16, 185, 129, 0.28);
}

[data-theme="amber"] {
  --bg-deep: #060503;
  --bg-panel: #100c07;
  --bg-card: #18120a;
  --bg-elevated: #231a0e;
  --accent: #ff9f1c;
  --accent-secondary: #ffbf69;
  --accent-glow: rgba(255, 159, 28, 0.26);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 0%, #0d182b 0%, var(--bg-deep) 68%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-hud-mode {
  overflow: hidden;
}

body.is-hud-mode .app-shell {
  display: none;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

/* Night Brightness Dimmer */
.dimmer-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 900;
  transition: opacity 0.2s ease;
}

/* Global Overspeed Edge Glow */
.overspeed-screen-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 800;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.overspeed-screen-glow.is-warn {
  opacity: 1;
  box-shadow: inset 0 0 42px rgba(245, 158, 11, 0.32);
}

.overspeed-screen-glow.is-danger {
  opacity: 1;
  box-shadow: inset 0 0 70px rgba(255, 51, 85, 0.65);
  animation: dangerPulse 0.85s ease-in-out infinite;
}

@keyframes dangerPulse {
  0%, 100% {
    box-shadow: inset 0 0 45px rgba(255, 51, 85, 0.45);
  }
  50% {
    box-shadow: inset 0 0 95px rgba(255, 51, 85, 0.9);
  }
}

/* Toast Stack */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  background: rgba(16, 26, 46, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.875rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.22s ease-out;
}

.toast.is-warn {
  border-left-color: var(--warn);
}

.toast.is-danger {
  border-left-color: var(--danger);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shell Layout */
.app-shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 16px;
  gap: 10px;
  max-width: 1560px;
  margin: 0 auto;
  overflow-x: hidden;
}

/* Top Cockpit Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-logo {
  border-radius: 8px;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.14em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.status-pill:hover {
  border-color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

.status-pill.is-live .status-dot {
  background: var(--safe);
  box-shadow: 0 0 10px var(--safe);
}

.status-pill.is-sim .status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.status-pill.is-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

.context-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 300px;
}

.road-badge {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-weight: 500;
}

.pill-sep {
  opacity: 0.4;
}

/* Mode Switcher */
.mode-switcher {
  display: inline-flex;
  background: var(--bg-deep);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mode-btn:hover {
  color: var(--text-primary);
}

.mode-btn.is-active {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
  color: #04101a;
  box-shadow: 0 0 18px var(--accent-glow);
}

.topbar-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

.icon-btn.is-listening {
  border-color: var(--danger);
  color: var(--danger);
  animation: dangerPulse 1s infinite;
}

/* Safety Banner */
.safety-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.09), rgba(59, 130, 246, 0.06));
  border: 1px solid rgba(0, 229, 255, 0.24);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.safety-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 240px;
  min-width: 0;
}

.safety-badge {
  background: var(--accent);
  color: #03111c;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

.safety-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cockpit Grid */
.cockpit-main {
  display: grid;
  grid-template-columns: 325px minmax(360px, 1fr) 390px;
  gap: 12px;
  flex: 1;
  align-items: stretch;
}

.cockpit-main.mode-gauge {
  grid-template-columns: 1fr;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

.cockpit-main.mode-gauge .cluster-left,
.cockpit-main.mode-gauge .cluster-right {
  display: none;
}

.cockpit-main.mode-gauge .speedometer-wrap {
  max-width: 500px;
}

.cluster-left,
.cluster-center,
.cluster-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Panels */
.panel {
  background: linear-gradient(180deg, rgba(16, 26, 46, 0.92), rgba(10, 17, 30, 0.96));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

/* Buttons */
.btn-mini {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn-mini:hover {
  border-color: var(--accent);
}

.btn-mini.btn-accent {
  background: rgba(0, 229, 255, 0.14);
  border-color: rgba(0, 229, 255, 0.4);
  color: var(--accent);
}

.btn-mini.btn-accent:hover {
  background: var(--accent);
  color: #03111c;
}

.btn-mini.btn-danger {
  background: rgba(255, 51, 85, 0.16);
  border-color: rgba(255, 51, 85, 0.45);
  color: #ff6b81;
}

.btn-mini.btn-ghost {
  background: transparent;
}

/* Limit Sign & Presets */
.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-chip .chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.toggle-chip.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.toggle-chip.is-active .chip-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.limit-hero-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.road-sign {
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ffffff;
  border: 8px solid #e11d48;
  color: #0f172a;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.85rem;
  font-weight: 900;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease, box-shadow 0.2s ease;
}

.road-sign.is-overspeed {
  transform: scale(1.06);
  box-shadow: 0 0 28px rgba(255, 51, 85, 0.75);
}

.limit-status-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.speed-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.speed-status-badge.is-safe {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.speed-status-badge.is-warn {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.speed-status-badge.is-danger {
  background: rgba(255, 51, 85, 0.24);
  color: #ff7a90;
  border: 1px solid rgba(255, 51, 85, 0.6);
}

.limit-subtext {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.limit-stepper {
  display: flex;
  gap: 6px;
}

.step-btn {
  height: 32px;
  min-width: 40px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}

.step-btn:hover {
  border-color: var(--accent);
}

.step-btn.step-wide {
  flex: 1;
  font-weight: 600;
  font-size: 0.73rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.preset-btn {
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-btn.is-active {
  background: var(--accent);
  color: #03111c;
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

.osm-status-note {
  margin-top: 9px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 9px;
  line-height: 1.35;
}

.osm-status-note.is-ok {
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.osm-status-note.is-warn {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.osm-status-note.is-error {
  border-color: rgba(255, 51, 85, 0.4);
  color: #fda4af;
}

/* Proximity Card */
.proximity-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
}

.proximity-body.is-alert {
  border-color: var(--warn);
  background: rgba(245, 158, 11, 0.1);
}

.proximity-body.is-critical {
  border-color: var(--danger);
  background: rgba(255, 51, 85, 0.14);
}

.proximity-icon {
  font-size: 1.5rem;
}

.proximity-title {
  font-size: 0.86rem;
  font-weight: 700;
}

.proximity-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.proximity-bar-track {
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}

.proximity-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--warn), var(--danger));
  transition: width 0.25s ease;
}

/* G-Force Panel */
.gforce-layout {
  display: flex;
  align-items: center;
  gap: 14px;
}

#gforce-canvas {
  border-radius: 50%;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.gforce-metrics {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
}

.metric-k {
  color: var(--text-secondary);
}

.metric-v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.accent {
  color: var(--accent) !important;
}

.danger {
  color: #ff6b81 !important;
}

.badge-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.25);
  padding: 3px 8px;
  border-radius: 6px;
}

/* Center Stage & Speedometer */
.hero-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.hero-top-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.meta-chip {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.meta-label {
  font-size: 0.64rem;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  font-weight: 700;
}

.meta-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
  font-weight: 700;
}

.speedometer-wrap {
  position: relative;
  width: 100%;
  max-width: 410px;
  aspect-ratio: 420 / 380;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.speed-svg-gauge {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-track-arc {
  stroke: rgba(148, 163, 184, 0.12);
  stroke-width: 18;
}

.gauge-limit-zone-arc {
  stroke: rgba(255, 51, 85, 0.25);
  stroke-width: 18;
}

.gauge-active-arc {
  stroke: url(#gauge-grad-safe);
  stroke-width: 18;
  transition: stroke 0.2s ease;
}

.speedometer-wrap.is-warn .gauge-active-arc {
  stroke: url(#gauge-grad-warn);
}

.speedometer-wrap.is-danger .gauge-active-arc {
  stroke: url(#gauge-grad-danger);
}

.gauge-tick {
  stroke: rgba(148, 163, 184, 0.35);
  stroke-width: 1.5;
}

.gauge-tick.is-major {
  stroke: rgba(226, 232, 240, 0.72);
  stroke-width: 2.4;
}

.gauge-tick-label {
  fill: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.limit-marker-dot {
  fill: #ff3355;
  stroke: #ffffff;
  stroke-width: 2.5;
}

.peak-marker-arrow {
  fill: var(--accent);
}

.gauge-needle-line {
  stroke: #ff4757;
  stroke-width: 4.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 71, 87, 0.6));
}

.gauge-center-shield {
  fill: #080f1d;
}

.gauge-center-ring {
  fill: none;
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 2;
}

.speedometer-wrap.is-danger .gauge-center-ring {
  stroke: rgba(255, 51, 85, 0.55);
}

.gauge-center-readout {
  position: absolute;
  top: 55.26%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
}

.hero-speed-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.3rem, 5.5vw, 4.6rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-shadow: 0 0 28px var(--accent-glow);
  transition: color 0.18s ease, text-shadow 0.18s ease;
}

.speedometer-wrap.is-warn .hero-speed-value {
  color: #fbbf24;
  text-shadow: 0 0 28px rgba(245, 158, 11, 0.45);
}

.speedometer-wrap.is-danger .hero-speed-value {
  color: #ff4769;
  text-shadow: 0 0 36px rgba(255, 51, 85, 0.7);
}

.unit-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}

.unit-toggle-btn:hover {
  border-color: var(--accent);
}

.unit-swap {
  font-size: 0.75rem;
  opacity: 0.75;
}

.hero-delta-label {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(11, 18, 32, 0.9);
}

.speedometer-wrap.is-danger .hero-delta-label {
  color: #ff8fa3;
  border-color: rgba(255, 51, 85, 0.45);
  background: rgba(255, 51, 85, 0.22);
}

.speed-dec {
  font-size: 0.44em;
  opacity: 0.85;
  font-weight: 700;
  margin-left: 1px;
}

/* Realtime GPS Telemetry & Calibration Strip */
.speed-calib-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.calib-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.calib-chip.is-imu {
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.calib-chip.is-stale {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.calib-chip.is-btn {
  cursor: pointer;
  color: var(--text-primary);
  transition: border-color 0.16s, color 0.16s, background 0.16s;
}

.calib-chip.is-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.calib-chip.is-btn.is-active {
  border-color: rgba(0, 229, 255, 0.45);
  background: rgba(0, 229, 255, 0.1);
  color: var(--accent);
}

/* Calibration Modal */
.calib-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calib-explain {
  margin: 0;
  font-size: 0.8rem;
}

.calib-live-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.calib-match-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calib-match-row input[type="number"] {
  width: 92px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.98rem;
}

.calib-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* Hero Actions Bar */
.hero-actions-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  width: 100%;
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.action-pill:hover {
  border-color: var(--accent);
}

.action-pill.is-primary {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
  color: #03111c;
  border-color: transparent;
  font-weight: 700;
}

.action-pill.is-running {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warn);
  color: #fbbf24;
}

/* Trip Strip */
.trip-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
}

.stat-tile {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 800;
}

.stat-value small {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Right Hub Panel */
.hub-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hub-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  background: var(--bg-deep);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.hub-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 4px;
  border-radius: 9px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.hub-tab:hover {
  color: var(--text-primary);
}

.hub-tab.is-active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 229, 255, 0.3);
}

.hub-tab-pane {
  display: none;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.hub-tab-pane.is-active {
  display: flex;
}

/* Map Frame */
.map-frame {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #070c16;
}

#minimap-tiles-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  filter: invert(92%) hue-rotate(180deg) brightness(0.86) contrast(1.06);
  pointer-events: none;
}

#minimap-canvas {
  position: relative;
  display: block;
  width: 100%;
  height: 270px;
}

.map-overlay-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.map-chip {
  pointer-events: auto;
  background: rgba(5, 8, 15, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.map-chip.btn-chip {
  cursor: pointer;
  font-weight: 700;
}

.map-chip.btn-chip.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

.map-chip.is-warn {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fcd34d;
}

.map-overlay-controls {
  position: absolute;
  right: 8px;
  bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.map-ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(5, 8, 15, 0.85);
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

.map-ctrl-btn:hover {
  border-color: var(--accent);
}

.map-legend {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  gap: 10px;
  background: rgba(5, 8, 15, 0.82);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.safe { background: var(--safe); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

/* Utility Cards */
.utility-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.utility-card,
.subcard {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.utility-head,
.subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subcard-head h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.utility-sub,
.muted-text {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.utility-actions {
  display: flex;
  gap: 8px;
}

/* Trip Tab */
#sparkline-canvas {
  width: 100%;
  height: 105px;
  display: block;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.trip-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kv-box {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kv-box span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.kv-box strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

/* Accel Tab */
.accel-controls {
  display: flex;
  gap: 8px;
}

.accel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.accel-box {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.accel-target {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.accel-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
}

.accel-best {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Spots Form & List */
.spot-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spot-form input,
.spot-form select,
.full-select {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  width: 100%;
}

.spot-form-row {
  display: grid;
  grid-template-columns: 1fr 72px auto;
  gap: 6px;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
}

.list-stack.empty-state {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 2px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.list-item-main {
  min-width: 0;
  flex: 1;
}

.list-item-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: 0.71rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Simulator Tab */
.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sim-slider-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.sim-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* =========================================
   DEDICATED WINDSHIELD HUD MODE
   ========================================= */
.hud-stage {
  position: fixed;
  inset: 0;
  z-index: 750;
  background: #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 26px;
  user-select: none;
}

.hud-projection {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  transition: transform 0.2s ease;
  --hud-ink: #00f0ff;
}

.hud-projection[data-hud-color="green"] { --hud-ink: #22ff66; }
.hud-projection[data-hud-color="amber"] { --hud-ink: #ffaa00; }
.hud-projection[data-hud-color="white"] { --hud-ink: #ffffff; }

.hud-projection.mirror-x { transform: scaleX(-1); }
.hud-projection.mirror-y { transform: scaleY(-1); }
.hud-projection.mirror-x.mirror-y { transform: scale(-1, -1); }

.hud-top-row,
.hud-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.3vw, 1.5rem);
  font-weight: 700;
  color: var(--hud-ink);
  opacity: 0.9;
}

.hud-sep {
  margin: 0 10px;
  opacity: 0.4;
}

.hud-center-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 7vw, 90px);
  flex-wrap: wrap;
}

.hud-speed-block {
  text-align: center;
}

.hud-speed-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(6.5rem, 21vw, 16rem);
  font-weight: 900;
  line-height: 0.9;
  color: var(--hud-ink);
  text-shadow: 0 0 36px currentColor;
}

.hud-stage.is-overspeed .hud-speed-value {
  color: #ff2a55;
  animation: hudBlink 0.7s infinite;
}

@keyframes hudBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.52; }
}

.hud-unit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: clamp(1.1rem, 2.8vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--hud-ink);
}

.hud-alert-tag {
  background: #ff2a55;
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.7em;
  letter-spacing: 0.08em;
}

.hud-limit-sign {
  width: clamp(110px, 18vw, 185px);
  height: clamp(110px, 18vw, 185px);
  border-radius: 50%;
  border: clamp(10px, 1.8vw, 18px) solid #ff2a55;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: clamp(3rem, 7.5vw, 5.4rem);
  font-weight: 900;
  box-shadow: 0 0 32px rgba(255, 42, 85, 0.35);
}

.hud-bar-wrap {
  width: min(760px, 90%);
  margin: 0 auto;
}

.hud-bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.hud-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--hud-ink);
  box-shadow: 0 0 18px var(--hud-ink);
}

.hud-stage.is-overspeed .hud-progress-fill {
  background: #ff2a55;
  box-shadow: 0 0 22px #ff2a55;
}

.hud-camera-alert {
  color: #fbbf24;
  font-weight: 800;
}

.hud-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  margin: 0 auto;
  transition: opacity 0.3s ease;
}

.hud-stage.is-idle .hud-controls {
  opacity: 0.15;
}

.hud-ctrl-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.hud-ctrl-btn.is-active {
  background: var(--accent);
  color: #03111c;
  border-color: transparent;
}

.hud-ctrl-btn.is-exit {
  background: rgba(255, 51, 85, 0.22);
  border-color: rgba(255, 51, 85, 0.5);
  color: #ff8fa3;
}

.hud-color-dots {
  display: inline-flex;
  gap: 6px;
  padding: 0 6px;
}

.hud-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.hud-color-dot[data-hud-color="cyan"] { background: #00f0ff; }
.hud-color-dot[data-hud-color="green"] { background: #22ff66; }
.hud-color-dot[data-hud-color="amber"] { background: #ffaa00; }
.hud-color-dot[data-hud-color="white"] { background: #ffffff; }

.hud-color-dot.is-active {
  transform: scale(1.18);
  border-color: #ffffff;
  box-shadow: 0 0 10px #ffffff;
}

/* =========================================
   MODALS
   ========================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 880;
  background: rgba(3, 7, 15, 0.78);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.modal-card {
  width: min(760px, 100%);
  max-width: 100%;
  min-width: 0;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-card.modal-wide {
  width: min(860px, 100%);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-footer {
  border-bottom: none;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  min-width: 0;
  line-height: 1.3;
}

.modal-close {
  border: none;
  background: var(--bg-elevated);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.setting-group {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.setting-group h3 {
  margin: 0 0 2px;
  font-size: 0.84rem;
  color: var(--accent);
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 0;
  max-width: 100%;
}

.setting-row select,
.setting-row input[type="number"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: var(--text-primary);
  text-overflow: ellipsis;
}

.setting-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.81rem;
  line-height: 1.35;
  cursor: pointer;
  min-width: 0;
}

.setting-check input {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.history-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.history-modal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* =========================================
   RESPONSIVE BREAKPOINTS
   ========================================= */
@media (max-width: 1220px) {
  .cockpit-main {
    grid-template-columns: 300px 1fr;
  }
  .cluster-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .cockpit-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .cluster-center {
    order: -1;
  }
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .hide-sm {
    display: none;
  }
  .context-pill {
    display: none;
  }
}

@media (max-width: 560px) {
  .modal-backdrop {
    padding: 8px;
  }
  .modal-card {
    max-height: 92dvh;
    border-radius: 14px;
  }
  .modal-header,
  .modal-footer {
    padding: 11px 13px;
  }
  .modal-header h2 {
    font-size: 0.95rem;
  }
  .modal-body {
    padding: 11px 12px;
  }
  .setting-group {
    padding: 10px 11px;
  }
  .calib-live-compare {
    grid-template-columns: minmax(0, 1fr);
  }
  .app-shell {
    padding: 8px;
  }
  .topbar {
    padding: 8px 10px;
  }
  .mode-switcher {
    width: 100%;
    justify-content: space-between;
  }
  .mode-btn {
    flex: 1;
    justify-content: center;
    padding: 7px 6px;
    font-size: 0.74rem;
  }
  .hub-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hub-tabs::-webkit-scrollbar {
    display: none;
  }
  .hub-tab {
    flex: 0 0 auto;
    padding: 8px 10px;
  }
  .panel {
    min-width: 0;
    max-width: 100%;
  }
  .trip-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .spot-form-row {
    grid-template-columns: 1fr;
  }
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}
