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

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --gfs: #58a6ff;
  --euro: #ffa657;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 50px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#header-left { display: flex; align-items: baseline; gap: 12px; }
h1 { font-size: 17px; font-weight: 600; }
#forecast-label { font-size: 12px; color: var(--muted); }
#header-right { display: flex; align-items: center; gap: 10px; }
#model-toggle, #unit-toggle { display: flex; gap: 3px; }

.model-btn, .unit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.12s;
}
.model-btn.active, .unit-btn.active {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--muted);
}
.model-btn:hover, .unit-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── Main ── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Map ── */
#map-panel {
  flex: 1;
  position: relative;
  min-width: 0;
}
#map { width: 100%; height: 100%; }

#time-display {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 500;
  background: rgba(13,17,23,0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  pointer-events: none;
}
#current-time-local { display: block; font-size: 13px; font-weight: 500; }
#current-time-z { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

#map-legend {
  position: absolute;
  bottom: 28px;
  left: 10px;
  z-index: 500;
  background: rgba(13,17,23,0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px 6px;
  pointer-events: none;
}
#legend-canvas { display: block; border-radius: 2px; }
#map-legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 10px;
  color: var(--muted);
}

/* ── Chart panel ── */
#chart-panel {
  width: 600px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#location-header {
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#location-header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#peak-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
#panel-size-btns { display: flex; gap: 3px; }
.panel-size-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.panel-size-btn svg { width: 13px; height: 13px; }
.panel-size-btn:hover { border-color: var(--border); color: var(--text); }
.panel-size-btn.active { border-color: var(--border); color: var(--text); background: var(--bg3); }

#chart-container {
  flex: 1;
  min-height: 0;
  padding: 10px 12px 6px;
  position: relative;
}
#temp-chart { width: 100% !important; height: 100% !important; cursor: pointer; }

/* ── Confidence ── */
#model-confidence {
  flex-shrink: 0;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--border);
}
#confidence-segments {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}
.conf-seg {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conf-bar { height: 6px; border-radius: 2px; }
.conf-seg span { font-size: 9px; color: var(--muted); white-space: nowrap; }
#model-advice { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ── Timeline ── */
#timeline-panel {
  padding: 6px 20px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#tl-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

/* step + play buttons */
#step-back, #step-fwd, #play-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#step-back:hover, #step-fwd:hover { background: var(--bg2); border-color: var(--muted); color: var(--text); }
#play-btn { background: var(--text); border-color: var(--text); color: var(--bg); }
#play-btn:hover { opacity: 0.85; }
#step-back svg, #step-fwd svg, #play-btn svg { width: 13px; height: 13px; }

/* speed buttons */
#speed-btns { display: flex; gap: 3px; margin-left: 2px; }
.speed-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: all 0.12s;
}
.speed-btn.active { background: var(--bg3); color: var(--text); border-color: var(--muted); }
.speed-btn:hover  { border-color: var(--text); color: var(--text); }

#timeline-readout {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* slider + ticks */
#timeline-wrapper {
  position: relative;
  padding-bottom: 20px; /* room for tick labels */
}

#timeline {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  display: block;
}
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
#timeline::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: none; cursor: pointer;
}

/* tick container */
#timeline-ticks {
  position: absolute;
  left: 0; right: 0;
  top: 8px; /* just below the slider track */
  height: 18px;
  pointer-events: none;
}
.tl-tick {
  position: absolute;
  transform: translateX(-50%);
  bottom: 0; /* grow upward from bottom of label area */
}
.tl-tick-day  { width: 1px; height: 7px; background: #6e7681; top: 0; }
.tl-tick-12h  { width: 1px; height: 5px; background: #3d444d; top: 0; }
.tl-tick-6h   { width: 1px; height: 3px; background: #2d333b; top: 0; }
.tl-label {
  position: absolute;
  transform: translateX(-50%);
  top: 8px;
  font-size: 9px;
  color: #6e7681;
  white-space: nowrap;
}

/* ── Loading ── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#loading-inner { text-align: center; font-size: 14px; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-status { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ── Leaflet overrides ── */
.leaflet-container { background: #080c10; }
.leaflet-control-zoom a {
  background: var(--bg2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
.leaflet-control-attribution { display: none; }

/* Zoom level badge */
.zoom-badge {
  background: rgba(13,17,23,0.75);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 10px;
  font-family: 'Inter', sans-serif;
  padding: 2px 6px;
  margin-bottom: 4px;
  text-align: center;
  pointer-events: none;
}

/* City dot markers */
.city-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform 0.1s;
  position: relative;
  overflow: visible;
}
.dot-temp-label {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #ffd700;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.6);
}
.city-dot:hover { transform: scale(1.4); }
.city-dot.selected {
  background: #ffd700;
  border-color: #ffd700;
  transform: scale(1.5);
}

.leaflet-popup-content-wrapper {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  box-shadow: none;
}
.leaflet-popup-tip { background: var(--bg2); }
.leaflet-popup-content { margin: 5px 10px; }
