* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #map { width: 100%; height: 100%; }
.maplibregl-canvas { cursor: url('../img/crosshair.svg') 16 16, crosshair !important; }

#status {
  position: absolute; top: 10px; left: 10px; z-index: 10;
  background: rgba(0,0,0,.65); color: #fff;
  font: 12px/1.5 monospace; padding: 8px 12px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
#status span { white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px;
       border-radius: 50%; margin-right: 5px; }
.green  { background: #2ecc71; }
.red    { background: #e74c3c; }
.yellow { background: #f1c40f; }

#adapters {
  position: absolute; bottom: 10px; right: 10px; z-index: 10;
  background: rgba(0,0,0,.65); color: #fff;
  font: 12px/1.6 monospace; padding: 8px 12px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 2px;
}

/* ── Legacy #pip shell kept in HTML — suppress it ───────────────────────── */
#pip { display: none !important; }

/* ── Camera PiP windows (created dynamically by camera.js) ──────────────── */
.pip {
  position: fixed; z-index: 20;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
  cursor: move; user-select: none;
}
.pip video {
  width: 100%; height: 100%;
  display: block; object-fit: contain; background: #111;
}
.pip-name {
  position: absolute; bottom: 8px; left: 8px;
  color: #fff; font: 11px/1 monospace;
  text-shadow: 0 1px 4px #000, 0 1px 4px #000;
  pointer-events: none;
}
.pip-close {
  position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font: bold 14px/18px sans-serif;
  text-align: center; cursor: pointer; padding: 0;
}
.pip-close:hover { background: rgba(200,50,50,.75); }
.pip-resize {
  position: absolute; width: 16px; height: 16px; z-index: 1;
}
.pip-resize-nw { top: 0;    left: 0;   cursor: nwse-resize; }
.pip-resize-ne { top: 0;    right: 0;  cursor: nesw-resize; }
.pip-resize-sw { bottom: 0; left: 0;   cursor: nesw-resize; }
.pip-resize-se { bottom: 0; right: 0;  cursor: nwse-resize; }

/* ── Track detail panel (slides in/out from the right edge) ──────────────────── */
#track-popup {
  position: fixed; top: 50%; right: 0; z-index: 25;
  width: 220px;
  transform: translateY(-50%) translateX(100%);
  transition: transform 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
  background: rgba(10,10,10,.88); color: #fff;
  font: 12px/1.7 monospace; padding: 14px 16px;
  border-radius: 8px 0 0 8px;
  border: 1px solid rgba(255,255,255,.15); border-right: none;
  box-shadow: -4px 0 24px rgba(0,0,0,.60);
}
#track-popup.visible {
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

/* ── PiP track info overlay (shown when camera is linked to a track) ─────────── */
.pip-track-overlay {
  position: absolute; top: 0; left: 0; right: 0;
  background: transparent;
  color: #fff; font: 9px/1.5 monospace; padding: 5px 8px;
  pointer-events: none; display: none;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.pip-track-overlay.visible { display: block; }
.pip-track-overlay .popup-title { font-weight: bold; font-size: 10px; margin-bottom: 2px; }
.pip-track-overlay .popup-row   { display: flex; gap: 4px; }
.pip-track-overlay .popup-label { color: rgba(255,255,255,.65); }
.pip-track-overlay .popup-pts   { font-size: 8px; color: #f1c40f; }
#track-popup .popup-title { font-weight: bold; margin-bottom: 6px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.10); padding-bottom: 6px; }
#track-popup .popup-row   { display: flex; justify-content: space-between; gap: 8px; }
#track-popup .popup-label { color: rgba(255,255,255,.50); }
#track-popup .popup-pts   { font-size: 10px; font-weight: normal; color: #f1c40f; }

/* ── Zone panel ──────────────────────────────────────────────────────────────── */
#zone-toggle {
  position: absolute; top: 10px; right: 10px; z-index: 20;
  background: rgba(0,0,0,.65); color: #fff;
  font: 12px monospace; padding: 6px 12px; border-radius: 6px;
  border: none; cursor: pointer; white-space: nowrap;
}
#zone-toggle:hover { background: rgba(0,0,0,.85); }

#zone-panel {
  position: absolute; top: 42px; right: 10px; z-index: 20;
  width: 240px;
  background: rgba(20,20,20,.92); color: #fff;
  font: 12px/1.5 monospace; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
  display: none; flex-direction: column; overflow: hidden;
}
#zone-panel.visible { display: flex; }

#zone-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
#zone-panel-header span { font-weight: bold; }

#zone-new-btn {
  background: #2ecc71; color: #000; border: none;
  padding: 3px 8px; border-radius: 4px; cursor: pointer; font: inherit;
}
#zone-new-btn:hover { background: #27ae60; }

