:root {
  --bg-dark: #000000;
  --bg-card: #0b0f19;
  --bg-card-hover: rgba(26, 38, 62, 0.95);
  --border-color: rgba(255, 255, 255, 0.22);
  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.3);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.35);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.35);
  --warning: #f59e0b;
  
  --font-main: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  overflow-x: clip;
}

body {
  background-color: #000000;
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding-top: max(1.25rem, env(safe-area-inset-top));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, env(safe-area-inset-left));
}

/* NAVBAR */
.navbar {
  position: relative;
  z-index: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand-text h1,
.brand-text h1.brand-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  display: inline-block;
  white-space: nowrap;
  transition: all 0.25s ease;
}

.brand-text h1.brand-title.pro {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.8rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(236, 72, 153, 0.25));
  border: 1px solid #f59e0b;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: #ffffff;
  color: #ffffff;
  cursor: default;
  line-height: 1.2;
  user-select: none;
}

.brand-text h1.brand-title.pro .brand-pro-tag {
  color: #fbbf24;
  font-weight: 800;
  letter-spacing: 0.05em;
  -webkit-text-fill-color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.navbar {
  gap: 1.25rem;
  flex-wrap: wrap;
}

.nav-actions {
  display: flex;
  flex: 1 1 auto;
  /* T81: a long route name is cut with an ellipsis instead of pushing the header past the screen. */
  min-width: 0;
  max-width: 100%;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Primary group: route selector + GPX split button */
.nav-primary {
  display: flex;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.nav-primary .route-dropdown-toggle {
  height: 44px;
  min-height: 44px !important;
  padding: 0 1rem !important;
  max-width: 300px;
  border-radius: 12px;
}

.nav-primary .dropdown-btn-group {
  border-radius: 12px;
}

.nav-primary .dropdown-btn-group .btn-split-main {
  min-height: 44px !important;
  height: 44px;
  padding: 0 0.9rem 0 1.1rem;
  border-radius: 12px 0 0 12px !important;
  white-space: nowrap;
}

.nav-primary .dropdown-btn-group .btn-split-arrow {
  min-height: 44px !important;
  min-width: 40px !important;
  height: 44px;
  padding: 0 0.7rem;
  border-radius: 0 12px 12px 0 !important;
}

/* Tools group: install, language, license, settings (uniform, quieter) */
.nav-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-color);
}

.nav-tools > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 44px;
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: 12px;
  font-size: 0.85rem;
  box-sizing: border-box;
  white-space: nowrap;
}

.nav-tools > .btn-install[hidden] {
  display: none !important;
}

.nav-tools > .btn-install .btn-text {
  display: none !important;
}

.nav-tools > .btn-install {
  justify-content: center;
  padding: 0 0.5rem;
}

.nav-tools > .btn-settings {
  padding: 0 0.8rem;
}

