/* Nothing to see here — UI */
:root {
  --bg: #0b0e12;
  --panel: rgba(16, 20, 26, 0.92);
  --panel-solid: #12161c;
  --line: #232a33;
  --text: #dfe5ec;
  --dim: #8a94a0;
  --accent: #3d8bff;
  --accent-2: #ffc24d;
  --radius: 10px;
  --header-h: 42px;
  font-size: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
button { font: inherit; cursor: pointer; }

/* ---------- password gate ---------- */
#gate {
  position: fixed; inset: 0; z-index: 1000;
  background: radial-gradient(ellipse at 50% 35%, #141a24 0%, #07090c 75%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease;
}
#gate.gate-out { opacity: 0; pointer-events: none; }
#gate-card {
  text-align: center; padding: 44px 48px;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.6);
  max-width: 92vw;
}
#gate-card h1 { font-size: 24px; font-weight: 600; margin: 14px 0 6px; letter-spacing: .02em; }
#gate-card p { color: var(--dim); margin-bottom: 22px; }
#gate-form { display: flex; gap: 8px; justify-content: center; }
#gate-input {
  background: #0a0d11; border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 8px; width: 200px; font-size: 15px; outline: none;
}
#gate-input:focus { border-color: var(--accent); }
#gate-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 20px; font-weight: 600;
}
#gate-btn:hover { filter: brightness(1.15); }
#gate-error { color: #ff6b6b; margin-top: 14px; min-height: 18px; font-size: 13px; }
#gate-card.shake, .shake #gate-card { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- header ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px;
  background: var(--panel); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#logo-home { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
#logo-home:hover .brand { color: var(--accent); }
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.tagline { color: var(--dim); font-size: 11px; white-space: nowrap; }
#topbar-right { display: flex; align-items: center; gap: 8px; }
#search-input {
  background: #0a0d11; border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 10px; width: 230px; outline: none;
}
#search-input:focus { border-color: var(--accent); }
#topbar button {
  background: #1a212b; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 12px; white-space: nowrap;
}
#topbar button:hover { border-color: var(--accent); }
#scan-btn { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; font-weight: 600; }
#scan-btn:disabled { opacity: .55; cursor: wait; }
#prospect-count {
  background: var(--accent-2); color: #111; border-radius: 9px;
  padding: 0 6px; font-size: 11px; font-weight: 700; margin-left: 3px;
}

/* ---------- map ---------- */
#map { position: fixed; inset: var(--header-h) 0 0 0; }
.maplibregl-popup-content {
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  font-family: inherit;
}
.maplibregl-popup-tip { border-top-color: var(--panel-solid) !important; border-bottom-color: var(--panel-solid) !important; }
.maplibregl-popup-close-button { color: var(--dim); font-size: 16px; right: 4px; top: 2px; }
.maplibregl-ctrl-attrib { background: rgba(11,14,18,.7) !important; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib a { color: #7c8590 !important; font-size: 10px; }

/* popup internals */
.pp-title { font-weight: 700; margin-bottom: 6px; }
.pp-sub { color: var(--dim); font-size: 11px; margin-top: 8px; }
.pp-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  font-size: 12.5px; margin: 6px 0;
}
.pp-grid span { color: var(--dim); }
.pp-flags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.pp-flags span {
  background: #1a212b; border: 1px solid var(--line); border-radius: 20px;
  padding: 2px 8px; font-size: 11px; color: var(--accent-2);
}
.pp-quals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 6px; }
.q-btn {
  background: var(--qc); color: #26313a; border: 1px solid transparent;
  border-radius: 7px; padding: 6px 4px; font-size: 12px; font-weight: 600;
  opacity: .82;
}
.q-btn:hover { opacity: 1; }
.q-btn.active {
  opacity: 1; border-color: #fff;
  box-shadow: inset 0 0 0 1px #fff; font-weight: 800;
}
.pp-coords {
  font-family: Consolas, monospace; font-size: 12px; color: var(--accent-2);
  margin: 4px 0; user-select: all;
}
.pp-actions { display: flex; gap: 6px; }
.pp-btn {
  background: #141a22; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; font-size: 12px; flex: 1;
}
.pp-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pp-btn:hover { filter: brightness(1.2); }

