:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #121826;
  --muted: #5b6475;
  --border: #dfe3ea;
  --brand: #0a1d56;
  --brand-text: #ffffff;
  --accent: #ffad00;
  --ok: #1f7a44;
  --warn: #a3520a;
  --error: #b42318;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d111a;
    --surface: #161c28;
    --text: #e8ebf2;
    --muted: #9aa3b5;
    --border: #2a3242;
    --brand: #1b3380;
    --ok: #4cc27f;
    --warn: #f0a04b;
    --error: #ff6b5e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { width: 100%; max-width: 560px; margin: 0 auto; padding: 32px 16px; flex: 1; }

h1 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -0.02em; }
h2 { margin: 4px 0; font-size: 1.35rem; }
h3 { margin: 28px 0 8px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.lead { margin: 0 0 24px; color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
}

#locate {
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #1a1200;
  font-weight: 650;
  font-size: 1.05rem;
}
#locate:hover { filter: brightness(1.05); }
#locate:focus-visible, .link:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.hint, .meta, .note { color: var(--muted); font-size: 0.875rem; }
.hint { margin: 8px 0 0; }

.message {
  margin: 20px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.message[data-kind="error"] { border-color: var(--error); color: var(--error); }

.manual { margin: 20px 0; }
.manual label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.95rem; }
.manual-row { display: flex; gap: 8px; }
.manual input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  /* mindestens 16px, sonst zoomt iOS Safari beim Antippen hinein */
  font-size: max(1.1rem, 16px);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.manual input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; color: var(--muted); }
.manual input:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; }
.manual button {
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-text);
  font-weight: 600;
}

#result { margin-top: 24px; }

/* Flughafen-Umschalter: kompakte Leiste + aufklappbares Bedienfeld */
.ap-summary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.ap-summary:hover { border-color: var(--muted); }
.ap-summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.ap-head { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ap-title { font-size: 1.2rem; font-weight: 700; line-height: 1.2; }
.ap-title .iata { margin-right: 6px; }
.ap-caret { flex: none; color: var(--muted); font-size: 0.9rem; transition: transform 0.15s ease; }
.ap-summary[aria-expanded="true"] .ap-caret { transform: rotate(180deg); }

/* Vor der Auswahl: Bedienfeld offen. Nach der Auswahl: zugeklappt, bis die Leiste aufgeklappt wird. */
body.has-airport #intro { display: none; }
body.has-airport #finder-panel { display: none; margin-top: 12px; }
body.has-airport #ap-toggle[aria-expanded="true"] + #finder-panel { display: block; }

.label { text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.08em; color: var(--muted); }
.iata { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brand); }
@media (prefers-color-scheme: dark) { .iata { color: var(--accent); } }
.meta { margin: 0; }

.pass {
  margin-top: 20px;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-text);
  padding: 20px;
  box-shadow: 0 8px 24px rgb(10 29 86 / 0.18);
}
.pass .meta, .pass .note { color: rgb(255 255 255 / 0.75); }
.pass-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flight-number { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.02em; }
.status {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
}
.status:empty { display: none; }
.status[data-code="cancelled"], .status[data-code="delayed"], .status[data-code="diverted"] { background: var(--accent); color: #1a1200; }

.route { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 4px; }
.route > div { display: flex; flex-direction: column; }
.route .to { text-align: right; }
.code { font-size: 2.5rem; font-weight: 750; line-height: 1; letter-spacing: 0.02em; }
.time { font-size: 1.1rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.arrow { font-size: 1.6rem; color: var(--accent); }

.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px dashed rgb(255 255 255 / 0.35);
}
.details dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgb(255 255 255 / 0.65); }
.details dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.pass .note { margin: 14px 0 0; }

