/* =========================================================
   Design-Tokens (hell = Standard; dunkel per System oder Schalter)
   ========================================================= */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --line: #e2e5ea;
  --line-strong: #cdd2da;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 78, 216, 0.1);
  --rain: #2563eb;
  --warm: #dc6b19;
  --cold: #3b82f6;
  --good: #15803d;
  --mid: #b45309;
  --bad: #b91c1c;
  --icon-sun: #f2a516;
  --icon-moon: #94a3b8;
  --icon-cloud: #64748b;
  --icon-cloud-fill: #ffffff;
  --icon-rain: #2563eb;
  --icon-snow: #60a5fa;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.02);
  --shadow-pop: 0 10px 30px rgba(15, 23, 42, 0.14);
  --radius: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0e13; --surface: #12161e; --surface-2: #171c25; --surface-3: #1d2330;
  --line: #222936; --line-strong: #313a4a; --ink: #e8ebf1; --ink-2: #c2c8d3; --muted: #8790a1;
  --accent: #6d9eff; --accent-ink: #0b0e13; --accent-soft: rgba(109, 158, 255, 0.14); --rain: #5b9bff;
  --good: #4ade80; --mid: #fbbf24; --bad: #f87171;
  --icon-cloud: #9aa6b8; --icon-cloud-fill: #12161e; --icon-moon: #c7d0dd; --icon-rain: #5b9bff; --icon-snow: #bfdbfe;
  --shadow: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e13; --surface: #12161e; --surface-2: #171c25; --surface-3: #1d2330;
    --line: #222936; --line-strong: #313a4a; --ink: #e8ebf1; --ink-2: #c2c8d3; --muted: #8790a1;
    --accent: #6d9eff; --accent-ink: #0b0e13; --accent-soft: rgba(109, 158, 255, 0.14); --rain: #5b9bff;
    --good: #4ade80; --mid: #fbbf24; --bad: #f87171;
    --icon-cloud: #9aa6b8; --icon-cloud-fill: #12161e; --icon-moon: #c7d0dd; --icon-rain: #5b9bff; --icon-snow: #bfdbfe;
    --shadow: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg);
  font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.meta { color: var(--muted); font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ---------- Buttons ---------- */
.btn-icon {
  width: 38px; height: 38px; display: grid; place-items: center; flex-shrink: 0; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); border-radius: 9px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-icon:hover { border-color: var(--line-strong); color: var(--ink); }
.btn-icon.small { width: 32px; height: 32px; border-radius: 8px; }
.btn-ghost {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: none; cursor: pointer;
  color: var(--muted); border-radius: 8px; transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-ghost.small { width: 26px; height: 26px; }
.btn-ghost[aria-pressed="true"] { color: var(--icon-sun); }

/* Segmentierter Umschalter */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 9px; }
.segmented button {
  border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 500;
  color: var(--muted); cursor: pointer; transition: background 0.2s var(--ease), color 0.2s, box-shadow 0.2s;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

/* ---------- Kopfzeile ---------- */
.topbar { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; margin-right: 8px; }
.brand #logo { display: flex; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-name span { font-weight: 400; color: var(--muted); margin-left: 4px; }
.search { position: relative; flex: 1; max-width: 480px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 36px 0 36px; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 11px var(--font); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; line-height: 18px; pointer-events: none;
}
.search input:focus ~ .search-kbd { display: none; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop);
  animation: pop 0.14s var(--ease);
}
.results li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.results li span { color: var(--muted); font-size: 12.5px; }
.results li:hover, .results li.active { background: var(--surface-3); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Seite ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 24px 24px; }
.error { color: var(--bad); padding: 48px 0; text-align: center; }
#app { animation: fade 0.35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.place-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.place-title { display: flex; align-items: center; gap: 4px; min-width: 0; }
.place-title h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-meta { margin-top: 2px; }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2.4s infinite; }
.live.stale .live-dot { background: var(--muted); animation: none; }
.live.loading .live-dot { background: var(--accent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.favorites { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 16px; }
.favorites:empty { margin: 0 0 16px; }
.fav {
  display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 4px 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.fav:hover { border-color: var(--line-strong); }
.fav.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.fav .t { font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 6px; }
.fav .x { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); opacity: 0; transition: opacity 0.15s; }
.fav:hover .x, .fav:focus-within .x { opacity: 1; }
.fav .x:hover { background: var(--surface-3); color: var(--ink); }

.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
#obsPanel, #modelPanel { align-self: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.panel > .panel-title { margin-bottom: 14px; }
.panel-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

/* ---------- Ladeplatzhalter ---------- */
.sk { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
.sk-title { height: 30px; width: 220px; margin: 4px 0 26px; }
.sk-panel { min-height: 300px; display: grid; gap: 14px; align-content: start; }
.sk-big { height: 80px; width: 60%; } .sk-line { height: 14px; } .sk-line.short { width: 50%; }
.sk-map { height: 260px; } .sk-chart { height: 240px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Warnungen ---------- */
.warning {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 12px;
}
.warning strong { font-weight: 600; }
.warning .meta, .warning p { grid-column: 2; }
.warning p { color: var(--ink-2); font-size: 13.5px; }
.warning.l1 { border-left-color: #eab308; } .warning.l1 svg { color: #ca8a04; }
.warning.l2 { border-left-color: #f97316; } .warning.l2 svg { color: #ea580c; }
.warning.l3 { border-left-color: #dc2626; } .warning.l3 svg { color: #dc2626; }

/* ---------- Aktuell ---------- */
.current-main { display: flex; align-items: center; gap: 18px; }
.current-icon svg { display: block; }
.current-temp { font-size: 68px; font-weight: 300; letter-spacing: -0.045em; line-height: 1; }
.current-cond { font-size: 16px; font-weight: 500; margin-top: 6px; }
.current-range { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 20px 0 0; border-top: 1px solid var(--line); }
.stats div { padding: 12px 0 0; }
.stats dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 17px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stats dd small { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.wind-arrow { color: var(--ink-2); transition: transform 0.4s var(--ease); }
.sun { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.sun svg { width: 100%; height: auto; display: block; }
.sun-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sun-labels b { color: var(--ink); font-weight: 500; }

/* Sicherheits-Anzeige */
.conf { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.conf i { width: 4px; border-radius: 1px; background: var(--line-strong); }
.conf i:nth-child(1) { height: 6px; } .conf i:nth-child(2) { height: 9px; } .conf i:nth-child(3) { height: 12px; }
.conf.c3 i { background: var(--good); }
.conf.c2 i:nth-child(-n + 2) { background: var(--mid); }
.conf.c1 i:nth-child(1) { background: var(--bad); }

/* ---------- Radar ---------- */
.radar { display: flex; flex-direction: column; }
.near-text { font-size: 16px; font-weight: 500; margin-bottom: 12px; }
.map-wrap { position: relative; flex: 1; min-height: 260px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.map { position: absolute; inset: 0; background: var(--surface-2); }
.map-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 500; pointer-events: none;
  background: color-mix(in srgb, var(--ink) 80%, transparent); color: var(--surface); font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.radar-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.radar-controls input[type="range"] { flex: 1; accent-color: var(--accent); }
.radar-time { font-size: 13px; color: var(--ink-2); min-width: 92px; text-align: right; }
.near-chart { margin-top: 8px; }
.near-chart svg { width: 100%; height: auto; display: block; }
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-3); }
.loc-marker { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2.5px solid #fff; box-shadow: 0 0 0 4px var(--accent-soft), 0 1px 4px rgba(0, 0, 0, 0.35); }

/* ---------- Verlauf ---------- */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.dchip {
  flex: 0 0 auto; scroll-snap-align: start; display: grid; justify-items: center; gap: 1px; min-width: 66px; padding: 7px 8px 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s var(--ease);
}
.dchip:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.dchip[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dchip .d { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.dchip[aria-selected="true"] .d { color: var(--accent); }
.dchip .tt { font-size: 12.5px; }
.dchip .tt span { color: var(--muted); margin-left: 3px; }
.dchip.wide { min-width: 80px; align-content: center; }
.readout {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; min-height: 34px; padding: 6px 12px; margin-bottom: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; font-size: 13px; color: var(--ink-2);
}
.readout b { color: var(--ink); font-weight: 600; }
.readout .k { color: var(--muted); margin-right: 4px; }
.readout .ri { display: inline-flex; align-items: center; gap: 6px; }
.chart-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.timeline { min-width: 720px; position: relative; outline: none; border-radius: 8px; }
.timeline.day { min-width: 0; }
.timeline:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft); }
.timeline svg, .compare-chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.timeline .draw { animation: draw 0.7s var(--ease); }
@keyframes draw { from { opacity: 0; } }
.axis { fill: var(--muted); font-size: 11px; }
.axis-strong { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 2px; }
.sw.band { height: 8px; border-radius: 2px; }
.sw.bar { width: 6px; height: 9px; border-radius: 1px; }
.sw.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); height: 2px; }

/* ---------- 14 Tage ---------- */
.daily { display: grid; }
.drow {
  display: grid; grid-template-columns: 92px 36px minmax(120px, 1.2fr) 110px minmax(160px, 2fr) 90px 44px;
  align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-top: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; transition: background 0.15s;
}
.drow:hover { background: var(--surface-2); }
.drow.selected { background: var(--accent-soft); }
.drow.head { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 0; cursor: default; border-top: 0; }
.drow.head:hover { background: none; }
.drow.head + .drow { border-top: 0; }
.dday b { font-weight: 600; display: block; }
.dday span { color: var(--muted); font-size: 12.5px; }
.dcond { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dprec { color: var(--rain); font-size: 13px; }
.dprec span { color: var(--muted); }
.drange { display: grid; grid-template-columns: 34px 1fr 34px; gap: 10px; align-items: center; }
.drange .lo { color: var(--muted); text-align: right; }
.drange .hi { font-weight: 600; }
.track { height: 5px; border-radius: 3px; background: var(--surface-3); position: relative; }
.track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--cold), #f2a516 65%, var(--warm)); }
.dwind { color: var(--ink-2); font-size: 13px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
td .sub .tag { margin-right: 4px; }
tr.off td { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.tag.official { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.tag.own { border-color: transparent; background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.ok { color: var(--good); }
.wbar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-right: 8px; opacity: 0.8; transition: width 0.4s var(--ease); }
.up { color: var(--good); } .down { color: var(--bad); }
.learning { color: var(--ink-2); margin-bottom: 14px; font-size: 13.5px; }

/* ---------- Modellvergleich ---------- */
.compare-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.compare-chart { min-width: 600px; position: relative; }
.compare-side { font-size: 13px; }
.compare-side .ts { font-weight: 600; margin-bottom: 6px; min-height: 20px; }
.mrow {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; padding: 4px 6px; margin: 0 -6px;
  border-radius: 6px; cursor: pointer; user-select: none; transition: background 0.15s, opacity 0.15s;
}
.mrow:hover { background: var(--surface-2); }
.mrow i { width: 12px; height: 12px; border-radius: 3px; }
.mrow .v { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.mrow.off { opacity: 0.4; }
.mrow.off i { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.mrow.blend { font-weight: 600; }
.compare-side .hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

.footer { max-width: 1240px; margin: 0 auto; padding: 8px 24px 40px; color: var(--muted); font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .compare-layout { grid-template-columns: minmax(0, 1fr); }
  .drow { grid-template-columns: 76px 32px 92px minmax(120px, 1fr) 40px; }
  .dcond, .dwind, .drow.head .h-cond, .drow.head .h-wind { display: none; }
}
@media (max-width: 560px) {
  .topbar-inner { padding: 10px 12px; gap: 8px; }
  .brand-name, .search-kbd { display: none; }
  .brand { margin-right: 0; }
  .page { padding: 16px 12px; }
  .panel { padding: 16px; }
  .place-head { flex-wrap: wrap; }
  .place-title h1 { font-size: 24px; }
  .current-temp { font-size: 56px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .drow { grid-template-columns: 56px 28px 42px minmax(0, 1fr) 20px; gap: 8px; }
  .drange { grid-template-columns: 28px 1fr 28px; gap: 6px; }
  .dprec .mm, .drow.head { display: none; }
  .segmented button { padding: 5px 9px; }
  .map-wrap { min-height: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