/* ---------- layers panel ---------- */
#layers-panel {
  position: fixed; top: calc(var(--header-h) + 10px); right: 10px; z-index: 400;
  width: 268px; max-height: calc(100vh - var(--header-h) - 60px);
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
#layers-toggle {
  padding: 9px 14px; font-weight: 700; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line);
}
#layers-toggle:hover { color: var(--accent); }
#layers-panel.collapsed #layers-body { display: none; }
#layers-panel.collapsed #layers-toggle { border-bottom: 0; }
#layers-body { overflow-y: auto; padding: 6px 0 10px; }
.layer-group { padding: 6px 14px 2px; }
.group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dim); margin: 6px 0 4px; display: flex; justify-content: space-between; align-items: baseline;
}
.group-title .src { font-size: 10px; text-transform: none; letter-spacing: 0; color: #5b6570; }
.layer-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  cursor: pointer; font-size: 13px;
}
.layer-row:hover .layer-name { color: #fff; }
.layer-row input { accent-color: var(--accent); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.layer-name { color: var(--text); line-height: 1.25; }

/* ---------- prospect drawer ---------- */
#prospect-drawer {
  position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 400;
  width: 300px; background: var(--panel); backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
#prospect-drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700;
}
#clear-prospects {
  background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 6px; padding: 3px 8px; font-size: 11px;
}
#clear-prospects:hover { color: #ff6b6b; border-color: #ff6b6b; }
#prospect-list { flex: 1; overflow-y: auto; padding: 6px; }
#prospect-list .empty { color: var(--dim); text-align: center; padding: 30px 20px; line-height: 1.6; }
.pl-row {
  display: flex; gap: 10px; align-items: center; padding: 7px 8px;
  border-radius: 8px; cursor: pointer;
}
.pl-row:hover { background: #1a212b; }
.pl-score {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #0b0e12; font-size: 13px;
}
.pl-title { font-size: 12.5px; }
.pl-sub { font-size: 11px; color: var(--dim); }
.drawer-legend {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 14px;
  border-top: 1px solid var(--line); font-size: 10.5px; color: var(--dim);
}
.drawer-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- progress + toast ---------- */
#progress {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 600; width: min(440px, 90vw);
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; opacity: 0; pointer-events: none; transition: all .25s;
}
#progress.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#progress-text { font-size: 12.5px; margin-bottom: 8px; color: var(--text); }
#progress-track { height: 6px; background: #1a212b; border-radius: 3px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #6fc3ff); transition: width .3s; }
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(16px);
  z-index: 700; max-width: min(560px, 92vw);
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast { z-index: 950; }

/* ---------- 3D viewer ---------- */
#view3d {
  position: fixed; inset: 0; z-index: 800; background: var(--bg);
  display: none; flex-direction: column;
}
#view3d.open { display: flex; }
#view3d-head {
  height: var(--header-h); display: flex; align-items: center; gap: 16px;
  padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel-solid);
}
#view3d-title { font-weight: 700; }
#exag-wrap { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; margin-left: auto; }
#exag-slider { accent-color: var(--accent); width: 130px; }
#view3d-close {
  background: #1a212b; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 14px;
}
#view3d-close:hover { border-color: #ff6b6b; color: #ff6b6b; }
#map3d { flex: 1; }

