* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  color: #e6edf3;
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
}

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 10px;
  background: rgba(22, 27, 34, 0.95);
  border-bottom: 1px solid #30363d;
  z-index: 10;
  min-height: 44px;
}

#logo { font-weight: 700; color: #d4a017; letter-spacing: 0.5px; }
#appVersion { font-weight: 400; font-size: 11px; color: #8b949e; letter-spacing: 0; }

#topbar select, #topbar button {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
  min-height: 34px;
}

#topbar button:hover { background: #30363d; }
#topbar label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
#topbar input[type="checkbox"] { width: 18px; height: 18px; }

#status { margin-left: auto; font-size: 12px; }
.status-ok { color: #3fb950; }
.status-wait { color: #d29922; }
.status-err { color: #f85149; }

#codeCopy {
  display: inline-block;
  cursor: pointer;
}

#map, #map3d, #hud3d {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  cursor: grab;
  touch-action: none;
}
#map.hidden, #map3d.hidden, #hud3d.hidden { display: none; }
#hud3d { pointer-events: none; z-index: 3; }
#map:active { cursor: grabbing; }
#view3dBtn.active, #floor3dBtn.active { background: #1f6feb; border-color: #388bfd; }
#elevatorBtn.recording, #cartBtn.recording { background: #9e2a2a; border-color: #f85149; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

#coords {
  position: fixed;
  bottom: 8px; left: 12px;
  font-size: 12px;
  color: #8b949e;
  background: rgba(13, 17, 23, 0.8);
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 5;
}

#waypointPanel {
  position: fixed;
  top: 96px; left: 12px;
  width: 300px;
  max-width: calc(100vw - 24px);
  max-height: 55vh;
  overflow-y: auto;
  background: rgba(22, 27, 34, 0.97);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px;
  z-index: 20;
}
#waypointPanel.hidden { display: none; }
.wp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid #21262d;
}
.wp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.wp-name:hover { color: #d4a017; }
.wp-row.selected {
  background: rgba(212, 160, 23, 0.15);
  outline: 1px solid #d4a017;
  border-radius: 5px;
}
.wp-row button {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 5px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  min-height: 32px;
}
.wp-row button.wp-active { background: #9e6a03; border-color: #d4a017; }

/* Collapsible groups in the markers list */
.wp-section { margin-bottom: 2px; }
.wp-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px;
  cursor: pointer;
  user-select: none;
  color: #8b949e;
  font-size: 12px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #21262d;
}
.wp-section-head:hover { color: #d4a017; }
.wp-section-body.hidden {
  display: none;
}
.wp-caret { width: 10px; font-size: 10px; }
.wp-section-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-count {
  background: #21262d;
  border-radius: 9px;
  padding: 0 6px;
  font-size: 11px;
  color: #8b949e;
}
.wp-nested { margin-left: 10px; }
.wp-nested > .wp-section-head { border-bottom: none; }
#routeStatus { font-size: 12px; color: #d4a017; padding-top: 6px; }

/* ---- Выбор торговца ---- */
#traderPickPopup {
  position: fixed;
  top: 96px; left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 27, 34, 0.98);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 260px;
}
#traderPickPopup.hidden { display: none; }
#traderPickTitle { font-size: 13px; color: #8b949e; }
#traderPickSelect,
#traderPickButtons button {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
}
#traderPickButtons { display: flex; gap: 8px; }
#traderPickButtons button { flex: 1; }
#traderPickAdd { background: #238636; border-color: #2ea043; }

/* ---- Тултип торговца (что продаёт) ---- */
#traderTooltip {
  position: fixed;
  z-index: 45;
  max-width: 380px;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(13, 17, 23, 0.97);
  border: 1px solid #d4a017;
  border-radius: 8px;
  padding: 8px 10px;
  pointer-events: none;
  font-size: 12px;
}
#traderTooltip.hidden { display: none; }
#traderTooltip h4 { color: #d4a017; font-size: 13px; margin-bottom: 2px; }
#traderTooltip .tt-loc { color: #8b949e; margin-bottom: 6px; }
#traderTooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-top: 1px solid #21262d;
}
#traderTooltip img { width: 22px; height: 22px; object-fit: contain; }
#traderTooltip .tt-arrow { color: #8b949e; }
#traderTooltip .tt-side { display: flex; align-items: center; gap: 4px; flex: 1; }
#traderTooltip .tt-unlock { color: #6e7681; font-size: 11px; }
#noPortalBtn {
  margin-top: 8px;
  width: 100%;
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 7px;
  cursor: pointer;
  font-size: 13px;
}
#noPortalBtn:hover { background: #30363d; }

#imagesPopup {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.96);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#imagesPopup.hidden { display: none; }

/* На широких экранах — боковая панель справа, карта и меню остаются видны */
@media (min-width: 768px) {
  #imagesPopup {
    inset: auto;
    top: 54px;
    right: 12px;
    bottom: 12px;
    width: min(46vw, 760px);
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
  }
}

#notesPopup {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.97);
  z-index: 31;
  display: flex;
  flex-direction: column;
}
#notesPopup.hidden { display: none; }
#notesHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(22, 27, 34, 0.97);
  border-bottom: 1px solid #30363d;
}
#notesStatus { flex: 1; font-size: 12px; color: #8b949e; }
#notesHeader button {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
#notesText {
  flex: 1;
  background: #0d1117;
  color: #e6edf3;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font: 14px/1.5 Consolas, monospace;
}

@media (min-width: 768px) {
  #notesPopup {
    inset: auto;
    top: 54px;
    right: 12px;
    bottom: 12px;
    width: min(38vw, 560px);
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
  }
}
#imagesHeader {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(22, 27, 34, 0.97);
  border-bottom: 1px solid #30363d;
}
#imagesHeader select {
  flex: 1;
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px;
}
#imagesHeader button {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
#imageWrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}
#imageView { max-width: 100%; max-height: 100%; object-fit: contain; }