#zone-list { max-height: 260px; overflow-y: auto; padding: 4px 0; }

.zone-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,.05);
}
.zone-row:last-child { border-bottom: none; }
.zone-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.zone-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-row.inactive .zone-name { opacity: 0.4; }
.zone-badge {
  font-size: 9px; padding: 1px 4px; border-radius: 3px;
  background: rgba(255,255,255,.15); flex-shrink: 0;
}
.zone-toggle-btn, .zone-del-btn {
  background: none; border: 1px solid rgba(255,255,255,.2);
  color: #ccc; padding: 1px 5px; border-radius: 3px;
  cursor: pointer; font: 10px monospace; flex-shrink: 0;
}
.zone-toggle-btn:hover { background: rgba(255,255,255,.1); }
.zone-del-btn { color: #e74c3c; border-color: #e74c3c; }
.zone-del-btn:hover { background: rgba(231,76,60,.15); }
.zone-empty { padding: 12px; color: #666; text-align: center; }

#zone-create-form {
  padding: 10px 12px; display: none; flex-direction: column; gap: 8px;
  border-top: 1px solid rgba(255,255,255,.1);
}
#zone-create-form.visible { display: flex; }
#zone-name-input {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
  color: #fff; padding: 4px 8px; border-radius: 4px; font: inherit; outline: none;
}
#zone-name-input:focus { border-color: #2ecc71; }
.zone-type-row { display: flex; gap: 14px; }
.zone-type-row label { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.zone-relative-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #aaa; }
.zone-relative-row input { cursor: pointer; }
.zone-relative-row.no-fix { opacity: 0.4; pointer-events: none; }
.zone-form-btns { display: flex; gap: 6px; }
#zone-start-draw {
  flex: 1; background: #2ecc71; color: #000; border: none;
  padding: 4px 0; border-radius: 4px; cursor: pointer; font: inherit;
}
#zone-start-draw:disabled { background: #555; color: #888; cursor: default; }
#zone-cancel-btn {
  background: none; border: 1px solid rgba(255,255,255,.2);
  color: #ccc; padding: 4px 8px; border-radius: 4px; cursor: pointer; font: inherit;
}

#draw-hint {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: rgba(0,0,0,.78); color: #fff;
  font: 12px monospace; padding: 6px 14px; border-radius: 6px;
  pointer-events: none; display: none; white-space: nowrap;
}
#draw-hint.visible { display: block; }

/* ── Right-side map controls (compass + follow) ──────────────────────────────── */
#map-controls {
  position: absolute; top: 46px; right: 10px; z-index: 15;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#compass {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(0,0,0,.65); box-shadow: 0 2px 8px rgba(0,0,0,.5);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1px;
  user-select: none;
}
#compass:hover { background: rgba(0,0,0,.85); }
#compass-mode {
  font: 7px/1 monospace; color: rgba(255,255,255,.55);
  pointer-events: none; margin-top: 1px;
}
#compass.hdg-up #compass-mode { color: #f1c40f; }
#follow-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.65); border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  user-select: none;
}
#follow-btn:hover { background: rgba(0,0,0,.85); }
#follow-btn.active { background: rgba(46,204,113,.75); }
#north-label {
  display: none; position: absolute; z-index: 15; pointer-events: none;
  color: #fff; font: bold 13px monospace;
  text-shadow: 0 0 4px #000, 0 0 4px #000;
}

/* ── Action ring ──────────────────────────────────────────────────────────── */
#action-ring {
  position: absolute;
  width: 0; height: 0;
  z-index: 24;
  pointer-events: none;
}
.ring-circle {
  position: absolute;
  width: 120px; height: 120px;
  left: -60px; top: -60px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#action-ring.visible .ring-circle { opacity: 1; }

.ring-btn {
  position: absolute;
  width: 36px; height: 36px;
  border-radius: 50%;
  background-color: rgba(20,20,30,0.85);
  border: 1.5px solid rgba(255,255,255,0.28);
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px 20px;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s;
  pointer-events: none;
}
#action-ring.visible .ring-btn {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}
.ring-camera { background-image: url('../img/camera.svg'); }

/* Camera name label — appears below each ring button */
.ring-label {
  position: absolute;
  transform: translate(-50%, 0);
  color: #fff;
  font: 8px/1.2 monospace;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 4px #000, 0 0 4px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#action-ring.visible .ring-label { opacity: 1; }

/* Button positions and label positions are set in JS (ring.js buildButtons) */
