*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222536;
  --border: #2d3148;
  --text: #e8eaf0;
  --muted: #a8b1cc;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --green: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 12px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* NAV */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}

.nav-actions { display: flex; gap: 10px; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: .85; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-danger { background: #3d1a1a; color: var(--red); border: 1px solid #5a2020; }

/* LAYOUT */
/* Wide: the sidebar already eats 208px, so let content use the rest of the
   viewport. Still capped so charts don't stretch absurdly on ultrawides. */
.container { max-width: 1760px; margin: 0 auto; padding: 28px 32px; }
.hidden { display: none !important; }

/* APP SHELL + SIDEBAR TABS */
.app-shell { display: flex; align-items: flex-start; }

.sidebar {
  flex: 0 0 268px;
  position: sticky;
  top: 60px;                       /* below the sticky nav */
  height: calc(100vh - 60px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
}
.side-nav { display: flex; flex-direction: column; gap: 10px; }

/* Outlined, raised tabs — meant to read as physical buttons, not text links */
.side-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 1px 0 #00000055, 0 2px 6px #00000033;
  transition: background .15s, color .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.side-tab svg { flex: 0 0 auto; color: var(--muted); transition: color .15s; }

.side-tab:hover {
  background: var(--surface2);
  border-color: #454b6e;
  transform: translateY(-1px);
  box-shadow: 0 2px 0 #00000055, 0 4px 10px #00000040;
}
.side-tab:hover svg { color: var(--text); }

/* Active tab: accent edge + left marker so it stands out at a glance */
.side-tab.is-active {
  background: var(--surface2);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent) inset, 0 2px 10px #6c63ff33;
}
.side-tab.is-active svg { color: var(--accent); }
.side-tab.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.side-tab { position: relative; }

.side-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
  min-width: 26px;
  text-align: center;
}
.side-tab.is-active .side-count { border-color: var(--accent); }

.app-main { flex: 1 1 auto; min-width: 0; max-width: 100%; overflow-x: clip; }
.app-main .container { margin: 0 auto; }
.card { min-width: 0; }

.view-header { margin-bottom: 20px; }
.view-header h1 { font-size: 22px; font-weight: 700; }
.view-header p { font-size: 13px; margin-top: 2px; }

/* Month group separator inside the activities table */
tr.month-row td {
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 16px;
}
tr.month-row:hover td { background: var(--bg); }
tr.month-row { cursor: default; }

/* MOBILE TAB BAR — hidden on desktop, replaces the sidebar on small screens */
.mobile-tabbar { display: none; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }

  /* The sidebar rail is replaced wholesale by the dropdown */
  .sidebar { display: none; }

  .mobile-tabbar {
    display: block;
    position: sticky;
    top: 60px;                    /* under the sticky nav */
    z-index: 90;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;               /* also the positioning context for the chevron */
  }
  .mobile-tabbar select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding: 13px 38px 13px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
  }
  .mobile-tabbar select:focus { outline: none; box-shadow: 0 0 0 3px #6c63ff33; }
  .mobile-tabbar-chevron {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    pointer-events: none;
  }

  /* Reclaim horizontal space — 32px side padding wasted ~17% of a phone screen */
  .container { padding: 14px 10px; }

  /* Charts go full width and lose their inner gutters */
  .charts-row { gap: 12px; margin-bottom: 12px; }
  /* Detail-page charts are deliberately left at their desktop height — that page
     already reads well on a phone. */
  .chart-wrap { padding: 10px 4px 4px; height: 260px; }
  .card { border-radius: 10px; margin-bottom: 12px; }
  .card-header { padding: 12px 14px; }

  .stat-grid { gap: 10px; margin-bottom: 12px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }

  .overview-top, .detail-top { gap: 12px; margin-bottom: 12px; }

  /* 27 week columns can't fit a phone; scroll instead of squashing to slivers.
     JS scrolls this to the far right on render so the current week is visible. */
  .cal-wrap { padding: 10px 0 0 10px; overflow-x: auto; }
  .cal-wrap .cal-body-row { min-width: 620px; }
  .cal-wrap .cal-months-row { min-width: 620px; }
  /* The sticky weekday column needs an opaque backdrop as cells pass under it */
  .cal-day-labels-col { box-shadow: 6px 0 6px -4px #0f1117; }
  .cal-legend { padding: 10px 12px 12px; gap: 10px; }

  .view-header h1 { font-size: 19px; }
  .nav { padding: 0 12px; }
  .nav-user { display: none; }        /* email is too wide on a phone */
}

/* STAT GRID */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 14px; font-weight: 600; }
.unit { color: var(--muted); font-weight: 400; }

