/* frontend/css/app.css */

/* ── Reset & Variables ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clr-bg:        #0f1117;
  --clr-surface:   #1a1d27;
  --clr-surface2:  #22263a;
  --clr-border:    #2e3347;
  --clr-text:      #e8ecf4;
  --clr-muted:     #7a8099;
  --clr-accent:    #4f9dff;

  /* Condition colours */
  --clr-excellent: #22c55e;   /* green  */
  --clr-good:      #84cc16;   /* lime   */
  --clr-fair:      #f59e0b;   /* amber  */
  --clr-bad:       #ef4444;   /* red    */

  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.45);
  --header-h: 56px;
  --sidebar-w: 340px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 1000;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
.logo { display: flex; align-items: center; }
.logo svg { display: block; }
.header-meta { display: flex; align-items: center; gap: 12px; }

/* ── Auth nav (login / user state in header) ─────────────────── */
.auth-nav { display: flex; align-items: center; gap: 6px; }
.auth-nav-link {
  font-size: .78rem; font-weight: 600;
  color: var(--clr-muted); text-decoration: none;
  padding: 5px 12px; border-radius: 7px;
  border: 1px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.auth-nav-link:hover { color: var(--clr-text); background: var(--clr-surface2); }
.auth-nav-link.primary {
  border-color: #4aaca7; color: #4aaca7;
}
.auth-nav-link.primary:hover { background: rgba(74,172,167,.12); }
.auth-nav-user {
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: var(--clr-muted);
}
.auth-nav-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--clr-surface2); border: 1px solid var(--clr-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #4aaca7;
  flex-shrink: 0; overflow: hidden;
}
.auth-nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth-nav-logout {
  background: none; border: none; cursor: pointer;
  font-size: .78rem; color: var(--clr-muted); padding: 5px 8px;
  border-radius: 6px; transition: color .15s, background .15s; font-family: inherit;
}
.auth-nav-logout:hover { color: var(--clr-text); background: var(--clr-surface2); }

/* ── Avatar dropdown menu ──────────────────────────────────────── */
.auth-dropdown-wrap {
  position: relative;
}
.auth-dropdown-trigger {
  background: none; border: none; cursor: pointer; padding: 0;
}
.auth-dropdown {
  position: fixed;
  min-width: 200px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  z-index: 2000;
  overflow: hidden;
  animation: dropdown-in .13s ease;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-dropdown-header {
  padding: 12px 14px 10px;
}
.auth-dropdown-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-dropdown-email {
  font-size: .75rem;
  color: var(--clr-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.auth-dropdown-sep {
  height: 1px;
  background: var(--clr-border);
  margin: 2px 0;
}
.auth-dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font-size: .83rem;
  color: var(--clr-muted);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s;
}
.auth-dropdown-item:hover {
  background: var(--clr-surface2);
  color: var(--clr-text);
}
.auth-dropdown-signout {
  color: #ef4444;
}
.auth-dropdown-signout:hover {
  background: rgba(239,68,68,.08);
  color: #ef4444;
}

.activity-toggle {
  display: flex;
  gap: 3px;
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  padding: 3px;
}
.toggle-btn {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--clr-muted);
  cursor: pointer;
  letter-spacing: .3px;
  transition: background .15s, color .15s;
}
.toggle-btn.active { background: var(--clr-accent); color: #fff; }
.toggle-btn:hover:not(.active) { color: var(--clr-text); }

.update-time { font-size: .72rem; color: var(--clr-muted); }

/* ── Main layout ───────────────────────────────────────────────── */
.app-main {
  display: flex;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  position: relative; /* anchor for the sidebar toggle button */
}

/* ── Map ───────────────────────────────────────────────────────── */
.map-panel {
  flex: 1;
  position: relative;
}
#map {
  width: 100%;
  height: 100%;
  background: #0d1117;
}




/* Custom marker pulse */
.marker-pulse {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  position: relative;
  cursor: pointer;
  transition: transform .15s;
}
.marker-pulse:hover { transform: scale(1.3); }
.marker-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}
/* ── Ski condition markers ────────────────────────────────────── */
.marker-excellent { background: var(--clr-excellent); }
.marker-excellent::after { border: 2px solid var(--clr-excellent); }
.marker-good { background: var(--clr-good); }
.marker-good::after { border: 2px solid var(--clr-good); }
.marker-fair { background: var(--clr-fair); }
.marker-fair::after { border: 2px solid var(--clr-fair); }
.marker-bad { background: var(--clr-bad); }
.marker-bad::after { border: 2px solid var(--clr-bad); }

