:root {
  --bg: #12161c;
  --panel: #171d25;
  --panel-2: #1e2631;
  --line: #2b3543;
  --text: #e7ecf2;
  --muted: #97a3b3;
  --accent: #6fb2ff;
  --camp: #2f9e57;
  --portage: #d3a017;
  --poi: #3b7de2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app { display: flex; height: 100%; }

/* ---------- panel ---------- */

#panel {
  position: relative;
  width: 330px;
  flex: 0 0 330px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 18px 16px 28px;
  scrollbar-width: thin;
}

#panel-close {
  display: none;
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); cursor: pointer;
  font-size: 19px; line-height: 1;
}
#panel-close:hover { border-color: #3b4757; }

#panel header h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
#panel .sub { margin: 2px 0 20px; color: var(--muted); font-size: 12.5px; }

section { margin-bottom: 22px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.section-head h2 {
  margin: 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); font-weight: 600;
}
.head-actions { display: flex; gap: 10px; }

button.link {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font: inherit; font-size: 12px; padding: 0;
}
button.link:hover { text-decoration: underline; }

ul { list-style: none; margin: 0; padding: 0; }

.day {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding: 8px 8px 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  align-items: start;
}
.day:hover { background: var(--panel-2); }
.day.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.day.off { opacity: .38; }

.chip {
  width: 10px; height: 10px; border-radius: 3px; margin-top: 5px;
  border: 1px solid rgba(255,255,255,.25);
}
.day .name { font-size: 13px; font-weight: 550; }
.day .meta { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.day .plan { color: #6c7889; font-size: 11px; }
.day .flag { color: #e6a23c; }

.toggle, .slider {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 4px; color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.slider input { flex: 1; accent-color: var(--accent); }
.toggle input { accent-color: var(--accent); }

.btn {
  margin-top: 8px; width: 100%; padding: 7px 10px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  font: inherit; font-size: 12.5px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.btn:hover { border-color: #3b4757; }
.btn.on { border-color: var(--accent); color: var(--accent); }
kbd {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0e1319; border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; color: var(--muted);
}

.measure-out {
  margin-top: 8px; padding: 8px 10px; border-radius: 7px;
  background: #0e1319; border: 1px solid var(--line);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text);
}

.legend li { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12.5px; padding: 3px 2px; }
.swatch { flex: 0 0 auto; }
.swatch.line { width: 22px; height: 0; border-top: 3px solid #cbd5e1; }
.swatch.line.dashed { border-top-style: dashed; border-color: var(--portage); }
.swatch.line.dotted { border-top-style: dotted; border-color: #2f9e57; }
.swatch.dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #0e1319; }
.swatch.dot.camp { background: var(--camp); }
.swatch.dot.portage { background: var(--portage); }
.swatch.dot.poi { background: var(--poi); }

.files li { padding: 2px 2px; }
.files a { color: var(--accent); text-decoration: none; font-size: 12.5px; }
.files a:hover { text-decoration: underline; }
.hint { color: #6c7889; font-size: 11.5px; margin: 8px 2px 0; }

#panel footer p { color: #66707e; font-size: 11px; line-height: 1.45; margin: 0; }

/* ---------- map ---------- */

#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#map.dragging { cursor: grabbing; }
#map.measuring { cursor: crosshair; }

#zoom-ctl {
  position: absolute; top: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
#zoom-ctl button, #panel-toggle {
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(18,22,28,.86); color: var(--text);
  border: 1px solid var(--line); cursor: pointer;
  font-size: 16px; line-height: 1; backdrop-filter: blur(6px);
}
#zoom-ctl button:hover, #panel-toggle:hover { background: rgba(30,38,49,.95); }

#panel-toggle { position: absolute; top: 14px; left: 14px; display: none; }

#scalebar {
  position: absolute; left: 14px; bottom: 14px;
  height: 24px; padding: 0 8px;
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 6px 6px;
  background: rgba(18,22,28,.82); backdrop-filter: blur(6px);
  display: flex; align-items: center; font-size: 11.5px; color: var(--text);
}

#readout {
  position: absolute; right: 14px; bottom: 14px;
  padding: 4px 9px; border-radius: 6px;
  background: rgba(18,22,28,.82); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted);
}

#hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px;
  padding: 4px 12px; border-radius: 999px;
  background: rgba(18,22,28,.72); border: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; backdrop-filter: blur(6px);
  transition: opacity .4s; pointer-events: none;
}
#hint.gone { opacity: 0; }

#card {
  position: absolute; max-width: 300px;
  background: rgba(20,25,32,.96); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
}
#card h3 { margin: 0 0 4px; font-size: 13.5px; }
#card p { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
#card .coords {
  font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent); cursor: pointer;
}
#card .close {
  position: absolute; top: 6px; right: 8px; background: none; border: 0;
  color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
}

.drop-active #map-wrap::after {
  content: "drop GPX to overlay";
  position: absolute; inset: 12px;
  border: 2px dashed var(--accent); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 15px; background: rgba(18,22,28,.35);
  pointer-events: none;
}

@media (max-width: 760px) {
  #panel {
    position: absolute; z-index: 5; height: 100%;
    width: min(330px, 88vw); flex-basis: min(330px, 88vw);
    padding-right: 54px;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  #app.panel-open #panel { transform: none; }
  #panel-close { display: block; }
  #panel-toggle { display: block; }
  #app.panel-open #panel-toggle { display: none; }
  #app.panel-open #zoom-ctl { opacity: .3; }
  /* tapping the sliver of map beside an open panel closes it */
  #app.panel-open #map-wrap::before {
    content: ""; position: absolute; inset: 0; z-index: 4;
    background: rgba(8,11,15,.35);
  }
  #hint { display: none; }
}
