:root {
  --bg: #0a0e14;
  --panel: rgba(14, 19, 28, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef6;
  --muted: #8a97a8;
  --metro: #e03a3a;
  --bbb: #2e9bff;
  --accent: #4be0a0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  overflow: hidden;
}
#map { position: absolute; inset: 0; }

/* keep the dark basemap reading cool and recessed so the data pops */
.maplibregl-canvas { filter: saturate(0.6) brightness(0.9); }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: 0.5; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(8,11,16,0.85) 0%, rgba(8,11,16,0) 100%);
  pointer-events: none;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(75, 224, 160, 0.18), 0 0 16px rgba(75, 224, 160, 0.7);
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.4px; font-weight: 650; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); letter-spacing: 0.3px; }
#clock { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); letter-spacing: 1px; }

#panel {
  position: absolute; top: 84px; right: 22px; width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(10px);
  z-index: 5;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5);
}
#panel h2 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); font-weight: 600; }
#panel .lead { margin: 0 0 16px; font-size: 15px; line-height: 1.45; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; text-align: center; }
.stat .num { display: block; font-size: 24px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.stat .lbl { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.25; }

.insight {
  font-size: 13.5px; line-height: 1.5; color: var(--text);
  background: rgba(75, 224, 160, 0.08);
  border-left: 3px solid var(--accent);
  padding: 11px 13px; border-radius: 8px; margin: 0 0 16px;
}
.insight b { color: var(--accent); }

.legend { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text); }
.swatch { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.swatch.ring { background: transparent; border: 2.5px solid var(--accent); box-shadow: 0 0 8px rgba(75,224,160,0.6); }

.source { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }

#controls {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 5;
}
.ctl {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 20px; font-size: 13.5px; font-weight: 550; cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ctl:hover { background: rgba(255,255,255,0.08); }
.ctl:active { transform: scale(0.97); }
.ctl.on { border-color: var(--accent); color: var(--accent); }
.ctl.active { background: var(--accent); color: #04130c; border-color: var(--accent); }

#displayHint {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--muted); letter-spacing: 1px;
  opacity: 0; pointer-events: none; transition: opacity 0.4s; z-index: 6;
}

/* display mode: hide chrome, keep the live picture */
body.display #topbar { background: none; }
body.display #panel { top: 50%; transform: translateY(-50%); }
body.display #controls { opacity: 0; pointer-events: none; }
body.display #displayHint { opacity: 1; }

/* dark popup for shared-stop hover */
.twin-popup .maplibregl-popup-content {
  background: #0e131c; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; padding: 9px 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.twin-popup .maplibregl-popup-tip { border-top-color: #0e131c; border-bottom-color: #0e131c; }
.twin-popup strong { color: var(--accent); }