.alternatives { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.link {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.link:hover { border-color: var(--muted); }
.link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .dist { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

#mock { margin-top: 24px; }

footer { text-align: center; padding: 16px; color: var(--muted); font-size: 0.75rem; }
footer a { color: inherit; }

/* Flugkarte: ganze Fläche per Maus anklickbar, zusätzlich ein Button für Touch/iOS */
.pass { cursor: pointer; }
.pass-cta {
  display: block;
  width: 100%;
  margin: 18px 0 0;
  padding: 12px 16px;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.12);
  color: var(--brand-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.pass-cta:hover { background: rgb(255 255 255 / 0.2); }
.pass-cta:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Dialog der Fake-Bordkarte */
.bp-dialog {
  width: min(92vw, 440px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--text);
}
.bp-dialog::backdrop { background: rgb(5 8 15 / 0.65); }
.bp {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.4);
}
.bp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 16px 20px;
  background: var(--brand);
  color: var(--brand-text);
}
.bp-airline { font-size: 1.4rem; font-weight: 750; letter-spacing: 0.04em; }
.bp-kind { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.8; }

.bp-route {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 2px dashed var(--border);
}
.bp-route > div { display: flex; flex-direction: column; min-width: 0; }
.bp-route .bp-dest { text-align: right; }
.bp-code { font-size: 2.2rem; font-weight: 750; line-height: 1; color: var(--brand); }
@media (prefers-color-scheme: dark) { .bp-code { color: var(--accent); } }
.bp-city { margin-top: 4px; font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-plane { color: var(--accent); font-size: 1.4rem; flex: none; }

.bp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
  padding: 20px;
}
.bp-grid .bp-wide { grid-column: 1 / -1; }
.bp-grid dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.bp-grid dd { margin: 2px 0 0; font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }

.bp-barcode {
  padding: 0 20px 4px;
  background: #fff;
}
.bp-barcode svg { display: block; width: 100%; height: auto; }
.bp-bcbp {
  margin: 0;
  padding: 8px 20px 16px;
  background: #fff;
  color: #333;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.6rem;
  line-height: 1.4;
  word-break: break-all;
}
.bp-fake {
  margin: 0;
  padding: 12px 20px;
  background: var(--accent);
  color: #1a1200;
  font-size: 0.8rem;
  font-weight: 650;
  text-align: center;
}
.bp-close-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.bp-close-btn:hover { background: var(--bg); }

/* Abflugbrett */
.board { margin-top: 24px; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.board-head h3 { margin: 0; color: var(--text); font-size: 1.1rem; }
.board-hint { margin: 14px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }

.airline-group { margin-top: 18px; }
.airline-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.airline-head .iata { font-size: 1.05rem; }
.airline-head .airline-name { color: var(--muted); font-weight: 500; font-size: 0.9rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.airline-head .airline-count { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.dep-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dep {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 12px;
  /* oben ausrichten: die planmäßige Zeit bleibt an gleicher Stelle, auch wenn darunter eine erwartete Zeit erscheint */
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.dep.is-clickable { cursor: pointer; }
.dep.is-clickable:hover { border-color: var(--muted); }
.dep:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.dep-time { display: flex; flex-direction: column; min-width: 3.4em; }
.dep-sched { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dep-sched.is-changed { text-decoration: line-through; opacity: 0.6; font-weight: 600; }
.dep-revised { font-size: 0.78rem; font-weight: 650; color: var(--warn); font-variant-numeric: tabular-nums; }

.dep-main { display: flex; flex-direction: column; min-width: 0; }
.dep-flight { font-weight: 650; }
.dep-dest { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dep-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.dep-gate { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.dep-status { font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--border); color: var(--text); white-space: nowrap; }
.dep-status:empty { display: none; }
.dep-status[data-code="cancelled"] { background: var(--error); color: #fff; }
.dep-status[data-code="delayed"], .dep-status[data-code="diverted"] { background: var(--accent); color: #1a1200; }
.dep-status[data-code="departed"], .dep-status[data-code="landed"] { background: var(--ok); color: #fff; }

/* Airline-Filter als Tags */
.airline-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.tag {
  padding: 5px 11px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .tag { border-color: var(--accent); } }
.tag.is-off {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  text-decoration: line-through;
}
.tag:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Flugdetails: unter der Flugzeile aufgeklappt */
.dep.is-open { border-color: var(--brand); }
.dep-detail {
  /* über die gesamte Breite der Zeile (drei Rasterspalten) */
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.dep-detail section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.dep-detail section:first-of-type { padding-top: 0; }
.dep-detail section:last-of-type { border-bottom: 0; }
.dep-detail h4 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.detail-grid dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.detail-grid dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.detail-empty { margin: 0; color: var(--muted); }
.detail-source { margin: 8px 0 0; font-size: 0.75rem; color: var(--muted); }
/* Warnhinweis bei Widersprüchen zur gemeldeten Abflugzeit */
.dep.has-warning .dep-flight::after { content: " ⚠"; color: var(--warn); }
.dep-warn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--warn);
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.dep-warn-icon { flex: none; color: var(--warn); font-size: 1.15rem; line-height: 1.25; }
.dep-warn ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 0.85rem; }

.dep-map { margin: 12px 0 0; }
.dep-map img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); background: var(--border); }
.dep-map figcaption { margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
