:root {
  --bg: #0b1120;
  --bg2: #111a2e;
  --karte: #141f36;
  --rand: #24314f;
  --text: #e6ecf7;
  --text2: #9fb0cf;
  --akzent: #38bdf8;
  --gruen: #22c55e;
  --gelb: #eab308;
  --rot: #ef4444;
  --grau: #64748b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16254a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; }
h1 { font-size: 1.25rem; margin: 0; letter-spacing: .02em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 650; }
code { background: var(--bg2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dezent { color: var(--text2); font-weight: 400; font-size: .9rem; margin-left: 6px; }
.dezent-block { color: var(--text2); font-size: .92rem; margin-bottom: 10px; }

/* Kopf */
.kopf {
  max-width: 1100px; margin: 0 auto; padding: 16px 16px 8px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
}
.marke { display: flex; align-items: center; gap: 10px; }
.logo { width: 28px; height: 28px; color: var(--akzent); transform: rotate(-30deg); }
.hinweis-offiziell {
  background: rgba(234, 179, 8, .14); border: 1px solid rgba(234, 179, 8, .55); color: #fde68a;
  padding: 8px 12px; border-radius: 10px; font-size: .92rem;
}
.hinweis-offiziell::before { content: "⚠ "; }

/* Karten */
.karte {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--karte);
  border: 1px solid var(--rand); border-radius: var(--radius); padding: 16px; margin-top: 14px;
}
.raster2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.raster2 > .karte { margin-top: 14px; }
@media (max-width: 820px) { .raster2 { grid-template-columns: 1fr; gap: 0; } }

/* Eingabe */
#formular { display: flex; gap: 8px; }
#platz {
  flex: 1; min-width: 0; font-size: 1.25rem; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--rand); background: var(--bg2); color: var(--text); letter-spacing: .06em;
  text-transform: uppercase;
}
#platz:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }
button, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--rand);
  border-radius: 10px; padding: 10px 14px; cursor: pointer;
}
#abrufen { background: var(--akzent); color: #04223a; font-weight: 700; border: 0; padding: 12px 20px; }
#abrufen:disabled { opacity: .6; cursor: wait; }
.zeile-unter { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-top: 12px; }
.zuletzt { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.zuletzt .leer { color: var(--text2); font-size: .9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .92rem;
  background: var(--bg2); border: 1px solid var(--rand); color: var(--text); cursor: pointer;
}
.chip small { color: var(--text2); max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--akzent); }
.link-knopf { background: none; border: 0; color: var(--text2); text-decoration: underline; padding: 4px; font-size: .85rem; }
.flugzeugwahl { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: .92rem; }
.flugzeugwahl select { font-size: 1rem; }
.vorschlaege { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }

