:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1b2733;
  --muted: #5d6b79;
  --line: #dde3e9;
  --accent: #1f6feb;
  --ok: #1a7f46;
  --warn: #9a6700;
  --bad: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151b;
    --surface: #18212a;
    --text: #e8eef4;
    --muted: #9aa8b5;
    --line: #2a3640;
    --accent: #5b9dff;
    --ok: #4cc382;
    --warn: #e3b341;
    --bad: #ff7b72;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top { flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 1.15rem; }

.pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid currentColor;
}
.pill-idle { color: var(--muted); }
.pill-live { color: var(--ok); }
.pill-wait { color: var(--warn); }
.pill-bad { color: var(--bad); }

.banner {
  margin: 0;
  padding: 10px 16px;
  background: var(--bad);
  color: #fff;
  font-size: .9rem;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  padding: 16px;
}
.map {
  min-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.card {
  overflow-y: auto;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.headline { margin: 0 0 4px; font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.subline { margin: 0 0 16px; color: var(--muted); min-height: 1.4em; }
.card h2 { margin: 22px 0 8px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.muted { margin: 0 0 6px; color: var(--muted); font-size: .9rem; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin: 0 0 14px;
}
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; }

.follow { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); }

.row { display: flex; gap: 8px; }
input[type="text"], input[type="password"] {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
button {
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button.link {
  padding: 4px 0;
  color: var(--accent);
  background: none;
  font-weight: 500;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.upcoming { margin: 0; padding: 0; list-style: none; }
.upcoming li { padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.upcoming li:first-child { border-top: 0; }
.upcoming small { display: block; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
dialog form { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
dialog p { margin: 0; }

.top-right { display: flex; align-items: center; gap: 10px; }
button.ghost {
  padding: 6px 12px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  font-weight: 600;
}
dialog.wide { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; }
dialog.wide h2 { margin: 0 0 8px; }
fieldset { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 6px; font-weight: 700; }
.hint { margin: 4px 0 8px; font-size: .88rem; color: var(--muted); }
.hint.strong { color: var(--text); font-weight: 600; }
.field { display: block; font-size: .95rem; margin-top: 8px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
input[type="number"], input[type="url"] {
  padding: 9px 10px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
input[type="url"] { width: 100%; }
input[type="datetime-local"] {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
#friend-dialog .field { margin: 12px 0 0; }
#friend-dialog .field > input[type="text"] { display: block; width: 100%; margin-top: 4px; }
#friend-dialog .inline { margin-top: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.plane-ring {
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  border: 3px solid #d92d20; border-radius: 50%;
  background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 2px #fff, 0 1px 5px rgba(0, 0, 0, .35);
}
.swatch {
  display: inline-block; width: .8em; height: .8em; margin-right: .5em; vertical-align: -.05em;
  border-radius: 50%; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 0 0 2px rgba(0, 0, 0, .25);
}
.board .f small .swatch { margin-right: .6em; box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(255, 255, 255, .6); }
.friend-tip { background: #000; color: #ffd400; border: 1px solid #ffd400; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.friend-tip::before { display: none; }
.upcoming li .rm { float: right; margin-left: 8px; padding: 0 6px; }
input[type="number"] { width: 80px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 12px; }
.steps .row { margin-top: 6px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.error { margin: 0 0 10px; color: var(--bad); font-weight: 600; }

.views, .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.views button, .seg button {
  padding: 6px 16px; font: inherit; font-weight: 600; font-size: .9rem;
  color: var(--muted); background: transparent; border: 0; border-radius: 0;
}
.views button[aria-selected="true"], .seg button[aria-selected="true"] { color: #fff; background: var(--accent); }

/* ---- Departures / arrivals board: old-school airport, black and yellow ---- */
.board-wrap {
  --y: #ffd400;
  --y-dim: #a88f00;
  --y-line: #3a3200;
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px;
  margin: 16px; padding: 14px 16px 12px; overflow: hidden;
  background: #000; color: var(--y);
  border: 3px solid #2a2a2a; border-radius: 8px;
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}
.board-wrap[hidden] { display: none; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.board-head .seg { border: 2px solid var(--y); border-radius: 4px; }
.board-head .seg button {
  padding: 8px 18px; font-size: 1rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--y); background: #000;
}
.board-head .seg button[aria-selected="true"] { color: #000; background: var(--y); }
.bd-clock { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: .08em; color: var(--y); font-variant-numeric: tabular-nums; }

.board-scroll { flex: 1; min-height: 0; overflow: auto; background: #000; border-top: 2px solid var(--y); border-bottom: 2px solid var(--y); }
.board { width: 100%; border-collapse: separate; border-spacing: 0 5px; color: var(--y); text-transform: uppercase; }
.board th {
  position: sticky; top: 0; z-index: 1; padding: 10px 8px 6px; text-align: left;
  font-size: .78rem; font-weight: 700; letter-spacing: .2em; color: var(--y-dim);
  background: #000; border-bottom: 1px solid var(--y-line);
}
.board td { padding: 3px 6px; vertical-align: middle; font-weight: 700; }
.board .bd-day td { padding: 16px 8px 4px; font-size: .8rem; letter-spacing: .22em; color: var(--y-dim); border-bottom: 1px dashed var(--y-line); }

/* split-flap characters */
.flap { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }
.flap .ch {
  display: inline-block; min-width: .8em; padding: .14em .1em; text-align: center;
  font-size: 1.4rem; line-height: 1.1; color: var(--y);
  background: linear-gradient(#1d1d1d 0 49%, #000 49% 52%, #121212 52% 100%);
  border-radius: 3px; box-shadow: inset 0 0 0 1px #2e2e2e;
}
.flap .ch.sp { min-width: .4em; background: none; box-shadow: none; }

.board .t small, .board .s small { display: block; margin-top: 3px; font-size: .78rem; font-weight: 400; letter-spacing: .1em; color: var(--y-dim); }
.board .s small.delay { margin-top: 4px; font-size: .8rem; font-weight: 700; letter-spacing: .12em; }
.board .s small.delay.late { color: #ff8a80; }
.board .s small.delay.early { color: #4cc382; }
.board .s small.delay.ontime { color: var(--y); }
.board tr.followed td { background: #191400; }
.board tr.followed td:first-child { box-shadow: inset 4px 0 0 var(--y); }
.board .s.live .ch, .board .s.bad .ch {
  color: #000; background: linear-gradient(var(--y) 0 49%, #8a7400 49% 52%, var(--y) 52% 100%); box-shadow: none;
}
.board .s.past .ch { color: var(--y-dim); }

.board-btn {
  padding: 7px 14px; font: inherit; font-size: .85rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--y); background: #000; border: 2px solid var(--y); border-radius: 4px; cursor: pointer;
}
.board-btn:hover { background: var(--y); color: #000; }
.board .f small { display: block; margin-top: 3px; font-size: .78rem; font-weight: 400; letter-spacing: .1em; color: var(--y-dim); }
.board tr.friend td:first-child { box-shadow: inset 4px 0 0 var(--y-dim); }
.board .p small.unconfirmed { display: block; margin-top: 3px; font-size: .68rem; font-weight: 400; letter-spacing: .08em; color: var(--y-dim); }
.board .x { width: 1%; text-align: right; white-space: nowrap; }
.board .x button + button { margin-left: 4px; }
.board .x button {
  padding: 2px 9px; font-size: 1rem; line-height: 1.2; color: var(--y-dim); background: #000;
  border: 1px solid var(--y-line); border-radius: 3px; cursor: pointer;
}
.board .x button:hover { color: #000; background: var(--y); border-color: var(--y); }
.board-head { flex-wrap: wrap; }
.bd-empty { margin: 24px 0; text-align: center; color: var(--y-dim); letter-spacing: .1em; text-transform: uppercase; }
.bd-note { margin: 0; font-size: .75rem; letter-spacing: .06em; color: var(--y-dim); }

@media (max-width: 640px) {
  .board-wrap { margin: 8px; padding: 10px; }
  .flap .ch { font-size: 1rem; }
  .board td { padding: 3px 2px; }
  .bd-clock { font-size: 1.4rem; }
  .board-head .seg button { padding: 6px 10px; font-size: .8rem; letter-spacing: .1em; }
}

body[data-view="board"] .layout,
body[data-view="forecast"] .layout { display: none; }

/* ---- Forecast view: what to wear for the next two days ---- */
.forecast { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.forecast[hidden] { display: none; }
.fc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.fc-head h2 { margin: 0; font-size: 1.35rem; }
.fc-head p { margin: 2px 0 0; }
.fc-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.fc-day { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.fc-day-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.fc-day-head h3 { margin: 0; font-size: 1.3rem; }
.fc-big { margin-left: auto; font-size: 1.15rem; font-weight: 700; }
.fc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin: 12px 0; }
.fc-stat { padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.fc-stat span { display: block; font-size: .72rem; color: var(--muted); }
.fc-wear h4 { margin: 14px 0 4px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fc-period { padding: 10px 0; border-top: 1px solid var(--line); }
.fc-period-name { font-weight: 700; }
.fc-facts { margin: 2px 0 4px; font-size: .85rem; color: var(--muted); }
.fc-period ul { margin: 4px 0 0; padding-left: 20px; }
.fc-period li { margin: 2px 0; }
.fc-day details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.fc-day summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.fc-hours { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: .85rem; }
.fc-hours th { padding: 4px 6px; text-align: left; font-size: .72rem; font-weight: 600; color: var(--muted); }
.fc-hours td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.fc-note { margin: 16px 0 0; font-size: .8rem; color: var(--muted); }
@media (max-width: 640px) {
  .fc-days { grid-template-columns: 1fr; }
  .views button { padding: 6px 10px; font-size: .85rem; }
}

.plane { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.plane svg { display: block; overflow: visible; }
.home-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--ok); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }

@media (max-width: 800px) {
  body { height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; }
  .map { height: 52vh; min-height: 280px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.wx-popup pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.4 ui-monospace, Consolas, monospace; }
.wx-popup strong { display: block; }

/* ---- traffic light: is the app up to date on its data? ---- */
.health-wrap { position: relative; }
.health {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(46ch, 62vw); padding: 5px 12px;
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.health #health-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-dot {
  flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--hc, #9ca3af);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hc, #9ca3af) 28%, transparent);
}
.health-green { --hc: #16a34a; }
.health-orange { --hc: #f59e0b; }
.health-red { --hc: #dc2626; }
.health-red .health-dot { animation: health-pulse 1.4s ease-in-out infinite; }
@keyframes health-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--hc) 10%, transparent); } }
@media (prefers-reduced-motion: reduce) { .health-red .health-dot { animation: none; } }
.health-panel {
  position: fixed; z-index: 1300; /* placed under the light by the page, always fully on screen */
  width: min(400px, calc(100vw - 24px)); padding: 12px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.health-panel[hidden] { display: none; }
.health-title { margin: 0 0 8px; font-weight: 700; }
.health-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; font-size: .88rem; }
.health-list li { display: flex; align-items: flex-start; gap: 9px; }
.health-list .health-dot { width: 10px; height: 10px; margin-top: .4em; box-shadow: none; animation: none; }
#set-airlabs { display: block; width: 100%; margin: 4px 0; padding: 9px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }

.check { display: flex; align-items: center; gap: .5rem; margin: .6rem 0; }
.check input { width: auto; margin: 0; }