/* DRAG DROP ZONE */

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem !important;
  min-height: 48px !important;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-success { background: #10b981; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-danger { background: #ef4444; color: white; }
.btn-secondary { background: #475569; color: white; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* DASHBOARD LAYOUT */
.dashboard-grid {
  display: grid;
  grid-template-columns: 395px 1fr;
  gap: 1.5rem;
}

.sidebar-panel, .main-panel {
  min-width: 0;
  max-width: 100%;
}

@media (min-width: 1400px) {
  .dashboard-grid {
    grid-template-columns: 415px 1fr;
  }
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .sidebar-panel, .main-panel {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* CARDS */
.card {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2, .card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* HUD CARD (Optimized with min-height & layout containment to prevent CLS) */
.hud-card {
  min-height: 420px;
  contain: layout;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08) 0%, rgba(18, 26, 42, 0.9) 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.hud-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.buffer-display {
  min-height: 4.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  padding: 1rem 0;
  margin: 0.5rem 0;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.buffer-display.green {
  color: #34d399;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.5);
  background: rgba(16, 185, 129, 0.1);
}

.buffer-display.red {
  color: #f87171;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.5);
  background: rgba(239, 68, 68, 0.1);
}

/* T72 (D12): not negative, but under 30 minutes or under 10% of the time left. */
.buffer-display.yellow {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.1);
}

/* T72 (D12, D13): a number that is not fresh live data: stale, without a fix, off the route, a plan. */
.buffer-display.neutral {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.1);
}

/* T72 (R5-004): no permission, no buffer. */
.buffer-display.permission-denied {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
}

.gps-permission-error {
  width: 100%;
  box-sizing: border-box;
  margin: 0.5rem 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 2px solid #f87171;
  background: rgba(127, 29, 29, 0.35);
  color: #fee2e2;
  text-align: left;
}

.gps-permission-error .gps-permission-title {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.gps-permission-error .gps-permission-steps {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.gps-permission-error .btn {
  min-height: 44px;
  background: #b91c1c;
  color: #ffffff;
  box-shadow: none;
}

/* D05: no cutoff: no number and no colour that could read as a buffer. */
.buffer-display.no-cutoff {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.1);
}

.buffer-display.no-cutoff .unit,
.buffer-display.permission-denied .unit,
.glance-buffer-box.no-cutoff .glance-buffer-unit,
.glance-buffer-box.none .glance-buffer-unit {
  display: none;
}

#btn-hud-set-cutoff {
  margin: 0.5rem auto 0;
}

/* D04: a missed cutoff not yet confirmed. The number stays, it is not green. */
.buffer-display.missed {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.5);
}

.hud-missed-cutoff-note {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fbbf24;
  margin-top: 4px;
  text-align: center;
}

.btn-missed-cutoff {
  width: 100%;
  min-height: 44px;
  margin-top: 0.5rem;
}

.cp-table tr.cutoff-missed {
  box-shadow: inset 3px 0 0 #f87171;
}

.cutoff-missed-chip {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* T72 (D13): the grey is the neutral level; a negative number stays red, so no filter here. */
.buffer-display.stale-gps {
  border: 2px dashed rgba(245, 158, 11, 0.7);
}

.hud-gps-age {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f59e0b;
  margin-top: 4px;
  text-align: center;
  background: rgba(245, 158, 11, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.hud-subtext {
  min-height: 1.35rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.hud-buffer-hint {
  font-size: 0.76rem;
  color: var(--text-muted, #94a3b8);
  text-align: center;
  margin-bottom: 1.25rem;
  line-height: 1.3;
  opacity: 0.88;
}

.hud-metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
}

.wide-metric {
  grid-column: 1 / -1 !important;
}

button.metric-box {
  all: unset;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 64px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.2s ease;
}

button.metric-box:hover,
button.metric-box:focus-visible {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.metric-box {
  box-sizing: border-box;
  min-height: 64px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
}

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  min-height: 1.4rem;
  line-height: 1.4rem;
}

#box-gps-coords .highlight-coords {
  min-height: 1.4rem;
  line-height: 1.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* NEXT CHECKPOINT BOX & CUTOFF */
.next-cp-box {
  min-height: 68px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 10px;
}

.cp-icon {
  font-size: 1.4rem;
}

.cp-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.cp-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cp-detail {
  font-size: 0.8rem;
  color: #93c5fd;
  margin-bottom: 0.3rem;
}

.cutoff-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}

.cutoff-badge.green {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.cutoff-badge.red {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.cutoff-badge.yellow {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* D02: a planned split is for orientation, it has no colour of a verdict. */
.cutoff-badge.planned {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.cutoff-pill.cutoff-none {
  color: #94a3b8;
}

.cutoff-tier-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.cutoff-tier-label[data-tier="unverified"] {
  color: #fbbf24;
  font-weight: 600;
}

.cutoff-confirm-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.mode-card.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

tr.is-bottleneck td:first-child {
  box-shadow: inset 3px 0 0 #fbbf24;
}

.cutoff-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  font-weight: 600;
  white-space: nowrap;
}

.cutoff-pill.cutoff-official {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.cutoff-pill.cutoff-planned {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.cutoff-pill.cutoff-start {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* CHECKPOINT TABLE */
.table-responsive {
  overflow-x: auto;
}

.cp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.cp-table th {
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.cp-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
}

.cp-table tr.visited {
  opacity: 0.6;
  background: rgba(16, 185, 129, 0.05);
}

.cp-table tr.active {
  background: rgba(56, 189, 248, 0.12);
  border-left: 3px solid #38bdf8;
}

.cp-table tr.active td {
  color: #f1f5f9;
  font-weight: 600;
}

/* FORM & CONFIG */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-row input[type="number"] {
  width: 70px;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: white;
  font-family: var(--font-mono);
  text-align: center;
}

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

.divider {
  border: 0;
  height: 1px;
  background: var(--border-color);
  margin: 1.25rem 0;
}

.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* SUMMARY BANNER */
.summary-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.summary-icon {
  font-size: 1.6rem;
}

.summary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* T81 (D03): the built-in route is an example, and it says so where its name is. */
.example-route-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: #fbbf24;
  color: #1f2937;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
}

.example-route-attribution {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.example-route-attribution a {
  color: inherit;
}

.example-route-badge[hidden],
.example-route-attribution[hidden] {
  display: none;
}

/* MAP & ELEVATION */
.map-view {
  height: 380px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  contain: layout;
}

.elevation-canvas-container {
  width: 100%;
  overflow-x: auto;
}

#elevation-canvas {
  width: 100%;
  height: 180px;
  display: block;
}

.status-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.3rem !important;
  flex-shrink: 0 !important;
}

/* PASTE MODAL */
.paste-modal {
  width: 520px;
  max-width: 90vw;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

#txt-paste-gpx {
  width: 100%;
  height: 220px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: #34d399;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.75rem;
  resize: vertical;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* LOCK SCREEN MODAL */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* SPLIT DROPDOWN GPX BUTTON */
.dropdown-btn-group {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-radius: 10px;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: all 0.2s ease;
}

.dropdown-btn-group:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.dropdown-btn-group .btn-split-main {
  background: transparent !important;
  box-shadow: none !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  padding: 0.6rem 0.9rem 0.6rem 1.1rem;
  border: none !important;
}

.dropdown-btn-group .btn-split-arrow {
  min-width: 48px !important;
  min-height: 48px !important;
  background: transparent !important;
  box-shadow: none !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
}

.dropdown-btn-group .btn-split-main:hover,
.dropdown-btn-group .btn-split-arrow:hover {
  background: rgba(255, 255, 255, 0.15) !important;
  transform: none !important;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.4rem;
  width: 220px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
}

.dropdown-menu.active {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.menu-pro-tag {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
}

/* --- MOBILE PERFORMANCE OPTIMIZATIONS (60 FPS GPU LAYER ACCELERATION) --- */
* {
  -webkit-tap-highlight-color: transparent;
}

.card, .navbar, .hud-card, .map-view, .dropdown-menu {
  transform: translateZ(0);
  backface-visibility: hidden;
}

@media (max-width: 768px) {
  html, body {
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  .app-container {
    padding: 0.6rem !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  .dashboard-grid,
  .sidebar-panel,
  .main-panel,
  .card {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .card,
  .navbar,
  .hud-card,
  .dropdown-menu {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--bg-card) !important;
    padding: 0.9rem !important;
    border-color: rgba(255, 255, 255, 0.22) !important;
  }

  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
    padding: 0.9rem !important;
  }

  .brand {
    justify-content: space-between;
  }

  .nav-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.7rem !important;
  }

  .nav-primary {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .nav-primary .route-dropdown-wrapper {
    display: block;
    width: 100%;
  }

  .nav-primary .route-dropdown-toggle {
    width: 100%;
    max-width: none;
    min-height: 48px !important;
    height: 48px;
  }

  .nav-primary .dropdown-btn-group {
    display: flex;
    width: 100%;
  }

  .nav-primary .dropdown-btn-group .btn-split-main {
    flex: 1 !important;
    justify-content: center !important;
    min-height: 48px !important;
    height: 48px;
  }

  .nav-primary .dropdown-btn-group .btn-split-arrow {
    min-width: 48px !important;
    min-height: 48px !important;
    height: 48px;
  }

  .nav-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 0.5rem;
    padding-left: 0;
    border-left: none;
    padding-top: 0.7rem;
    border-top: 1px solid var(--border-color);
  }

  .nav-tools > .btn {
    width: 100%;
    min-height: 48px !important;
    height: 48px;
    padding: 0 0.5rem;
  }

  /* SUMMARY BANNER RESPONSIVE FIX */
  .summary-banner {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.6rem !important;
    padding: 0.8rem !important;
  }

  .summary-item {
    min-width: 0 !important;
    gap: 0.5rem !important;
  }

  .summary-item strong {
    font-size: 0.85rem !important;
    word-break: break-word !important;
  }

  .summary-icon {
    font-size: 1.3rem !important;
  }

  .map-view {
    height: 300px !important;
    width: 100% !important;
  }

  /* ELEVATION PROFILE CANVAS RESPONSIVE FIX */
  .elevation-canvas-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .elevation-canvas-container canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
  }

  /* TABLE RESPONSIVE FIX */
  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    display: block !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .cp-table {
    min-width: 580px !important; /* Table scrolls horizontally cleanly inside table card */
  }
}

/* LEAFLET LAYER CONTROL STYLING */
.leaflet-control-layers {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 12px !important;
  color: #f8fafc !important;
  font-family: inherit !important;
  font-size: 0.82rem !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  padding: 6px 10px !important;
}

.leaflet-control-layers-toggle {
  width: 36px !important;
  height: 36px !important;
  background-size: 20px 20px !important;
}

.leaflet-control-layers-expanded {
  padding: 10px 14px !important;
}

.leaflet-control-layers label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-bottom: 6px !important;
  cursor: pointer !important;
  font-weight: 500 !important;
}

.leaflet-control-layers label:last-child {
  margin-bottom: 0 !important;
}

/* MILESTONE M4: AUDIO CONFIG & GPS MODAL STYLING */
.audio-config-modal {
  width: 580px;
  max-width: 94vw;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.4);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.7);
}

.config-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.audio-notice-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #fbbf24;
  margin: 0.6rem 0;
}

.audio-sub-options {
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.audio-sub-options.is-disabled {
  opacity: 0.38;
  filter: grayscale(0.6);
  pointer-events: none;
  user-select: none;
}

.audio-sub-options.is-disabled input[type="checkbox"],
.audio-sub-options.is-disabled select,
.audio-sub-options.is-disabled label {
  cursor: not-allowed !important;
}

.config-section h4 {
  font-size: 0.95rem;
  color: #3b82f6;
  margin-top: 0;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  color: #e2e8f0;
}

.config-row:last-child {
  margin-bottom: 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.select-inline {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 580px) {
  .audio-config-modal {
    padding: 1.1rem !important;
    width: 95vw !important;
    max-width: 95vw !important;
  }

  .config-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.4rem !important;
  }

  .select-inline {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 0.2rem !important;
  }
}

.gps-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
}

.gps-badge.inactive {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.gps-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* LIVE USER LOCATION BEACON (STABLE HTML DIVICON - NO SVG MATRIX JUMPING) */
.user-location-beacon {
  position: relative;
  width: 24px;
  height: 24px;
  pointer-events: auto;
}

.beacon-core {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  background: #2563eb;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.9);
  z-index: 2;
}

.beacon-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border: 2px solid #3b82f6;
  border-radius: 50%;
  animation: beacon-pulse 2s infinite ease-out;
  z-index: 1;
}

@keyframes beacon-pulse {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* CLICKABLE METRICS & ETA HIGHLIGHT */
.clickable-metric {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.clickable-metric:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.edit-icon {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-left: 0.25rem;
}

.highlight-eta {
  color: #38bdf8;
  font-weight: 700;
}

.wide-metric {
  grid-column: span 2;
}

/* MASTER AUDIO SWITCH & HELP SUBTEXT */
.master-toggle-row {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
}

.master-label strong {
  color: #60a5fa;
  font-size: 0.95rem;
}

.help-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

.divider-sub {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1rem 0;
}

/* CONFIRMATION & TIME PICKER MODALS */
.confirm-modal, .edit-time-modal {
  max-width: 440px;
  width: 90%;
}

.warning-header h3 {
  color: #f87171;
}

.warning-icon-large {
  font-size: 3rem;
  color: #ef4444;
  margin-bottom: 0.75rem;
}

.confirm-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.confirm-submessage {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-footer-center {
  justify-content: center;
  gap: 1rem;
}

@media (max-width: 480px) {
  .wide-metric {
    grid-column: span 1;
  }
}

.modal-content {
  background: #0b0f19;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  padding: 1.25rem;
  width: 92%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  color: #f1f5f9;
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.5rem;
}

.btn-close:hover {
  color: #ffffff;
}

.modal-body {
  margin-bottom: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding-right: 0.35rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

/* CUSTOM ROUTE SELECTOR DROPDOWN */
.route-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.route-dropdown-toggle {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: #0b0f19;
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.5);
  padding: 0.85rem 1rem !important;
  min-height: 48px !important;
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.route-dropdown-toggle:hover {
  border-color: #60a5fa;
  background: rgba(11, 15, 25, 0.9);
}

.route-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}

.dropdown-arrow {
  font-size: 0.75rem;
  color: #60a5fa;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.route-dropdown-wrapper.active .dropdown-arrow {
  transform: rotate(180deg);
}

.route-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 380px;
  background: #0f172a;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 12px;
  padding: 0.4rem;
  z-index: 1000;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  display: none;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  max-height: 320px;
  overflow-y: auto;
}

.route-dropdown-menu.active {
  display: block;
}

.route-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.4rem 0;
}

.route-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.88rem;
  gap: 0.6rem;
  user-select: none;
}

.route-dropdown-item:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #ffffff;
}

.route-dropdown-item.active-route {
  background: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
  font-weight: 700;
}

.route-item-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.route-item-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.route-item-delete-btn:hover {
  background: #ef4444;
  color: #ffffff;
  transform: scale(1.12);
  border-color: #ef4444;
}

/* WATCH EXPORT MODAL STYLES */
.watch-export-modal {
  max-width: 500px !important;
  border-radius: 20px !important;
  background: #0d1322 !important;
  border: 1px solid rgba(59, 130, 246, 0.35) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75) !important;
  color: #f1f5f9;
}

.modal-subtext {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 0.6rem;
}

.export-format-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.format-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(59, 130, 246, 0.25);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.format-card:hover {
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(30, 41, 59, 0.8);
}

.format-card.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.2);
}

.format-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.format-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.format-card-info strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-main);
}

.format-card-info span {
  font-size: 0.78rem;
  color: #94a3b8;
}

.format-card-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  color: transparent;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.format-card.active .format-card-radio {
  border-color: #3b82f6;
  background: #3b82f6;
  color: #ffffff;
}

.checkbox-option-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.4;
}

