/* ==========================================================================
   fr24 web — map UI design system
   --------------------------------------------------------------------------
   One token layer, then components. Every value a component uses comes from a
   token below, so a theme change is a token change and nothing else. Both
   themes are defined in full (the old build only re-declared five variables,
   which left the popups hard-coded white in dark mode and vice-versa).
   ========================================================================== */

/* ---- 1. tokens ---------------------------------------------------------- */
:root {
  /* type scale — 6 steps, nothing in between */
  --fs-xs:   10.5px;
  --fs-sm:   11.5px;
  --fs-base: 12.5px;
  --fs-md:   13.5px;
  --fs-lg:   15px;
  --fs-xl:   18px;

  /* space scale — 4px base */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 20px; --sp-6: 28px;

  /* radius scale */
  --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-xl: 17px;

  /* elevation — 3 steps only */
  --e-1: 0 1px 2px rgba(9, 14, 22, .10), 0 2px 6px rgba(9, 14, 22, .07);
  --e-2: 0 4px 12px rgba(9, 14, 22, .13), 0 10px 28px rgba(9, 14, 22, .12);
  --e-3: 0 12px 28px rgba(9, 14, 22, .20), 0 28px 64px rgba(9, 14, 22, .22);

  --dur: .16s;
  --ease: cubic-bezier(.32, .72, 0, 1);

  /* class colours — identical in both themes so the map legend never shifts */
  --c-military:   #4f8b3b;
  --c-government: #7d5bc4;
  --c-passenger:  #2f76cf;
  --c-cargo:      #c2811f;
  --c-helicopter: #bc4a76;
  --c-other:      #64707e;

  --ok:   #1f9d55;
  --warn: #c8881f;
  --hot:  #d4622a;
  --bad:  #d33f3b;
}

/* light (default) */
:root {
  --bg:        #e9edf2;
  --surface:   rgba(255, 255, 255, .90);
  --surface-2: #ffffff;
  --chip:      #eef1f6;
  --ink:       #161c25;
  --ink-2:     #4a5462;
  --ink-3:     #7b8593;
  --line:      #d7dee7;
  --line-soft: rgba(22, 28, 37, .08);
  --accent:    #1668c8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(22, 104, 200, .10);
  --ring:      rgba(22, 104, 200, .45);
  --scrim:     rgba(12, 18, 28, .42);
}

:root[data-theme="dark"] {
  --bg:        #0a0e14;
  --surface:   rgba(19, 24, 33, .90);
  --surface-2: #161c26;
  --chip:      #1d2531;
  --ink:       #e7ebf1;
  --ink-2:     #a8b2c0;
  --ink-3:     #798497;
  --line:      #2b3341;
  --line-soft: rgba(255, 255, 255, .09);
  --accent:    #6fb6ff;
  --accent-ink: #06121f;
  --accent-soft: rgba(111, 182, 255, .14);
  --ring:      rgba(111, 182, 255, .55);
  --scrim:     rgba(2, 5, 10, .60);

  --e-1: 0 1px 2px rgba(0, 0, 0, .40), 0 2px 6px rgba(0, 0, 0, .30);
  --e-2: 0 4px 12px rgba(0, 0, 0, .46), 0 10px 28px rgba(0, 0, 0, .38);
  --e-3: 0 12px 28px rgba(0, 0, 0, .55), 0 28px 64px rgba(0, 0, 0, .48);
}

