    :root {
      --primary: #f97316;
      --safe-top: env(safe-area-inset-top);
      --safe-bottom: env(safe-area-inset-bottom);
      --ui-bg: #07111b;
      --ui-surface: rgba(10,19,30,0.94);
      --ui-surface-elevated: #101d2c;
      --ui-control: #122235;
      --ui-border: rgba(148,163,184,0.24);
      --ui-accent: #52b788;
      --ui-accent-strong: #86efac;
      --ui-alert: #fbbf24;
    }
    body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent; overflow: hidden; background: #060d1f; }
    /* If this stylesheet is missing, the inline recovery card in index.html
       remains visible and covers the unstyled shell. */
    .app-style-sentinel { display: none !important; }
    input, textarea, select { font-size: 16px !important; }  /* 防 iOS Safari 自動縮放 */
    .pg { display: none; animation: fadeIn 0.3s ease-out; }
    .pg.active { display: block; position: absolute; inset: 0; }
    #pg-map.active { display: block; }
    #map { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
    @keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
    .glass { background: rgba(15,23,42,0.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.1); }

    /* CARTO's no-labels base lets the app own the place-name language. These
       lightweight labels stay readable over the MapLibre map. */
    .local-map-place-label {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 2.1rem;
      padding: .16rem .34rem;
      color: #e5f7ed;
      background: rgba(7,17,27,0.76);
      border: 1px solid rgba(82,183,136,0.42);
      border-radius: .3rem;
      box-shadow: 0 2px 9px rgba(0,0,0,0.38), 0 0 0 1px rgba(7,17,27,0.25);
      font-size: .66rem;
      font-weight: 900;
      line-height: 1.1;
      letter-spacing: .02em;
      text-shadow: 0 1px 2px rgba(0,0,0,0.8);
      white-space: nowrap;
      pointer-events: none;
      user-select: none;
    }
    body.light .local-map-place-label {
      color: #12352a;
      background: rgba(248,250,252,0.86);
      border-color: rgba(22,101,52,0.3);
      text-shadow: none;
    }

    /* Dark surfaces need a brighter text ladder so route data stays readable over maps. */
  body:not(.light) {
      --ui-text-primary: #f8fafc;
      --ui-text-secondary: #f1f5f9;
      --ui-text-muted: #d5deea;
      --ui-text-subtle: #c0cedc;
      --ui-text-faint: #aec0d2;
      --ui-bg: #07111b;
      --ui-surface: rgba(10,19,30,0.94);
      --ui-surface-elevated: #101d2c;
      --ui-control: #122235;
      --ui-border: rgba(148,163,184,0.24);
      --ui-accent: #52b788;
      --ui-accent-strong: #86efac;
      --ui-alert: #fbbf24;
      color: var(--ui-text-secondary);
    }
    body:not(.light) .text-slate-300 { color: var(--ui-text-secondary) !important; }
    body:not(.light) .text-slate-400 { color: var(--ui-text-muted) !important; }
    body:not(.light) .text-slate-500 { color: var(--ui-text-subtle) !important; }
    body:not(.light) .text-slate-600 { color: var(--ui-text-faint) !important; }
    body:not(.light) .placeholder-slate-500::placeholder { color: var(--ui-text-subtle); opacity: 1; }

    ::-webkit-scrollbar { width: 4px; }
    ::-webkit-scrollbar-thumb { background: rgba(249,115,22,0.5); border-radius: 10px; }
    .nav-it.active { color: var(--primary); }
    .nav-it.active i { transform: translateY(-4px); transition: transform 0.2s; }
    .list-filter-shell {
      background:
        radial-gradient(circle at top right, rgba(249,115,22,0.18), transparent 34%),
        linear-gradient(180deg, rgba(15,23,42,0.9), rgba(15,23,42,0.72));
      border: 1px solid rgba(255,255,255,0.08);
      box-shadow: 0 18px 42px rgba(0,0,0,0.28);
    }
    .list-tabs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: rgba(255,255,255,0.04); }
    .rtab {
      color: #cbd5e1;
      background: transparent;
      border: 1px solid transparent;
      letter-spacing: 0.02em;
    }
    .rtab.active {
      background: linear-gradient(135deg, #fb923c, #f97316);
      color: #fff;
      box-shadow: 0 8px 18px rgba(249,115,22,0.35);
    }
    .county-rtab {
      background: rgba(255,255,255,0.05);
      color: #cbd5e1;
      border: 1px solid rgba(255,255,255,0.08);
    }
    .county-rtab.active {
      box-shadow: 0 8px 18px rgba(249,115,22,0.24);
    }
    .list-search-input {
      background:
        linear-gradient(180deg, rgba(15,23,42,0.86), rgba(15,23,42,0.66));
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 20px;
      color: #e2e8f0;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    }
    .list-search-input::placeholder { color: #64748b; }
    .hint-chip {
      background: rgba(255,255,255,0.05);
      color: #cbd5e1;
      border: 1px solid rgba(255,255,255,0.08);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    }
    .hint-chip:hover {
      background: rgba(249,115,22,0.12);
      color: #fdba74;
      border-color: rgba(249,115,22,0.35);
    }
    .list-suggest-label { letter-spacing: 0.12em; text-transform: uppercase; }
    .cam-card {
      transition: border-color 0.2s, transform 0.18s, box-shadow 0.18s, background 0.18s;
      content-visibility: auto;
      contain-intrinsic-size: 76px;
      background:
        radial-gradient(circle at top right, rgba(249,115,22,0.08), transparent 30%),
        linear-gradient(180deg, rgba(15,23,42,0.78), rgba(15,23,42,0.62));
      box-shadow: 0 12px 24px rgba(0,0,0,0.18);
    }
    .route-mode-btn.active { background: #f97316 !important; color: #fff !important; border-color: #f97316 !important; }
    .cam-card:hover {
      border-color: rgba(249,115,22,0.5) !important;
      transform: translateY(-2px);
      box-shadow: 0 16px 28px rgba(0,0,0,0.24);
    }
    body.light { background: #f1f5f9; color: #1e293b; }
    body.light .glass { background: rgba(255,255,255,0.85); border-color: rgba(0,0,0,0.1); }
    body.light #pg-list { background: #f1f5f9; }
    body.light #pg-tools { background: #f1f5f9; }
    body.light input { background: rgba(0,0,0,0.05) !important; color: #1e293b; }
    body.light .text-slate-100 { color: #1e293b; }
    body.light .text-slate-400 { color: #64748b; }
    body.light .list-filter-shell {
      background:
        radial-gradient(circle at top right, rgba(249,115,22,0.16), transparent 34%),
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.82));
      box-shadow: 0 16px 36px rgba(148,163,184,0.18);
    }
    body.light .list-tabs-grid { background: rgba(15,23,42,0.04); }
    body.light .rtab { color: #475569; }
    body.light .county-rtab,
    body.light .hint-chip {
      background: rgba(15,23,42,0.04);
      color: #475569;
      border-color: rgba(148,163,184,0.22);
    }
    body.light .list-search-input {
      background: rgba(255,255,255,0.9) !important;
      color: #1e293b;
      border-color: rgba(148,163,184,0.28);
    }
    body.light .cam-card {
      background:
        radial-gradient(circle at top right, rgba(249,115,22,0.08), transparent 30%),
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.82));
      box-shadow: 0 14px 28px rgba(148,163,184,0.16);
    }
    body.light .tools-weather-shell {
      background:
        radial-gradient(circle at top right, rgba(56,189,248,0.12), transparent 34%),
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.84));
      box-shadow: 0 18px 34px rgba(148,163,184,0.16);
    }
    body.light .tools-refresh-btn,
    body.light .wx-county-card {
      background: rgba(255,255,255,0.88);
      border-color: rgba(148,163,184,0.22);
      color: #334155;
    }
@media (max-width: 520px) {
      .list-tabs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .ride-status-grid { grid-template-columns: 1fr; }
    }
    @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
    @keyframes ping { 0%,100%{transform:scale(1);opacity:0.3;} 50%{transform:scale(1.8);opacity:0;} }

/* === 主畫面 Web App === */
.pwa-network-banner,
.pwa-action-banner,
.pwa-install-nudge {
  position: fixed;
  top: calc(var(--safe-top) + 4.2rem);
  left: 50%;
  z-index: 900;
  width: min(92vw, 430px);
  transform: translateX(-50%);
  border: 1px solid rgba(251,146,60,0.28);
  border-radius: 16px;
  color: #f8fafc;
  box-shadow: 0 16px 40px rgba(2,6,23,0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.ui-clock-wrap { display: flex; align-items: center; }
.ui-dismiss-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border: 0;
  border-radius: 9px;
  padding: 0 5px 0 7px;
  color: #94a3b8;
  background: transparent;
  transition: background .18s, color .18s;
}
.ui-dismiss-btn:hover,
.ui-dismiss-btn:focus-visible {
  color: #f8fafc;
  background: rgba(255,255,255,0.1);
  outline: none;
}
.ui-dismiss-btn i { font-size: 9px; opacity: .75; }
.ui-dismiss-btn-compact { min-height: 22px; padding: 0 4px; }
body.ui-clock-hidden #js-clock-wrap { display: none; }
body.ui-route-banner-hidden #js-route-banner { display: none !important; }
.ui-setting-row {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 0 13px;
  color: #e2e8f0;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  transition: background .18s, border-color .18s;
}
.ui-setting-row:hover,
.ui-setting-row:focus-visible {
  border-color: rgba(249,115,22,0.38);
  background: rgba(249,115,22,0.1);
  outline: none;
}
.ui-setting-state {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
}
.ui-setting-row[aria-pressed="true"] .ui-setting-state { color: #fb923c; }
body.light .ui-dismiss-btn { color: #64748b; }
body.light .ui-dismiss-btn:hover,
body.light .ui-dismiss-btn:focus-visible { color: #1e293b; background: rgba(15,23,42,0.08); }
body.light .ui-setting-row { color: #334155; border-color: rgba(148,163,184,0.24); background: rgba(15,23,42,0.04); }
body.light .ui-setting-row:hover,
body.light .ui-setting-row:focus-visible { background: rgba(249,115,22,0.1); }
.pwa-network-banner {
  top: calc(var(--safe-top) + 3.6rem);
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  background: rgba(67,20,7,0.94);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.pwa-network-banner.hidden,
.pwa-action-banner.hidden,
.pwa-install-nudge.hidden,
.pwa-install-sheet.hidden {
  display: none;
}
.pwa-network-banner i {
  margin-top: 2px;
  color: #fb923c;
}
.pwa-action-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  background: rgba(15,23,42,0.96);
}
.pwa-install-nudge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  border-color: rgba(34,211,238,0.28);
  background: rgba(8,47,73,0.96);
}
.pwa-install-nudge-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.pwa-install-nudge-copy strong {
  color: #f8fafc;
  font-size: 12px;
}
.pwa-install-nudge-copy span {
  color: #bae6fd;
  font-size: 10px;
  line-height: 1.35;
}
.pwa-install-nudge-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.pwa-install-nudge-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 900;
}
#pwa-install-nudge-open {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  color: #082f49;
  box-shadow: 0 8px 18px rgba(14,165,233,0.22);
}
#pwa-install-nudge-close {
  background: rgba(255,255,255,0.08);
  color: #bae6fd;
}
body:has(#pwa-update-banner:not(.hidden)) .map-top-panel {
  top: calc(var(--safe-top) + 8.5rem);
}
body:has(#pwa-install-nudge:not(.hidden)) .map-top-panel {
  top: calc(var(--safe-top) + 8.5rem);
}
body.is-offline .pwa-action-banner {
  top: calc(var(--safe-top) + 7.8rem);
}
body.is-offline:has(#pwa-update-banner:not(.hidden)) .map-top-panel {
  top: calc(var(--safe-top) + 12.1rem);
}
.pwa-action-banner div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.pwa-action-banner strong {
  font-size: 12px;
}
.pwa-action-banner span {
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.35;
}
.pwa-action-banner button,
.pwa-tools-action,
.pwa-install-done {
  border: 0;
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(249,115,22,0.24);
}
.pwa-action-banner button {
  min-width: 78px;
  min-height: 38px;
  border-radius: 12px;
  font-size: 11px;
}
.pwa-install-sheet {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
}
.pwa-install-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2,6,23,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.pwa-install-card {
  position: relative;
  width: min(100%, 430px);
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 26px;
  background:
    radial-gradient(circle at top right, rgba(249,115,22,0.16), transparent 36%),
    #0f172a;
  color: #f8fafc;
  box-shadow: 0 24px 70px rgba(2,6,23,0.68);
}
.pwa-install-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pwa-install-head img,
.pwa-tools-icon {
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(2,6,23,0.26);
}
.pwa-install-head > div {
  min-width: 0;
  flex: 1;
}
.pwa-install-head span {
  color: #fb923c;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
}
.pwa-install-head h2 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 900;
}
.pwa-install-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
}
.pwa-install-steps {
  display: grid;
  gap: 10px;
  margin: 18px 0 12px;
  padding: 0;
  list-style: none;
}
.pwa-install-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: #cbd5e1;
  font-size: 12px;
}
.pwa-install-steps li > span {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border-radius: 50%;
  background: rgba(249,115,22,0.16);
  color: #fb923c;
  font-size: 11px;
  font-weight: 900;
}
.pwa-install-card > p {
  margin: 0;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.5;
}
.pwa-install-done {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border-radius: 14px;
  font-size: 12px;
}
.pwa-tools-action {
  min-width: 58px;
  min-height: 38px;
  border-radius: 12px;
  font-size: 11px;
}
body.light .pwa-install-card,
body.light .pwa-action-banner,
body.light .pwa-install-nudge {
  border-color: rgba(148,163,184,0.22);
  background: rgba(255,255,255,0.98);
  color: #0f172a;
}
body.light .pwa-install-steps li {
  border-color: rgba(148,163,184,0.2);
  background: rgba(241,245,249,0.78);
  color: #334155;
}
@media (display-mode: standalone) {
  body {
    overscroll-behavior: none;
  }
}

/* === 沿途影像輪播 === */
#route-camera-strip {
  position: fixed;
  bottom: 5.5rem;
  left: 12px;
  right: 12px;
  z-index: 1700;
  display: none;
  background: rgba(10,18,38,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(249,115,22,0.4);
  border-radius: 16px;
  padding: 10px 12px 12px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.7);
}
#route-camera-strip.visible { display: block; }
#route-camera-strip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
#route-camera-strip-scroll::-webkit-scrollbar { height: 4px; }
.strip-cam {
  flex: 0 0 140px;
  width: 140px;
  background: rgba(30,41,59,0.8);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
  scroll-snap-align: start;
  transition: border-color 0.2s, transform 0.15s;
}
.strip-cam:active { transform: scale(0.96); }
.strip-cam:hover { border-color: rgba(249,115,22,0.6); }
.strip-cam-img {
  width: 100%;
  height: 80px;
  background: #0f172a;
  position: relative;
  overflow: hidden;
}
.strip-cam-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}
.strip-cam-img .ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #475569; font-size: 18px;
}
.strip-cam-info { padding: 5px 7px; }
.strip-cam-name {
  font-size: 10px; font-weight: 700; color: #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.strip-cam-meta {
  font-size: 9px; color: #94a3b8; margin-top: 2px;
  display: flex; align-items: center; gap: 4px;
}
.strip-cam-badge {
  display: inline-block; padding: 0 4px; border-radius: 3px;
  font-size: 8px; font-weight: 900;
  flex-shrink: 0;
}
.strip-cam-badge.yt { background: #ef4444; color: #fff; }
.strip-cam-badge.cctv { background: rgba(249,115,22,0.25); color: #fb923c; }

/* 工具頁天氣面板 */
.tools-weather-shell {
  background:
    radial-gradient(circle at top right, rgba(56,189,248,0.18), transparent 34%),
    linear-gradient(180deg, rgba(15,23,42,0.9), rgba(15,23,42,0.72));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 38px rgba(0,0,0,0.24);
}
.tools-weather-icon {
  background: linear-gradient(135deg, rgba(56,189,248,0.2), rgba(14,165,233,0.08));
  border: 1px solid rgba(56,189,248,0.18);
}
.tools-refresh-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 7px 12px;
}
.tools-refresh-btn:hover {
  background: rgba(56,189,248,0.12);
  border-color: rgba(56,189,248,0.25);
  color: #bae6fd;
}
.wx-county-card {
  background:
    radial-gradient(circle at top right, rgba(56,189,248,0.1), transparent 36%),
    linear-gradient(180deg, rgba(30,41,59,0.78), rgba(15,23,42,0.72));
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}
.wx-county-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56,189,248,0.28);
  box-shadow: 0 14px 26px rgba(0,0,0,0.22);
}

