:root {
  --bg: #0a0d12;
  --panel: rgba(15, 19, 27, 0.88);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf1;
  --muted: #8a94a3;
  --accent: #ffd166;
  --accent-soft: rgba(255, 209, 102, 0.16);
  --accent-line: rgba(255, 209, 102, 0.55);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

a { color: inherit; }

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

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

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 330px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 5;
  scrollbar-width: thin;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}

.panel h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.collapse {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.collapse:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.panel-body { padding: 8px 18px 14px; }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed .panel-head { padding-bottom: 14px; }

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.lede strong { color: var(--accent); font-weight: 600; }

/* mode toggles */
.modes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 16px 0 14px;
}
.mode {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.mode:hover { background: rgba(255, 255, 255, 0.06); }
.mode:active { transform: scale(0.98); }
.mode:last-child { grid-column: 1 / -1; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode.on {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.mode .icon { font-size: 20px; line-height: 1; }
.mode .text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mode .label { font-size: 13px; font-weight: 600; }
.mode .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode.on .sub { color: rgba(255, 209, 102, 0.8); }
.mode:focus-within { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* fields */
.field { display: block; margin: 12px 0; }
.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-label output { color: var(--accent); letter-spacing: 0; }
.field input[type="text"], .field input:not([type]) {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  outline: none;
}
.field input:not([type]):focus { border-color: var(--accent-line); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0;
}

.options { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 10px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }
.check:hover { color: var(--text); }

.stats {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  min-height: 1.2em;
}
.stats b { color: var(--text); font-weight: 600; }

/* travel-time colour legend */
.bands {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
  margin: 0 0 12px;
}
.band i { display: block; height: 9px; border-radius: 2px; }
.band span { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }

.more, .legend { border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; color: var(--muted); }
.more summary, .legend summary { cursor: pointer; font-weight: 600; color: var(--text); font-size: 12.5px; }
.more .field { margin-top: 10px; }
.note { margin: 8px 0 4px; line-height: 1.45; }
.legend p { line-height: 1.45; }
.legend-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin: 10px 0; }
.legend-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text); }
.legend-line i { width: 18px; height: 4px; border-radius: 2px; flex: none; }
.legend-line i.dashed { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); }
.credits { font-size: 11px; }

.hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- zoom */

.zoom {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
.zoom button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.zoom button:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------------------------------------------------------------- tooltip */

.tooltip {
  position: fixed;
  z-index: 6;
  pointer-events: none;
  max-width: 280px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(12, 15, 22, 0.94);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  line-height: 1.4;
}
.tooltip .name { font-weight: 600; font-size: 13px; }
.tooltip .kind { color: var(--muted); font-size: 11px; }
.tooltip .time { color: var(--accent); font-weight: 700; font-size: 16px; margin-top: 3px; }
.tooltip .time.unreachable { color: #ff6b6b; font-size: 13px; }
.tooltip .legs { margin-top: 5px; color: var(--muted); font-size: 11.5px; }
.tooltip .legs span { color: var(--text); }
.tooltip .legs i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---------------------------------------------------------------- loading */

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 10;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: opacity 0.4s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading span { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 560px) {
  .panel { left: 10px; top: 10px; width: calc(100% - 20px); max-height: 60%; }
  .modes { grid-template-columns: 1fr 1fr; }
  .mode .sub { display: none; }
  .zoom { bottom: 12px; right: 12px; }
}