/* ---- 2. base ------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body, #map { height: 100%; margin: 0; }
#map { position: relative; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-base)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* One visible focus treatment for the whole app. */
:where(button, input, select, a, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* The floating chrome shares one surface recipe. */
.pane {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
}

/* ---- 3. HUD ------------------------------------------------------------- */
#hud {
  position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 1000;
  display: flex; align-items: stretch; gap: 1px;
  padding: var(--sp-1) 5px;
  font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
}
#hud.tick { animation: hudtick .55s var(--ease); }
@keyframes hudtick {
  0%   { box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft), 0 0 0 0 var(--ring); }
  45%  { box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft), 0 0 0 5px transparent; }
  100% { box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft), 0 0 0 0 transparent; }
}
#hud .brand {
  display: flex; align-items: center; gap: 7px;
  padding: 0 var(--sp-3) 0 var(--sp-2);
  font-weight: 800; font-size: var(--fs-xs); letter-spacing: 1.6px;
  color: var(--ink-2);
}
#hud .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  animation: breathe 2.4s var(--ease) infinite;
}
@keyframes breathe {
  0%   { box-shadow: 0 0 0 0 rgba(31, 157, 85, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(31, 157, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); }
}
#hud .m {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 3px var(--sp-3); position: relative;
}
#hud .m + .m::before, #hud .act::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 1px;
  background: linear-gradient(transparent, var(--line) 22%, var(--line) 78%, transparent);
}
#hud .m svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
#hud .m .col { display: flex; flex-direction: column; line-height: 1.05; }
#hud .m .v { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.2px; }
#hud .m .v small { font-weight: 500; color: var(--ink-3); font-size: var(--fs-sm); margin-left: 2px; }
#hud .m .k {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink-3); margin-top: 3px; font-weight: 650;
}
#hud .m.blip .v { animation: blip .5s var(--ease); }
@keyframes blip { 0% { color: var(--accent); transform: translateY(-1px); } }

/* freshness dot — the one place colour carries meaning in the HUD */
#hud .m.fresh .v::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 5px; vertical-align: 1px;
  background: var(--ok); transition: background var(--dur);
}
#hud .m.fresh[data-state="ok"]    .v::before { background: var(--warn); }
#hud .m.fresh[data-state="stale"] .v::before { background: var(--hot); }
#hud .m.fresh[data-state="dead"]  .v::before { background: var(--bad); }
#hud .m.fresh[data-state="stale"] .v,
#hud .m.fresh[data-state="dead"]  .v { color: var(--hot); }

#hud .act {
  display: flex; align-items: center; gap: 5px;
  padding-left: 11px; margin-left: 5px; position: relative;
}
#hud .act button {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--r-md); cursor: pointer; font: inherit; font-weight: 650;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
#hud .act button.primary {
  font-size: var(--fs-base); padding: 6px var(--sp-3) 6px 11px;
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  box-shadow: var(--e-1);
}
#hud .act button.primary:hover { filter: brightness(1.08); }
#hud .act button.primary.on {
  background: var(--ink); color: var(--surface-2); box-shadow: none;
}
#hud .act button.ico {
  font-size: var(--fs-base); width: 31px; height: 31px;
  justify-content: center; padding: 0; color: var(--ink-2);
}
#hud .act button.ico b { font-weight: 800; font-style: normal; }
#hud .act button.ico:hover {
  border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
#hud .act button svg { width: 15px; height: 15px; flex: none; }
#hud .act button.ico svg { width: 16px; height: 16px; }

/* segmented base-map switcher — one control, two mutually exclusive states */
#hud .seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--chip); border: 1px solid var(--line);
  border-radius: var(--r-md);
}
#hud .seg button {
  border: 0; background: transparent; color: var(--ink-2);
  border-radius: 7px; padding: 4px var(--sp-2); font-size: var(--fs-sm);
  font-weight: 650; gap: 5px;
}
#hud .seg button:hover { color: var(--ink); }
#hud .seg button.on {
  background: var(--surface-2); color: var(--ink); box-shadow: var(--e-1);
}
#hud .seg button svg { width: 14px; height: 14px; }
@media (max-width: 1080px) { #hud .seg button span { display: none; }
  #hud .seg button { padding: 4px 7px; } }

#hud-info {
  position: absolute; top: 100%; left: 0; margin-top: var(--sp-2);
  width: 330px; z-index: 1001;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-4) var(--sp-3);
  box-shadow: var(--e-3), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  font-size: var(--fs-base); line-height: 1.55;
}
#hud-info[hidden] { display: none; }
#hud-info h4 {
  margin: 0 0 var(--sp-2); font-size: var(--fs-xs); letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-3); font-weight: 700;
}
#hud-info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px var(--sp-3); }
#hud-info dt { font-weight: 700; color: var(--accent); white-space: nowrap; }
#hud-info dd { margin: 0; color: var(--ink-2); }
#hud-info .tiny {
  margin: var(--sp-3) 0 0; padding-top: var(--sp-2);
  border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-sm);
}

