:root{
  --panel: rgba(15, 20, 16, .78);
  --panel-line: rgba(255,255,255,.14);
  --ink: #f2f4ef;
  --ink-dim: #b9c2b4;
  --accent: #ffd166;
}
*{ box-sizing: border-box; }
html, body{ margin:0; height:100%; overflow:hidden; background:#0b0f0c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); }
#map{ position:absolute; inset:0; }

/* ---------- title card ---------- */
#titlecard{
  position:absolute; top:14px; left:14px; z-index:10;
  max-width: 300px; padding:14px 16px 12px;
  background:var(--panel); border:1px solid var(--panel-line); border-radius:14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
#titlecard h1{ margin:0; font-size:19px; line-height:1.15; letter-spacing:.2px; }
#titlecard h1 span{ display:block; font-size:12px; font-weight:600; color:var(--accent);
  text-transform:uppercase; letter-spacing:1.6px; margin-top:3px; }
#tagline{ margin:8px 0 10px; font-size:12.5px; color:var(--ink-dim); line-height:1.45; }
#unitfacts{ margin:8px 0 10px; font-size:12.5px; color:var(--ink-dim); line-height:1.45; }

#switcher{
  display:flex; align-items:center; gap:7px; width:100%;
  font:600 12.5px/1 inherit; font-family:inherit; color:var(--ink);
  background:rgba(255,255,255,.06); border:1px solid var(--panel-line);
  border-radius:10px; padding:9px 11px; cursor:pointer; margin-bottom:10px;
}
#switcher:hover{ border-color:rgba(255,255,255,.35); }
#switcher svg{ width:14px; height:14px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round; flex:none; }
#switcher span{ flex:1; text-align:left; }
#switcher .chev{ width:12px; height:12px; opacity:.7; }
#switcher[aria-expanded="true"] .chev{ transform:rotate(180deg); }

#unitmenu{
  margin:-4px 0 10px; max-height:min(46vh, 420px); overflow-y:auto;
  border:1px solid var(--panel-line); border-radius:10px;
  background:rgba(0,0,0,.25);
}
.menuhead{
  font-size:10px; font-weight:700; letter-spacing:1.4px; text-transform:uppercase;
  color:var(--accent); padding:9px 11px 4px;
}
.menuitem{
  display:flex; align-items:baseline; gap:8px; width:100%;
  font:500 12.5px/1.2 inherit; font-family:inherit; color:var(--ink);
  background:none; border:none; text-align:left; padding:7px 11px; cursor:pointer;
}
.menuitem:hover{ background:rgba(255,255,255,.08); }
.menuitem span{ flex:1; }
.menuitem em{ font-style:normal; font-size:10.5px; color:var(--ink-dim); flex:none; }
.menuitem.current{ color:var(--accent); }
.menuitem.current em{ color:var(--accent); opacity:.75; }

#cardlinks{ display:flex; gap:6px; flex-wrap:wrap; }
#cardlinks a{
  display:inline-flex; align-items:center; gap:5px;
  font-size:11.5px; font-weight:600; color:var(--ink-dim); text-decoration:none;
  padding:4px 9px; border:1px solid var(--panel-line); border-radius:999px;
}
#cardlinks a:hover{ color:var(--ink); border-color:rgba(255,255,255,.35); }
#cardlinks svg{ width:13px; height:13px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }

/* ---------- legend chips ---------- */
#legend{
  position:absolute; left:14px; bottom:14px; z-index:10;
  display:flex; gap:6px; flex-wrap:wrap; max-width:min(520px, calc(100vw - 28px));
}
.chip{
  display:inline-flex; align-items:center; gap:6px;
  font: 600 12px/1 inherit; font-family:inherit; color:var(--ink);
  background:var(--panel); border:1px solid var(--panel-line); border-radius:999px;
  padding:7px 12px; cursor:pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chip svg{ width:14px; height:14px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.chip:hover{ border-color:rgba(255,255,255,.4); }
.chip:not(.on){ color:var(--ink-dim); opacity:.55; }
.chip:not(.on) svg{ opacity:.6; }

/* ---------- view buttons ---------- */
#viewbtns{ position:absolute; right:14px; bottom:38px; z-index:10;
  display:flex; flex-direction:column; gap:6px; align-items:flex-end; }
.viewbtn{
  display:inline-flex; align-items:center; gap:7px;
  font:600 12px/1 inherit; font-family:inherit; color:var(--ink);
  background:var(--panel); border:1px solid var(--panel-line); border-radius:999px;
  padding:8px 13px; cursor:pointer;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.viewbtn:hover{ border-color:rgba(255,255,255,.4); }
.viewbtn svg{ width:13px; height:13px; fill:currentColor; stroke:none; }
#btn-top svg, #btn-base svg{ fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }

/* ---------- hint ---------- */
#hint{
  position:absolute; left:50%; bottom:78px; transform:translateX(-50%); z-index:9;
  font-size:12px; color:var(--ink); background:var(--panel);
  border:1px solid var(--panel-line); border-radius:999px; padding:7px 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events:none; opacity:0; transition:opacity .8s;
}
#hint.show{ opacity:1; }

/* ---------- maplibre chrome ---------- */
.maplibregl-ctrl-top-right{ top:10px; right:10px; }
.maplibregl-ctrl-group{
  background:var(--panel) !important; border:1px solid var(--panel-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow:0 4px 16px rgba(0,0,0,.3) !important;
}
.maplibregl-ctrl-group button{ background:transparent !important; }
.maplibregl-ctrl-group button + button{ border-top:1px solid var(--panel-line) !important; }
.maplibregl-ctrl button .maplibregl-ctrl-icon{ filter: invert(1) hue-rotate(180deg); }
.maplibregl-ctrl-attrib{
  background:rgba(15,20,16,.6) !important; color:#aab3a6;
  font-size:10px; border-radius:8px 0 0 0;
}
.maplibregl-ctrl-attrib a{ color:#cdd6c8; }

.maplibregl-popup{ z-index:11; }
.maplibregl-popup-content{
  background:var(--panel); color:var(--ink);
  border:1px solid var(--panel-line); border-radius:12px;
  padding:11px 14px; box-shadow:0 8px 30px rgba(0,0,0,.4);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size:13px;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{ border-top-color:rgba(15,20,16,.85); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip{ border-bottom-color:rgba(15,20,16,.85); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip{ border-right-color:rgba(15,20,16,.85); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip{ border-left-color:rgba(15,20,16,.85); }
.maplibregl-popup-close-button{ color:var(--ink-dim); font-size:16px; padding:2px 7px; }
.popup-kind{ font-size:10px; font-weight:700; letter-spacing:1.2px; text-transform:uppercase;
  color:var(--accent); margin:0 12px 2px 0; }
.popup-name{ font-weight:700; font-size:14px; margin:0; }
.popup-desc{ margin:5px 0 0; color:var(--ink-dim); font-size:12px; line-height:1.4; }

/* ---------- small screens ---------- */
@media (max-width:640px){
  #titlecard{ max-width:230px; padding:11px 13px 10px; }
  #titlecard h1{ font-size:16px; }
  #tagline{ display:none; }
  #legend{ bottom:12px; gap:5px; }
  .chip{ padding:6px 10px; font-size:11px; }
  #viewbtns{ bottom:104px; }
  .viewbtn span{ display:none; }
  .viewbtn{ padding:10px; border-radius:50%; }
  #hint{ bottom:118px; width:max-content; max-width:86vw; }
}
