:root {
  --bg: #0f1116;
  --panel: #171a22;
  --text: #e6e6e6;
  --muted: #a7afc0;
  --accent: #ff8c37;
  --border: #252a36;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12151c, #0f1116);
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.app-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  height: calc(100vh - 48px - 32px);
}

.map-wrap {
  position: relative;
}
#map {
  position: absolute;
  inset: 0;
}

.side-panel {
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 14px 12px;
  overflow: auto;
}

.panel-section {
  margin-bottom: 16px;
}
.panel-section h2 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.toggle input {
  width: 18px;
  height: 18px;
}

button#btn-reset {
  appearance: none;
  border: 1px solid var(--border);
  background: #1b1f2a;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
button#btn-reset:hover {
  border-color: #2c3242;
  background: #1e2330;
}

.smallprint {
  color: var(--muted);
  font-size: 12px;
}

/* Leaflet theme tweaks for dark panel */
.leaflet-container {
  background: #0b0d12;
}
.leaflet-control-attribution,
.leaflet-bar a {
  background: #1a1f2b;
  color: #cbd2e1;
}
.leaflet-bar a:hover {
  background: #23293a;
}

/* Reset (home) button icon in zoom bar */
.leaflet-bar .leaflet-control-zoom-home {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0; /* avoid baseline misalignment */
}
.leaflet-control-zoom-home svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* Stack Leaflet controls at top-left (under header) */
.leaflet-top.leaflet-left {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}
.leaflet-top.leaflet-left .leaflet-control {
  margin: 10px 0 0 10px; /* default Leaflet spacing */
}

/* X/Y Go control */
.coords-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: #1a1f2b;
  border: 1px solid #2a3142;
  border-radius: 6px;
}
.coords-go input[type="text"] {
  width: 90px;
  background: #0f141f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}
.coords-go input.invalid {
  border-color: #ff4d4f;
  box-shadow: 0 0 0 2px #ff4d4f33;
}
.coords-go button {
  appearance: none;
  border: 1px solid var(--border);
  background: #1b1f2a;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.coords-go button:hover {
  background: #23293a;
}

/* Go-to waypoint icon and pulse highlight */
.goto-waypoint {
  position: relative;
}
.goto-waypoint .pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff2d55; /* distinct from default waypoints */
  border: 2px solid #0b0d12;
  box-shadow: 0 0 0 2px #ff2d55aa;
}
.goto-waypoint.pulse .pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 45, 83, 0.829);
  animation: goto-ping 900ms ease-out 1;
  opacity: 0;
}
@keyframes goto-ping {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.9;
  }
  70% {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0.15;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.6);
    opacity: 0;
  }
}

/* Footer */
.app-footer {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: #11141b;
  color: var(--muted);
  font-size: 12px;
}
.app-footer .coords {
  display: flex;
  gap: 16px;
}
.app-footer .credits {
  margin-left: auto;
}
.app-footer .credits a {
  color: var(--muted);
  text-decoration: none;
}
.app-footer .credits a:hover {
  text-decoration: underline;
}

/* Collapsible sections */
.collapsible {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}
.collapse-toggle .title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.collapse-toggle .caret {
  width: 0;
  height: 0;
  border-left: 6px solid #8ea2c8;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.collapse-toggle[aria-expanded="true"] .caret {
  transform: rotate(90deg);
}
.collapse-body {
  padding: 6px 4px 2px;
}

/* Hide collapsible body when collapsed */
.collapse-toggle[aria-expanded="false"] + .collapse-body {
  display: none;
}

/* Info icon + tooltip next to section titles */
.info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #ffffff;
  background: #1a1f2b;
  color: #cbd2e1;
  font-size: 11px;
  line-height: 1;
  cursor: help;
}
.info-icon::before {
  content: "i";
  font-weight: 700;
}
.info-icon::after {
  content: attr(aria-label);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-40%);
  display: block;
  width: max-content;
  min-width: 100px;
  max-width: 180px;
  padding: 8px 10px;
  background: #0f141f;
  color: #cbd2e1;
  border: 1px solid #2a3142;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  z-index: 1000;
  transition: opacity 120ms ease;
}
.info-icon:hover::after,
.info-icon:focus-visible::after {
  opacity: 1;
}

/* Simple form styles */
.form .field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 4px;
}
.form select.full,
.form select,
.form input[type="range"] {
  width: 100%;
}
.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form select {
  background: #0f141f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
}
.form input[type="range"] {
  accent-color: var(--accent);
}

/* Nodes rows */
.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}
.row .label {
  font-size: 13px;
  color: var(--text);
}
.btns {
  display: inline-flex;
  gap: 6px;
}
.btn {
  border: 1px solid var(--border);
  background: #1b2a1c;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.btn.ghost {
  background: transparent;
  border-color: #2a3142;
  color: #b8c4e0;
}
.btn.icon {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #1f0f0f;
}
.btn.icon img.mini-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}
.btn.icon.impure {
  border-color: #ff4d4f;
}
.btn.icon.normal {
  border-color: #ffa940;
}
.btn.icon.pure {
  border-color: #52c41a;
}
.btn.active {
  border: 3px solid var(--accent);
  background: #2a2320;
}

/* Waypoint icon re-use */
.waypoint-icon div {
  outline: none;
}

/* Node markers (image with purity-colored border) */
.node-marker {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid #2a3142;
  background: #0b0d12;
  box-shadow: 0 0 0 1px #000a;
  overflow: hidden;
}
.node-marker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.node-marker.impure {
  border-color: #ff4d4f;
}
.node-marker.normal {
  border-color: #ffa940;
}
.node-marker.pure {
  border-color: #52c41a;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
    height: auto;
  }
  .side-panel {
    order: -1;
    height: auto;
  }
  .map-wrap {
    height: 70vh;
  }
}
.node-group {
  margin: 10px 0 14px;
}
.group-title {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