@media (max-width: 760px) {
  #hud { flex-wrap: wrap; max-width: calc(100vw - 24px); row-gap: 2px; }
  #hud .m .k { display: none; }
  #hud .brand { padding-right: 7px; }
}
@media (max-width: 720px) {
  #hud .act button.primary span { display: none; }
  #hud .act button.primary { padding: 6px var(--sp-2); }
}

/* ---- 4. legend ---------------------------------------------------------- */
#legend {
  position: absolute; bottom: var(--sp-4); left: var(--sp-3); z-index: 1000;
  width: 252px; padding: var(--sp-2) var(--sp-3) 7px;
  font-size: var(--fs-sm); line-height: 1.45;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--e-2), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
}
#legend .bar {
  height: 9px; border-radius: 3px; margin: var(--sp-1) 0 3px;
  background: linear-gradient(to right,
    hsl(20, 85%, 50%), hsl(80, 85%, 48%), hsl(140, 80%, 42%), hsl(190, 85%, 47%),
    hsl(250, 80%, 55%), hsl(300, 80%, 52%), hsl(340, 85%, 55%));
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
#legend .ticks {
  display: flex; justify-content: space-between;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
#legend .apnote {
  margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line);
  color: var(--ink-2); display: flex; align-items: center; gap: 6px;
}

/* ---- 5. canvas + tile filter -------------------------------------------- */
#planes {
  position: absolute; left: 0; top: 0; pointer-events: none;
  z-index: 450; will-change: transform;
}
:root.tilefilter .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.82);
}

/* ---- 6. hover tip ------------------------------------------------------- */
#hovertip {
  position: absolute; z-index: 1700; pointer-events: none;
  background: #10141b; color: #eef3f8;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 7px; padding: var(--sp-1) var(--sp-2) 5px;
  font: 650 var(--fs-base)/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: var(--e-2);
}
#hovertip[hidden] { display: none; }
#hovertip .ht2 {
  display: block; font-weight: 400; font-size: var(--fs-sm);
  color: rgba(238, 243, 248, .68); margin-top: 1px;
}

/* ---- 7. docked popup ---------------------------------------------------- */
#fr24-popup {
  position: absolute; right: var(--sp-3); bottom: 30px; left: auto; top: auto;
  z-index: 1600; pointer-events: auto;
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px);
  overflow-y: auto; border-radius: var(--r-lg);
  box-shadow: var(--e-3);
  animation: fpopin var(--dur) var(--ease) both;
}
@keyframes fpopin { from { opacity: 0; transform: translateY(10px); } }
#fr24-popup[hidden] { display: none; }
@media (max-width: 600px) { #fr24-popup { right: var(--sp-2); bottom: 26px; } }

#fr24-popup > [data-close] {
  position: absolute; right: 5px; top: 5px; z-index: 3;
  border: 0; width: 22px; height: 22px; border-radius: var(--r-sm);
  background: var(--chip); color: var(--ink-2);
  font: var(--fs-lg)/1 system-ui; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
#fr24-popup > [data-close]:hover { background: var(--line); color: var(--ink); }
#fr24-popup > .fpop, #fr24-popup > .apop { border-radius: var(--r-lg); overflow: hidden; }
#fr24-popup > .fpop { padding-right: 26px; }
#fr24-popup > .apop .body { padding-right: 24px; }
.leaflet-popup-content { margin: 0; }
.leaflet-popup-content-wrapper { border-radius: var(--r-lg); padding: 0; overflow: hidden; }

/* ---- 8. airport popup --------------------------------------------------- */
.apop {
  display: flex; width: 274px;
  font: var(--fs-md)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--surface-2);
}
.apop .flagwrap {
  flex: 0 0 96px; background: #101722;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-3);
  /* in dark mode the panel would otherwise melt into the popup body */
  border-right: 1px solid var(--line-soft);
}
.apop .flagwrap img {
  width: 76px; height: 57px; object-fit: cover; border-radius: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45); display: block;
}
.apop .flagwrap .emoji { font-size: 46px; line-height: 1; }
.apop .body { flex: 1 1 auto; padding: var(--sp-3); min-width: 0; }
.apop .name { font-weight: 700; font-size: var(--fs-md); margin-bottom: 5px; }
.apop .row {
  display: flex; align-items: center; gap: 7px; margin-bottom: var(--sp-1);
  flex-wrap: wrap;
}
.apop .iata {
  display: inline-block; font-weight: 700; font-size: var(--fs-sm);
  letter-spacing: 1px; background: var(--ink); color: var(--surface-2);
  border-radius: 5px; padding: 2px 7px; white-space: nowrap;
}
.apop .country { font-size: var(--fs-base); color: var(--ink-2); font-weight: 650; }
.apop .sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 3px; }
.apop a.gmap {
  display: inline-block; margin-top: 7px; font-size: var(--fs-sm);
  color: var(--accent); text-decoration: none; font-weight: 650;
}
.apop a.gmap:hover { text-decoration: underline; }

