/* Wetter App-Stile. Formensprache wie Kiosk (design/BRANDBOOK.md dort), Farben nur über Tokens. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open, body.map-open { overflow: hidden; }

a { color: var(--ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { display: block; flex-shrink: 0; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--signal); color: var(--on-signal); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}
.muted { color: var(--muted); }
.signal { color: var(--signal-text); }
.noscript { padding: 24px; font-family: var(--font-mono); }

/* ---- Grundlayout ------------------------------------------------------------ */
#app { --gutter: var(--space-4); padding-bottom: calc(var(--bar) + 40px + env(safe-area-inset-bottom)); }
.page { max-width: var(--measure); margin: 0 auto; }
.col { display: flex; flex-direction: column; min-width: 0; }

@media (min-width: 1040px) {
  #app { --gutter: var(--space-6); }
  .page {
    max-width: 1240px; display: grid; column-gap: var(--space-8); padding: 0 var(--space-6);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas: "hdr hdr" "a side" "b side";
    grid-template-rows: auto auto 1fr;
  }
  .page > .hdr { grid-area: hdr; padding-left: 0; padding-right: 0; }
  .col { --gutter: 0px; }
  .col--a { grid-area: a; }
  .col--b { grid-area: b; }
  .col--side { grid-area: side; position: sticky; top: 16px; align-self: start; }
  .col--side .sec--radar { margin-top: var(--space-2); }
}

/* ---- Kopfzeile -------------------------------------------------------------- */
.hdr { display: flex; align-items: center; gap: var(--space-2); padding: 18px var(--gutter) 10px; }
.hdr .t-wordmark { flex-grow: 1; }

.icon-btn {
  width: var(--tap); height: var(--tap); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border-radius: var(--radius-pill); border: 1px solid var(--rule);
  background: transparent; color: var(--ink); text-decoration: none;
}
.icon-btn.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.icon-btn--sm { width: 36px; height: 36px; position: relative; }
.icon-btn--sm::after { content: ""; position: absolute; inset: -4px; }
.icon-btn--plain { border-color: transparent; color: var(--muted); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.is-busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Chips, Pillen ------------------------------------------------------- */
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  height: 36px; padding: 0 14px; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-pill); border: 1px solid var(--rule);
  background: transparent; color: var(--ink);
  font-family: var(--font-sans); font-size: 14px; line-height: 18px; font-weight: 500; white-space: nowrap;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--tap); padding: 0 18px; border-radius: var(--radius-pill);
  border: 1px solid var(--rule); background: transparent; color: var(--ink);
  font-size: 15px; line-height: 20px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.pill--primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.pill-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---- Abschnitte und Karten ------------------------------------------------ */
.sec { padding: 0 var(--gutter); margin-top: var(--space-8); }
.sec-head { display: flex; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.sec-head .t-section { flex-grow: 1; }
.sec-head .t-caption { color: var(--muted); }
.card { background: var(--raised); border-radius: var(--radius-md); padding: var(--space-4); }
.card + .card { margin-top: var(--space-3); }

/* ---- Jetzt (Kopf der Seite) --------------------------------------------- */
.now { padding: 8px var(--gutter) 0; }
.now-meta { color: var(--muted); }
.now-meta button { all: unset; cursor: pointer; border-radius: var(--radius-sm); }
.now-meta button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.now-main { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-2); }
.now-temp {
  font-family: var(--font-dot); font-weight: 700; font-size: 112px; line-height: 104px;
  letter-spacing: 0.02em; margin-left: -4px;
}
.now-temp .deg {
  display: inline-block; width: 0.2em; height: 0.2em; border: 0.055em solid currentColor; border-radius: 50%;
  vertical-align: top; margin: 0.1em 0 0 0.06em;
}
.now-icon { color: var(--ink); margin-left: auto; }
.now-cond { font-size: 24px; line-height: 30px; font-weight: 500; letter-spacing: -0.01em; margin-top: var(--space-2); }
.now-sub { color: var(--muted); margin-top: 2px; font-size: 15px; }
.now-facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-4); }
.fact { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.fact b { color: var(--ink); font-weight: 400; }

/* Ansage für die nächsten zwei Stunden */
.cast { display: flex; gap: var(--space-3); align-items: flex-start; }
.sec--cast { margin-top: var(--space-6); }
.cast-dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--rule); margin-top: 7px; flex-shrink: 0; }
.cast.is-wet .cast-dot { background: var(--signal); }
.cast-text { font-size: 17px; line-height: 23px; font-weight: 500; }
.cast-src { color: var(--muted); margin-top: 2px; }