/* ── MTB condition markers ───────────────────────────────────── */
.marker-snow-covered   { background: #c8d0d8; }
.marker-snow-covered::after   { border: 2px solid #c8d0d8; }
.marker-prevalent-mud  { background: #b8900e; }
.marker-prevalent-mud::after  { border: 2px solid #b8900e; }
.marker-wet            { background: #f97316; }
.marker-wet::after            { border: 2px solid #f97316; }
.marker-variable       { background: #86efac; }
.marker-variable::after       { border: 2px solid #86efac; }
.marker-hero-dirt      { background: #22c55e; }
.marker-hero-dirt::after      { border: 2px solid #22c55e; }
.marker-dry            { background: #a3e635; }
.marker-dry::after            { border: 2px solid #a3e635; }
.marker-very-dry       { background: #65a30d; }
.marker-very-dry::after       { border: 2px solid #65a30d; }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: .6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Permanent marker labels */
.leaflet-tooltip.marker-label {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: .75rem;
  color: #334155;
  white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0,0,0,.15);
  pointer-events: none;
}
.leaflet-tooltip.marker-label::before { display: none; }

/* Cluster badge */
.cluster-icon {
  border-radius: 50%;
  background: transparent;
  border: 2.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  line-height: 1;
}
.cluster-icon:hover { transform: scale(1.12); }
.cluster-count { color: #fff; }

/* Bikepark wheel marker */
.marker-wheel {
  width: 24px; height: 24px;
  cursor: pointer;
  transition: transform .15s;
  position: relative;
}
.marker-wheel::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--wheel-color, #4f9dff);
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}
.marker-wheel:hover { transform: scale(1.35); }
.marker-wheel svg {
  width: 100%; height: 100%; display: block;
  filter: drop-shadow(0 0 5px var(--wheel-color, #4f9dff));
}

/* Popup bikepark badge + trail button */
.popup-bike-badge { font-size: .8rem; }
.popup-trail-btn {
  display: block;
  text-align: center;
  margin-top: 5px;
  padding: 5px;
  background: rgba(34,197,94,.15);
  border-radius: 6px;
  font-size: .78rem;
  color: #22c55e;
  text-decoration: none;
  border: 1px solid rgba(34,197,94,.3);
  transition: background .15s;
}
.popup-trail-btn:hover { background: rgba(34,197,94,.25); }

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--clr-text);
  padding: 0;
}
.leaflet-popup-content { margin: 0; }
.leaflet-popup-tip { background: var(--clr-surface); }
.popup-inner { padding: 12px 16px; }
.popup-name { font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.popup-label { font-size: .8rem; color: var(--clr-muted); }
.popup-score { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.popup-score-box {
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 7px;
  padding: 8px 12px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 6px 0 4px;
  gap: 3px;
}
.popup-detail-btn {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 5px;
  background: var(--clr-surface2);
  border-radius: 6px;
  font-size: .78rem;
  color: var(--clr-accent);
  cursor: pointer;
  border: none;
  width: 100%;
  transition: background .15s;
}
.popup-detail-btn:hover { background: var(--clr-border); }

/* Popup score history strip */
.popup-history { min-height: 0; }
.ph-loading { display: block; font-size: .7rem; color: var(--clr-muted); margin: 6px 0 2px; letter-spacing: .1em; }
.ph-login-hint { letter-spacing: 0; font-style: italic; }
.ph-header {
  display: block;
  font-size: .6rem;
  color: var(--clr-muted);
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.ph-wrap {
  border-top: 1px solid var(--clr-border);
  padding-top: 6px;
  display: flex;
  gap: 4px;
}
.ph-box {
  flex: 1;
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 7px;
  padding: 5px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.ph-box:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.5);
  z-index: 2;
}
.ph-score {
  font-size: .95rem;
  font-weight: 800;
  line-height: 1;
}
.ph-ts {
  font-size: .6rem;
  font-weight: 400;
  color: var(--clr-muted);
  line-height: 1;
}

/* ── Re-center map button (topleft, beside zoom controls) ────────────────── */

/* Make the topleft control container horizontal so zoom + recenter sit side by side */
.leaflet-top.leaflet-left {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}

.map-recenter-wrap {
  margin-top: 10px;  /* match Leaflet zoom control top margin */
  margin-left: 6px;
}

.map-recenter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  background: rgba(10, 12, 22, 0.82);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: rgba(200,208,224,0.55);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: .02em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .14s, color .14s, border-color .14s;
}
.map-recenter-btn:hover {
  background: rgba(10, 12, 22, 0.95);
  color: rgba(200,208,224,0.85);
  border-color: rgba(255,255,255,0.3);
}
.map-recenter-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Map location search ─────────────────────────────────────────────────── */
.map-search-wrap {
  position: relative;
  flex-shrink: 0;
}

/* Expanding input — absolutely positioned so it floats left over the map
   without pushing the panel or toggle buttons wider */
.map-search-expand {
  position: absolute;
  right: 100%;           /* right edge sits flush against the button's left edge */
  top: 0;
  overflow: hidden;
  width: 0;
  transition: width .22s cubic-bezier(.4,0,.2,1);
  display: flex;
  align-items: center;
}
.map-search-wrap.open .map-search-expand {
  width: 185px;
}

.map-search-input {
  width: 185px;
  height: 30px;
  padding: 5px 10px;
  background: rgba(10, 12, 22, 0.88);
  border: 1.5px solid rgba(255,255,255,0.22);
  border-right: none;
  border-radius: 7px 0 0 7px;
  color: #e2e8f0;
  font-size: .72rem;
  font-weight: 500;
  outline: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.map-search-input::placeholder { color: rgba(200,208,224,0.38); }
.map-search-input:focus { border-color: rgba(99,130,255,.7); }

.map-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  padding: 0;
  background: rgba(10, 12, 22, 0.82);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: rgba(200,208,224,0.6);
  cursor: pointer;
  flex-shrink: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .14s, color .14s, border-color .14s, border-radius .22s;
}
.map-search-wrap.open .map-search-btn {
  border-radius: 0 7px 7px 0;
  border-left: none;
  border-color: rgba(99,130,255,.7);
  color: rgba(200,208,224,0.9);
  background: rgba(10, 12, 22, 0.92);
}
.map-search-btn:hover { color: rgba(200,208,224,0.9); border-color: rgba(255,255,255,0.3); }
.map-search-btn svg { width: 14px; height: 14px; }

/* Results dropdown */
.map-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 220px;
  background: rgba(13,16,28,.97);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  list-style: none;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  max-height: 280px;
  overflow-y: auto;
}
.map-search-results.visible { display: block; }

.msr-item {
  padding: 7px 13px;
  font-size: .78rem;
  color: rgba(200,208,224,.75);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s, color .1s;
}
.msr-item strong {
  color: #e2e8f0;
  font-weight: 700;
}
.msr-item:hover,
.msr-item.msr-active {
  background: rgba(59,130,246,.18);
  color: #e2e8f0;
}
.msr-empty {
  padding: 8px 13px;
  font-size: .75rem;
  color: rgba(200,208,224,.38);
  font-style: italic;
}

/* Map filter toggle chips */
.map-filter-wrap {
  display: flex;
  flex-direction: row;    /* search magnifier | toggles column */
  align-items: flex-start;
  gap: 5px;
  margin-top: 6px;
}

.map-toggles-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.map-toggle-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 9px;
  background: rgba(10, 12, 22, 0.82);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: rgba(200,208,224,0.55);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  letter-spacing: .02em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .14s, color .14s, border-color .14s;
}
.map-toggle-btn:hover {
  background: rgba(10, 12, 22, 0.95);
  color: rgba(200,208,224,0.85);
  border-color: rgba(255,255,255,0.3);
}
.map-toggle-btn.active {
  background: rgba(29, 78, 216, 0.35);
  border-color: #3b82f6;
  color: #bfdbfe;
}
.map-toggle-btn.active .mtb-dot { background: #3b82f6; }
.mtb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(200,208,224,0.25);
  flex-shrink: 0;
  transition: background .14s;
}

/* Station dot tooltip */
.station-dot-tip { font-size: .72rem; }

/* Suppress browser focus outline on SVG paths (polylines, lift lines, etc.) */
.leaflet-overlay-pane path:focus,
.leaflet-overlay-pane path:focus-visible { outline: none; }

/* Lift line tooltip */
.leaflet-tooltip.lift-tip {
  background: rgba(15, 17, 23, .92);
  border: 1px solid #2a2f3e;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: .78rem;
  font-weight: 500;
  padding: 3px 9px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.leaflet-tooltip.lift-tip::before { display: none; }

/* Map legend */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 12px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  z-index: 500;
  font-size: .78rem;
}
.legend-title { font-weight: 600; margin-bottom: 6px; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .5px; font-size: .68rem; }
.legend-item { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-excellent { background: var(--clr-excellent); }
.dot-good      { background: var(--clr-good); }
.dot-fair      { background: var(--clr-fair); }
.dot-bad       { background: var(--clr-bad); }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--clr-surface);
  border-left: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .25s ease, border-color .25s ease;
  flex-shrink: 0;
}

/* ── Sidebar collapse toggle ────────────────────────────────────── */
.sidebar-toggle-btn {
  position: absolute;
  right: var(--sidebar-w);
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
  width: 18px;
  height: 44px;
  padding: 0;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--clr-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: right .25s ease, background .15s, color .15s;
}
.sidebar-toggle-btn:hover {
  background: var(--clr-surface2);
  color: var(--clr-text);
}
.sidebar-toggle-icon {
  transition: transform .25s ease;
  display: block;
  flex-shrink: 0;
}

/* Collapsed state */
.app-main.sidebar-collapsed .sidebar {
  width: 0;
  border-left-color: transparent;
}
.app-main.sidebar-collapsed .sidebar-toggle-btn {
  right: 0;
}
.app-main.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}
/* ── App footer (bottom of sidebar = bottom-right) ──────────────── */
.app-footer {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--clr-border);
  font-size: .7rem;
  color: var(--clr-muted);
  gap: 8px;
}
.app-footer-copy { white-space: nowrap; }
.app-footer-links { display: flex; gap: 12px; }
.app-footer-links a {
  color: var(--clr-muted);
  text-decoration: none;
  transition: color .15s;
}
.app-footer-links a:hover { color: var(--clr-text); }

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--clr-border);
}
.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--clr-muted);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-bottom .15s;
  border-bottom: 2px solid transparent;
}
.tab-btn.active {
  color: var(--clr-accent);
  border-bottom-color: var(--clr-accent);
}
.tab-content { display: none; flex-direction: column; overflow-y: auto; flex: 1; }
.tab-content.active { display: flex; }

/* Top lists */
.top-list-section { padding: 16px; }
.list-heading { font-size: .85rem; font-weight: 700; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.top-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.top-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--clr-surface2);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid transparent;
}
.top-list-item:hover { background: var(--clr-border); border-color: var(--clr-border); }
.rank { font-size: .7rem; font-weight: 700; color: var(--clr-muted); width: 16px; }
.rank-1 { color: #fbbf24; }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #cd7c2f; }
.item-name { flex: 1; font-size: .86rem; font-weight: 600; }
.item-flag { margin-right: .25rem; font-style: normal; }
.item-score { font-size: .86rem; font-weight: 700; }
.item-label { font-size: .72rem; color: var(--clr-muted); }

/* All locations */
.location-search {
  margin: 12px;
  padding: 9px 14px;
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  color: var(--clr-text);
  font-size: .85rem;
  outline: none;
}
.location-search:focus { border-color: var(--clr-accent); }
.location-list { list-style: none; overflow-y: auto; flex: 1; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.location-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s;
}
.location-list-item:hover { background: var(--clr-surface2); }
.loc-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.loc-name { flex: 1; font-size: .84rem; }
.loc-score { font-size: .82rem; font-weight: 700; }
.loc-country { font-size: .7rem; color: var(--clr-muted); }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: var(--shadow);
  animation: slide-up .2s ease;
}
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--clr-surface2);
  border: none;
  border-radius: 50%;
  width: 30px; height: 30px;
  color: var(--clr-muted);
  font-size: .9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--clr-border); color: var(--clr-text); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.modal-meta { font-size: .78rem; color: var(--clr-muted); }

.modal-score-badge {
  text-align: center;
  background: var(--clr-surface2);
  border-radius: var(--radius);
  padding: 10px 18px;
  border: 2px solid var(--clr-border);
  min-width: 90px;
  flex-shrink: 0;
}
.modal-score-badge.excellent { border-color: var(--clr-excellent); }
.modal-score-badge.good      { border-color: var(--clr-good); }
.modal-score-badge.fair      { border-color: var(--clr-fair); }
.modal-score-badge.bad       { border-color: var(--clr-bad); }

.score-value { font-size: 2rem; font-weight: 900; line-height: 1; }
.score-label { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--clr-muted); margin-top: 2px; }

/* Conditions grid */
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.cond-card {
  background: var(--clr-surface2);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.cond-icon { font-size: 1.3rem; }
.cond-value { font-size: 1rem; font-weight: 700; margin: 2px 0; }
.cond-name { font-size: .68rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .4px; }

.modal-summary {
  font-size: .84rem;
  color: var(--clr-muted);
  line-height: 1.6;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--clr-surface2);
  border-radius: 8px;
  border-left: 3px solid var(--clr-accent);
}

/* Score breakdown bars */
.score-breakdown { margin-bottom: 20px; }
.score-breakdown h4 { font-size: .78rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.breakdown-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: .82rem; }
.breakdown-label { width: 90px; color: var(--clr-muted); flex-shrink: 0; }
.breakdown-bar-wrap { flex: 1; background: var(--clr-surface2); border-radius: 99px; height: 6px; }
.breakdown-bar { height: 6px; border-radius: 99px; transition: width .4s; }
.breakdown-val { width: 28px; text-align: right; font-weight: 600; font-size: .78rem; }

/* Recent condition reports */
.recent-reports { margin-bottom: 20px; }
.recent-reports h4 { font-size: .78rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.conditions-history { display: block; }

/* Slideshow wrapper */
.ch-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.ch-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.ch-track {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch-arrow {
  flex-shrink: 0;
  width: 18px;
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  color: var(--clr-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, opacity .15s;
  padding: 0;
  user-select: none;
}
.ch-arrow:hover:not(:disabled) {
  background: var(--clr-border);
  color: var(--clr-text);
}
.ch-arrow:disabled {
  opacity: .2;
  cursor: default;
}

.report-card {
  padding: 12px 14px;
  background: var(--clr-surface2);
  border-radius: 8px;
  border-left: 3px solid var(--clr-border);
}
.report-card--latest { border-left-color: var(--clr-accent); }
.report-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.report-time { font-size: .72rem; color: var(--clr-muted); }
.report-now { background: var(--clr-accent); color: #fff; font-size: .65rem; padding: 1px 6px; border-radius: 99px; vertical-align: middle; }
.report-score { font-size: 1.1rem; font-weight: 700; }
.report-label { font-size: .8rem; font-weight: 600; margin-bottom: 6px; }
.report-stats { display: flex; gap: 14px; font-size: .75rem; color: var(--clr-muted); margin-bottom: 4px; }
.report-summary { font-size: .75rem; color: var(--clr-muted); font-style: italic; margin-top: 4px; }

/* ── Auth Gate Overlay ─────────────────────────────────────────── */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: gate-in .18s ease;
}
.gate-overlay[hidden] { display: none; }
@keyframes gate-in { from { opacity: 0; } }

.gate-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: 18px;
  width: 100%;
  max-width: 400px;
  padding: 32px 28px 24px;
  position: relative;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
  animation: slide-up .2s ease;
}

.gate-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--clr-surface2);
  border: none; border-radius: 50%;
  width: 28px; height: 28px;
  color: var(--clr-muted); font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.gate-close:hover { background: var(--clr-border); color: var(--clr-text); }

.gate-icon { font-size: 2rem; margin-bottom: 10px; }

.gate-title {
  font-size: 1.25rem; font-weight: 800;
  letter-spacing: -.3px; margin-bottom: 6px;
}

.gate-sub {
  font-size: .84rem; color: var(--clr-muted);
  line-height: 1.5; margin-bottom: 20px;
}

.gate-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: #f87171;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .83rem;
  margin-bottom: 12px;
}

.gate-form { display: flex; flex-direction: column; gap: 10px; }

.gate-input {
  height: 42px; width: 100%;
  padding: 0 13px;
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  color: var(--clr-text); font-size: .92rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}
.gate-input:focus { border-color: var(--clr-accent); }

.gate-pw-wrap { position: relative; }

.gate-btn-primary {
  height: 44px; width: 100%;
  background: #4aaca7; color: #fff;
  border: none; border-radius: 9px;
  font-size: .95rem; font-weight: 700;
  cursor: pointer; font-family: var(--font);
  transition: background .15s;
  margin-top: 2px;
}
.gate-btn-primary:hover    { background: #3d9a96; }
.gate-btn-primary:disabled { background: var(--clr-surface2); color: var(--clr-muted); cursor: not-allowed; }

.gate-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: .75rem; color: var(--clr-muted);
  margin: 14px 0 10px;
}
.gate-divider::before, .gate-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--clr-border);
}

