/* ─────────────────────────────────────────────────────────────────
   MYBUS — operations-center theme
   Tipografia: IBM Plex Mono (telemetria) + IBM Plex Sans (UI)
   Palette: deep navy + amber + cyan + signal green
   ───────────────────────────────────────────────────────────────── */

:root,
:root[data-theme="dark"] {
  /* base */
  --bg-0: #060912;              /* deep navy/quasi nero */
  --bg-1: #0b1220;              /* surface principale */
  --bg-2: #131b2e;              /* surface elevata */
  --bg-3: #1a2440;              /* hover */
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);

  /* text */
  --t-0: #e8eef9;
  --t-1: #aab4cc;
  --t-2: #6c7891;
  --t-3: #3e485d;

  /* accent */
  --amber: #ff8a1c;             /* bus markers */
  --amber-glow: rgba(255, 138, 28, 0.55);
  --cyan: #2dd4ff;              /* trails / data */
  --cyan-glow: rgba(45, 212, 255, 0.5);
  --lime: #b6ff3c;              /* signal / online */
  --magenta: #ff2d8a;            /* selected / alert */
  --magenta-glow: rgba(255, 45, 138, 0.6);
  --warn: #ffd55a;

  --grid-line: rgba(45, 212, 255, 0.04);
  --vignette-1: rgba(45, 212, 255, 0.06);
  --vignette-2: rgba(255, 138, 28, 0.06);
  --tile-filter: contrast(1.05) saturate(1.1);
  --popup-shadow: 0 8px 24px rgba(0,0,0,0.6), 0 0 24px rgba(45,212,255,0.18);
}

/* LIGHT THEME — paper / blueprint */
:root[data-theme="light"] {
  --bg-0: #efece4;              /* avorio caldo (carta tecnica) */
  --bg-1: #f7f5ee;              /* surface principale */
  --bg-2: #fefdf9;              /* surface elevata */
  --bg-3: #e7e3d6;              /* hover */
  --line: rgba(20, 30, 50, 0.10);
  --line-strong: rgba(20, 30, 50, 0.20);

  --t-0: #0d1322;               /* navy quasi nero */
  --t-1: #3a4762;
  --t-2: #6b7794;
  --t-3: #a3acc0;

  /* accenti adattati per leggibilità su sfondo chiaro */
  --amber: #d96b00;             /* arancione più scuro */
  --amber-glow: rgba(217, 107, 0, 0.45);
  --cyan: #0073a8;              /* blu petrolio */
  --cyan-glow: rgba(0, 115, 168, 0.30);
  --lime: #2f8a17;              /* verde foresta */
  --magenta: #c41365;           /* magenta scuro */
  --magenta-glow: rgba(196, 19, 101, 0.45);
  --warn: #b58000;

  --grid-line: rgba(13, 19, 34, 0.045);
  --vignette-1: rgba(0, 115, 168, 0.05);
  --vignette-2: rgba(217, 107, 0, 0.04);
  --tile-filter: none;
  --popup-shadow: 0 8px 24px rgba(13,19,34,0.18), 0 0 24px rgba(0,115,168,0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--t-0);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  transition: background-color .25s ease, color .25s ease;
}

/* Background grid + vignette */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 50%, transparent 100%);
}
.bg-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, var(--vignette-1), transparent 80%),
    radial-gradient(ellipse 50% 30% at 100% 100%, var(--vignette-2), transparent 80%);
}

/* ──────────────── HEADER ──────────────── */
.hdr {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  z-index: 600;
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr auto;
  align-items: stretch;
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.hdr__brand {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  border-right: 1px solid var(--line);
}
.hdr__logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  background: rgba(45, 212, 255, 0.06);
  box-shadow: inset 0 0 12px rgba(45, 212, 255, 0.15);
  border-radius: 2px;
}
.hdr__title { line-height: 1; }
.hdr__name {
  font-family: 'IBM Plex Sans Condensed', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.18em;
}
.hdr__name .dot { color: var(--amber); margin: 0 1px; }
.hdr__sub {
  margin-top: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--t-2);
}

