:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);
  --route-w2: #2a78d6;
  --route-w8: #eb6834;
  --route-other: #1baf7a;
  --route-mixed: #6250d6;
  --route-unknown: #b5b3ab;
  --good: #0ca30c;
  --warning: #fab219;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --route-w2: #3987e5;
    --route-w8: #d95926;
    --route-other: #199e70;
    --route-mixed: #9085e9;
    --route-unknown: #5d5c58;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.05);
  --route-w2: #3987e5;
  --route-w8: #d95926;
  --route-other: #199e70;
  --route-mixed: #9085e9;
  --route-unknown: #5d5c58;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
}
a { color: var(--route-w2); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.top { border-bottom: 1px solid var(--border); background: var(--surface); }
.top-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 14px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 22px 0 6px; }
.zh { color: var(--muted); font-weight: 400; font-size: 0.9em; margin-left: 4px; }
.note { color: var(--ink-2); font-size: 13px; margin: 0 0 8px; }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.status .dot.daily { background: var(--warning); }

main { padding-block: 16px 40px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

#map { height: 460px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); }
@media (max-width: 600px) { #map { height: 360px; } }
.leaflet-container { font: inherit; }
/* Muted basemap so the airways carry the colour; dark mode inverts the OSM tiles. */
.tiles-light { filter: grayscale(1) contrast(0.85) brightness(1.08); }
.tiles-dark { filter: grayscale(1) invert(1) contrast(0.8) brightness(0.75); }
.leaflet-tooltip.fix-label { background: transparent; border: 0; box-shadow: none; color: var(--ink-2); font-size: 11px; padding: 0; }
.leaflet-tooltip.fix-label::before { display: none; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
i.sq, .legend i.sq { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

.live-list { margin-top: 10px; display: grid; gap: 6px; font-size: 14px; }
.live-list .empty { color: var(--muted); }
.live-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.range { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.range button, .button {
  font: inherit; font-size: 13px; color: var(--ink); background: transparent; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; text-decoration: none;
}
.range button:hover, .button:hover { background: var(--wash); }
.range button.on { border-color: var(--ink-2); font-weight: 600; }
.range .custom { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-2); }
.range input { font: inherit; font-size: 13px; color: var(--ink); background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.tile .label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.tile .hint { font-size: 12px; color: var(--muted); }

.chart { width: 100%; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--wash); }
.chart .empty-msg { fill: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
#flights tbody tr { cursor: pointer; }
#flights tbody tr:hover, #flights tbody tr.sel { background: var(--wash); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.badge i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.muted { color: var(--muted); }

.tip {
  position: fixed; z-index: 1000; pointer-events: none; max-width: 260px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); padding: 8px 10px; font-size: 13px;
}
.tip b { font-weight: 600; }
.tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .row span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.about p { margin: 8px 0; color: var(--ink-2); font-size: 14px; }
