:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #5f676e;
  --line: #d9ddd8;
  --accent: #0b5cad;
  --uk: #c8102e;
  --other: #59636e;
  --seg-bg: #e7e9e4;
  --seg-on: #1d2125;
  --seg-on-text: #ffffff;
  /* Aircraft colours: drawn on the always-light OSM tiles, so NOT redefined for dark mode. */
  --ac-uk: #c8102e;
  --ac-other: #1f5fbf;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b;
    --surface: #1e2226;
    --text: #e6e8ea;
    --muted: #9aa3ab;
    --line: #30363c;
    --accent: #6cb0f5;
    --uk: #ff5468;
    --other: #a3adb7;
    --seg-bg: #2a2f34;
    --seg-on: #e6e8ea;
    --seg-on-text: #15181b;
  }
}

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

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.bar h1 { font-size: 1.1rem; margin: 0; letter-spacing: .02em; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--seg-bg); border-radius: 8px; padding: 2px; }
.seg button, .list-toggle, .panel-close {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--seg-on-text); }
.list-toggle { display: none; background: var(--seg-bg); }

.layout { flex: 1; display: flex; min-height: 0; position: relative; overflow: hidden; } /* clips the closed phone drawer */
.trail-hint {
  position: absolute;
  left: calc((100% - 300px) / 2); /* centre of the map, beside the 300px list panel */
  top: 12px;
  transform: translateX(-50%);
  z-index: 900;
  font: inherit;
  font-size: .85em;
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(29, 33, 37, .82);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.trail-hint[hidden] { display: none; }
#map { flex: 1; min-width: 0; background: var(--bg); }

.panel {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 12px 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { font-size: 1rem; margin: 4px 0 8px; }
.panel h3 { font-size: .85rem; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }
.panel-close { display: none; font-size: 1.3rem; line-height: 1; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list li:hover { background: var(--seg-bg); }
.list.nopos li { cursor: default; }
.list.nopos li:hover { background: none; }
.list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ac-other); }
.list .dot.uk { background: var(--ac-uk); }
.list .name { font-weight: 600; }
.list .sub { color: var(--muted); font-size: .85em; }
.list .alt { color: var(--muted); font-size: .85em; text-align: right; white-space: nowrap; }
.list .stale { opacity: .5; }
.list li.empty { display: block; color: var(--muted); padding: 8px 0; cursor: default; border-bottom: 0; }
.list li.empty:hover { background: none; }

.about { margin-top: 16px; color: var(--muted); font-size: .9em; }
.about summary { cursor: pointer; color: var(--text); }

.status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 16px;
  font-size: .85em;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.status.old #status { color: var(--uk); }

/* Aircraft markers */
.ac-icon { background: none; border: 0; }
.ac-icon svg { display: block; overflow: visible; transition: transform .3s; filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); }
.ac-icon svg * { stroke: #ffffff; stroke-width: 1.2px; stroke-linejoin: round; paint-order: stroke; }
.ac-icon.uk svg * { fill: var(--ac-uk); }
.ac-icon.other svg * { fill: var(--ac-other); }
.ac-icon.stale { opacity: .45; }

.leaflet-popup-content { font: 13px/1.45 system-ui, sans-serif; margin: 10px 12px; }
.pop h4 { margin: 0 0 4px; font-size: 14px; }
.pop table { border-collapse: collapse; }
.pop td { padding: 1px 8px 1px 0; vertical-align: top; }
.pop td:first-child { color: #5f676e; }

@media (max-width: 720px) {
  .bar { padding: 8px 16px; gap: 8px; }
  .controls { order: 3; flex-basis: 100%; }
  .trails-seg { margin-left: auto; }
  .list-toggle { display: inline-block; }
  .panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 60%;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.2);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform .25s;
    padding: 8px 16px 16px;
  }
  .panel.open { transform: none; }
  .trail-hint { left: 50%; }
  .panel-close { display: block; }
}
