:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --secondary: #0891b2;
  --surface-1: #f8fafc;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --danger: #ef4444;
  --warning: #f59e0b;
  --warning-alt: #d97706;
  --success: #10b981;
  --info: #06b6d4;
  --base-gray: #64748b;
  --base-gray-light: #94a3b8;
  --base-gray-lighter: #cbd5e1;
  --bg-gradient-1: #0f172a;
  --bg-gradient-2: #1e293b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

/* `display:flex`/`display:grid` on a class (e.g. .err) would otherwise
   re-show elements marked with the `hidden` attribute. */
[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
  color: #1e293b;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: #0f172a;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--primary-light);
}

.top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--base-gray-lighter);
  padding: 12px 24px;
  box-shadow: var(--shadow-md);
}

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

.logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 14px;
  color: white;
  font-size: 24px;
  box-shadow: var(--shadow-md);
}

.sub {
  font-size: 13px;
  color: var(--base-gray);
  margin: 0;
  white-space: nowrap;
}

.sub a {
  color: var(--primary);
}

#feedTime {
  color: var(--success);
  font-weight: 600;
}

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  gap: 8px;
  border: 1px solid var(--base-gray-lighter);
  background: var(--surface-2);
  color: var(--base-gray);
}

.pill.live {
  background: #dcfce7;
  border-color: var(--success);
  color: var(--success);
}

.pill.err {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--base-gray-lighter);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Page: map full-width on top, panels flow in a responsive row below. */
.grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

/* The two content columns beneath the map (each keeps its natural height —
   no stretched empty space):
     left  = most severe + active alerts
     right = stations (weather wall) + crowd reports          */
.cards-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* The alerts list caps its own height and scrolls on stormy days (many
   warnings) instead of stretching the page. */
.alerts-panel #alertList {
  max-height: 720px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Stack the cards columns below a narrow viewport. */
@media (max-width: 900px) {
  .cards-row { grid-template-columns: 1fr; }
}

.panel {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  border: 1px solid var(--base-gray-lighter);
  transition: box-shadow 0.3s ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--base-gray-lighter);
}

.panel-head h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--base-gray);
  font-weight: 700;
}

.map-panel {
  padding: 0;
  overflow: hidden;
}

.map-panel .panel-head {
  padding: 16px 20px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid var(--base-gray-lighter);
}

.map-wrap {
  position: relative;
}

#map {
  width: 100%;
  /* Reasonable, responsive height — tall enough to read Germany, short
     enough that the panels below are close by. */
  height: min(58vh, 540px);
  min-height: 360px;
  background: #e0f2fe;          /* shown until basemap tiles arrive */
  z-index: 1;
}

/* Panel head: legend left, basemap selector right */
.map-head-right {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.basemap-select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: #fff;
  color: var(--base-gray-dark);
}

/* ---- Alert escalation (L3+ Starkwarnung) ---- */
#escBanner.esc-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 18px;
  font-size: 14px;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(90deg, #b91c1c 0%, #dc2626 45%, #ef4444 100%);
  border-bottom: 2px solid #7f1d1d;
  box-shadow: 0 6px 18px rgba(185, 28, 28, 0.35);
  animation: escPulse 2.2s ease-in-out infinite;
}
#escBanner[hidden] { display: none; }
#escBanner.esc-banner .esc-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
#escBanner.esc-banner .esc-body { display: flex; flex-direction: column; }
#escBanner.esc-banner .esc-title { font-weight: 700; letter-spacing: 0.2px; }
#escBanner.esc-banner .esc-meta { font-size: 12px; opacity: 0.92; }
/* Stronger pulse when a watched city is directly hit. */
#escBanner.esc-city {
  background: linear-gradient(90deg, #7f1d1d 0%, #b91c1c 50%, #dc2626 100%);
  animation: escPulse 1.4s ease-in-out infinite;
}
@keyframes escPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(185,28,28,0.35), 0 0 0 0 rgba(220,38,38,0.0); }
  50%      { box-shadow: 0 6px 22px rgba(185,28,28,0.55), 0 0 0 6px rgba(220,38,38,0.18); }
}

/* Watched city inside the L3+ area: thick pulsing red ring on its card. */
.station.esc-affected {
  border: 2px solid #dc2626;
  box-shadow: 0 0 0 0 rgba(220,38,38,0.0);
  animation: cardPulse 1.6s ease-in-out infinite;
}
@keyframes cardPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.0), 0 1px 2px rgba(0,0,0,0.08); }
  50%      { box-shadow: 0 0 0 5px rgba(220,38,38,0.22), 0 1px 2px rgba(0,0,0,0.08); }
}