.hdr__telem {
  display: flex; align-items: stretch;
  padding: 0 8px;
  overflow-x: auto;
}
.kv {
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 18px;
  border-right: 1px solid var(--line);
  min-width: 140px;
}
.kv:last-child { border-right: 0; }
.kv__k {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--t-2);
}
.kv__v {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-0);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.kv--status { display: flex; flex-direction: row; gap: 10px; align-items: center; }
.kv--status .kv__v { margin-top: 0; }
.led {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime), 0 0 2px var(--lime);
  animation: led-pulse 1.6s ease-in-out infinite;
}

/* THEME TOGGLE */
.hdr__theme {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-left: 1px solid var(--line);
  background: transparent;
  border-top: 0; border-right: 0; border-bottom: 0;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--t-1);
  transition: color .15s, background-color .15s;
}
.hdr__theme:hover { background: var(--bg-2); color: var(--t-0); }
.hdr__theme-track {
  position: relative;
  width: 44px; height: 22px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  display: inline-block;
}
.hdr__theme-thumb {
  position: absolute;
  top: 1px; left: 1px;
  width: 18px; height: 18px;
  background: var(--bg-0);
  border: 1px solid var(--cyan);
  display: grid; place-items: center;
  color: var(--cyan);
  transition: transform .25s cubic-bezier(.6,0,.2,1), color .25s, border-color .25s;
}
:root[data-theme="light"] .hdr__theme-thumb {
  transform: translateX(20px);
  color: var(--amber);
  border-color: var(--amber);
}
.ic { display: none; }
:root[data-theme="dark"] .ic--moon,
:root:not([data-theme="light"]) .ic--moon { display: block; }
:root[data-theme="light"] .ic--sun { display: block; }
.hdr__theme-lbl { color: inherit; }
@keyframes led-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ──────────────── SIDEBARS ──────────────── */
.side {
  position: fixed;
  top: 56px; bottom: 64px;
  width: 320px;
  z-index: 500;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 14px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.side--l { left: 0; }
.side--r { right: 0; border-right: 0; border-left: 1px solid var(--line); transform: translateX(105%); transition: transform .35s cubic-bezier(.6,0,.2,1); padding: 0; }
.side--r.is-open { transform: translateX(0); }

.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }

/* BLOCK (general data section) */
.block {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  position: relative;
}
.block::before {
  /* corner notches */
  content: '';
  position: absolute; top: -1px; left: -1px;
  width: 8px; height: 8px;
  border-top: 1px solid var(--cyan);
  border-left: 1px solid var(--cyan);
}
.block::after {
  content: '';
  position: absolute; bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-bottom: 1px solid var(--cyan);
  border-right: 1px solid var(--cyan);
}
.block__hd {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.015);
}
.block__id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.18em;
}
.block__t {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--t-0);
}
.block__r {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--t-1);
  font-variant-numeric: tabular-nums;
}

/* CTRL (filtri) */
.ctrl { padding: 12px; border-bottom: 1px solid var(--line); }
.ctrl:last-child { border-bottom: 0; }
.ctrl__l {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--t-2);
  margin-bottom: 6px;
}
.ctrl__sel {
  width: 100%;
  background: var(--bg-0);
  color: var(--t-0);
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  border-radius: 0;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  outline: none;
  transition: border-color .15s, background-color .15s;
}
.ctrl__sel:hover, .ctrl__sel:focus {
  border-color: var(--cyan);
  background-color: rgba(45,212,255,0.04);
}

.ctrl--toggles { display: flex; gap: 8px; }
.tg {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 6px;
  border: 1px solid var(--line-strong);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.tg input { appearance: none; width: 10px; height: 10px; border: 1px solid var(--t-2); position: relative; margin: 0; }
.tg input:checked { border-color: var(--lime); background: var(--lime); box-shadow: 0 0 8px rgba(182,255,60,0.6); }
.tg span { color: var(--t-1); }
.tg:has(input:checked) { border-color: var(--lime); }
.tg:has(input:checked) span { color: var(--lime); }

/* METRIC (big number) */
.metric { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); }
.metric__big {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 300;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--amber);
  text-shadow: 0 0 30px var(--amber-glow);
  font-variant-numeric: tabular-nums;
}
.metric__lbl {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.25em;
  color: var(--t-2);
  margin-top: 6px;
}

/* BARS (province breakdown) */
.bars { padding: 10px 12px 14px; }
.bar {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 10px; align-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.bar__k { color: var(--t-1); letter-spacing: 0.12em; }
.bar__t { height: 4px; background: rgba(255,255,255,0.04); position: relative; }
.bar__t::after {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--cyan), var(--cyan-glow));
  box-shadow: 0 0 6px var(--cyan-glow);
  transition: width .3s cubic-bezier(.4,0,.2,1);
}
.bar__v { color: var(--t-0); text-align: right; }