.ride-status-shell {
  background:
    radial-gradient(circle at top left, rgba(34,211,238,0.14), transparent 30%),
    linear-gradient(180deg, rgba(8,16,34,0.92), rgba(8,16,34,0.76));
  border-color: rgba(103,232,249,0.12);
  box-shadow: 0 16px 34px rgba(2,8,23,0.34);
}
.ride-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ride-metric-card {
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(15,23,42,0.62);
  border: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ride-metric-label {
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}
.ride-metric-value {
  font-size: 12px;
  color: #f8fafc;
  font-weight: 800;
}
.ride-inline-note {
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(249,115,22,0.08);
  color: #fdba74;
  border: 1px solid rgba(249,115,22,0.18);
  font-size: 11px;
  line-height: 1.5;
}
.map-legend {
  position: absolute;
  bottom: 5.5rem;
  right: 1rem;
  z-index: 400;
  min-width: 88px;
  padding: 8px 10px;
  border-radius: 14px;
}
.map-legend-title {
  font-size: 9px;
  font-weight: 900;
  color: #f97316;
  margin-bottom: 5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 10px;
  color: #cbd5e1;
}
.map-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.map-legend-dot.highway { background: #3b82f6; box-shadow: 0 0 4px #3b82f6; }
.map-legend-dot.expressway { background: #a855f7; box-shadow: 0 0 4px #a855f7; }
.map-legend-dot.provincial { background: #f97316; box-shadow: 0 0 4px #f97316; }
.map-legend-dot.scenic { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.list-state-banner {
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(34,211,238,0.08);
  border: 1px solid rgba(34,211,238,0.14);
  color: #a5f3fc;
  font-size: 11px;
  font-weight: 700;
}
.list-load-more {
  color: #fdba74;
  border: 1px solid rgba(249,115,22,0.16);
  border-radius: 16px;
  background: rgba(249,115,22,0.07);
  font-weight: 800;
}
.list-load-more:active,
.list-load-more:hover {
  background: rgba(249,115,22,0.14);
}
.tools-hero-shell {
  background:
    radial-gradient(circle at top right, rgba(249,115,22,0.18), transparent 34%),
    linear-gradient(180deg, rgba(15,23,42,0.95), rgba(15,23,42,0.78));
}
.tools-hero-icon {
  background: linear-gradient(135deg, rgba(249,115,22,0.22), rgba(251,146,60,0.08));
  border: 1px solid rgba(249,115,22,0.2);
}
.tool-empty {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(15,23,42,0.55);
  color: #94a3b8;
  font-size: 12px;
  border: 1px dashed rgba(148,163,184,0.2);
}
.tool-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 7px 12px;
  border: 1px solid rgba(249,115,22,0.28);
  border-radius: 12px;
  background: rgba(249,115,22,0.1);
  color: #fdba74;
  font-size: 11px;
  font-weight: 900;
}
.tool-action:hover,
.tool-action:focus-visible {
  background: rgba(249,115,22,0.18);
  border-color: rgba(249,115,22,0.5);
  color: #fed7aa;
}
body[data-route-state="empty"] #ride-status-card,
body[data-route-state="analyzing"] #ride-status-card,
body[data-route-state="empty"] #route-conditions-panel,
body[data-route-state="analyzing"] #route-conditions-panel,
body[data-route-state="empty"] #route-camera-strip,
body[data-route-state="analyzing"] #route-camera-strip {
  display: none !important;
}
.tool-check-item,
.favorite-item {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(15,23,42,0.58);
  border: 1px solid rgba(255,255,255,0.06);
}
.tool-check-item + .tool-check-item,
.favorite-item + .favorite-item {
  margin-top: 8px;
}
.tool-check-title,
.favorite-title {
  font-size: 12px;
  color: #f8fafc;
  font-weight: 800;
}
.tool-check-sub,
.favorite-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
  line-height: 1.45;
}
.risk-chip,
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: #cbd5e1;
}
.risk-chip.warn {
  color: #fdba74;
  border-color: rgba(249,115,22,0.25);
  background: rgba(249,115,22,0.08);
}
.risk-chip.good {
  color: #86efac;
  border-color: rgba(34,197,94,0.22);
  background: rgba(34,197,94,0.08);
}
.favorite-action,
.card-favorite-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
}
.favorite-action.active,
.card-favorite-btn.active {
  color: #67e8f9;
  border-color: rgba(103,232,249,0.28);
  background: rgba(34,211,238,0.08);
}
.cam-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cam-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

body.light .ride-status-shell,
body.light .tools-hero-shell {
  background:
    radial-gradient(circle at top right, rgba(249,115,22,0.12), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.86));
}
body.light .ride-metric-card,
body.light .tool-check-item,
body.light .favorite-item,
body.light .tool-empty {
  background: rgba(255,255,255,0.92);
  border-color: rgba(148,163,184,0.18);
}
body.light .ride-metric-value,
body.light .tool-check-title,
body.light .favorite-title {
  color: #0f172a;
}
body.light .ride-inline-note {
  background: rgba(249,115,22,0.09);
  color: #c2410c;
}
body.light .map-legend-item,
body.light .meta-chip,
body.light .risk-chip {
  color: #475569;
}

/* info-panel 縮圖 */
#info-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
  display: none;
}
#info-thumb.visible { display: block; }
#info-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
}
#info-thumb .ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #475569; font-size: 24px;
}

/* 診斷狀態面板 */
#diag-panel {
  position: fixed;
  top: calc(var(--safe-top) + 3.5rem);
  left: 8px;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  color: #10b981;
  font-family: monospace;
  font-size: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(16,185,129,0.4);
  max-width: 280px;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
  display: none;
}
#diag-panel.visible { display: block; }
#diag-panel .diag-err { color: #ef4444; }
#diag-panel .diag-warn { color: #f59e0b; }
#diag-panel .diag-info { color: #60a5fa; }
#diag-panel .diag-close {
  float: right;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  margin-left: 6px;
  margin-top: -2px;
}