.gate-btn-google {
  height: 42px; width: 100%;
  border: 1px solid var(--clr-border);
  border-radius: 9px;
  background: var(--clr-surface2);
  color: var(--clr-text); font-size: .88rem; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font);
  text-decoration: none;
  transition: background .15s;
}
.gate-btn-google:hover { background: var(--clr-border); }
.gate-btn-google svg { width: 17px; height: 17px; flex-shrink: 0; }

.gate-footer-links {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px;
  font-size: .79rem; color: var(--clr-muted);
}
.gate-footer-links a { color: var(--clr-accent); text-decoration: none; font-weight: 500; }
.gate-footer-links a:hover { text-decoration: underline; }

.gate-zoom-out {
  display: block; width: 100%;
  margin-top: 14px;
  background: none; border: 1px solid var(--clr-border);
  border-radius: 8px; padding: 9px;
  color: var(--clr-muted); font-size: .8rem;
  cursor: pointer; font-family: var(--font);
  transition: color .15s, border-color .15s;
}
.gate-zoom-out:hover { color: var(--clr-text); border-color: var(--clr-muted); }
.gate-zoom-out[hidden] { display: none; }

/* ── Loading overlay ───────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--clr-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
  font-size: .9rem;
  color: var(--clr-muted);
  transition: opacity .4s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-main { flex-direction: column; }
  .map-panel { height: 55vh; }
  .sidebar { width: 100%; height: 45vh; border-left: none; border-top: 1px solid var(--clr-border); transition: none; }
  :root { --sidebar-w: 100%; }
  .conditions-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar-toggle-btn { display: none; }
}

/* Score colour helpers */
.score-excellent { color: var(--clr-excellent); }
.score-good      { color: var(--clr-good); }
.score-fair      { color: var(--clr-fair); }
.score-bad       { color: var(--clr-bad); }