/* Meldungen */
.meldung { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid; }
.meldung.fehler { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .5); color: #fecaca; }
.meldung.info { background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .4); color: #bae6fd; }
.hinweis { margin-top: 10px; padding: 10px 14px; border-radius: 10px; font-size: .95rem; border-left: 4px solid; }
.hinweis.warn { background: rgba(234, 179, 8, .1); border-color: var(--gelb); color: #fef3c7; }
.hinweis.fehler { background: rgba(239, 68, 68, .1); border-color: var(--rot); color: #fee2e2; }
.hinweis.station { background: rgba(56, 189, 248, .1); border-color: var(--akzent); color: #e0f2fe; }
.laden { margin-top: 18px; color: var(--text2); display: flex; align-items: center; gap: 10px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--rand); border-top-color: var(--akzent); border-radius: 50%; animation: dreh 1s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* Platzkopf */
.platzkopf { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; }
.platzkopf .kennung { font-size: 1.6rem; font-weight: 800; letter-spacing: .05em; }
.platzkopf .name { font-size: 1.05rem; }
.fakten { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text2); font-size: .92rem; margin-top: 4px; }
.fakten b { color: var(--text); font-weight: 600; }
.aktualisieren { font-size: .92rem; }

/* METAR */
.roh {
  margin: 10px 0 14px; padding: 12px 14px; background: #060b16; border: 1px solid var(--rand); border-radius: 10px;
  font: 600 1.05rem/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #7dd3fc;
  white-space: pre-wrap; word-break: break-word;
}
.roh.klein { font-size: .92rem; font-weight: 500; color: var(--text2); }
.entschl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.entschl dt { color: var(--text2); font-size: .92rem; }
.entschl dd { margin: 0; }
.entschl dd code { margin-left: 6px; color: var(--text2); font-size: .8rem; }
@media (max-width: 520px) {
  .entschl { grid-template-columns: 1fr; gap: 0; }
  .entschl dt { margin-top: 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
}
details summary { cursor: pointer; color: var(--text2); margin-top: 12px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; vertical-align: middle; }
.badge.VFR { background: rgba(34,197,94,.2); color: #86efac; }
.badge.MVFR { background: rgba(56,189,248,.2); color: #7dd3fc; }
.badge.IFR { background: rgba(239,68,68,.2); color: #fca5a5; }
.badge.LIFR { background: rgba(217,70,239,.2); color: #f0abfc; }
.badge.beste { background: rgba(56,189,248,.18); color: #7dd3fc; }

/* Ampel */
.ampel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 820px) { .ampel { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .ampel { grid-template-columns: 1fr; } }
.licht {
  border-radius: 12px; padding: 12px; border: 1px solid var(--rand); background: var(--bg2);
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.licht::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--farbe); }
.licht .kopfzeile { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.licht .punkt { width: 14px; height: 14px; border-radius: 50%; background: var(--farbe); box-shadow: 0 0 12px var(--farbe); flex: none; }
.licht .wert { font-size: 1.2rem; font-weight: 700; }
.licht .klein { color: var(--text2); font-size: .82rem; }
.licht.gruen { --farbe: var(--gruen); }
.licht.gelb { --farbe: var(--gelb); }
.licht.rot { --farbe: var(--rot); background: rgba(239,68,68,.08); }
.licht.grau { --farbe: var(--grau); }
.licht.grau .punkt { box-shadow: none; }
.licht.unbekannt { --farbe: #94a3b8; border-style: dashed; }
.licht.unbekannt .punkt { box-shadow: none; background: transparent; border: 2px dashed var(--farbe); }

/* Windrose */
.windrose-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
#windrose { width: min(100%, 320px); height: auto; flex: none; }
.windtext { flex: 1; min-width: 180px; }
.windtext .gross { font-size: 1.6rem; font-weight: 800; }
.windtext .klein { color: var(--text2); font-size: .9rem; }
.rose-ring { fill: #0a1428; stroke: var(--rand); stroke-width: 1.5; }
.rose-strich { stroke: #3a4a6e; stroke-width: 1; }
.rose-strich.lang { stroke: #5b6e96; stroke-width: 1.5; }
.rose-text { fill: var(--text2); font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.piste { fill: #3b475f; stroke: #8b9bbd; stroke-width: 1; }
.piste-mitte { stroke: #e6ecf7; stroke-width: 1.2; stroke-dasharray: 7 6; }
.piste-text { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: #0a1428; stroke-width: 3px; }
.piste-text.beste { fill: #7dd3fc; }
.wind-pfeil { stroke: var(--akzent); stroke-width: 5; stroke-linecap: round; fill: none; }
.wind-spitze { fill: var(--akzent); }
.wind-sektor { fill: rgba(56, 189, 248, .18); stroke: rgba(56, 189, 248, .5); }
.rose-mitte { fill: var(--text); font-size: 14px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }

/* Tabellen */
.tabelle-scroll { overflow-x: auto; margin-top: 12px; -webkit-overflow-scrolling: touch; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabelle th, .tabelle td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--rand); white-space: nowrap; }
.tabelle th { color: var(--text2); font-weight: 600; font-size: .85rem; }
.tabelle td.zahl, .tabelle th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.tabelle tr.beste td { background: rgba(56, 189, 248, .07); }
.tabelle tr.abweichung td { background: rgba(234, 179, 8, .12); }
.tabelle tr.abweichung td:first-child { box-shadow: inset 4px 0 0 var(--gelb); }
.rueckenwind { color: #fca5a5; }
.ueber-limit { color: #fca5a5; font-weight: 700; }
.markierung { color: #fde68a; font-weight: 700; }
.fussnote { color: var(--text2); font-size: .82rem; margin: 10px 0 0; }

/* Dichtehöhe */
.dh-wert { font-size: 2rem; font-weight: 800; }
.dh-wert.hoch { color: #fca5a5; }
.dh-liste { list-style: none; padding: 0; margin: 10px 0 0; color: var(--text2); font-size: .92rem; }
.dh-liste li { padding: 3px 0; }
.dh-liste b { color: var(--text); }

.fuss { color: var(--text2); font-size: .85rem; text-align: center; margin-top: 18px; }
.seitenfuss { max-width: 1100px; margin: 0 auto; padding: 16px 16px 32px; color: var(--text2); font-size: .85rem; border-top: 1px solid var(--rand); }
.seitenfuss strong { color: #fde68a; }

/* ---------------------------------------------------------- PWA-Ergänzungen */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.kopf { padding-top: max(16px, env(safe-area-inset-top)); }
.marke { flex: 1; }
.marke .logo { transform: none; width: 32px; height: 32px; border-radius: 8px; }
.knopf-icon {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; margin-left: auto;
  background: var(--bg2); border: 1px solid var(--rand); border-radius: 10px; color: var(--text);
}
.knopf-icon svg { width: 20px; height: 20px; }
.netzstatus {
  background: rgba(239, 68, 68, .18); color: #fecaca; border: 1px solid rgba(239, 68, 68, .5);
  border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.stand {
  margin-top: 14px; padding: 10px 14px; border-radius: 12px; font-size: .95rem;
  background: var(--bg2); border: 1px solid var(--rand); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
}
.stand b { font-size: 1.05rem; }
.stand.alt { background: rgba(234, 179, 8, .14); border-color: rgba(234, 179, 8, .6); color: #fef3c7; }
.stand.sehr-alt { background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .65); color: #fee2e2; }
.stand .offline-marke { font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.stand button { padding: 6px 12px; font-size: .9rem; margin-left: auto; }

/* Dialog */
.dialog {
  width: min(680px, 100vw); max-height: min(92vh, 900px); padding: 0; border: 1px solid var(--rand); border-radius: 16px;
  background: var(--karte); color: var(--text);
}
.dialog::backdrop { background: rgba(2, 6, 18, .7); backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  .dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
}
#einst-form { display: flex; flex-direction: column; height: 100%; max-height: inherit; }
.dialog-kopf, .dialog-fuss { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rand); }
.dialog-kopf { padding-top: max(12px, env(safe-area-inset-top)); }
.dialog-kopf h2 { margin: 0; }
.dialog-fuss { border-top: 1px solid var(--rand); border-bottom: 0; justify-content: flex-end; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.dialog-inhalt { padding: 14px 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.primaer { background: var(--akzent); color: #04223a; font-weight: 700; border: 0; }
.gefahr { border-color: rgba(239, 68, 68, .6); color: #fecaca; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button[aria-selected="true"] { background: var(--akzent); color: #04223a; border-color: var(--akzent); font-weight: 700; }
.gruppe { border: 1px solid var(--rand); border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.gruppe legend { padding: 0 6px; color: var(--text2); font-size: .9rem; font-weight: 600; }
.felder { display: grid; gap: 10px; margin-top: 8px; }
.feld { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.feld > span { font-size: .95rem; }
.feld small { grid-column: 1 / -1; color: var(--text2); font-size: .8rem; }
.feld-paar { display: flex; gap: 8px; align-items: center; }
.eingabe-zahl { display: inline-flex; align-items: center; gap: 4px; color: var(--text2); font-size: .85rem; }
.eingabe-zahl input, .feld input[type="text"] {
  width: 5.5em; font: inherit; font-size: 1rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--rand); background: var(--bg2); color: var(--text); text-align: right;
}
.feld input[type="text"] { width: 11em; text-align: left; }
.eingabe-zahl.gelb input { border-color: rgba(234, 179, 8, .7); }
.eingabe-zahl.rot input { border-color: rgba(239, 68, 68, .7); }
.feld .warnung { color: #fde68a; }
.erweitert { margin-top: 12px; }
.erweitert summary { margin-top: 0; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; }
.knopf-label {
  display: inline-block; padding: 10px 14px; border: 1px solid var(--rand); border-radius: 10px; background: var(--bg2); cursor: pointer;
}
.einst-meldung { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(56, 189, 248, .1); color: #bae6fd; }
.einst-meldung.fehler { background: rgba(239, 68, 68, .12); color: #fecaca; }
.standard-wahl { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; color: var(--text2); }
.dialog-inhalt { overflow-x: hidden; }
.feld > span { min-width: 0; }
.feld-paar { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 600px) {
  .feld { grid-template-columns: 1fr; }
  .feld-paar { justify-content: flex-start; }
  .eingabe-zahl input { width: 4.8em; }
  .feld input[type="text"] { width: 100%; }
}

/* ---------------------------------------------------------- Suchvorschläge */
#formular { position: relative; }
.suchfeld { flex: 1; min-width: 0; }
.suchfeld #platz { width: 100%; text-transform: none; letter-spacing: .02em; }
.suchliste {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; margin: 0; padding: 6px; list-style: none;
  background: var(--bg2); border: 1px solid var(--rand); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  max-height: min(60vh, 440px); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.suchliste li {
  display: grid; grid-template-columns: 4.6em 1fr; gap: 0 10px; align-items: center;
  min-height: 48px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.suchliste li[aria-selected="true"], .suchliste li:hover { background: rgba(56, 189, 248, .16); }
.suchliste .code { font-weight: 800; letter-spacing: .04em; font-size: .95rem; grid-row: span 2; }
.suchliste .code.lang { font-size: .78rem; letter-spacing: 0; }
.suchliste .sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suchliste .smeta { color: var(--text2); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suchliste .smeta .zeigt { color: var(--akzent); }
.suchliste .leer { display: block; min-height: 0; color: var(--text2); cursor: default; }
.suchliste .leer:hover { background: none; }
.suchliste mark { background: none; color: var(--akzent); font-weight: 700; }
