:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-dark: #184f95;
  --none-fill: #898781;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-dark: #86b6ef;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--page-plane);
}

#map { position: fixed; inset: 0 0 0 340px; }

#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 340px;
  padding: 20px;
  overflow-y: auto;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  z-index: 1000;
}

h1 { font-size: 18px; margin: 0 0 8px; }
.lede { font-size: 13px; color: var(--text-secondary); line-height: 1.4; margin: 0 0 16px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

.search-wrap { position: relative; margin-bottom: 10px; }
#origin-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page-plane);
  color: var(--text-primary);
}
#origin-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.suggestions {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 1001;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.suggestions.hidden { display: none; }
.suggestion-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.suggestion-item:hover, .suggestion-item.active { background: var(--gridline); }

button {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-bottom: 12px;
}
button:disabled { background: var(--gridline); color: var(--text-muted); cursor: not-allowed; }
button:not(:disabled):hover { background: var(--accent-dark); }
#list-toggle { background: transparent; color: var(--accent); border: 1px solid var(--border); }
#list-toggle:hover { background: var(--gridline); }

.hidden { display: none !important; }

.status { margin-bottom: 16px; }
#status-text { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.map-controls { margin-bottom: 16px; }
.map-controls label { margin-top: 10px; }
.map-controls label:first-child { margin-top: 0; }
#category-select, #max-minutes, #max-changes {
  width: 100%;
  padding: 7px 9px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page-plane);
  color: var(--text-primary);
}
#category-select:focus, #max-minutes:focus, #max-changes:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#max-changes { margin-bottom: 12px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: normal;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-row input { margin: 0; cursor: pointer; }

.legend { margin-bottom: 16px; font-size: 12px; }
.legend-title { font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.legend-gradient {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #cde2fb, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b);
}
.legend-labels { display: flex; justify-content: space-between; color: var(--text-muted); margin: 4px 0 8px; }
.legend-row { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); margin-top: 4px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.swatch-none { background: var(--none-fill); opacity: 0.6; }
.swatch-border { background: var(--accent); border: 1.5px dashed var(--text-primary); }

.list-view { font-size: 12px; margin-top: 8px; }
.list-view table { width: 100%; border-collapse: collapse; }
.list-view th, .list-view td { text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--gridline); }
.list-view th { color: var(--text-muted); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
.list-view td.num { text-align: right; font-variant-numeric: tabular-nums; }
.list-view tbody tr:hover { background: var(--gridline); }

.footnote { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-top: 20px; }

.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content table { border-collapse: collapse; margin-top: 4px; }
.leaflet-popup-content td { padding: 1px 6px 1px 0; }
.set-origin-btn {
  margin-top: 8px;
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.set-origin-btn:hover { background: var(--accent-dark); }
