/* SWIM flight status — black on white. */
:root {
  color-scheme: light;

  --bg: #ffffff;
  --panel: #ffffff;
  /* Nested surfaces (summary callouts, constraint cards, code blocks) need to
     read as recessed against a white page without introducing a second
     background colour, so they sit a hair off-white. */
  --panel-2: #f5f7f9;
  --line: #d8dee5;

  --ink: #000000;
  --ink-dim: #4a5560;
  --ink-faint: #77828d;

  /* Status colours are darkened from their dark-theme values: amber and green
     that read well on a near-black page fail contrast on white. */
  --accent: #0b62d6;
  --major: #c0271f;
  --warn: #9a5b00;
  --ok: #17753a;
  --info: #6b7885;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 14px; line-height: 1.5; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .2px; }
.brand .mark { color: var(--accent); font-size: 18px; }
.brand em { font-style: normal; color: var(--ink-dim); font-weight: 450; }

.search { display: flex; gap: 8px; flex: 1 1 340px; min-width: 240px; }
.search input {
  flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 14px; font-family: var(--sans);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search button {
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; font-size: 14px;
}
.search button:hover { filter: brightness(1.1); }

.feeds { display: flex; gap: 6px; align-items: center; }
.feed-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11px; font-family: var(--mono); color: var(--ink-dim);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.dot.up { background: var(--ok); }
.dot.down { background: var(--major); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button {
  padding: 6px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-dim); cursor: pointer; font-size: 13px;
}
.tabs button.active { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.tabs button:hover:not(.active) { color: var(--ink); }

.empty { padding: 48px 16px; text-align: center; color: var(--ink-faint); }
.statusbar {
  padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel);
  color: var(--ink-faint); font-size: 11px; font-family: var(--mono);
  display: flex; gap: 16px; flex-wrap: wrap;
}

/* ---------- flight rows ---------- */
.rows { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: grid; grid-template-columns: 108px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; cursor: pointer; text-align: left; width: 100%;
  color: inherit; font: inherit;
}
.row:hover { border-color: var(--accent); }
.row .acid { font-family: var(--mono); font-weight: 650; font-size: 14px; }
.row .pair { color: var(--ink-dim); font-size: 12px; font-family: var(--mono); }
.row .when { color: var(--ink-faint); font-size: 11px; margin-top: 1px; }
.ident-text { min-width: 0; }
.row .why { color: var(--ink-dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .delay { font-family: var(--mono); font-weight: 650; text-align: right; white-space: nowrap; }
.delay.major { color: var(--major); }
.delay.warn { color: var(--warn); }
.delay.ok { color: var(--ok); }

/* ---------- detail ---------- */
.detail { display: flex; flex-direction: column; gap: 14px; }
.back {
  align-self: flex-start; background: none; border: none; color: var(--accent);
  cursor: pointer; padding: 0; font-size: 13px; font-family: var(--sans);
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .7px; color: var(--ink-faint); font-weight: 600; }

.hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hero .ident { display: flex; flex-direction: column; gap: 3px; }
.hero .callsign { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.hero .route { font-family: var(--mono); font-size: 15px; color: var(--ink-dim); }
.hero .meta { color: var(--ink-faint); font-size: 12px; }
.phase {
  padding: 4px 12px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 12px; color: var(--ink-dim); white-space: nowrap;
}
.summary { margin-top: 12px; padding: 12px 14px; border-radius: 9px;
  background: var(--panel-2); border-left: 3px solid var(--accent); font-size: 14.5px; }
.summary.major { border-left-color: var(--major); }
.summary.warn { border-left-color: var(--warn); }

/* time ladder */
.ladder { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 620px) { .ladder { grid-template-columns: 1fr; } }
.ladder h3 { margin: 0 0 8px; font-size: 12px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.times { display: flex; flex-direction: column; gap: 3px; }
.time-row { display: flex; justify-content: space-between; gap: 12px;
  padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.time-row:last-child { border-bottom: none; }
.time-row .label { color: var(--ink-dim); text-transform: capitalize; }
.time-row .val { font-family: var(--mono); }
.time-row.best .val { font-weight: 700; color: var(--accent); }

/* constraints */
.constraints { display: flex; flex-direction: column; gap: 8px; }
.constraint { padding: 11px 13px; border-radius: 8px; background: var(--panel-2);
  border-left: 3px solid var(--info); }
.constraint.major { border-left-color: var(--major); }
.constraint.warn { border-left-color: var(--warn); }
.constraint .title { font-weight: 600; margin-bottom: 2px; }
.constraint .detail { color: var(--ink-dim); font-size: 13px; }
.constraint .src { color: var(--ink-faint); font-size: 11px; font-family: var(--mono); margin-top: 4px; }
.constraint .adv-text {
  margin-top: 8px; padding: 10px; background: #eef1f4; border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap;
  max-height: 260px; overflow: auto; color: var(--ink-dim);
}

/* facts grid */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fact .k { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .5px; }
.fact .v { font-family: var(--mono); font-size: 14px; margin-top: 2px; }

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl { display: grid; grid-template-columns: 62px 64px 1fr; gap: 10px;
  padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.tl:last-child { border-bottom: none; }
.tl .t { font-family: var(--mono); color: var(--ink-faint); font-size: 12px; }
.tl .f { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
  align-self: center; text-align: center; background: var(--panel-2);
  border-radius: 4px; padding: 1px 4px; }

/* route string */
.routestr { font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim);
  word-break: break-all; line-height: 1.7; }

/* ---------- map ---------- */
.mapbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  margin-bottom: 10px;
}
.mfilter { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 160px; }
.mfilter label {
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--ink-faint);
}
.mfilter-box {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  min-height: 36px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel);
}
.mfilter-box:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.mfilter-box input {
  flex: 1 1 64px; min-width: 64px; border: 0; outline: 0; padding: 4px 2px;
  background: transparent; color: var(--ink); font: inherit; font-size: 13px;
  font-family: var(--mono);
}
.mchip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-family: var(--mono);
  font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.4;
}
.mchip span { color: var(--ink-faint); font-weight: 500; font-size: 13px; line-height: 1; }
.mchip:hover { border-color: var(--accent); color: var(--accent); }
.mchip:hover span { color: var(--accent); }
.mfilter-clear {
  flex: 0 0 auto; align-self: end; height: 36px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-dim); font-size: 13px; cursor: pointer;
}
.mfilter-clear:hover { color: var(--ink); border-color: var(--accent); }
.mfilter-clear[hidden] { display: none; }

.mapwrap { background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px; overflow: hidden; position: relative; }
svg.map {
  display: block; width: 100%; height: auto; cursor: grab;
  /* The map handles its own gestures; without this the browser scrolls the
     page instead of panning the map on touch. */
  touch-action: none;
}
svg.map.grabbing { cursor: grabbing; }

/* Strokes are in user units, so they thin out as the viewBox shrinks. */
svg.map .land, svg.map .grid, svg.map .flown, svg.map .planned {
  vector-effect: non-scaling-stroke;
}

.mapctl {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  display: flex; flex-direction: column; gap: 4px;
}
.mapctl button {
  width: 28px; height: 28px; padding: 0; line-height: 1;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink-dim);
  font-size: 15px; cursor: pointer;
}
.mapctl button:hover { color: var(--ink); border-color: var(--accent); }

.maptip {
  position: absolute; z-index: 3; pointer-events: none;
  min-width: 120px; padding: 8px 10px;
  background: var(--ink); color: #fff; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  font-size: 12px; line-height: 1.35; white-space: nowrap;
}
.maptip .acid { font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: .2px; }
.maptip .pair { font-family: var(--mono); color: rgba(255, 255, 255, .78); margin-top: 2px; }
.maptip .alt { font-family: var(--mono); color: rgba(255, 255, 255, .92); margin-top: 4px; font-weight: 600; }
.maptip .alt.dim { color: rgba(255, 255, 255, .45); font-weight: 450; }

svg.map .land { fill: #fafbfc; stroke: #b9c2cc; stroke-width: .8; }
svg.map .grid { stroke: #e3e8ed; stroke-width: .35; }
svg.map .trk { fill: var(--accent); opacity: .75; cursor: pointer; }
svg.map .trk:hover { fill: var(--major); opacity: 1; }
svg.map .trk path { stroke: #fff; stroke-width: .4; vector-effect: non-scaling-stroke; }
svg.map .trk.nodir { opacity: .4; }
svg.map .planned { stroke: var(--info); stroke-width: 1.4; fill: none; stroke-dasharray: 5 4; opacity: .85; }
svg.map .flown { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin-top: 10px; font-size: 12px; color: var(--ink-dim); }
.legend i.sw { display: inline-block; width: 16px; height: 0; vertical-align: middle;
  margin-right: 6px; border-top-width: 2px; border-top-style: solid; }
.legend i.sw.planned { border-top-color: var(--info); border-top-style: dashed; }
.legend i.sw.flown { border-top-color: var(--accent); }
.legend .note { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; margin-left: auto; }
svg.map .apt { fill: var(--ok); }
svg.map .me { fill: var(--warn); }
svg.map .me path { stroke: var(--bg); stroke-width: .6; vector-effect: non-scaling-stroke; }
svg.map .me circle { stroke: var(--bg); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
svg.map .me.nodir { opacity: .7; }
svg.map text { fill: var(--ink-faint); font-family: var(--mono); font-size: 7px; }

/* ---------- advisories / restrictions ---------- */
.adv { background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 13px 15px; margin-bottom: 8px; }
.adv .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.adv .kind { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px;
  background: var(--panel-2); color: var(--warn); font-family: var(--mono); }
.adv .kind.GROUND_STOP { color: var(--major); }
.adv .kind.GDP { color: var(--warn); }
.adv .title { font-weight: 600; font-size: 13.5px; }
.adv .when { color: var(--ink-faint); font-size: 11.5px; font-family: var(--mono); margin-left: auto; }
.adv pre { margin: 10px 0 0; padding: 10px; background: #f5f7f9;
  border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap;
  color: var(--ink-dim); max-height: 220px; overflow: auto; }
.adv .stats { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--ink-faint); padding: 6px 10px;
  border-bottom: 1px solid var(--line); font-weight: 600; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
table.grid tr:last-child td { border-bottom: none; }
.wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }

/* airports table */
table.grid td.strong { font-weight: 700; font-size: 13.5px; }
tr.apt-row { cursor: pointer; }
tr.apt-row:hover td { background: var(--panel-2); }
table.grid td.major { color: var(--major); }
table.grid td.warn { color: var(--warn); }
table.grid td.ok { color: var(--ok); }
.pill { font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--panel-2); color: var(--ink-dim); font-family: var(--mono); }

/* ---------- API docs ---------- */
.docs { display: flex; flex-direction: column; gap: 10px; }
.docs .card p { margin: 0 0 8px; color: var(--ink-dim); font-size: 13.5px; }
.docs .card p:last-child { margin-bottom: 0; }
.docs-note { color: var(--ink-faint) !important; font-size: 12.5px !important; }
.docs-path { margin-bottom: 8px; font-size: 14px; }
.docs-path code {
  font-family: var(--mono); font-weight: 650; font-size: 13.5px;
  color: var(--ink);
}
.docs-params { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.docs-schema {
  margin: 8px 0 0; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap;
  color: var(--ink-dim); overflow: auto;
}
.docs-try { display: flex; flex-wrap: wrap; gap: 8px; }
.docs-try a {
  display: inline-block; padding: 6px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--accent); text-decoration: none; font-size: 12.5px;
}
.docs-try a:hover { border-color: var(--accent); }
.docs-try code { font-family: var(--mono); font-size: 12px; }
.docs code { font-family: var(--mono); font-size: 12.5px; }

/* carrier tails (seats.aero) */
.tail { display: block; flex: none; object-fit: contain; }
.tail.sm { width: 26px; height: 26px; }
.tail.lg { width: 44px; height: 44px; }
.ident-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.callsign-row { display: flex; align-items: center; gap: 12px; }
.row { grid-template-columns: 168px 1fr auto; }
@media (max-width: 560px) {
  .tail.sm { width: 20px; height: 20px; }
  .row { grid-template-columns: 132px 1fr auto; }
}
