:root {
  /* GenGIS dark theme: near-black navy surfaces, brand teal accent */
  --bg: #0b1118;
  --bg-2: #10171f;
  --bg-3: #182029;
  --border: #243040;
  --text: #e6ebf2;
  --text-dim: #8d9aad;
  --accent: #1db3a9;
  --accent-strong: #26c9bd;
  --brand-navy: #0c335b;
  --brand-teal: #1db3a9;
  --accent-2: #e4572e;
  --warn: #ffd166;
  --danger: #ff5c5c;
  --radius: 8px;
  --topbar-h: 52px;
  --sidebar-w: 330px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.dim { color: var(--text-dim); }
hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
kbd { background: var(--bg-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; }

#app { display: flex; flex-direction: column; height: 100%; }

/* ---------- top bar ---------- */
#topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--border); flex: 0 0 auto; position: relative; z-index: 2000;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); min-width: 0; }
.brand .logo { height: 26px; width: auto; display: block; }
.project-name {
  background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; width: 180px;
  color: var(--text); font-weight: 600; font-size: 14px;
}
.project-name:hover, .project-name:focus { border-color: var(--border); background: var(--bg); outline: none; }

.search-wrap { position: relative; flex: 1 1 auto; max-width: 620px; display: flex; align-items: center; }
.search-icon { position: absolute; left: 10px; color: var(--text-dim); pointer-events: none; }
#searchInput {
  flex: 1; height: 34px; padding: 0 8px 0 34px; border-radius: 8px 0 0 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); outline: none; min-width: 120px;
}
#searchInput:focus { border-color: var(--accent); }
#searchBtn { border-radius: 0 8px 8px 0; height: 34px; border-left: 0; }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  color: var(--text); line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: #363d4e; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06201e; font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--border); cursor: pointer; color: var(--text); padding: 0;
}
.icon-btn:hover { background: #363d4e; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.mini { width: 26px; height: 26px; background: transparent; border-color: transparent; color: var(--text-dim); }
.icon-btn.mini:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.mini.on { color: var(--text); }
.icon-btn.mini.danger:hover { color: var(--danger); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bg); border: 0; padding: 7px 12px; cursor: pointer; color: var(--text-dim); }
.seg button.active { background: var(--accent); color: #06201e; font-weight: 600; }
.seg.small button { padding: 4px 10px; font-size: 12px; }

select { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; color: var(--text); height: 34px; }
select:focus { outline: none; border-color: var(--accent); }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.45); z-index: 100; min-width: 220px; overflow: hidden;
}
.dropdown.menu { padding: 6px; }
.dropdown.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.dropdown.menu button:hover { background: var(--bg-3); }
#searchResults { left: 0; right: 0; max-height: 360px; overflow: auto; }
.result-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.result-item:last-child { border-bottom: 0; }
.result-item:hover, .result-item.active { background: var(--bg-3); }
.result-item .type { color: var(--text-dim); font-size: 11px; text-transform: capitalize; }
.result-item.empty { color: var(--text-dim); cursor: default; }

/* ---------- main ---------- */
#main { display: flex; flex: 1 1 auto; min-height: 0; }
#mapwrap { position: relative; flex: 1 1 auto; min-width: 0; z-index: 0; }
#map { position: absolute; inset: 0; background: #0f1218; }
#map.mb-crosshair, #map.mb-crosshair .leaflet-interactive { cursor: crosshair !important; }

#toolbar {
  position: absolute; left: 12px; top: 12px; z-index: 1000; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
#toolbar button {
  width: 38px; height: 38px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
#toolbar button svg { width: 22px; height: 22px; }
#toolbar button:hover { background: var(--bg-3); color: var(--text); }
#toolbar button.active { background: var(--accent); color: #06201e; }
#toolbar .sep { height: 1px; background: var(--border); margin: 3px 4px; }

.tool-hint {
  position: absolute; left: 64px; top: 16px; z-index: 1000; background: rgba(27,31,39,.92); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; color: var(--text); pointer-events: none; max-width: 420px;
}