.checkbox-option-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.export-info-card {
  margin-top: 1rem;
  padding: 0.85rem 1.1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px dashed rgba(59, 130, 246, 0.35);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.export-info-card .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: #94a3b8;
}

.export-info-card .info-row strong {
  color: #60a5fa;
  font-weight: 700;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* WATCH EXPORT MODAL HEIGHT FIT TWEAKS */
.watch-export-modal {
  max-width: 520px !important;
  max-height: 90vh !important;
}

.watch-export-modal .modal-body {
  padding: 1rem 1.2rem !important;
  overflow-y: hidden !important;
}

.watch-export-modal .modal-subtext {
  margin-bottom: 0.8rem !important;
  font-size: 0.86rem !important;
}

.watch-export-modal .format-card {
  padding: 0.65rem 0.9rem !important;
  gap: 0.75rem !important;
}

.watch-export-modal .export-info-card {
  margin-top: 0.8rem !important;
  padding: 0.7rem 0.9rem !important;
}

/* WCAG AA CONTRAST ACCESSIBILITY FIXES */
.btn-success {
  background: #047857 !important;
  color: #ffffff !important;
}

.btn-success:hover {
  background: #065f46 !important;
}

.btn-danger {
  background: #b91c1c !important;
  color: #ffffff !important;
}

.btn-danger:hover {
  background: #991b1b !important;
}

/* GPS COORDS HIGHLIGHT */
.highlight-coords {
  color: #34d399 !important;
  font-family: var(--font-mono) !important;
  font-size: 0.9rem !important;
  letter-spacing: -0.3px;
}

/* --- TOUCH ERGONOMICS & INTERACTIVE FEEDBACK (PWA AUDIT) --- */
button, [role="button"], .btn {
  touch-action: manipulation;
}

button:active, .btn:active {
  transform: scale(0.98);
}

:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* Leaflet touch controls sizing (min 44px) */
.leaflet-touch .leaflet-control-layers-toggle,
.leaflet-touch .leaflet-bar a {
  width: 44px !important;
  height: 44px !important;
  line-height: 44px !important;
}

/* --- PWA UPDATE & NETWORK ERROR BANNERS --- */
.update-banner[hidden],
.network-error-banner[hidden],
[hidden] {
  display: none !important;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.22) 0%, rgba(59, 130, 246, 0.22) 100%);
  border: 1px solid rgba(52, 211, 153, 0.5);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: bannerSlideDown 0.3s ease;
}

.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.update-banner-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: #f8fafc;
  font-size: 0.95rem;
}

.update-banner-icon {
  font-size: 1.2rem;
}

.network-error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 14px;
  color: #fecaca;
  font-size: 0.92rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: bannerSlideDown 0.3s ease;
}

.network-error-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
}

.network-error-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close-banner {
  background: none;
  border: none;
  color: #fca5a5;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  min-height: auto;
  line-height: 1;
  transition: color 0.2s;
}

.btn-close-banner:hover {
  color: #ffffff;
}

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-weight: 600;
}

.btn-install:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #ffffff;
}

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

/* --- IOS INSTALL GUIDE MODAL --- */
.ios-install-modal {
  width: 480px;
  max-width: 92vw;
  background: #0f172a;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85);
}

.ios-install-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.ios-step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.ios-step-item .step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.88rem;
}

.ios-step-item .step-desc {
  font-size: 0.92rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.ios-share-icon {
  display: inline-block;
  font-size: 1.15rem;
  font-weight: bold;
  color: #60a5fa;
}

/* --- M6.1 ADAPTIVE AI HUD BADGE --- */
.hud-ai-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-top: 0.65rem;
  padding: 0.42rem 0.65rem;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.78rem;
  box-sizing: border-box;
  max-width: 100%;
  transition: all 0.2s ease;
}

.hud-ai-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: #93c5fd;
  font-weight: 600;
  font-size: 0.77rem;
  white-space: nowrap;
}

.hud-ai-status {
  color: #38bdf8;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.73rem;
  letter-spacing: -0.015em;
  white-space: nowrap;
  text-align: right;
  margin-left: auto;
}

/* --- HUD PRO ACTIVATION PILL & LINKS --- */
.hud-pro-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.25;
  margin-left: 6px;
  text-decoration: none;
  font-family: var(--font-main);
  box-sizing: border-box;
}

.hud-pro-pill:hover,
.hud-pro-pill:focus-visible {
  background: rgba(59, 130, 246, 0.32);
  border-color: #60a5fa;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.45);
  transform: translateY(-1px);
}

.hud-pro-pill .hud-pro-action {
  font-size: 0.68rem;
  font-weight: 600;
  color: #67e8f9;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hud-pro-pill:hover .hud-pro-action {
  color: #a5f3fc;
}

.hud-pro-banner {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.hud-pro-banner-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #93c5fd;
  font-family: var(--font-main);
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px dashed rgba(96, 165, 250, 0.4);
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}

.hud-pro-banner-link:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: #60a5fa;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.35);
  transform: translateY(-1px);
}

@keyframes highlight-pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.8); }
  50% { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.highlight-pulse {
  animation: highlight-pulse-glow 1.5s ease-out;
  border-color: rgba(96, 165, 250, 0.8) !important;
}

/* --- LICENSE BADGE & MODAL STYLES --- */

.license-status-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.status-badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: 9999px;
  margin-bottom: 0.5rem;
  background: #334155;
  color: #cbd5e1;
}

.status-badge.pro {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.5);
}

.license-desc {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0;
}

.pro-features-list {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.pro-features-list h4 {
  margin: 0 0 0.5rem 0;
  color: #60a5fa;
  font-size: 0.92rem;
}

.pro-features-list ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.84rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.pro-features-list li {
  margin-bottom: 0.35rem;
}

.license-input-section {
  margin-bottom: 1.25rem;
}

.license-input-section label {
  display: block;
  font-size: 0.85rem;
  color: #e2e8f0;
  margin-bottom: 0.4rem;
}

.license-feedback {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.license-feedback.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #34d399;
}

.license-feedback.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #f87171;
}

.license-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* --- PWA AUDIT: ROUTE LOADING SKELETON & VISUAL FEEDBACK --- */
.route-loading-skeleton {
  position: relative;
  overflow: hidden;
  pointer-events: none;
}

