:root {
  color-scheme: light dark;
  --bg: #f2f4f8; --card: #ffffff; --ink: #14202e; --muted: #5d6b7c; --line: #dfe4ec;
  --accent: #0a5cff; --accent-ink: #ffffff;
  --ok: #1a7f4b; --ok-bg: #e2f4ea; --live: #0a5cff; --live-bg: #e3ecff;
  --warn: #9a5b00; --warn-bg: #fff0d6; --bad: #b3261e; --bad-bg: #fde7e5; --done: #4a5565; --done-bg: #e7eaef;
  --radius: 16px;
  --plane: #ffad00;
  --plane-edge: -1px 0 0 #05164d, 1px 0 0 #05164d, 0 -1px 0 #05164d, 0 1px 0 #05164d;
}
/* dark palette: when the phone is dark (unless light was chosen), or when dark was chosen — see theme.js */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d131b; --card: #18212c; --ink: #eaf0f7; --muted: #94a3b5; --line: #2a3644;
    --accent: #5b9bff; --accent-ink: #06142b;
    --ok: #5fd39a; --ok-bg: #12301f; --live: #7db0ff; --live-bg: #14284a;
    --warn: #ffc15e; --warn-bg: #3a2a0c; --bad: #ff8d84; --bad-bg: #411a17; --done: #b5c0cf; --done-bg: #263140;
      --plane: #ffb81c; --plane-edge: 0 1px 2px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0d131b; --card: #18212c; --ink: #eaf0f7; --muted: #94a3b5; --line: #2a3644;
    --accent: #5b9bff; --accent-ink: #06142b;
    --ok: #5fd39a; --ok-bg: #12301f; --live: #7db0ff; --live-bg: #14284a;
    --warn: #ffc15e; --warn-bg: #3a2a0c; --bad: #ff8d84; --bad-bg: #411a17; --done: #b5c0cf; --done-bg: #263140;
  color-scheme: dark;
    --plane: #ffb81c; --plane-edge: 0 1px 2px rgba(0,0,0,.6);
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
main { max-width: 560px; margin: 0 auto; padding-block: 8px 40px; }
h1 { font-size: 1.5rem; margin: 12px 0 4px; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 20px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.bad-text { color: var(--bad); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 12px 0; display: block;
}
.card.narrow { margin-top: 18vh; }
.card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
a.card { text-decoration: none; color: inherit; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
a.card div { display: flex; flex-direction: column; }

.bar { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
/* confirmations float at the bottom (above the home bar): at the top they covered the back button */
.toasts { position: fixed; z-index: 1000; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); padding-inline: 16px; pointer-events: none; display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; }
.toasts .flash { pointer-events: auto; width: 100%; max-width: 528px; margin: 0; box-shadow: 0 4px 16px rgba(0,0,0,.18); transition: opacity .4s, transform .4s; cursor: pointer; }
.toasts .flash.gone { opacity: 0; transform: translateY(12px); }
.flash { padding: 10px 14px; border-radius: 12px; margin: 10px 0; background: var(--ok-bg); color: var(--ok); font-size: .92rem; }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0; }
input {
  display: block; width: 100%; margin-top: 4px; padding: 12px; font: inherit; font-size: 16px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
}
input[readonly] { font-size: .8rem; }
button {
  font: inherit; font-weight: 600; padding: 12px 16px; min-height: 44px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; }
button:disabled { opacity: .5; }
button.link { background: none; border: 0; color: var(--accent); padding: 8px 4px; font-weight: 500; }
button.danger, .danger { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }
.legrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sharebox input { margin: 8px 0; }

/* status pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.live { background: var(--live-bg); color: var(--live); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.done { background: var(--done-bg); color: var(--done); }
.pill.muted { background: var(--done-bg); color: var(--muted); }

/* public page */
.hero h1 { margin-top: 18px; }
.hero p { margin: 0 0 6px; }
#map { height: 38vh; min-height: 230px; max-height: 360px; border-radius: var(--radius); border: 1px solid var(--line); margin: 12px 0; background: #dfe6ee; }
#map.mapfail { display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--muted); background: var(--card); font-size: .85rem; }
/* section headings ("Current flight", "Coming up", "Completed"): readable at a glance, an icon per kind, a rule across */
.sec { display: flex; align-items: center; gap: 8px; margin: 26px 2px 6px; font-size: .8rem; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink); font-weight: 750; }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec.now, .sec.upc, .sec.done { font-size: .86rem; }
.sec.now::before, .sec.upc::before, .sec.done::before { flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; font-size: .85rem; letter-spacing: 0; }
.sec.now { color: var(--accent); }
.sec.now::before { content: "\2708\FE0E"; background: var(--live-bg); color: var(--accent); }
.sec.upc { color: var(--warn); }
.sec.upc::before { content: "\27A4\FE0E"; background: var(--warn-bg); color: var(--warn); font-size: .8rem; padding-left: 2px; box-sizing: border-box; }
.sec.done { color: var(--ok); }
.sec.done::before { content: "\2713\FE0E"; background: var(--ok-bg); color: var(--ok); font-weight: 800; }
.sec.final { font-size: 1.05rem; letter-spacing: .05em; margin-top: 30px; }   /* everything landed: the journey is over */
.sec.final::before { width: 30px; height: 30px; font-size: 1.05rem; }
.sec + .card { margin-top: 6px; }
/* the flight that matters now: a bolder frame with a soft glow */
.card.current { border-width: 3px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
/* completed flights read as past: a little faded (still fully legible) */
.grp-done .card { opacity: .78; }
.grp-done .card .pill { opacity: .9; }
.leg header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.leg header > :first-child { justify-self: start; }
.leg header > :last-child { justify-self: end; }
.fno { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.amid { justify-self: center; display: flex; }   /* airline logo in the middle of the card header */
/* airline logo: bigger and frameless on the white card; in dark mode on a soft white pill (logos are made for white) */
.alogo { display: inline-flex; align-items: center; }
.alogo img { display: block; height: 26px; width: auto; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .alogo { background: #fff; border-radius: 999px; padding: 4px 12px; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
  :root:not([data-theme="light"]) .alogo img { height: 22px; }
}
:root[data-theme="dark"] .alogo { background: #fff; border-radius: 999px; padding: 4px 12px; box-shadow: 0 1px 6px rgba(0,0,0,.45); }
:root[data-theme="dark"] .alogo img { height: 22px; }
/* brand stripe along the top edge of the card, in the airline's colour (from /logo/brands.css);
   in dark mode lightened a little, so dark brand colours (Lufthansa navy) stay visible on the dark card */
.card[class*="brand-"] { --stripe: var(--brand, transparent); box-shadow: inset 0 5px 0 var(--stripe); padding-top: 18px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card[class*="brand-"] { --stripe: color-mix(in oklab, var(--brand, transparent), white 38%); }
}
:root[data-theme="dark"] .card[class*="brand-"] { --stripe: color-mix(in oklab, var(--brand, transparent), white 38%); }
.aname { font-weight: 600; font-size: .85rem; color: var(--muted); letter-spacing: 0; }
/* departure | plane | arrival: equal outer columns, so the plane sits at the same spot on every card */
.route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.route .arrow { justify-self: center; }
.ap { display: flex; flex-direction: column; min-width: 0; }
.ap.right { text-align: right; align-items: flex-end; }
.ap b { font-size: 1.9rem; line-height: 1.1; letter-spacing: .02em; }
.ap span { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
/* the little plane between the airports: Lufthansa yellow; in light mode with a thin navy edge so it stays visible on white */
.arrow { color: var(--plane); font-size: 1.3rem; text-shadow: var(--plane-edge); }
progress { width: 100%; height: 8px; margin: 12px 0 6px; border: 0; border-radius: 99px; overflow: hidden; background: var(--line); accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.times div { display: flex; flex-direction: column; }
.times small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .68rem; }
.times strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.eta { margin: 10px 0 2px; font-size: 1.05rem; }
.leg p { margin: 4px 0; }
footer { margin-top: 24px; }
.plane { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 2px solid #0d1b2a; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.plane-icon { display: block; }
.where { font-size: 1rem; margin: 6px 0 2px; }
.where b { font-weight: 650; }
.leaflet-tooltip.ap-tip { font-weight: 650; font-size: .78rem; padding: 2px 6px; }
.leaflet-tooltip.plane-tip { font-weight: 650; font-size: .78rem; padding: 3px 8px; background: #0d1b2a; color: #fff; border-color: #0d1b2a; border-radius: 8px; }
.leaflet-tooltip-top.plane-tip::before { border-top-color: #0d1b2a; }
.leaflet-tooltip-bottom.plane-tip::before { border-bottom-color: #0d1b2a; }
.leaflet-tooltip-left.plane-tip::before { border-left-color: #0d1b2a; }
.leaflet-tooltip-right.plane-tip::before { border-right-color: #0d1b2a; }
.alt-legend { background: rgba(255,255,255,.9); color: #14202e; border-radius: 8px; padding: 5px 8px 4px; width: 128px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.alt-bar { height: 7px; border-radius: 4px; }
.alt-note { font-size: .58rem; color: #4a5565; margin-top: 2px; line-height: 1.2; }
.alt-ticks { display: flex; justify-content: space-between; font-size: .62rem; margin-top: 2px; }
.leaflet-container { font: inherit; }

/* journeys ledger */
textarea { display: block; width: 100%; margin-top: 4px; padding: 12px; font: inherit; font-size: 16px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; resize: vertical; }
select { font: inherit; font-size: 16px; padding: 10px 8px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; text-align: center; }
.stats b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
#rmap { height: 42vh; min-height: 260px; max-height: 420px; border-radius: var(--radius); border: 1px solid var(--line); margin: 12px 0 8px; background: #dfe6ee; }
.legchips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { padding: 6px 12px; min-height: 36px; font-size: .82rem; border-radius: 999px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rctl { display: flex; gap: 10px; align-items: center; }
.rctl button { width: 52px; padding: 0; flex: none; }
.rctl input[type=range] { margin: 0; padding: 0; flex: 1; border: 0; background: none; accent-color: var(--accent); }
.rinfo { margin: 8px 2px 4px; min-height: 3.6em; }
#rplace { font-size: 1.05rem; }
.jleg header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 8px; }
.jleg header > :first-child { justify-self: start; }
.jleg header > :last-child { justify-self: end; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 10px 0; }
.facts div { min-width: 0; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.leg.missed { opacity: .72; }
.leg.missed .route b { text-decoration: line-through; text-decoration-thickness: 2px; }
/* share list: the stored public link, copyable */
.legrow > div:first-child { flex: 1 1 220px; min-width: 0; }
.linkfield { width: 100%; margin: 8px 0 6px; font-size: .78rem; padding: 6px 8px; }
/* back link: a real tap target (44 px tall), not a tiny underlined word */
.back { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px 0 10px; margin-left: -4px; border-radius: 22px;
  font-size: 1.05rem; font-weight: 600; color: var(--accent, #0a62ff); text-decoration: none; background: var(--card); border: 1px solid var(--line); }
.back:active { opacity: .7; }
/* top-bar buttons share the back link's pill shape (44 px tap target) */
button.pillbtn { display: inline-flex; align-items: center; min-height: 44px; width: auto; margin: 0; padding: 0 16px; border-radius: 22px;
  font-size: 1.05rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); color: var(--accent); }
button.signout { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
button.pillbtn:active { opacity: .7; }
/* freshness, flight phase, inbound aircraft, outbound link */
.stale { background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; font-size: .9rem; }
.card.stale { border: 0; }
.phase { font-weight: 600; margin: 6px 0 2px; }
.inbound { border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: .9rem; }
.inbound.ok { background: var(--done-bg); color: var(--done); }
.inbound.late { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
a.ext { color: var(--accent); text-decoration: none; }
/* aircraft page: earlier flights of the plane */
.acft-row { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.acft-row:last-child { border-bottom: 0; }
.acft-row .muted { margin-left: auto; }
a.link { color: var(--accent); text-decoration: none; padding: 8px 4px; font-weight: 500; }
.acft-row.mine { background: var(--done-bg); border-radius: 8px; padding: 8px; }
.inbound.tight { background: var(--warn-bg); color: var(--warn); }
.warn-text { color: var(--warn); }
.tz { font-size: .62em; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: .02em; }
.arrived { display: flex; flex-direction: column; gap: 2px; background: var(--done-bg); color: var(--ink, inherit); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.arrived b { font-size: 1.2rem; }
.arrived > span { font-size: 1rem; color: var(--ink); opacity: .85; }   /* "Thu 19 Nov · 18:12 CET — journey complete.": readable, not small print */
.arrived .closing { display: flex; gap: 10px; align-items: center; margin: 10px 0 0; padding: 10px 12px; border-radius: 12px;
  background: var(--warn-bg); border-left: 4px solid var(--warn); color: var(--ink); font-size: .95rem; line-height: 1.4; }
.arrived .closing::before { content: "⏳"; font-size: 1.25rem; line-height: 1; flex: none; }
.arrived .closing strong { font-weight: 700; }
.arrived .closing .tz { color: inherit; }
.arrived .closing .yt { display: inline; font: inherit; color: var(--warn); }
.arrived .closing .yt[hidden] { display: none; }
.arrived .closing .yt::before { content: " ("; }
.arrived .closing .yt::after { content: ")"; }
details.dbg { margin-top: 4px; }
details.dbg summary { font-size: .78rem; color: var(--muted); cursor: pointer; list-style: none; }
details.dbg summary::before { content: '▸ '; }
details.dbg[open] summary::before { content: '▾ '; }

/* footer: language switch + theme button */
.prefs { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 10px; }
.langs a { color: var(--accent); text-decoration: none; }
.themebtn { min-width: 44px; min-height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1.15rem; padding: 0 12px; }
.plang { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--muted); }
.plang select { width: auto; padding: 6px 8px; }
.card.newlink { border: 2px solid var(--accent); }
.takeoff { display: block; font-weight: 600; color: var(--ink); }
/* zone labels next to normal-size text (aircraft page rows, notes) must stay readable: only the big card times get the small label */
.acft-row .tz, .inbound .tz, p .tz { font-size: .85em; margin-left: 2px; }
/* the current flight keeps its blue frame together with the brand stripe */
.card.current[class*="brand-"] { box-shadow: inset 0 5px 0 var(--stripe), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
/* white lines along map tile edges: Leaflet 1.9 draws tiles with mix-blend-mode: plus-lighter (a Chrome workaround),
   which on iPhone ADDS the anti-aliased edges of neighbouring tiles = bright seams. Normal blending + 1 px overlap:
   each tile simply covers its neighbour's edge — no gap, no brightening. */
#map img.leaflet-tile, #rmap img.leaflet-tile { mix-blend-mode: normal !important; width: 257px !important; height: 257px !important; }
/* the viewer's own time under an airport time (only when it differs) */
.yt { display: block; font-size: .8rem; font-weight: 600; color: var(--accent); }

/* "This link is no longer available": an alarm, not a quiet card */
.card.alert { background: var(--bad-bg); border: 2px solid var(--bad); margin-top: 14vh; padding: 24px 18px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--bad) 15%, transparent); }
.card.alert h1 { color: var(--bad); font-size: 1.3rem; margin: 10px 0 8px; }
.card.alert p { color: var(--ink); opacity: .85; margin: 0; }
.card.alert .alert-icon { width: 52px; height: 52px; margin: 0 auto; border-radius: 50%; background: var(--bad); color: var(--card);
  display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; line-height: 1; }
