:root {
  --bg: #111827;
  --panel: #1f2937;
  --panel2: #374151;
  --accent: #e94560;
  --accent2: #f0a500;
  --teal: #22d3ee;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: #374151;
  --green: #4ade80;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── HEADER ───────────────────────────────────────── */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
header svg { color: var(--teal); }
header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
header .subtitle { color: var(--muted); font-size: 0.82rem; }

/* ── HAMBURGER MENU TOGGLE ────────────────────────── */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── SIDEBAR BACKDROP ─────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
}

/* ── LAYOUT ───────────────────────────────────────── */
.app {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────── */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.steps-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  opacity: 0.45;
  transition: opacity 0.2s, background 0.2s;
}
.step-item.active { opacity: 1; background: rgba(233,69,96,0.12); }
.step-item.done   { opacity: 0.75; }
.step-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--panel2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
}
.step-item.active .step-badge { background: var(--accent); }
.step-item.done   .step-badge { background: var(--green); color: #111; }
.step-item .step-name { font-size: 0.82rem; font-weight: 500; }

.divider { border: none; border-top: 1px solid var(--border); margin: 4px 12px; }

.ctrl-panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ctrl-panel.hidden { display: none; }

/* ── CONTROLS ─────────────────────────────────────── */
.info-box {
  background: rgba(34,211,238,0.06);
  border: 1px solid rgba(34,211,238,0.18);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.78rem;
  color: #a5f3fc;
  line-height: 1.55;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.field input[type=number],
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 0.88rem;
  width: 100%;
}
.field input[type=number]:focus,
.field select:focus { outline: none; border-color: var(--accent); }
.row-2 { display: flex; gap: 8px; }
.row-2 .field { flex: 1; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px;
  border: none; border-radius: 8px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: filter 0.15s, transform 0.1s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--panel2); color: var(--text); }
.btn-secondary:hover { filter: brightness(1.15); }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

input[type=range] { width: 100%; accent-color: var(--teal); cursor: pointer; }
.range-row { display: flex; align-items: center; gap: 8px; }
.range-row input { flex: 1; }
.range-val { font-size: 0.78rem; color: var(--muted); min-width: 28px; text-align: right; }

/* ── MARKER LIST ──────────────────────────────────── */
.marker-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 220px; overflow-y: auto;
}
.marker-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 0.76rem;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 6px;
}
.m-title { font-weight: 600; color: var(--accent2); margin-bottom: 2px; }
.m-coords { color: var(--muted); line-height: 1.55; }
.m-dist { color: var(--green); font-weight: 600; }
.m-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0; flex-shrink: 0;
}
.m-del:hover { color: var(--accent); }

.no-markers { color: var(--muted); font-size: 0.78rem; text-align: center; padding: 10px 0; }

/* ── CANVAS AREA ──────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0b0f1a;
}
#mainCanvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
}

/* ── DROP OVERLAY ─────────────────────────────────── */
.drop-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #0b0f1a;
  z-index: 10;
}
.drop-overlay.hidden { display: none; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 52px 72px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--teal);
  background: rgba(34,211,238,0.04);
}
.drop-icon { opacity: 0.35; margin-bottom: 14px; }
.drop-zone h2 { font-size: 1.05rem; margin-bottom: 5px; }
.drop-zone p  { color: var(--muted); font-size: 0.82rem; }
.drop-zone input[type=file] { display: none; }

/* ── CANVAS ACTION BUTTON (floating confirm) ──────── */
.canvas-action-btn {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

/* ── ZOOM CONTROLS ────────────────────────────────── */
#zoom-btns {
  position: absolute;
  bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.zoom-btn {
  width: 34px; height: 34px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.zoom-btn:hover { background: var(--panel2); }

/* ── WARP TOGGLE ──────────────────────────────────── */
#warp-btn-wrap {
  position: absolute;
  bottom: 16px; left: 16px;
}
#btn-warp {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 12px;
  transition: all 0.15s;
}
#btn-warp:hover { background: var(--panel2); color: var(--text); }
#btn-warp.active {
  background: rgba(34,211,238,0.12);
  border-color: var(--teal);
  color: var(--teal);
}

/* ── STATUS BAR ───────────────────────────────────── */
#status-bar {
  position: absolute;
  bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(31,41,55,0.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.76rem;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}

/* ── COORD TOOLTIP ────────────────────────────────── */
#coord-tip {
  position: absolute;
  background: rgba(31,41,55,0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.72rem;
  color: var(--text);
  pointer-events: none;
  display: none;
}

/* ── MOBILE ───────────────────────────────────────── */
@media (max-width: 640px) {
  .menu-toggle { display: flex; }

  /* Allow fixed-position sidebar to escape the overflow:hidden on .app */
  .app { overflow: visible; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: min(300px, 85vw);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    z-index: 999;
  }
  .sidebar-backdrop.open {
    display: block;
  }
}