.leaflet-container { font-family: var(--font); }
.leaflet-top.leaflet-right { top: 0; }
.leaflet-bar a { background: var(--bg-2); color: var(--text); border-bottom-color: var(--border); }
.leaflet-bar a:hover { background: var(--bg-3); }
.leaflet-control-attribution { background: rgba(27,31,39,.8) !important; color: var(--text-dim); font-size: 10px; }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-control-scale { margin-right: 12px !important; margin-bottom: 12px !important; }
.leaflet-control-scale-line {
  background: rgba(27,31,39,.85); color: #fff; border-color: #fff; font-size: 11px; line-height: 1.2; padding: 2px 6px 1px;
  text-shadow: 0 0 2px #000;
}
.leaflet-control-scale-line:not(:first-child) { border-top: none; margin-top: -1px; }
.mb-status {
  background: rgba(27,31,39,.85); color: var(--text); padding: 4px 8px; border-radius: 6px; font-size: 11px; font-variant-numeric: tabular-nums;
  margin: 0 0 12px 12px !important; border: 1px solid var(--border);
}
.leaflet-popup-content-wrapper { background: var(--bg-2); color: var(--text); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.leaflet-popup-tip { background: var(--bg-2); }
.leaflet-popup-content { margin: 10px 12px; }
.mb-popup-title { font-weight: 600; margin-bottom: 4px; }
.mb-popup-coords { color: var(--text-dim); font-size: 11px; margin-bottom: 8px; }
.mb-popup-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.leaflet-tooltip.mb-measure-label, .leaflet-tooltip.mb-measure-result {
  background: rgba(27,31,39,.88); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 3px 7px;
  font-size: 11px; box-shadow: none; text-align: center; line-height: 1.3; font-variant-numeric: tabular-nums;
}
.leaflet-tooltip.mb-measure-result { border-color: var(--warn); }
.leaflet-tooltip.mb-measure-label::before, .leaflet-tooltip.mb-measure-result::before { display: none; }
.leaflet-tooltip.mb-name-tip { background: var(--bg-2); color: var(--text); border-color: var(--border); }

.mb-seg-label span {
  display: inline-block; transform: translate(-50%, -50%); background: rgba(27,31,39,.85); color: var(--warn); font-size: 10px;
  padding: 1px 5px; border-radius: 4px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.mb-measure-tip {
  display: none; position: absolute; z-index: 1000; pointer-events: none; background: rgba(27,31,39,.92); color: #fff;
  border: 1px solid var(--warn); border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.35; white-space: nowrap;
}
.mb-measure-tip b { font-size: 14px; }

.mb-pin svg { filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); }
.mb-pin.mb-selected svg, .mb-svg-pin.mb-selected img { filter: drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 2px var(--accent)); }
path.mb-selected { filter: drop-shadow(0 0 3px rgba(29,179,169,.95)); }
.mb-svg-pin img { display: block; pointer-events: none; transform-origin: center; }
.mb-svg-ground.mb-selected { outline: 2px dashed var(--accent); outline-offset: 2px; }
.mb-handle span {
  display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4);
  cursor: move;
}

.pm-text-marker .pm-textarea {
  font-family: var(--font); font-weight: 600; text-shadow: 0 0 2px rgba(0,0,0,.6);
  border: 1px solid transparent; outline: none; resize: none; box-sizing: content-box;
}
.pm-text-marker .pm-textarea:not(.pm-disabled) { border-color: var(--accent); cursor: text; }
.pm-text-marker .pm-textarea.pm-disabled { cursor: pointer; }

/* ---------- sidebar ---------- */
#sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; background: var(--bg-2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
#sidebar.collapsed { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.tabs button {
  flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 4px; cursor: pointer;
  color: var(--text-dim); font-weight: 500; font-size: 12px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panels { flex: 1 1 auto; overflow: auto; min-height: 0; }