.route-loading-skeleton::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.22), transparent);
  animation: skeleton-shimmer 1.2s infinite;
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

#map.map-loading {
  opacity: 0.75;
  filter: saturate(0.8);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

/* --- M6.2 SOLAR TWILIGHT BADGE & TIMELINE STYLES --- */
.hud-solar-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  padding: 0.42rem 0.65rem;
  margin-top: 0.5rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  box-sizing: border-box;
  max-width: 100%;
  transition: all 0.25s ease;
}

.hud-solar-badge.day {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.hud-solar-badge.twilight {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.12);
}

.hud-solar-badge.night {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(88, 28, 135, 0.2);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}

.hud-solar-title {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.77rem;
  color: var(--text-main);
  white-space: nowrap;
}

.hud-solar-times {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  letter-spacing: -0.015em;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
  margin-left: auto;
}

/* --- M6.4 DATA GATING & TERRAIN / MUD FACTOR BADGE STYLES --- */
.hud-terrain-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  padding: 0.42rem 0.65rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.78rem;
  box-sizing: border-box;
  max-width: 100%;
  transition: all 0.25s ease;
}

.hud-terrain-title {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.77rem;
  color: var(--text-main);
  white-space: nowrap;
}

.hud-terrain-select {
  margin-left: auto;
  min-height: 48px;
  max-width: 60%;
  font-size: 0.82rem;
}

@media (max-width: 600px) {
  .hud-ai-badge, .hud-solar-badge, .hud-terrain-badge {
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
  }
  .hud-ai-status, .hud-solar-times {
    margin-left: auto;
  }
}

.status-chip.terrain-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  cursor: default;
  transition: all 0.2s ease;
}

/* Language Toggle Button (M10) */
.btn-lang-toggle {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-lang-toggle:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-1px);
}

.btn-lang-toggle:active {
  transform: translateY(0);
}

.lang-flag {
  font-size: 1.1rem;
  line-height: 1;
}

#lang-code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* 24-Hour Time Picker Component */
.time-picker-24h {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1rem 0;
  background: rgba(0, 0, 0, 0.4);
  padding: 1.25rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.time-picker-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-number-input {
  width: 96px;
  height: 64px;
  background: #111827;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: #ffffff;
  font-family: var(--font-mono, monospace);
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  padding: 0;
  outline: none;
  transition: all 0.2s ease;
  -moz-appearance: textfield;
  appearance: textfield;
}

.time-number-input::-webkit-outer-spin-button,
.time-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.time-number-input:focus {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
  background: #1e293b;
}

.time-picker-colon {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary, #3b82f6);
  margin-bottom: 1.25rem;
  user-select: none;
}

.time-picker-sublabel {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.time-quick-presets {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.btn-quick-time {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-time:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #ffffff;
}

/* --- MODE SWITCHER BAR (M6 UX IMPROVEMENT) --- */
.mode-bar-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
  width: 100%;
}

.mode-segmented-control {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  padding: 0.35rem;
  gap: 0.35rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  max-width: 100%;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  box-sizing: border-box;
  gap: 0.5rem;
  padding: 0.55rem 1.35rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9999px;
  color: #94a3b8;
  font-family: var(--font-sans, system-ui);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s ease;
  user-select: none;
  white-space: nowrap;
}

.mode-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.mode-tab.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.5), rgba(59, 130, 246, 0.4));
  border-color: rgba(96, 165, 250, 0.65);
  color: #ffffff;
  box-shadow: 0 2px 14px rgba(37, 99, 235, 0.4);
}

.mode-tab-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.mode-tab-pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mode-tab.active .mode-tab-pill {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

.mode-tab-pill.live-indicator.is-live {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(248, 113, 113, 0.6);
  color: #f87171;
  animation: pulse-live-indicator 1.8s infinite;
}

.mode-tab.tab-locked,
.mode-tab[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.65);
  background: transparent !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
  color: #64748b !important;
  box-shadow: none !important;
}

.mode-tab.tab-locked .mode-tab-pill,
.mode-tab[disabled] .mode-tab-pill {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #94a3b8 !important;
}

.sim-section.sim-locked {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.7);
  user-select: none;
}

