/* Endste Wetter – eigene Gestaltung: dunkle Himmelsverläufe, helle Karten, große Temperatur */
:root {
  --sky-top: #0f62c7;
  --sky-bottom: #4fa0ec;
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.72);
  --text-faint: rgba(255, 255, 255, 0.5);
  --card: rgba(8, 20, 40, 0.28);
  --card-line: rgba(255, 255, 255, 0.14);
  --accent: #ffd24a;
  --rain: #5cb8ff;
  --warn-minor: #ffd23f;
  --warn-moderate: #ff9b2f;
  --warn-severe: #ff4d4d;
  --warn-extreme: #c03bd6;
  --tab-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b2a55;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; background: transparent; }

#sky {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  transition: background 0.8s;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: #bfe3ff; }
.dim { color: var(--text-dim); }

/* ---------- Kopfleiste ---------- */
#topbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 8px 16px;
  background: rgba(8, 24, 50, 0.35);
  background: color-mix(in srgb, var(--sky-top) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
body.radar #topbar { background: rgba(10, 18, 32, 0.78); }
.place {
  flex: 1; min-width: 0; text-align: left;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
#place-name { font-size: 20px; font-weight: 650; letter-spacing: 0.2px; }
#place-name::after { content: " ▾"; font-size: 13px; color: var(--text-dim); }
#place-region { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gps-mark { color: var(--text-dim); align-self: center; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }
#refresh-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ansichten ---------- */
#views { position: fixed; inset: 0; }
.view {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 64px) 12px calc(var(--tab-h) + var(--safe-bottom) + 16px);
  display: none;
}
.view.active { display: block; }
.view > * { max-width: 760px; margin-left: auto; margin-right: auto; }

/* ---------- Kopf „Jetzt" ---------- */
#hero {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto;
  column-gap: 8px; align-items: center; padding: 8px 6px 18px;
}
#hero-icon { grid-row: 1 / span 2; }
#hero-icon svg { width: 112px; height: 112px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18)); }
#hero-temp { font-size: 84px; font-weight: 250; line-height: 1; letter-spacing: -3px; }
#hero-text { font-size: 19px; font-weight: 550; }
#hero-sub { grid-column: 1 / span 2; font-size: 15px; color: var(--text-dim); margin-top: 8px; }

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  padding: 12px 12px;
  margin-bottom: 12px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card-title {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim);
  margin: 0 2px 10px;
}
.card-title .dim { text-transform: none; letter-spacing: 0; }

/* Stundenleiste */
.hscroll {
  display: flex; overflow-x: auto; gap: 2px; scroll-snap-type: x proximity;
  scrollbar-width: none; margin: 0 -4px; padding: 0 4px;
}
.hscroll::-webkit-scrollbar { display: none; }
.hour {
  flex: 0 0 58px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0 2px; scroll-snap-align: start; border-radius: 12px;
}
.hour.now { background: rgba(255, 255, 255, 0.12); }
.hour.daystart { border-left: 1px solid var(--card-line); border-radius: 0 12px 12px 0; }
.hour .h-time { font-size: 13px; color: var(--text-dim); font-weight: 550; }
.hour.now .h-time { color: var(--text); }
.hour .h-temp { font-size: 17px; font-weight: 600; }
.hour .h-pop { font-size: 12px; color: var(--rain); min-height: 15px; font-weight: 550; }
.hour .h-mm { font-size: 11px; color: var(--text-faint); min-height: 13px; }
.hour .h-wind { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 2px; }
.arrow { display: inline-block; width: 11px; height: 11px; }
.hour .day-label { font-size: 11px; color: var(--accent); font-weight: 650; min-height: 13px; }

/* Diagramme */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-dim); font-size: 11px; font-family: inherit; }
.chart .t-max { fill: #fff; font-weight: 600; }

/* Details */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
  background: rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px; min-height: 70px;
}
.tile .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.tile .v { font-size: 21px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .s { font-size: 12px; color: var(--text-dim); }

/* Warnungen */
.alert {
  border-radius: 14px; padding: 10px 12px; margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.3); border-left: 5px solid var(--warn-minor);
}
.alert.moderate { border-color: var(--warn-moderate); }
.alert.severe { border-color: var(--warn-severe); }
.alert.extreme { border-color: var(--warn-extreme); }
.alert summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
.alert summary::-webkit-details-marker { display: none; }
.alert .when { font-size: 13px; color: var(--text-dim); font-weight: 400; }
.alert p { margin: 8px 0 0; font-size: 14px; line-height: 1.4; color: var(--text-dim); white-space: pre-line; }