/* ---- 9. flight popup ---------------------------------------------------- */
.fpop {
  width: 292px; padding: var(--sp-3);
  font: var(--fs-base)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--surface-2);
}
.fpop .photo {
  margin: calc(var(--sp-3) * -1) calc(var(--sp-3) * -1) var(--sp-2);
  position: relative; background: #101722; line-height: 0;
}
.fpop .photo img { width: 100%; height: 132px; object-fit: cover; display: block; }
.fpop .photo .cr {
  position: absolute; inset: auto 0 0 0;
  font-size: 9px; line-height: 1.35; color: #eef4fb; text-align: right;
  padding: 10px var(--sp-2) 3px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
}
.fpop .photo .cr a { color: #d3e6ff; text-decoration: none; }
.fpop .cs { font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.1px; }
.fpop .cs .tc { font-weight: 400; color: var(--ink-3); font-size: var(--fs-base); }
.fpop .tag {
  display: inline-block; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; padding: 1px 6px;
  border-radius: 5px; margin-left: 6px; vertical-align: 2px; color: #fff;
}
.fpop .rt { margin: 3px 0 6px; color: var(--ink-2); }
/* Route: full airport name + country, never truncated. Long names wrap onto
   more lines rather than ellipsising — the destination is the thing people
   actually read in this popup. */
.fpop .route {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: start; gap: var(--sp-2);
  margin: var(--sp-2) 0; padding: var(--sp-2) 0;
  border-block: 1px solid var(--line-soft);
}
.fpop .route .ap { display: flex; flex-direction: column; line-height: 1.28; min-width: 0; }
.fpop .route .ap-to { text-align: right; align-items: flex-end; }
.fpop .route .ap b {
  font-size: var(--fs-lg); font-weight: 800; color: var(--ink);
  letter-spacing: .6px; line-height: 1.1;
}
.fpop .route .ap i {
  font-style: normal; font-size: var(--fs-sm); color: var(--ink-2); margin-top: 3px;
  overflow-wrap: anywhere;
}
.fpop .route .ap u {
  text-decoration: none; font-size: var(--fs-xs); color: var(--ink-3); margin-top: 1px;
}
.fpop .route .ar {
  color: var(--ink-3); font-size: var(--fs-lg); line-height: 1.1;
  align-self: start; padding-top: 1px;
}
.fpop .g {
  display: grid; grid-template-columns: auto 1fr; gap: 2px var(--sp-3);
  color: var(--ink-3); font-size: var(--fs-sm);
}
.fpop .g b {
  color: var(--ink); font-variant-numeric: tabular-nums;
  font-size: var(--fs-base); text-align: right;
}
.fpop .g .regflag {
  width: 15px; height: 11px; object-fit: cover; border-radius: 2px;
  margin-right: 5px; vertical-align: -1px;
  box-shadow: 0 0 0 1px var(--line-soft);
}

/* class colours — one source of truth for popup tags, list bars and tabs */
.c-military   { background: var(--c-military); }
.c-government { background: var(--c-government); }
.c-passenger  { background: var(--c-passenger); }
.c-cargo      { background: var(--c-cargo); }
.c-helicopter { background: var(--c-helicopter); }
.c-other      { background: var(--c-other); }

/* ---- 10. search panel --------------------------------------------------- */
#search {
  position: absolute; top: 64px; left: var(--sp-3); z-index: 1002;
  width: 340px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 78px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--e-3), inset 0 0 0 1px var(--line-soft);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  overflow: hidden; font-size: var(--fs-base);
  animation: panein var(--dur) var(--ease) both;
}
@keyframes panein { from { opacity: 0; transform: translateY(-6px); } }
#search[hidden] { display: none; }
#search .s-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
}
#search .s-head b {
  font-size: var(--fs-sm); letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--ink-2); font-weight: 700; flex: 1 1 auto;
}
#search .s-head button {
  background: transparent; border: 0; color: var(--ink-3);
  font-size: var(--fs-xl); line-height: 1; cursor: pointer; padding: 0 3px;
}
#search .s-head button:hover { color: var(--ink); }
/* "live" pill — the list re-queries on its own, this says so without a spinner */
#search .s-live {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-3);
}
#search .s-live i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: breathe 2.4s var(--ease) infinite;
}
#search.busy .s-live i { background: var(--accent); animation-duration: .7s; }

