:root {
  --bg0: #05070b;
  --bg1: #0b111a;
  --panel: rgba(255,255,255,0.035);
  --card: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.12);
  --text: #e6edf7;
  --muted: #a1b0c4;
  --green: #2dd4bf;
  --green2: #14b8a6;
  --shadow: 0 12px 34px rgba(0,0,0,0.45);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: linear-gradient(180deg, var(--bg0), var(--bg1));
  position: relative;
  overflow-x: hidden;
}

/* Subtle background image theme */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url('bg_city.webp') center / cover no-repeat;
  /* User request: background should be clearly visible (~80%) */
  opacity: 0.80;
  filter: blur(0.8px) contrast(1.03) brightness(0.90) saturate(0.98);
  pointer-events: none;
  z-index: -2;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1100px 620px at 18% -10%, rgba(45, 212, 191, 0.10), transparent 55%),
    radial-gradient(900px 520px at 85% 10%, rgba(148, 163, 184, 0.08), transparent 55%),
    /* lighten the dark overlay so the background image shows through */
    linear-gradient(180deg, rgba(5,7,11,0.18), rgba(11,17,26,0.38));
  pointer-events: none;
  z-index: -1;
}
#app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.70);
  backdrop-filter: blur(10px);
}

.brandTitle { font-weight: 800; letter-spacing: 0.3px; font-size: 16px; line-height: 1.1; }
.brandSub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav { display: flex; gap: 8px; }

.sideNav {
  position: sticky;
  top: 0;
  z-index: 25;
  margin: -14px -14px 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(10px);
}

.navSide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.navSide .navBtn {
  width: 100%;
  text-align: center;
  padding: 10px 0;
}

.navBtn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 650;
  letter-spacing: 0.2px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.navBtn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.navBtn.isActive {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  color: var(--text);
}

.status {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
}
.chipLabel { color: var(--muted); font-size: 12px; }
.chipValue { font-size: 13px; font-weight: 650; }

.main {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 1fr 420px;
}

#map {
  height: 100%;
  border-right: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Let the page background show through the empty parts of the viewer */
#map .openseadragon-container,
#map .openseadragon-canvas,
#map canvas {
  background: transparent !important;
}

#panel {
  height: 100%;
  overflow: auto;
  padding: 14px;
}

.view { display: none; }
.view.isActive { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  margin-bottom: 12px;
}

.cardTitle {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: #c9d7ea;
}

.cardHeaderRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.muted { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.list {
  margin: 10px 0 0;
  padding-left: 16px;
}
.list li {
  margin: 8px 0;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  color: #cfe0f5;
  font-size: 12px;
}

.kv {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 10px 12px;
  margin-top: 12px;
}
.k { color: var(--muted); font-size: 12px; padding-top: 2px; }
.v { display: flex; align-items: center; gap: 10px; }

code {
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  color: var(--text);
}

.iconBtn {
  width: 34px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
.iconBtn:hover { background: rgba(255,255,255,0.07); }
.iconBtn:active { transform: translateY(1px); }

.btn {
  margin-top: 14px;
  display: inline-flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btnRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.btnRow .btn {
  margin-top: 0;
  width: auto;
  flex: 1 1 160px;
}

.plainList {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.plainList li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  margin: 8px 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  border-radius: 12px;
}
.plainList code {
  white-space: nowrap;
}

.link {
  color: #cfe0f5;
  text-decoration: none;
  border-bottom: 1px dashed rgba(255,255,255,0.25);
}
.link:hover { border-bottom-color: rgba(255,255,255,0.55); }
.btn:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.20); }
.btn:active { transform: translateY(1px); }

.btnLg { padding: 14px 12px; font-size: 15px; }

.btnGreen {
  background: linear-gradient(180deg, rgba(45,212,191,0.32), rgba(20,184,166,0.22));
  border-color: rgba(45,212,191,0.46);
}
.btnGreen:hover {
  background: linear-gradient(180deg, rgba(45,212,191,0.42), rgba(20,184,166,0.28));
  border-color: rgba(45,212,191,0.68);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.btnDiscord {
  background: linear-gradient(180deg, rgba(88,101,242,0.32), rgba(88,101,242,0.18));
  border-color: rgba(88,101,242,0.55);
}
.btnDiscord:hover {
  background: linear-gradient(180deg, rgba(88,101,242,0.42), rgba(88,101,242,0.24));
  border-color: rgba(88,101,242,0.72);
}


.input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  outline: none;
}
.input::placeholder { color: rgba(168,182,200,0.75); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(10, 15, 22, 0.85);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.toast.isVisible { opacity: 1; }

/* Existing overlays */
.overlay-safehouse {
  background: rgba(45, 212, 191, 0.16);
  border: 3px solid rgba(45, 212, 191, 0.92);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.40), 0 0 18px rgba(45, 212, 191, 0.22);
  box-sizing: border-box;
  border-radius: 6px;
}
.overlay-player {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 210, 80, 0.95);
  border: 1px solid rgba(0,0,0,0.35);
}


