:root {
  --bg: #0b1017;
  --bar: #111824ee;
  --panel: #121a26f2;
  --line: #233044;
  --text: #dce4ee;
  --muted: #8796a8;
  --accent: #3ec6ff;
  --air: #ffd24a;
  --ground: #9aa7b6;
  --ctr: #2fd0a6;
  --uir: #a98bff;
  --app: #ff9a3d;
  --twr: #ff5c6c;
  --gnd: #4bb6ff;
  --del: #b5c2d1;
  --atis: #ffd24a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#map { position: absolute; inset: 52px 0 0 0; background: radial-gradient(ellipse at 50% 45%, #0c1626 0%, #04070b 70%); }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; inset: 0 0 auto 0; height: 52px; z-index: 1050; /* above the side panel, so menus and search results open over it */
  display: flex; align-items: center; gap: 18px; padding: 0 14px;
  background: var(--bar); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.search { position: relative; flex: 0 1 340px; }
.search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c131d; color: var(--text); font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--accent); }
.search-results {
  position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: 340px; overflow: auto;
}
.search-results li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.search-results li:hover, .search-results li.active { background: #1b2636; }
.search-results .kind { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.stats { display: flex; gap: 14px; font-size: 13px; white-space: nowrap; }
.stat b { color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 2px 8px; cursor: pointer; font: inherit; font-size: 12px; }
.stat-btn:hover { color: var(--text); }
.muted { color: var(--muted); }
.toggles { margin-left: auto; display: flex; gap: 12px; font-size: 13px; white-space: nowrap; }
.toggles label { cursor: pointer; user-select: none; }
.toggles select { background: #0c131d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 12px; }
@media (max-width: 1000px) { .toggles, .stats .muted { display: none; } }
@media (max-width: 640px) { .stats { display: none; } }

/* ---------- side panel ---------- */
.panel {
  position: absolute; top: 64px; right: 12px; bottom: 12px; width: 380px; z-index: 1000;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: auto; padding: 16px 16px 20px; backdrop-filter: blur(6px);
}
@media (max-width: 640px) { .panel { left: 8px; right: 8px; width: auto; top: auto; height: 55%; } }
.panel-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; }
.panel h2 { margin: 0 0 2px; font-size: 22px; letter-spacing: .5px; }
.panel h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.panel .sub { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.kv div { background: #0e151f; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.kv span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kv b { font-size: 15px; font-variant-numeric: tabular-nums; }
.r-pt { color: #7fd8ff; } .r-awy { color: #c9b26a; } .r-unres { color: #ff8a96; } .r-skip { color: #5b6b80; }
.r-solid { color: #3ec6ff; } .r-dot { color: #7f9bb5; } .r-dash { color: #9fdcff; }
.track-legend { margin-top: 10px; flex-wrap: wrap; }
.route-legend { display: flex; gap: 12px; font-size: 11px; margin: 6px 0 2px; }
.wp { font-size: 10px; font-weight: 700; color: #cfe9ff; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; }
.wp.passed { color: #6c7b8f; }
.route-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; background: #0e151f; border: 1px solid var(--line); border-radius: 8px; padding: 8px; word-break: break-word; }
.legs { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.legs .ap { flex: 1; min-width: 0; }
.legs .ap b { font-size: 20px; display: block; }
.legs .ap small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legs .ap.right { text-align: right; }
.progress { height: 4px; background: #1c2737; border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.ctl { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; background: #0e151f; }
.ctl-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ctl-cs { font-weight: 700; }
.ctl-freq { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); }
.ctl-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ctl-text { white-space: pre-wrap; font-size: 12px; margin-top: 6px; color: #b9c5d3; font-family: ui-monospace, Menlo, Consolas, monospace; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; color: #0b1017; margin-right: 6px; vertical-align: 1px; }
.flist { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.flist li { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px solid #1a2433; cursor: pointer; }
.flist li:hover { color: var(--accent); }

/* ---------- map markers ---------- */
/* MapLibre chrome */
.maplibregl-popup.ac-tip .maplibregl-popup-content { background: #0d141e; color: var(--text); border: 1px solid var(--line); box-shadow: none; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.maplibregl-popup.ac-tip .maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-group { background: #121a26 !important; border: 1px solid var(--line); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(.85); }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib.maplibregl-compact { background: #0b1017cc !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: #9bb3cc !important; }
.maplibregl-ctrl-attrib-button { filter: invert(.85); }

.l-DEL { background: var(--del); } .l-GND { background: var(--gnd); } .l-TWR { background: var(--twr); }
.l-APP { background: var(--app); } .l-ATIS { background: var(--atis); }

.sector-list { font-size: 12px; columns: 2; column-gap: 12px; margin: 0; padding: 0; list-style: none; }
.sector-list li { padding: 2px 0; break-inside: avoid; }
.sector-list .lv { color: var(--muted); font-variant-numeric: tabular-nums; }
.badge-src { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 3px; }


.toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 1100; background: #3a1d22; border: 1px solid #6b2c35; color: #ffd6db; padding: 8px 14px; border-radius: 8px; font-size: 13px; }

/* ---------- account menu ---------- */
.account { position: relative; margin-left: 4px; }
.login-btn, .me-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.login-btn { background: var(--accent); color: #06121c; font-weight: 600; }
.me-btn { background: #0c131d; color: var(--text); border: 1px solid var(--line); max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.me-btn:hover { border-color: var(--accent); }
.me-dot { width: 8px; height: 8px; border-radius: 50%; background: #3dff8f; box-shadow: 0 0 8px #3dff8f; flex: none; }
.me-menu { position: absolute; right: 0; top: 40px; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 1200; box-shadow: 0 8px 24px #0008; }
.me-menu a, .me-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font: inherit; font-size: 13px; background: none; border: 0; cursor: pointer; }
.me-menu a:hover, .me-menu button:hover { background: #1b2636; }
.me-menu #me-find { color: #3dff8f; }
.me-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 700; }
.me-head small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.me-chip { color: #3dff8f !important; border-color: #1f6b46 !important; }

/* Privacy link and cookie banner */
.legal { position: fixed; left: 10px; bottom: 6px; z-index: 5; font-size: 11px; color: #8796a8; background: rgba(11,16,23,.7); padding: 2px 8px; border-radius: 10px; }
.legal a { color: #a9b6c6; text-decoration: none; } .legal a:hover { color: #fff; }
.cookie-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50; width: min(560px, calc(100% - 24px));
  background: #121a26; border: 1px solid #233044; border-radius: 12px; padding: 14px 16px; color: #dce4ee; font-size: 13px; line-height: 1.45;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; flex: 1 1 300px; } .cookie-banner a { color: #3ec6ff; }
.cookie-banner div { display: flex; gap: 8px; margin-left: auto; }
.cookie-banner button { font: inherit; border-radius: 8px; padding: 7px 14px; cursor: pointer; border: 1px solid #3ec6ff; background: #3ec6ff; color: #04121c; font-weight: 600; }
.cookie-banner button.ghost { background: transparent; color: #dce4ee; border-color: #3a4a60; }
.wp.apt { font-size: 12px; color: #fff; background: rgba(11,16,23,.75); border: 1px solid #3ec6ff; border-radius: 4px; padding: 1px 5px; text-shadow: none; }

/* Friends */
.friends-wrap { position: relative; display: inline-flex; }
.friends-chip { color: #ff5ce1 !important; border-color: #6b2a5f !important; animation: friend-glow 2s ease-in-out infinite; }
@keyframes friend-glow { 50% { box-shadow: 0 0 10px #ff5ce188; } }
.friends-pop { position: absolute; top: 34px; left: 0; min-width: 220px; max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 1200; box-shadow: 0 8px 24px #0008; }
.friends-pop button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.friends-pop button:hover { background: #1b2636; }
.friends-pop button span { color: var(--muted); font-size: 12px; }
.friend-star { color: #ff5ce1; }
.friend-name { color: #ff5ce1; }
.panel-actions { margin: 8px 0 4px; }
.ctl-actions { margin-top: 4px; }
.friend-btn { display: inline-block; font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid #6b2a5f; background: transparent; color: #ff9cec; cursor: pointer; text-decoration: none; }
.friend-btn:hover { background: #2a1226; }
.friend-btn.on { background: #ff5ce1; border-color: #ff5ce1; color: #1a0716; font-weight: 600; }
.ctl.is-friend { border-left: 3px solid #ff5ce1; padding-left: 8px; }