/* ---------- hideable side panels ---------- */
#layers-panel, #pins-panel { transition: transform .25s ease, opacity .25s ease; }
#layers-panel.offscreen, #pins-panel.offscreen {
  transform: translateX(calc(100% + 14px)); opacity: 0; pointer-events: none;
}
#layers-hide, #pins-hide {
  float: right; color: var(--dim); padding: 0 4px; cursor: pointer; font-weight: 800;
}
#layers-hide:hover, #pins-hide:hover { color: var(--accent); }
.edge-tab {
  position: fixed; right: 0; z-index: 401;
  background: var(--panel); border: 1px solid var(--line); border-right: 0;
  color: var(--text); border-radius: 8px 0 0 8px; padding: 8px 8px 8px 10px;
  font-size: 13px; display: none;
}
.edge-tab.show { display: block; }
.edge-tab:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- user pins ---------- */
#pin-btn.active { background: #ff5ce1 !important; border-color: #ff5ce1 !important; }
#pins-panel {
  position: fixed; right: 58px; bottom: 36px; z-index: 400;
  width: 252px; max-height: 38vh;
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
#pins-toggle {
  padding: 9px 14px; font-weight: 700; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line);
}
#pins-count {
  background: #ff5ce1; color: #111; border-radius: 9px;
  padding: 0 6px; font-size: 11px; font-weight: 700;
}
#pins-panel.collapsed #pins-list { display: none; }
#pins-panel.collapsed #pins-toggle { border-bottom: 0; }
#pins-list { overflow-y: auto; padding: 4px; }
#pins-list .empty { color: var(--dim); text-align: center; padding: 18px 14px; line-height: 1.6; font-size: 12px; }
.pin-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 8px;
}
.pin-row:hover { background: #1a212b; }
.pin-main { flex: 1; cursor: pointer; }
.pin-title { font-size: 12.5px; }
.pin-sub { font-size: 11px; color: var(--accent-2); font-family: Consolas, monospace; }
.pin-x {
  background: none; border: 0; color: var(--dim); font-size: 12px; padding: 4px;
}
.pin-x:hover { color: #ff6b6b; }
.pin-name {
  background: #0a0d11; border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 3px 6px; font-size: 13px; width: 150px;
}

/* ---------- 3D compass ---------- */
#compass-wrap { display: flex; align-items: center; gap: 4px; }
#compass, #rot-left, #rot-right {
  background: none; border: 0; color: var(--text); font-size: 17px; padding: 2px 5px;
  line-height: 1;
}
#rot-left:hover, #rot-right:hover { color: var(--accent); }
#compass svg { display: block; transition: transform .3s ease; }
#compass:hover circle { stroke: var(--accent); }

/* ---------- LIDAR viewer ---------- */
#lidar {
  position: fixed; inset: 0; z-index: 820; background: #04070c;
  display: none; flex-direction: column;
}
#lidar.open { display: flex; }
#lidar-head {
  height: var(--header-h); display: flex; align-items: center; gap: 14px;
  padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel-solid);
  flex: none;
}
#lidar-title { font-weight: 700; white-space: nowrap; }
#lidar-qual {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: #1a212b; border: 1px solid var(--line); color: var(--dim);
}
#lidar-qual[data-qual="strong"] { background: #a9e6b0; color: #1c2b1e; }
#lidar-qual[data-qual="lead"]   { background: #d9e8a0; color: #2a2b1c; }
#lidar-qual[data-qual="unsure"] { background: #f7e6a1; color: #2b271c; }
#lidar-qual[data-qual="pass"]   { background: #f2b0a9; color: #2b1d1c; }
#lidar-meta { color: var(--dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#lidar-radii { display: flex; gap: 4px; }
#lidar-radii button {
  background: #1a212b; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 10px; font-size: 12px;
}
#lidar-radii button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
#lidar-close {
  background: #1a212b; color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 14px;
}
#lidar-close:hover { border-color: #ff6b6b; color: #ff6b6b; }
#lidar-canvas { flex: 1; min-height: 0; position: relative; }
#lidar-canvas canvas { display: block; }
#lidar-stats {
  position: absolute; top: calc(var(--header-h) + 8px); left: 12px; z-index: 2;
  font-size: 11.5px; color: var(--dim); background: rgba(11,14,18,.72);
  padding: 4px 10px; border-radius: 7px;
}
#lidar-legend {
  position: absolute; bottom: 44px; left: 12px; z-index: 2;
  display: flex; gap: 12px; flex-wrap: wrap;
  background: rgba(11,14,18,.72); border-radius: 8px; padding: 6px 12px;
  font-size: 11px; color: var(--text);
}
#lidar-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
#lidar-help {
  flex: none; padding: 7px 14px; font-size: 11.5px; color: var(--dim);
  border-top: 1px solid var(--line); background: var(--panel-solid); text-align: center;
}
#lidar-loading {
  position: absolute; inset: var(--header-h) 0 32px 0; z-index: 3;
  display: none; align-items: center; justify-content: center;
  background: rgba(4,7,12,.82);
}
#lidar-loading.show { display: flex; }
#lidar-progress {
  font-size: 14px; color: var(--text); background: var(--panel-solid);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px 26px;
  max-width: 78vw; text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .tagline { display: none; }
  #search-input { width: 130px; }
  #layers-panel { width: 230px; }
  #prospect-drawer { width: 260px; }
}
@media (max-width: 560px) {
  .brand { display: none; }
  #topbar-right { gap: 5px; }
  #search-input { width: 110px; }
}
