/* Dark grey is the default; the light theme is beige. Every colour the canvas
   uses is a token here too, so the scope repaints with the page. */
:root {
  --bg: #141517;
  --panel: #1b1c1f;
  --line: #2b2d31;
  --hair: #232529;
  --scope-fill: rgba(255, 255, 255, 0.022);
  --ink: #d6d8da;
  --dim: #85888d;
  --faint: #55585d;
  --accent: #58d9a3;
  --arrival: #5cc8ff;
  --departure: #ffb257;
  --over: #8b9095;
  --unknown: #5e6368;
  --row-hover: #212327;
  --row-selected: #2b2f34;
  --selected-ink: #ffffff;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg: #efe7d8;
  --panel: #e7ddca;
  --line: #d2c5ab;
  --hair: #dcd1ba;
  --scope-fill: rgba(60, 46, 26, 0.03);
  --ink: #3a3225;
  --dim: #7a6c56;
  --faint: #a2937b;
  --accent: #2f7a63;
  --arrival: #1f6f9c;
  --departure: #b0632a;
  --over: #8a7c66;
  --unknown: #a2937b;
  --row-hover: #ded2ba;
  --row-selected: #d3c4a6;
  --selected-ink: #17130c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--mono);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
/* Only the title and the selected field live here; everything else is behind
   the settings button. */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

.home {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--ink);
  letter-spacing: 0.06em;
}
.home b { color: var(--accent); font-weight: 600; }

.gear {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 9px;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
}
.gear:hover { color: var(--accent); }
.gear[aria-expanded="true"] { color: var(--accent); border-color: var(--line); background: var(--bg); }
.gear svg { transition: transform 0.25s ease; }
.gear[aria-expanded="true"] svg { transform: rotate(60deg); }

/* ---------- settings panel ---------- */
.panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 12px;
  z-index: 20;
  width: 292px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.panel[hidden] { display: none; }
.panel hr { border: none; border-top: 1px solid var(--line); margin: 9px 2px; }

.panel .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 2px;
  cursor: pointer;
}
.panel .row > span {
  flex: 1;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--dim);
}
.panel .version {
  padding: 2px 2px 0;
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: var(--faint);
  word-break: break-all;
}
.panel .version b { color: var(--dim); font-weight: 600; }

.panel .row input:not([type="checkbox"]),
.panel .row select { width: 146px; }
.panel .switchrow input { position: absolute; opacity: 0; pointer-events: none; }

input, select {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 7px;
  font: inherit;
  outline: none;
}
#airport { text-transform: uppercase; }
input:focus, select:focus { border-color: var(--accent); }

.switch {
  position: relative;
  flex: none;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform 0.18s ease, background 0.18s ease;
}
.switchrow input:checked ~ .switch { border-color: var(--accent); }
.switchrow input:checked ~ .switch::after { transform: translateX(16px); background: var(--accent); }
.switchrow input:focus-visible ~ .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  color: var(--accent);
}
.pill.demo { color: var(--departure); border-color: var(--departure); }

.banner {
  padding: 7px 16px;
  background: var(--hair);
  border-bottom: 1px solid var(--line);
  color: var(--departure);
  font-size: 12px;
}

/* ---------- layout ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(320px, 1fr) minmax(150px, 38vh);
  min-height: 0;
}

.scope { position: relative; min-height: 0; background: var(--bg); }
#radar { display: block; width: 100%; height: 100%; cursor: crosshair; }

.legend {
  position: absolute;
  left: 14px; bottom: 12px;
  display: flex;
  gap: 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  pointer-events: none;
}
.scope-status {
  position: absolute;
  right: 14px; bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}

.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; vertical-align: middle; }
.k.arrival { background: var(--arrival); }
.k.departure { background: var(--departure); }
.k.overflight { background: var(--over); }
.k.unknown { background: var(--unknown); }

/* ---------- table ---------- */
.list {
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
}

table { width: 100%; border-collapse: collapse; }
table.no-metrics [data-col="metrics"] { display: none; }

/* Width hints so the columns hold still as routes resolve in. */
th:nth-child(1) { width: 8%; }
th:nth-child(2) { width: 17%; }
th:nth-child(3) { width: 17%; }
th:nth-child(4) { width: 10%; }
th[data-col="metrics"] { width: 7%; }

thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
thead th:hover { color: var(--accent); }
thead th.sorted { color: var(--accent); }
thead th.sorted::after { content: " ▾"; }
thead th.sorted.asc::after { content: " ▴"; }

tbody td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.selected { background: var(--row-selected); }
tbody tr.arrival .cs { color: var(--arrival); }
tbody tr.departure .cs { color: var(--departure); }
.cs { font-weight: 600; }
.route { color: var(--accent); letter-spacing: 0.06em; }
.muted { color: var(--unknown); }

.empty { padding: 24px; text-align: center; color: var(--dim); }

@media (max-width: 720px) {
  main { grid-template-rows: minmax(260px, 1fr) minmax(160px, 45vh); }
  .scope-status { display: none; }
  .panel { right: 8px; left: 8px; width: auto; }
  /* Operator and the full airport names are the first things to go. */
  [data-col="operator"], [data-col="from"], [data-col="to"] { display: none; }
}
