:root {
  --orange: #ff6a13;
  --orange-dark: #d9530a; /* AA-safe orange for text on white */
  --green: #2e7d32;
  --grey: #9aa0a6;
  --ink: #1b1e23;
  --muted: #5c636e; /* >=4.5:1 on white and on the panel */
  --line: #e7e9ee;
  --panel: #f3f4f6; /* the sidebar: a quiet second neutral layer */
  --surface: #ffffff; /* cards sit on the panel */
  --bg: #eef0f3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.05);
  --ring: 0 0 0 3px rgba(255, 106, 19, 0.4);
  --space: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-feature-settings: "tnum" 1; /* steady, aligned figures for a data tool */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  color: var(--ink);
  background: var(--bg);
}

#sidebar {
  width: 344px;
  flex: 0 0 344px;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

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

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  flex: 0 0 auto;
}

.brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tagline a {
  color: var(--orange-dark);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand {
  padding: 0 2px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label {
  font-weight: 600;
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.pill-off {
  background: #fdecea;
  color: #b71c1c;
}

.pill-on {
  background: #e6f4ea;
  color: var(--green);
}

.pill-new {
  background: #fff1e6;
  color: var(--orange-dark);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover {
  background: #f1f2f4;
  border-color: #d8dbe1;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  box-shadow: 0 1px 2px rgba(217, 83, 10, 0.3);
}

.btn-primary:hover {
  background: var(--orange-dark);
  border-color: var(--orange-dark);
}

/* Official "Connect with Strava" button (their artwork; don't restyle it). */
.strava-connect {
  display: inline-block;
  line-height: 0;
}

.strava-connect img {
  display: block;
  height: 48px;
  width: auto;
}

.btn-ghost {
  background: transparent;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.percent {
  font-size: 20px;
  font-weight: 700;
  color: var(--orange-dark);
}

.bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--orange);
  border-radius: 999px;
  transition: transform 0.4s ease;
}

.bar-sm {
  height: 5px;
}

.provinces {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.provinces summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.provinces summary::-webkit-details-marker {
  display: none;
}

.provinces summary::before {
  content: "▸";
  font-size: 14px;
  line-height: 1;
  color: var(--orange);
  transition: transform 0.15s ease;
}

.provinces[open] summary::before {
  transform: rotate(90deg);
}

.provinces summary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 4px;
}

.prov-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.prov-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prov-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.prov-name {
  font-weight: 600;
  color: var(--ink);
}

.prov-meta {
  color: var(--muted);
}

.strava-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #f2f3f5;
  color: var(--ink);
}

.icon-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stats {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  text-align: center;
  gap: 8px;
}

.stat-value-sm {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.result {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.impact {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.impact-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--orange-dark);
}

.impact-provs {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.message {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
}

.message.error {
  background: #fdecea;
  color: #b71c1c;
}

.attribution {
  margin-top: auto;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.attribution p {
  margin: 0 0 6px;
}

.attribution a {
  color: var(--muted);
  text-decoration: underline;
}

.compleet-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Standalone legal pages (privacy.html, voorwaarden.html). */
.legal-body {
  display: block;
  height: auto;
  background: var(--bg);
}

.legal {
  max-width: 700px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  line-height: 1.65;
}

.legal h1 {
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.legal h2 {
  font-size: 18px;
  margin: 28px 0 6px;
}

.legal .legal-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 0;
}

.legal a {
  color: var(--orange-dark);
}

.hidden {
  display: none;
}

.hover-hint {
  position: absolute;
  z-index: 1000;
  transform: translate(-50%, -100%);
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

/* Postcode polygons read as clickable, with an instant hover/select feel. */
.leaflet-interactive {
  cursor: pointer;
  transition: fill-opacity 120ms ease-out, stroke-width 120ms ease-out;
}

/* While Shift is held, the whole map signals box-select. */
.leaflet-container.box-mode,
.leaflet-container.box-mode .leaflet-interactive {
  cursor: crosshair;
}

kbd {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  color: var(--ink);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff1e6;
  color: var(--orange-dark);
  border: 1px solid #ffd8bf;
  border-radius: 999px;
  padding: 2px 6px 2px 9px;
  font-size: 12px;
  font-weight: 600;
}

.chip button {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.chip button:hover {
  color: #b71c1c;
}

.link-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.sel-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Visible focus for keyboard users on every interactive control. */
.btn:focus-visible,
.icon-btn:focus-visible,
.chip button:focus-visible,
.link-btn:focus-visible,
.checkbox input:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.checkbox input {
  accent-color: var(--orange);
  width: 16px;
  height: 16px;
}

/* First-run welcome overlay (shown over the map until Strava is connected). */
.welcome {
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(238, 240, 243, 0.72);
}

.welcome.hidden {
  display: none;
}

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(20, 23, 28, 0.15);
  padding: 28px;
  max-width: 380px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.welcome-card h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.welcome-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.welcome-steps {
  text-align: left;
  margin: 6px 0 0;
  padding-left: 20px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

/* Map legend (Leaflet control, bottom-left). */
.legend {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend .sw {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend .ln {
  width: 14px;
  height: 0;
  border-top: 3px solid;
  flex: 0 0 auto;
}

.sw-open {
  background: #c8ccd1;
}

.sw-done {
  background: var(--green);
}

.sw-sel {
  background: var(--orange);
}

.ln-route {
  border-top-color: #1565c0;
}

.ln-import {
  border-top-color: #7b1fa2;
  border-top-style: dashed;
}

.map-loading {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.map-loading.hidden {
  display: none;
}

.mini-spin {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Desktop-only: a full-screen notice on narrow viewports. */
#mobile-warning {
  display: none;
}

.mobile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mobile-card h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.mobile-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 768px) {
  #mobile-warning {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--panel);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