@keyframes pulse-live-indicator {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

/* --- LIVE TRAIL COCKPIT CARD STYLES --- */
.live-cockpit-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.45);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.live-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
  display: inline-block;
  margin-right: 0.5rem;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.live-gps-callout {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px dashed rgba(59, 130, 246, 0.35);
  border-radius: 14px;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.live-callout-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.live-callout-content strong {
  display: block;
  font-size: 1.05rem;
  color: #f8fafc;
  margin-bottom: 0.35rem;
}

.live-callout-content p {
  font-size: 0.84rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.4;
}

.btn-cockpit-action {
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.live-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.live-metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.live-metric-label {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.live-metric-val {
  font-family: var(--font-mono, monospace);
  font-size: 1.05rem;
  color: #60a5fa;
  font-weight: 700;
}

.live-cockpit-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.live-cockpit-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.btn-cockpit-btn {
  padding: 0.6rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-radius: 8px;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-trail-summary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.trail-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
}

.trail-info-label {
  color: #94a3b8;
}

.trail-info-val {
  color: #e2e8f0;
  font-weight: 600;
}

/* Live Mode layout adjustments */
body.mode-live #sim-section {
  display: none !important;
}

@media (max-width: 600px) {
  .mode-tab {
    padding: 0.5rem 0.85rem;
    font-size: 0.84rem;
    min-height: 44px;
    min-width: 44px;
  }
  .mode-tab-pill {
    display: none;
  }
}

/* Interactive Cockpit Summary Rows & Quick Limit Presets */
.trail-info-row.clickable {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.trail-info-row.clickable:hover {
  background: rgba(255, 255, 255, 0.08);
}

.trail-info-row.clickable:active {
  transform: scale(0.98);
}

.trail-info-row .edit-icon {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-left: 4px;
  transition: opacity 0.2s ease;
}

.trail-info-row.clickable:hover .edit-icon {
  opacity: 1;
}

.trail-info-val.editable-val {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
  padding-bottom: 1px;
}

.btn-quick-limit {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-limit:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

/* --- M7 VECTOR MAP & OFFLINE REGIONS STYLES --- */
.map-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.map-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.map-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.map-engine-switch {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.65);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-engine-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  min-width: 44px;
  box-sizing: border-box;
}

.btn-engine-switch.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-outline-cyan {
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.35);
  color: #38bdf8;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline-cyan:hover {
  background: rgba(14, 165, 233, 0.22);
  border-color: #38bdf8;
  color: #ffffff;
}

.region-suggestion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  margin: 0 0 1rem 0;
  border-radius: 10px;
  font-size: 0.86rem;
  box-sizing: border-box;
  animation: fadeIn 0.3s ease;
}

.region-suggestion-banner .btn,
.region-suggestion-banner .btn-xs,
.btn-xs {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 44px !important;
  min-width: 44px !important;
  padding: 0.35rem 1rem !important;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

.region-suggestion-banner.info {
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: #7dd3fc;
}

.region-suggestion-banner.success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.region-suggestion-banner.warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.btn-vector-compass {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, background 0.2s ease;
}

.btn-vector-compass.is-active {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.4);
}

.vector-user-marker {
  position: relative;
  width: 24px;
  height: 24px;
}

.user-pulse {
  position: absolute;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #38bdf8;
  border: 3px solid #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
}

/* OFFLINE REGIONS MODAL */
.offline-regions-modal {
  max-width: 640px !important;
  max-height: 85vh !important;
}

.offline-storage-info-bar {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.offline-regions-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.region-card {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.region-card.is-downloaded {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(22, 101, 52, 0.15);
}

.region-card.is-invalid {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(120, 53, 15, 0.15);
}

.region-card.is-invalid .region-card-actions {
  flex-wrap: wrap;
}

.region-download-error {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fca5a5;
}

.region-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.region-card-title-group {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.region-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.region-name {
  font-size: 0.95rem;
  color: #f8fafc;
  display: block;
}

.region-desc {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 2px 0 0 0;
  line-height: 1.35;
}

.region-size-tag {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.region-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.region-card-actions .hud-pro-pill {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 10px;
}

.region-status-badge {
  font-size: 0.78rem;
  font-weight: 600;
}

.region-status-badge.downloaded {
  color: #4ade80;
}

.region-status-badge.available {
  color: #94a3b8;
}

.region-status-badge.invalid {
  color: #fbbf24;
}

/* A warning has to stay readable in sunlight, on the light cards of the daylight theme. */
body.theme-daylight .region-status-badge.invalid,
body.theme-daylight .region-suggestion-banner.warning {
  color: #92400e;
}

body.theme-daylight .region-download-error {
  color: #b91c1c;
}

.region-download-progress-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 4px;
  transition: width 0.15s ease;
}

.progress-bar-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #94a3b8;
}

.btn-text-danger {
  background: none;
  border: none;
  color: #f87171;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
}

.btn-text-danger:hover {
  text-decoration: underline;
}

/* ==========================================================================
   M11 MOBILE ERGONOMICS & VISUAL SENSORY ENGINE (UI_AUDIT.md IMPLEMENTATION)
   ========================================================================== */

/* --- 1. TRI-STATE VISUAL ENVIRONMENTAL THEMES --- */

/* 1.1 DAYLIGHT / SNOW / GLARE HIGH-CONTRAST MODE */
body.theme-daylight {
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: rgba(15, 23, 42, 0.25);
  --text-main: #0f172a;
  --text-muted: #334155;
  background-color: #f8fafc;
  color: #0f172a;
}

body.theme-daylight .navbar {
  background: #ffffff;
  border-bottom: 2px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

body.theme-daylight .brand-title {
  color: #0f172a;
}

body.theme-daylight .card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

body.theme-daylight .card-header {
  border-bottom: 1px solid #e2e8f0;
}

body.theme-daylight .card-header h2,
body.theme-daylight .card-header h3,
body.theme-daylight .card-header h4 {
  color: #0f172a;
}

body.theme-daylight .buffer-display.green {
  background: rgba(4, 120, 87, 0.12);
  color: #047857;
  border: 2px solid #047857;
  box-shadow: 0 0 24px rgba(4, 120, 87, 0.15);
}

body.theme-daylight .buffer-display.red {
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
  border: 2px solid #b91c1c;
  box-shadow: 0 0 24px rgba(185, 28, 28, 0.15);
}

body.theme-daylight .buffer-display.yellow {
  background: rgba(180, 83, 9, 0.1);
  color: #92400e;
  border: 2px solid #b45309;
}

body.theme-daylight .buffer-display.neutral,
body.theme-daylight .buffer-display.permission-denied {
  background: #f1f5f9;
  color: #334155;
  border: 2px dashed #64748b;
}

body.theme-daylight .gps-permission-error {
  background: #fef2f2;
  color: #7f1d1d;
  border-color: #b91c1c;
}

body.theme-daylight .hud-subtext {
  color: #1e293b;
  font-weight: 600;
}

body.theme-daylight .metric-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

body.theme-daylight .metric-label {
  color: #475569;
  font-weight: 600;
}

body.theme-daylight .metric-value {
  color: #0f172a;
}

body.theme-daylight .highlight-eta {
  color: #0369a1;
}

body.theme-daylight .highlight-coords {
  color: #0f172a;
}

body.theme-daylight .next-cp-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

body.theme-daylight .next-cp-box strong {
  color: #0f172a;
}

body.theme-daylight .btn-outline {
  border-color: #94a3b8;
  color: #0f172a;
  background: #ffffff;
}

body.theme-daylight .btn-outline:hover {
  background: #f1f5f9;
  border-color: #64748b;
}

body.theme-daylight .mode-segmented-control {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

body.theme-daylight .mode-tab {
  color: #475569;
}

body.theme-daylight .mode-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.theme-daylight .cp-table th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid #cbd5e1;
}

body.theme-daylight .cp-table td {
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

body.theme-daylight .modal-content {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

body.theme-daylight .mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid #cbd5e1;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

body.theme-daylight .bottom-nav-item {
  color: #64748b;
}

body.theme-daylight .bottom-nav-item.active {
  color: #0284c7;
}

body.theme-daylight .field-glance-overlay {
  background: #ffffff;
  color: #0f172a;
}

body.theme-daylight .glance-buffer-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
}

body.theme-daylight .glance-cp-card {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
}

body.theme-daylight .glance-telemetry-row {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
}

body.theme-daylight .glance-cp-name {
  color: #0f172a;
}

body.theme-daylight .glance-metric-val {
  color: #0f172a;
}

body.theme-daylight .glance-tel-val {
  color: #0f172a;
}

body.theme-daylight .glance-buffer-value {
  color: #334155;
}

body.theme-daylight .glance-buffer-box.green .glance-buffer-value {
  color: #047857;
}

body.theme-daylight .glance-buffer-box.yellow .glance-buffer-value {
  color: #92400e;
}

body.theme-daylight .glance-buffer-box.red .glance-buffer-value {
  color: #b91c1c;
}

body.theme-daylight .glance-buffer-box.missed .glance-buffer-value,
body.theme-daylight .glance-missed-cutoff-note,
body.theme-daylight .hud-missed-cutoff-note {
  color: #b45309;
}

body.theme-daylight .buffer-display.no-cutoff,
body.theme-daylight .glance-buffer-box.no-cutoff .glance-buffer-value,
body.theme-daylight .glance-buffer-box.no-cutoff .glance-buffer-main {
  color: #334155;
}

body.theme-daylight .cutoff-badge.planned {
  color: #334155;
}

body.theme-daylight .buffer-display.missed {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
  border: 2px solid #b45309;
}

body.theme-daylight .timeline-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

/* 1.2 DAYLIGHT: text colours hard-coded for the dark theme (T63 contrast gate) */
body.theme-daylight .glance-title,
body.theme-daylight .btn-glance-tool,
body.theme-daylight .glance-buffer-status,
body.theme-daylight .glance-buffer-sign,
body.theme-daylight .glance-buffer-main,
body.theme-daylight .hud-solar-title,
body.theme-daylight .hud-solar-times,
body.theme-daylight .hud-ai-badge,
body.theme-daylight .hud-terrain-badge,
body.theme-daylight #hud-gps-coords,
body.theme-daylight #next-cp-detail {
  color: #0f172a;
}

body.theme-daylight .hud-solar-badge,
body.theme-daylight .hud-terrain-badge,
body.theme-daylight .hud-ai-badge {
  background: #f1f5f9;
}

body.theme-daylight .hud-ai-title {
  color: #1e3a8a;
}

body.theme-daylight .highlight-coords {
  color: #047857 !important;
}

body.theme-daylight .glance-buffer-label,
body.theme-daylight .glance-buffer-unit,
body.theme-daylight .glance-metric-lbl,
body.theme-daylight .glance-tel-lbl {
  color: #334155;
}

body.theme-daylight .btn-glance-tool {
  background: #e2e8f0;
}

body.theme-daylight .btn-glance-close {
  background: #fee2e2;
  color: #991b1b;
}

body.theme-daylight .glance-buffer-box.red .glance-buffer-main {
  color: #b91c1c;
}

body.theme-daylight .glance-cp-badge {
  color: #075985;
  background: #e0f2fe;
}

body.theme-daylight .hud-ai-status {
  color: #075985;
}

body.theme-daylight .hud-pro-pill,
body.theme-daylight .hud-pro-banner-link {
  color: #1e3a8a;
  background: #dbeafe;
}

body.theme-daylight .hud-pro-pill .hud-pro-action {
  color: #155e75;
}

body.theme-daylight .free-tier-notice {
  color: #78350f;
  background: #fef3c7;
}

/* --- 2. GLOVE-FRIENDLY TOUCH TARGETS & MANIPULATION --- */
button,
a,
input,
select,
.mode-tab,
.dropdown-item,
.bottom-nav-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn {
  min-height: 44px;
}

.btn-cockpit-action {
  min-height: 52px;
  font-size: 1.05rem;
}

.btn-cockpit-btn {
  min-height: 48px;
  font-weight: 600;
}

/* Enlarge Leaflet Touch Targets for Softshell/Winter Gloves */
.leaflet-touch .leaflet-bar a {
  width: 48px !important;
  height: 48px !important;
  line-height: 48px !important;
  font-size: 22px !important;
  border-radius: 8px !important;
  background: rgba(11, 15, 25, 0.95) !important;
  color: #f1f5f9 !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

.leaflet-touch .leaflet-control-layers-toggle {
  width: 48px !important;
  height: 48px !important;
  background-size: 28px 28px !important;
  border-radius: 8px !important;
  background-color: rgba(11, 15, 25, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  opacity: 0.75;
}

/* --- 3. MOBILE BOTTOM NAVIGATION (THUMB ZONE) --- */
.mobile-bottom-nav {
  display: none;
}

@media (min-width: 1025px) {
  #btn-install-pwa,
  #btn-theme-toggle,
  #config-section-install,
  #config-row-haptic {
    display: none !important;
  }
}

.browser-recommendation-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.4;
  color: #93c5fd;
}

.browser-recommendation-chip strong {
  color: #60a5fa;
}

@media (display-mode: standalone), (display-mode: minimal-ui), (display-mode: fullscreen) {
  #btn-install-pwa,
  .btn-install,
  #config-section-install {
    display: none !important;
  }
}

body.is-pwa #btn-install-pwa,
body.is-pwa .btn-install,
body.is-pwa #config-section-install {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 0 4px;
    box-sizing: border-box;
    background: #0b0f19;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    z-index: 10000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
  }

  .app-container {
    padding-bottom: 72px !important;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    background: none;
    border: none;
    color: #94a3b8;
    padding: 2px 4px;
    cursor: pointer;
    min-width: 56px;
    height: 56px;
    border-radius: 8px;
    transition: color 0.15s ease, background-color 0.15s ease;
    touch-action: manipulation;
  }

  .bottom-nav-item:active {
    background-color: rgba(255, 255, 255, 0.08);
  }

  .bottom-nav-item.active {
    color: #38bdf8;
  }

  .bnav-icon {
    font-size: 1.15rem;
    line-height: 1.1;
  }

  .bnav-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1px;
  }
}