/* OPLIST */
.oplist { padding: 6px 10px 10px; }
.op {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px; align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
}
.op:last-child { border-bottom: 0; }
.op__n { color: var(--t-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.04em; }
.op__c { color: var(--cyan); text-align: right; font-variant-numeric: tabular-nums; }

/* ──────────────── MAP ──────────────── */
#map {
  position: absolute;
  top: 56px; bottom: 64px;
  left: 320px; right: 0;
  background: var(--bg-0);
}
/* Ridipingere i tile in modo da fonderli col tema */
.leaflet-tile-pane { filter: var(--tile-filter); }

.leaflet-control-zoom {
  border: 1px solid var(--line-strong) !important;
  box-shadow: none !important;
  background: var(--bg-1) !important;
}
.leaflet-control-zoom a {
  background: var(--bg-1) !important;
  color: var(--t-0) !important;
  border-bottom: 1px solid var(--line) !important;
  font-family: 'IBM Plex Mono', monospace !important;
}
.leaflet-control-zoom a:hover {
  background: var(--bg-2) !important;
  color: var(--cyan) !important;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--bg-1) 88%, transparent) !important;
  color: var(--t-2) !important;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 9px !important;
  letter-spacing: 0.05em !important;
  border: 1px solid var(--line) !important;
  border-bottom: 0 !important;
  border-right: 0 !important;
}
.leaflet-control-attribution a { color: var(--t-1) !important; }

/* MARKERS */
.bus-marker { background: transparent !important; border: 0 !important; }
.bus-marker svg { display: block; }
.bus-marker .core {
  fill: var(--amber);
  filter: drop-shadow(0 0 6px var(--amber-glow));
}
.bus-marker .ring { stroke: var(--amber); stroke-opacity: 0.6; }
.bus-marker.is-selected .core { fill: var(--magenta); filter: drop-shadow(0 0 14px var(--magenta-glow)); }
.bus-marker.is-selected .ring { stroke: var(--magenta); }
.bus-marker.is-selected::after {
  content: '';
  position: absolute; inset: -8px;
  border: 1px solid var(--magenta);
  border-radius: 50%;
  animation: ping 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes ping {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* TRAILS (polyline) */
.leaflet-overlay-pane svg path.trail {
  filter: drop-shadow(0 0 6px var(--cyan-glow));
}

/* POPUP customization */
.leaflet-popup-content-wrapper {
  background: color-mix(in srgb, var(--bg-1) 96%, transparent) !important;
  color: var(--t-0) !important;
  border: 1px solid var(--cyan) !important;
  border-radius: 0 !important;
  box-shadow: var(--popup-shadow) !important;
  padding: 0 !important;
}
.leaflet-popup-tip { background: var(--cyan) !important; }
.leaflet-popup-content { margin: 14px 16px !important; font-family: 'IBM Plex Mono', monospace !important; font-size: 11.5px !important; color: var(--t-0) !important; }
.leaflet-popup-close-button { color: var(--t-1) !important; }

/* ──────────────── DETAIL PANEL (right) ──────────────── */
.detail { display: flex; flex-direction: column; height: 100%; }
.detail__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.detail__id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.28em;
  color: var(--cyan);
}
.detail__close {
  background: transparent; border: 1px solid var(--line-strong); color: var(--t-1);
  font-size: 16px; line-height: 1; width: 26px; height: 26px;
  cursor: pointer; padding: 0;
  font-family: inherit;
  transition: all .15s;
}
.detail__close:hover { color: var(--magenta); border-color: var(--magenta); }

.detail__body { padding: 14px 16px; overflow-y: auto; }
.dgrp { margin-bottom: 18px; }
.dgrp__t {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--t-2);
  margin-bottom: 6px;
}
.dgrp__hero {
  font-family: 'IBM Plex Sans Condensed', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--t-0);
  letter-spacing: 0.02em;
}
.dgrp__hero .accent { color: var(--amber); }
.dgrp__row {
  display: grid; grid-template-columns: 96px 1fr;
  gap: 10px; padding: 4px 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  border-bottom: 1px solid var(--line);
}
.dgrp__row:last-child { border-bottom: 0; }
.dgrp__rk { color: var(--t-2); letter-spacing: 0.1em; }
.dgrp__rv { color: var(--t-0); font-variant-numeric: tabular-nums; }
.dgrp__rv .muted { color: var(--t-2); }

