:root {
  /* Airport: wayfinding-sign yellow on charcoal, information blue for links; verdict tones
     green / orange / rose (orange, not amber, so it never reads as the sign yellow). */
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #15171c;
  --muted: #5b616e;
  --border: #dcdfe5;
  --accent: #15171c;
  --accent-2: #5b616e;
  --sky: #5b616e;
  --link-line: #e0a800;
  --sign: #ffc20e;
  --sign-text: #15171c;
  --board: #111418;
  --board-border: #2a2f36;
  --board-text: #ffc20e;
  --accent-text: #15171c;
  --btn: linear-gradient(180deg, #ffd23f, #ffbf00);
  --btn-glow: rgb(255 191 0 / 0.35);
  --danger: #be123c;
  --good: #047857;
  --warn: #c2410c;
  --bad: #be123c;
  --track: #e3e6eb;
  --focus: #15171c;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(21 23 28 / 0.06), 0 6px 18px rgb(21 23 28 / 0.07);
  --bg-glow:
    radial-gradient(700px 340px at 0% -140px, rgb(255 194 14 / 0.18), transparent 70%),
    radial-gradient(600px 320px at 100% -100px, rgb(21 23 28 / 0.06), transparent 70%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e11;
    --surface: #15181d;
    --text: #eef0f3;
    --muted: #9aa1ad;
    --border: #262a31;
    --accent: #ffc20e;
    --accent-2: #9aa1ad;
    --sky: #9aa1ad;
    --link-line: #ffc20e;
    --board: #07090b;
    --board-border: #2f343c;
    --danger: #fb7185;
    --good: #34d399;
    --warn: #fb923c;
    --bad: #fb7185;
    --track: #20242b;
    --focus: #ffc20e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 24px rgb(0 0 0 / 0.4);
    --bg-glow:
      radial-gradient(700px 340px at 0% -140px, rgb(255 194 14 / 0.10), transparent 70%),
      radial-gradient(600px 320px at 100% -100px, rgb(255 255 255 / 0.04), transparent 70%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-glow), var(--bg);
  color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.page {
  max-width: 28rem; margin: 0 auto; padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
.view { flex: 0 0 auto; }
.view[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header h1 {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; font-weight: 800; margin: 0; padding: 0.3rem 0.6rem; border-radius: 6px;
  letter-spacing: 0.1em; text-transform: uppercase; background: var(--sign); color: var(--sign-text);
}
header h1::before { content: "✈"; font-size: 0.9rem; letter-spacing: 0; }
.subtitle { font-size: 1.65rem; font-weight: 750; margin: 0.6rem 0 1.2rem; line-height: 1.15; letter-spacing: -0.02em; }

form { display: flex; flex-direction: column; }
.field-label { display: block; font-size: 0.88rem; color: var(--muted); margin: 0 0 0.3rem; padding: 0; }
input[type="text"], input[type="date"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  min-height: 48px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
}
/* Flight number as a split-flap departures board: the real input sits underneath (transparent
   text), the flaps are a mirror of its value. */
.board-field { position: relative; }
input.flight-input {
  font: 700 2rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.9em;
  text-transform: uppercase; padding: 0 1rem; min-height: 78px;
  background: var(--board); border: 2px solid var(--board-border);
  color: transparent; caret-color: transparent;
}
input.flight-input::placeholder { color: transparent; }
input.flight-input:focus, input.flight-input:focus-visible { outline: none; border-color: var(--sign); box-shadow: 0 0 0 4px rgb(255 194 14 / 0.35), var(--shadow); }
.flaps { position: absolute; inset: 2px; display: flex; gap: 5px; align-items: center; padding: 0 10px; pointer-events: none; }
.flap {
  position: relative; flex: 1 1 0; max-width: 2.7rem; height: 56px; border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; perspective: 120px;
  font: 700 2rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--board-text);
  background: linear-gradient(#20252c 0 50%, #191d23 50% 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05), 0 1px 2px rgb(0 0 0 / 0.5);
}
.flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: rgb(0 0 0 / 0.7); }
.flap.ghost { color: color-mix(in srgb, var(--board-text) 28%, transparent); }
.flap .glyph { display: block; transform-origin: 50% 50%; }
.flap.spin .glyph { animation: flap 60ms linear; }
@keyframes flap { 0% { transform: rotateX(0); } 50% { transform: rotateX(80deg); } 100% { transform: rotateX(0); } }
.flap.cursor::before {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 7px; height: 3px; border-radius: 2px;
  background: var(--board-text); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flap.spin .glyph, .flap.cursor::before { animation: none; } }

/* Small board tag for the flight number on the result. */
.board-tag { display: inline-flex; gap: 3px; vertical-align: 0.15em; margin-right: 0.35rem; }
.board-tag .flap { flex: 0 0 auto; width: 1.5rem; max-width: none; height: 2rem; font-size: 1.2rem; border-radius: 4px; }
.board-tag .flap::after { height: 1px; margin-top: 0; }

.hint { min-height: 1.35em; margin: 0.3rem 0 0; font-size: 0.9rem; color: var(--muted); }
.hint:empty { min-height: 0; margin: 0; }
#flight-hint { min-height: 1.35em; margin-top: 0.3rem; }
.hint.error { color: var(--danger); }
.hint.known { color: var(--good); font-weight: 550; }
.hint.known::before { content: "✓ "; }

.link-button {
  align-self: flex-start;
  background: none; border: 0; padding: 0.2rem 0; margin: 0.1rem 0 0.9rem;
  color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--link-line); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.airline-panel {
  margin: -0.4rem 0 1rem; padding: 0.8rem 0.9rem 0.6rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.airline-panel[hidden] { display: none; }
.combo { position: relative; margin-bottom: 0.7rem; }
.options {
  list-style: none; margin: 0.25rem 0 0; padding: 0.25rem; max-height: 13rem; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.options li { padding: 0.55rem 0.6rem; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 0.75rem; }
.options li:hover, .options li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.options .codes { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; gap: 0.6rem; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }

.date-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips {
  display: flex; gap: 4px; padding: 4px;
  background: var(--track); border-radius: var(--radius);
}
.chip {
  flex: 1; min-height: 40px; padding: 0 0.5rem;
  font: inherit; font-size: 0.95rem; font-weight: 550; color: var(--muted);
  background: transparent; border: 0; border-radius: calc(var(--radius) - 4px); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip[aria-pressed="true"] { background: var(--board); color: var(--board-text); box-shadow: var(--shadow); font-weight: 700; }
.date-input { margin-top: 0.5rem; }

.primary-button, .secondary-button {
  font: inherit; font-weight: 600; border-radius: var(--radius); min-height: 48px; cursor: pointer;
}
.primary-button {
  width: 100%; margin-top: 1.2rem; min-height: 54px; border: 0; font-size: 1.08rem; font-weight: 750; color: var(--sign-text);
  background: var(--btn);
  box-shadow: 0 8px 22px var(--btn-glow);
  transition: transform 0.1s, box-shadow 0.15s;
}
.primary-button:active { transform: translateY(1px); }
.primary-button[aria-busy="true"] { opacity: 0.75; cursor: progress; }
.secondary-button { padding: 0 1.1rem; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.status { text-align: center; }

.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.15em; margin-right: 0.5rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.site-footer { margin-top: auto; padding-top: 1.5rem; color: var(--muted); font-size: 0.7rem; }
.site-footer .disclaimer { margin: 0 0 0.6rem; text-align: center; line-height: 1.5; }
.footer-row { text-align: center; opacity: 0.85; }

/* --- Result view (replaces the form) ------------------------------------------------------- */
.result:focus { outline: none; }
.back {
  background: none; border: 0; padding: 0.2rem 0; margin: 0 0 0.4rem; min-height: 44px;
  color: var(--text); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
.back::first-letter { color: var(--link-line); }
.result h2 { font-size: 1.45rem; margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
.result .sub { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }
.verdict { margin: 0; font-size: 1.1rem; font-weight: 650; }
.meter { height: 8px; border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; }
.basis, .explain { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.9rem; }
.links { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.8; }
.links a { color: var(--text); text-decoration-color: var(--link-line); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.result .primary-button { margin-top: 0.9rem; }
.notice .verdict { color: var(--warn); margin-top: 0.4rem; }
.error .verdict { color: var(--danger); margin-top: 0.4rem; }
.leg-form fieldset { border: 0; padding: 0; margin: 0.4rem 0 0; }
.leg-form legend { font-weight: 650; margin-bottom: 0.3rem; }
.choice {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 0.9rem; margin-top: 0.5rem; min-height: 52px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.choice input { accent-color: var(--accent); }
.choice input { width: 1.15rem; height: 1.15rem; margin: 0; }
.choice .route { font-weight: 650; }
.choice .time { color: var(--muted); margin-left: auto; font-size: 0.9rem; }

/* Result as a departures board (dark in both themes, like a real FIDS screen). */
.fids {
  --tone: var(--warn);
  margin-top: 0.2rem; padding: 0.85rem 0.95rem 0.75rem; border-radius: calc(var(--radius) + 2px);
  background: #0d1013; color: #e9ecf1; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
}
@media (prefers-color-scheme: dark) { .fids { background: #101418; box-shadow: inset 0 0 0 1px #1d2229, 0 10px 30px rgb(0 0 0 / 0.4); } }
.fids.tone-good { --tone: #34d399; }
.fids.tone-mid { --tone: #fb923c; }
.fids.tone-bad { --tone: #fb7185; }
.fids-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.fids-title { color: var(--sign); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.fids-date { color: #8b929e; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.fids-airline { margin: 0.45rem 0 0; color: #8b929e; font-size: 0.78rem; }
.fids-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 0.6rem; margin-top: 0.6rem; }
.fids-col { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.fids-label { display: block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #7d8592; }
.fids-cells { display: flex; align-items: center; }
.fids .board-tag { margin: 0; vertical-align: 0; gap: 2px; }
.fids-row .board-tag .flap { width: 1.05rem; height: 1.6rem; font-size: 0.92rem; border-radius: 3px; }
.fids-empty { font: 700 0.85rem ui-monospace, "SF Mono", Menlo, monospace; color: #4c525b; line-height: 1.5rem; }
.next-day { margin-left: 0.15rem; font-size: 0.62rem; font-weight: 700; color: var(--sign); }
.fids-rule { height: 1px; margin: 0.75rem 0 0.6rem; background: #23282f; }
.fids-big { display: flex; align-items: center; gap: 0.75rem; }
.fids-pct { font-size: 3rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: #f4f6f9; }
.fids-verdict {
  padding: 0.3rem 0.7rem; border-radius: 999px; font-weight: 750; font-size: 0.95rem;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 40%, transparent);
}
.fids-caption { display: block; margin-top: 0.35rem; color: #9aa1ad; font-size: 0.85rem; }
.fids .meter { margin-top: 0.55rem; height: 6px; background: #23282f; }
.fids .meter span { background: var(--tone); }
.fids-stats { display: flex; gap: 1rem; margin-top: 0.75rem; }
.fids-stat { flex: 1; min-width: 0; }
.fids-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 0.5rem; margin-top: 0.2rem; font-weight: 750; font-size: 1.1rem; color: #f4f6f9; }
.fids-leaves { font-size: 0.8rem; font-weight: 600; color: #9aa1ad; }
.fids-stat:first-child .fids-value [data-testid="median"] { color: var(--sign); }
.fids .segments { display: flex; gap: 3px; width: 3.4rem; margin: 0; align-self: center; }
.fids .segments i { flex: 1; height: 6px; border-radius: 999px; box-shadow: inset 0 0 0 1px #3a4049; }
.fids .conf-low .fids-value { color: #fb923c; }
.fids .conf-medium .fids-value { color: var(--sign); }
.fids .conf-high .fids-value { color: #34d399; }
.fids .conf-low .segments i.on { background: #fb923c; box-shadow: none; }
.fids .conf-medium .segments i.on { background: var(--sign); box-shadow: none; }
.fids .conf-high .segments i.on { background: #34d399; box-shadow: none; }
.fids-foot { margin: 0.65rem 0 0; font-size: 0.7rem; color: #7d8592; }