/* --- 4. FIELD GLANCE VIEW (CSŐLÁTÁS / VÉSZHELYZETI FÓKUSZ) --- */
.field-glance-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000000;
  display: flex;
  flex-direction: column;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  overflow-y: auto;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease-out;
}

.glance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

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

.glance-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #f1f5f9;
}

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

.btn-glance-tool {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  min-width: 56px;
  min-height: 56px;
  border-radius: 10px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-glance-close {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  min-width: 56px;
  min-height: 56px;
  border-radius: 10px;
  font-size: 1.4rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.glance-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 1.25rem;
  padding: 1.5rem 0;
}

.glance-buffer-box {
  background: #090e17;
  border: 2px solid rgba(148, 163, 184, 0.5);
  border-radius: 20px;
  padding: 1.75rem 1rem;
  text-align: center;
}

/* T72: green is a level of hud_coach, never the default of the box. */
.glance-buffer-box.green {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.2);
}

.glance-buffer-box.yellow {
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.2);
}

.glance-buffer-box.neutral {
  border-style: dashed;
}

.glance-buffer-box.red {
  border-color: rgba(239, 68, 68, 0.7);
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.25);
}

.glance-buffer-box.missed {
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.25);
}

.glance-buffer-box.no-cutoff {
  border-color: rgba(148, 163, 184, 0.5);
  box-shadow: none;
}

.glance-buffer-box.no-cutoff .glance-buffer-main {
  color: #94a3b8;
}

.glance-missed-cutoff-note {
  margin-top: 0.5rem;
  font-weight: 600;
  color: #fbbf24;
}

.glance-buffer-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.glance-buffer-main {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(3.8rem, 15vw, 6.5rem);
  font-weight: 900;
  line-height: 1;
  color: #cbd5e1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.glance-buffer-box.red .glance-buffer-main {
  color: #f87171;
}

.glance-buffer-box.green .glance-buffer-main {
  color: #34d399;
}

.glance-buffer-box.yellow .glance-buffer-main {
  color: #fbbf24;
}

.glance-buffer-box.missed .glance-buffer-main {
  color: #fbbf24;
}

.glance-buffer-unit {
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 700;
  color: #94a3b8;
  margin-left: 6px;
}

.glance-buffer-status {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.75rem;
  color: #e2e8f0;
}

.glance-cp-card {
  background: #090e17;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  padding: 1.5rem;
}

.glance-cp-header {
  margin-bottom: 0.5rem;
}

.glance-cp-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 3px 8px;
  border-radius: 6px;
}

.glance-cp-name {
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 1rem;
}

.glance-cp-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.glance-metric-col {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 10px 6px;
}

.glance-metric-lbl {
  display: block;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

.glance-metric-val {
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  font-weight: 800;
  color: #f8fafc;
  font-family: 'JetBrains Mono', monospace;
}

.glance-telemetry-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: #090e17;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
}

.glance-tel-lbl {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

.glance-tel-val {
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 800;
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
}

/* --- 5. RAIN & POCKET WATER LOCK --- */
.pocket-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: fadeIn 0.2s ease-out;
}

.pocket-lock-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 360px;
}

.pocket-lock-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.pocket-lock-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #f8fafc;
  margin-bottom: 0.5rem;
}

.pocket-lock-desc {
  font-size: 0.95rem;
  color: #94a3b8;
  line-height: 1.4;
  margin-bottom: 2rem;
}

