:root {
  --deep: #0b2536;
  --deep-2: #103850;
  --brass: #c9a25e;
  --foam: #eef4f6;
  --paper: #ffffff;
  --ink: #1d2b33;
  --muted: #6e828c;
  --border: #d8e2e7;
  --sighting: #e8b04b;
  --pursuit: #d9643a;
  --nautilus: #2e8fa3;
  --escape: #7cb342;
  --sidebar-w: 400px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--foam);
}

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

/* ---------- Sidebar ---------- */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--foam);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-header {
  padding: 22px 22px 16px;
  background: linear-gradient(165deg, var(--deep), var(--deep-2));
  color: #dfe9ee;
}

.sidebar-header h1 {
  margin: 0;
  font-family: "Playfair Display", serif;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 700;
}

.sidebar-header h1 span {
  font-style: italic;
  font-weight: 500;
  color: var(--brass);
}

.tagline { margin: 8px 0 0; font-size: 12px; opacity: 0.8; }

.controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  padding: 14px 16px 10px;
}

.controls input, .controls select {
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  min-width: 0;
}

.controls input:focus, .controls select:focus {
  border-color: var(--nautilus);
  box-shadow: 0 0 0 3px rgba(46, 143, 163, 0.15);
}

.controls #tour-btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 11px;
  border: 1px solid var(--nautilus);
  border-radius: 8px;
  background: var(--nautilus);
  color: #fff;
  cursor: pointer;
  transition: background 120ms;
}

.controls #tour-btn:hover { background: #257589; }

.controls #tour-btn.touring {
  background: var(--pursuit);
  border-color: var(--pursuit);
}

.controls .toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 2px 1px 0;
}

.controls .toggle input { accent-color: var(--nautilus); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 2px 18px 8px;
  font-size: 11px;
  color: var(--muted);
}

.legend-item i {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

.stop-count {
  padding: 4px 18px 6px;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#stop-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 10px;
  overflow-y: auto;
  flex: 1;
}

#stop-list li {
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: baseline;
  transition: background 120ms;
}

#stop-list li:hover { background: #e2ecf0; }
#stop-list li.active { background: #d3e3ea; }

.stop-num {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--paper);
  background: var(--nautilus);
  border-radius: 50%;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.stop-num.phase-sighting { background: var(--sighting); }
.stop-num.phase-pursuit { background: var(--pursuit); }
.stop-num.phase-escape { background: var(--escape); }

.stop-name { font-size: 13.5px; font-weight: 600; flex: 1; }

.stop-sub {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.sidebar-footer p { margin: 0; }
.sidebar-footer a { color: var(--nautilus); }

/* ---------- Map ---------- */

#map-wrap { position: relative; flex: 1; }
#map { width: 100%; height: 100%; }

.map-error[hidden] { display: none; }

.map-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--deep);
}

.map-error-card {
  max-width: 440px;
  background: var(--paper);
  border-radius: 14px;
  padding: 26px 30px;
}

.map-error-card h2 { margin: 0 0 10px; font-family: "Playfair Display", serif; color: var(--deep); }
.map-error-card code { background: var(--foam); padding: 2px 6px; border-radius: 5px; }

/* ---------- Info window ---------- */

.iw {
  font-family: "Inter", system-ui, sans-serif;
  max-width: 330px;
  padding: 2px 4px;
}

.iw h3 {
  margin: 0 0 2px;
  font-family: "Playfair Display", serif;
  font-size: 19px;
  color: var(--deep);
}

.iw .iw-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }

.iw blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--brass);
  background: #f7f4ee;
  font-family: "Playfair Display", serif;
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  color: #33414a;
}

.iw .iw-note { font-size: 11px; color: var(--muted); margin: 6px 0; }

.iw .iw-actions {
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.iw .iw-actions a { color: var(--nautilus); font-weight: 600; text-decoration: none; }
.iw .iw-actions a:hover { text-decoration: underline; }
.iw .iw-actions .iw-step { cursor: pointer; color: var(--deep); font-weight: 600; }

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
}
