:root {
  --bg: #0b1220;
  --panel: rgba(15, 23, 42, 0.92);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --border: rgba(148, 163, 184, 0.25);
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.toolbar {
  position: relative;
  z-index: 2500;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 220px;
}

.brand .sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  flex: 1;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field.grow { flex: 1; min-width: 180px; }

.field select,
.field input {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  outline: none;
}

.field select:focus,
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.field-label {
  font-size: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}

.profile-field {
  min-width: 280px;
}

.profile-row input[type="text"] {
  min-width: 140px;
  flex: 1;
}

.profile-row {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

.profile-row select {
  min-width: 140px;
  flex: 1;
}

.profile-btn {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
}

.profile-btn:hover {
  border-color: var(--accent);
}

.profile-btn.ghost {
  opacity: 0.8;
}

.line-filter-btn {
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-filter-btn:hover,
.line-filter-btn[aria-expanded="true"] {
  border-color: var(--accent);
}

.line-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 2600;
  width: min(360px, calc(100vw - 2rem));
  max-height: min(360px, 55vh);
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 0.5rem;
}

.line-filter-panel[hidden] {
  display: none !important;
}

.line-filter-actions {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}

.line-filter-actions button {
  flex: 1;
  font: inherit;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

.line-filter-actions button:hover {
  border-color: var(--accent);
}

.line-checkboxes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.2rem 0.35rem;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.line-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
  padding: 0.2rem 0.15rem;
  border-radius: 4px;
}

.line-check:hover {
  background: rgba(56, 189, 248, 0.08);
}

.line-check input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
  flex-shrink: 0;
}

#map {
  height: calc(100% - 74px);
  width: 100%;
  background: #020617;
}

/* Satellite softened for overlay readability */
.leaflet-tile-pane .satellite-soft {
  filter: saturate(0.45) contrast(1.05) brightness(0.85);
}

.panel {
  position: absolute;
  z-index: 1000;
  bottom: 1rem;
  left: 1rem;
  width: min(300px, calc(100vw - 2rem));
  max-height: calc(100% - 6.5rem);
  overflow-y: auto;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.panel-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.85rem 0;
}

.leaflet-top.leaflet-left {
  top: 8px;
  left: 8px;
}

.leaflet-bottom.leaflet-right {
  margin-bottom: 42px;
  margin-right: 14px;
}

.ideal-min {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0.7rem;
}

.ideal-min input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.ideal-min strong {
  color: var(--text);
  min-width: 2.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.score-marker {
  background: transparent;
  border: none;
}

.score-bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #0b1220;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.75);
}

.fear-list {
  margin: 0.45rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  color: #fbbf24;
  line-height: 1.4;
}

.panel h2 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.swatches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.swatches li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.swatch.bike {
  background: rgba(34, 197, 94, 0.35);
  box-shadow: inset 0 0 0 1px #22c55e;
}

.bike-zone-canvas {
  pointer-events: none;
}

.meta {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.leaflet-control-attribution {
  margin: 0 8px 6px 0 !important;
}

.leaflet-control-layers {
  background: var(--panel) !important;
  color: var(--text);
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
}

.leaflet-control-layers-expanded {
  padding: 0.6rem 0.75rem !important;
  font-size: 0.85rem;
}

.leaflet-control-layers label {
  color: var(--text);
}

.leaflet-popup-content-wrapper {
  background: #0f172a;
  color: var(--text);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.leaflet-popup-tip { background: #0f172a; }

.popup-title {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.popup-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #334155;
}

.popup-time {
  font-size: 0.9rem;
}

.popup-time strong {
  color: var(--accent);
  font-size: 1.15rem;
}

.mode-tag {
  font-size: 0.72rem;
  color: var(--muted);
}

.popup-compare {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.popup-both {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  opacity: 0.75;
}

@media (max-width: 720px) {
  #map { height: calc(100% - 120px); }
  .panel { bottom: auto; top: auto; position: fixed; }
}