/* ---- search box --------------------------------------------------------- */
#search .s-box {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: 0 var(--sp-3) var(--sp-2); padding: 0 var(--sp-2);
  background: var(--chip); border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
#search .s-box:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
#search .s-box > svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
#search .s-box input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: var(--fs-md);
  padding: var(--sp-2) 0; outline: none;
}
#search .s-box input::placeholder { color: var(--ink-3); }
#search .s-box button {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: var(--fs-lg); line-height: 1; padding: 0 2px;
}
#search .s-box button:hover { color: var(--ink); }
#search .s-box button[hidden] { display: none; }

#search .s-opts {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3) var(--sp-3);
}
#search select {
  font: inherit; font-size: var(--fs-sm);
  background: var(--chip); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px var(--sp-2); flex: 1 1 auto; min-width: 0;
  transition: border-color var(--dur) var(--ease);
}
#search select:focus { border-color: var(--accent); }
#search .s-scope {
  color: var(--ink-3); font-size: var(--fs-sm); white-space: nowrap;
  display: flex; align-items: center; gap: 5px; cursor: pointer;
}
#search .s-scope input { accent-color: var(--accent); margin: 0; }

/* ---- class chips -------------------------------------------------------- */
#search .s-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 5px; padding: 0 var(--sp-3) var(--sp-3);
}
#search .s-tabs button {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  border-radius: var(--r-md); padding: 6px 7px 9px; cursor: pointer;
  font: inherit; text-align: left; line-height: 1.25;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
#search .s-tabs button:hover { border-color: var(--accent); transform: translateY(-1px); }
#search .s-tabs .t-top {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 650; color: var(--ink-2);
}
#search .s-tabs .dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
#search .s-tabs .dot.c-all {
  background: linear-gradient(135deg, var(--c-passenger), var(--c-military));
}
#search .s-tabs button b {
  display: block; margin-top: 1px; font-size: var(--fs-md); font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -.3px;
}
/* proportion of the sky this class holds — reads at a glance, unlike a number */
#search .s-tabs .share {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--line);
}
#search .s-tabs .share u {
  display: block; height: 100%; width: 0; border-radius: 0 2px 2px 0;
  transition: width .35s var(--ease);
}
#search .s-tabs .k-military   .share u { background: var(--c-military); }
#search .s-tabs .k-government .share u { background: var(--c-government); }
#search .s-tabs .k-passenger  .share u { background: var(--c-passenger); }
#search .s-tabs .k-cargo      .share u { background: var(--c-cargo); }
#search .s-tabs .k-helicopter .share u { background: var(--c-helicopter); }
#search .s-tabs button:first-child .share u { background: var(--accent); }
#search .s-tabs button.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
#search .s-tabs button.on .t-top { color: var(--accent-ink); opacity: .85; }
#search .s-tabs button.on .share u { background: currentColor; opacity: .6; }
#search .s-tabs button.on.k-military   { background: var(--c-military);   border-color: var(--c-military);   color: #fff; }
#search .s-tabs button.on.k-government { background: var(--c-government); border-color: var(--c-government); color: #fff; }
#search .s-tabs button.on.k-passenger  { background: var(--c-passenger);  border-color: var(--c-passenger);  color: #fff; }
#search .s-tabs button.on.k-cargo      { background: var(--c-cargo);      border-color: var(--c-cargo);      color: #fff; }
#search .s-tabs button.on.k-helicopter { background: var(--c-helicopter); border-color: var(--c-helicopter); color: #fff; }
#search .s-tabs button.on .t-top { color: inherit; opacity: .8; }
#search .s-tabs button.on .dot { background: currentColor !important; }

