* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1c1c1c;
}

body {
  display: flex;
}

#sidebar {
  width: 300px;
  flex: 0 0 300px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: #f4f5f7;
  border-right: 1px solid #d8dade;
}

#sidebar h1 {
  font-size: 1.15rem;
  margin: 0 0 0.2rem;
}

.lead {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #555;
}

#sidebar label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
}

#sidebar label.checkbox {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

#sidebar select,
#sidebar input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  font-size: 0.9rem;
}

#sidebar select {
  padding: 0.35rem;
  border: 1px solid #c2c5cc;
  border-radius: 4px;
  background: #fff;
}

.region-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.region-row select {
  flex: 1;
  margin-top: 0;
}

#manual-bbox {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  color: #c0392b;
  background: #fff;
  border: 1px solid #c0392b;
  border-radius: 4px;
  cursor: pointer;
}

#manual-bbox:hover { background: #fdecea; }

#manual-bbox.active {
  background: #c0392b;
  color: #fff;
}

#manual-bbox:disabled { opacity: 0.6; cursor: default; }

.bbox-close-icon {
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: #c0392b;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

#search {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #c0392b;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#search:hover { background: #a93226; }
#search:disabled { background: #b8b8b8; cursor: default; }

#reset {
  width: 100%;
  padding: 0.45rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  background: #fff;
  border: 1px solid #c2c5cc;
  border-radius: 4px;
  cursor: pointer;
}

#reset:hover { background: #eceef1; }

#filters-toggle {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #c0392b;
  background: #fff;
  border: 1px solid #c0392b;
  border-radius: 4px;
  cursor: pointer;
}

#filters-toggle:hover { background: #fdecea; }

.status {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: #444;
  min-height: 1.2em;
}

.status.error { color: #c0392b; font-weight: 600; }

.legend {
  margin-top: 1rem;
  font-size: 0.78rem;
}

.legend-bar {
  height: 10px;
  margin: 0.3rem 0 0.15rem;
  border-radius: 5px;
  background: linear-gradient(
    to right,
    hsl(120, 80%, 45%),
    hsl(60, 80%, 45%),
    hsl(0, 80%, 45%)
  );
}

.legend-ends {
  display: flex;
  justify-content: space-between;
  color: #666;
}

#map {
  flex: 1;
  height: 100%;
}

#map.drawing,
#map.drawing .leaflet-container {
  cursor: crosshair;
}

#results:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.results-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid #d8dade;
}

.results-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid #e4e6ea;
  font-size: 0.82rem;
  cursor: pointer;
}

.results-list li:hover { background: #eceef1; }

.res-name { font-weight: 600; }
.res-meta { color: #666; white-space: nowrap; }

/* Popup */
.popup { font-size: 0.85rem; line-height: 1.4; min-width: 180px; }
.popup strong { font-size: 0.95rem; }
.pop-sub { color: #666; }
.pop-time { margin: 0.25rem 0; }
.pop-trail, .pop-weather { color: #444; margin-top: 0.15rem; }

.conn-btn {
  margin-top: 0.5rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid #c0392b;
  color: #c0392b;
  background: #fff;
  border-radius: 4px;
}
.conn-btn:hover { background: #fdecea; }
.conn-btn:disabled { opacity: 0.6; cursor: default; }

.conn-out { margin-top: 0.4rem; }
.conn-head { font-weight: 600; margin-bottom: 0.2rem; }
.conn-legs { list-style: none; margin: 0; padding: 0; }
.conn-legs .leg {
  display: grid;
  grid-template-columns: 1.3rem auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0;
  border-top: 1px solid #eee;
  line-height: 1.25;
}
.leg-line {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}
.leg-times { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.conn-legs .leg-walk { color: #777; font-size: 0.75rem; padding: 0.1rem 0 0.1rem 1.7rem; }
.error { color: #c0392b; }