/* Sonne & Mond */
.sunmoon { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.sunmoon > div:first-child svg { width: 100%; height: auto; display: block; }
.sunmoon .moon-box svg { display: block; margin: 0 auto; }
.sunmoon .moon-box { text-align: center; font-size: 13px; color: var(--text-dim); min-width: 92px; }
.sunmoon .moon-box b { display: block; color: var(--text); font-size: 14px; margin-top: 4px; }
.sun-times { display: flex; justify-content: space-between; font-size: 14px; margin-top: 4px; }
.sun-times span { color: var(--text-dim); }

.source { font-size: 12px; color: var(--text-faint); text-align: center; padding: 4px 0 12px; }
.source.stale { color: var(--warn-moderate); }

/* ---------- 14 Tage ---------- */
.list { padding: 4px 0; }
.day { border-top: 1px solid var(--card-line); }
.day:first-child { border-top: 0; }
.day-row {
  width: 100%; display: grid; align-items: center;
  grid-template-columns: 62px 40px 46px 1fr; gap: 6px; padding: 8px 12px; text-align: left;
}
.day-row .d-name { font-weight: 650; font-size: 16px; line-height: 1.1; }
.day-row .d-date { font-size: 12px; color: var(--text-dim); font-weight: 400; display: block; }
.day-row .d-pop { font-size: 12px; color: var(--rain); text-align: center; line-height: 1.2; font-weight: 550; }
.day-row .d-pop small { display: block; color: var(--text-faint); font-weight: 400; }
.range { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; }
.range .lo { text-align: right; color: var(--text-dim); font-size: 16px; }
.range .hi { font-weight: 650; font-size: 16px; }
.bar { position: relative; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.day-more { display: none; padding: 0 12px 12px; }
.day.open .day-more { display: block; }
.day.open .day-row { background: rgba(255, 255, 255, 0.06); }
.parts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 10px; }
.part { text-align: center; background: rgba(255, 255, 255, 0.07); border-radius: 12px; padding: 6px 2px; }
.part .p-name { font-size: 12px; color: var(--text-dim); }
.part .p-temp { font-weight: 650; }
.part .p-pop { font-size: 12px; color: var(--rain); min-height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; padding: 5px 10px; color: var(--text-dim); }
.chip b { color: var(--text); font-weight: 600; }
.partial-note { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

/* ---------- Radar ---------- */
#view-radar { padding: 0; overflow: hidden; }
#view-radar > * { max-width: none; }
#radar-map { position: absolute; inset: 0; background: #1b2330; }
#radar-panel {
  position: absolute; left: 10px; right: 10px; z-index: 500;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 10px);
  max-width: 640px; margin: 0 auto;
  background: rgba(10, 18, 32, 0.78); border: 1px solid var(--card-line); border-radius: 16px;
  padding: 10px 12px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#radar-status { font-size: 15px; font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
#radar-status .fc { color: #ffb347; }
#radar-status small { font-weight: 400; color: var(--text-dim); }
.radar-row { display: flex; align-items: center; gap: 10px; }
.round-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; background: #fff; color: #0d2a52; display: grid; place-items: center; }
.round-btn .pause { display: none; }
.round-btn.playing .pause { display: block; }
.round-btn.playing .play { display: none; }
#radar-slider { flex: 1; min-width: 0; accent-color: #ffd24a; height: 30px; }
.pill { border: 1px solid var(--card-line); border-radius: 999px; padding: 7px 12px; font-size: 14px; background: rgba(255, 255, 255, 0.1); }
.radar-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin-top: 8px; }
.radar-legend i {
  flex: 0 0 110px; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, #9be1ff, #3c8cff, #2ad15a, #ffe100, #ff8a00, #ff2020, #c23bd4);
}
#radar-attrib { margin-left: auto; text-align: right; }
.map-btn {
  position: absolute; z-index: 500; right: 12px; top: calc(var(--safe-top) + 64px);
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(10, 18, 32, 0.78); border: 1px solid var(--card-line);
}
.leaflet-container { font-family: inherit; background: #1b2330; }
/* helle OSM-Karte in eine ruhige, dunkle Grundkarte verwandeln, damit das Radar heraussticht */
.ew-osm { filter: invert(1) hue-rotate(195deg) saturate(0.35) brightness(0.82) contrast(0.9); }
.leaflet-control-attribution {
  background: rgba(10, 18, 32, 0.6) !important; color: var(--text-dim) !important; font-size: 10px;
}
.leaflet-control-attribution a { color: #bfe3ff !important; }
.leaflet-top.leaflet-right { top: calc(var(--safe-top) + 112px); }
.here-dot { width: 16px; height: 16px; border-radius: 50%; background: #2e8bff; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(46, 139, 255, 0.35); }

/* ---------- Orte ---------- */
.search-wrap { position: relative; margin-bottom: 12px; }
#search {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: rgba(255, 255, 255, 0.16); border: 1px solid var(--card-line); border-radius: 12px;
  padding: 11px 14px; outline: none;
}
#search::placeholder { color: var(--text-faint); }
#search-results { margin-top: 8px; }
.prow {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--card-line);
}
.prow:first-child { border-top: 0; }
.prow.current { background: rgba(255, 255, 255, 0.08); }
.prow .p-main { min-width: 0; text-align: left; }
.prow .p-title { font-weight: 650; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.prow .p-sub { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .p-wx { display: flex; align-items: center; gap: 4px; font-size: 20px; font-weight: 600; }
.prow .p-act { display: flex; gap: 2px; }
.prow .p-act button { width: 32px; height: 32px; border-radius: 8px; color: var(--text-dim); font-size: 16px; }
.prow .p-act button:active { background: rgba(255, 255, 255, 0.15); }
.hint { font-size: 12px; color: var(--text-faint); text-align: center; margin: 2px 0 16px; }
.about { font-size: 13px; color: var(--text-dim); line-height: 1.45; padding: 0 4px; }

/* ---------- Tableiste ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(8, 18, 36, 0.82); border-top: 1px solid var(--card-line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-faint); font-size: 11px; font-weight: 550; }
#tabbar svg { width: 26px; height: 26px; }
#tabbar button.active { color: var(--accent); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 14px);
  background: rgba(0, 0, 0, 0.78); padding: 9px 14px; border-radius: 12px; font-size: 14px; max-width: 90vw;
}
#view-radar.active ~ #toast { bottom: calc(var(--tab-h) + var(--safe-bottom) + 130px); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