.overlay-calib {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: rgba(0,0,0,0.78);
  background: rgba(140, 235, 255, 0.95);
  border: 1px solid rgba(0,0,0,0.35);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 0 14px rgba(140, 235, 255, 0.20);
  pointer-events: none;
  user-select: none;
}

/* Responsive */
@media (max-width: 980px) {
  .header {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
  }
  .status { justify-content: flex-start; }
  .main {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 55vh auto;
  }
  #map { border-right: none; border-bottom: 1px solid var(--border); }
}


/* Charts */
.chartWrap {
  position: relative;
  width: 100%;
  height: 180px;
}
.chartWrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}
.chartEmpty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
  background: rgba(0,0,0,0.18);
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.chartEmpty.isVisible { opacity: 1; }

/* Keep tab buttons at the top of the right panel */
.sideNav {
  position: sticky;
  top: 10px;
  z-index: 10;
  backdrop-filter: blur(10px);
}


/* --- Map wrapper & custom controls --- */
#mapWrap { position: relative; height: 100%; min-height: 0; 
  background: rgba(0,0,0,0.08);
  /* JS sets these so the top-right toggles never overlap the OpenSeadragon navigator (minimap). */
  --navSpace: 0px;
  --navTop: 14px;
}
#map { position: absolute; inset: 0; }

.mapControls {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.mapCtlBtn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 16, 28, 0.65);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  user-select: none;
  backdrop-filter: blur(8px);
}
.mapCtlBtn:hover { border-color: rgba(255,255,255,0.22); }
.mapCtlBtn:active { transform: translateY(1px); }

.mapToggles {
  position: absolute;
  /* Dock to the LEFT of the minimap (navigator). */
  right: calc(var(--navSpace, 0px) + 14px);
  top: var(--navTop, 14px);
  display: flex;
  gap: 10px;
  z-index: 50;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 16, 28, 0.55);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  font-size: 12px;
  color: #cfe0f5;
  user-select: none;
}
.toggle input { accent-color: var(--green); }
.toggleRow { margin-top: 12px; padding: 10px 12px; border-radius: 14px; }
.toggleText { white-space: nowrap; }

/* --- Safehouse groups --- */
.groups { margin-top: 10px; display: grid; gap: 10px; }
.group {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  overflow: hidden;
}
.group > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.group > summary::-webkit-details-marker { display: none; }
.groupTitle { font-weight: 650; color: #d7e6fb; }
.groupMeta { display: inline-flex; gap: 8px; align-items: center; }
.groupList { margin: 0; padding: 6px 12px 10px; list-style: none; display: grid; gap: 8px; }
.groupItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
}
.itemMain { min-width: 0; }
.itemTitle { font-weight: 600; }
.itemSub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.miniBtn {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #dbe9fb;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.miniBtn:hover { border-color: rgba(255,255,255,0.22); }

/* --- Coordinate settings --- */
.detailsCard { margin-top: 12px; }
.detailsSummary { cursor: pointer; font-weight: 650; }
.detailsBody { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 6px; }
.fieldLabel { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.small { font-size: 12px; }

/* --- Map overlays --- */
.overlay-player {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.9);
  background: #fbbf24;
  box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.18);
}

.overlay-safehouse {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 2px solid rgba(57, 217, 138, 0.85);
  background: rgba(57, 217, 138, 0.10);
  box-shadow: 0 0 0 6px rgba(57, 217, 138, 0.08);
}

.osd-overlay { pointer-events: none; }


.overlay-safehousePin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(57, 217, 138, 0.95);
  color: rgba(0,0,0,0.85);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* --- Calibration picker modal (K) --- */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 120;
}
.modal.isVisible { display: grid; place-items: center; }

.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}

.modalDialog {
  position: relative;
  width: min(560px, calc(100vw - 26px));
  max-height: min(72vh, 640px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 16, 28, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modalHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.modalTitle { font-weight: 850; letter-spacing: 0.2px; }
.modalSub { margin-top: 4px; color: var(--muted); font-size: 12px; }

.modalBody { padding: 12px 14px; overflow: auto; }
.modalFooter { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.10); }

.modalList { display: grid; gap: 10px; }
.pickBtn {
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.pickBtn:hover { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.08); }
.pickBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.pickBtn:disabled:hover { border-color: rgba(255,255,255,0.14); background: rgba(255,255,255,0.06); }
.pickBtn.isActive {
  border-color: rgba(57,217,138,0.55);
  background: linear-gradient(180deg, rgba(57,217,138,0.20), rgba(16,185,129,0.10));
}
.pickName { font-weight: 800; letter-spacing: 0.2px; }
.pickMeta { color: var(--muted); font-size: 12px; white-space: nowrap; }


/* Calibration click-capture overlay */
.calib-shield {
  position: absolute;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0);
  cursor: crosshair;
}

/* Calibration backup UI */
.calibBackupRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

#calibImportFile {
  display: none;
}