/* CHARTS */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { margin-bottom: 0; }
.chart-card--tall .chart-wrap { height: 340px; }
.chart-wrap { padding: 16px; height: 280px; position: relative; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* TABLE */
/* min-width:0 + max-width:100% keep the nowrap table scrolling INSIDE its card.
   Without them the 9-column table widened the whole page, so headings outside the
   card (e.g. the Runs "view-header") sat left of the scrolled viewport. */
.table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); cursor: pointer; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--surface2); color: var(--accent); border: 1px solid var(--border); }

/* HEART RATE ZONES */
.hr-zone { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.hr-low { background: #1a3a2a; color: var(--green); }
.hr-mod { background: #2a3a1a; color: #a3e635; }
.hr-hard { background: #3a2a1a; color: var(--orange); }
.hr-max { background: #3a1a1a; color: var(--red); }

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { opacity: .3; margin-bottom: 8px; }

/* DETAIL */
.back-btn { margin-bottom: 20px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.detail-header h1 { font-size: 24px; font-weight: 700; }

/* UPLOAD OVERLAY */
.upload-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 17, 23, .85);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.upload-overlay.active { display: flex; }
.upload-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

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

/* DETAIL TOP — map (left) + stat tiles (right) as one equal-height section */
.detail-top {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 24px;
}
.detail-top > .card { margin-bottom: 0; display: flex; flex-direction: column; }

/* No GPS (lifting, HIIT, treadmill): tiles use the full width */
.detail-top--nomap { grid-template-columns: 1fr; }
.detail-top--nomap .stat-grid--detail { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Tiles stretch to match the map's height instead of stacking at the top */
.stat-grid--detail {
  margin-bottom: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
}
.stat-grid--detail .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
}

@media (max-width: 1100px) {
  .detail-top { grid-template-columns: 1fr; }
  .stat-grid--detail { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .stat-grid--detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* MAP */
#mapContainer {
  height: 440px;
  flex: 1 1 auto;      /* fill the card so the section heights agree */
  width: 100%;
  background: var(--surface2);
}
.leaflet-container { background: #1a1d27; }
.leaflet-tile { filter: brightness(0.85) saturate(0.7); }

/* Pace legend bar */
.pace-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.pace-legend-bar {
  width: 80px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #f87171, #facc15, #4ade80);
}

/* HR reference legend */
.hr-ref-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}
.hr-ref-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hr-ref-swatch {
  width: 20px;
  height: 2px;
  border-top: 2px dashed;
}

/* Distance vs pace chart */
/* The four detail-page charts share one size so the 2x2 grid reads as a set */
.chart-card--detail { display: flex; flex-direction: column; }
.chart-card--detail .chart-wrap { height: 360px; flex: 1 1 auto; }

/* COMPARE BAR (between the map and the charts it toggles) */
.compare-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.compare-hint { font-size: 12px; }

/* Accent-filled so the control is visible, not a ghost button */
.btn-compare {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px #ffffff14 inset;
}
.btn-compare:hover { opacity: .9; }
/* Active = comparisons showing */
.btn-compare.btn-active {
  background: var(--surface2) !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* ── Analytics section ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 18px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.section-divider::before, .section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.scatter-legend { display: flex; gap: 10px; margin-left: auto; font-weight: 500; }

/* OVERVIEW TOP — totals (2x2) + training calendar, equal height */
.overview-top {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 2fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 24px;
}
.overview-top > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.overview-top .cal-wrap { flex: 1 1 auto; }

/* 2x2 totals that stretch to the calendar's height */
.stat-grid--totals {
  margin-bottom: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 16px;
}
.stat-grid--totals .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 1100px) {
  .overview-top { grid-template-columns: 1fr; }
}

/* Training calendar */
/* Cells FLEX to fill the card width, so they become wide rectangles */
.cal-wrap {
  padding: 10px 16px 0;
  --cal-gap: 5px;
  --cal-cell-h: 30px;
  --cal-labels-w: 30px;
}

.cal-months-row {
  display: flex;
  gap: var(--cal-gap);
  padding-bottom: 6px;
  padding-left: calc(var(--cal-labels-w) + 8px);
}
.cal-month-lbl {
  flex: 1 1 0;
  min-width: 0;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  font-weight: 600;
  text-align: left;
  overflow: visible;
}

.cal-body-row { display: flex; gap: 8px; }
/* Frozen weekday axis: stays put while the weeks scroll horizontally */
.cal-day-labels-col {
  display: flex;
  flex-direction: column;
  gap: var(--cal-gap);
  flex: 0 0 var(--cal-labels-w);
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  padding-right: 4px;
}
.cal-day-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  height: var(--cal-cell-h);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.cal-day-label.is-weekend { color: var(--muted); font-weight: 500; }
/* Abbreviate to one letter when the rows get short (12-month view) */
.cal-wrap[style*="17px"] .cal-day-label,
.cal-wrap[style*="22px"] .cal-day-label { font-size: 9px; }

/* Week-padding days outside the 6-month window: keep the grid, draw nothing */
.cal-day-outside { background: transparent; box-shadow: none; }
.cal-day-outside:hover { transform: none; }

.cal-weeks-cols { display: flex; gap: var(--cal-gap); flex: 1 1 auto; min-width: 0; }
.cal-col { display: flex; flex-direction: column; gap: var(--cal-gap); flex: 1 1 0; min-width: 0; }

.cal-day {
  width: 100%;
  height: var(--cal-cell-h);
  border-radius: 4px;
  background: var(--surface2);
  cursor: default;
  transition: transform .1s, outline-color .1s;
  /* Border on every cell so the gaps between days read clearly */
  box-shadow: inset 0 0 0 1px #00000055, 0 0 0 1px var(--border);
}
.cal-day:hover { transform: scale(1.06); z-index: 2; position: relative; }

/* Weekend rows sit on a slightly different track to separate the work week */
.cal-day.is-weekend { border-radius: 7px; }

/* Split cells (2+ activity types) get a stronger ring so the division is legible */
.cal-day.is-split { box-shadow: inset 0 0 0 1px #00000066, 0 0 0 1px var(--muted); }

/* Today */
.cal-day.is-today { box-shadow: inset 0 0 0 1px #00000055, 0 0 0 2px var(--text); }

/* Cells are colored by activity type inline; these are the two empty states */
.cal-day-rest   { background: #171a27; }
.cal-day-rest.is-weekend { background: #13161f; }
.cal-day-future { background: transparent; box-shadow: 0 0 0 1px var(--border); }
.cal-day-future:hover { transform: none; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px 14px;
  justify-content: flex-end;
}
.cal-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.cal-key i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cal-key i.cal-key-rest { background: #1e2235; }

/* Floating tooltip */
.cal-tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  z-index: 9999;
  display: none;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  line-height: 1.6;
}
.cal-tooltip.visible { display: block; }

/* UPLOAD DIALOG */
.modal-card--upload { max-width: 620px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone svg { color: var(--muted); opacity: .55; }
.dropzone-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dropzone-sub { font-size: 12px; max-width: 380px; }
.dropzone-sub code {
  background: var(--surface2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}
.dropzone-hint { font-size: 11px; margin-top: 2px; }

/* Drag-over state */
.dropzone.is-over {
  border-color: var(--accent);
  background: #6c63ff0f;
}
.dropzone.is-over svg { color: var(--accent); opacity: 1; }

.dropzone-or {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 180px;
  margin: 2px 0;
  color: var(--muted);
  font-size: 11px;
}
.dropzone-or::before, .dropzone-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.upload-status { margin-top: 16px; font-size: 13px; color: var(--muted); }

.upload-results { margin-top: 16px; }
.upload-results-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 600;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.upload-results-list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  font-size: 12px;
}
.upload-results-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 2px;
  border-bottom: 1px solid var(--border);
}
.upload-results-list li:last-child { border-bottom: none; }
.upload-results-list .u-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.upload-results-list .u-tag { flex: 0 0 auto; font-weight: 600; }
.u-ok  { color: var(--green); }
.u-dup { color: var(--muted); }
.u-err { color: var(--red); }

/* COMPARISON RUN PICKER */
.btn-pick {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}
.btn-pick:hover { border-color: var(--accent); opacity: 1; }

.modal-card--picker { max-width: 720px; }

.picker-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.picker-actions { display: flex; gap: 8px; margin-left: auto; }
.picker-body { max-height: 60vh; overflow-y: auto; padding: 0; }

.picker-row { cursor: pointer; }
.picker-row.is-on td { background: #6c63ff14; }
.picker-row.is-locked { opacity: .45; }
.picker-row.is-locked:hover td { background: transparent; }

/* Checkbox tinted with the comparison hue that run will actually use */
.picker-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--muted);
  border-radius: 4px;
  background: transparent;
}

/* AUTH */
.nav-user { font-size: 12px; color: var(--muted); margin-right: 2px; }

.auth-view {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
  margin-bottom: 22px;
}
.auth-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active { background: var(--surface2); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.auth-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #6c63ff26;
}
.auth-field input::placeholder { color: #6b7391; }

.auth-error {
  background: #3d1a1a;
  border: 1px solid #5a2020;
  color: #fca5a5;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
}
.auth-submit { justify-content: center; padding: 11px 16px; font-size: 14px; }
.auth-submit:disabled { opacity: .6; cursor: default; }
.auth-note { font-size: 11px; text-align: center; }

/* PROFILE */
.side-nav--bottom { margin-top: auto; }
.sidebar { display: flex; flex-direction: column; }

.profile-card { padding: 22px; }
.profile-head { display: flex; gap: 22px; align-items: flex-start; }

.profile-avatar-wrap { position: relative; flex: 0 0 auto; }
.profile-avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
  background: var(--surface2);
}
.profile-avatar--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface2);
}
.profile-avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.profile-avatar-edit:hover { opacity: .9; }

.profile-meta { flex: 1 1 auto; min-width: 0; }
.profile-meta h1 { font-size: 24px; font-weight: 700; }
.profile-joined { font-size: 12px; margin-top: 2px; }
.profile-bio { font-size: 13px; margin-top: 10px; white-space: pre-wrap; max-width: 62ch; }

.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.btn-count { border: 1px solid var(--border); }
.btn-count strong { color: var(--text); margin-right: 4px; }
.btn-count:hover { border-color: var(--accent); }

.profile-edit { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.profile-edit textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  width: 100%;
}
.profile-edit textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #6c63ff26; }
.profile-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Activity feed — route thumbnail left, stats right */
.profile-feed-header { background: transparent; border: none; padding: 4px 2px 12px; }
.profile-feed { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.feed-item {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s;
}
.feed-item:hover { border-color: var(--accent); }

.feed-map {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.feed-map svg { width: 100%; height: 100%; }
.feed-map-none { color: var(--muted); font-size: 11px; text-align: center; padding: 8px; }

.feed-body { min-width: 0; }
.feed-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.feed-title h3 { font-size: 15px; font-weight: 700; }
.feed-title .feed-date { font-size: 12px; color: var(--muted); }

.feed-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 10px 14px;
}
.feed-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.feed-stat-val { font-size: 14px; font-weight: 600; margin-top: 2px; }

/* People lists (Following / Followers / Find) */
.modal-card--people { max-width: 520px; }
.people-body { max-height: 60vh; overflow-y: auto; }
.people-list { display: flex; flex-direction: column; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.person:last-child { border-bottom: none; }
.person-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 15px;
}
.person-info { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.person-name { font-size: 14px; font-weight: 600; }
.person-name:hover { color: var(--accent); }
.person-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.find-search { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.find-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.find-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #6c63ff26; }

@media (max-width: 760px) {
  .profile-head { flex-direction: column; gap: 14px; align-items: flex-start; }
  .profile-avatar { width: 84px; height: 84px; }
  .feed-item { grid-template-columns: 1fr; gap: 12px; }
  .feed-map { height: 150px; }
}

/* Detail header actions */
.detail-actions { display: flex; align-items: center; gap: 8px; }

/* Expand icon button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* Compare toggle active state */
.btn-active { background: var(--accent) !important; color: #fff !important; opacity: 1 !important; }

/* Expand modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 16, 0.88);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body {
  padding: 20px;
  flex: 1;
  min-height: 0;
  height: calc(75vh - 80px);
  position: relative;
}
.modal-body canvas { width: 100% !important; height: 100% !important; }
