/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --header-h: 52px;
  --sidebar-w: 280px;
  --detail-w: 340px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --red: #DC2626;
  --amber: #F59E0B;
  --green: #059669;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --transition-fast: 0.15s;
  --transition-normal: 0.3s;
  --transition-panel: 0.35s;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body { height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }

/* === Header === */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 12px; gap: 12px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-title h1 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.header-subtitle { font-size: 11px; color: var(--text-muted); }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

.header-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text);
  transition: all var(--transition-fast);
}
.header-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.header-btn:active { transform: scale(0.95); }
.header-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === Search Bar === */
.header-search { flex: 1; display: flex; align-items: center; max-width: 400px; margin: 0 8px; }
.search-toggle-btn { display: none; }
.search-wrapper { position: relative; flex: 1; }
#search-input {
  width: 100%; padding: 7px 32px 7px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: var(--font); color: var(--text);
  background: var(--bg); outline: none; transition: border var(--transition-fast), box-shadow var(--transition-fast);
}
#search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
#search-input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 18px; color: var(--text-muted);
  cursor: pointer; display: none; padding: 2px 4px; line-height: 1;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--text); }

/* Search pin info window */
.search-pin-info { min-width: 200px; }
.search-pin-info h4 { font-size: 14px; margin-bottom: 4px; color: #111827; }
.search-pin-info .search-pin-addr { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.search-pin-info .search-pin-dist { font-size: 12px; color: #059669; margin-bottom: 8px; }
.search-pin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.search-pin-btn {
  padding: 5px 10px; border: none; border-radius: 4px;
  font-size: 11px; cursor: pointer; font-family: var(--font);
}
.search-pin-btn.primary { background: var(--primary); color: #fff; }
.search-pin-btn.secondary { background: #f3f4f6; color: #374151; }
.search-pin-btn:hover { opacity: 0.85; }

/* === Main Layout === */
#main {
  position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
  display: flex;
}

/* === Sidebar / Drawer Shell === */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: margin-left var(--transition-normal);
  z-index: 20;
}
#sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

/* Drawer Header */
.drawer-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #1e293b 0%, #2d4a6e 100%);
  color: #fff;
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.drawer-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.drawer-brand { display: flex; align-items: center; gap: 10px; }
.drawer-brand-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-brand-text { display: flex; flex-direction: column; }
.drawer-brand-title { font-size: 14px; font-weight: 700; line-height: 1.25; }
.drawer-brand-sub { font-size: 10px; opacity: 0.65; letter-spacing: 0.3px; }
.drawer-close-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; color: #fff; cursor: pointer;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.drawer-close-btn:hover { background: rgba(255,255,255,0.25); }
.drawer-stats { font-size: 11px; color: rgba(255,255,255,0.7); font-weight: 400; }

/* Tab Navigation */
.drawer-tabs {
  flex-shrink: 0;
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.drawer-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 9px 4px 8px;
  background: none;
  border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 10px; font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.4px; text-transform: uppercase;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  font-family: var(--font);
}
.drawer-tab:hover { color: var(--primary); background: var(--primary-light); }
.drawer-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}
.drawer-tab svg { flex-shrink: 0; }

/* Scrollable Tab Content */
.drawer-content { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

/* Tab Panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.sidebar-section { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-section h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 12px; }

/* Filters */
.filter-group { margin-bottom: 10px; }
.filter-group label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 3px; color: var(--text-muted); }
.filter-group input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 5px;
  font-size: 13px; background: var(--bg);
  transition: border-color var(--transition-fast);
}
.filter-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.filter-group select {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 5px;
  font-size: 13px; background: var(--bg);
  transition: border-color var(--transition-fast);
  font-family: inherit; color: var(--text);
}
.filter-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }

.btn {
  padding: 7px 14px; border: none; border-radius: 5px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--transition-fast);
}
.btn:active { transform: scale(0.97); }
.btn-clear { width: 100%; margin-top: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }
.btn-clear:hover { background: #fee2e2; color: var(--red); border-color: var(--red); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338CA; }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: #f1f5f9; }

.stats-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Legend */
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,0.1); flex-shrink: 0; }

/* Infrastructure Toggles */
.infra-toggle-item { margin-bottom: 6px; }
.infra-toggle-item label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer;
}
.infra-toggle-item input[type="checkbox"] {
  width: 14px; height: 14px; cursor: pointer;
}
.infra-dot {
  width: 20px; height: 20px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}