/* 地名建議下拉 */
.suggest-box { display:none; }
.suggest-box.visible { display:block; }
.route-suggest-box {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  box-shadow: 0 16px 32px rgba(0,0,0,0.32);
}
.list-chip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.ride-route-chip {
  border: 1px solid rgba(249,115,22,0.14);
  background: linear-gradient(180deg, rgba(249,115,22,0.14), rgba(15,23,42,0.38));
  color: #fed7aa;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.18s ease;
}
.ride-route-chip:active,
.ride-route-chip:hover {
  background: rgba(249,115,22,0.2);
  border-color: rgba(249,115,22,0.26);
  color: #fff7ed;
}
.suggest-group {
  padding: 8px 0 2px;
}
.suggest-group + .suggest-group {
  border-top: 1px solid rgba(255,255,255,0.05);
}
.suggest-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.suggest-item {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 11px;
  color: #cbd5e1;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active,
.suggest-item.is-active { background: rgba(249,115,22,0.15); }
.suggest-item .suggest-icon { color: #f97316; font-size: 10px; flex-shrink: 0; }
.suggest-item .suggest-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; }
.suggest-item .suggest-sub { color: #64748b; font-size: 10px; flex-shrink:0; }
.suggest-item[data-type="camera"] .suggest-icon { color: #38bdf8; }
.suggest-item[data-type="route"] .suggest-icon { color: #fb923c; }
.suggest-item[data-type="place"] .suggest-icon { color: #a78bfa; }

/* 路線解析按鈕動畫 */
.route-shell.route-shell-collapsed,
.route-shell.route-shell-expanded {
  background:
    radial-gradient(circle at top right, rgba(249,115,22,0.18), transparent 34%),
    linear-gradient(180deg, rgba(15,23,42,0.88), rgba(15,23,42,0.72));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 34px rgba(0,0,0,0.24);
}
.route-shell-icon {
  width: 38px;
  height: 38px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(249,115,22,0.24), rgba(249,115,22,0.08));
  border: 1px solid rgba(249,115,22,0.2);
}
.route-mini-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 6px 10px;
  transition: all 0.18s ease;
}
.route-mini-btn:hover {
  background: rgba(249,115,22,0.12);
  border-color: rgba(249,115,22,0.24);
}
.route-input-card {
  background: linear-gradient(180deg, rgba(15,23,42,0.78), rgba(15,23,42,0.64));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
}
.route-point-badge {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.route-point-start { background: linear-gradient(135deg, #22c55e, #16a34a); }
.route-point-end { background: linear-gradient(135deg, #ef4444, #dc2626); }
.route-text-input {
  background: linear-gradient(180deg, rgba(15,23,42,0.76), rgba(15,23,42,0.58));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  color: #e2e8f0;
}
.route-text-input:focus {
  border-color: rgba(249,115,22,0.45);
  box-shadow: 0 0 0 2px rgba(249,115,22,0.12);
}
.route-action-btn {
  background: linear-gradient(135deg, #fb923c, #f97316);
  box-shadow: 0 14px 24px rgba(249,115,22,0.26);
}
.route-action-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}
#js-route-btn.loading {
  background: linear-gradient(90deg, #c2410c, #ea580c, #c2410c);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
body.light .route-shell.route-shell-collapsed,
body.light .route-shell.route-shell-expanded {
  background:
    radial-gradient(circle at top right, rgba(249,115,22,0.14), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.84));
  box-shadow: 0 16px 30px rgba(148,163,184,0.18);
}
body.light .route-mini-btn,
body.light .route-input-card,
body.light .route-text-input {
  background: rgba(255,255,255,0.88);
  border-color: rgba(148,163,184,0.24);
  color: #334155;
}

/* === v2 route safety and condition timeline === */
.route-vehicle-shell {
  padding: 10px;
  border-radius: 20px;
  background: rgba(8, 16, 34, 0.58);
  border: 1px solid rgba(255,255,255,0.07);
}
.route-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 900;
}
.route-option-head span:last-child {
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  text-align: right;
}
.route-plate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.route-mode-btn {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(30,41,59,0.72);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.route-mode-btn:active { transform: scale(0.97); }
.route-advanced {
  margin-top: 8px;
  color: #64748b;
  font-size: 10px;
}
.route-advanced summary {
  cursor: pointer;
  user-select: none;
}
.route-car-btn {
  width: 100%;
  margin-top: 8px;
}
.route-collapse-btn {
  width: auto;
  margin: 0;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.route-conditions-panel {
  position: absolute;
  right: 1rem;
  bottom: calc(var(--safe-bottom) + 5.4rem);
  z-index: 850;
  width: min(430px, calc(100vw - 2rem));
  max-height: min(70dvh, 670px);
  overflow: hidden;
  border-radius: 28px;
  background:
    radial-gradient(circle at 90% 0%, rgba(34,211,238,0.14), transparent 30%),
    linear-gradient(180deg, rgba(6,13,31,0.96), rgba(9,18,38,0.93));
  border-color: rgba(103,232,249,0.18);
  box-shadow: 0 28px 70px rgba(2,8,23,0.62);
  animation: conditionRise 320ms cubic-bezier(.2,.8,.2,1);
}
@keyframes conditionRise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.condition-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.condition-panel-head > :first-child {
  min-width: 0;
}
.condition-kicker {
  color: #67e8f9;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.condition-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.condition-title-row h2 {
  color: #f8fafc;
  font-size: 14px;
  font-weight: 900;
}
.condition-source-badge {
  padding: 3px 7px;
  border-radius: 999px;
  color: #a5f3fc;
  background: rgba(34,211,238,0.1);
  border: 1px solid rgba(34,211,238,0.18);
  font-size: 9px;
  font-weight: 900;
}
.condition-source-badge.demo {
  color: #fde68a;
  background: rgba(245,158,11,0.11);
  border-color: rgba(245,158,11,0.24);
}
.condition-source-badge.error {
  color: #fecaca;
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.24);
}
.condition-collapsed-summary {
  display: none;
  max-width: min(42vw, 10rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fdba74;
  background: rgba(249,115,22,0.1);
  border: 1px solid rgba(249,115,22,0.2);
  font-size: 9px;
  font-weight: 900;
}
.condition-collapsed-summary.danger {
  color: #fecaca;
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.24);
}
.condition-sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.condition-head-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}
.condition-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  color: #cbd5e1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.condition-icon-btn.loading i { animation: spin 1s linear infinite; }
.condition-demo-warning {
  margin: 10px 12px 0;
  padding: 9px 11px;
  border-radius: 14px;
  color: #fde68a;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.45;
}
.condition-loading {
  padding: 16px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 8px;
}
.condition-loading.hidden {
  display: none;
}
.condition-skeleton {
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(51,65,85,0.45), rgba(100,116,139,0.28), rgba(51,65,85,0.45));
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}
#condition-content {
  padding: 12px 14px 14px;
  max-height: calc(min(70dvh, 670px) - 65px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.condition-overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.condition-metric {
  min-width: 0;
  padding: 8px 5px;
  border-radius: 14px;
  text-align: center;
  background: rgba(15,23,42,0.7);
  border: 1px solid rgba(255,255,255,0.06);
}
.condition-metric span {
  display: block;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
}
.condition-metric strong {
  display: block;
  margin-top: 3px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.condition-metric.rain strong { color: #7dd3fc; }
.condition-metric.danger strong { color: #fca5a5; }
.condition-metric.warning strong { color: #fde68a; }
.condition-metric.coverage strong { color: #86efac; }
.condition-update-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px 7px;
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
}
#condition-validation { color: #86efac; }
.condition-alerts {
  display: grid;
  gap: 7px;
  margin: 5px 0 10px;
}
.condition-alert {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  border-radius: 14px;
  color: #fecaca;
  background: rgba(239,68,68,0.09);
  border: 1px solid rgba(239,68,68,0.18);
  font-size: 10px;
  font-weight: 800;
  min-height: 44px;
}
.condition-alert.weather {
  color: #bae6fd;
  background: rgba(14,165,233,0.09);
  border-color: rgba(14,165,233,0.2);
}
.condition-alert.warning {
  color: #fde68a;
  background: rgba(245,158,11,0.09);
  border-color: rgba(245,158,11,0.2);
}
.road-event-accident {
  --road-event-color: #fb7185;
  --road-event-bg: rgba(244,63,94,0.1);
  --road-event-border: rgba(251,113,133,0.26);
}
.road-event-construction {
  --road-event-color: #fbbf24;
  --road-event-bg: rgba(245,158,11,0.1);
  --road-event-border: rgba(251,191,36,0.25);
}
.road-event-congestion {
  --road-event-color: #f87171;
  --road-event-bg: rgba(239,68,68,0.09);
  --road-event-border: rgba(248,113,113,0.24);
}
.road-event-control {
  --road-event-color: #c4b5fd;
  --road-event-bg: rgba(139,92,246,0.1);
  --road-event-border: rgba(167,139,250,0.26);
}
.road-event-weather {
  --road-event-color: #7dd3fc;
  --road-event-bg: rgba(14,165,233,0.1);
  --road-event-border: rgba(56,189,248,0.25);
}
.road-event-disaster {
  --road-event-color: #fda4af;
  --road-event-bg: rgba(225,29,72,0.11);
  --road-event-border: rgba(251,113,133,0.28);
}
.road-event-activity {
  --road-event-color: #67e8f9;
  --road-event-bg: rgba(6,182,212,0.09);
  --road-event-border: rgba(34,211,238,0.24);
}
.road-event-hazard {
  --road-event-color: #fdba74;
  --road-event-bg: rgba(249,115,22,0.1);
  --road-event-border: rgba(251,146,60,0.26);
}
.road-event-other {
  --road-event-color: #cbd5e1;
  --road-event-bg: rgba(100,116,139,0.1);
  --road-event-border: rgba(148,163,184,0.22);
}
.road-impact-full_closure {
  --road-event-color: #fca5a5;
  --road-event-bg: rgba(220,38,38,0.14);
  --road-event-border: rgba(248,113,113,0.36);
}
.road-impact-lane_closure {
  --road-event-color: #fda4af;
  --road-event-bg: rgba(225,29,72,0.11);
  --road-event-border: rgba(251,113,133,0.28);
}
.road-impact-controlled {
  --road-event-color: #c4b5fd;
  --road-event-bg: rgba(124,58,237,0.1);
  --road-event-border: rgba(167,139,250,0.28);
}
.road-impact-shoulder {
  --road-event-color: #fde68a;
  --road-event-bg: rgba(202,138,4,0.09);
  --road-event-border: rgba(250,204,21,0.22);
}
.road-impact-no_impact {
  --road-event-color: #86efac;
  --road-event-bg: rgba(34,197,94,0.08);
  --road-event-border: rgba(74,222,128,0.2);
}
.condition-alert.road-event {
  color: var(--road-event-color, #fde68a);
  background: var(--road-event-bg, rgba(245,158,11,0.09));
  border-color: var(--road-event-border, rgba(245,158,11,0.2));
}
.condition-alert.road-event.is-scheduled {
  border-style: dashed;
}
.condition-alert.road-event.is-approximate {
  border-style: dotted;
}
.condition-nav-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 11px;
}
.condition-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 14px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  text-decoration: none;
}
.condition-nav-btn.is-disabled { pointer-events: none; opacity: 0.5; }
.condition-nav-btn.google { background: linear-gradient(135deg, #16a34a, #15803d); }
.condition-nav-btn.apple { background: linear-gradient(135deg, #334155, #0f172a); border: 1px solid rgba(255,255,255,0.1); }
.apple-leg-links {
  margin: -3px 0 11px;
  padding: 9px;
  border-radius: 14px;
  color: #94a3b8;
  background: rgba(15,23,42,0.68);
  border: 1px solid rgba(255,255,255,0.07);
  font-size: 9px;
}
.apple-leg-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}
.apple-leg-button {
  padding: 6px 9px;
  border-radius: 999px;
  color: #e2e8f0;
  background: rgba(255,255,255,0.07);
  font-weight: 800;
}
.condition-timeline {
  position: relative;
  display: grid;
  gap: 8px;
}
.condition-section {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  padding: 10px;
  text-align: left;
  border-radius: 17px;
  background: rgba(15,23,42,0.62);
  border: 1px solid rgba(255,255,255,0.065);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.condition-section-body {
  min-width: 0;
}
.condition-section:hover,
.condition-section.active {
  transform: translateY(-1px);
  border-color: rgba(103,232,249,0.28);
  background: rgba(15,23,42,0.88);
}
.condition-section:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: 2px;
}
.condition-section.has-road-event {
  border-left: 3px solid var(--road-event-color, #f59e0b);
  background:
    linear-gradient(90deg, var(--road-event-bg, rgba(245,158,11,0.09)), transparent 42%),
    rgba(15,23,42,0.68);
}
.condition-section.has-scheduled-event {
  border-left-style: dashed;
}
.condition-order {
  width: 27px;
  height: 27px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #64748b;
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 0 14px rgba(100,116,139,0.28);
}
.condition-section[data-level="clear"] .condition-order { background: #16a34a; box-shadow: 0 0 14px rgba(34,197,94,0.3); }
.condition-section[data-level="slow"] .condition-order { background: #ca8a04; box-shadow: 0 0 14px rgba(250,204,21,0.26); }
.condition-section[data-level="congested"] .condition-order { background: #dc2626; box-shadow: 0 0 14px rgba(239,68,68,0.32); }
.condition-section-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 900;
}
.condition-section-km {
  color: #64748b;
  font-size: 9px;
  white-space: nowrap;
}
.condition-section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.condition-data-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 9px;
  font-weight: 700;
}
.condition-data-chip.unknown { color: #94a3b8; }
.condition-road-events {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.condition-road-event {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 13px;
  color: var(--road-event-color, #fde68a);
  background: var(--road-event-bg, rgba(245,158,11,0.09));
  border: 1px solid var(--road-event-border, rgba(245,158,11,0.2));
}
.condition-road-event.is-scheduled {
  border-style: dashed;
}
.condition-road-event.is-approximate {
  border-style: dotted;
}
.condition-road-event-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  border-radius: 10px;
  color: var(--road-event-color, #fde68a);
  background: rgba(2,6,23,0.24);
}
.condition-road-event-body {
  display: grid;
  min-width: 0;
}
.condition-road-event-body strong {
  color: var(--road-event-color, #fde68a);
  font-size: 10px;
  font-weight: 900;
}
.condition-road-event-description {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  color: #cbd5e1;
  font-size: 9px;
  line-height: 1.45;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.condition-road-event-meta {
  margin-top: 4px;
  color: #64748b;
  font-size: 8px;
  font-weight: 800;
}
.condition-road-event-more {
  padding: 2px 7px;
  color: #94a3b8;
  font-size: 9px;
  font-weight: 800;
}
.condition-camera-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}
.condition-camera-button {
  color: #67e8f9;
  font-size: 9px;
  font-weight: 800;
}
.condition-footnote {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 13px;
  color: #64748b;
  background: rgba(2,6,23,0.32);
  font-size: 9px;
  line-height: 1.5;
}

/* Keep secondary route facts readable against the dark timeline cards. */
body:not(.light) .apple-leg-links,
body:not(.light) .condition-footnote {
  color: var(--ui-text-muted);
}
body:not(.light) .condition-section-km,
body:not(.light) .condition-road-event-meta,
body:not(.light) .condition-metric span,
body:not(.light) .condition-update-row {
  color: var(--ui-text-subtle);
}
body:not(.light) .condition-data-chip,
body:not(.light) .condition-road-event-description {
  color: var(--ui-text-secondary);
}
body:not(.light) .condition-data-chip.unknown,
body:not(.light) .condition-road-event-more {
  color: var(--ui-text-muted);
}
body:not(.light) .condition-kicker,
body:not(.light) .condition-source-badge,
body:not(.light) .condition-collapsed-summary {
  text-shadow: 0 0 1px rgba(255,255,255,0.08);
}
.condition-error {
  padding: 18px 16px;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
.condition-error button {
  margin-left: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: #ea580c;
}
.route-conditions-panel.is-collapsed {
  max-height: 64px;
}
.route-conditions-panel.is-collapsed .condition-panel-head {
  min-height: 62px;
  padding: 10px 12px;
}
.route-conditions-panel.is-collapsed .condition-kicker,
.route-conditions-panel.is-collapsed .condition-title-row h2,
.route-conditions-panel.is-collapsed #condition-refresh {
  display: none;
}
.route-conditions-panel.is-collapsed .condition-title-row {
  margin-top: 0;
}
.route-conditions-panel.is-collapsed .condition-source-badge {
  display: none;
}
.route-conditions-panel.is-collapsed .condition-collapsed-summary {
  display: inline-flex;
}
.route-conditions-panel.is-collapsed > :not(.condition-panel-head) {
  display: none !important;
}
.route-weather-pin {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: #e0f2fe;
  background: rgba(2,132,199,0.9);
  border: 2px solid rgba(255,255,255,0.88);
  box-shadow: 0 7px 18px rgba(2,132,199,0.45);
}
.camera-source-link {
  display: block;
  margin-top: 8px;
  color: #f97316;
  font-size: 10px;
}
.map-legend-dot.traffic-clear { background: #22c55e; box-shadow: 0 0 5px #22c55e; }
.map-legend-dot.traffic-slow { background: #facc15; box-shadow: 0 0 5px #facc15; }
.map-legend-dot.traffic-congested { background: #ef4444; box-shadow: 0 0 5px #ef4444; }
.map-legend-dot.traffic-unknown { background: #94a3b8; box-shadow: 0 0 5px #94a3b8; }
.map-legend-weather { width: 10px; color: #38bdf8; font-size: 9px; }
.map-legend-incident {
  width: 22px;
  height: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b 0 34%, #f43f5e 34% 67%, #8b5cf6 67%);
  box-shadow: 0 0 0 2px rgba(15,23,42,0.7), 0 2px 7px rgba(15,23,42,0.45);
}
.route-incident-pin {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 11px;
  color: #fff;
  background: var(--road-event-color, #f59e0b);
  border: 2px solid rgba(255,255,255,0.92);
  box-shadow: 0 8px 20px rgba(2,8,23,0.38);
  font-size: 10px;
  font-weight: 900;
}
.route-incident-pin.is-scheduled {
  color: var(--road-event-color, #f59e0b);
  background: rgba(15,23,42,0.94);
  border-style: dashed;
}

body.light .route-vehicle-shell,
body.light .condition-metric,
body.light .condition-section,
body.light .apple-leg-links {
  background: rgba(255,255,255,0.9);
  border-color: rgba(148,163,184,0.2);
}
body.light .route-conditions-panel {
  background:
    radial-gradient(circle at 90% 0%, rgba(14,165,233,0.12), transparent 30%),
    linear-gradient(180deg, rgba(248,250,252,0.97), rgba(241,245,249,0.96));
  border-color: rgba(14,165,233,0.2);
  box-shadow: 0 24px 60px rgba(100,116,139,0.32);
}
body.light .condition-title-row h2,
body.light .condition-section-title,
body.light .condition-metric strong,
body.light .route-option-head {
  color: #0f172a;
}
body.light .condition-section:hover,
body.light .condition-section.active {
  background: #fff;
}
body.light .condition-data-chip {
  color: #475569;
  background: rgba(15,23,42,0.04);
  border-color: rgba(148,163,184,0.18);
}
body.light .condition-section.has-road-event {
  background:
    linear-gradient(90deg, var(--road-event-bg, rgba(245,158,11,0.08)), transparent 46%),
    rgba(255,255,255,0.94);
}
body.light .condition-road-event-description {
  color: #334155;
}
body.light .condition-road-event-meta {
  color: #64748b;
}
body.light .condition-road-event-icon {
  background: rgba(255,255,255,0.7);
}

@media (max-width: 640px) {
  .map-top-panel {
    top: calc(var(--safe-top) + 2.8rem);
    left: 0.65rem;
    right: 0.65rem;
  }
  /* 手機版頂部收納：隱藏副標、壓縮 verdict bar，減少地圖被擠壓 */
  .brand-copy small { display: none; }
  .brand-copy { gap: 0; }
  #ride-verdict-bar { padding: 0.45rem 0.7rem; border-radius: 18px; }
  #ride-verdict-bar .ride-verdict-sub { display: none; }
  #ride-verdict-bar .ride-verdict-headline { font-size: 0.8rem; }
  #route-collapsed { padding: 0.5rem 0.7rem; border-radius: 18px; margin-top: 0.4rem; }
  #route-expanded.route-shell-expanded {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 7rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px;
    border-radius: 22px;
  }
  #route-expanded.route-shell-expanded > :not([hidden]) ~ :not([hidden]) {
    margin-top: 8px;
  }
  .route-expanded-head {
    min-height: 28px;
    padding-inline: 2px;
  }
  .route-title-kicker,
  .route-option-head span:last-child {
    display: none;
  }
  .route-title-text {
    font-size: 13px;
  }
  .route-head-actions {
    gap: 5px;
  }
  #history-count {
    display: none;
  }
  .route-mini-btn,
  .route-collapse-btn {
    min-height: 28px;
    padding: 5px 8px;
  }
  .route-input-card {
    min-height: 38px;
    padding: 6px 9px;
    border-radius: 14px;
  }
  .route-point-row {
    gap: 7px;
  }
  .route-point-badge {
    width: 22px;
    height: 22px;
  }
  .route-text-input {
    min-height: 36px;
    padding: 6px 28px 6px 10px;
    border-radius: 13px;
  }
  .route-vehicle-shell {
    padding: 8px;
    border-radius: 16px;
  }
  .route-option-head {
    margin-bottom: 6px;
    font-size: 10px;
  }
  .route-plate-grid {
    gap: 5px;
  }
  .route-mode-btn {
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 12px;
  }
  .route-advanced {
    margin-top: 6px;
    line-height: 1.2;
  }
  .route-car-btn {
    margin-top: 6px;
  }
  .route-action-btn {
    min-height: 44px;
    padding-block: 8px;
    border-radius: 14px;
    box-shadow: 0 10px 20px rgba(249,115,22,0.22);
  }
  #route-expanded:not(.hidden) ~ #ride-status-card {
    display: none;
  }
  #pg-map:has(#route-conditions-panel:not(.hidden):not(.is-collapsed)) #ride-status-card {
    display: none;
  }
  body[data-route-state="ready"] .map-top-panel {
    width: min(calc(100vw - 1.3rem), 340px);
    right: auto;
  }
  body[data-route-state="ready"] #route-collapsed {
    min-height: 44px;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 18px;
  }
  body[data-route-state="ready"] #route-collapsed .route-shell-icon {
    width: 30px;
    height: 30px;
    border-radius: 12px;
  }
  body[data-route-state="ready"] #route-paste-input,
  body[data-route-state="ready"] #js-route-status,
  body[data-route-state="ready"] #js-route-banner,
  body[data-route-state="ready"] #ride-status-card {
    display: none !important;
  }
  body[data-route-state="ready"] #route-summary {
    display: block !important;
    margin-top: 0;
    font-size: 10px;
    line-height: 1.25;
  }
  body[data-route-state="ready"] #route-toggle {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 10px;
  }
  body[data-route-state="ready"] #js-route-clear-small {
    min-width: 24px;
    min-height: 24px;
  }
  #js-route-status {
    margin-top: 4px;
    padding-inline: 8px;
    border-radius: 10px;
    line-height: 1.35;
  }
  #js-route-status:empty {
    display: none;
  }
  .ride-status-shell {
    margin-top: 8px;
    padding: 8px;
    border-radius: 18px;
    box-shadow: 0 12px 26px rgba(2,8,23,0.28);
  }
  .ride-status-head {
    min-height: 28px;
    padding-inline: 2px;
  }
  .ride-status-kicker {
    display: none;
  }
  .ride-status-title {
    font-size: 13px;
    line-height: 1.2;
  }
  #js-open-favorites {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 10px;
  }
  .ride-status-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr) minmax(0, 1.25fr) minmax(0, 0.7fr);
    gap: 0;
    margin-top: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 13px;
    background: rgba(15,23,42,0.5);
  }
  .ride-metric-card {
    min-width: 0;
    min-height: 48px;
    padding: 6px 7px;
    justify-content: center;
    border: 0;
    border-right: 1px solid rgba(255,255,255,0.07);
    border-radius: 0;
    background: transparent;
    gap: 2px;
  }
  .ride-metric-card:last-child {
    border-right: 0;
  }
  .ride-metric-label {
    overflow: hidden;
    font-size: 8px;
    line-height: 1.15;
    letter-spacing: 0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ride-metric-value {
    display: -webkit-box;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .ride-inline-note {
    min-height: 30px;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 11px;
    font-size: 10px;
    line-height: 1.35;
  }
  body.light .ride-status-grid {
    background: rgba(255,255,255,0.68);
    border-color: rgba(148,163,184,0.18);
  }
  body.light .ride-metric-card {
    background: transparent;
    border-color: rgba(148,163,184,0.18);
  }
  .map-control-stack {
    left: 0.75rem;
    bottom: calc(var(--safe-bottom) + 4.55rem);
    gap: 8px;
  }
  .map-control-stack > button {
    width: 40px;
    height: 40px;
  }
  .bottom-navigation {
    padding-top: 6px;
    padding-bottom: calc(var(--safe-bottom) + 4px);
    border-radius: 24px 24px 0 0;
  }
  .bottom-navigation .nav-it {
    gap: 0;
  }
  .bottom-navigation .nav-it > div {
    width: 42px;
    height: 26px;
  }
  .bottom-navigation .nav-it i {
    font-size: 16px;
  }
  .bottom-navigation .nav-it span {
    font-size: 9px;
    letter-spacing: 0.08em;
  }
  .map-legend {
    min-width: 0;
    right: 0.65rem;
    bottom: calc(var(--safe-bottom) + 4.55rem);
    padding: 6px 8px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .map-legend-title,
  .map-legend-item {
    display: none;
  }
  .map-legend-item:has(.traffic-unknown) {
    display: flex;
    gap: 5px;
    margin: 0;
    font-size: 9px;
  }
  .map-legend-item.has-events:has(.map-legend-incident) {
    display: flex;
    gap: 5px;
    margin: 0;
    font-size: 9px;
  }
  .map-legend-dot.traffic-unknown {
    width: 8px;
    height: 8px;
  }
  .condition-road-event {
    grid-template-columns: 26px minmax(0, 1fr);
    padding: 7px;
  }
  .condition-road-event-icon {
    width: 26px;
    height: 26px;
  }
  #pg-list {
    scroll-padding-top: calc(var(--safe-top) + 4rem);
    scroll-padding-bottom: calc(var(--safe-bottom) + 6rem);
  }
  #pg-list .list-filter-shell {
    position: relative;
    top: auto;
    z-index: 1;
  }
  .cam-card {
    scroll-margin-top: calc(var(--safe-top) + 4rem);
    scroll-margin-bottom: calc(var(--safe-bottom) + 6rem);
  }
  .favorite-action,
  .card-favorite-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
  }
  .route-conditions-panel {
    left: 0.65rem;
    right: 0.65rem;
    bottom: calc(var(--safe-bottom) + 5.15rem);
    width: auto;
    max-height: 55dvh;
    border-radius: 24px;
  }
  .route-conditions-panel.is-collapsed {
    left: auto;
    width: auto;
    max-width: calc(100vw - 5rem);
    max-height: 50px;
    border-radius: 18px;
  }
  .route-conditions-panel.is-collapsed .condition-panel-head {
    min-height: 48px;
    gap: 8px;
    padding: 6px 8px 6px 10px;
  }
  .route-conditions-panel.is-collapsed .condition-head-actions {
    gap: 4px;
  }
  .route-conditions-panel.is-collapsed .condition-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 11px;
  }
  .route-conditions-panel.is-collapsed .condition-collapsed-summary {
    max-width: min(44vw, 11rem);
  }
  #condition-content {
    max-height: calc(55dvh - 62px);
  }
  .condition-overview-grid {
    grid-template-columns: repeat(5, minmax(54px, 1fr));
    overflow-x: auto;
    padding-bottom: 3px;
  }
}

/* The compact brand wraps to two lines on very narrow devices. Keep the
   route shell below that taller header so its toggle remains tappable. */
@media (max-width: 360px) {
  .map-top-panel {
    top: calc(var(--safe-top) + 4.5rem);
  }
}

@media (hover: none) {
  .cam-card:hover {
    transform: none;
  }
}

/* === Desktop command center (>=1200px) === */
.desktop-only-header,
.desktop-only-panel,
.desktop-disclaimer,
#desktop-map,
#desktop-map-tools,
.desktop-resizer,
.desktop-condition-info-toggle {
  display: none;
}

/* Desktop controls are intentionally absent from the compact mobile header. */
.desktop-header-action {
  display: none;
}

@media (min-width: 1200px) {
  :root {
    --desktop-header-height: 4.55rem;
    /* The desktop disclaimer is an overlay, so it must not reserve a footer row. */
    --desktop-footer-height: 0rem;
    --desktop-left-rail: 18.5rem;
    --desktop-right-rail: 15rem;
    --desktop-bottom-rail: 17.4rem;
    --desktop-gap: 0.55rem;
    --desktop-border: rgba(148,163,184,0.18);
    --desktop-surface: rgba(10,19,30,0.92);
  }

  body {
    overflow: hidden;
    background: #07111b;
  }

  header {
    height: var(--desktop-header-height);
    padding: 0 1.1rem !important;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(148,163,184,0.16);
    background: rgba(7,17,27,0.96) !important;
    backdrop-filter: blur(18px);
  }

  header > div:first-child {
    max-width: none !important;
    width: 100%;
    gap: 1.4rem;
  }

  header h1 {
    font-size: 0.95rem !important;
    letter-spacing: -0.03em;
    white-space: nowrap;
  }

  .brand-mark { background: #1f9d62 !important; box-shadow: 0 8px 18px rgba(31,157,98,.26) !important; }
  .brand-mark i { color: #f0fdf4 !important; }
  .brand-copy { display: flex; flex-direction: column; gap: .18rem; min-width: 0; }
  .brand-copy small { color: #86a79b; font-size: .53rem; font-weight: 700; line-height: 1; white-space: nowrap; }

  header .w-7.h-7 {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.7rem;
  }

  header > div:first-child > div:first-child {
    flex-shrink: 0;
    padding-right: 1.2rem;
    border-right: 1px solid rgba(148,163,184,0.2);
  }

  .desktop-only-header {
    display: flex;
    align-items: center;
    gap: 1.35rem;
    min-width: 0;
    flex: 1;
  }

  .desktop-header-route-copy {
    display: flex;
    flex-direction: column;
    min-width: 9rem;
    max-width: 17rem;
  }

  .desktop-header-route-label {
    color: #f8fafc;
    font-size: 1.05rem;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .desktop-header-route-meta {
    color: #94a3b8;
    font-size: 0.68rem;
    margin-top: 0.16rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .desktop-vehicle-tabs {
    display: flex;
    min-width: 0;
    border: 1px solid rgba(148,163,184,0.22);
    border-radius: 0.45rem;
    overflow: hidden;
    background: rgba(15,23,42,0.7);
  }

  .desktop-vehicle-tab {
    min-height: 2.35rem;
    padding: 0 1rem;
    color: #cbd5e1;
    background: transparent;
    border: 0;
    border-right: 1px solid rgba(148,163,184,0.15);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
    transition: background .18s, color .18s;
  }

  .desktop-vehicle-tab:last-child { border-right: 0; }
  .desktop-vehicle-tab:hover { background: rgba(255,255,255,0.07); color: #fff; }
  .desktop-vehicle-tab.active { background: #145c47; color: #ecfdf5; box-shadow: inset 0 -2px 0 #52b788; }

  .desktop-header-action {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    min-height: 2.2rem;
    padding: 0 0.65rem;
    color: #e2e8f0;
    background: transparent;
    border: 0;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .desktop-header-action:hover,
  .desktop-header-action:focus-visible { color: #86efac; }

  #desktop-settings-toggle { border-left: 1px solid rgba(148,163,184,0.16); padding-left: 1rem; }
  #desktop-favorites-toggle { border-left: 1px solid rgba(148,163,184,0.16); padding-left: 1rem; }
  header #js-theme { display: none; }
  header .ui-clock-wrap { margin-left: auto; }
  header .ui-clock-wrap .ui-dismiss-btn { color: #cbd5e1; font-size: 0.8rem; }
  header .ui-clock-wrap .ui-dismiss-btn i { display: none; }

  .desktop-settings-popover {
    position: absolute;
    top: calc(var(--desktop-header-height) - 0.35rem);
    right: 5.2rem;
    z-index: 1600;
    width: 15rem;
    padding: 0.65rem;
    border: 1px solid var(--desktop-border);
    border-radius: 0.55rem;
    background: rgba(10,19,30,0.98);
    box-shadow: 0 18px 40px rgba(0,0,0,0.38);
  }

  .desktop-settings-title {
    padding: 0.35rem 0.45rem 0.55rem;
    color: #94a3b8;
    font-size: 0.64rem;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
  }

  .desktop-settings-row,
  .desktop-settings-link {
    width: 100%;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.38rem 0.45rem;
    color: #e2e8f0;
    background: transparent;
    border: 0;
    text-align: left;
    font-size: 0.72rem;
  }

  .desktop-settings-row span:last-child { color: #86efac; font-size: 0.65rem; }
  .desktop-settings-row:hover,
  .desktop-settings-link:hover { background: rgba(255,255,255,0.06); }
  .desktop-settings-link { margin-top: 0.25rem; color: #86efac; border-top: 1px solid rgba(148,163,184,0.13); padding-top: 0.6rem; }

  main {
    margin-top: var(--desktop-header-height) !important;
    height: calc(100dvh - var(--desktop-header-height));
    flex: none;
    overflow: hidden;
  }

  .desktop-disclaimer {
    position: fixed;
    left: 50%;
    bottom: .28rem;
    z-index: 1450;
    width: min(90vw, 58rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 0;
    padding: .16rem .55rem;
    transform: translateX(-50%);
    color: var(--ui-text-subtle);
    background: rgba(10,19,30,.9);
    border: 1px solid rgba(148,163,184,.2);
    background: color-mix(in srgb, var(--ui-bg) 84%, transparent);
    border-color: color-mix(in srgb, var(--ui-border) 72%, transparent);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0,0,0,.16);
    font-size: .5rem;
    line-height: 1.25;
    text-align: center;
    pointer-events: none;
    opacity: .82;
  }
  .desktop-disclaimer i { flex: 0 0 auto; color: #facc15; }

  #pg-map.active {
    display: grid !important;
    grid-template-columns: var(--desktop-left-rail) minmax(30rem, 1fr) var(--desktop-right-rail);
    grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail);
    gap: var(--desktop-gap);
    padding: var(--desktop-gap) var(--desktop-gap) 0;
    position: absolute !important;
    inset: 0;
    background: #07111b;
  }

  #map,
  #desktop-map {
    grid-column: 2;
    grid-row: 1;
    position: relative !important;
    inset: auto !important;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.23);
    border-radius: 0.45rem;
    background: #0b1722;
  }

  #map { display: none; z-index: 1; }
  #desktop-map { display: block; z-index: 2; }
  body.desktop-legacy-map #desktop-map { display: none; }
  body.desktop-legacy-map #map { display: block; }
  /* Static graceful-degradation notice when WebGL2 is unavailable
     (no second map stack is maintained). */
  .map-degraded-notice {
    position: absolute; inset: 0; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem; pointer-events: none;
  }
  .map-degraded-card {
    pointer-events: auto;
    max-width: 22rem; text-align: center;
    background: rgba(15,23,42,0.92);
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  }
  .map-degraded-title { color: #f1f5f9; font-weight: 800; font-size: 1rem; margin-bottom: 0.5rem; }
  .map-degraded-desc { color: #94a3b8; font-size: 0.82rem; line-height: 1.6; }
  .maplibregl-ctrl-group { background: rgba(10,19,30,0.88); border: 1px solid rgba(148,163,184,0.25); }
  .maplibregl-ctrl-group button { filter: invert(.9) hue-rotate(80deg); }
  .maplibregl-ctrl-attrib { background: rgba(7,17,27,0.78) !important; color: #94a3b8; font-size: 0.58rem; }
  .maplibregl-ctrl-attrib a { color: #cbd5e1; }

  .map-top-panel {
    grid-column: 1;
    grid-row: 1;
    position: relative !important;
    inset: auto !important;
    z-index: 5;
    width: auto !important;
    max-width: none !important;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    border: 1px solid var(--desktop-border);
    border-radius: 0.45rem;
    background: rgba(10,19,30,0.94);
  }

  .desktop-route-panel-heading {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .15rem .2rem .55rem;
    color: #e2e8f0;
  }
  .desktop-route-panel-heading > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    color: #0b1722;
    background: #e2e8f0;
    font-size: .62rem;
    font-weight: 900;
  }
  .desktop-route-panel-heading h2 { margin: 0; font-size: .75rem; font-weight: 900; }
  .desktop-route-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 0 .2rem .35rem;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.16);
    border-radius: .3rem;
    background: rgba(15,23,42,0.55);
  }
  .desktop-route-tabs span {
    min-height: 1.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ui-text-muted);
    border-right: 1px solid rgba(148,163,184,0.12);
    font-size: .61rem;
    font-weight: 800;
  }
  .desktop-route-tabs span:last-child { border-right: 0; }
  .desktop-route-tabs span.active { color: #f8fafc; background: rgba(82,183,136,0.18); box-shadow: inset 0 -2px 0 #52b788; }

  #route-collapsed { display: none !important; }
  #route-expanded { display: block !important; margin-top: 0 !important; padding: 0.7rem !important; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  #route-expanded .route-expanded-head { padding: 0 0 0.65rem; border-bottom: 1px solid rgba(148,163,184,0.15); }
  #route-expanded .route-title-kicker { color: #94a3b8; letter-spacing: .16em; }
  #route-expanded .route-title-text { font-size: .95rem; }
  #route-expanded .route-input-card,
  #route-expanded .route-text-input,
  #route-expanded .route-vehicle-shell { border-color: rgba(148,163,184,0.2); background: rgba(15,23,42,0.72); border-radius: .35rem; }
  #route-expanded .route-input-card input { min-width: 0; }
  #route-expanded .route-input-card { margin-top: .7rem; }
  #route-expanded .route-point-row { margin-top: .5rem; }
  /* Keep desktop place suggestions in the form flow so they push the main
     action down instead of covering it and intercepting the click. */
  #route-expanded .route-suggest-box {
    position: static;
    margin-top: .25rem;
    max-height: 7rem;
  }
  #route-expanded .route-text-input { padding-block: .62rem; }
  #route-expanded .route-vehicle-shell { padding: .7rem; }
  /* The header is the single desktop vehicle selector. Keep the route form
     focused on locations and the primary action instead of rendering a
     second, competing motorcycle selector. */
  #route-expanded > .route-vehicle-shell { display: none !important; }
  #route-expanded > #js-route-btn { margin-top: .35rem; }
  #route-expanded .route-action-btn { min-height: 2.65rem; border-radius: .35rem; background: #2b9b65; box-shadow: none; }
  #route-expanded .route-action-btn:hover { background: #35b879; }
  #history-btn,
  #route-toggle-close { color: #94a3b8; }
  #route-expanded .route-head-actions { display: none !important; }
  .ride-status-shell { margin-top: .6rem !important; padding: .65rem !important; border-radius: .45rem !important; background: rgba(15,23,42,0.55); box-shadow: none; }
  .ride-status-kicker { color: #94a3b8; }
  .ride-status-title { font-size: .8rem; }
  .ride-status-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: .35rem; margin-top: .5rem; }
  .ride-metric-card { min-height: 3.45rem; padding: .5rem; border-radius: .35rem; background: rgba(15,23,42,0.72); border-color: rgba(148,163,184,0.14); }
  .ride-metric-label { font-size: .58rem; }
  .ride-metric-value { font-size: .72rem; }
  .ride-inline-note { min-height: 0; margin-top: .45rem !important; padding: .45rem .55rem; font-size: .64rem; border-radius: .35rem; }
  #js-route-status { padding: .35rem .5rem; font-size: .68rem; }

  /* Keep the full route entry and the safety summary visible in ready state,
     matching the command-center reference where the left rail remains the
     operator's primary control surface. */
  body[data-route-state="ready"] #route-expanded { display: block !important; }
  body[data-route-state="ready"] #route-collapsed { display: none !important; }
  body[data-route-state="ready"] #route-expanded .route-expanded-head,
  body[data-route-state="ready"] #route-expanded .route-point-row,
  body[data-route-state="ready"] #route-expanded #waypoints-container { display: none !important; }
  body[data-route-state="ready"] #route-expanded { padding: .45rem !important; }
  body[data-route-state="ready"] #route-expanded .route-input-card { margin-top: 0; min-height: 0; padding: .45rem .55rem; }
  body[data-route-state="ready"] #js-route-status { padding: .15rem .35rem; font-size: .6rem; }
  body[data-route-state="ready"] #ride-status-card { display: none !important; }

  #desktop-left-insights,
  #desktop-route-context,
  #desktop-cctv-card {
    display: block !important;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--desktop-border);
    border-radius: .45rem;
    background: var(--desktop-surface);
  }

  #desktop-left-insights { margin: .7rem 0 0; padding: .7rem; }
  .desktop-panel-heading { display: flex; align-items: center; gap: .45rem; color: #e2e8f0; }
  .desktop-panel-heading > span { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; color: #0b1722; background: #e2e8f0; font-size: .62rem; font-weight: 900; }
  .desktop-panel-heading h2 { margin: 0; font-size: .75rem; font-weight: 900; }
  .desktop-panel-heading em { margin-left: .35rem; color: #86efac; font-size: .58rem; font-style: normal; font-weight: 700; }
  .desktop-validation-summary { margin-top: .65rem; padding: .6rem; color: #b7f7ce; border: 1px solid rgba(82,183,136,0.34); border-radius: .35rem; background: rgba(82,183,136,0.1); font-size: .72rem; font-weight: 900; }
  .desktop-attention-list { display: grid; gap: .35rem; margin-top: .55rem; }
  .desktop-attention-list > div { display: flex; gap: .45rem; align-items: flex-start; color: #cbd5e1; font-size: .64rem; line-height: 1.35; }
  .desktop-attention-list i { color: #f59e0b; margin-top: .08rem; }
  .desktop-muted { color: #64748b; font-size: .64rem; line-height: 1.4; }
  .desktop-mini-metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: .65rem; border-top: 1px solid rgba(148,163,184,0.14); border-bottom: 1px solid rgba(148,163,184,0.14); }
  .desktop-mini-metrics > div { display: flex; flex-direction: column; gap: .12rem; padding: .45rem .35rem; border-right: 1px solid rgba(148,163,184,0.12); }
  .desktop-mini-metrics > div:nth-child(2n) { border-right: 0; }
  .desktop-mini-metrics span { color: #64748b; font-size: .56rem; }
  .desktop-mini-metrics strong { color: #f8fafc; font-size: .72rem; }
  .desktop-source-note { margin-top: .55rem; color: #64748b; font-size: .58rem; line-height: 1.45; }
  body[data-route-state="ready"] #desktop-source-note { display: none; }
  body[data-route-state="ready"] .desktop-attention-list > div { font-size: .58rem; line-height: 1.2; }
  body[data-route-state="ready"] .desktop-validation-summary { padding: .45rem; }

  #desktop-support-panel {
    display: block !important;
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--desktop-border);
    border-radius: .45rem;
    background: var(--desktop-surface);
  }
  .desktop-support-section { padding: .65rem .7rem; }
  .desktop-support-section + .desktop-support-section { border-top: 1px solid rgba(148,163,184,0.14); }
  .desktop-legend-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .38rem .55rem; margin-top: .55rem; }
  .desktop-legend-grid > div { display: flex; align-items: center; gap: .38rem; min-width: 0; color: var(--ui-text-muted); font-size: .58rem; line-height: 1.25; }
  .desktop-legend-line { display: inline-block; width: 1.35rem; height: .24rem; flex: 0 0 auto; border-radius: .2rem; }
  .desktop-legend-line.is-clear { background: #52b788; }
  .desktop-legend-line.is-slow { background: #facc15; }
  .desktop-legend-line.is-congested { background: #ef4444; }
  .desktop-legend-line.is-unknown { background: #94a3b8; }
  .desktop-legend-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.05rem; flex: 0 0 auto; font-size: .7rem; }
  .desktop-legend-icon.is-weather { color: #38bdf8; }
  .desktop-legend-icon.is-construction { color: #fb923c; }
  .desktop-legend-icon.is-incident { color: #f87171; }
  .desktop-legend-icon.is-camera { color: #e2e8f0; }
  .desktop-source-list { display: grid; gap: .35rem; margin-top: .55rem; }
  .desktop-source-list > div { display: flex; align-items: baseline; gap: .35rem; min-width: 0; color: var(--ui-text-muted); font-size: .57rem; line-height: 1.25; }
  .desktop-source-list > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-source-list > div b { margin-left: auto; color: var(--ui-text-subtle); font-size: .53rem; font-weight: 700; white-space: nowrap; }
  .desktop-source-dot { width: .42rem; height: .42rem; flex: 0 0 auto; border-radius: 50%; background: #52b788; box-shadow: 0 0 0 .12rem rgba(82,183,136,0.12); }
  .desktop-source-dot.is-muted { background: #facc15; box-shadow: 0 0 0 .12rem rgba(250,204,21,0.12); }
  .desktop-support-update { display: flex; align-items: center; gap: .35rem; margin-top: .55rem; padding-top: .45rem; color: var(--ui-text-subtle); border-top: 1px solid rgba(148,163,184,0.12); font-size: .53rem; }
  .desktop-support-update i { margin-left: auto; color: var(--ui-text-faint); }

  #route-conditions-panel {
    grid-column: 2;
    grid-row: 2;
    position: relative !important;
    inset: auto !important;
    z-index: 6;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    /* The disclaimer is a fixed overlay. Grid now reaches the viewport edge,
       so the three bottom panels can share one clean baseline. */
    height: auto;
    margin: 0;
    overflow: hidden;
    animation: none;
    border-radius: .45rem;
    background: rgba(10,19,30,0.96);
  }

  #route-conditions-panel:not(.hidden) { display: block !important; }
  #route-conditions-panel .condition-panel-head { min-height: 2.45rem; padding: .42rem .7rem; border-bottom: 1px solid rgba(148,163,184,0.14); }
  #route-conditions-panel .condition-kicker { display: none; }
  #route-conditions-panel .condition-title-row h2 { font-size: .88rem; }
  #route-conditions-panel .condition-source-badge { min-height: 1.2rem; padding-inline: .34rem; font-size: .48rem; }
  #route-conditions-panel .condition-head-actions { gap: .28rem; }
  #route-conditions-panel .condition-icon-btn { width: 1.7rem; height: 1.7rem; font-size: .62rem; }
  #route-conditions-panel .desktop-condition-info-toggle { display: inline-flex !important; }
  #condition-content:not(.hidden) { display: flex !important; flex-direction: column; height: calc(100% - 2.5rem); max-height: calc(100% - 2.5rem); min-height: 0; overflow: hidden; padding: .18rem .7rem .45rem; }
  #condition-loading { padding: .75rem; }
  #condition-error { padding: 1rem; }
  #route-conditions-panel .condition-overview-grid { grid-template-columns: repeat(5, minmax(0,1fr)); gap: .35rem; padding-top: .55rem; }
  #route-conditions-panel .condition-metric { min-height: 3rem; padding: .45rem; border-radius: .35rem; background: rgba(15,23,42,0.72); }
  #route-conditions-panel .condition-metric span { font-size: .56rem; }
  #route-conditions-panel .condition-metric strong { font-size: .72rem; }
  #route-conditions-panel .condition-update-row { margin-top: .45rem; font-size: .6rem; }
  #route-conditions-panel .condition-alerts { display: none; }
  #route-conditions-panel .condition-nav-actions { display: flex; gap: .4rem; margin-top: .45rem; }
  #route-conditions-panel .condition-nav-btn { min-height: 1.8rem; padding: .3rem .5rem; font-size: .58rem; border-radius: .3rem; }
  #route-conditions-panel .condition-timeline { margin-top: .4rem; max-height: 8rem; overflow-y: auto; }
  #route-conditions-panel .condition-section { padding: .45rem .55rem; border-radius: .3rem; }
  #route-conditions-panel .condition-footnote { margin-top: .45rem; padding: .4rem 0; font-size: .56rem; line-height: 1.4; }
  #desktop-elevation-panel:not(.hidden) { display: flex !important; flex: 1 1 auto; flex-direction: column; min-height: 0; margin-top: .22rem; padding: .35rem 0 0; border-top: 1px solid rgba(148,163,184,0.14); }
  .desktop-elevation-heading,
  .desktop-cctv-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: #e2e8f0; font-size: .66rem; font-weight: 900; }
  .desktop-elevation-heading span:last-child { color: #64748b; font-size: .5rem; font-weight: 700; }
  #desktop-elevation-chart { display: block; flex: 1 1 5.5rem; width: 100%; min-height: 5.2rem; margin-top: .08rem; overflow: visible; }
  .desktop-elevation-line { fill: none; stroke: url(#desktop-elevation-stroke); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .desktop-elevation-area { fill: url(#desktop-elevation-fill); }
  .desktop-chart-axis { stroke: rgba(148,163,184,0.17); stroke-width: 1; }
  .desktop-chart-label { fill: #64748b; font-size: 9px; font-weight: 700; }
  .desktop-chart-peak { fill: #fb923c; stroke: #fee2e2; stroke-width: 2; }
  .desktop-chart-peak-label { fill: #f8fafc; font-size: 9px; font-weight: 900; }
  .desktop-chart-empty { fill: #64748b; font-size: 12px; }
  .desktop-elevation-summary { margin-top: -.18rem; color: #64748b; font-size: .5rem; text-align: center; }
  .desktop-playback-controls { display: flex; align-items: center; gap: .42rem; margin-top: auto; margin-bottom: .95rem; padding-top: .3rem; color: #94a3b8; font-size: .54rem; }
  .desktop-playback-label { font-weight: 800; white-space: nowrap; }
  #desktop-playback-toggle { width: 1.55rem; height: 1.55rem; border: 1px solid rgba(82,183,136,.45); border-radius: .24rem; color: #07111b; background: #52b788; font-size: .62rem; }
  #desktop-playback-range { flex: 1; min-width: 5rem; accent-color: #52b788; }
  #desktop-playback-speed { min-height: 1.55rem; color: #cbd5e1; background: #172435; border: 1px solid rgba(148,163,184,0.2); border-radius: .25rem; font-size: .58rem; }

  #desktop-route-context {
    grid-column: 3;
    grid-row: 1;
    padding: .75rem;
  }
  .desktop-context-empty { margin-top: 1rem; color: #64748b; font-size: .68rem; line-height: 1.5; }
  .desktop-context-label { margin-top: .85rem; color: #64748b; font-size: .58rem; }
  .desktop-context-road { margin-top: .2rem; color: #f8fafc; font-size: 1rem; font-weight: 900; }
  .desktop-context-sub { margin-top: .2rem; color: #94a3b8; font-size: .65rem; }
  .desktop-context-divider { margin: .75rem 0; border-top: 1px solid rgba(148,163,184,0.14); }
  .desktop-context-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .5rem; }
  .desktop-context-grid > div { display: flex; flex-direction: column; gap: .14rem; min-width: 0; }
  .desktop-context-grid span { color: #64748b; font-size: .56rem; }
  .desktop-context-grid strong { color: #cbd5e1; font-size: .68rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-context-alerts { display: grid; gap: .35rem; margin-top: .85rem; }
  .desktop-context-alert,
  .desktop-context-ok { display: flex; gap: .4rem; align-items: flex-start; color: #fbbf24; font-size: .6rem; line-height: 1.35; }
  .desktop-context-ok { color: #86efac; }
  .desktop-context-link { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 1rem; padding: .5rem 0; color: #86efac; background: transparent; border: 0; border-top: 1px solid rgba(148,163,184,0.14); font-size: .62rem; font-weight: 800; text-align: left; }

  #desktop-cctv-card { grid-column: 3; grid-row: 2; padding: .65rem; }
  .desktop-cctv-heading span:last-child { color: #86efac; font-size: .56rem; font-weight: 800; }
  .desktop-cctv-media { position: relative; display: flex; align-items: center; justify-content: center; height: 8.5rem; margin-top: .55rem; overflow: hidden; color: #64748b; background: #0b1722; border: 1px solid rgba(148,163,184,0.14); border-radius: .3rem; font-size: .62rem; text-align: center; }
  .desktop-cctv-media img { width: 100%; height: 100%; object-fit: cover; }
  .desktop-cctv-media i { font-size: 1.2rem; margin-bottom: .35rem; }
  .desktop-cctv-media span { display: block; }
  .desktop-cctv-placeholder { position: absolute; left: .5rem; bottom: .35rem; padding: .18rem .3rem; color: #cbd5e1; background: rgba(7,17,27,0.72); border-radius: .2rem; font-size: .52rem; }
  .desktop-cctv-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .45rem; }
  .desktop-cctv-meta > span { min-width: 0; overflow: hidden; color: #cbd5e1; font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-cctv-meta button { flex-shrink: 0; color: #86efac; background: transparent; border: 0; font-size: .58rem; font-weight: 800; }
  .desktop-cctv-meta button:disabled { color: #475569; }

  /* The command center is an adjustable workspace on desktop. Handles sit in
     the grid gutters so they do not cover map controls or panel content. */
  .desktop-resizer {
    display: block;
    position: absolute;
    z-index: 80;
    touch-action: none;
    background: transparent;
    border: 0;
    opacity: .64;
    transition: opacity .16s ease;
  }
  .desktop-resizer::after {
    content: '';
    position: absolute;
    inset: .18rem;
    border-radius: 999px;
    background: rgba(148,163,184,.28);
    box-shadow: 0 0 0 1px rgba(7,17,27,.28);
  }
  .desktop-resizer:hover,
  .desktop-resizer:focus-visible,
  body.desktop-resizing .desktop-resizer { opacity: 1; }
  .desktop-resizer:focus-visible { outline: 2px solid #52b788; outline-offset: 1px; }
  .desktop-resizer-vertical {
    top: 0;
    bottom: 0;
    width: .7rem;
    margin-left: -.35rem;
    cursor: col-resize;
  }
  #desktop-resize-left { left: calc(var(--desktop-left-rail) + var(--desktop-gap) / 2); }
  #desktop-resize-right { right: calc(var(--desktop-right-rail) + var(--desktop-gap) / 2); }
  .desktop-resizer-horizontal {
    left: 0;
    right: 0;
    bottom: calc(var(--desktop-bottom-rail) + var(--desktop-gap) / 2);
    height: .7rem;
    margin-bottom: -.35rem;
    cursor: row-resize;
  }
  .desktop-resizer-horizontal::after { inset: .22rem 35%; }
  body.desktop-resizing { user-select: none; }
  body.desktop-resizing[data-resize-axis="col"] { cursor: col-resize; }
  body.desktop-resizing[data-resize-axis="row"] { cursor: row-resize; }

  body:not(.light) .desktop-muted,
  body:not(.light) .desktop-source-note,
  body:not(.light) .desktop-context-empty,
  body:not(.light) .desktop-context-label,
  body:not(.light) .desktop-context-grid span,
  body:not(.light) .desktop-elevation-heading span:last-child {
    color: var(--ui-text-subtle);
  }
  body:not(.light) .desktop-context-sub,
  body:not(.light) .desktop-elevation-summary,
  body:not(.light) .desktop-playback-controls,
  body:not(.light) .desktop-cctv-media,
  body:not(.light) .desktop-attention-list > div,
  body:not(.light) .desktop-panel-heading,
  body:not(.light) .desktop-mini-metrics span,
  body:not(.light) .desktop-context-grid strong,
  body:not(.light) .desktop-cctv-placeholder,
  body:not(.light) .desktop-cctv-meta > span {
    color: var(--ui-text-muted);
  }
  body:not(.light) .maplibregl-ctrl-attrib { color: var(--ui-text-muted); }
  body:not(.light) .maplibregl-ctrl-attrib a { color: var(--ui-text-secondary); }
  body:not(.light) .desktop-chart-empty { fill: var(--ui-text-subtle); }
  body:not(.light) #desktop-playback-speed { color: var(--ui-text-secondary); }
  body:not(.light) .desktop-cctv-meta button:disabled { color: var(--ui-text-faint); }
  body:not(.light) .desktop-header-route-meta,
  body:not(.light) .desktop-settings-title,
  body:not(.light) #route-expanded .route-title-kicker,
  body:not(.light) #history-btn,
  body:not(.light) #route-toggle-close,
  body:not(.light) header .ui-clock-wrap .ui-dismiss-btn {
    color: var(--ui-text-muted);
  }
  body:not(.light) .desktop-vehicle-tab { color: var(--ui-text-secondary); }
  body:not(.light) #route-conditions-panel .condition-kicker { color: var(--ui-text-muted); }

  /* Keep the initial desktop task focused on route entry and the map. The
     context rail and timeline only consume space after a route is ready. */
  body[data-route-state="empty"] #pg-map.active,
  body[data-route-state="analyzing"] #pg-map.active {
    grid-template-columns: var(--desktop-left-rail) minmax(30rem, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  body[data-route-state="empty"] #desktop-route-context,
  body[data-route-state="empty"] #desktop-cctv-card,
  body[data-route-state="analyzing"] #desktop-route-context,
  body[data-route-state="analyzing"] #desktop-cctv-card,
  body[data-route-state="empty"] #route-conditions-panel,
  body[data-route-state="analyzing"] #route-conditions-panel,
  body[data-route-state="empty"] #desktop-support-panel,
  body[data-route-state="analyzing"] #desktop-support-panel {
    display: none !important;
  }
  body[data-route-state="empty"] #desktop-resize-right,
  body[data-route-state="empty"] #desktop-resize-bottom,
  body[data-route-state="analyzing"] #desktop-resize-right,
  body[data-route-state="analyzing"] #desktop-resize-bottom {
    display: none;
  }
  body[data-route-state="empty"] #desktop-map,
  body[data-route-state="analyzing"] #desktop-map,
  body[data-route-state="empty"] #map,
  body[data-route-state="analyzing"] #map {
    grid-column: 2;
    grid-row: 1;
  }
  body[data-route-state="empty"] .map-top-panel,
  body[data-route-state="analyzing"] .map-top-panel {
    grid-row: 1;
  }

  .brand-home { padding: 0; color: inherit; background: transparent; border: 0; text-align: left; cursor: pointer; }
  .brand-home:focus-visible { outline: 2px solid #52b788; outline-offset: 3px; border-radius: .35rem; }
  .desktop-map-tools { position: absolute; top: .8rem; left: calc(var(--desktop-left-rail) + var(--desktop-gap) + .8rem); z-index: 20; display: flex; overflow: visible; border: 1px solid rgba(148,163,184,0.2); border-radius: .35rem; background: rgba(7,17,27,0.84); }
  #desktop-map-tools { display: flex; }
  .desktop-map-tools button { min-height: 2rem; padding: 0 .7rem; color: #cbd5e1; background: transparent; border: 0; border-right: 1px solid rgba(148,163,184,0.14); font-size: .62rem; font-weight: 800; }
  .desktop-map-tools button:last-child { border-right: 0; }
  .desktop-map-tools button:hover,
  .desktop-map-tools button.active { color: #ecfdf5; background: #145c47; }
  .desktop-map-tools button:disabled { color: #64748b; background: transparent; cursor: not-allowed; }
  body.desktop-legacy-map .desktop-map-tools button.active { background: #334155; }
  .desktop-map-provider-logo { position: absolute; left: .65rem; bottom: .55rem; z-index: 5; display: inline-flex; align-items: center; min-height: 1.45rem; padding: .18rem .42rem; color: #fff; background: rgba(7,17,27,.78); border: 1px solid rgba(255,255,255,.35); border-radius: .25rem; font-size: .58rem; font-weight: 900; letter-spacing: .02em; text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
  .desktop-map-provider-logo:hover { color: #bbf7d0; background: rgba(7,17,27,.94); }
  .desktop-route-intelligence { margin: 0; padding: .3rem 0 .34rem; border-bottom: 1px solid rgba(148,163,184,.14); }
  #desktop-route-intelligence:not(.hidden) { display: block !important; }
  .desktop-timeline-row { display: grid; grid-template-columns: 3.4rem minmax(0,1fr); align-items: center; gap: .35rem; min-width: 0; }
  .desktop-timeline-row + .desktop-timeline-row { margin-top: .22rem; }
  .desktop-timeline-label { color: #94a3b8; font-size: .54rem; font-weight: 800; line-height: 1.15; white-space: nowrap; }
  .desktop-route-stops { position: relative; display: grid; grid-template-columns: repeat(var(--desktop-stop-count, 1), minmax(0,1fr)); gap: 0; min-width: 0; }
  .desktop-route-stops::before { content: ''; position: absolute; left: 6%; right: 6%; top: 1.12rem; height: 1px; background: rgba(148,163,184,.42); }
  .desktop-route-stop { position: relative; z-index: 1; display: grid; grid-template-rows: .76rem .72rem .62rem .56rem; justify-items: center; min-width: 0; padding: 0 .12rem; color: #94a3b8; background: transparent; border: 0; text-align: center; }
  .desktop-route-stop::after { content: ''; grid-row: 2; align-self: center; width: .42rem; height: .42rem; border: 2px solid #0a131e; border-radius: 50%; background: #cbd5e1; box-shadow: 0 0 0 1px rgba(148,163,184,.4); }
  .desktop-route-stop strong { grid-row: 1; max-width: 100%; overflow: hidden; color: #e2e8f0; font-size: .6rem; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
  .desktop-route-stop .desktop-stop-time { grid-row: 3; color: #cbd5e1; font-size: .52rem; }
  .desktop-route-stop .desktop-stop-distance { grid-row: 4; color: #64748b; font-size: .49rem; }
  .desktop-route-stop:hover strong,
  .desktop-route-stop:focus-visible strong,
  .desktop-route-stop.active strong { color: #bbf7d0; }
  .desktop-route-stop:hover::after,
  .desktop-route-stop:focus-visible::after,
  .desktop-route-stop.active::after { background: #52b788; box-shadow: 0 0 0 2px rgba(82,183,136,.2); }
  .desktop-route-stop:focus-visible { outline: 1px solid #52b788; outline-offset: 2px; border-radius: .2rem; }
  .desktop-traffic-band { display: flex; gap: .08rem; height: .52rem; min-width: 0; overflow: hidden; border-radius: .18rem; background: rgba(148,163,184,.12); }
  .desktop-traffic-segment { min-width: .22rem; border-radius: .08rem; }
  .desktop-traffic-segment.is-clear { background: #52b788; }
  .desktop-traffic-segment.is-slow { background: #f6c945; }
  .desktop-traffic-segment.is-congested { background: #ef5350; }
  .desktop-traffic-segment.is-unknown { background: #94a3b8; }
  .desktop-weather-track { display: grid; grid-template-columns: repeat(var(--desktop-stop-count, 1), minmax(0,1fr)); gap: .18rem; min-width: 0; overflow: hidden; color: #94a3b8; font-size: .51rem; white-space: nowrap; }
  .desktop-weather-track span { display: flex; align-items: center; justify-content: center; gap: .16rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .desktop-weather-track i { color: #38bdf8; }
  .desktop-weather-track .is-sunny i { color: #facc15; }
  .desktop-weather-track .is-cloudy i { color: #94a3b8; }
  .desktop-condition-info-popover { position: absolute; top: 2.75rem; right: .7rem; z-index: 5; max-width: 18rem; padding: .5rem .6rem; color: #cbd5e1; background: rgba(7,17,27,.96); border: 1px solid rgba(148,163,184,.24); border-radius: .3rem; box-shadow: 0 12px 28px rgba(0,0,0,.34); font-size: .56rem; line-height: 1.45; }
  .desktop-condition-nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .35rem; margin-top: .5rem; padding-top: .45rem; border-top: 1px solid rgba(148,163,184,.18); }
  .desktop-condition-nav button { min-height: 1.75rem; padding: 0 .45rem; color: #d1fae5; background: rgba(82,183,136,.12); border: 1px solid rgba(82,183,136,.3); border-radius: .25rem; font-size: .54rem; font-weight: 850; }
  .desktop-condition-nav button:disabled { color: #64748b; background: rgba(148,163,184,.08); border-color: rgba(148,163,184,.15); cursor: not-allowed; }
  #route-conditions-panel #apple-leg-links:not(.hidden) { position: absolute; top: 7.7rem; right: .7rem; z-index: 6; width: min(18rem, calc(100% - 1.4rem)); margin: 0; padding: .55rem; color: #cbd5e1; background: rgba(7,17,27,.98); border: 1px solid rgba(148,163,184,.24); border-radius: .3rem; box-shadow: 0 12px 28px rgba(0,0,0,.34); }
  .desktop-event-marker { width: auto; min-width: 1.65rem; max-width: 10rem; height: 1.65rem; gap: .18rem; padding: 0 .34rem; color: #07111b; border-radius: .35rem; }
  .desktop-event-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
  .desktop-event-callout { max-width: 7.5rem; overflow: hidden; font-size: .52rem; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
  #route-conditions-panel .condition-footnote,
  #route-conditions-panel .condition-timeline,
  #route-conditions-panel #condition-demo-warning { display: none !important; }
  #route-conditions-panel .condition-overview-grid,
  #route-conditions-panel .condition-update-row,
  #route-conditions-panel .condition-nav-actions { display: none !important; }
  body.light .desktop-route-stop strong { color: var(--ui-text-secondary); }
  body.light .desktop-route-stop span, body.light .desktop-weather-track { color: var(--ui-text-muted); }
  body.light .desktop-condition-info-popover { color: var(--ui-text-secondary); background: rgba(255,255,255,.98); border-color: rgba(15,23,42,.18); }
  body.light .desktop-condition-nav button { color: #14532d; background: #dcfce7; border-color: #86efac; }
  body.light #route-conditions-panel #apple-leg-links:not(.hidden) { color: var(--ui-text-secondary); background: rgba(255,255,255,.98); border-color: rgba(15,23,42,.18); }
  body.light .desktop-map-provider-logo { color: #fff; background: rgba(15,23,42,.86); }
  .desktop-camera-popover { position: absolute; top: calc(100% + .35rem); right: 0; display: grid; grid-template-columns: repeat(2, minmax(4rem, 1fr)); gap: .25rem; min-width: 10rem; padding: .35rem; border: 1px solid rgba(148,163,184,0.25); border-radius: .35rem; background: rgba(7,17,27,0.96); box-shadow: 0 12px 28px rgba(0,0,0,0.35); }
  .desktop-camera-popover.hidden { display: none; }
  .desktop-camera-popover .desktop-camera-preset { min-height: 1.8rem; padding: 0 .45rem; border: 1px solid transparent; border-radius: .25rem; color: #cbd5e1; font-size: .6rem; }
  .desktop-camera-popover .desktop-camera-preset:hover,
  .desktop-camera-popover .desktop-camera-preset.active { color: #ecfdf5; background: #145c47; border-color: rgba(82,183,136,0.55); }
  .desktop-camera-state { grid-column: 1 / -1; padding: .25rem .35rem .1rem; color: #94a3b8; border-top: 1px solid rgba(148,163,184,0.14); font-size: .54rem; text-align: center; }

  .desktop-map-marker { display: inline-flex; align-items: center; justify-content: center; width: 1.65rem; height: 1.65rem; padding: 0; color: #07111b; background: var(--marker-color); border: 2px solid rgba(255,255,255,0.9); border-radius: 50%; box-shadow: 0 2px 9px rgba(0,0,0,0.5); font-size: .72rem; font-weight: 900; cursor: pointer; }
  .desktop-map-marker:hover { transform: scale(1.12); }
  .desktop-cctv-marker { z-index: 3; width: 1.8rem; height: 1.8rem; color: #f8fafc; background: rgba(7,17,27,.94); border-color: #e2e8f0; box-shadow: 0 0 0 2px rgba(15,23,42,.5), 0 3px 10px rgba(0,0,0,.65); }
  .desktop-cctv-marker i { font-size: .72rem; }
  .desktop-cctv-marker:focus-visible { outline: 2px solid #52b788; outline-offset: 2px; }
  .desktop-cursor-marker { width: 2rem; height: 2rem; color: #07111b; background: #f8fafc; border-color: #52b788; box-shadow: 0 0 0 5px rgba(82,183,136,0.2), 0 2px 10px rgba(0,0,0,0.55); }
  .desktop-cursor-marker i { font-size: .8rem; }

  #js-route-banner,
  #route-camera-strip,
  .bottom-navigation,
  .map-legend { display: none !important; }
  .map-control-stack { left: calc(var(--desktop-left-rail) + var(--desktop-gap) + .8rem) !important; bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; z-index: 20 !important; }
  .map-control-stack > button { width: 2rem; height: 2rem; border-radius: .35rem; }
  #nearby-panel { left: calc(var(--desktop-left-rail) + var(--desktop-gap) + 3.1rem) !important; bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
  #favorites-panel { top: calc(var(--desktop-header-height) + .7rem) !important; right: 1rem !important; width: 22rem !important; border-radius: .45rem; }
  #pg-list,
  #pg-tools { padding-top: calc(var(--desktop-header-height) + 1rem) !important; padding-bottom: 1.5rem !important; }
  /* The traffic browser is a page-level view on desktop. Keep its filter
     shell in normal flow so scrolling never lets it cover camera cards. */
  #pg-list .list-filter-shell {
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
  }
  #pg-list .max-w-xl,
  #pg-tools .max-w-xl { max-width: 60rem; }

  body.light { background: #e9eef2; }
  body.light #pg-map.active { background: #e9eef2; }
  body.light header { background: rgba(241,245,249,0.96) !important; }
  body.light .desktop-settings-popover,
  body.light #desktop-left-insights,
  body.light #desktop-support-panel,
  body.light #desktop-route-context,
  body.light #desktop-cctv-card,
  body.light #route-conditions-panel { background: rgba(248,250,252,0.96); }
  body.light .desktop-header-route-label,
  body.light .desktop-context-road,
  body.light .desktop-mini-metrics strong { color: #0f172a; }
  body.light .brand-copy small { color: #475569; }
  body.light .desktop-header-route-meta,
  body.light .desktop-source-note,
  body.light .desktop-muted { color: #64748b; }
  body.light .desktop-camera-popover { background: rgba(248,250,252,0.98); border-color: rgba(71,85,105,0.25); }
  body.light .desktop-camera-popover .desktop-camera-preset { color: #334155; }
  body.light .desktop-camera-popover .desktop-camera-preset:hover,
  body.light .desktop-camera-popover .desktop-camera-preset.active { color: #064e3b; background: #bbf7d0; }
}

@media (min-width: 1200px) and (max-height: 820px) {
  #pg-map.active { grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail); }
  .map-control-stack { bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
  #nearby-panel { bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
  .desktop-cctv-media { height: 6.6rem; }
  #route-conditions-panel .condition-timeline { max-height: 5rem; }
}

/* The photo reference is a 1280px command-center viewport. Tighten the
   rails and header only in that range so the map keeps the dominant visual
   area without introducing horizontal scrolling. */
@media (min-width: 1200px) and (max-width: 1399px) {
  :root {
    --desktop-header-height: 3.8rem;
    --desktop-footer-height: 0rem;
    --desktop-left-rail: 15rem;
    --desktop-right-rail: 12.2rem;
    --desktop-gap: .45rem;
  }
  header { padding-inline: .7rem !important; }
  header > div:first-child { gap: .8rem; }
  header > div:first-child > div:first-child { padding-right: .8rem; }
  header h1 { font-size: .82rem !important; }
  header .w-7.h-7 { width: 1.95rem; height: 1.95rem; }
  .desktop-only-header { gap: .8rem; }
  .desktop-header-route-copy { min-width: 8rem; max-width: 13rem; }
  .desktop-header-route-label { font-size: .88rem; }
  .desktop-header-route-meta { font-size: .6rem; }
  .desktop-vehicle-tab { min-height: 2rem; padding-inline: .68rem; font-size: .64rem; }
  .desktop-header-action { min-height: 1.95rem; padding-inline: .45rem; font-size: .68rem; }
  #desktop-settings-toggle,
  #desktop-favorites-toggle { padding-left: .7rem; }
  #pg-map.active { grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail); }
  .map-control-stack,
  #nearby-panel { bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
  .desktop-cctv-media { height: 12.6rem; }
  #route-expanded { padding: .55rem !important; }
  #route-expanded .route-expanded-head { padding-bottom: .45rem; }
  #route-expanded .route-input-card { margin-top: .45rem; }
  #route-expanded .route-point-row { margin-top: .35rem; }
  #route-expanded .route-text-input { padding-block: .52rem; }
  #route-expanded > #js-route-btn { min-height: 2.35rem; }
  #desktop-left-insights { margin-top: .45rem; padding: .55rem; }
  .desktop-validation-summary { margin-top: .45rem; padding: .5rem; }
  .desktop-attention-list { margin-top: .4rem; gap: .25rem; }
  .desktop-mini-metrics { margin-top: .45rem; }
  .desktop-source-note { margin-top: .4rem; }
  .desktop-support-section { padding: .55rem .6rem; }
  .desktop-legend-grid { gap: .3rem .4rem; margin-top: .4rem; }
  .desktop-source-list { gap: .28rem; margin-top: .4rem; }
}

/* v26 contrast refresh: keep small labels legible on dark map/surface layers.
   These are dark-theme-only and intentionally leave the light theme intact. */
body:not(.light) .ride-metric-label,
body:not(.light) .tool-empty,
body:not(.light) .tool-check-sub,
body:not(.light) .favorite-sub,
body:not(.light) .list-chip-head,
body:not(.light) .suggest-group-title,
body:not(.light) .route-option-head span:last-child,
body:not(.light) .route-advanced,
body:not(.light) .route-collapse-btn,
body:not(.light) .condition-section-km,
body:not(.light) .condition-road-event-meta,
body:not(.light) .condition-metric span,
body:not(.light) .condition-update-row,
body:not(.light) .condition-footnote,
body:not(.light) .desktop-muted,
body:not(.light) .desktop-source-note,
body:not(.light) .desktop-context-empty,
body:not(.light) .desktop-context-label,
body:not(.light) .desktop-context-grid span,
body:not(.light) .desktop-elevation-heading span:last-child,
body:not(.light) .desktop-cctv-media {
  color: var(--ui-text-subtle) !important;
}

body:not(.light) .map-legend-item,
body:not(.light) .suggest-item,
body:not(.light) .condition-data-chip,
body:not(.light) .condition-road-event-description,
body:not(.light) .desktop-attention-list > div,
body:not(.light) .desktop-panel-heading,
body:not(.light) .desktop-context-grid strong,
body:not(.light) .desktop-cctv-placeholder,
body:not(.light) .desktop-cctv-meta > span,
body:not(.light) .desktop-playback-controls,
body:not(.light) .desktop-map-tools button {
  color: var(--ui-text-muted) !important;
}

body:not(.light) .suggest-item .suggest-sub,
body:not(.light) .desktop-cctv-meta button:disabled,
body:not(.light) #nearby-radius-row,
body:not(.light) #nearby-radius-row .text-slate-600,
body:not(.light) #history-count {
  color: var(--ui-text-faint) !important;
}

/* Keep desktop and mobile surfaces/actions on the same dark command-center
   palette. Orange remains the brand/alert accent; green is reserved for the
   verified route action and active vehicle state. */
body:not(.light) header,
body:not(.light) #pg-map.active,
body:not(.light) .map-top-panel,
body:not(.light) #desktop-left-insights,
body:not(.light) #desktop-support-panel,
body:not(.light) #desktop-route-context,
body:not(.light) #desktop-cctv-card,
body:not(.light) #route-conditions-panel {
  background-color: var(--ui-bg);
  border-color: var(--ui-border);
}

body:not(.light) .route-shell.route-shell-collapsed,
body:not(.light) .route-shell.route-shell-expanded,
body:not(.light) .ride-status-shell,
body:not(.light) .desktop-settings-popover,
body:not(.light) .route-input-card,
body:not(.light) .route-vehicle-shell {
  background-color: var(--ui-surface);
  border-color: var(--ui-border);
}

body:not(.light) .desktop-vehicle-tabs,
body:not(.light) .route-text-input,
body:not(.light) .route-mode-btn,
body:not(.light) .ride-metric-card,
body:not(.light) .condition-metric,
body:not(.light) .condition-section {
  background-color: var(--ui-control);
  border-color: var(--ui-border);
}

body:not(.light) .desktop-vehicle-tab,
body:not(.light) .route-mode-btn,
body:not(.light) .desktop-header-action,
body:not(.light) .desktop-map-tools button {
  color: var(--ui-text-secondary) !important;
}

body:not(.light) .desktop-vehicle-tab.active,
body:not(.light) .route-mode-btn.active,
body:not(.light) .route-action-btn,
body:not(.light) #js-route-btn {
  background: var(--ui-accent) !important;
  border-color: var(--ui-accent) !important;
  color: #07111b !important;
  box-shadow: inset 0 -2px 0 rgba(7,17,27,0.22), 0 10px 22px rgba(82,183,136,0.18);
}

body:not(.light) .desktop-vehicle-tab.active,
body:not(.light) .route-mode-btn.active {
  color: #ecfdf5 !important;
}

body:not(.light) .desktop-vehicle-tab:hover,
body:not(.light) .desktop-vehicle-tab:focus-visible,
body:not(.light) .route-mode-btn:hover,
body:not(.light) .route-mode-btn:focus-visible {
  background: rgba(82,183,136,0.18) !important;
  color: var(--ui-accent-strong) !important;
}

/* v30 light-theme contrast pass: use a deliberate ink hierarchy instead of
   inheriting the dark command-center palette.  The map can remain dark while
   every light surface, control and supporting label keeps a clear text edge. */
body.light {
  --ui-text-primary: #0f172a;
  --ui-text-secondary: #1e293b;
  --ui-text-muted: #475569;
  --ui-text-subtle: #334155;
  --ui-text-faint: #64748b;
  --ui-bg: #f1f5f9;
  --ui-surface: #ffffff;
  --ui-surface-elevated: #ffffff;
  --ui-control: #f8fafc;
  --ui-border: rgba(15,23,42,0.18);
  --ui-accent: #178a58;
  --ui-accent-strong: #166534;
  --ui-alert: #b45309;
  color: var(--ui-text-primary);
  background: var(--ui-bg);
}

body.light .text-slate-100 { color: var(--ui-text-primary) !important; }
body.light .text-slate-200 { color: var(--ui-text-secondary) !important; }
body.light .text-slate-300 { color: var(--ui-text-secondary) !important; }
body.light .text-slate-400 { color: var(--ui-text-muted) !important; }
body.light .text-slate-500 { color: var(--ui-text-faint) !important; }
body.light .text-slate-600 { color: var(--ui-text-muted) !important; }
body.light .placeholder-slate-500::placeholder {
  color: var(--ui-text-faint) !important;
  opacity: 1;
}
body.light input,
body.light textarea,
body.light select { color: var(--ui-text-primary); }

body.light header {
  color: var(--ui-text-primary);
  background: rgba(255,255,255,0.97) !important;
  border-bottom-color: rgba(15,23,42,0.14) !important;
}
body.light header .ui-dismiss-btn,
body.light header .ui-dismiss-btn span,
body.light .desktop-header-action {
  color: var(--ui-text-secondary) !important;
}
body.light header .ui-dismiss-btn:hover,
body.light header .ui-dismiss-btn:focus-visible,
body.light .desktop-header-action:hover,
body.light .desktop-header-action:focus-visible {
  color: var(--ui-accent-strong) !important;
}

body.light .map-top-panel {
  color: var(--ui-text-primary);
  background: rgba(255,255,255,0.96) !important;
  border: 1px solid rgba(15,23,42,0.16);
  box-shadow: 0 18px 36px rgba(71,85,105,0.18);
}
body.light .desktop-route-panel-heading,
body.light .desktop-panel-heading {
  color: var(--ui-text-primary) !important;
}
body.light .desktop-route-panel-heading > span,
body.light .desktop-panel-heading > span {
  color: #fff;
  background: #0f172a;
}
body.light .desktop-route-tabs {
  background: #e2e8f0;
  border-color: rgba(15,23,42,0.16);
}
body.light .desktop-route-tabs span {
  color: var(--ui-text-muted) !important;
}
body.light .desktop-route-tabs span.active {
  color: var(--ui-accent-strong) !important;
  background: #dcfce7;
  box-shadow: inset 0 -2px 0 var(--ui-accent);
}

body.light #route-expanded .route-title-text,
body.light .route-option-head,
body.light .route-option-head span:last-child,
body.light #history-btn,
body.light #route-toggle-close,
body.light .route-advanced,
body.light .route-collapse-btn,
body.light .route-mini-btn {
  color: var(--ui-text-secondary) !important;
}
body.light #route-expanded .route-title-kicker { color: #c2410c !important; }
body.light #route-expanded .route-input-card,
body.light #route-expanded .route-text-input,
body.light #route-expanded .route-vehicle-shell,
body.light .route-input-card,
body.light .route-text-input,
body.light .route-vehicle-shell,
body.light #history-dropdown,
body.light .suggest-box {
  color: var(--ui-text-primary) !important;
  background: #fff !important;
  border-color: rgba(15,23,42,0.18) !important;
}
body.light #route-expanded input::placeholder,
body.light .route-text-input::placeholder,
body.light .route-input-card input::placeholder {
  color: var(--ui-text-faint) !important;
  opacity: 1;
}
body.light .route-action-btn,
body.light #js-route-btn {
  background: #178a58 !important;
  border-color: #178a58 !important;
  color: #fff !important;
}
body.light .route-action-btn:hover,
body.light #js-route-btn:hover { background: #166534 !important; }
body.light .route-mode-btn {
  color: var(--ui-text-secondary) !important;
  background: #f1f5f9;
  border-color: rgba(15,23,42,0.16);
}
body.light .route-mode-btn.active {
  color: #fff !important;
  background: #178a58 !important;
  border-color: #178a58 !important;
}

body.light #desktop-left-insights,
body.light #desktop-support-panel,
body.light #desktop-route-context,
body.light #desktop-cctv-card,
body.light #route-conditions-panel {
  color: var(--ui-text-primary);
  background: rgba(255,255,255,0.98) !important;
  border-color: rgba(15,23,42,0.16) !important;
}
body.light .desktop-validation-summary {
  color: #166534 !important;
  background: #f0fdf4;
  border-color: #86efac;
}
body.light .desktop-attention-list > div,
body.light .desktop-legend-grid > div,
body.light .desktop-source-list > div {
  color: var(--ui-text-secondary) !important;
}
body.light .desktop-muted,
body.light .desktop-source-note,
body.light .desktop-mini-metrics span,
body.light .desktop-source-list > div b,
body.light .desktop-support-update,
body.light .desktop-context-empty,
body.light .desktop-context-label,
body.light .desktop-context-sub,
body.light .desktop-context-grid span,
body.light .desktop-elevation-heading span:last-child,
body.light .desktop-elevation-summary,
body.light .desktop-playback-controls {
  color: var(--ui-text-muted) !important;
}
body.light .desktop-mini-metrics strong,
body.light .desktop-context-road,
body.light .desktop-context-grid strong {
  color: var(--ui-text-primary) !important;
}
body.light .desktop-route-stop::after {
  border-color: #f8fafc;
}
body.light .desktop-chart-label,
body.light .desktop-elevation-summary {
  fill: var(--ui-text-muted);
  color: var(--ui-text-muted) !important;
}
body.light .desktop-chart-peak-label {
  fill: var(--ui-text-primary);
}
body.light .desktop-support-section + .desktop-support-section,
body.light .desktop-context-divider,
body.light .desktop-support-update,
body.light #desktop-elevation-panel:not(.hidden) {
  border-color: rgba(15,23,42,0.14) !important;
}

body.light .desktop-vehicle-tabs,
body.light .desktop-map-tools {
  background: rgba(255,255,255,0.96);
  border-color: rgba(15,23,42,0.18);
}
body.light .desktop-vehicle-tab,
body.light .desktop-map-tools button {
  color: var(--ui-text-secondary) !important;
}
body.light .desktop-vehicle-tab:hover,
body.light .desktop-vehicle-tab:focus-visible,
body.light .desktop-map-tools button:hover {
  color: var(--ui-accent-strong) !important;
  background: #dcfce7;
}
body.light .desktop-vehicle-tab.active,
body.light .desktop-map-tools button.active {
  color: #fff !important;
  background: #166534;
}
body.light .desktop-settings-popover {
  color: var(--ui-text-primary);
  background: #fff !important;
  border-color: rgba(15,23,42,0.18);
}
body.light .desktop-settings-title { color: var(--ui-text-muted) !important; }
body.light .desktop-settings-row,
body.light .desktop-settings-link { color: var(--ui-text-secondary) !important; }
body.light .desktop-settings-row span:last-child,
body.light .desktop-settings-link { color: var(--ui-accent-strong) !important; }

body.light #route-conditions-panel .condition-panel-head {
  border-bottom-color: rgba(15,23,42,0.14);
}
body.light #route-conditions-panel .condition-kicker { color: #0369a1 !important; }
body.light #route-conditions-panel .condition-title-row h2,
body.light #route-conditions-panel .condition-section-title,
body.light #route-conditions-panel .condition-metric strong {
  color: var(--ui-text-primary) !important;
}
body.light #route-conditions-panel .condition-metric,
body.light #route-conditions-panel .condition-section {
  background: #f8fafc !important;
  border-color: rgba(15,23,42,0.16) !important;
}
body.light #route-conditions-panel .condition-metric span,
body.light #route-conditions-panel .condition-section-km,
body.light #route-conditions-panel .condition-road-event-meta,
body.light #route-conditions-panel .condition-update-row,
body.light #route-conditions-panel .condition-footnote {
  color: var(--ui-text-muted) !important;
}
body.light #route-conditions-panel .condition-data-chip,
body.light #route-conditions-panel .condition-road-event-description {
  color: var(--ui-text-secondary) !important;
}
body.light #desktop-playback-speed {
  color: var(--ui-text-secondary) !important;
  background: #f8fafc;
  border-color: rgba(15,23,42,0.18);
}

body.light .desktop-cctv-heading,
body.light .desktop-cctv-meta > span,
body.light .desktop-cctv-media {
  color: var(--ui-text-secondary) !important;
}
body.light .desktop-cctv-heading span:last-child,
body.light .desktop-cctv-meta button { color: var(--ui-accent-strong) !important; }
body.light .desktop-cctv-media {
  background: #e2e8f0;
  border-color: rgba(15,23,42,0.16);
}
body.light .desktop-cctv-placeholder {
  color: #fff !important;
  background: rgba(15,23,42,0.82);
}
body.light .desktop-disclaimer {
  color: var(--ui-text-muted);
  background: rgba(248,250,252,.9);
  border-color: rgba(15,23,42,0.14);
}
body.light .desktop-disclaimer i { color: #b45309; }

body.light .maplibregl-ctrl-group {
  background: rgba(255,255,255,0.96);
  border-color: rgba(15,23,42,0.18);
}
body.light .maplibregl-ctrl-group button { filter: none; color: #334155; }
body.light .maplibregl-ctrl-attrib {
  color: #475569;
  background: rgba(255,255,255,0.86) !important;
}
body.light .maplibregl-ctrl-attrib a { color: #334155; }

body.light .local-map-place-label {
  color: #12352a !important;
  background: rgba(255,255,255,0.96) !important;
  border-color: rgba(22,101,52,0.48) !important;
  box-shadow: 0 2px 9px rgba(15,23,42,0.32), 0 0 0 1px rgba(255,255,255,0.7);
}
body.light .map-control-stack > button {
  color: var(--ui-text-secondary) !important;
  background: rgba(255,255,255,0.92) !important;
  border-color: rgba(15,23,42,0.18) !important;
}
body.light .map-control-stack > button#js-loc { color: #c2410c !important; }

body.light .pwa-action-banner span,
body.light .pwa-install-nudge-copy span { color: var(--ui-text-muted); }
body.light #pwa-install-nudge-close { color: var(--ui-text-secondary); background: #e2e8f0; }

/* v31 desktop density pass: keep the command center focused on the map at
   normal desktop heights. Short viewports retain the existing compact rule. */
@media (min-width: 1200px) and (min-height: 821px) {
  main { min-height: 0; }
  #pg-map.active { min-height: 0; grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail); }
}

@media (min-width: 1400px) and (min-height: 821px) {
  :root { --desktop-header-height: 4rem; }
}

/* v38 keeps the lower intelligence strip readable at the reference desktop
   height while the central map remains the dominant surface. */
@media (min-width: 1200px) and (min-height: 821px) {
  #pg-map.active { grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail); }
  .map-control-stack, #nearby-panel { bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
}
@media (min-width: 1200px) and (max-width: 1399px) and (min-height: 821px) {
  #pg-map.active { grid-template-rows: minmax(0, 1fr) var(--desktop-bottom-rail); }
  .map-control-stack, #nearby-panel { bottom: calc(var(--desktop-bottom-rail) + .7rem) !important; }
  #desktop-elevation-chart { min-height: 5.2rem; }
}

/* === route-filmstrip.js：沿途 CCTV 膠卷增強（新鮮度 + 休息站重檢） === */
/* 卡片放大到手機可視尺寸（覆蓋上方 .strip-cam 140px） */
.strip-cam { flex: 0 0 240px; width: 240px; }
.strip-cam-img { height: 135px; }
/* 新鮮度 badge：左上小藥丸，綠點 = 新鮮 */
.strip-cam-fresh {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  font-size: 9px; font-weight: 800; color: #e2e8f0;
  background: rgba(2,6,23,0.72);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2px 7px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
  pointer-events: none; white-space: nowrap;
}
.strip-cam-fresh::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; flex-shrink: 0;
}
/* 疑似過期（>15 分鐘未更新）：影像灰階 + 琥珀色 badge */
.strip-cam.is-stale .strip-cam-img img { filter: grayscale(0.7) brightness(0.75); }
.strip-cam.is-stale .strip-cam-fresh { color: #fbbf24; border-color: rgba(251,191,36,0.5); }
.strip-cam.is-stale .strip-cam-fresh::before { background: #f59e0b; }
/* 路線 banner 內的「休息站重檢」按鈕 */
.rb-action-btn {
  font-size: 10px; font-weight: 700; color: #38bdf8;
  background: transparent; border: none; cursor: pointer;
  margin-left: 4px; padding: 2px 4px;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.rb-action-btn:hover { color: #7dd3fc; }
.rb-action-btn:disabled { opacity: 0.5; cursor: wait; }

/* ===== 快照誠實化（行動 5）：官方快照 vs 推估資料的設計語言 ===== */
/* 官方快照：冷色實心小標籤；推估：琥珀色虛線框。不貼工程術語。 */
.snapshot-chip {
  display: inline-block; font-size: 10px; font-weight: 800;
  color: #a5f3fc; background: rgba(8,145,178,0.18);
  border: 1px solid rgba(34,211,238,0.35);
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.snapshot-chip.is-proxy {
  color: #fcd34d; background: rgba(245,158,11,0.10);
  border: 1px dashed rgba(251,191,36,0.65);
}
.snapshot-chip.is-snapshot { color: #fdba74; background: rgba(249,115,22,0.12); border-color: rgba(249,115,22,0.4); }
.snapshot-chip.is-stale { color: #fca5a5; background: rgba(239,68,68,0.10); border-color: rgba(248,113,113,0.5); }
.snapshot-age { font-size: 10px; font-weight: 700; color: #94a3b8; white-space: nowrap; }
.snapshot-age.is-stale { color: #fca5a5; }

/* ===== 降級 UX：誠實的缺席（行動 7） ===== */
.data-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(30,41,59,0.6); border: 1px solid rgba(251,191,36,0.25);
  border-radius: 16px; padding: 12px 14px; text-align: left;
}
.data-notice-icon { color: #fbbf24; font-size: 16px; margin-top: 2px; flex-shrink: 0; }
.data-notice-copy { flex: 1; min-width: 0; }
.data-notice-title { font-size: 12px; font-weight: 900; color: #f1f5f9; }
.data-notice-body { font-size: 11px; color: #94a3b8; margin-top: 3px; line-height: 1.6; }
.data-notice-retry {
  flex-shrink: 0; font-size: 11px; font-weight: 800; color: #38bdf8;
  background: rgba(56,189,248,0.12); border: 1px solid rgba(56,189,248,0.4);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; align-self: center;
}
.data-notice-retry:hover { background: rgba(56,189,248,0.22); }

/* ===== 30 秒總結條（行動 10） ===== */
.ride-verdict-shell { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ride-verdict-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: #64748b; }
.ride-verdict-dot.is-go { background: #22c55e; box-shadow: 0 0 10px rgba(34,197,94,0.7); }
.ride-verdict-dot.is-caution { background: #f59e0b; box-shadow: 0 0 10px rgba(245,158,11,0.7); }
.ride-verdict-dot.is-stop { background: #ef4444; box-shadow: 0 0 10px rgba(239,68,68,0.8); animation: verdict-pulse 1.6s ease-in-out infinite; }
.ride-verdict-dot.is-idle { background: #64748b; }
@keyframes verdict-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.ride-verdict-headline { font-size: 13px; font-weight: 900; color: #f1f5f9; line-height: 1.3; }
.ride-verdict-sub { font-size: 10px; color: #94a3b8; margin-top: 2px; line-height: 1.5; }
.ride-verdict-feedback {
  flex-shrink: 0; font-size: 10px; font-weight: 800; color: #7dd3fc;
  text-decoration: none; border: 1px solid rgba(125,211,252,0.35);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.ride-verdict-feedback:hover { background: rgba(125,211,252,0.12); }
.ride-verdict-feedback-block { display: inline-block; margin-top: 8px; }
