:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #111827;
  --bg-glass: rgba(15, 23, 42, 0.78);
  --bg-glass-card: rgba(30, 41, 59, 0.65);
  --bg-glass-hover: rgba(51, 65, 85, 0.65);
  
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Map Canvas */
#map-container {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: #0f172a;
}

/* Glass Floating Header on Map */
.map-floating-header {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, #ffffff 40%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.preset-dropdown {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.preset-dropdown:focus {
  border-color: var(--accent-emerald);
}

/* Map Hint Overlay */
.map-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
  animation: fadeInDown 0.6s ease-out;
}

.hint-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseDot 2s infinite;
}

/* Sidebar Styling */
.sidebar {
  width: 420px;
  min-width: 380px;
  height: 100%;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-glass);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 1001;
}

.sidebar-scroll {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Philosophy Card */
.philosophy-card {
  padding: 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(6, 182, 212, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
}

.pill-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-emerald);
}

.philosophy-desc {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Section Cards */
.section-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.section-title svg {
  color: var(--accent-emerald);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.label-with-value {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.highlight-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-emerald);
}

/* Mode Selector Buttons */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.15);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
  border-color: var(--accent-emerald);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-emerald-glow);
}

.mode-icon {
  font-size: 1.3rem;
}

.mode-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.mode-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: center;
}

.mode-btn.active .mode-sub {
  color: #a7f3d0;
}

/* Distance Slider */
.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Budget type toggle (Distance / Duration) */
.budget-type-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.budget-type-btn {
  flex: 1;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
}

.budget-type-btn:hover {
  border-color: rgba(16, 185, 129, 0.5);
  color: var(--text-main);
}

.budget-type-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

/* Destination marker (A → B routes) */
.custom-dest-icon {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 4px;
  background: rgba(245, 158, 11, 0.25);
  border: 2px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-45deg);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.custom-dest-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
}

/* Route composition list */
.top-roads-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.top-road-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.top-road-item .road-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-main);
}

.top-road-item .road-len {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.top-road-item .road-scenic {
  font-size: 12px;
  flex-shrink: 0;
}

/* Via point marker */
.custom-via-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.3);
  border: 2px solid #8b5cf6;
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

/* Right-click context menu */
.context-menu {
  position: absolute;
  z-index: 1200;
  min-width: 210px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.context-menu-item:hover {
  background: rgba(16, 185, 129, 0.16);
}

.context-menu-item .ctx-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.context-menu-divider {
  height: 1px;
  margin: 5px 8px;
  background: rgba(255, 255, 255, 0.09);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.slider-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.slider-subtext strong {
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* Origin Display Box */
.coord-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

.coord-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-rose);
  box-shadow: 0 0 8px var(--accent-rose);
}

.coord-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#coord-display {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
}

.coord-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.mini-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.mini-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-main);
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

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

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* Spinner */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Stats Section */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-badge {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-number {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-main);
}

.metric-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Distribution Block */
.distribution-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.distribution-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.dist-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.dist-subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.multi-bar {
  display: flex;
  height: 12px;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.bar-slice {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.slice-pedestrian { background: #10b981; }    /* Emerald */
.slice-residential { background: #06b6d4; }   /* Cyan */
.slice-secondary { background: #f59e0b; }     /* Amber */
.slice-arterial { background: #f43f5e; }      /* Rose */

.dist-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 0.75rem;
}

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

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

.dot-pedestrian { background: #10b981; }
.dot-residential { background: #06b6d4; }
.dot-secondary { background: #f59e0b; }
.dot-arterial { background: #f43f5e; }

.legend-name {
  color: var(--text-muted);
}

.legend-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
  margin-left: auto;
}

/* Costing Explainer Box */
.costing-explain-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.explain-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 4px;
}

.explain-text {
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.badge-code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  color: #f1f5f9;
}

/* Error Banner */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fecdd3;
  font-size: 0.82rem;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Leaflet Custom Marker & Popup Overrides */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.9) !important;
  backdrop-filter: blur(12px) !important;
  color: #fff !important;
  border: 1px solid var(--border-glass) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.9) !important;
}

.custom-anchor-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #06b6d4;
  border: 2px solid #fff;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.8);
}

.custom-origin-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #10b981;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.9);
}

.custom-origin-inner {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

/* Provider & CRS Configuration Styling */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pill-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 5px;
  background-color: var(--text-muted);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  pointer-events: none;
}

.custom-select {
  width: 100%;
  padding: 10px 32px 10px 14px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.custom-select option {
  background: #0f172a;
  color: #f8fafc;
}

.custom-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s ease;
}

.custom-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.custom-input.invalid {
  border-color: rgba(244, 63, 94, 0.75);
}

.field-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.field-hint a {
  color: var(--accent-emerald);
}

.field-error {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #fecdd3;
}

.custom-tile-grid {
  margin-top: 0;
}

.provider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.provider-grid-stack {
  grid-template-columns: 1fr;
}

.provider-source-hint {
  grid-column: 1 / -1;
  margin-top: 0;
}

.crs-pill-banner {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: #a5f3fc;
}

.crs-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
  animation: pulseDot 2s infinite ease-in-out;
  flex-shrink: 0;
}

.crs-indicator-text {
  font-family: var(--font-mono);
  line-height: 1.3;
}



/* ============ Mobile / Narrow Screens (≤ 860px) ============ */
@media (max-width: 860px) {
  #app {
    flex-direction: column;
  }

  /* Map takes the upper portion */
  #map-container {
    flex: 1 1 56%;
    min-height: 0;
  }

  /* Sidebar becomes a bottom sheet */
  .sidebar {
    width: 100%;
    min-width: 0;
    flex: 0 0 44%;
    height: auto;
    order: 2;
    border-left: none;
    border-top: 1px solid var(--border-glass);
    border-radius: 18px 18px 0 0;
    margin-top: -16px;
    z-index: 1100;
  }

  .sidebar-scroll {
    padding: 18px 16px 28px;
    gap: 16px;
  }

  /* Drag handle affordance for the bottom sheet */
  .sidebar::before {
    content: '';
    display: block;
    width: 42px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
  }

  /* Compact floating header */
  .map-floating-header {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 16px;
    flex-wrap: wrap;
  }

  .brand-text {
    display: none; /* icon-only brand on phones */
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .header-actions .icon-btn span {
    display: none; /* icon-only buttons */
  }

  .preset-dropdown {
    max-width: 132px;
    font-size: 12px;
  }

  /* Hide philosophy banner on small screens */
  .philosophy-card {
    display: none;
  }

  /* Denser mode picker */
  .mode-sub {
    display: none;
  }

  .mode-btn {
    padding: 8px 6px;
  }

  /* Metrics stay 2×2 but tighter */
  .metrics-grid {
    gap: 8px;
  }

  /* Context menu slightly wider tap targets */
  .context-menu-item {
    padding: 11px 12px;
    font-size: 14px;
  }
}

/* Very small phones */
@media (max-width: 400px) {
  .custom-tile-grid {
    grid-template-columns: 1fr;
  }

  .preset-dropdown {
    max-width: 104px;
  }

  .map-hint {
    font-size: 11px;
    left: 10px;
    right: 10px;
    text-align: center;
  }
}