/* Balken der nächsten zwei Stunden */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 72px; margin-top: var(--space-4); }
.bars--dry { height: 12px; }
.bars span { flex: 1 1 0; min-width: 0; border-radius: 3px 3px 0 0; background: var(--hairline); height: 2px; }
.bars span.wet { background: var(--signal); }
.bars span.snow { background: var(--ink); }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); margin-top: 6px; }

/* ---- Radar ---------------------------------------------------------------- */
.radar { position: relative; isolation: isolate; border-radius: var(--radius-md); overflow: hidden; background: var(--raised); }
.radar-map { height: 380px; background: var(--raised-2); }
@media (min-width: 1040px) { .radar-map { height: min(62vh, 620px); } }
.radar-top { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500; display: flex; align-items: flex-start; gap: var(--space-2); pointer-events: none; }
.radar-top > * { pointer-events: auto; }
.radar-time {
  background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--radius-pill);
  padding: 6px 14px; display: flex; align-items: baseline; gap: 10px;
}
.radar-time .t-counter { font-size: 18px; line-height: 22px; }
.radar-time .t-meta { color: var(--muted); }
.radar-time.is-future .t-meta { color: var(--signal-text); }
.radar-top .icon-btn { margin-left: auto; background: var(--raised); border-color: var(--hairline); }
.radar-ctl { display: flex; align-items: center; gap: var(--space-3); padding: 12px 12px 4px; }
.radar-ctl .icon-btn { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.scrub { position: relative; flex: 1 1 auto; height: var(--tap); display: flex; align-items: center; }
.scrub input { width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; height: var(--tap); position: relative; z-index: 2; }
.scrub-track { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: var(--radius-pill); background: var(--rule); overflow: hidden; }
.scrub-track i { position: absolute; top: 0; bottom: 0; right: 0; background: var(--signal); }
.scrub-now { position: absolute; top: 50%; width: 2px; height: 16px; margin-top: -8px; background: var(--ink); z-index: 1; }
.scrub input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.scrub input::-moz-range-track { height: 4px; background: transparent; }
.scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--ink); border: 3px solid var(--raised); }
.scrub input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--raised); }
.radar-axis { display: flex; justify-content: space-between; padding: 0 12px 0 68px; color: var(--muted); }
.radar-legend { display: flex; align-items: center; gap: 6px; padding: 10px 12px 14px; color: var(--muted); flex-wrap: wrap; }
.radar-legend i { width: 18px; height: 8px; border-radius: var(--radius-pill); display: inline-block; }
.radar-legend .sp { flex-grow: 1; }
.radar-note { padding: 0 12px 14px; color: var(--muted); }
.radar-load { position: absolute; left: 12px; top: 64px; z-index: 500; background: var(--raised); border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 4px 12px; display: flex; gap: 8px; align-items: center; }

/* Vollbild-Karte */
.radar.is-full { position: fixed; inset: 0; z-index: 60; border-radius: 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.radar.is-full .radar-map { flex: 1 1 auto; height: auto; }
.radar.is-full .radar-top { top: calc(12px + env(safe-area-inset-top)); }

/* Leaflet an Kiosk angleichen */
.leaflet-container { font-family: var(--font-sans); background: var(--raised-2); }
.leaflet-control-attribution {
  background: var(--raised) !important; color: var(--muted) !important; font-family: var(--font-mono);
  font-size: 10px; line-height: 14px; border-radius: var(--radius-sm) 0 0 0; padding: 1px 6px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar { border: 1px solid var(--hairline) !important; border-radius: var(--radius-md) !important; overflow: hidden; }
.leaflet-bar a { background: var(--raised) !important; color: var(--ink) !important; border-bottom-color: var(--hairline) !important; }
/* Filter auf der ganzen Kachel-Ebene statt je Kachel: sonst Nähte zwischen den Kacheln. */
.radar-map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(0.78) contrast(0.92); }
:root[data-theme="light"] .radar-map .leaflet-tile-pane { filter: grayscale(1) brightness(1.04) contrast(0.88); }
.leaflet-pane.leaflet-radar-pane { opacity: 0.9; }
.me-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }

/* ---- Wind ------------------------------------------------------------------ */
.metric { display: flex; gap: var(--space-4); align-items: center; }
.metric-body { flex: 1 1 auto; min-width: 0; }
.big { font-family: var(--font-dot); font-weight: 700; font-size: 56px; line-height: 56px; letter-spacing: 0.02em; }
.big small { font-family: var(--font-mono); font-weight: 400; font-size: 13px; letter-spacing: 0.02em; margin-left: 6px; text-transform: uppercase; color: var(--muted); }
.metric-word { font-size: 18px; line-height: 24px; font-weight: 500; margin-top: 6px; }
.metric-sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.compass { width: 112px; height: 112px; position: relative; flex-shrink: 0; }
.compass svg { width: 100%; height: 100%; }
.compass .c-dot { fill: var(--dot-off); }
.compass .c-dot.on { fill: var(--ink); }
.compass .c-lbl { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; text-anchor: middle; dominant-baseline: central; }
.compass .c-arrow { stroke: var(--ink); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--signal); color: var(--on-signal); }

.spark { margin-top: var(--space-4); }
.spark svg { width: 100%; height: 72px; overflow: visible; }
.spark .s-gust { fill: none; stroke: var(--rule); stroke-width: 1.5; stroke-dasharray: 2 4; stroke-linecap: round; }
.spark .s-wind { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .s-now { fill: var(--signal); }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); margin-top: 4px; }
.spark-key { display: flex; gap: var(--space-4); align-items: center; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.spark-key span { display: inline-flex; align-items: center; gap: 6px; }
.spark-key .sp { flex-grow: 1; }
.spark-key i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--ink); }
.spark-key i.k-gust { border-top: 2px dotted var(--rule); }

/* ---- UV ---------------------------------------------------------------------- */
.uvscale { display: flex; gap: 6px; margin-top: var(--space-4); }
.uvscale span { flex: 1 1 0; height: 10px; border-radius: var(--radius-pill); background: var(--dot-off); }
.uvscale span.on { background: var(--ink); }
.uvscale span.on.hot { background: var(--signal); }
.uvscale-axis { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); column-gap: 6px; color: var(--muted); margin-top: 6px; text-align: center; }
.uvtips { margin: var(--space-4) 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.uvtips li { display: flex; gap: 10px; align-items: baseline; font-size: 15px; line-height: 21px; }
.uvtips li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--rule); flex-shrink: 0; transform: translateY(-2px); }
.uvtips.hot li::before { background: var(--signal); }

/* ---- Stündlich ---------------------------------------------------------- */
.hours {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
}
.hours::-webkit-scrollbar { display: none; }
.hour {
  flex: 0 0 64px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0; border-radius: var(--radius-md); scroll-snap-align: start;
}
.hour.is-now { background: var(--raised); }
.hour .t-meta { color: var(--muted); }
.hour-temp { font-size: 18px; line-height: 22px; font-weight: 500; }
.hour-p { color: var(--signal-text); min-height: 16px; }
.hour-w { color: var(--muted); display: flex; align-items: center; gap: 2px; }
.hour-w svg { color: var(--muted); }
.hour.is-day-break { border-left: 1px solid var(--hairline); border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* ---- Tage ------------------------------------------------------------------- */
.days { display: flex; flex-direction: column; }
.day {
  display: grid; grid-template-columns: 56px 28px 1fr; align-items: center; column-gap: var(--space-3); row-gap: 2px;
  min-height: 56px; border-bottom: 1px solid var(--hairline); padding: 6px 0;
}
.day:last-child { border-bottom: 0; }
.day-name { font-weight: 500; }
.day-name .t-meta { display: block; color: var(--muted); font-weight: 400; }
.day-p { color: var(--signal-text); text-align: left; }
.day-p.dry { color: var(--muted); }
.range { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.range .lo { color: var(--muted); text-align: right; }
.range-track { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--raised-2); }
.range-track i { position: absolute; top: 0; bottom: 0; border-radius: var(--radius-pill); background: var(--ink); }
.range-track b { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--signal); border: 2px solid var(--bg); }
.day-extra { grid-column: 3 / -1; display: flex; gap: var(--space-3); color: var(--muted); margin-top: -4px; padding-bottom: 4px; white-space: nowrap; }
.day-extra span { display: inline-flex; gap: 4px; align-items: center; }

