/* ------------------------------------------------------------------ Basis */
:root {
  --bg-top: #0b1a2e;
  --bg-mid: #12365c;
  --bg-bot: #0a1220;
  --glow-a: rgba(90, 160, 255, 0.45);
  --glow-b: rgba(40, 90, 180, 0.35);
  --ink: #f7faff;
  --ink-dim: rgba(240, 246, 255, 0.84);
  --ink-faint: rgba(240, 246, 255, 0.68);
  --card: rgba(9, 20, 36, 0.42);
  --card-line: rgba(255, 255, 255, 0.18);
  --accent: #6cb8ff;
  --accent-2: #9ad6ff;
  --prob: rgba(255, 214, 120, 0.95);
  --radius: 22px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI',
    'Helvetica Neue', Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-bot);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* --------------------------------------------------------------- Himmel */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bot) 100%);
  transition: background 1.4s ease;
}

.sky__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  transition: background 1.4s ease;
}

.sky__glow--a {
  width: 70vmax;
  height: 70vmax;
  top: -32vmax;
  left: -18vmax;
  background: var(--glow-a);
  animation: drift-a 34s ease-in-out infinite alternate;
}

.sky__glow--b {
  width: 55vmax;
  height: 55vmax;
  bottom: -26vmax;
  right: -16vmax;
  background: var(--glow-b);
  animation: drift-b 42s ease-in-out infinite alternate;
}

.sky__rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.6s ease;
}

body[data-rain='1'] .sky__rain {
  opacity: 1;
}

@keyframes drift-a {
  to {
    transform: translate3d(12vw, 8vh, 0) scale(1.15);
  }
}
@keyframes drift-b {
  to {
    transform: translate3d(-10vw, -6vh, 0) scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sky__glow {
    animation: none;
  }
}

/* ---------------------------------------------------------------- Layout */
.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 18px calc(40px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ------------------------------------------------------------------ Hero */
.hero {
  padding: 26px 6px 12px;
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  /* Der Kopfbereich liegt ohne Karte direkt auf dem Verlauf */
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.42);
}

.hero__place {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-dim);
}

.hero__place h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--ink);
}

.hero__condition {
  margin: 10px 0 0;
  font-size: 18.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.hero__value {
  margin-top: 2px;
  font-size: clamp(64px, 19vw, 104px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.045em;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.hero__unit {
  font-size: 0.24em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-dim);
  transform: translateY(-0.35em);
}

.hero__detail {
  margin: 4px auto 0;
  max-width: 34ch;
  font-size: 15.5px;
  /* liegt direkt auf dem hellsten Bereich des Verlaufs - volle Deckung */
  color: var(--ink);
  line-height: 1.5;
}

.hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(9, 20, 36, 0.42);
  border: 1px solid var(--card-line);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.chip b {
  font-weight: 600;
}

.chip--warn {
  background: rgba(255, 196, 90, 0.18);
  border-color: rgba(255, 196, 90, 0.4);
}

/* ------------------------------------------------------------------ Card */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: var(--shadow);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card:nth-of-type(2) { animation-delay: 0.04s; }
.card:nth-of-type(3) { animation-delay: 0.08s; }
.card:nth-of-type(4) { animation-delay: 0.12s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--ink-dim);
}

.card__head h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 0;
  flex: 1;
  color: var(--ink);
}

.card__badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink-dim);
  white-space: nowrap;
}

