:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0d6efd;
  --open: #16a34a;
  --summer: #2e9e5b;
  --indoor: #2563eb;
  --beach: #0d9488;
  --kids: #d97706;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.08);
  --sidebar-w: 380px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: var(--ink);
  background: #f1f5f9;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg);
  color: #fff;
  flex: 0 0 auto;
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.topbar__sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: #cbd5e1;
}
.topbar__meta {
  font-size: 12px;
  color: #cbd5e1;
  text-align: right;
  white-space: nowrap;
}
.topbar__meta strong {
  color: #fff;
}

/* ---------- layout ---------- */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #f8fafc;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
#map {
  position: absolute;
  inset: 0;
  background: #e5e7eb;
}

/* ---------- controls ---------- */
.controls {
  padding: 14px 16px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.field {
  margin-bottom: 12px;
}
.field > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.origin-row {
  display: flex;
  gap: 6px;
}
.origin-row input {
  flex: 1 1 auto;
  min-width: 0;
}
input,
select {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
#locate-btn {
  flex: 0 0 auto;
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 17px;
  cursor: pointer;
}
#locate-btn:hover {
  background: #f1f5f9;
}
.opt {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #94a3b8;
}
#dest-clear {
  flex: 0 0 auto;
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
}
#dest-clear:hover {
  background: #f1f5f9;
}
.fav-btn {
  flex: 0 0 auto;
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 17px;
  color: #94a3b8;
  cursor: pointer;
}
.fav-btn:hover {
  background: #fffbeb;
  color: #d97706;
}
.fav-btn.is-set {
  color: #f59e0b;
}

/* favourites list */
.favs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.favs__row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 6px 5px 10px;
}
.favs__name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.favs__name::before {
  content: '★';
  color: #f59e0b;
  margin-right: 6px;
}
.favs__row button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.favs__row button.favs__del {
  color: var(--muted);
  padding: 3px 7px;
}
.favs__row button:hover {
  background: #eef2ff;
}
.origin-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}
.origin-status.is-set {
  color: var(--open);
  font-weight: 600;
}
.origin-status.is-error {
  color: #dc2626;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg__btn {
  padding: 8px 16px;
  border: 0;
  background: #fff;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}
.seg__btn.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.plan-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.plan-row select {
  flex: 1 1 auto;
}

/* ---------- results ---------- */
.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
}
#results-count {
  font-weight: 700;
  color: var(--ink);
}
.results-sort {
  font-size: 11.5px;
}
.pool-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 10px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.pool-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.12s, transform 0.05s;
}
.pool-card:hover {
  border-color: #94a3b8;
}
.pool-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18);
}
.pool-card__top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: space-between;
}
.pool-card__name {
  font-weight: 650;
  font-size: 14.5px;
  line-height: 1.25;
}
.kind-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge--time {
  background: #eef2ff;
  color: #3730a3;
}
.badge--walk {
  background: #dcfce7;
  color: #166534;
}
.badge--loading {
  background: #f1f5f9;
  color: var(--muted);
}
.badge--none {
  background: #fef2f2;
  color: #b91c1c;
}
.pool-card__hours {
  margin-top: 6px;
  font-size: 13px;
  color: var(--open);
  font-weight: 600;
}
.pool-card__hours .left {
  color: var(--muted);
  font-weight: 500;
}
.pool-card__meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.pool-card__links {
  margin-top: 8px;
  display: flex;
  gap: 14px;
  font-size: 12.5px;
}
.pool-card__links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.pool-card__links a:hover {
  text-decoration: underline;
}
.pool-list__empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- sidebar footer ---------- */
.sidebar__foot {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
}
.sidebar__foot p {
  margin: 0 0 4px;
}
.sidebar__foot a {
  color: var(--accent);
}
.muted {
  color: var(--muted);
}

/* ---------- map markers ---------- */
.pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
}
.pin > span {
  transform: rotate(45deg);
  font-size: 12px;
  line-height: 1;
}
.pin--rank {
  font-weight: 800;
  color: #fff;
}
.origin-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111827;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #111827;
}
.dest-pin {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #dc2626;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #dc2626;
}
.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 13px;
}
.popup__name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
}
.popup__row {
  margin: 2px 0;
}
.popup__links {
  margin-top: 7px;
  display: flex;
  gap: 12px;
}
.popup__links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  /* Let the whole document scroll naturally instead of locking to the viewport
     height with a cramped inner scroll area for the pool list. Stay flex-column
     (so `order` keeps the map on top) but give everything its natural height. */
  html,
  body {
    height: auto;
  }
  body {
    min-height: 100dvh;
  }
  .layout {
    flex-direction: column;
  }
  .map-wrap {
    order: 1;
    flex: 0 0 auto;
    height: 42vh;
    min-height: 240px;
  }
  .sidebar {
    order: 2;
    width: 100%;
    flex: 0 0 auto;
    border-right: 0;
  }
  /* the page scrolls, so the list expands to its content rather than scrolling internally */
  .pool-list {
    overflow: visible;
  }
  .topbar__sub {
    display: none;
  }
}