.tab-panel { display: none; padding: 12px; }
.tab-panel.active { display: block; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h3, .section h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.section { margin-bottom: 16px; }
.section h3 { margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.row.right { justify-content: flex-end; }
.row label { flex: 0 0 92px; color: var(--text-dim); font-size: 12px; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row input[type="text"], .row input[type="number"], .row select, .row textarea {
  flex: 1 1 auto; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; color: var(--text); height: 32px;
}
.row textarea { height: auto; min-height: 56px; resize: vertical; }
.row input:focus, .row select:focus, .row textarea:focus { outline: none; border-color: var(--accent); }
.row input[type="range"] { flex: 1 1 auto; accent-color: var(--accent); min-width: 0; }
.row input[type="color"] { width: 36px; height: 30px; padding: 0 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }
.row input[type="number"].narrow { flex: 0 0 64px; }
.row .val { flex: 0 0 44px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.row .unit { color: var(--text-dim); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.note { color: var(--text-dim); font-size: 12px; line-height: 1.4; }
.badge { display: inline-block; background: var(--bg-3); border-radius: 10px; padding: 1px 8px; font-size: 11px; color: var(--text-dim); }
.measure-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.measure-box div { display: flex; justify-content: space-between; padding: 2px 0; }
.measure-box span:first-child { color: var(--text-dim); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* layers list */
.layer-list { display: flex; flex-direction: column; gap: 4px; }
.layer-item {
  display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 8px; border: 1px solid transparent; background: var(--bg);
  cursor: pointer;
}
.layer-item.active { border-color: var(--accent); }
.layer-item.hidden-layer .layer-name { color: var(--text-dim); text-decoration: line-through; }
.layer-item .layer-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.layer-item .layer-name input { width: 100%; background: var(--bg-3); border: 1px solid var(--accent); border-radius: 4px; padding: 2px 4px; }
.layer-item .count { color: var(--text-dim); font-size: 11px; margin-right: 2px; }
.layer-item .active-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); margin: 0 4px; flex: 0 0 auto; }
.layer-item.active .active-dot { background: var(--accent); }
.feature-list { margin-top: 10px; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.feature-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 12px; }
.feature-item:last-child { border-bottom: 0; }
.feature-item:hover { background: var(--bg-3); }
.feature-item.selected { background: rgba(29,179,169,.18); }
.feature-item .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.25); }
.feature-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-item .ftype { color: var(--text-dim); font-size: 11px; }

/* svg library */
.svg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.svg-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; position: relative; }
.svg-card:hover, .svg-card.active { border-color: var(--accent); }
.svg-card img { width: 100%; height: 56px; object-fit: contain; background: repeating-conic-gradient(#2c3241 0 25%, #232834 0 50%) 0 0 / 12px 12px; border-radius: 4px; }
.svg-card .name { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.svg-card .del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0; display: none; }
.svg-card:hover .del { display: block; }
.drop-zone { border: 1px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; color: var(--text-dim); margin-bottom: 12px; cursor: pointer; }
.drop-zone.over { border-color: var(--accent); color: var(--text); background: rgba(29,179,169,.08); }

/* poi list */
.poi-list { max-height: 45vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.poi-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border); cursor: pointer; }
.poi-item:last-child { border-bottom: 0; }
.poi-item:hover { background: var(--bg-3); }
.poi-item .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-item .pkind { color: var(--text-dim); font-size: 11px; }
.poi-item .pdist { color: var(--text-dim); font-size: 11px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* toast, modal */
#mb-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: all .2s; z-index: 5000; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 80vw;
}
#mb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 4000; }
.modal-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; max-width: 560px; width: 92vw; max-height: 90vh; overflow: auto; }
.modal-box h2 { margin: 0 0 8px; }
.modal-box h3 { margin: 14px 0 6px; font-size: 13px; }
.modal-box ul { padding-left: 18px; margin: 0; }
.modal-box li { margin-bottom: 4px; }
.kbd-list { line-height: 2; }

@media (max-width: 860px) {
  :root { --sidebar-w: 280px; }
  .project-name { width: 110px; }
  #searchInput { padding-left: 30px; }
  .seg button { padding: 7px 8px; }
}
.sheet-close { display: none; }
@media (max-width: 640px) {
  :root { --topbar-h: auto; }
  #topbar { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 6px; }
  .brand { gap: 6px; }
  .project-name { width: 90px; font-size: 13px; padding: 4px 6px; }
  .search-wrap { order: 3; flex: 1 1 100%; max-width: none; }
  .brand { flex: 1 1 auto; }
  .topbar-right { order: 2; flex: 1 1 100%; margin-left: 0; gap: 6px; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; scrollbar-width: none; padding-bottom: 2px; }
  .topbar-right::-webkit-scrollbar { display: none; }
  .seg button { padding: 7px 8px; font-size: 12px; }
  #basemapSelect { max-width: 120px; }
  #main { position: relative; }
  /* side panel becomes a bottom sheet */
  #sidebar { position: absolute; left: 0; right: 0; bottom: 0; top: auto; width: 100%; height: 56%; max-height: 70vh; border-left: 0; border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0; z-index: 30; box-shadow: 0 -8px 24px rgba(0,0,0,.5); padding-bottom: env(safe-area-inset-bottom); }
  .tabs { overflow-x: auto; scrollbar-width: none; position: relative; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: 12px 10px; }
  .sheet-close { display: flex; align-items: center; justify-content: center; flex: 0 0 36px; height: 40px; border: 0; background: transparent; color: var(--text-dim); font-size: 14px; }
  .tab-panel { padding: 10px; }
  /* toolbar: compact column that fits a phone's height */
  #toolbar { left: 8px; top: 8px; padding: 4px; gap: 2px; }
  #toolbar button { width: 36px; height: 36px; }
  #toolbar button svg { width: 20px; height: 20px; }
  .tool-hint { left: 54px; top: 10px; max-width: calc(100vw - 70px); font-size: 11px; }
  .leaflet-control-zoom { display: none; }
  .mb-status { font-size: 10px; margin: 0 0 8px 8px !important; }
  .mb-scale { margin: 0 8px 8px 0 !important; }
  .leaflet-control-attribution { max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row label { flex: 0 0 80px; }
  .form-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .form-grid label { margin-top: 6px; }
  .modal-box { padding: 14px; max-height: 92vh; }
  .btn, .icon-btn { min-height: 36px; }
  .layer-node .icon-btn.mini, .obj-item .icon-btn.mini { width: 28px; height: 28px; }
  #presentBar { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); right: 10px; }
}
@media (hover: none) and (pointer: coarse) {
  /* touch: bigger hit areas, no hover-only affordances */
  .svg-card .del { display: block; }
  .layer-item, .obj-item { padding-top: 6px; padding-bottom: 6px; }
  .mb-ctx li { padding: 10px 12px; }
}

/* ---------- two-block scale bar ---------- */
.mb-scale { margin: 0 12px 12px 0 !important; color: #fff; font-size: 11px; font-weight: 600; line-height: 1; text-shadow: 0 0 2px #000, 0 0 4px #000, 0 1px 3px rgba(0,0,0,.95), 0 0 1px #000; }
.mb-scale-bar { display: flex; height: 8px; border: 1.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(0,0,0,.85), 0 1px 4px rgba(0,0,0,.6); background: rgba(27,31,39,.55); }
.mb-scale-bar span { flex: 1 1 50%; }
.mb-scale-bar span:first-child { background: #fff; }
.mb-scale-labels { position: relative; height: 13px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.mb-scale-labels span { position: absolute; top: 0; white-space: nowrap; background: rgba(11,17,24,.62); padding: 1px 4px; border-radius: 3px; }
.mb-scale-labels span:nth-child(1) { left: 0; }
.mb-scale-labels span:nth-child(2) { left: 50%; transform: translateX(-50%); }
.mb-scale-labels span:nth-child(3) { right: 0; }

/* ---------- move tool ---------- */
#map.mb-move .leaflet-interactive, #map.mb-move .mb-svg-pin, #map.mb-move .pm-text-marker { cursor: move !important; }

/* ---------- text format controls ---------- */
.tog-group { display: inline-flex; gap: 4px; }
.tog { width: 30px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; }
.tog:hover { color: var(--text); }
.tog.on { background: var(--accent); border-color: var(--accent); color: #06201e; }

/* ---------- presenter mode ---------- */
body.presenting #topbar, body.presenting #toolbar, body.presenting #sidebar, body.presenting #toolHint, body.presenting .mb-status,
body.presenting .mb-measure-tip { display: none !important; }
#presentBar {
  position: fixed; top: 10px; right: 10px; z-index: 3000; display: none; align-items: center; gap: 8px;
  background: rgba(27,31,39,.9); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 12px;
  opacity: .45; transition: opacity .2s; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
#presentBar:hover { opacity: 1; }
body.presenting #presentBar { display: flex; }

/* ---------- context menu ---------- */
.mb-ctx {
  position: fixed; z-index: 4500; list-style: none; margin: 0; padding: 5px; min-width: 210px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.5); font-size: 13px;
}
.mb-ctx li { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.mb-ctx li:hover { background: var(--bg-3); }
.mb-ctx li.disabled { opacity: .4; cursor: default; }
.mb-ctx li.disabled:hover { background: transparent; }
.mb-ctx li.danger { color: var(--danger); }
.mb-ctx li.sep { height: 1px; padding: 0; margin: 4px 6px; background: var(--border); cursor: default; }
.mb-ctx li.sep:hover { background: var(--border); }
.mb-ctx .lbl { flex: 1 1 auto; }
.mb-ctx .hint { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.mb-ctx .arrow { color: var(--text-dim); }
.mb-ctx ul.sub { display: none; position: absolute; left: 100%; top: -5px; margin-left: 2px; }
.mb-ctx li.has-sub:hover > ul.sub { display: block; }

/* ---------- API settings dialog ---------- */
.modal-box.wide { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px 10px; align-items: center; }
.form-grid label { color: var(--text-dim); font-size: 12px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; color: var(--text); height: 32px; }
.form-grid textarea { height: auto; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: var(--accent); }
.prov-list { display: flex; flex-direction: column; gap: 6px; }
.prov-item { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.prov-item .pname { font-weight: 500; }
.badge.warn { color: var(--warn); }

/* ---------- layers tree ---------- */
.layer-tree { display: flex; flex-direction: column; gap: 6px; }
.layer-node { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.layer-node.active { border-color: var(--accent); }
.layer-node .layer-item { border: 0; border-radius: 0; background: var(--bg-3); padding: 4px 6px 4px 2px; gap: 2px; }
.layer-node.active .layer-item { background: rgba(29,179,169,.16); }
.layer-node .chev { width: 20px; height: 22px; border: 0; background: transparent; color: var(--text-dim); cursor: pointer; padding: 0; font-size: 12px; transition: transform .15s; }
.layer-node .chev.closed { transform: rotate(-90deg); }
.layer-node .active-dot { margin: 0 4px 0 0; }
.obj-list { padding: 3px 4px 3px 10px; display: flex; flex-direction: column; gap: 1px; }
.obj-empty { color: var(--text-dim); font-size: 11px; padding: 4px 8px 5px; }
.obj-item { display: flex; align-items: center; gap: 4px; padding: 2px 2px 2px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; border-left: 2px solid transparent; }
.obj-item:hover { background: var(--bg-3); }
.obj-item.selected { background: rgba(29,179,169,.18); border-left-color: var(--accent); }
.obj-item.obj-hidden .fname { color: var(--text-dim); text-decoration: line-through; }
.obj-item .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.25); }
.obj-item .fname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-item .fname input { width: 100%; background: var(--bg-3); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; font-size: 12px; }
.obj-item .icon-btn.mini, .layer-node .icon-btn.mini { width: 22px; height: 22px; }
.obj-item .icon-btn.mini svg, .layer-node .icon-btn.mini svg { width: 14px; height: 14px; }
.obj-item .icon-btn.mini:disabled { opacity: .25; }

/* ---------- FAA / data layers panel ---------- */
.data-item { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.data-item.on { border-color: rgba(29,179,169,.6); }
.data-item .dname { font-weight: 500; }
.data-item .icon-btn.mini { position: absolute; top: 6px; right: 6px; }
.data-item .legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 2px 23px; font-size: 11px; color: var(--text-dim); }
.data-item .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(255,255,255,.25); }
.data-item .note { margin: 2px 0 0 23px; }
.data-item .dstatus { margin: 4px 0 0 23px; font-size: 11px; color: var(--text-dim); }
.data-item .dstatus.err { color: var(--warn); }
.mb-datatable { border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.mb-datatable td { padding: 2px 6px 2px 0; vertical-align: top; }
.mb-datatable td:first-child { color: var(--text-dim); white-space: nowrap; }
.tabs button { padding: 10px 2px; }

/* sub-element toggles inside a dataset */
.data-item .subsets { display: flex; flex-wrap: wrap; gap: 3px 10px; margin: 5px 0 2px 23px; font-size: 11px; color: var(--text); align-items: center; }
.data-item .subsets label.sub { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.data-item .subsets label.sub.off { color: var(--text-dim); text-decoration: line-through; }
.data-item .subsets input { accent-color: var(--accent); width: 13px; height: 13px; margin: 0; }
.data-item .subsets i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(255,255,255,.25); }
.data-item .sub-actions { flex: 1 0 100%; color: var(--text-dim); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 11px; }
button.link:hover { text-decoration: underline; }

.overlay-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; }

/* ---------- offline areas ---------- */
.area-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; margin-bottom: 6px; }
.area-head { display: flex; align-items: center; gap: 8px; }
.area-head .aname { font-weight: 500; flex: 1; }
.progress { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.warn { color: var(--warn); }

/* ---------- on-map name labels ---------- */
.mb-name-label-wrap { overflow: visible !important; }
.mb-name-label {
  position: absolute; white-space: nowrap; background: rgba(27,31,39,.86); color: #fff; padding: 1px 7px; border-radius: 4px;
  border: 1px solid rgba(255,255,255,.22); font-weight: 600; line-height: 1.35; pointer-events: none;
}

/* ---------- snap indicator ---------- */
.leaflet-tooltip.mb-snap-tip { background: rgba(27,31,39,.9); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 4px; padding: 1px 6px; font-size: 10px; box-shadow: none; }
.leaflet-tooltip.mb-snap-tip::before { display: none; }

.brand-name { font-weight: 700; font-size: 15px; color: var(--text); letter-spacing: .02em; }
.brand-name sup { font-size: 10px; color: var(--accent); }

/* ---------- startup splash ---------- */
#splash { position: fixed; inset: 0; z-index: 9000; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; transition: opacity .35s; }
#splash img { width: min(46vw, 260px); height: auto; }
#splash .ver { color: var(--text-dim); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
#splash.hide { opacity: 0; pointer-events: none; }
/* "a new version is ready" notice */
#mb-update {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 8000; display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 13px; max-width: calc(100vw - 24px);
}
.about-logo { width: 72px; height: auto; float: right; margin: 0 0 8px 12px; }

/* ---------- airport frequencies in popups ---------- */
.mb-freqs { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.mb-freq-table { border-collapse: collapse; font-size: 12px; width: 100%; font-variant-numeric: tabular-nums; }
.mb-freq-table td { padding: 2px 6px 2px 0; vertical-align: top; }
.mb-freq-table .ft { color: var(--text-dim); white-space: nowrap; }
.mb-freq-table .fd { color: var(--text); }
.mb-freq-table .fm { text-align: right; font-weight: 600; color: var(--accent-strong); white-space: nowrap; }
.mb-freq-foot { color: var(--text-dim); font-size: 10.5px; margin-top: 4px; line-height: 1.35; }
.mb-extra { margin-top: 8px; font-size: 12px; }

.measure-box .alt { color: var(--text-dim); font-size: 11px; margin-left: 6px; }
.measure-box div span:last-child { text-align: right; }

/* ---------- busy indicator (under the coordinates readout) ---------- */
.mb-busy { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.mb-busy.hidden { display: none; }
.mb-busy .spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(29,179,169,.25); border-top-color: var(--accent); animation: mb-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes mb-spin { to { transform: rotate(360deg); } }

/* ---------- data sources panel ---------- */
.ds-tools { gap: 6px; }
.ds-tools input[type="search"] { flex: 1 1 auto; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; color: var(--text); height: 32px; }
.ds-tools input[type="search"]:focus { outline: none; border-color: var(--accent); }
.ds-tools select { flex: 0 0 auto; height: 32px; }
.ds-source { margin-bottom: 14px; }
.ds-source-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 6px; }
.ds-source-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text); }
.ds-source-head h3 a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--text-dim); }
.ds-source .section { margin-bottom: 10px; }
.ds-source .section h3 { font-size: 11px; }
/* chart-style data icons */
.mb-data-icon { background: transparent; border: 0; }
.mb-data-icon svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }

/* ---------- identify popup (all features under a click) ---------- */
.mb-identify details.mb-ident { border-top: 1px solid var(--border); padding: 4px 0; }
.mb-identify details.mb-ident:first-of-type { border-top: 0; }
.mb-identify details.mb-ident:first-of-type > summary { margin-right: 14px; } /* clear the popup's close button */
.mb-identify summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; padding: 3px 4px; border-radius: 4px; }
.mb-identify summary::-webkit-details-marker { display: none; }
.mb-identify summary::before { content: '▸'; color: var(--text-dim); font-size: 10px; flex: 0 0 auto; }
.mb-identify details[open] > summary::before { content: '▾'; }
.mb-identify details:hover > summary { background: rgba(255,209,102,.14); }
.mb-ident-ds { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.mb-ident-label { font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-identify .mb-datatable { margin: 2px 0 4px 18px; }
.mb-identify .mb-freqs { margin-left: 18px; }
.mb-ident-more { font-size: 11px; padding: 4px 4px 0; border-top: 1px solid var(--border); }
.mb-data-icon.mb-data-hl svg { filter: drop-shadow(0 0 4px #ffd166) drop-shadow(0 0 2px #ffd166); transform: scale(1.25); }

/* ---------- live air traffic (ADS-B) ---------- */
.mb-ac { background: transparent; border: 0; }
.mb-ac-rot { width: 100%; height: 100%; color: #dfe4ea; }
.mb-ac-rot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mb-ac-rot svg path, .adsb-types svg path { fill: currentColor; stroke: #0b1118; stroke-width: 1.5; stroke-linejoin: round; paint-order: stroke; }
.mb-ac-rot svg path.rotor-bg, .adsb-types svg path.rotor-bg { fill: none; stroke: #0b1118; stroke-width: 3.6; stroke-linecap: round; }
.mb-ac-rot svg path.rotor, .adsb-types svg path.rotor { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; paint-order: normal; }
.mb-ac.stale { opacity: .45; }
.mb-ac.sel .mb-ac-rot { filter: drop-shadow(0 0 3px #ffd166) drop-shadow(0 0 2px #ffd166); }
.mb-ac-label {
  display: none; position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 3px; white-space: nowrap; pointer-events: none;
  font-size: 10.5px; font-weight: 600; line-height: 1; color: #fff; text-shadow: 0 0 2px #000, 0 0 3px #000, 0 1px 2px #000;
}
.leaflet-mb-adsb-pane.labels .mb-ac-label, .mb-ac.sel .mb-ac-label { display: block; }
/* glide between position reports; switched off while the map zooms */
.leaflet-mb-adsb-pane.smooth .mb-ac { transition: transform 1s linear; } /* duration is set per icon to its source's refresh rate */
.mb-alt-legend {
  width: 250px; max-width: calc(100vw - 90px); margin: 0 12px 8px 0 !important; pointer-events: none;
  background: rgba(27,31,39,.85); border: 1px solid var(--border); border-radius: 6px; padding: 5px 14px 4px; font-size: 10px; color: var(--text);
}
@media (max-width: 640px) { .mb-alt-legend { margin: 0 8px 14px 0 !important; } } /* clear the coordinates box on phones */
.mb-alt-legend .ttl { color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.mb-alt-legend .scale, .mb-alt-legend .ticks { display: flex; gap: 6px; align-items: center; }
.mb-alt-legend .scale span { height: 8px; border-radius: 2px; }
.mb-alt-legend .gnd { flex: 0 0 24px; text-align: center; }
.mb-alt-legend .bar, .mb-alt-legend .axis { flex: 1 1 auto; }
.mb-alt-legend .ticks { margin-top: 2px; height: 12px; font-variant-numeric: tabular-nums; }
.mb-alt-legend .axis { position: relative; height: 12px; }
.mb-alt-legend .axis i { position: absolute; top: 0; transform: translateX(-50%); font-style: normal; white-space: nowrap; }
.data-item .adsb-row { margin: 6px 0 0 23px; }
.data-item .adsb-row label { flex: 0 0 52px; }
.data-item .dname a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--text-dim); }
.data-item.adsb-display .subsets, .data-item.adsb-display .note, .data-item.adsb-display .adsb-row { margin-left: 0; }
.data-item.adsb-display .adsb-row input { height: 30px; }
.adsb-types svg { width: 15px; height: 15px; color: var(--text); overflow: visible; }
#adsbFindOut .mb-datatable { margin: 4px 0; }
.mb-ac-info .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; border: 1px solid rgba(255,255,255,.3); }
.mb-ac-info .warn { color: var(--warn); font-weight: 600; }
.mb-ac-look { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.mb-ac-look:empty { display: none; }
.mb-ac-links { margin-top: 6px; font-size: 11px; }