/* TIMELINE OF STOPS */
.tlst { position: relative; padding-left: 16px; margin-top: 8px; }
.tlst::before {
  content: '';
  position: absolute; left: 4px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line-strong);
}
.tlst__node {
  display: grid; grid-template-columns: 50px 1fr;
  gap: 10px;
  padding: 4px 0 8px;
  position: relative;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}
.tlst__node::before {
  content: ''; position: absolute; left: -16px; top: 9px;
  width: 9px; height: 9px;
  border: 1px solid var(--cyan);
  background: var(--bg-0);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan-glow);
}
.tlst__node.is-now::before { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 10px var(--magenta-glow); }
.tlst__h { color: var(--cyan); }
.tlst__node.is-now .tlst__h { color: var(--magenta); }
.tlst__d { color: var(--t-1); line-height: 1.35; }
.tlst__d strong { color: var(--t-0); font-weight: 500; }
.tlst__d small { display: block; color: var(--t-2); font-size: 10px; margin-top: 2px; }

/* ──────────────── BOTTOM TIMELINE ──────────────── */
.tl {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 64px; z-index: 600;
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  display: flex; align-items: center;
}
.tl__row {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  width: 100%;
}
.tl__live {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--t-1);
  cursor: pointer;
  transition: all .15s;
}
.tl__live.is-live { border-color: var(--lime); color: var(--lime); }
.tl__live.is-live .tl__livedot {
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
}
.tl__livedot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--t-3);
  transition: all .2s;
}
.tl__time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--t-0);
  font-variant-numeric: tabular-nums;
  min-width: 110px;
  letter-spacing: 0.04em;
}
.tl__range {
  flex: 1;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg,
    var(--bg-3) 0%,
    var(--bg-3) calc(var(--prog, 0) * 1%),
    rgba(45, 212, 255, 0.18) calc(var(--prog, 0) * 1%),
    rgba(45, 212, 255, 0.18) 100%);
  outline: none;
  border-radius: 0;
  border: 0;
  margin: 0;
}
.tl__range::-webkit-slider-thumb {
  appearance: none;
  width: 4px; height: 22px;
  background: var(--cyan);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 0 12px var(--cyan-glow);
}
.tl__range::-moz-range-thumb {
  width: 4px; height: 22px;
  background: var(--cyan);
  border-radius: 0;
  cursor: pointer;
  border: 0;
  box-shadow: 0 0 12px var(--cyan-glow);
}
.tl__hours {
  position: absolute; left: 250px; right: 18px; bottom: 8px;
  display: flex; justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--t-3);
  pointer-events: none;
}

/* ──────────────── PLANNER ──────────────── */
.ctrl__inp {
  width: 100%;
  background: var(--bg-0);
  color: var(--t-0);
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color .15s;
}
.ctrl__inp:focus { border-color: var(--cyan); background: rgba(45,212,255,0.03); }
.ctrl__inp::placeholder { color: var(--t-3); }
.ctrl__inp[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.6); cursor: pointer; }

.ctrl--btn { border-bottom: 0; }
.plan__btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.plan__btn:hover { background: rgba(45,212,255,0.08); }
.plan__msg {
  margin-top: 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--t-2);
  text-align: center;
  min-height: 14px;
}

/* Autocomplete dropdown (position: fixed, set via JS) */
.ac__drop {
  display: none;
  position: fixed;
  z-index: 9000;
  background: var(--bg-2);
  border: 1px solid var(--cyan);
  border-top: 0;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.ac__drop.is-open { display: block; }
.ac__item {
  padding: 8px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  color: var(--t-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac__item:last-child { border-bottom: 0; }
.ac__item:hover { background: var(--bg-3); color: var(--t-0); }

/* Result legs */
.leg {
  border: 1px solid var(--line);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.leg:hover { border-color: var(--amber); }
.leg.is-active { border-color: var(--magenta); }
.leg__hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--line);
}
.leg__num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--t-2);
}
.leg__line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--amber);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 65%;
}
.leg__board, .leg__alight {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 10px;
  padding: 6px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}
