:root {
  --bg: #0a121c;
  --bg-alt: #0e1826;
  --surface: #142334;
  --surface-2: #1a2c40;
  --border: #223347;
  --text: #edf1f8;
  --text-dim: #93a4ba;
  --accent: #2994d2;
  --accent-2: #ec690e;
  --radius: 14px;
  --max-width: 1200px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 18, 28, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}

.brand-icon { width: 34px; height: 34px; border-radius: 8px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 0.98rem; letter-spacing: 0.01em; }
.brand-text small { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.nav-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }

.nav-link {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--accent); }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem;
  }
  .nav-links.open { display: flex; }
}

/* ---------- Status bar ---------- */
.status-bar {
  background: linear-gradient(135deg, rgba(41, 148, 210, 0.1), rgba(236, 105, 14, 0.05));
  border-bottom: 1px solid var(--border);
}

.status-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.status-label { color: var(--text-dim); font-size: 0.85rem; }

.status-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.status-time { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.status-updated { color: var(--text-dim); font-size: 0.78rem; }

.error-banner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.5rem 1.25rem 0.9rem;
  color: #f5a341;
  font-size: 0.85rem;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}
.level-badge.small { padding: 0.15rem 0.5rem; font-size: 0.78rem; }

/* ---------- Sections ---------- */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.75rem 1.25rem;
}
.section.alt { background: var(--bg-alt); max-width: none; }
.section.alt > * { max-width: var(--max-width); margin-left: auto; margin-right: auto; }
.section.alt { padding-left: 0; padding-right: 0; }
.section.alt .section-head,
.section.alt .grid,
.section.alt .disclaimer,
.section.alt .push-box,
.section.alt a.link-card { padding-left: 1.25rem; padding-right: 1.25rem; }

.section-head { margin-bottom: 1.5rem; }
.section-head h2 { margin: 0 0 0.3rem; font-size: 1.5rem; }
.section-head p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }

.sub-head { font-size: 1rem; color: var(--text-dim); margin: 1.5rem 0 0.75rem; }

.grid { display: grid; gap: 0.9rem; }
.gemeinden-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.gefahren-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.water-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.webcams-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ---------- Über uns ---------- */
.ueberuns-text { max-width: 760px; color: var(--text); font-size: 0.95rem; margin: 0 0 1.75rem; }

.wappen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1.75rem;
}
.wappen-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  width: 78px;
  transition: transform 0.15s;
}
.wappen-item:hover { transform: translateY(-2px); }
.wappen-item img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
}
.wappen-item span { font-size: 0.68rem; color: var(--text-dim); text-align: center; line-height: 1.2; }

.karte-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.karte-wrap img { width: 100%; height: auto; }
.karte-caption { margin: 0.6rem 0 0; color: var(--text-dim); font-size: 0.78rem; }

/* ---------- Gemeinde cards ---------- */
.gemeinde-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  transition: transform 0.15s, border-color 0.15s;
}
.gemeinde-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.gemeinde-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.gemeinde-head h3 { margin: 0; font-size: 1.02rem; }
.kanton-tag { font-size: 0.68rem; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.45rem; }

.gemeinde-weather { display: flex; align-items: center; gap: 0.5rem; margin: 0.6rem 0; }
.wx-icon { font-size: 1.6rem; }
.wx-temp { font-size: 1.5rem; font-weight: 700; }
.wx-text { color: var(--text-dim); font-size: 0.85rem; }

.gemeinde-meta { display: flex; gap: 0.9rem; color: var(--text-dim); font-size: 0.8rem; flex-wrap: wrap; }
.gemeinde-note { margin: 0.6rem 0 0; font-size: 0.72rem; color: var(--text-dim); font-style: italic; }

/* ---------- Gefahren cards ---------- */
.hazard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--level-color, var(--accent));
  border-radius: var(--radius);
  padding: 1rem;
}
.hazard-top { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.hazard-icon { font-size: 1.3rem; }
.hazard-label { font-weight: 600; }
.hazard-level { margin-bottom: 0.5rem; }
.hazard-value { margin: 0; color: var(--text-dim); font-size: 0.82rem; }

.disclaimer {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.disclaimer a { color: var(--accent); }

/* ---------- Prognose ---------- */
.hourly-row, .daily-row {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.hour-card, .day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 84px;
  flex: 0 0 auto;
  font-size: 0.82rem;
}
.day-card { min-width: 120px; }
.hour-time, .day-label { color: var(--text-dim); font-size: 0.75rem; }
.hour-icon, .day-icon { font-size: 1.4rem; }
.hour-temp { font-weight: 700; }
.day-temps { font-size: 0.85rem; }
.hour-precip, .day-precip, .day-wind { color: var(--accent-2); font-size: 0.72rem; }

/* ---------- Wetterkarte ---------- */
.map-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#wetterkarte-map { height: 440px; width: 100%; background: var(--surface); }
@media (max-width: 640px) { #wetterkarte-map { height: 320px; } }

.map-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(10, 18, 28, 0.85);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem 0.3rem 0.3rem;
}
.map-toggle {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  flex: 0 0 auto;
}
.map-toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.map-time { font-size: 0.78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.leaflet-container { background: var(--surface); font: inherit; }
.leaflet-control-zoom a {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-attribution {
  background: rgba(10, 18, 28, 0.8) !important;
  color: var(--text-dim) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-tooltip {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

/* ---------- Gewässer ---------- */
.water-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}
.water-card h3 { margin: 0 0 0.1rem; font-size: 1rem; }
.water-body { margin: 0 0 0.75rem; color: var(--text-dim); font-size: 0.8rem; }
.water-values { display: flex; gap: 1.5rem; }
.water-values > div { display: flex; flex-direction: column; }
.water-num { font-size: 1.35rem; font-weight: 700; }
.water-unit { color: var(--text-dim); font-size: 0.72rem; }

/* ---------- Webcams ---------- */
.webcam-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s, transform 0.15s;
}
.webcam-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.webcam-icon { font-size: 1.5rem; }
.webcam-card h3 { margin: 0; font-size: 1rem; }
.webcam-card p { margin: 0; color: var(--text-dim); font-size: 0.82rem; }
.webcam-link { color: var(--accent); font-size: 0.8rem; margin-top: 0.3rem; }

/* ---------- Link cards (Alertswiss / BWL) ---------- */
.link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.link-card-icon { font-size: 1.8rem; }
.link-card-body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.link-card-body span { color: var(--text-dim); font-size: 0.85rem; }
.link-card-arrow { color: var(--accent); font-size: 1.2rem; }

/* ---------- Energie ---------- */
.energy-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .energy-grid { grid-template-columns: 1fr; } }

/* ---------- Push ---------- */
.push-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}
.push-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: filter 0.15s;
}
.push-btn:hover { filter: brightness(1.1); }
.push-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.push-status { margin: 0; color: var(--text-dim); font-size: 0.85rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 1.25rem 2.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.site-footer p { max-width: 700px; margin: 0.25rem auto; }