/* ---- Sonne -------------------------------------------------------------------- */
.sun { display: flex; gap: var(--space-6); }
.sun > div { display: flex; gap: var(--space-2); align-items: center; }
.sun .muted { display: block; }

/* ---- Leerzustand, Laden, Fehler -------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: 72px 16px 80px; text-align: center; }
.empty p { color: var(--muted); max-width: 34ch; }
.empty .pill-row { justify-content: center; padding-top: 8px; }
.matrix { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); width: 88px; margin-bottom: var(--space-3); }
.matrix span { width: var(--dot); height: var(--dot); border-radius: var(--radius-pill); background: var(--rule); }
.matrix span.on { background: var(--ink); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px var(--gutter); }
.load-dots { display: inline-flex; gap: 4px; }
.load-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: pulse 1.2s ease-in-out infinite; }
.load-dots span:nth-child(2) { animation-delay: 0.2s; }
.load-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .load-dots span, .icon-btn.is-busy svg { animation: none; }
}
.err { color: var(--signal-text); padding: 12px var(--gutter); }

/* ---- Schnellzugriffsleiste (Orte) ------------------------------------------- */
#bar {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20;
  height: var(--bar); padding: 10px 12px; border-radius: var(--radius-pill);
  background: var(--raised); border: 1px solid var(--hairline);
  display: flex; align-items: center; gap: var(--space-2);
  max-width: calc(var(--measure) - 32px); margin: 0 auto;
}
.bar-scroll {
  flex: 1 1 auto; min-width: 0; display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none;
  align-items: center; scroll-snap-type: x proximity; scroll-padding-inline: 12px;
}
.bar-scroll::-webkit-scrollbar { display: none; }
.bar-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); height: var(--tap); padding: 0 14px; flex-shrink: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--rule); background: transparent; color: var(--ink);
  font-family: var(--font-sans); font-size: 15px; line-height: 20px; font-weight: 500; letter-spacing: 0.02em;
  white-space: nowrap; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; scroll-snap-align: start;
}
.bar-chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.bar-chip .t-counter { color: var(--muted); }
.bar-chip.is-on .t-counter { color: inherit; opacity: 0.7; }

/* ---- Blätter ------------------------------------------------------------------ */
#sheet { position: fixed; inset: 0; z-index: 70; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; }
.sheet-panel {
  width: 100%; max-width: var(--measure); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--raised); display: flex; flex-direction: column; gap: 4px;
}
.sheet-panel--tall { min-height: min(640px, calc(100dvh - 40px)); }
.sheet-grip { width: 40px; height: 4px; border-radius: var(--radius-pill); background: var(--rule); align-self: center; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; gap: var(--space-2); padding: 8px 0; }
.sheet-head .t-section { flex-grow: 1; }
.sheet-sub { padding: 20px 0 4px; color: var(--muted); }
.field {
  display: flex; align-items: center; gap: var(--space-2); height: var(--tap); padding: 0 16px;
  border-radius: var(--radius-pill); background: var(--raised-2); border: 1px solid transparent;
}
.field:focus-within { border-color: var(--ink); }
.field input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; }
.field svg { color: var(--muted); }
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: 6px 0;
  border-bottom: 1px solid var(--hairline); background: none; border-left: 0; border-right: 0; border-top: 0;
  text-align: left; width: 100%; color: var(--ink);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-main .t-meta { color: var(--muted); display: block; margin-top: 2px; }
.row-title { font-size: 17px; line-height: 22px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .icon-btn { margin-left: auto; }
.row-btn {
  display: flex; align-items: center; gap: var(--space-3); flex: 1 1 auto; min-width: 0; min-height: 44px;
  padding: 0; border: 0; background: none; color: inherit; text-align: left;
}
.mono-circle {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-dot); font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
}
.about { color: var(--muted); font-size: 14px; line-height: 20px; padding: 12px 0; }
.about a { color: var(--ink); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--bar) + 32px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; background: var(--ink); color: var(--on-ink); border-radius: var(--radius-pill);
  padding: 10px 18px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 0.2s;
  max-width: calc(100vw - 32px);
}
#toast.is-on { opacity: 1; }