.icon {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--fill {
  fill: currentColor;
  stroke: none;
}

.icon .hole {
  fill: var(--bg-mid);
  stroke: none;
}

/* ----------------------------------------------------------------- Chart */
.chart {
  position: relative;
  width: 100%;
  touch-action: pan-y;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  font-family: inherit;
  fill: var(--ink-dim);
  font-size: 12.5px;
  font-weight: 600;
}

.chart .axis-line {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}

.chart .grid-label {
  fill: var(--ink-faint);
  font-size: 12px;
  font-weight: 500;
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.chart__legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

.swatch--main {
  background: linear-gradient(180deg, #8fd0ff, #3d86f0);
}
.swatch--band {
  background: rgba(140, 200, 255, 0.28);
}
.swatch--prob {
  background: var(--prob);
  height: 3px;
  border-radius: 2px;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -110%);
  background: rgba(10, 18, 32, 0.96);
  border: 1px solid var(--card-line);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.14s ease;
  z-index: 5;
}

.tooltip.is-on {
  opacity: 1;
}

.tooltip b {
  font-weight: 600;
}

.tooltip .t-dim {
  color: rgba(240, 246, 255, 0.72);
}

/* ----------------------------------------------------------------- Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.stat__k {
  font-size: 12.5px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.stat__v {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 3px;
}

.stat__v small {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-dim);
  margin-left: 4px;
}

/* ------------------------------------------------------------------- Map */
.card--map {
  padding-bottom: 14px;
}

.map {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 62vh;
  border-radius: 16px;
  overflow: hidden;
  background: #0d1a2b;
  cursor: grab;
  touch-action: none;
}

.map:active {
  cursor: grabbing;
}

.map canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.map__label {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(10, 18, 32, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--card-line);
}

.map__attrib {
  position: absolute;
  right: 8px;
  bottom: 7px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(10, 18, 32, 0.7);
  padding: 3px 7px;
  border-radius: 6px;
}

.map__zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--card-line);
}

.map__zoom button {
  width: 32px;
  height: 32px;
  border: 0;
  background: rgba(10, 18, 32, 0.7);
  color: var(--ink);
  font-size: 18px;
  font-weight: 400;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.map__zoom button:hover {
  background: rgba(30, 50, 80, 0.85);
}

/* -------------------------------------------------------------- Timeline */
.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
}

.timeline__play {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--card-line);
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.timeline__play:hover {
  background: rgba(255, 255, 255, 0.2);
}
.timeline__play:active {
  transform: scale(0.94);
}

.timeline__time {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 78px;
  text-align: right;
  color: var(--ink);
}

input[type='range'] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.55) var(--pct, 0%),
    rgba(255, 255, 255, 0.16) var(--pct, 0%)
  );
  outline: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

input[type='range']::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

/* ----------------------------------------------------------------- Skala */
.scale {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-dim);
}

.scale__bar {
  display: flex;
  flex: 1;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
}

.scale__bar i {
  flex: 1;
}

.scale__ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.scale__wrap {
  flex: 1;
}

/* --------------------------------------------------------------- Details */
.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px 12px;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail__k {
  font-size: 12.5px;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail__v {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.detail__v small {
  font-size: 13px;
  color: var(--ink-dim);
  font-weight: 500;
}

/* ---------------------------------------------------------- Notification */
.notify__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.notify__row strong {
  font-size: 16px;
  font-weight: 600;
}

.notify__row p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--ink-dim);
  max-width: 42ch;
  line-height: 1.5;
}

.switch {
  width: 51px;
  height: 31px;
  flex: none;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.2);
  position: relative;
  cursor: pointer;
  transition: background 0.28s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
  transition: transform 0.28s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.switch[aria-checked='true'] {
  background: #34c759;
}

.switch[aria-checked='true'] span {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.notify__opts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.notify__opts label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-faint);
  flex: 1 1 170px;
}

select,
.btn {
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--card-line);
  border-radius: 11px;
  padding: 9px 11px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
    linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

select option {
  background: #16273f;
  color: var(--ink);
}

.btn {
  align-self: flex-end;
  font-weight: 500;
  transition: background 0.2s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn--ghost {
  background: transparent;
  font-size: 12.5px;
  padding: 7px 12px;
}

.notify__hint {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--ink-dim);
  line-height: 1.55;
}

.notify__hint b {
  color: var(--ink);
}

/* --------------------------------------------------------------- Quellen */
.sources {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.source h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 700;
}

.source p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-dim);
}

.source__meta {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- Footer */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 0;
  font-size: 13px;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ----------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: rgba(16, 26, 44, 0.94);
  border: 1px solid var(--card-line);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 13.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 40;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------- Zustand */
body[data-state='loading'] .card,
body[data-state='loading'] .hero__chips {
  opacity: 0.75;
}

@media (max-width: 430px) {
  .shell {
    padding-left: 14px;
    padding-right: 14px;
    gap: 13px;
  }
  .card {
    padding: 16px 14px 14px;
    border-radius: 20px;
  }
}
