/* Flights — "control tower at night" (dark) + daylight theme. No external fonts. */

:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-2: #172238;
  --line: #24314a;
  --text: #e6edf7;
  --muted: #8a99b3;
  --accent: #f5b041;        /* aircraft amber */
  --accent-ink: #1a1203;
  --focus: #4cc9f0;         /* selection / home cyan */
  --danger: #ef6f6c;
  --ok: #5bd18b;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --radius: 12px;
  --gap: 12px;
  --list-w: 320px;
  --detail-w: 360px;
  --top-h: 52px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef2f8; --panel: #ffffff; --panel-2: #f3f6fb; --line: #d8e0ec;
    --text: #172033; --muted: #5b6b85; --accent: #c77700; --accent-ink: #fff;
    --focus: #0077b6; --shadow: 0 8px 24px rgba(20, 40, 80, .15); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef2f8; --panel: #ffffff; --panel-2: #f3f6fb; --line: #d8e0ec;
  --text: #172033; --muted: #5b6b85; --accent: #c77700; --accent-ink: #fff;
  --focus: #0077b6; --shadow: 0 8px 24px rgba(20, 40, 80, .15); color-scheme: light;
}

/* Large external displays: scale everything up a step. */
@media (min-width: 2000px) { :root { font-size: 18px; --list-w: 380px; --detail-w: 440px; --top-h: 60px; } }
@media (min-width: 3000px) { :root { font-size: 22px; --list-w: 460px; --detail-w: 540px; --top-h: 72px; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--focus); }
h1, h2 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.fine { font-size: .8rem; color: var(--muted); margin-top: 1rem; }
.pad { padding: 0 var(--gap); }
.msg { min-height: 1.4em; margin: .6rem 0 0; color: var(--danger); }
.msg.ok { color: var(--ok); }

.boot { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .9rem; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.icon { width: 40px; padding: 0; font-size: 1.15rem; }
.btn.wide { width: 100%; margin-top: 1rem; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type="text"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .7rem; width: 100%; min-height: 40px;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
label { display: block; margin-top: .6rem; font-size: .9rem; color: var(--muted); }
label.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0 1rem 0 0; color: var(--text); }
label > input, label > select { margin-top: .25rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-top: .6rem; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 180px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: .02em; }
.brand.small { font-size: 1.05rem; }
.brand-mark {
  width: 1.4em; height: 1.4em; display: inline-block; background: var(--accent);
  -webkit-mask: url(/plane.svg) center / contain no-repeat; mask: url(/plane.svg) center / contain no-repeat;
}

/* ---------- sign-in / invite cards ---------- */
.card-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow); }

/* ---------- app layout ---------- */
.app {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: var(--list-w) 1fr auto;
  grid-template-rows: var(--top-h) 1fr auto;
  grid-template-areas: "top top top" "list map detail" "attrib attrib attrib";
}
.topbar { grid-area: top; display: flex; align-items: center; gap: var(--gap); padding: 0 var(--gap);
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 3; }
.status { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem;
  font-variant-numeric: tabular-nums; margin-right: auto; white-space: nowrap; min-width: 0; overflow: hidden; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 0 rgba(91, 209, 139, .6); animation: pulse 2s infinite; }
.dot.down { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(91, 209, 139, .55); } 70% { box-shadow: 0 0 0 8px rgba(91, 209, 139, 0); } 100% { box-shadow: 0 0 0 0 rgba(91, 209, 139, 0); } }
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } }
.actions { display: flex; gap: .4rem; }
.phone-only { display: none; }

.map { grid-area: map; position: relative; min-height: 0; }
.panel { background: var(--panel); border-color: var(--line); border-style: solid; overflow: auto; min-height: 0; }
.list-panel { grid-area: list; border-width: 0 1px 0 0; display: flex; flex-direction: column; }
.detail-panel { grid-area: detail; width: var(--detail-w); border-width: 0 0 0 1px; position: relative; padding: var(--gap); }
.panel-head { position: sticky; top: 0; background: var(--panel); padding: var(--gap); border-bottom: 1px solid var(--line); z-index: 1; }
.panel-head h2 { display: flex; justify-content: space-between; }
.attrib { grid-area: attrib; font-size: .72rem; color: var(--muted); padding: 2px var(--gap);
  background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attrib a { color: var(--muted); }

/* aircraft list */
.ac-list { list-style: none; margin: 0; padding: 4px 0; }
.ac-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 .6rem; padding: .5rem var(--gap);
  border-bottom: 1px solid var(--line); cursor: pointer; }
.ac-list li:hover, .ac-list li[aria-selected="true"] { background: var(--panel-2); }
.ac-list li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--focus); }
.ac-cs { font-weight: 650; letter-spacing: .02em; }
.ac-alt { text-align: right; font-variant-numeric: tabular-nums; }
.ac-sub { color: var(--muted); font-size: .82rem; grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: .72rem; padding: 0 .4rem; border-radius: 6px; margin-left: .3rem;
  border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; }
.chip.alert { color: var(--danger); border-color: var(--danger); }
.filter { margin-top: .4rem; }

/* detail panel */
.close { position: absolute; top: 8px; right: 8px; }
.det-title { font-size: 1.5rem; font-weight: 700; margin: 0 2.5rem .1rem 0; }
.det-route { font-size: 1.1rem; margin: .4rem 0 .8rem; }
.det-route b { color: var(--accent); }
.det-route.unsure { color: var(--muted); }
.det-route.unsure b { color: var(--muted); text-decoration: line-through; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: .5rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.fact { background: var(--panel-2); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; color: var(--muted); }
.spark { width: 100%; height: 70px; display: block; margin: .6rem 0; }

/* dialogs */
.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow); }
.dialog.wide { width: min(860px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-body { padding: 20px; max-height: calc(100vh - 40px); overflow: auto; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 10px 14px 14px; }
legend { padding: 0 .4rem; color: var(--muted); font-size: .85rem; }
.plain { list-style: none; padding: 0; margin: .2rem 0 .6rem; }
.secret { margin-top: .6rem; padding: .6rem; border-radius: 10px; background: var(--bg); border: 1px dashed var(--accent);
  word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.tbl { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.tbl th, .tbl td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 500; }

/* map overlays: follow the theme */
.maplibregl-ctrl-group { background: var(--panel) !important; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib.maplibregl-compact { background: var(--panel) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-scale { background: var(--panel) !important; color: var(--text) !important; border-color: var(--muted) !important; }
:root:not([data-theme="light"]) .maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-group button { filter: none; }
:root:not([data-theme="light"]) .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
.pick-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2;
  background: var(--accent); color: var(--accent-ink); padding: .4rem .8rem; border-radius: 10px; font-weight: 600; }

/* ---------- phone: map full screen, list/detail as a bottom sheet ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top-h) 1fr auto;
    grid-template-areas: "top" "map" "attrib"; }
  .phone-only { display: inline-block; }
  .wide-only { display: none; }
  .brand.small { font-size: 0; gap: 0; }           /* mark only: the topbar needs the room */
  .brand.small .brand-mark { font-size: 1rem; }
  .list-panel, .detail-panel {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 55vh; z-index: 4;
    border-width: 1px 0 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .list-panel:not(.open) { display: none; }
  .detail-panel { z-index: 5; }
  .attrib { font-size: .65rem; }
}