/* POI / Map Layer Toggles */
.infra-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer;
  padding: 6px 0;
}
.infra-toggle input[type="checkbox"] {
  width: 14px; height: 14px; cursor: pointer; flex-shrink: 0;
}
.infra-badge {
  width: 20px; height: 20px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
#global-poi-toggles {
  display: flex; flex-direction: column; gap: 2px;
}

/* === Map === */
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* === InfoWindow === */
.iw-content { padding: 2px; min-width: 180px; }
.iw-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.iw-name { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.iw-row { font-size: 12px; display: flex; justify-content: space-between; padding: 2px 0; }
.iw-row span { color: var(--text-muted); }
.iw-status { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.iw-vulnerable { background: #FEE2E2; color: var(--red); }
.iw-semiVulnerable { background: #FEF3C7; color: #B45309; }
.iw-safe { background: #D1FAE5; color: var(--green); }

/* === Detail Panel === */
#detail-panel {
  position: absolute; top: 0; right: -360px; bottom: 0;
  width: var(--detail-w);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transition: right var(--transition-panel) var(--ease-out-expo);
  z-index: 30;
}
#detail-panel.open { right: 0; }

.dp-header { padding: 16px; background: linear-gradient(135deg, #1e293b, #334155); color: #fff; }
.dp-title-row { display: flex; justify-content: space-between; align-items: flex-start; }
.dp-title-row h2 { font-size: 20px; }
.dp-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 24px; cursor: pointer; line-height: 1; }
.dp-close:hover { color: #fff; }
.dp-station-name { font-size: 13px; opacity: 0.85; margin: 4px 0 8px; }
.dp-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.dp-vulnerable { background: var(--red); color: #fff; }
.dp-semiVulnerable { background: var(--amber); color: #000; }
.dp-safe { background: var(--green); color: #fff; }

/* Photo Carousel */
.photo-carousel { position: relative; width: 100%; background: #000; overflow: hidden; }
.photo-carousel .photo-track { display: flex; transition: transform 0.3s ease; }
.photo-carousel .photo-slide { min-width: 100%; position: relative; }
.photo-carousel .photo-slide img { width: 100%; height: 200px; object-fit: cover; display: block; }
.photo-carousel .photo-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.5); color: #fff; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; transition: background 0.2s; }
.photo-carousel .photo-nav:hover { background: rgba(0,0,0,0.8); }
.photo-carousel .photo-prev { left: 8px; }
.photo-carousel .photo-next { right: 8px; }
.photo-carousel .photo-counter { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.6); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; z-index: 2; }
.photo-carousel .photo-attr { position: absolute; bottom: 8px; left: 8px; color: rgba(255,255,255,0.7); font-size: 10px; z-index: 2; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-loading { padding: 20px; text-align: center; color: var(--text-muted); font-size: 12px; background: #f1f5f9; }
.photo-none { display: none; }

.dp-section { padding: 14px 16px; border-bottom: 1px solid var(--border); overflow: hidden; }
.dp-section h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: #fff; background: #64748b; margin: -14px -16px 12px; padding: 8px 16px; }
.dp-section h4 { font-size: 12px; font-weight: 600; color: #374151; background: #f1f5f9; border-left: 3px solid #cbd5e1; margin: 10px -16px 6px; padding: 5px 16px; }

/* Section colour overrides */
[data-section="location"] h3 { background: #3730A3; }
[data-section="demographics"] h3 { background: #5B21B6; }
[data-section="demographics"] h4 { background: #F5F3FF; border-left-color: #7C3AED; color: #5B21B6; }
[data-section="election-2024"] h3 { background: #92400E; }
[data-section="election-2024"] h4 { background: #FFFBEB; border-left-color: #D97706; color: #92400E; }
[data-section="election-2021"] h3 { background: #9A3412; }
[data-section="election-2021"] h4 { background: #FFF7ED; border-left-color: #EA580C; color: #9A3412; }
[data-section="status"] h3 { background: #991B1B; }
[data-section="blo"] h3 { background: #374151; }
[data-section="sector"] h3 { background: #065F46; }
[data-section="sector"] h4 { background: #ECFDF5; border-left-color: #10B981; color: #065F46; }
[data-section="sector-officer"] h3 { background: #065F46; }
[data-section="sector-assistant"] h3 { background: #0F766E; }
[data-section="police"] h3 { background: #1E3A5F; }
[data-section="booths"] h3 { background: #3730A3; }
[data-section="poi"] h3 { background: #0F766E; }

.dp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-item { display: flex; flex-direction: column; }
.dp-item label { font-size: 11px; color: var(--text-muted); }
.dp-item span { font-size: 13px; font-weight: 500; }
.dp-margin { color: var(--primary); font-weight: 700; }

/* POI */
.dp-poi-loading { font-size: 13px; color: var(--text-muted); padding: 8px 0; }
.poi-category { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.poi-category:first-child { margin-top: 0; }
.poi-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; border-radius: 4px; }
.poi-item:hover { background: var(--bg); }
.poi-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.poi-info { flex: 1; }
.poi-name { font-size: 13px; font-weight: 500; }
.poi-dist { font-size: 11px; color: var(--text-muted); }
.poi-empty { font-size: 13px; color: var(--text-muted); padding: 8px 0; }

/* === Route Section (in sidebar) === */
.route-actions { display: flex; gap: 6px; margin: 8px 0; }

/* Start point indicator */
.route-start-point {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 14px;
  background: #EEF2FF; border: 1px solid #c7d2fe;
  border-radius: 8px; font-size: 13px; color: var(--text-muted);
  transition: all var(--transition-fast);
}
.route-start-point.ready {
  background: #ECFDF5; border-color: #a7f3d0; color: #065f46;
}
.route-start-point.error {
  background: #FEF2F2; border-color: #fca5a5; color: #991b1b;
}
.route-start-icon { flex-shrink: 0; display: flex; align-items: center; }
.route-start-label { font-size: 12px; font-weight: 500; line-height: 1.3; }

/* Destination type selector */
.dest-type-group {
  display: flex; gap: 6px; margin-bottom: 14px;
}
.dest-type-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 10px;
  background: var(--surface);
  transition: all var(--transition-fast);
  text-align: center;
}
.dest-type-card input[type="radio"] { display: none; }
.dest-type-card:hover { border-color: var(--primary); background: var(--primary-light); }
.dest-type-card.active {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.dest-type-icon { font-size: 20px; line-height: 1; }
.dest-type-name { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); }
.dest-type-card.active .dest-type-name { color: var(--primary); }

/* Destination filter containers */
.dest-filters { margin-bottom: 8px; }

/* DC RC destination info */
.dcrc-dest-info {
  padding: 10px 12px; background: #FEF2F2;
  border: 1px solid #fca5a5; border-radius: 8px;
  margin-bottom: 8px;
}
.dcrc-dest-name { font-size: 13px; font-weight: 600; color: #991b1b; margin-bottom: 2px; }
.dcrc-dest-location { font-size: 12px; color: #b91c1c; }

/* Route summary card */
.route-summary-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; margin: 12px 0;
}
.route-summary-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px;
}
.route-summary-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.route-summary-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; }
.route-summary-label { flex: 1; color: var(--text-muted); }
.route-summary-value { font-size: 14px; color: var(--text); }

/* Route calculating / error */
.route-calculating { font-size: 13px; color: var(--text-muted); padding: 12px 0; text-align: center; }
.route-error { font-size: 13px; color: var(--red); padding: 12px 0; text-align: center; }

/* Start Navigation button */
.btn-nav-start {
  width: 100%; padding: 14px 16px; margin-top: 8px;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
  transition: all var(--transition-fast);
  font-family: var(--font);
}
.btn-nav-start:hover { background: linear-gradient(135deg, #047857, #065f46); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4); }
.btn-nav-start:active { transform: scale(0.98); }

/* Filter button row */
.filter-btn-row { display: flex; gap: 8px; margin-top: 8px; }
.filter-btn-row .btn { flex: 1; }

.wp-empty { font-size: 13px; color: var(--text-muted); padding: 8px 0; }
.wp-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.wp-num { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.wp-name { flex: 1; }
.wp-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
.wp-remove:hover { color: var(--red); }

.route-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; pointer-events: none; }
.drawer-tab { position: relative; }

.route-total { padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 6px; font-size: 14px; }
.route-travel-modes { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--text-muted); }
.travel-mode { display: flex; align-items: center; gap: 2px; }
.route-leg { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.leg-label { color: var(--text); }
.leg-detail { color: var(--text-muted); }

/* === Toast === */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 20px; border-radius: 8px; font-size: 13px; color: #fff; box-shadow: var(--shadow-lg); transition: opacity var(--transition-normal); }
.toast-info { background: #334155; }
.toast-warn { background: var(--amber); color: #000; }
.toast-error { background: var(--red); }
.toast-fade { opacity: 0; }

/* === Mobile === */
@media (max-width: 768px) {
  :root { --detail-w: 100%; }

  /* Elevate #main above the header so the fixed-position drawer
     paints on top of the header bar (which is z:100 in root context) */
  #main { z-index: 110; }

  /* Left-side slide-in drawer (replaces bottom sheet) */
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 78vw; max-width: 320px;
    height: 100%;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 28px rgba(0,0,0,0.22);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform var(--transition-panel) var(--ease-out-expo);
    margin-left: 0 !important;
    will-change: transform;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar.dragging { transition: none !important; }
  #sidebar::before { display: none; }

  /* Backdrop sits between map and drawer */
  .backdrop { z-index: 45; }

  .btn-label { display: none; }

  /* 5 tabs on mobile: smaller text */
  .drawer-tab { font-size: 9px; padding: 8px 2px 7px; gap: 2px; }

  /* Mobile filter controls */
  .filter-group { margin-bottom: 12px; }
  .filter-group label { font-size: 13px; margin-bottom: 5px; font-weight: 600; color: var(--text); }
  .filter-group select {
    font-size: 16px; padding: 10px 12px; border-radius: 8px;
    min-height: 44px;
  }
  .filter-group input {
    font-size: 16px; padding: 10px 12px; border-radius: 8px;
    min-height: 44px;
  }

  /* Mobile search: icon button + expandable overlay */
  .header-search { max-width: none; margin: 0; flex: 0; }
  .search-toggle-btn { display: flex; }
  .search-wrapper {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h); padding: 8px 12px; z-index: 110;
    background: var(--surface); box-shadow: var(--shadow-lg);
  }
  .search-wrapper.mobile-open { display: flex; align-items: center; }
  .search-wrapper.mobile-open #search-input { font-size: 16px; }

  #detail-panel {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: 75vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform var(--transition-panel) var(--ease-out-expo);
    z-index: 48;
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  #detail-panel.open { transform: translateY(0); right: auto; bottom: 0; }
  #detail-panel.dragging { transition: none !important; }

  #detail-panel::before {
    content: '';
    display: block; width: 36px; height: 4px;
    background: rgba(255,255,255,0.4); border-radius: 2px;
    margin: 8px auto;
  }

  /* Mobile detail panel typography */
  .dp-header { padding: 20px 16px 16px; }
  .dp-title-row h2 { font-size: 22px; }
  .dp-section { padding: 16px; }
  .dp-section h3 { font-size: 13px; margin: -16px -16px 12px; padding: 9px 16px; }
  .dp-section h4 { margin: 10px -16px 6px; padding: 5px 16px; }
  .dp-item span { font-size: 14px; }
  .dp-item label { font-size: 12px; }
  .dp-grid { gap: 12px; }
  .dp-badge { font-size: 12px; padding: 4px 12px; }

  /* Mobile toast positioning */
  #toast-container { bottom: calc(20px + env(safe-area-inset-bottom, 0)); }

  /* Mobile nav panel */
  .nav-distance { font-size: 32px; }
  .nav-instruction { font-size: 16px; }
  .nav-icon { width: 56px; height: 56px; font-size: 28px; }

  /* Active/press states for touch */
  .wp-remove:active { color: var(--red); transform: scale(1.2); }
  .poi-item:active { background: var(--bg); }

  /* Mobile destination type cards */
  .dest-type-card { padding: 12px 6px; }
  .dest-type-icon { font-size: 22px; }
  .dest-type-name { font-size: 10px; }

  /* Mobile nav start button */
  .btn-nav-start { padding: 16px; font-size: 16px; }
}

@media (min-width: 769px) {
  #btn-sidebar-toggle { display: none; }
  .drawer-close-btn { display: none; }
}

/* === Backdrop Overlay === */
.backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 35;
  pointer-events: none;
  transition: background var(--transition-normal);
}
.backdrop.visible {
  background: rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

/* === Navigation Panel === */
.nav-panel { padding: 8px 0; }
.nav-maneuver {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.nav-icon {
  width: 48px; height: 48px;
  background: var(--primary); color: #fff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.nav-distance { font-size: 28px; font-weight: 700; color: var(--text); }
.nav-instruction {
  font-size: 15px; color: var(--text);
  line-height: 1.5; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.nav-meta {
  display: flex; justify-content: space-between;
  padding: 8px 0; font-size: 13px; color: var(--text-muted);
}
.nav-actions { display: flex; gap: 8px; padding-top: 8px; }
.nav-actions .btn { flex: 1; }

/* === Navigation Overlay (fullscreen map-style navigation) === */
.nav-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 400;
}
.nav-overlay.hidden { display: none; }

.nav-top-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(135deg, #4F46E5, #3730a3);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
  box-shadow: 0 2px 16px rgba(0,0,0,0.35);
}
.nav-overlay-icon {
  font-size: 38px;
  min-width: 52px;
  text-align: center;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.nav-top-text { flex: 1; min-width: 0; }
.nav-overlay-dist {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}
.nav-overlay-instr {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-bottom-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.15);
}
.nav-bottom-info { flex: 1; }
.nav-bottom-eta {
  font-size: 26px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}
.nav-bottom-remaining {
  font-size: 13px;
  color: #6b7280;
  margin-top: 2px;
}
.nav-bottom-actions { display: flex; gap: 8px; align-items: center; }
.nav-voice-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background var(--transition-fast);
}
.nav-voice-btn:hover { background: #f3f4f6; }
.nav-stop-btn {
  background: #DC2626;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-stop-btn:hover { background: #b91c1c; }

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0.01ms;
    --transition-normal: 0.01ms;
    --transition-panel: 0.01ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Cluster / Group Marker Menu */
.cluster-menu { min-width: 200px; max-width: 280px; }
.cluster-title { font-size: 13px; font-weight: 600; color: #374151; padding: 4px 0 8px; border-bottom: 1px solid #e5e7eb; margin-bottom: 4px; }
.cluster-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-radius: 6px; cursor: pointer; transition: background var(--transition-fast); }
.cluster-item:hover { background: #f3f4f6; }
.cluster-item:active { background: #e5e7eb; }
.cluster-item strong { font-size: 13px; color: #111827; }
.cluster-item-name { font-size: 11px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cluster-item-voters { font-size: 11px; color: #059669; }

/* Sector booth tags */
/* Sector booth list rows */
.sector-booth-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid #f3f4f6; cursor: pointer; transition: background var(--transition-fast); }
.sector-booth-row:hover { background: #f3f4f6; }
.sector-booth-row:active { background: #e5e7eb; }
.sector-booth-row:last-child { border-bottom: none; }
.sector-booth-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sector-booth-info strong { font-size: 13px; color: #111827; }
.sector-booth-name { font-size: 11px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sector-booth-dist { text-align: right; font-size: 11px; color: #059669; display: flex; flex-direction: column; gap: 1px; white-space: nowrap; }
.sector-booth-drive { color: #6b7280; }
.sector-booth-arrow { color: #9ca3af; font-size: 18px; font-weight: bold; }

/* Back button in detail panel */
.dp-back { background: none; border: none; color: #4F46E5; font-size: 13px; cursor: pointer; padding: 4px 0; font-weight: 500; }
.dp-back:hover { text-decoration: underline; }

/* Title actions (star + close) */
.dp-title-actions { display: flex; align-items: center; gap: 4px; }

/* Bookmark star */
.bookmark-star { background: none; border: none; font-size: 22px; cursor: pointer; color: #d1d5db; padding: 2px; line-height: 1; }
.bookmark-star.filled { color: #f59e0b; }
.bookmark-star:hover { color: #f59e0b; }

/* Bookmark list in sidebar */
.bookmark-item { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid #f3f4f6; cursor: pointer; transition: background var(--transition-fast); }
.bookmark-item:hover { background: #f3f4f6; }
.bookmark-item:active { background: #e5e7eb; }
.bookmark-item:last-of-type { border-bottom: none; }
.bookmark-badge { font-size: 9px; font-weight: 600; color: #fff; padding: 2px 5px; border-radius: 3px; white-space: nowrap; }
.bookmark-name { flex: 1; font-size: 12px; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-del { background: none; border: none; font-size: 16px; color: #d1d5db; cursor: pointer; padding: 0 4px; line-height: 1; }
.bookmark-del:hover { color: #dc2626; }

/* === Distance Calculator Tab === */
.calc-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.4; }
.calc-add-section { margin-bottom: 16px; }
.calc-waypoint-list { margin: 8px 0; }
.calc-actions { display: flex; gap: 8px; margin: 12px 0; }
.calc-legs { margin-top: 8px; padding: 8px 0; border-top: 1px solid var(--border); }

/* Shared button styles for calc */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition-fast); font-family: var(--font); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338CA; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); }