.leg__alight { border-bottom: 0; }
.leg__t { color: var(--cyan); }
.leg__s { color: var(--t-1); }
.leg__s small { display: block; color: var(--t-2); font-size: 10px; margin-top: 2px; }

.xfer {
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.15em;
  color: var(--t-2);
  padding: 5px 0 8px;
}

/* ──────────────── SIM BADGE (brand) ──────────────── */
.hdr__sim {
  margin-left: auto;
  align-self: center;
  padding: 3px 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.hdr__sim::before { content: '◆ '; opacity: 0.8; }
.hdr__sim:hover { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--t-0); }

/* ──────────────── HEADER ACTIONS (lang + info + theme) ──────────────── */
.hdr__actions { display: flex; align-items: stretch; }
.hdr__info, .hdr__lang {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  border: 0; border-left: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--t-1);
  transition: color .15s, background-color .15s;
}
.hdr__info:hover, .hdr__lang:hover { background: var(--bg-2); color: var(--cyan); }
.hdr__lang span { font-weight: 600; }

/* ──────────────── FIRST-VISIT BANNER ──────────────── */
.intro[hidden] { display: none; }
.intro {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 72px;
  z-index: 1200;
  display: flex; align-items: center; gap: 14px;
  max-width: min(720px, calc(100vw - 32px));
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg-2) 96%, transparent);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--warn);
  border-radius: 3px;
  box-shadow: var(--popup-shadow);
  backdrop-filter: blur(8px);
}
.intro__ic { color: var(--warn); display: grid; place-items: center; flex: 0 0 auto; }
.intro__txt { font-size: 12px; line-height: 1.5; color: var(--t-1); }
.intro__txt strong { color: var(--t-0); }
.intro__txt em { color: var(--warn); font-style: normal; }
.intro__more, .intro__ok {
  flex: 0 0 auto;
  padding: 7px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--t-1);
  transition: background-color .15s, color .15s, border-color .15s;
}
.intro__more:hover { color: var(--cyan); border-color: var(--cyan); }
.intro__ok {
  border-color: var(--lime);
  color: var(--lime);
}
.intro__ok:hover { background: color-mix(in srgb, var(--lime) 16%, transparent); }

/* ──────────────── INFO OVERLAY ──────────────── */
.ov { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; }
.ov[hidden] { display: none; }
.ov__backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg-0) 78%, transparent);
  backdrop-filter: blur(3px);
}
.ov__panel {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: var(--popup-shadow);
}
.ov__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.ov__id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--cyan);
}
.ov__close {
  background: transparent; border: 0; cursor: pointer;
  color: var(--t-2); font-size: 22px; line-height: 1;
  padding: 0 4px; transition: color .15s;
}
.ov__close:hover { color: var(--magenta); }
.ov__body { padding: 16px; overflow-y: auto; }
.ov__lead { margin: 0 0 14px; color: var(--t-1); font-size: 13px; line-height: 1.55; }
.ov__sec { margin-bottom: 16px; }
.ov__sec h3 {
  margin: 0 0 6px;
  font-family: 'IBM Plex Sans Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--t-0);
}
.ov__sec p { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--t-1); }
.ov__sec strong { color: var(--t-0); }
.ov__sec--credits { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 2px; }
.ov__sec--credits h3 { margin-top: 0; color: var(--t-2); font-size: 11px; letter-spacing: 0.1em; }
.ov__credits { font-size: 11.5px !important; color: var(--t-2) !important; }
.ov__credits a { color: var(--cyan); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
.ov__credits a:hover { border-color: var(--cyan); }
.ov__sec code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 1px 5px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--cyan);
}
.ov__foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
}
.ov__link { color: var(--cyan); text-decoration: none; border-bottom: 1px solid currentColor; }
.ov__link:hover { color: var(--amber); }
.ov__sep { color: var(--t-3); }
.ov__muted { color: var(--t-2); }

/* Responsive collapses (basic) */
@media (max-width: 980px) {
  .side--l { width: 240px; }
  .hdr { grid-template-columns: 220px 1fr; }
  #map { left: 240px; }
  .kv { min-width: 110px; padding: 0 12px; }
  .hdr__info span { display: none; }
  .intro { flex-wrap: wrap; bottom: 64px; }
  .intro__txt { flex: 1 1 100%; }
}
