:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2a3544;
  --text: #e8edf2;
  --muted: #8b9aab;
  --done: #3d9a6a;
  --done-dim: #2a6b4a;
  --todo: #3a4554;
  --accent: #6eb5ff;
  --cursor: #ffd166;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.stats {
  display: flex;
  gap: 1.5rem;
  margin: 0;
}

.stats div {
  text-align: right;
}

.stats dt {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

main {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 0;
  min-height: calc(100vh - 140px);
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 55vh;
  }
}

.panel {
  padding: 1rem 1.25rem 1.5rem;
}

.progress-panel {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.bar-wrap {
  margin-top: 1rem;
}

.bar-labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.bar-labels span:nth-child(2) {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  position: relative;
  height: 2.25rem;
  border-radius: 8px;
  cursor: crosshair;
  outline: none;
}

.bar-track:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.bar-rail {
  position: absolute;
  inset: 0.65rem 0;
  background: var(--todo);
  border-radius: 6px;
}

.bar-segments {
  position: absolute;
  inset: 0.65rem 0;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
}

.bar-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: auto;
  cursor: pointer;
  background: linear-gradient(180deg, var(--done) 0%, var(--done-dim) 100%);
}

.bar-cursor {
  position: absolute;
  top: 0.15rem;
  bottom: 0.15rem;
  width: 3px;
  margin-left: -1.5px;
  background: var(--cursor);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.7);
  pointer-events: none;
  z-index: 2;
}

.segment-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.segment-list li {
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.segment-list li.done {
  border-left: 3px solid var(--done);
}

.segment-list li.todo {
  border-left: 3px solid var(--todo);
  color: var(--muted);
}

.segment-list .miles {
  font-weight: 600;
  color: var(--text);
}

.segment-list .date {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

#map {
  height: 100%;
  min-height: 420px;
  border-radius: 0;
  background: #1e2630;
}

.map-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
}

footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

footer code {
  font-size: 0.85em;
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Leaflet overrides */
.leaflet-container {
  font-family: inherit;
}

.leaflet-control-layers {
  background: var(--panel, #1a222c);
  border: 1px solid var(--border, #2a3544);
  border-radius: 6px;
  color: var(--text, #e8edf2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.leaflet-control-layers-expanded {
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
}

.leaflet-control-layers label {
  margin-bottom: 0.2rem;
}

.leaflet-control-layers-separator {
  border-top-color: var(--border, #2a3544);
  margin: 0.35rem 0;
}

.route-hover-marker {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--cursor);
  border: 2px solid #1a222c;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.85);
}