/* L3+ warning polygon: thick pulsing red stroke. */
.leaflet-overlay-pane path.warn-lv3 {
  stroke-width: 4px !important;
  animation: polyPulse 1.8s ease-in-out infinite;
}
@keyframes polyPulse {
  0%, 100% { stroke-opacity: 1;   }
  50%      { stroke-opacity: 0.4; }
}

/* ---- Motion player (watch rain / cloud cells sweep across Germany) ---- */
.motion-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 8px;
  margin-left: 6px;
  border-left: 1px solid var(--base-gray-lighter);
}
.motion-play {
  width: 30px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.motion-play:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35); }
.motion-play:active { transform: translateY(0); }
.motion-scrub {
  width: 110px;
  accent-color: #2563eb;
  cursor: pointer;
}
.motion-scrub:disabled { opacity: 0.35; cursor: not-allowed; }
.motion-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #1e293b;
  min-width: 34px;
  text-align: center;
  background: #eef2ff;
  padding: 2px 4px;
  border-radius: 4px;
}

/* ---- 24-hour forecast play (continuous cloud + rain field) ---- */
.fc24-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 8px;
  margin-left: 6px;
  border-left: 1px solid var(--base-gray-lighter);
}
.fc24-play {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.fc24-play:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4); }
.fc24-play:active { transform: translateY(0); }
.fc24-scrub { width: 130px; accent-color: #0284c7; cursor: pointer; }
.fc24-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #082f49;
  min-width: 62px;
  text-align: center;
  background: #e0f2fe;
  padding: 2px 4px;
  border-radius: 4px;
}

/* The fc24 field canvas sits between the base tiles (z400) and the SVG
   overlays (z460) so the L2/L3 polygons + crowd dots + city markers
   remain *above* the field, while clicks still reach the map. */
.fc24-holder {
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  overflow: hidden;
}
.fc24-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Leaflet base-tile containers sit below our overlays */
.leaflet-overlay-pane {
  z-index: 400;
}

/* Warning polygons drawn by Leaflet */
.warn-poly {
  cursor: pointer;
  transition: fill-opacity 0.15s ease;
}
.warn-poly:hover {
  fill-opacity: 0.6 !important;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  list-style: none;
}

.legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--base-gray);
  white-space: nowrap;
}

 legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--base-gray);
}

.legend .sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.sw.l2 {
  background: var(--warning);
}

.sw.l3 {
  background: var(--danger);
}

.sw.crowd {
  background: #7c3aed;
}

/* Leaflet tooltip styled like the old .map-tip */
.leaflet-tooltip.map-tip-leaflet {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 300px;
}
.leaflet-tooltip.map-tip-leaflet h3 {
  font-size: 14px;
  margin: 0 0 5px;
  color: #fff;
}
.leaflet-tooltip.map-tip-leaflet .t-meta {
  font-size: 12px;
  color: var(--base-gray-lighter);
  margin-bottom: 5px;
}
.leaflet-tooltip.map-tip-leaflet .t-desc {
  font-size: 13px;
  color: var(--base-gray-lighter);
  line-height: 1.4;
}
/* keep the little pointer arrow on the dark tooltip */
.leaflet-tooltip-top.map-tip-leaflet::before {
  border-top-color: #1e293b;
}
.leaflet-tooltip-bottom.map-tip-leaflet::before {
  border-bottom-color: #0f172a;
}
/* attribution readability over light tiles */
.leaflet-control-attribution {
  background: rgba(255,255,255,0.8) !important;
}

.map-tip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}

.map-tip h3 {
  font-size: 14px;
  margin-bottom: 6px;
  color: white;
}

.map-tip .t-meta {
  font-size: 12px;
  color: var(--base-gray-lighter);
  margin-bottom: 8px;
}

.map-tip .t-desc {
  font-size: 13px;
  color: var(--base-gray-lighter);
  line-height: 1.5;
}

#mapNote {
  font-size: 12px;
  color: var(--base-gray);
  padding: 14px 20px;
  background: linear-gradient(0deg, #f8fafc 0%, #f1f5f9 100%);
  border-top: 1px solid var(--base-gray-lighter);
  margin: 0;
}

.hero-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid var(--base-gray-lighter);
  transition: all 0.3s ease;
}