/* ── Light mode variables ───────────────────────────────────────── */
[data-theme="light"] {
  --clr-bg:       #f4f6fb;
  --clr-surface:  #ffffff;
  --clr-surface2: #edf0f7;
  --clr-border:   #d8dde8;
  --clr-text:     #1a1d27;
  --clr-muted:    #6b7399;
  --clr-accent:   #2563eb;
  --shadow:       0 4px 24px rgba(0,0,0,.10);
}

/* ── Light mode overrides ───────────────────────────────────────── */
[data-theme="light"] #map           { background: #d4dce8; }

[data-theme="light"] .modal-overlay { background: rgba(0,0,0,.35); }

[data-theme="light"] .leaflet-popup-content-wrapper,
[data-theme="light"] .leaflet-popup-tip { background: #fff; }
[data-theme="light"] .leaflet-popup-content-wrapper { color: #1a1d27; }

[data-theme="light"] .popup-detail-btn { background: #edf0f7; }
[data-theme="light"] .popup-detail-btn:hover { background: #d8dde8; }

[data-theme="light"] .map-legend { background: rgba(255,255,255,.92); }

[data-theme="light"] .loading-overlay { background: #f4f6fb; }

/* ── Theme toggle button ────────────────────────────────────────── */
.theme-toggle-btn {
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  line-height: 1;
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: var(--clr-border);
  border-color: var(--clr-accent);
}

/* ── Bikepark station map ───────────────────────────────────────── */
.station-map-container {
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  margin-bottom: 18px;
}

/* ── Station cards (bikepark modal) ────────────────────────────── */
.score-breakdown h4 {
  font-size: .78rem; color: var(--clr-muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px;
}
.station-card {
  background: var(--clr-surface2);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 3px solid var(--clr-border);
}
.station-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.station-card-left  { display: flex; align-items: center; gap: 8px; }
.station-card-right { display: flex; align-items: baseline; gap: 8px; text-align: right; }
.station-badge {
  font-size: .7rem; font-weight: 700;
  padding: 2px 9px; border-radius: 99px;
  border: 1px solid;
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
.station-elev  { font-size: .72rem; color: var(--clr-muted); }
.station-score { font-size: 1.15rem; font-weight: 800; }
.station-label-text { font-size: .75rem; color: var(--clr-muted); white-space: nowrap; }
.station-stats {
  font-size: .75rem; color: var(--clr-muted);
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.station-summary {
  font-size: .75rem; color: var(--clr-muted);
  font-style: italic; margin-top: 4px;
  line-height: 1.5;
}

/* ── Light-mode overrides for map controls ─────────────────────────────────── */
[data-theme="light"] .leaflet-tooltip.marker-label {
  background: #fff;
  border-color: rgba(0,0,0,0.15);
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
}

[data-theme="light"] .cluster-icon {
  background: rgba(255,255,255,0.92);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
[data-theme="light"] .cluster-count { color: #1e293b; }

[data-theme="light"] .map-recenter-btn {
  background: rgba(255,255,255,0.88);
  border-color: rgba(0,0,0,0.18);
  color: rgba(30,41,59,0.70);
}
[data-theme="light"] .map-recenter-btn:hover {
  background: rgba(255,255,255,0.98);
  border-color: rgba(0,0,0,0.30);
  color: rgba(30,41,59,0.90);
}

[data-theme="light"] .map-search-input {
  background: rgba(255,255,255,0.90);
  border-color: rgba(0,0,0,0.18);
  color: #1e293b;
}
[data-theme="light"] .map-search-input::placeholder { color: rgba(30,41,59,0.35); }
[data-theme="light"] .map-search-input:focus { border-color: rgba(59,130,246,.65); }

[data-theme="light"] .map-search-btn {
  background: rgba(255,255,255,0.88);
  border-color: rgba(0,0,0,0.18);
  color: rgba(30,41,59,0.60);
}
[data-theme="light"] .map-search-wrap.open .map-search-btn {
  background: rgba(255,255,255,0.96);
  border-color: rgba(59,130,246,.65);
  color: rgba(30,41,59,0.90);
}
[data-theme="light"] .map-search-btn:hover {
  color: rgba(30,41,59,0.90);
  border-color: rgba(0,0,0,0.30);
}

[data-theme="light"] .map-search-results {
  background: rgba(255,255,255,0.97);
  border-color: rgba(0,0,0,0.12);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
[data-theme="light"] .msr-item { color: rgba(30,41,59,0.70); }
[data-theme="light"] .msr-item strong { color: #1e293b; }
[data-theme="light"] .msr-item:hover,
[data-theme="light"] .msr-item.msr-active {
  background: rgba(59,130,246,0.10);
  color: #1e293b;
}
[data-theme="light"] .msr-empty { color: rgba(30,41,59,0.38); }

[data-theme="light"] .map-toggle-btn {
  background: rgba(255,255,255,0.88);
  border-color: rgba(0,0,0,0.18);
  color: rgba(30,41,59,0.65);
}
[data-theme="light"] .map-toggle-btn:hover {
  background: rgba(255,255,255,0.98);
  border-color: rgba(0,0,0,0.30);
  color: rgba(30,41,59,0.90);
}
[data-theme="light"] .map-toggle-btn.active {
  background: rgba(59,130,246,0.12);
  border-color: #3b82f6;
  color: #1d4ed8;
}
[data-theme="light"] .map-toggle-btn.active .mtb-dot { background: #3b82f6; }
[data-theme="light"] .mtb-dot { background: rgba(30,41,59,0.22); }

/* ── Skeleton / shimmer loading states ─────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.map-skeleton {
  position: absolute;
  inset: 0;
  z-index: 500;
  background: var(--clr-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.map-skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.04) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.map-skeleton-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--clr-muted);
  font-size: .875rem;
  position: relative;
  z-index: 1;
}
.map-skeleton-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.skel-item {
  display: block;
  height: 40px;
  background: var(--clr-surface2);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  position: relative;
  list-style: none;
}
.skel-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.05) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