/* ---- result rows -------------------------------------------------------- */
#search .s-list {
  overflow-y: auto; border-top: 1px solid var(--line);
  flex: 1 1 auto; min-height: 90px; outline: none;
}
#search .s-item {
  display: flex; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); cursor: pointer;
  border-bottom: 1px solid var(--line-soft); align-items: center;
  transition: background var(--dur) var(--ease);
}
#search .s-item:hover, #search .s-item.sel { background: var(--accent-soft); }
#search .s-item.sel { box-shadow: inset 2px 0 0 var(--accent); }
#search .s-item .bar { flex: 0 0 3px; align-self: stretch; border-radius: 2px; }
#search .s-item .s-sil { flex: 0 0 30px; display: block; }
#search .s-item .mid { flex: 1 1 auto; min-width: 0; }
#search .s-item .cs { font-weight: 750; font-size: var(--fs-md); letter-spacing: -.1px; }
#search .s-item .cs small {
  font-weight: 500; color: var(--ink-3); margin-left: 6px; font-size: var(--fs-sm);
}
#search .s-item .sub {
  color: var(--ink-2); font-size: var(--fs-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* origin —————— destination, drawn rather than written as "A→B" */
#search .s-item .r-strip {
  display: flex; align-items: center; gap: 6px; margin-top: 3px;
  font-size: var(--fs-xs); color: var(--ink-3);
}
#search .s-item .r-strip b {
  font-weight: 700; letter-spacing: .5px; color: var(--ink-2);
}
#search .s-item .r-strip .r-line {
  flex: 1 1 auto; height: 1px; min-width: 12px;
  background: repeating-linear-gradient(to right,
    var(--line) 0 4px, transparent 4px 7px);
  position: relative;
}
#search .s-item .r-strip .r-line::after {
  content: ""; position: absolute; right: -1px; top: -2px;
  border-left: 5px solid var(--line); border-block: 2.5px solid transparent;
}
#search .s-item .met {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end;
  gap: 2px; font-variant-numeric: tabular-nums;
}
#search .s-item .met .alt { font-size: var(--fs-sm); color: var(--ink); font-weight: 650; }
#search .s-item .met .spd { font-size: var(--fs-xs); color: var(--accent); font-weight: 650; }
#search .s-empty {
  padding: var(--sp-5) var(--sp-4); color: var(--ink-3); text-align: center;
  display: flex; flex-direction: column; gap: 5px;
}
#search .s-empty b { color: var(--ink-2); font-size: var(--fs-md); }
#search .s-empty span { font-size: var(--fs-sm); line-height: 1.5; }
#search .s-foot {
  padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-2); font-size: var(--fs-sm); color: var(--ink-3);
}
#search .s-foot a { color: var(--accent); text-decoration: none; font-weight: 650; }
#search .s-foot a:hover { text-decoration: underline; }

/* ---- 11. playback timeline ---------------------------------------------- */
#track-panel { border-top: 1px solid var(--line); padding: var(--sp-2) var(--sp-3) var(--sp-3); }
#track-panel[hidden] { display: none; }
#track-panel > b {
  display: block; font-size: var(--fs-sm); letter-spacing: .5px;
  text-transform: uppercase; color: var(--ink-2); font-weight: 700;
}
#track-panel .track-meta {
  display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap;
  margin: var(--sp-1) 0 7px; font-size: var(--fs-sm); color: var(--ink-2);
}
#track-panel .track-meta #track-aircraft { font-weight: 700; color: var(--ink); }
#track-panel .track-meta #track-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
#track-panel input { width: 100%; accent-color: var(--accent); }
#track-panel .track-scale {
  display: flex; justify-content: space-between; margin-top: 2px;
  font-size: var(--fs-xs); color: var(--ink-3);
}
#track-panel button {
  margin-top: var(--sp-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  background: transparent; color: var(--ink); padding: 5px var(--sp-2);
  cursor: pointer; font: inherit; font-size: var(--fs-sm); font-weight: 650;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
#track-panel button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---- 12. modal overlays (catalog + fleet) ------------------------------- */
#catalog, #fleet {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: var(--scrim); backdrop-filter: blur(4px);
  animation: fade var(--dur) var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
#catalog[hidden], #fleet[hidden] { display: none; }
#catalog .box, #fleet .box {
  max-height: 82vh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-xl);
  box-shadow: var(--e-3), inset 0 0 0 1px var(--line-soft);
  overflow: hidden;
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  animation: boxin var(--dur) var(--ease) both;
}
@keyframes boxin { from { opacity: 0; transform: translateY(12px) scale(.985); } }
#catalog .box { width: min(690px, 92vw); }
#fleet .box   { width: min(570px, 92vw); }

