:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #16202a;
  --muted: #5d6b78;
  --line: #e2e7ec;
  --accent: #1f7ae0;
  --warm: #e0671f;
  --good: #1f9d55;
  --warn: #c98a00;
  --bad: #d23c3c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #182028;
    --text: #e6edf3;
    --muted: #93a1ae;
    --line: #26313c;
    --accent: #5aa6ff;
    --warm: #ff9a52;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 40px; }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
header h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
header h1 span { color: var(--muted); font-weight: 400; }
.stamp { color: var(--muted); font-size: .9rem; }
.stamp.stale { color: var(--bad); font-weight: 600; }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px;
}
.hero .temp { font-size: clamp(3rem, 9vw, 4.5rem); font-weight: 650; line-height: 1; letter-spacing: -.03em; }
.hero .temp small { font-size: .4em; color: var(--muted); font-weight: 500; }
.hero .sub { color: var(--muted); margin-top: 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; min-height: 118px;
}
.tile .label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.8rem; font-weight: 600; margin-top: 4px; }
.tile .value small { font-size: .55em; color: var(--muted); font-weight: 500; margin-left: 2px; }
.tile .hint { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.trend { font-size: .95rem; color: var(--muted); white-space: nowrap; }

.wind { display: flex; align-items: center; gap: 14px; }
.compass { width: 64px; height: 64px; flex: none; }
.compass circle { fill: none; stroke: var(--line); stroke-width: 2; }
.compass text { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.compass .needle { fill: var(--accent); transition: transform .6s ease; transform-origin: 32px 32px; }

.uv-bar { height: 6px; border-radius: 3px; margin-top: 10px; background: var(--line); overflow: hidden; }
.uv-bar i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .6s ease, background .6s; }

.cam {
  background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; margin-bottom: 16px; border: 1px solid var(--line);
}
.cam iframe { width: 100%; height: 100%; border: 0; display: block; }

.error { background: var(--card); border: 1px solid var(--bad); color: var(--bad); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: none; }

footer { color: var(--muted); font-size: .85rem; margin-top: 28px; text-align: center; }

/* ---------- Serienfarben (Diagramme) ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; --storm-bad: #d23c3c; --storm-warn: #c98a00; --storm-info: #5d6b78; }
@media (prefers-color-scheme: dark) {
  :root { --s1: #3987e5; --s2: #d95926; --storm-bad: #e66767; --storm-warn: #e0a000; --storm-info: #93a1ae; }
}

/* ---------- Gewitter ---------- */
.storm {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--storm-info);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
}
.storm[hidden] { display: none; }
.storm.warn { border-left-color: var(--storm-warn); }
.storm.bad  { border-left-color: var(--storm-bad); }
.storm-icon { font-size: 1.8rem; line-height: 1; }
.storm-tag { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.storm.warn .storm-tag { color: var(--storm-warn); }
.storm.bad  .storm-tag { color: var(--storm-bad); }
.storm-main { font-size: 1.25rem; font-weight: 650; }
.storm-sub { color: var(--muted); font-size: .95rem; }

/* ---------- Verlauf ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 32px 0 12px; }
.section-head h2 { font-size: 1.1rem; margin: 0; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  font: inherit; font-size: .9rem; border: 0; background: none; color: var(--muted);
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 8px; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-head h3 { font-size: .95rem; margin: 0; }
.chart-sum { color: var(--muted); font-size: .85rem; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { position: relative; margin-top: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--s1); }
.chart .line.s2 { stroke: var(--s2); }
.chart .bar { fill: var(--s1); }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .dot.s1 { fill: var(--s1); }
.chart .dot.s2 { fill: var(--s2); }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart-empty { color: var(--muted); font-size: .9rem; padding: 40px 8px; text-align: center; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.key.s1 { background: var(--s1); }
.key.s2 { background: var(--s2); }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); padding: 6px 10px; font-size: .85rem; white-space: nowrap;
}
.tip-t { color: var(--muted); font-size: .8rem; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row span { color: var(--muted); }
details.table { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
details.table summary { cursor: pointer; color: var(--muted); }
details.table .scroll { max-height: 360px; overflow: auto; margin-top: 8px; }
details.table table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
details.table th, details.table td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
details.table th:first-child, details.table td:first-child { text-align: left; }
details.table th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; }

/* ---------- Rechtliches ---------- */
.legal .tile { margin-bottom: 16px; min-height: 0; }
.legal h2 { font-size: 1.05rem; margin: 0 0 8px; }
.legal p { margin: 0 0 10px; color: var(--text); }
.legal p:last-child { margin-bottom: 0; }
a { color: var(--accent); }
header a.stamp { text-decoration: none; }
footer a { color: var(--muted); }

/* ---------- Tabelle kompakt ---------- */
details.table table { width: auto; font-size: .85rem; }
details.table th, details.table td { padding: 3px 10px; }
details.table th small { display: block; font-weight: 400; font-size: .7rem; }
details.table td.dim { color: var(--muted); opacity: .6; }
details.table tbody tr:hover td { background: var(--bg); }
@media (max-width: 480px) {
  details.table { padding: 8px 10px; }
  details.table table { font-size: .78rem; }
  details.table th, details.table td { padding: 3px 5px; }
}

/* ---------- Tendenz-Pfeile ---------- */
.trend .arrow { display: inline-block; font-weight: 800; font-size: 1.15em; line-height: 1; }
.trend .arrow.up   { color: var(--s2); }     /* steigend: orange */
.trend .arrow.down { color: var(--s1); }     /* fallend: blau */
.trend .arrow.flat { color: var(--muted); }  /* gleich: grau */

/* ---------- Zeitraffer ---------- */
#zeitraffer[hidden] { display: none; }
.zr-video { background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16 / 9; }
.zr-video video { width: 100%; height: 100%; display: block; background: #000; }
.zr-days { display: flex; gap: 6px; flex-wrap: wrap; }
.zr-days button {
  font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.zr-days button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.zr-info { color: var(--muted); font-size: .85rem; margin-top: 6px; }
#zeitraffer { margin-bottom: 16px; }

/* ---------- Radtouren ---------- */
.tour-sum { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tour-sum .tile { min-height: 0; }
.map-box { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
#map { height: min(60vh, 460px); background: var(--card); }
@media (prefers-color-scheme: dark) {
  #map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
}
.leaflet-container { font: inherit; }
.tour-detail { min-height: 0; }
.tour-werte { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 16px; margin-top: 10px; }
.tour-werte .value { font-size: 1.4rem; }
#profil svg { display: block; width: 100%; height: auto; }
#profil .area { fill: var(--s1); opacity: .15; }
.tour-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tour-liste button {
  width: 100%; display: grid; grid-template-columns: 9em 6em 1fr; gap: 10px; align-items: baseline; text-align: left;
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer;
}
.tour-liste button:hover { border-color: var(--muted); }
.tour-liste button[aria-pressed="true"] { border-color: var(--s2); box-shadow: inset 4px 0 0 var(--s2); }
.tour-liste .l-km { font-weight: 650; font-variant-numeric: tabular-nums; }
.tour-liste .l-info { color: var(--muted); font-size: .9rem; }
@media (max-width: 480px) {
  .tour-liste button { grid-template-columns: 1fr auto; }
  .tour-liste .l-info { grid-column: 1 / -1; }
}

/* Kachel als Sprung-Link (Radtouren) */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
#alle { scroll-margin-top: 16px; }
a.tile-link { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: border-color .15s, transform .15s; }
a.tile-link:hover, a.tile-link:focus-visible { border-color: var(--s1); transform: translateY(-1px); }
a.tile-link .hint { font-size: .8rem; transition: color .15s; }
a.tile-link:hover .hint, a.tile-link:focus-visible .hint { color: var(--s1); }