.hero-card:hover {
  box-shadow: var(--shadow-md);
}

.hero-badge {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 28px;
  background: linear-gradient(135deg, var(--success) 0%, var(--info) 100%);
  color: white;
  font-weight: 800;
  line-height: 1;
}

.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--base-gray-lighter);
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alert:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.alert .stripe {
  width: 4px;
  height: 60px;
  border-radius: 2px;
  flex-shrink: 0;
}

.alert .a-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.alert .a-title {
  font-weight: 600;
  font-size: 14px;
  color: #1e293b;
}

.alert .a-event {
  font-size: 11px;
  color: var(--base-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.alert .a-region {
  font-size: 13px;
  color: var(--base-gray);
}

.alert .a-when {
  font-size: 12px;
  color: var(--base-gray);
  margin-top: 4px;
}

.alert .a-desc {
  font-size: 13px;
  color: var(--base-gray);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--base-gray-lighter);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag.lv2 {
  background: #fef3c7;
  color: var(--warning-alt);
}

.tag.lv3 {
  background: #fee2e2;
  color: var(--danger);
}

.station {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  align-items: center;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: white;
  border: 1px solid var(--base-gray-lighter);
  transition: all 0.2s ease;
}

.station:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.station .s-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.station .s-remove {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--base-gray-light);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.station .s-remove:hover {
  background: #fee2e2;
  color: var(--danger);
}

.station .s-name {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.station .s-id {
  font-size: 12px;
  color: var(--base-gray);
  margin-top: 2px;
}

.station .s-now {
  text-align: right;
}

.station .s-temp {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.station .s-sub {
  font-size: 12px;
  color: var(--base-gray);
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.station .s-forecast {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  margin-top: 16px;
  overflow-x: auto;
  padding: 8px 0;
}

.fc {
  /* Flexible boxes: all 6 days fit inside any card width without scrolling. */
  flex: 1 1 0;
  min-width: 44px;
  max-width: 96px;   /* in the (now wider) column, don't let boxes balloon    */
  text-align: center;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  transition: all 0.2s ease;
}

.fc:hover {
  background: var(--primary-light);
  color: white;
}

.fc .fc-d {
  font-size: 11px;
  font-weight: 600;
  color: var(--base-gray);
  text-transform: uppercase;
}

.fc:hover .fc-d {
  color: white;
}

.fc .fc-ic {
  font-size: 22px;
}

.fc .fc-t {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}

.fc:hover .fc-t {
  color: white;
}

.fc.rainy {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.station .s-warns {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.sw-chip.lv2 {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.sw-chip.lv3 {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

/* ---- Day-chip precipitation row + clickable/selected states ---- */
.fc .fc-p {
  min-height: 12px;
  font-size: 9.5px;
  font-weight: 700;
  color: #1d4ed8;
  margin-top: 2px;
}

.fc.snowy {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.fc-day {
  cursor: pointer;
  outline: none;
}

.fc-day:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.fc-day.selected {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

.fc-day.selected .fc-d,
.fc-day.selected .fc-t,
.fc-day.selected .fc-ic { color: #fff; }

.fc-day.selected .fc-p { color: #dbeafe; }

/* ---- Hourly strip (next 24 h + per-day detail) ---- */
.s-hours {
  grid-column: 1 / -1;
  margin-top: 12px;
}

.s-hours-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--base-gray);
  margin-bottom: 6px;
}

.s-hours-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0 6px;
  scrollbar-width: thin;
}

.hcell {
  flex: 0 0 auto;
  width: 46px;
  padding: 6px 2px 5px;
  border-radius: 8px;
  background: var(--surface-3);
  text-align: center;
  line-height: 1.1;
}

.hcell .h-time {
  font-weight: 700;
  font-size: 10px;
  color: var(--base-gray);
}

.hcell .h-ic {
  font-size: 16px;
  line-height: 1.2;
}

.hcell .h-t {
  font-weight: 700;
  font-size: 11px;
  color: #0f172a;
}

.hcell .h-p {
  font-size: 9px;
  min-height: 13px;
  color: #1d4ed8;
  font-weight: 600;
}

.hcell.rain {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border: 1px solid #bfdbfe;
}

.hcell.snow {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  border: 1px solid #bae6fd;
}

/* No-data hour: DWD returns 32767 for hours without a forecast. Keep it
   visually quiet so it doesn't read as "clear" — muted background, faded
   text, and a "–" instead of an icon. */
.hcell.nodata {
  background: var(--surface-2) !important;
  border: 1px dashed var(--base-gray-lighter);
  opacity: 0.75;
}

.hcell.nodata .h-ic,
.hcell.nodata .h-t {
  color: var(--base-gray);
  font-weight: 500;
}

/* ---- Expandable per-day detail panel ---- */
.s-details {
  grid-column: 1 / -1;
  margin-top: 6px;
  border-top: 1px dashed var(--base-gray-lighter);
  padding-top: 10px;
}

.dd-head {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}

.dd-head .dd-sum {
  margin-left: 8px;
  font-weight: 500;
  font-size: 11px;
  color: var(--base-gray);
}

.s-details .s-hours-strip {
  margin-top: 8px;
}

/* ---- Map header data-overlay toggle cluster (radar + OWM clouds/rain/snow/temp) ---- */
.layer-toggles {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border: 1px solid var(--base-gray-lighter);
  border-radius: 999px;
  background: var(--surface-1);
  flex-wrap: wrap;
}

.layer-toggles .lt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--base-gray);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 1px 4px;
  border-radius: 6px;
}

.layer-toggles .lt:hover {
  background: var(--surface-2);
}

.layer-toggles .lt input {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
}

/* ---- Map overlays: keep OWM/rain layers visually distinct, above the base
       tiles but below the warning polygons / markers (Leaflet panes handle
       this automatically; the className just helps debugging / theming). ---- */
.leaflet-overlay-pane .rain-layer,
.leaflet-overlay-pane .owm-layer {
  pointer-events: none;
}

/* ---- Distinct tint per overlay ----------------------------------
   OWM delivers every raster (clouds / rain / snow / temp) as the same
   washed-out blue-grey, so Clouds and Rain are basically indistinguishable.
   The alpha channel still carries the physical intensity (cloud %, rain mm,
   °C), so a CSS filter can re-color the layer *without* losing that
   gradient data.

   Recipe: sepia(1) gives the flat white a chroma, hue-rotate() moves that
   chroma to the target hue, saturate() intensifies it, brightness() scales
   it to the map. (Do NOT lead with saturate(0) — that bleeds the hue.)

   Final palette (deliberately far apart so stacked layers read clearly):
     clouds  -> neutral slate grey  (coverage; desaturated, so it is never
                                     mistaken for the blue rain layer)
     rain    -> deep saturated blue (water / precipitation)
     snow    -> bright icy cyan     (cold precipitation)
     temp    -> warm orange/red     (heat map)
     radar   -> violet              (live nowcast; kept off the blue axis so
                                     it never reads as OWM rain)

   CLOUDS NOTE — historically this was `saturate(0.15) brightness(1.4)` +
   0.6 opacity, which rendered a near-white grey. OWM's clouds_new alpha
   caps at ~50% (127/255), even empty sky has an ~12% alpha floor, so the
   peak layer was only ~30% over the light basemap = effectively invisible.
   Now: neutral slate grey, saturated down off the blue axis (so it reads as
   "coverage" not rain), contrast boosted so the low->high gradient is
   legible, and opacity raised to 0.9 so peak coverage actually shows.
------------------------------------------------------------------- */
.leaflet-overlay-pane .owm-clouds {
  filter: saturate(0.08) brightness(0.85) contrast(1.5);
  opacity: 0.9;
}
.leaflet-overlay-pane .owm-rain {
  filter: sepia(1) hue-rotate(190deg) saturate(6) brightness(0.72);
  opacity: 0.7;
}
.leaflet-overlay-pane .owm-snow {
  filter: sepia(1) hue-rotate(160deg) saturate(3) brightness(1.15);
  opacity: 0.7;
}
.leaflet-overlay-pane .owm-temp {
  filter: sepia(1) hue-rotate(-15deg) saturate(6) brightness(0.82);
  opacity: 0.68;
}
/* Keyless live radar (RainViewer) — violet, clearly not any OWM layer. */
.leaflet-overlay-pane .rain-layer {
  filter: sepia(1) hue-rotate(258deg) saturate(6) brightness(0.85);
  opacity: 0.7;
}

/* ---- Forecast mode: hourly forecast dot layers (Open-Meteo) -----------
   Two independent circle layers over the fixed Germany grid:
     fc-cloud  grey  — cloud cover % (bigger/darker = more coverage)
     fc-rain   blue  — rain mm (bigger/darker = heavier)
   The fill is drawn with a soft radial gradient (via filter: drop-shadow)
   so the dots don't look like hard billboards and read as "coverage"
   rather than a binary hit. */
path.fc-cloud {
  fill: #6a7582;
  fill-opacity: 0.25;
  stroke: #5a6472;
  stroke-opacity: 0.4;
}
path.fc-rain {
  fill: #1e6fd0;
  fill-opacity: 0.55;
  stroke: #0b3f7a;
  stroke-opacity: 0.6;
}
/* The #when dropdown — slightly different from the basemap select so
   the two controls next to each other still read as two distinct widgets. */
.when-select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: #fff;
  color: var(--base-gray-dark);
}

/* ---- City markers: pure-CSS dot (no image, so no broken "?" glyph) ---- */
.leaflet-marker-icon.city-marker {
  background: rgba(37, 99, 235, 0.95);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.add-form {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--base-gray-lighter);
}

.add-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: var(--surface-3);
  font-size: 14px;
  color: #1e293b;
  transition: all 0.2s ease;
}

.add-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.add-form input::placeholder {
  color: var(--base-gray);
}

.add-form button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-form button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.add-form button:active {
  transform: translateY(0);
}

/* ---- Station search (city autocomplete) ---- */
.searchbox {
  position: relative;
  flex-direction: column;
}

.search-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--base-gray-lighter);
  background: var(--surface-3);
  font-size: 14px;
  color: #1e293b;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-input::placeholder {
  color: var(--base-gray);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);   /* pop up below the input, above other content */
  right: 0;
  left: 0;
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: white;
  border: 1px solid var(--base-gray-lighter);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.search-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: #1e293b;
}

.search-results li:hover {
  background: var(--surface-2);
}

.search-results li .s-match {
  font-weight: 600;
}

.search-results li .s-id {
  color: var(--base-gray);
  font-size: 11px;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.search-results li .s-add {
  color: var(--primary);
  font-weight: 700;
}

.search-note {
  font-size: 12px;
  margin-top: 8px;
  color: var(--base-gray);
}

.add-id {
  margin-top: 12px;
  font-size: 13px;
}

.add-id summary {
  cursor: pointer;
  user-select: none;
}

.add-id .add-form {
  border-top: none;
  padding-top: 10px;
  margin-top: 8px;
}

.err {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: var(--radius-sm);
}

.crowd {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.crowd-empty {
  color: var(--base-gray);
  text-align: center;
  padding: 24px;
}

.crowd-bar {
  display: flex;
  height: 20px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--base-gray-lighter);
}

.crowd-bar .bar-segment {
  height: 100%;
}

.crowd-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 13px;
  color: var(--base-gray);
}

.crowd-stats b {
  color: #0f172a;
  font-weight: 600;
}

.cat-REGEN { background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); }
.cat-WIND { background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%); }
.cat-BEWOELKUNG { background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); }
.cat-NEBEL { background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%); }
.cat-BLITZE { background: linear-gradient(135deg, #f87171 0%, #ef4444 100%); }
.cat-SCHNEE { background: linear-gradient(135deg, #67e8f9 0%, #06b6d4 100%); }
.cat-DEFAULT { background: var(--surface-3); }

.foot {
  text-align: center;
  padding: 32px 24px;
  margin: 0;
  color: var(--base-gray);
  font-size: 13px;
  border-top: 1px solid var(--base-gray-lighter);
  background: var(--surface-2);
}

.foot a {
  color: var(--primary);
  font-weight: 600;
}

.foot a:hover {
  text-decoration: underline;
}

.scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) transparent;
}

.scroll::-webkit-scrollbar {
  width: 8px;
}

.scroll::-webkit-scrollbar-track {
  background: transparent;
}

.scroll::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 4px;
}

.scroll::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

@media (max-width: 1200px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .top {
    padding: 12px 16px;
  }
  
  .top {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .brand {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .controls {
    width: 100%;
  }
  
  .btn {
    flex: 1;
    justify-content: center;
  }
  
  .add-form {
    flex-direction: column;
  }
  
  .add-form input,
  .add-form button {
    width: 100%;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--base-gray);
}

.loading::after {
  content: "⋯";
  animation: pulse 1.5s infinite;
}

/* New-alert toast (appears when a fresh warning is detected on refresh) */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  max-width: min(92vw, 480px);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: #1e293b;
  color: #f8fafc;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--warning);
  animation: toast-in 0.25s ease-out;
  pointer-events: none;
}

.toast.sev3 { border-left-color: var(--danger); }

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