:root {
  color-scheme: dark;
  --bg: #060c14;
  --panel: #101b27;
  --panel2: #142333;
  --line: #26384a;
  --text: #eef7ff;
  --muted: #9db0c2;
  --brand: #2fe6b8;
  --blue: #3e7bfa;
  --purple: #9b4dff;
  --danger: #ff6074;
  --walk: #44e08f;
  --bike: #45b7ff;
  --drive: #9b4dff;

  --grad-brand: linear-gradient(120deg, #2fe6b8 0%, #3e7bfa 55%, #9b4dff 112%);
  --surface: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
  --shadow-sm: 0 2px 10px -4px rgba(0, 0, 0, .55);
  --shadow-md: 0 22px 48px -26px rgba(0, 0, 0, .8);
  --shadow-glow: 0 26px 60px -30px rgba(47, 230, 184, .4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  position: relative;
  min-height: 100vh;
}

/* Ambient atmosphere behind the dashboard — aurora wash + a faint map grid
   that keeps the territory theme present without distracting from data. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(52% 40% at 16% -2%, rgba(62, 123, 250, .18), transparent 66%),
    radial-gradient(46% 38% at 88% 2%, rgba(47, 230, 184, .13), transparent 66%),
    radial-gradient(50% 50% at 94% 88%, rgba(155, 77, 255, .10), transparent 72%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: .45;
  background-image:
    linear-gradient(rgba(120, 150, 180, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 150, 180, .05) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px;
  mask-image: radial-gradient(120% 80% at 50% 0%, #000 15%, transparent 72%);
  -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 15%, transparent 72%);
}

.wrap { width: min(1180px, calc(100% - 32px)); margin: auto; }

/* Selection */
::selection {
  background: rgba(47, 230, 184, 0.32);
  color: var(--text);
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(6, 12, 20, .72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}
.brand span { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.nav, .footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; flex-wrap: wrap; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; text-decoration: none; }
.brand img { width: 32px; }
.brand span, .eyebrow { color: var(--brand); }
.footer { color: var(--muted); font-size: .9rem; }

/* Hero */
.hero { padding: 56px 0; max-width: 720px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4.6rem); line-height: .98; margin: 0 0 16px; letter-spacing: -0.03em; font-weight: 800; }
.auth-shell .hero h1 {
  background: linear-gradient(120deg, var(--text) 30%, var(--brand) 78%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); font-size: 1.1rem; }
.panel-hero {
  position: relative;
  max-width: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background:
    radial-gradient(80% 140% at 100% 0%, rgba(155, 77, 255, .12), transparent 60%),
    linear-gradient(135deg, rgba(47, 230, 184, .14), rgba(62, 123, 250, .11));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-radius: 28px;
  padding: 30px;
  margin-top: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.panel-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--grad-brand);
}
.panel-hero h1 {
  background: linear-gradient(120deg, var(--text), #bfe6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* Auth */
.auth-shell { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center; }
.card {
  background: var(--panel);
  background-image: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin-top: 0;
}
.auth-card { max-width: 460px; margin-left: auto; width: 100%; }
.hidden { display: none !important; }

/* Tabs / filter pills */
.tabs, .section-tabs, .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button, .section-tabs button, .filters button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tabs button:hover, .section-tabs button:hover, .filters button:hover { border-color: var(--brand); color: var(--text); }
.tabs .active, .section-tabs .active, .filters .active {
  background: var(--grad-brand);
  color: #04221b;
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 8px 20px -10px rgba(47, 230, 184, .6);
}

/* Forms */
label { display: grid; gap: 8px; margin: 12px 0; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b1520;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  transition: border-color .15s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  font: inherit;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--blue)); color: #04131a; border: 0; }
.btn.danger { background: rgba(255, 96, 116, .12); border-color: rgba(255, 96, 116, .5); color: #ff9aaa; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.muted { color: var(--muted); }
a { color: var(--brand); }
.small { font-size: .9rem; }

.message {
  position: relative;
  padding: 12px 40px 12px 44px;
  border-radius: 14px;
  margin: 12px 0;
  border: 1px solid transparent;
  animation: msg-in .18s ease;
}
.message::before {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  line-height: 1;
}
.message.error { background: rgba(255, 96, 116, .12); color: #ffb2bf; border-color: rgba(255, 96, 116, .3); }
.message.error::before { content: "⚠"; color: #ffb2bf; }
.message.ok { background: rgba(47, 230, 184, .12); color: #aaffea; border-color: rgba(47, 230, 184, .3); }
.message.ok::before { content: "✓"; color: #aaffea; }
.message .msg-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: .6;
}
.message .msg-close:hover { opacity: 1; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Dashboard grid */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  padding: 18px;
  border-radius: 20px;
  background: var(--panel);
  background-image: var(--surface);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .2s ease;
}
.stat:hover {
  transform: translateY(-3px);
  border-color: rgba(47, 230, 184, .4);
  box-shadow: var(--shadow-md);
}
.stat::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--grad-brand);
  opacity: .75;
}
.stat .value {
  font-size: 1.75rem;
  font-weight: 900;
  margin-top: 8px;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff, #b8d6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }

.chart { display: flex; align-items: end; gap: 5px; height: 180px; border-bottom: 1px solid var(--line); padding-top: 12px; }
.bar { flex: 1; min-width: 3px; background: linear-gradient(180deg, var(--brand), var(--blue)); border-radius: 7px 7px 0 0; }

.mode-row, .activity {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  transition: background .15s ease;
}
.mode-row:last-child, .activity:last-child { border-bottom: none; }
.activity { grid-template-columns: 1fr auto; }
.activity:hover { background: rgba(255, 255, 255, .03); }
.mode-icon { font-size: 1.8rem; }
.pill { display: inline-flex; border-radius: 999px; padding: 4px 9px; background: #192a3a; color: var(--muted); font-size: .82rem; margin-right: 6px; }
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.activity-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.activity-actions { display: flex; gap: 8px; align-items: center; }
.type-pill { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .68rem; }
.type-pill.type-loop { background: rgba(68, 224, 143, .16); color: var(--walk); }
.type-pill.type-track { background: rgba(69, 183, 255, .16); color: var(--bike); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }

.replay-map { width: 100%; height: 420px; background: #07111a; border-radius: 18px; margin-top: 12px; z-index: 0; }
.replay-map .leaflet-tile-pane { filter: brightness(0.72) saturate(0.9) invert(1) hue-rotate(180deg); }
.replay-map .leaflet-control-zoom a {
  background: var(--panel2);
  color: var(--text);
  border-color: var(--line) !important;
}
.replay-map .leaflet-control-zoom a:hover { background: var(--panel); }
.replay-map .leaflet-control-attribution {
  background: rgba(8, 16, 24, .75);
  color: var(--muted);
}
.replay-map .leaflet-control-attribution a { color: var(--muted); }
.replay-cursor { filter: drop-shadow(0 0 6px currentColor); animation: replay-pulse 1s ease-in-out infinite; }
@keyframes replay-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.replay-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.replay-controls .btn { padding: 10px 14px; line-height: 1; }
.replay-progress { flex: 1; height: 6px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.replay-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--blue)); transition: width .1s linear; }

.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-right: 10px; }
.unit-toggle button {
  border: 0;
  background: var(--panel);
  color: var(--muted);
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.unit-toggle button.active { background: var(--brand); color: #04221b; }

.avatar-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar-row img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: #07111a; border: 1px solid var(--line); }

/* Route builder */
.route-layout { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
.route-controls .card { position: sticky; top: 84px; }
.route-mode, .route-method { margin-bottom: 12px; }
.route-method button { flex: 1; }
.btn.block { width: 100%; margin-top: 14px; }
.row-check { display: flex; align-items: center; gap: 10px; flex-direction: row; color: var(--text); font-weight: 700; margin: 14px 0; }
.row-check input { width: auto; }
.notif-prefs { display: flex; flex-direction: column; margin-top: 10px; }
.notif-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-row:last-child { border-bottom: none; }
.notif-row input[type="checkbox"] { width: auto; margin-top: 4px; }
.notif-copy { flex: 1; }
.notif-label { color: var(--text); font-weight: 700; font-size: .95rem; }
.route-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.route-actions .btn { flex: 1 1 120px; }
.route-landmarks { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--brand); }
.chip.wp { cursor: default; background: var(--panel); }
.chip .chip-x { color: var(--muted); font-weight: 900; }
.chip .chip-mult { color: var(--brand); font-size: .78rem; }
.route-preview { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.route-preview .rp { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.route-preview .rp .value { font-size: 1.25rem; font-weight: 900; margin-top: 4px; }
.route-preview .rp.wide { grid-column: 1 / -1; }
.route-save { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }

.route-map-card { padding: 12px; position: relative; }
.route-map { width: 100%; height: min(72vh, 640px); min-height: 420px; background: #07111a; border-radius: 14px; z-index: 0; }
.locate-btn { position: absolute; top: 22px; right: 22px; z-index: 400; padding: 8px 12px; box-shadow: 0 6px 18px rgba(0,0,0,.35); }

/* Shared dark-map treatment (route builder + replay) */
.tl-map .leaflet-tile-pane { filter: brightness(0.72) saturate(0.9) invert(1) hue-rotate(180deg); }
.tl-map .leaflet-control-zoom a { background: var(--panel2); color: var(--text); border-color: var(--line) !important; }
.tl-map .leaflet-control-zoom a:hover { background: var(--panel); }
.tl-map .leaflet-control-attribution { background: rgba(8, 16, 24, .75); color: var(--muted); }
.tl-map .leaflet-control-attribution a { color: var(--muted); }
.route-wp-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #04221b; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .8rem; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.saved-route-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill.shared-pill { background: rgba(155, 77, 255, .18); color: var(--purple); }

/* Team plans */
.two-col.tight { gap: 12px; margin-top: 0; }
.two-col.tight label { margin: 8px 0; }
.when-preview { color: var(--brand); font-weight: 700; margin: 4px 0 8px; min-height: 1.2em; }
.map-hint { margin: 0 4px 10px; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; text-decoration: underline; }
.raid-target { border: 1px dashed var(--line); border-radius: 14px; padding: 12px; margin: 12px 0 4px; }
.raid-progress { height: 6px; border-radius: 999px; background: var(--panel2); overflow: hidden; margin: 8px 0; max-width: 360px; }
.raid-progress > div { height: 100%; background: linear-gradient(90deg, var(--danger), var(--purple)); }
.session-desc { margin: 4px 0; color: var(--text); }
.session-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 360px; }
.pill.live-pill { background: rgba(47, 230, 184, .18); color: var(--brand); }
textarea { resize: vertical; }

@media (max-width: 850px) {
  .route-layout { grid-template-columns: 1fr; }
  .route-controls .card { position: static; }
}

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .auth-shell, .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-hero { display: block; }
  .panel-hero .btn { margin-top: 16px; }
  .hero { padding: 32px 0; }
  .auth-card { margin: 0; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}

/* Auth-view welcome preview column */
.auth-shell .hero {
  padding-right: 12px;
}
.auth-shell .hero .eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.auth-shell .hero p {
  margin-top: 8px;
}
.hero-perks {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}
.hero-perks li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: .95rem;
}
.hero-perks li::before {
  content: "✓";
  color: var(--brand);
  font-weight: 900;
  margin-top: 1px;
  flex: none;
}

.auth-card {
  animation: card-in .3s ease;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Section tabs — sticky, scrollable on narrow screens */
.section-tabs {
  position: sticky;
  top: 64px;
  z-index: 4;
  background: rgba(9, 16, 26, .8);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  padding: 10px;
  margin: 12px -4px 20px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs button { white-space: nowrap; flex: none; }

/* Empty state polish */
.activity.muted {
  padding: 32px 20px;
  text-align: center;
  display: block;
  color: var(--muted);
  font-size: .95rem;
}

/* Skeleton loaders */
.skeleton {
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel2) 50%, var(--panel) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s infinite;
  border-radius: 14px;
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.stat.skeleton { min-height: 82px; border-color: transparent; }
.stat.skeleton::after { display: none; }

/* Refresh button spin animation */
.btn.refreshing::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Filter pill count badge (e.g. "Walk 12") */
.filters button .count-badge,
.section-tabs button .count-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: inherit;
  font-size: .72rem;
  font-weight: 800;
  vertical-align: 1px;
}
.filters button.active .count-badge,
.section-tabs button.active .count-badge {
  background: rgba(0,0,0,.22);
}

/* Activity row layout — clearer, spacious, mobile-friendly */
.activity {
  padding: 16px;
}
.activity-actions .btn {
  padding: 8px 12px;
  font-size: .85rem;
  border-radius: 10px;
}
@media (max-width: 640px) {
  .activity {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .activity-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Search input for history */
.search-input {
  flex: 1;
  min-width: 180px;
  background: #0b1520;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--brand); }

/* Kbd hint */
.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .72rem;
  font-weight: 700;
}

/* Print-friendly: hide chrome that doesn't belong on a printed stat page */
@media print {
  .topbar, .section-tabs, .filters, .filter-group, .btn, .replay-controls, .footer { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .stat, .list { background: #fff !important; border: 1px solid #ccc; box-shadow: none; color: #000; }
}

/* -------- Tab unread badge -------- */
.tab-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--brand);
  color: #051a11;
  font-weight: 900;
  font-size: .7rem;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}
.tab-badge.hidden { display: none; }

/* -------- Membership card -------- */
.membership-card { padding: 18px; margin-bottom: 16px; }
.membership-card.hidden { display: none; }
.membership-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.membership-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .8rem;
}
.membership-badge.pro {
  background: linear-gradient(135deg, #f4d35e, #ee964b);
  color: #202020;
}
.membership-title { font-weight: 800; color: var(--text); font-size: 1rem; }
.membership-actions { margin-left: auto; }

/* -------- Notification feed -------- */
.notif-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; margin: 8px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.notif-item.unread { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: inset 3px 0 0 var(--brand); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { color: var(--text); font-weight: 800; font-size: .95rem; }
.notif-meta { color: var(--muted); font-size: .75rem; margin-top: 6px; }
.notif-actions { display: flex; flex-direction: column; gap: 6px; }
.btn.small { font-size: .82rem; padding: 6px 10px; }

/* -------- Badges grid -------- */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.badge-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.badge-tile.earned { opacity: 1; border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.badge-tile:hover { transform: translateY(-1px); }
.badge-emoji { font-size: 2rem; margin-bottom: 6px; }
.badge-name { color: var(--text); font-weight: 800; font-size: .88rem; margin-bottom: 2px; }

/* -------- Activity analytics (this-week / weekly goal / PRs) -------- */
.week-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.week-row:first-child { border-top: 0; }
.week-row .muted { flex: 1; font-size: .88rem; }
.week-row .value { font-weight: 800; color: var(--text); }
.delta { font-size: .75rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; border: 1px solid; }
.delta.pos { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.delta.neg { color: #f87171; border-color: color-mix(in srgb, #f87171 40%, var(--line)); }
.delta.neutral { color: var(--muted); border-color: var(--line); }

.goal-headline { font-size: 1.05rem; margin-bottom: 8px; color: var(--text); }
.goal-track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin-bottom: 6px; }
.goal-fill { height: 100%; background: var(--brand); border-radius: 5px; }
.goal-editor { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.goal-editor input { max-width: 100px; }

.records-group { margin-bottom: 14px; }
.records-title {
  color: var(--muted); font-size: .72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.pr-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.pr-row:first-of-type { border-top: 0; }
.pr-label { color: var(--text); font-weight: 700; }
.pr-value { color: var(--text); font-weight: 900; }

/* -------- Mobile refinements --------
   The two big grid breakpoints above (850px and 480px) do the heavy lifting;
   this block tightens spacing at phone widths, wraps a few flex rows that
   were fixed-width, and shrinks maps so they don't dominate the viewport. */
@media (max-width: 640px) {
  .wrap { width: calc(100% - 24px); }
  .hero { padding: 32px 0; }
  .hero h1 { line-height: 1.05; }
  .panel-hero { padding: 20px; border-radius: 18px; }
  .card { padding: 18px; border-radius: 18px; }
  .list { border-radius: 18px; }
  .replay-map { height: 320px; }
  .route-map { height: min(60vh, 420px); min-height: 300px; }
  .locate-btn { top: 18px; right: 18px; padding: 6px 10px; font-size: .82rem; }
  .membership-row { flex-direction: column; align-items: flex-start; }
  .membership-actions { margin-left: 0; }
  .btn { padding: 11px 14px; }
  .avatar-row { justify-content: center; text-align: center; }
  .avatar-row img { width: 84px; height: 84px; }
  .filter-group .search-input,
  .filter-group select { flex: 1 1 140px; min-width: 0; }
  .notif-item { padding: 12px; }
  .notif-actions { flex-direction: row; flex-wrap: wrap; }
  .footer { justify-content: center; text-align: center; font-size: .82rem; }
  .section-tabs { top: 60px; }
  .replay-controls { flex-wrap: wrap; }
  .replay-controls .replay-progress { flex: 1 1 100%; order: 3; }
  .pr-row { grid-template-columns: 1fr auto; }
  .pr-row .delta { grid-column: 2; }
}

@media (max-width: 480px) {
  .badges-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .badge-tile { padding: 14px 8px; }
  .badge-emoji { font-size: 1.6rem; }
  h1 { font-size: clamp(1.8rem, 8vw, 2.4rem); }
}