#catalog .c-head, #fleet .c-head {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex; gap: var(--sp-3); align-items: center;
  border-bottom: 1px solid var(--line-soft);
}
#catalog .c-head b, #fleet .c-head b { font-size: var(--fs-lg); font-weight: 700; }
#fleet .c-head b { flex: 1 1 auto; }
#catalog .c-head input {
  flex: 1 1 auto; font: inherit; font-size: var(--fs-md);
  background: var(--chip); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-2) 11px;
}
#catalog .c-head input:focus, #fleet .c-search input:focus { border-color: var(--accent); }
#catalog .c-head button, #fleet .c-head button {
  background: transparent; border: 0; color: var(--ink-3); cursor: pointer;
  font-size: var(--fs-md); font-weight: 650;
  transition: color var(--dur) var(--ease);
}
#catalog .c-head button:hover, #fleet .c-head button:hover { color: var(--ink); }
#catalog .c-head button { font-size: var(--fs-xl); }
#fleet .c-head #fleet-close { font-size: var(--fs-xl); }
#fleet .c-head #fleet-back[hidden] { display: none; }

#fleet .c-search { padding: var(--sp-3) var(--sp-4) 0; }
#fleet .c-search input {
  width: 100%; font: inherit; font-size: var(--fs-base);
  padding: var(--sp-2) 11px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  outline: none;
}

#catalog .c-list, #fleet .c-list { overflow-y: auto; padding: var(--sp-2) var(--sp-2) var(--sp-2); }
#catalog .c-row, #fleet .c-row {
  display: grid; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline; font-size: var(--fs-base); border-radius: var(--r-sm);
}
#catalog .c-row { grid-template-columns: 68px 1fr auto; }
#fleet .c-row { grid-template-columns: auto 1fr auto; cursor: pointer;
  transition: background var(--dur) var(--ease); }
#fleet .c-row:hover { background: var(--accent-soft); }
#catalog .c-row .d, #fleet .c-row .d {
  font-weight: 800; letter-spacing: .5px; color: var(--accent);
}
#catalog .c-row .mf, #fleet .c-row .mf {
  color: var(--ink-3); font-size: var(--fs-sm); white-space: nowrap;
}
#fleet .c-row .bar3 { width: 4px; height: 15px; border-radius: 2px; align-self: center; }
#catalog .c-note, #fleet .c-note {
  padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); color: var(--ink-3);
  border-top: 1px solid var(--line);
}
#catalog .c-hint, #fleet .c-hint {
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  font-size: var(--fs-sm); color: var(--ink-3); line-height: 1.55;
}

@media (max-width: 760px) { #search { width: calc(100vw - 24px); } }

/* ---- 13. MapLibre chrome ------------------------------------------------ */
.maplibregl-ctrl-bottom-right { z-index: 900; }
.maplibregl-ctrl-attrib {
  font: var(--fs-xs)/1.4 system-ui, sans-serif !important;
  background: var(--surface) !important; color: var(--ink-3) !important;
  border-radius: var(--r-sm) 0 0 0 !important;
}
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
.maplibregl-ctrl-group {
  border-radius: var(--r-md) !important; overflow: hidden;
  background: var(--surface) !important;
  box-shadow: var(--e-1), inset 0 0 0 1px var(--line-soft) !important;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.6);
}
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1) brightness(1.6); }