.unlock-circle-container {
  position: relative;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.unlock-svg {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.unlock-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 6;
}

.unlock-ring-fill {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 213.6;
  transition: stroke-dashoffset 0.05s linear;
}

.btn-hold-to-unlock {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn-hold-to-unlock:active {
  transform: scale(0.95);
  background: #0f172a;
}

.unlock-btn-icon {
  font-size: 2rem;
  pointer-events: none;
}

.unlock-hint {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

/* --- 6. MOBILE TRAIL TIMELINE CARDS --- */
.mobile-only-timeline {
  display: none;
}

@media (max-width: 768px) {
  .desktop-only-table {
    display: none !important;
  }

  .mobile-only-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.5rem 0;
  }

  .timeline-card {
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 1rem 1.15rem;
    transition: border-color 0.15s ease;
  }

  .timeline-card.is-next {
    border-color: #38bdf8;
    border-left: 6px solid #38bdf8;
    background: #0d1527;
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.15);
  }

  .timeline-card.is-visited {
    border-left: 6px solid #10b981;
    opacity: 0.7;
  }

  .timeline-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
  }

  .timeline-cp-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f1f5f9;
  }

  .timeline-metrics {
    display: flex;
    gap: 14px;
    font-size: 0.85rem;
    color: #94a3b8;
    flex-wrap: wrap;
  }

  .timeline-cutoff-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
  }

  .timeline-tier {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.8;
  }

  .timeline-buffer.level-ok { color: #34d399; }
  .timeline-buffer.level-warn { color: #fbbf24; }
  .timeline-buffer.level-late { color: #f87171; }
  .timeline-buffer.level-neutral { color: #94a3b8; font-weight: 500; }

  .timeline-card.is-bottleneck {
    border-color: rgba(245, 158, 11, 0.7);
    box-shadow: inset 3px 0 0 #fbbf24;
  }

  .bottleneck-chip {
    display: inline-block;
    margin-top: 0.5rem;
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.5);
    font-size: 0.75rem;
  }

}

/* --- 7. GPS SEMAPHORE & WAKE LOCK BADGE --- */
.cockpit-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gps-semaphore-icon {
  margin-left: 6px;
  font-size: 0.88rem;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.gps-semaphore-icon.high {
  filter: drop-shadow(0 0 6px #10b981);
}

.gps-semaphore-icon.medium {
  filter: drop-shadow(0 0 6px #f59e0b);
}

.gps-semaphore-icon.low {
  filter: drop-shadow(0 0 8px #ef4444);
  animation: pulse-slow 1.6s infinite;
}

.wake-lock-badge {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 6px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- 8. TOAST NOTIFICATION CONTAINER --- */
.toast-container {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast-item {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-item.toast-leave {
  opacity: 0;
  transform: translateY(-16px) scale(0.96);
}

.toast-icon {
  font-size: 1.15rem;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- 9. IOS SAFARI SMART APP BANNER --- */
.ios-smart-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.25s ease-out;
}

.ios-banner-icon {
  font-size: 1.6rem;
}

.ios-banner-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ios-banner-title {
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 700;
}

.ios-banner-desc {
  font-size: 0.8rem;
  color: #94a3b8;
}

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

/* LEAFLET CHECKPOINT PERMANENT LABELS (MATCHING VECTOR MAP) */
.checkpoint-leaflet-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  text-shadow: 
    -1.5px -1.5px 0 #ffffff,
     1.5px -1.5px 0 #ffffff,
    -1.5px  1.5px 0 #ffffff,
     1.5px  1.5px 0 #ffffff,
     0px -1.5px 0 #ffffff,
     0px  1.5px 0 #ffffff,
    -1.5px  0px 0 #ffffff,
     1.5px  0px 0 #ffffff,
     0px  0px 4px #ffffff,
     0px  0px 6px #ffffff !important;
  white-space: normal !important;
  max-width: 135px !important;
  text-align: center !important;
  line-height: 1.25 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

.checkpoint-leaflet-label::before {
  display: none !important;
}

/* ==========================================================================
   SPRINT 1 (M11): SPECIALIZED CLIENT MODES (AUTOMATIC BY ENVIRONMENT)
   Desktop (Route Planner Studio) vs Mobile / Installed PWA (Outdoor Cockpit)
   ========================================================================== */

/* View Mode Layout Specifics:
   - Desktop (planner): Pure route strategist & simulation studio. No live GPS tracking controls or live HUD.
   - Phone (app): Dual mode (Simulation testing + Live GPS field cockpit with glance mode & rain lock).
   One address serves both (D35); the page picks the mode. */
body.mode-planner .mode-bar-container {
  display: none !important;
}

body.mode-planner #card-live-cockpit,
body.mode-planner #card-hud-live,
body.mode-planner #btn-open-glance,
body.mode-planner #btn-pocket-lock,
body.mode-planner #mobile-bottom-nav {
  display: none !important;
}

body.mode-planner #card-config-planning {
  display: block !important;
}

body.mode-app .mode-bar-container {
  display: flex !important;
}

body.mode-app #mobile-bottom-nav {
  display: flex !important;
}

/* --- BATTERY MANAGEMENT & SAVER (SAF-17 / AT-14) --- */
.battery-saver-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border: 1px solid rgba(250, 204, 21, 0.35);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.battery-preflight-notice {
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.25);
  color: #fde047;
  font-size: 0.78rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.battery-preflight-notice .notice-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

.battery-preflight-text {
  color: #fbbf24 !important;
  font-size: 0.76rem;
  margin-top: 0.4rem;
  line-height: 1.35;
}

.battery-status-val {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: 600;
}

.modal-critical-battery {
  max-width: 440px;
  width: 92%;
  border: 2px solid #ef4444;
  background: rgba(24, 10, 10, 0.98);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  box-shadow: 0 16px 45px rgba(239, 68, 68, 0.35);
}

.modal-critical-battery .modal-header h3 {
  color: #f87171;
}

.critical-warning-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  padding: 1rem;
  color: #fca5a5;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Safety Disclaimer Modal (SAF-22) */
.safety-gate-note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.safety-disclaimer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.safety-disclaimer-modal {
  width: 540px;
  max-width: 92vw;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

.gpx-import-warnings {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid var(--warning);
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
  padding: 0.75rem 0.9rem;
}

.gpx-import-warnings[hidden] {
  display: none;
}

.safety-disclaimer-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  padding: 0.9rem;
  margin-bottom: 1.2rem;
}

.safety-alert-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.safety-disclaimer-text {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #fca5a5;
  font-weight: 500;
  margin: 0;
}

.safety-guidelines h4 {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.safety-guidelines ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.safety-guidelines li {
  font-size: 0.85rem;
  color: #cbd5e1;
  padding: 0.4rem 0;
  line-height: 1.4;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Free tier model limitations warning (SAF-22) */
.free-tier-notice {
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #fbbf24;
  margin: 0.6rem 0;
  text-align: center;
}

/* Elevation Source Badge (GPS-P3.1) */
.ele-source-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
  margin-left: 4px;
  vertical-align: middle;
}

/* --- Startup self-check (T68): above everything, readable in both themes --- */
.startup-error {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  overflow-y: auto;
  background: #000000;
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1.5;
}

.startup-error[hidden] {
  display: none;
}

.startup-error h1 {
  font-size: 1.6rem;
  color: #fca5a5;
}

.startup-error ul {
  padding-left: 1.25rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.startup-error-reload {
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border: 2px solid #ffffff;
  border-radius: 8px;
  background: #ffffff;
  color: #000000;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.map-unavailable {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
}

.status-notice {
  margin: 0 0 0.75rem 0;
  padding: 0.65rem 1rem;
  border: 1px solid var(--warning);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.4;
}

.status-notice[hidden] {
  display: none;
}

/* T69: the facts of an interrupted run, one per line */
#interrupted-run-info {
  white-space: pre-line;
}

/* T73 (R2-004, D23): the screen is not kept on. Stays until the lock is back or the run stops. */
.wake-lock-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  border-width: 2px;
  font-weight: 600;
}

.wake-lock-bar[hidden],
.wake-lock-bar [hidden] {
  display: none;
}

.wake-lock-bar span {
  flex: 1 1 14rem;
}

/* T73 (D23): the self-check before the start */
.preflight-intro,
.preflight-note {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.preflight-list {
  list-style: none;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.preflight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  border-radius: 8px;
}

.preflight-item[data-state="ok"] { border-left-color: var(--success); }
.preflight-item[data-state="warn"] { border-left-color: var(--warning); }
.preflight-item[data-state="fail"] { border-left-color: var(--danger); }
.preflight-item[data-state="info"] { border-left-color: var(--primary); }

.preflight-icon::before {
  display: inline-block;
  width: 1.4rem;
  font-weight: 800;
  text-align: center;
  content: "…";
}

.preflight-item[data-state="ok"] .preflight-icon::before { content: "✓"; color: var(--success); }
.preflight-item[data-state="warn"] .preflight-icon::before { content: "!"; color: var(--warning); }
.preflight-item[data-state="fail"] .preflight-icon::before { content: "✕"; color: var(--danger); }
.preflight-item[data-state="info"] .preflight-icon::before { content: "i"; color: var(--primary); }

.preflight-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.preflight-detail {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.preflight-item[data-state="fail"] .preflight-detail {
  color: var(--text-main);
  font-weight: 600;
}

.preflight-text select {
  max-width: 100%;
}

/* T73 (R5-009): the rain lock shows the buffer and the age of the data. The overlay is dark in every theme. */
.pocket-lock-reading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 1rem;
}

.pocket-lock-label {
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #cbd5e1;
}

.pocket-lock-buffer {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  color: #f8fafc;
}

.pocket-lock-buffer.green { color: #34d399; }
.pocket-lock-buffer.yellow { color: #fbbf24; }
.pocket-lock-buffer.red { color: #f87171; }
.pocket-lock-buffer.neutral { color: #cbd5e1; }
/* T113 (D04): the colour of .buffer-display.missed on the HUD. */
.pocket-lock-buffer.missed { color: #fbbf24; }

.pocket-lock-missed {
  max-width: 22rem;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: #fbbf24;
}

.pocket-lock-missed[hidden] {
  display: none;
}

.pocket-lock-age {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fbbf24;
}

.pocket-lock-age[hidden] {
  display: none;
}

.pocket-lock-status {
  font-size: 0.95rem;
  line-height: 1.4;
  color: #e2e8f0;
  margin-bottom: 1.5rem;
}

.pocket-lock-status.warning {
  color: #fbbf24;
  font-weight: 700;
}

/* D24: the battery saver keeps the screen on, but dark: no glow, no animation. */
body.battery-saver .live-pulse-dot,
body.battery-saver .beacon-ring {
  animation: none;
}

body.battery-saver .card,
body.battery-saver .glance-buffer-box {
  box-shadow: none;
}

/* ==========================================================================
   T79 (D28, R5-003, R5-008, R5-014, R5-018): phone default view, first start path,
   a view that names itself, the number in sight once the run started
   ========================================================================== */

.dropdown-item[hidden] {
  display: none !important;
}

/* The simulation is reached from the menu on the phone: its tab shows only while the simulation view is open. */
body.mode-app:not(.mode-planning) #tab-mode-planning {
  display: none;
}

body.mode-planner .app-menu-wrapper {
  display: none !important;
}

.app-menu-wrapper {
  position: relative;
  display: inline-flex;
}

.app-menu {
  width: 260px;
  right: 0;
}

.btn-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
}

/* A plan or a simulation is not tracking: no green frame and no pulsing dot around its number. */
body:not([data-view-mode="live"]) .hud-card {
  border-color: var(--border-color);
  background: var(--bg-card);
}

body:not([data-view-mode="live"]) .hud-live-dot {
  display: none;
}

.sim-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 2px solid #f59e0b;
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  font-size: 0.9rem;
  line-height: 1.3;
}

.sim-badge strong {
  font-size: 1.05rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sim-badge[hidden],
.glance-sim-badge[hidden],
.first-run-card[hidden],
.paste-error[hidden] {
  display: none;
}

.glance-sim-badge {
  display: inline-block;
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  border: 2px solid #f59e0b;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  font-size: 1.05rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

body.theme-daylight .sim-badge,
body.theme-daylight .glance-sim-badge {
  color: #92400e;
  background: #fef3c7;
  border-color: #b45309;
}

/* R5-014: the first start path */
.first-run-steps {
  list-style: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.first-run-step {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.first-run-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  font-size: 0.9rem;
}

/* R5-014: the model parameters in an advanced section */
.advanced-params {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
}

.advanced-params > summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* R5-018 */
#map.cp-labels-hidden .checkpoint-leaflet-label {
  display: none;
}

.profile-axis-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.paste-error {
  margin: 0.5rem 0 0;
  color: #f87171;
  font-weight: 600;
}

.confirm-action-message {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  white-space: pre-line;
}

.toast-text {
  white-space: pre-line;
}

.toast-item.toast-error {
  border-color: rgba(239, 68, 68, 0.6);
}

/* R5-008: once the run started the number is in sight, and the rows that sell Pro are out of the way */
body.tracking-active .hud-pro-banner,
body.tracking-active .free-tier-notice,
body.tracking-active #hud-ai-pro-badge,
body.tracking-active .hud-buffer-hint {
  display: none !important;
}

@media (max-width: 768px) {
  body.mode-app.tracking-active .sidebar-panel {
    display: flex;
    flex-direction: column;
  }

  body.mode-app.tracking-active #hud-card {
    order: -1;
    min-height: 0;
  }

  /* R5-008: the Focus view fits a 812 px phone */
  .field-glance-overlay {
    padding-top: max(0.6rem, env(safe-area-inset-top));
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  }

  .glance-header {
    padding-bottom: 0.5rem;
  }

  .glance-body {
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  .glance-buffer-box {
    padding: 1rem 0.75rem;
  }

  .glance-buffer-status {
    font-size: 1.05rem;
    margin-top: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .glance-cp-card {
    padding: 1rem;
  }

  .glance-cp-name {
    margin-bottom: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 768px) {
  /* Eight tools do not fit one row at a thumb-sized width: two rows of four */
  .nav-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* The route cannot change under a running hike: its selector and the file buttons give the room to the number. */
  body.mode-app.tracking-active .nav-primary {
    display: none;
  }
}

.app-menu-wrapper > .btn {
  width: 100%;
}

@media (max-width: 768px) {
  .app-menu-wrapper {
    display: block;
  }
}

/* The dropdowns of the route and GPX buttons open over the tools row below them. */
.nav-primary {
  position: relative;
  z-index: 3;
}

.app-menu-wrapper {
  z-index: 2;
}

/* T82 (D17, R5-015): the plan goes to the phone as a GPX file; the card is the desktop planner's only */
.planner-handoff-card {
  display: none;
}

body.mode-planner .planner-handoff-card {
  display: block;
}

.planner-handoff-steps {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* T82 (R3-007): after the deletion only Restart is left; the bottom bar (10000) stays under it */
#modal-data-wiped {
  z-index: 10100;
}

.planner-handoff-card .btn-block,
#config-section-local-data .btn-block {
  width: 100%;
  min-height: 44px;
}

/* ===== T83 (D30, R5-012, R5-013): accessibility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -120px;
  left: 8px;
  z-index: 100000;
  padding: 14px 18px;
  min-height: 48px;
  border-radius: 8px;
  background: #ffffff;
  color: #000000;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.skip-link:focus {
  top: 8px;
}

#main-content:focus {
  outline: none;
}

/* The Pro badge is a way to buy, not a way to run: during a run it is no target (R5-013). */
body.tracking-active .hud-pro-pill {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* R5-013: gloves and a moving hand. Form fields from 48 px (the slider counts with its hit area). */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]):not([type="file"]),
select,
textarea {
  min-height: 48px;
  box-sizing: border-box;
}

input[type="range"] {
  min-height: 48px;
}

.toggle-label {
  min-height: 48px;
  align-items: center;
}

.hud-pro-pill {
  min-height: 48px;
}

/* T83 (D30): the daylight theme kept dark-theme text colours on its light cards (axe color-contrast, measured
   on the cockpit, the checkpoint cards, the settings and two dialogs). Text on white from 4.5:1. */
body.theme-daylight #net-status,
body.theme-daylight #map-status {
  color: #065f46 !important;
}

body.theme-daylight .live-callout-content strong {
  color: #0f172a;
}

body.theme-daylight .live-callout-content p {
  color: #334155;
}

body.theme-daylight .battery-preflight-notice,
body.theme-daylight .battery-preflight-notice span,
body.theme-daylight #settings-battery-preflight-notice {
  color: #713f12 !important;
}

body.theme-daylight .trail-info-label,
body.theme-daylight .modal-subtext,
body.theme-daylight .time-picker-sublabel {
  color: #334155;
}

body.theme-daylight .trail-info-val,
body.theme-daylight .config-row,
body.theme-daylight .config-row span {
  color: #0f172a;
}

body.theme-daylight #cockpit-audio-status {
  color: #065f46 !important;
}

body.theme-daylight .hud-pro-pill,
body.theme-daylight .hud-pro-pill .hud-pro-action {
  color: #1e4e66;
}

body.theme-daylight .btn-outline-cyan,
body.theme-daylight .btn-outline-cyan span {
  color: #0f4c63;
}

body.theme-daylight .timeline-card .timeline-cp-name,
body.theme-daylight .timeline-card .timeline-cutoff-row {
  color: #0f172a;
}

body.theme-daylight .timeline-card .timeline-metrics,
body.theme-daylight .timeline-card .timeline-metrics span,
body.theme-daylight .timeline-card .timeline-metrics strong,
body.theme-daylight .timeline-buffer.level-neutral {
  color: #334155;
}

body.theme-daylight .timeline-buffer.level-ok { color: #065f46; }
body.theme-daylight .timeline-buffer.level-warn { color: #854d0e; }
body.theme-daylight .timeline-buffer.level-late { color: #b91c1c; }

/* The engine switch sits on a translucent dark bar in this theme: white on it and on the blue active half. */
body.theme-daylight .btn-engine-switch,
body.theme-daylight .btn-engine-switch span {
  color: #ffffff;
}

body.theme-daylight .time-picker-24h {
  background: #e2e8f0;
}

/* The badge carries its colours inline (ergonomics-pwa.js). */
body.theme-daylight .active-next {
  color: #0c4a6e !important;
}

body.theme-daylight .config-section h4 {
  color: #1d4ed8;
}

body.theme-daylight .gps-badge.inactive {
  color: #334155;
}

body.theme-daylight #battery-status-text {
  color: #0c4a6e;
}

body.theme-daylight .btn-quick-time {
  color: #0f172a;
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* The export dialog keeps its dark face in every theme: its text must stay light on it. */
body.theme-daylight .watch-export-modal,
body.theme-daylight .watch-export-modal .modal-header h3,
body.theme-daylight .watch-export-modal .modal-header h3 span,
body.theme-daylight .watch-export-modal .format-card-info strong {
  color: #f1f5f9;
}

body.theme-daylight .watch-export-modal .field-label,
body.theme-daylight .watch-export-modal .format-card-info span,
body.theme-daylight .watch-export-modal .export-info-card .info-row,
body.theme-daylight .watch-export-modal .export-info-card .info-row span {
  color: #cbd5e1;
}

body.theme-daylight .watch-export-modal .export-info-card .info-row strong,
body.theme-daylight .watch-export-modal #preview-route-name {
  color: #93c5fd;
}

/* The line under the rain lock's ring: dark theme text on a black screen, 4.5:1 and more. */
.unlock-hint {
  color: #94a3b8;
}

body.theme-daylight .region-suggestion-banner.info { color: #0c4a6e; }
body.theme-daylight .region-suggestion-banner.success { color: #14532d; }
body.theme-daylight .region-suggestion-banner.warning { color: #78350f; }
body.theme-daylight .bottleneck-chip { color: #854d0e; }
