/* Design tokens follow Apple's Human Interface Guidelines: system backgrounds and grouped
   surfaces, system label colours, hairline separators and the system status colours. The brand
   mint stays as the one tint colour. */
:root {
  --bg: #0a131d;                        /* systemBackground (dark) */
  --bg-art: #0a131d;                    /* plain: no glows behind the pages */
  --card: #13202e;                      /* secondarySystemBackground */
  --card2: #1d2d3f;                     /* tertiarySystemBackground / fills */
  --text: #eaf2f7;                      /* label */
  --muted: #8fa3b6;        /* secondaryLabel */
  --line: rgba(143,163,182,.22);            /* separator */
  --accent: #71d6b3;                    /* tint: the logo's mint */
  --accent-ink: #00130c;
  --slow: #ff453a;   /* systemRed: too slow -> speed up  */
  --orange: #ff9f0a; /* systemOrange: challenge icons and tags */
  --fast: #0a84ff;   /* systemBlue:   too fast -> slow down */
  --ok: #30d158;     /* systemGreen */
  --danger: #ff453a; /* systemRed */
  --nav-h: 56px;
  --accent-text: #71d6b3;
  --accent-soft: rgba(113,214,179,.16);
  --route-stroke: #71d6b3;
  --overlay: rgba(19,32,46,.8);        /* materials floating on the map (blurred) */
  --scrim: #0a131d;
  --nav-bg: rgba(10,19,29,.84);         /* bar material, blurred */
  --map-bg: #13202e;
  --hero-from: #13202e;
  --hero-border: transparent;
  --dot-grid: #1d2d3f;
  --press: rgba(255,255,255,.22);
  --toast-bg: rgba(29,45,63,.95);
  --toast-text: #fff;
  --toast-action: #71d6b3;
  --attrib-filter: invert(1);
  --logo-ink: #ffffff;
  --logo-glow: rgba(113,214,179,0);
  --logo-track: #1d2d3f;
  --logo-fill: #71d6b3;
  --radius: 12px;
  --blur: saturate(1.8) blur(20px);
  --seg-bg: #13202e; --seg-on: #2a3e55;   /* segmented controls (Week / Month / Year) */
  --blade: linear-gradient(90deg, #b9e83a, #71d6b3);   /* the skate-blade line under big numbers */
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #edf3f7;                        /* systemGroupedBackground */
  --bg-art: #edf3f7;
  --card: #ffffff;                      /* secondarySystemGroupedBackground */
  --card2: #e3edf3;       /* tertiarySystemFill */
  --text: #0e1a2b;
  --muted: #5a6b7d;
  --line: #d3e1ea;
  --accent: #0e7a5b;                    /* deep mint: readable on white */
  --accent-ink: #ffffff;
  --slow: #d70015;   /* systemRed, accessible variant */
  --orange: #c93400;
  --fast: #007aff;
  --ok: #248a3d;     /* systemGreen, accessible variant */
  --danger: #ff3b30;
  --accent-text: #0e7a5b;
  --accent-soft: rgba(14,122,91,.1);
  --route-stroke: #0e7a5b;
  --overlay: rgba(255,255,255,.86);
  --scrim: #edf3f7;
  --nav-bg: rgba(255,255,255,.86);
  --map-bg: #dfe9ef;
  --hero-from: #ffffff;
  --hero-border: transparent;
  --dot-grid: #e3edf3;
  --press: rgba(0,0,0,.1);
  --toast-bg: rgba(255,255,255,.95);
  --toast-text: #0e1a2b;
  --toast-action: #0e7a5b;
  --attrib-filter: none;
  --logo-ink: #000000;
  --logo-glow: rgba(113,214,179,0);
  --logo-track: #dbe6ed;
  --logo-fill: #0e7a5b;
  --seg-bg: #dbe6ed; --seg-on: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Text follows the reader's text size (Dynamic Type on iPhone, browser text size elsewhere):
   1rem = the body size, 17px by default. Fixed per Apple HIG. Audit by HIG Compliance Auditor (Omraj Kumar). */
html { font-size: 106.25%; }
/* iPhone/iPad only: on a Mac this system style is a 13px desktop size */
@supports (font: -apple-system-body) {
  @media (hover: none) and (pointer: coarse) { html { font: -apple-system-body; } }
}
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
}
body {
  font: 1rem/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.025em; -webkit-font-smoothing: antialiased;   /* -0.43px at 17px, per Apple HIG */
  overscroll-behavior: none; touch-action: manipulation;          /* no double-tap zoom */
}
/* iPhone app: long-pressing a label or button doesn't select text or open a Copy menu (that's a
   website thing); text fields still select and paste normally */
.native-app body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.native-app :is(input, textarea, [contenteditable]) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
body { display: flex; flex-direction: column; height: 100dvh; padding-top: env(safe-area-inset-top); background: var(--bg-art); }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
h1 { font-size: 1.647rem; font-weight: 700; letter-spacing: -.029em; line-height: 1.15; margin: 0; }   /* iOS title 1: -0.8px at 28px */
h2 { margin: 0 0 12px; font-size: 1.294rem; font-weight: 700; }
h3 { margin: 0 0 8px; font-size: 0.7647rem; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }   /* grouped section header */
.muted { color: var(--muted); font-size: 0.8824rem; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }

/* The pages live in their own layer, cut off at the bottom bar, so nothing on a page (run tiles,
   map buttons, badges) can ever be drawn over the bar. Only full-screen overlays sit above it. */
main { flex: 1; min-height: 0; position: relative; z-index: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 16px; }
.view.active { display: flex; flex-direction: column; }
#view-record { overflow: hidden; padding-bottom: 10px; }

/* ---------- map ---------- */
.map-wrap { position: relative; flex: 1; min-height: 150px; }
.map { position: absolute; inset: 0; background: var(--map-bg); }
.leaflet-container .leaflet-control-attribution {
  background: var(--overlay); color: var(--muted); font-size: 0.6471rem;
}
.leaflet-container .leaflet-control-attribution a { color: var(--text); }

/* vector map: copyright notice as a small dark (i) button */
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--overlay); color: var(--muted); font-size: 0.7059rem; }
.maplibregl-ctrl-attrib.maplibregl-compact a { color: var(--text); }
.maplibregl-ctrl-attrib-button { filter: var(--attrib-filter); opacity: .6; }
.end-dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.gps-pill {
  position: absolute; top: 10px; left: 10px; z-index: 500;
  background: var(--overlay); padding: 5px 10px; border-radius: 99px; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  font-size: 0.7647rem; font-weight: 600; color: var(--muted);
}
.gps-pill.good { color: var(--ok); }
.gps-pill.weak { color: var(--slow); }
.gps-pill.bad { color: var(--danger); }
.map-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 500;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--overlay); color: var(--text); display: grid; place-items: center;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.map-btn svg { width: 22px; height: 22px; }
.map-btn.following { color: var(--accent-text); }

/* before a run starts: map, target, week and Start. Pace status + numbers appear once you run. */
#view-record.is-idle .guard,
#view-record.is-idle .run-stats { display: none; }

.locating {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 600;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  background: var(--overlay); padding: 12px 16px; border-radius: 12px;
  font-weight: 600; font-size: 1rem;
}
.locating.done { display: none; }
.locating.error .spinner { display: none; }
.loc-title, .loc-retry { display: none; }
/* location off: a card with a title, what to do, and Try again */
#locating.error { flex-direction: column; align-items: flex-start; gap: 8px; width: min(340px, calc(100% - 32px));
  padding: 16px 18px; font-weight: 500; font-size: 0.8824rem; line-height: 1.4; }
#locating.error .loc-title { display: block; font-size: 1.059rem; }
#locating.error .loc-retry:not(.hidden) { display: block; align-self: stretch; margin-top: 4px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 3px solid var(--line); border-top-color: var(--accent-text);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* "you are here": dot with your profile picture */
.me-dot {
  position: relative; width: 26px; height: 26px; border-radius: 50%;
  background: #0a84ff; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.me-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 3px solid #0a84ff; animation: ping 2s ease-out infinite;
}
.me-dot .avatar { width: 100%; height: 100%; font-size: 10px; background: none; }
@keyframes ping { from { transform: scale(1); opacity: .8; } to { transform: scale(2.6); opacity: 0; } }

/* ---------- pace guard (compact status strip) ---------- */
.guard {
  margin-bottom: 8px; padding: 8px 12px; border-radius: 12px;
  background: var(--card); border: 1px solid transparent;
  transition: background .3s, border-color .3s;
}
.guard-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.guard-label { font-weight: 600; font-size: 1rem; white-space: nowrap; }
.guard-sub { font-size: 0.7647rem; color: var(--muted); text-align: right; }
.guard.ok { border-color: transparent; }
.guard.ok .guard-label { color: var(--ok); }
.guard.slow { border-color: transparent; background: color-mix(in srgb, var(--slow) 16%, var(--card)); }
.guard.slow .guard-label { color: var(--slow); }
.guard.fast { border-color: transparent; background: color-mix(in srgb, var(--fast) 16%, var(--card)); }
.guard.fast .guard-label { color: var(--fast); }
.guard.pulse { animation: pulse .7s ease-out; }
@keyframes pulse { 0% { transform: scale(1.03); } 100% { transform: scale(1); } }

.gauge {
  position: relative; height: 6px; border-radius: 3px; margin: 8px 2px 2px;
  /* green middle third = inside tolerance; gauge spans ±3× tolerance */
  background: linear-gradient(90deg, var(--slow) 0 33.3%, var(--ok) 33.3% 66.6%, var(--fast) 66.6% 100%);   /* too slow left, too fast right */
  opacity: .9;
}
.needle {
  position: absolute; top: -5px; left: 50%; width: 5px; height: 16px; border-radius: 3px;
  background: var(--text); transform: translateX(-50%); box-shadow: 0 0 0 2px var(--bg);
  transition: left 1s linear, opacity .3s; opacity: .25;   /* one smooth glide per second's update */
}
.needle.live { opacity: 1; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 12px 0; }
.stat { background: var(--card); border-radius: var(--radius); padding: 8px 12px; }
.stat b { display: block; font-size: 1.765rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat small { color: var(--muted); font-size: 0.7647rem; }

/* ---------- record screen bottom panel ---------- */
.rec-panel { flex: none; padding: 10px 12px 0; }
.rec-panel .week-strip { margin: 8px 0 0; width: 100%; }
.rec-panel .controls { margin: 10px 0 0; }

.run-stats { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--card); cursor: pointer; }
.run-stats:active { background: var(--card2); }
.rs-expand {
  position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card2); color: var(--text); font-size: 17px;
}
.rs-pace { flex: none; min-width: 112px; text-align: center; }
.rs-pace b { display: block; font-size: 2.706rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; transition: color .3s; }
.rs-pace small, .rs-grid small { color: var(--muted); font-size: 0.7647rem; }
.run-stats.st-ok .rs-pace b { color: var(--ok); }
.run-stats.st-slow .rs-pace b { color: var(--slow); }
.run-stats.st-fast .rs-pace b { color: var(--fast); }
.rs-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding-left: 12px; border-left: 1px solid var(--line); }
.rs-grid b { display: block; font-size: 1.412rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* expandable stats: handle on top of the panel during a run */
.panel-handle {
  display: none; width: 100%; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; padding: 0 0 8px; margin-top: -4px;
  color: var(--muted); font-size: 0.7647rem; font-weight: 700; touch-action: none;
}
.panel-handle .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
#view-record:not(.is-idle) .panel-handle { display: flex; }

.full-stats { display: none; }
/* stats page: only the numbers (plus pause controls); map, status strip and target chip hidden */
#view-record.stats-full:not(.is-idle) .map-wrap,
#view-record.stats-full:not(.is-idle) .run-stats,
#view-record.stats-full:not(.is-idle) .guard,
#view-record.stats-full:not(.is-idle) .target-row,
#view-record.stats-full:not(.is-idle) .panel-handle { display: none; }
#view-record.stats-full:not(.is-idle) .rec-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: 6px; }
#view-record.stats-full:not(.is-idle) .full-stats { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.fs-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 6px; }
.fs-back { border: 0; background: var(--card); border-radius: 99px; padding: 8px 14px; font-weight: 700; font-size: 0.8824rem; }
.fs-status { font-size: 0.8824rem; font-weight: 700; color: var(--muted); }
.full-stats.st-ok .fs-status { color: var(--ok); }
.full-stats.st-slow .fs-status { color: var(--slow); }
.full-stats.st-fast .fs-status { color: var(--fast); }
.fs-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fs-row {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  border-top: .5px solid var(--line); min-height: 0;
}
.fs-row:first-child { border-top: 0; }
.fs-row small { font-size: 0.7647rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.fs-row b { font-size: clamp(40px, 13vw, 60px); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.fs-row span { font-size: 1.059rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
.fs-row.fs-pace b { font-size: clamp(64px, 22vw, 104px); transition: color .3s; }
.full-stats.st-ok .fs-pace b { color: var(--ok); }
.full-stats.st-slow .fs-pace b { color: var(--slow); }
.full-stats.st-fast .fs-pace b { color: var(--fast); }

.target-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.target-chip {
  flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: baseline; gap: 5px;
  border: 0; border-radius: 99px; padding: 8px 14px; background: var(--card);
  font-size: 0.8235rem; color: var(--muted); white-space: nowrap; overflow: hidden;
}
.target-chip b { color: var(--text); font-size: 1.059rem; font-variant-numeric: tabular-nums; }
.target-chip small { font-size: 0.7647rem; overflow: hidden; text-overflow: ellipsis; }
.target-chip .edit { margin-left: auto; padding-left: 6px; }
.mini-switch { flex: none; display: flex; align-items: center; gap: 8px; font-size: 0.7647rem; font-weight: 600; color: var(--muted); }
.mini-switch .switch { width: 44px; height: 26px; }
.mini-switch .switch span::after { width: 20px; height: 20px; }
.mini-switch .switch input:checked + span::after { transform: translateX(18px); }
.btn.lock-btn { flex: none; width: 64px; padding: 0; font-size: 1.412rem; }

.round {
  width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none;
  background: var(--card2); font-size: 1.706rem; line-height: 1;
}

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--card2); border-radius: 99px; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .25s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch span { background: rgba(120,120,128,.32); }

/* ---------- buttons ---------- */
.controls { display: flex; gap: 10px; margin: 12px 12px 0; }
.btn {
  flex: 1; border: 0; border-radius: var(--radius); padding: 14px 16px;
  background: var(--card2); font-weight: 600; font-size: 1rem; letter-spacing: -.02em;
}
.btn.big { padding: 16px; font-size: 1rem; border-radius: 12px; }
.btn.small { flex: none; padding: 7px 14px; font-size: 0.8824rem; border-radius: 99px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
/* one accent colour for every main action: mint (lime is kept for the route line on the map) */
.btn.mint { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.danger-text { color: var(--danger); }
.btn:active, .round:active { opacity: .7; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- route planner ---------- */
#view-routes { overflow: hidden; padding-bottom: 0; }
.plan-tabs {
  flex: none; align-self: center; display: flex; gap: 2px; margin: 10px 0;
  padding: 2px; border-radius: 9px; background: rgba(118,118,128,.24);
}
/* Saved tab without a route picked: full-screen list, no map */
#view-routes.list-only .map-wrap { display: none; }
#view-routes.list-only .plan-panel { flex: 1; max-height: none; }
.plan-tabs button { border: 0; background: none; color: var(--text); font-weight: 500; font-size: 0.8235rem; padding: 6px 16px; border-radius: 7px; }
.plan-tabs button.active { background: #636366; font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12); }
:root[data-theme="light"] .plan-tabs { background: rgba(118,118,128,.12); }
:root[data-theme="light"] .plan-tabs button.active { background: #fff; }
/* small phones: the tabs move left and tighten so they stay clear of the floating bell */
@media (max-width: 380px) {
  .plan-tabs { align-self: flex-start; margin-left: 12px; }
  .plan-tabs button { padding: 8px 11px; }
}
.plan-panel { flex: none; max-height: 48vh; overflow-y: auto; padding: 12px 12px 8px; }
.dist-picker { display: flex; align-items: center; gap: 10px; }
.dist-val { flex: 1; text-align: center; background: var(--card); border-radius: 12px; padding: 6px; }
.dist-val b { font-size: 1.824rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; margin: 5px 0; padding: 5px 0; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; border: 0; border-radius: 99px; padding: 7px 14px; background: var(--card2); font-weight: 600; font-size: 0.8824rem; }
.chip.active { background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; }
.plan-result { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: .5px solid var(--line); }
.plan-result b { font-size: 1.706rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn.del-route { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--danger); }
.btn.del-route svg { width: 21px; height: 21px; }
/* "Run this": mint with a glow, so it stands out as the next step after Generate */
.btn.run-this { font-weight: 700; padding: 11px 18px; font-size: 1rem;
   }
.credit { color: var(--muted); font-size: 0.6471rem; margin: 8px 0 0; text-align: center; }
.route-item { display: flex; align-items: center; gap: 12px; padding: 10px; margin-bottom: 10px; border-radius: 12px; background: var(--card); cursor: pointer; }
.route-item svg { width: 64px; height: 64px; flex: none; border-radius: 10px; background: var(--card2); }
.route-item b { font-size: 1.118rem; }
.route-item .km { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
#savedBack { margin-bottom: 4px; }
.route-item .del { border: 0; background: none; color: var(--muted); font-size: 1.176rem; padding: 8px; min-width: 44px; min-height: 44px; }
.wp {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg);
  background: #fff; color: #111; font: 700 12px/18px -apple-system, sans-serif; text-align: center;
}
.wp.first { background: var(--ok); }
.route-chip {
  position: absolute; top: 10px; right: 10px; z-index: 500; max-width: 62%;
  border: 0; border-radius: 99px; padding: 6px 10px; background: var(--overlay);
  font-size: 0.7647rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* route and ghost chips: only the name shrinks ("…"); distance and ✕ always stay visible */
.route-chip:has(.chip-name), .ghost-chip { display: flex; align-items: center; min-width: 0; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-meta { flex: none; margin-left: 5px; color: var(--muted); }
.route-chip .x, .ghost-chip .x { flex: none; color: var(--muted); margin-left: 8px; padding-left: 2px; }

/* ---------- pages ---------- */
.page-head { padding: 16px 16px 8px; }
.page-head.row { display: flex; align-items: center; gap: 10px; }
/* back buttons: a drawn chevron, exactly in the middle of the circle (a ‹ character never centres) */
.back { position: relative; border: 0; background: var(--card2); width: 40px; height: 40px; border-radius: 50%; flex: none; padding: 0;
  font-size: 0; color: var(--text); }
/* placed on its own (the button's hidden ‹ text would otherwise push it up) */
.back::before { content: ""; position: absolute; inset: 0; margin: auto; width: 10px; height: 10px;
  border-left: 2.6px solid currentColor; border-bottom: 2.6px solid currentColor; border-radius: 1px; transform: translateX(4px) rotate(45deg); }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin: 12px 16px 0; }
.hint { color: var(--muted); font-size: 0.8824rem; margin: 8px 0 12px; }
.c-slow { color: var(--slow); }
.c-fast { color: var(--fast); }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 0.7647rem; color: var(--muted); margin: 0 0 6px 4px; text-transform: uppercase; letter-spacing: .02em; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 0;
  background: var(--card2); color: var(--text); font-size: 1rem; outline: none;
}
.field input:focus, .field textarea:focus { box-shadow: 0 0 0 2px var(--accent); }
.sound-row .play { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--card2); font-size: 0.8824rem; }
.sound-row .play:active { background: var(--accent); color: var(--accent-ink); }
.page-head .btn.small { flex: none; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; font-size: 1rem; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }

/* ---------- activities ---------- */
.eyebrow { font-size: 0.7647rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
/* large title, like the iOS apps; room on the right for the floating bell */
.act-head { padding: 12px 70px 4px 16px; }
.act-head h1 { font-size: 2rem; font-weight: 700; letter-spacing: .01em; line-height: 1.2; }
.act-period { margin: 8px 16px 12px; }
/* the period summary */
.hero { margin: 0 16px; padding: 16px 16px 12px; border-radius: 16px; background: var(--card); }
.hero-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.delta { font-size: 0.8235rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--muted); }
.hero-num { font-size: 2.588rem; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -.02em; }
.hero-num small { font-size: 1.176rem; font-weight: 600; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.hero-sub { color: var(--muted); font-size: 0.8824rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
/* bars: 7 (week), up to 31 (month) or 12 (year); the gap narrows as there are more */
.week-chart, .wdays { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: clamp(2px, calc(56px / var(--n, 7)), 8px); }
.week-chart { align-items: end; height: 110px; margin-top: 16px; }
.wbar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; border: 0; background: none; padding: 0; }
.wbar i { display: block; width: 100%; max-width: 26px; border-radius: 4px 4px 1px 1px; background: var(--accent); min-height: 2px; transition: height .4s ease; }
.wbar.zero i { background: var(--line); }
.wbar.sel i { outline: 2px solid var(--text); outline-offset: 1px; }
.wdays { margin-top: 6px; text-align: center; font-size: 0.7059rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.wdays .today { color: var(--text); }
.week-tip { min-height: 18px; margin-top: 8px; font-size: 0.8235rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.week-tip b { color: var(--text); }

/* all time: km, runs, week streak */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 16px 0; }
.totals div { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.totals b { display: block; font-size: 1.294rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals small { color: var(--muted); font-size: 0.7647rem; }

/* your runs: an inset grouped list per month, like Settings and Fitness */
.act-list { margin-top: 6px; padding-bottom: 8px; }
.month { display: flex; justify-content: space-between; margin: 22px 20px 6px; font-size: 0.7647rem; text-transform: uppercase;
  letter-spacing: .02em; color: var(--muted); font-variant-numeric: tabular-nums; }
.act-group { margin: 0 16px; border-radius: 12px; background: var(--card); overflow: hidden; }
.act-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px 10px 10px;
  border: 0; background: none; color: var(--text); text-align: left; }
.act-row + .act-row::before { content: ""; position: absolute; top: 0; left: 82px; right: 0; border-top: .5px solid var(--line); }
.act-row:active { background: var(--card2); }
.act-thumb { flex: none; width: 60px; height: 60px; border-radius: 10px; overflow: hidden; background: var(--card2); }
.act-thumb svg, .act-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.act-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.act-title { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8824rem; }
.act-title b { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-title span { flex: none; color: var(--muted); }
.act-km { font-size: 1.529rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.act-km small { margin-left: 3px; font-size: 0.8235rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.act-sub { font-size: 0.8235rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pace-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; vertical-align: 1px; background: var(--muted); }
.pace-dot.good { background: var(--ok); }
.pace-dot.mid { background: var(--slow); }
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty-card { margin: 16px 12px; padding: 32px 20px; border-radius: 16px; background: var(--card); text-align: center; color: var(--muted); }
.empty-card svg { width: 48px; height: 48px; color: var(--accent-text); margin-bottom: 8px; }
.empty-card .btn { margin-top: 14px; flex: none; }

/* ---------- week strip on the record screen ---------- */
.week-strip {
  display: flex; align-items: center; gap: 12px; margin: 10px 12px 0; padding: 10px 14px;
  border: 0; border-radius: 12px; background: var(--card); text-align: left; flex: none;
}
.week-strip .grow b { display: block; font-size: 1.059rem; font-variant-numeric: tabular-nums; }
.week-strip .spark { display: grid; grid-template-columns: repeat(7, 7px); gap: 4px; align-items: end; height: 30px; }
.week-strip .spark i { display: block; border-radius: 2px 2px 0 0; background: var(--route-stroke); min-height: 2px; }
.week-strip .spark i.zero { background: var(--line); }
#view-record:not(.is-idle) .week-strip { display: none; }

/* during a run: a slightly bigger picture dot so it stands out on the tilted map */
.me.nav .me-dot { width: 36px; height: 36px; }
.me.nav .me-dot .avatar { font-size: 13px; }

/* avatars */
.avatar {
  display: inline-grid; place-items: center; overflow: hidden; border-radius: 50%; flex: none;
  background: var(--card2); color: #fff; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar b { font-weight: 700; }
.avatar.no-pic:not(.me-dot .avatar) {
  background: var(--card2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238b93a3'%3E%3Ccircle cx='12' cy='9' r='4'/%3E%3Cpath d='M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7z'/%3E%3C/svg%3E") center 70% / 70% no-repeat;
}
.nav-avatar { width: 26px; height: 26px; font-size: 11px; border: 2px solid transparent; }
nav button.active .nav-avatar { border-color: currentColor; }

/* account page */
.profile-card { margin: 4px 12px 0; padding: 28px 16px 16px; border-radius: 16px; text-align: center;
  background: var(--card); border: 1px solid var(--hero-border); }
.avatar-btn { position: relative; border: 0; background: none; padding: 0; }
.avatar-xl { width: 104px; height: 104px; font-size: 36px; border: 3px solid var(--accent); }
.avatar-edit {
  position: absolute; right: 0; bottom: 2px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); font-size: 18px; border: 3px solid var(--card);
}
.pc-name { font-size: 1.529rem; font-weight: 700; margin-top: 10px; }
.pc-meta { color: var(--muted); font-size: 0.8824rem; margin-top: 4px; min-height: 4px; }
/* stats under a profile: equal columns (3 on yours, 4 on a friend's), each number centred above its label */
.pc-stats { display: flex; margin-top: 16px; }
.pc-stats > * { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.pc-stats b { display: block; font-size: 1.118rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.pc-stats small { display: block; color: var(--muted); font-size: 0.7059rem; line-height: 1.3; }
/* "friends" in your profile stats opens your friends list */
.pc-stat-link { position: relative; border: 0; background: none; padding: 0; margin: 0; color: inherit; font: inherit; line-height: inherit; }
.pc-stat-link small { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.pc-stat-link.has-requests::after {
  content: ""; position: absolute; top: 0; left: calc(50% + 14px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}
.link-card {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 24px); margin: 10px 12px 0; padding: 14px 16px;
  border: 0; border-radius: 12px; background: var(--card); text-align: left;
}
.link-card .chev { font-size: 1.706rem; color: var(--muted); }
.avatar-stack { display: flex; min-width: 36px; }
.avatar-stack .avatar { width: 34px; height: 34px; font-size: 13px; border: 2px solid var(--card); }
.avatar-stack .avatar + .avatar { margin-left: -10px; }
.avatar-stack:empty::before { content: "👥"; font-size: 26px; }
.field textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 0;
  background: var(--card2); color: var(--text); font: inherit; font-size: 1rem; resize: none; outline: none;
}

/* friends */
.friend-list { margin-top: 6px; }
.friend { display: flex; align-items: center; gap: 12px; margin: 8px 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); }
.friend .f-avatar { width: 44px; height: 44px; font-size: 18px; }
.friend .del { border: 0; background: none; color: var(--muted); font-size: 1.176rem; padding: 8px; min-width: 44px; min-height: 44px; }

/* coloured screen edge when off pace */
#view-record::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 900;
  box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .4s;
}
#view-record.edge-slow::after { box-shadow: inset 0 0 0 6px var(--slow), inset 0 0 48px rgba(255,69,58,.35); }
#view-record.edge-fast::after { box-shadow: inset 0 0 0 6px var(--fast), inset 0 0 48px rgba(74,168,255,.35); }

/* km split card: slides down from the top for a few seconds */
.split-card {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 950;
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  border-radius: 12px; background: var(--card); border-left: 6px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  transform: translateY(-160%); transition: transform .4s cubic-bezier(.2,.9,.3,1.2); pointer-events: none;
}
.split-card.show { transform: translateY(0); }
.split-card.ok { border-left-color: var(--ok); }
.split-card.slow { border-left-color: var(--slow); }
.split-card.fast { border-left-color: var(--fast); }
.sc-km { font-size: 0.8235rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sc-time b { font-size: 1.882rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-time small { color: var(--muted); margin-left: 2px; }
.sc-delta { margin-left: auto; text-align: right; font-size: 0.8824rem; font-weight: 700; }
.split-card.ok .sc-delta { color: var(--ok); }
.split-card.slow .sc-delta { color: var(--slow); }
.split-card.fast .sc-delta { color: var(--fast); }

/* countdown before a run */
.countdown {
  position: fixed; inset: 0; z-index: 2500; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 24px; background: var(--scrim);
}
.countdown.hidden { display: none; }
.cd-ring { position: relative; width: min(64vw, 260px); aspect-ratio: 1; }
.cd-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.cd-track { fill: none; stroke: var(--card2); stroke-width: 8; }
.cd-prog {
  fill: none; stroke: var(--slow); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .4s ease, stroke .4s;
}
.cd-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cd-center b { font-size: clamp(56px, 20vw, 96px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cd-center b.pop { animation: cd-pop .5s ease-out; }
.cd-center small { color: var(--muted); font-size: 1rem; margin-top: 6px; font-weight: 600; }
@keyframes cd-pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cd-msg { color: var(--muted); text-align: center; max-width: 300px; margin: 0; min-height: 40px; }
.cd-actions { display: flex; gap: 10px; width: 100%; max-width: 360px; }

/* colour key under a run's map */
.zone-legend { display: flex; justify-content: center; gap: 16px; margin: 8px 12px 0; font-size: 0.8235rem; color: var(--muted); }
.zone-legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* hold-to-confirm buttons: fill from left while held */
.btn.hold {
  background-image: linear-gradient(var(--press), var(--press));
  background-repeat: no-repeat; background-size: 0% 100%;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.btn.hold.holding { background-size: 100% 100%; transition: background-size .9s linear; }

.lock-overlay {
  position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.25);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 24px calc(28px + env(safe-area-inset-bottom));
}
.lock-overlay.hidden { display: none; }
.lock-overlay .btn { flex: none; width: 100%; max-width: 360px; padding: 18px; font-size: 1.176rem; background-color: #fff; color: #111; }

/* target dialog */
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(118,118,128,.24); margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--text); font-weight: 500; font-size: 0.8235rem; padding: 7px; border-radius: 7px; }
.seg button.active { background: #636366; color: var(--text); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
:root[data-theme="light"] .seg button.active { background: #fff; }
:root[data-theme="light"] .seg { background: rgba(118,118,128,.12); }
.goal-result { text-align: center; margin: 4px 0 14px; font-size: 1rem; }
.goal-result b { font-size: 1.706rem; font-variant-numeric: tabular-nums; margin: 0 4px; }

/* ---------- detail ---------- */
.detail-map { position: relative; height: 38vh; min-height: 220px; flex: none; margin: 0 12px; border-radius: 12px; overflow: hidden; }
.detail-stats .stat b { font-size: 1.529rem; }
.detail-stats { grid-template-columns: repeat(3, 1fr); }
.splits { display: grid; gap: 6px; }
.split { display: grid; grid-template-columns: 44px 52px 1fr; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-size: 1rem; }
.split .bar { height: 14px; border-radius: 4px; background: var(--ok); }
.split .bar.slow { background: var(--slow); }
.split .bar.fast { background: var(--fast); }
.discipline { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 8px 0 6px; background: var(--card2); }
.discipline span { display: block; }
.legend { display: flex; gap: 14px; font-size: 0.8235rem; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.detail-actions { display: flex; gap: 10px; margin: 12px; }
.d-again { display: block; width: calc(100% - 24px); margin: 12px 12px 0; }

/* ---------- nav / dialog / toast ---------- */
nav {
  position: relative; z-index: 10;
  display: flex; flex: none; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--nav-bg); border-top: .5px solid var(--line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
nav button {
  flex: 1; border: 0; background: none; color: #8e8e93; font-size: 0.6471rem; font-weight: 500; letter-spacing: .01em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 0 0 2px;
}
nav button.active { color: var(--accent); }
/* slightly bolder line icons, closer in weight to the Record runner */
nav button:not(.nav-record) svg [stroke-width] { stroke-width: 2; }
nav svg { width: 24px; height: 24px; }
/* Record stands out: ~15% bigger than the other tabs */
nav button.nav-record { font-size: 0.6471rem; }
nav button.nav-record svg { width: 28px; height: 28px; }
/* the runner from the app icon: chrome mint on the dark bar, deep petrol and mint on the light bar;
   a little dimmed until Record is the open tab */
nav button.nav-record svg.rec-runner { width: 46px; height: 46px; overflow: visible; opacity: .72; transition: opacity .2s; }   /* icon only, no label */
nav button.nav-record.active svg.rec-runner { opacity: 1; }
.rec-runner .rc1 { stop-color: #ffffff; }
.rec-runner .rc2 { stop-color: #a9e3cf; }
.rec-runner .rc3 { stop-color: #244c65; }
.rec-runner .rc4 { stop-color: var(--accent); }
.rec-runner .rc5 { stop-color: #eaf7f2; }
.rec-runner .rc-bar { fill: #b6f22e; }
:root[data-theme="light"] .rec-runner .rc1 { stop-color: #244c65; }
:root[data-theme="light"] .rec-runner .rc2 { stop-color: #1c7a5e; }
:root[data-theme="light"] .rec-runner .rc3 { stop-color: var(--accent-ink); }
:root[data-theme="light"] .rec-runner .rc4 { stop-color: #1c7a5e; }
:root[data-theme="light"] .rec-runner .rc5 { stop-color: #244c65; }
:root[data-theme="light"] .rec-runner .rc-bar { fill: #8cc21a; }

dialog {
  border: 0; border-radius: 12px; padding: 20px; width: min(92vw, 420px);
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; text-align: center; }
.dlg-sum b { display: block; font-size: 1.294rem; font-variant-numeric: tabular-nums; }
.dlg-sum small { color: var(--muted); font-size: 0.7647rem; }
.dlg-actions { display: flex; gap: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 4500;
  background: var(--toast-bg); color: var(--toast-text); padding: 11px 18px; border-radius: 99px; font-weight: 600; font-size: 0.8824rem;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: 0 8px 30px rgba(0,0,0,.18);
  max-width: calc(100vw - 32px); text-align: center; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* small phones: tighten the record screen */
@media (max-height: 700px) {
  .rs-pace b { font-size: 2.235rem; }
  .rs-grid b { font-size: 1.235rem; }
  .btn.big { padding: 14px; }
}

/* planner: shape + heading pickers, route preview */
.shape-seg { margin-bottom: 10px; }
.shape-seg button { padding: 8px 4px; font-size: 0.8824rem; }
.plan-info { margin-top: 10px; }
.pi-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pi-stats div { background: var(--card); border-radius: 12px; padding: 8px 10px; }
.pi-stats b { display: block; font-size: 1.176rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pi-stats small { color: var(--muted); font-size: 0.7647rem; }

/* personal records */
.pr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pr { border: 0; text-align: left; background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.pr small { display: block; font-size: 0.7647rem; font-weight: 700; color: var(--accent-text); letter-spacing: .04em; }
.pr b { display: block; font-size: 1.412rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pr span { font-size: 0.7647rem; color: var(--muted); }
.pr.none b, .pr.none small { color: var(--muted); }

/* monthly calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; text-align: center; }
.cal-head b { font-size: 1.059rem; }
.cal-nav { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--card2); font-size: 1.294rem; line-height: 1; }
.cal-nav:disabled { opacity: .3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 0.7059rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.cal-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; border: 0; padding: 0; background: none;
  font-size: 0.8235rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-day > span { position: relative; }
.cal-day i { position: absolute; inset: 0; margin: auto; width: calc(var(--s) * 100%); height: calc(var(--s) * 100%);
  max-width: 40px; max-height: 40px; border-radius: 50%; background: var(--accent); }
.cal-day.run { color: var(--accent-ink); font-weight: 700; }
.cal-day.today:not(.run) > span { color: var(--text); font-weight: 700; border-bottom: 2px solid var(--accent-text); }
.cal-day.today.run i { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }

/* pace chart */
.pace-chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.pace-chart text { fill: var(--muted); font-size: 0.6471rem; font-variant-numeric: tabular-nums; }
.chart-tip { font-size: 0.8235rem; color: var(--muted); min-height: 20px; margin-bottom: 4px; }
.chart-tip b { color: var(--text); }
.pc-grid { stroke: var(--line); stroke-width: 1; }
.pc-band { fill: var(--ok); opacity: .08; }
.pc-target { stroke: var(--ok); stroke-width: 1; stroke-dasharray: 4 3; opacity: .45; }
/* the pace line in zone colours (too slow / on pace / too fast), with a soft glow underneath */
.pc-line { fill: none; stroke: url(#pcZones); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.pc-glow { display: none; }
:root[data-theme="light"] .pc-glow { opacity: .25; }
.pc-legend { margin-top: 6px; }
.pc-cross { stroke: var(--muted); stroke-width: 1; }
.pc-dot { fill: var(--route-stroke); stroke: var(--card); stroke-width: 2; }

/* summary after a run */
.summary { position: fixed; inset: 0; z-index: 2400; background: var(--scrim); overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.sum-inner { max-width: 420px; margin: 0 auto; text-align: center; animation: sum-in .4s ease-out; }
.sum-inner h1 { margin-top: 4px; }
.sum-route { margin: 14px 0; background: var(--card); border-radius: 16px; }
.sum-route svg { display: block; width: 100%; height: auto; }
.draw polyline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw-line 1.4s .2s ease-in-out forwards; }
.end-pop { opacity: 0; animation: fade-in .3s 1.5s forwards; }
.sum-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum-stats div { background: var(--card); border-radius: 12px; padding: 10px 6px; }
.sum-stats b { display: block; font-size: 1.529rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-stats small { color: var(--muted); font-size: 0.7647rem; }
.sum-badges { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.sum-badge { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--card); border-radius: 12px;
  padding: 10px 14px; font-weight: 700; opacity: 0; animation: badge-pop .45s ease-out forwards; }
.sum-badge span { font-size: 24px; }
.sum-badge.gold { background: var(--card); border: 1px solid var(--hero-border); }
.sum-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.sum-actions > .btn { width: 100%; }
.sum-sub { display: flex; justify-content: center; gap: 8px; }
.sum-sub .btn { color: var(--muted); }
@keyframes draw-line { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes sum-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes badge-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .draw polyline, .end-pop, .sum-badge, .sum-inner { animation: none; stroke-dashoffset: 0; opacity: 1; }
}

/* the ACE logo (shapes in index.html): light letters with a mint glow; navy letters in light mode */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ace-ink { fill: var(--logo-ink); }
.ace-glow { flood-color: var(--logo-glow); }

/* opening animation (2 s): A-C-E rise in, the bar fills left to right with the lime dot at its tip,
   then it all fades away and the app opens */
.splash { position: fixed; inset: 0; z-index: 5000; background: var(--bg-art); display: flex;
  align-items: center; justify-content: center; }
.splash.out { animation: sp-out .38s ease-in forwards; }
.splash.quiet { visibility: hidden; }
.sp-mark { display: block; width: min(64vw, 336px); height: auto; overflow: visible; }
.sp-l { opacity: 0; transform: translateY(40px); animation: sp-rise .45s cubic-bezier(.2,.8,.2,1) forwards; }
.sp-l:nth-child(2) { animation-delay: .08s; }
.sp-l:nth-child(3) { animation-delay: .16s; }
.sp-track { fill: var(--logo-track); opacity: 0; animation: sp-fade .3s .3s forwards; }
/* the bar follows the loading (the script in index.html sets both transforms) */
.sp-fill { fill: var(--logo-fill); transform-box: fill-box; transform-origin: 0 50%; transform: scaleX(0); }
.sp-dot { fill: var(--accent); opacity: 0; animation: sp-fade .2s .3s forwards; }
@keyframes sp-rise { to { opacity: 1; transform: none; } }
@keyframes sp-fade { to { opacity: 1; } }
@keyframes sp-out { to { opacity: 0; transform: scale(1.04); visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .sp-l, .sp-track, .sp-dot { animation: none; opacity: 1; }
  .sp-l { transform: none; }
}

/* compass on the map: appears once you turn or tilt it */
.compass { position: absolute; right: 10px; top: 52px; z-index: 5; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--overlay); color: var(--text); display: grid; place-items: center; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.compass svg { width: 22px; height: 22px; transition: transform .1s linear; }

/* polish: page transitions, tab pop, bars that grow, cards that slide in */
.view.enter { animation: view-in .24s ease-out; }
.view.enter-push { animation: view-push .28s cubic-bezier(.2,.8,.2,1); }
.view.enter-back { animation: view-back .28s cubic-bezier(.2,.8,.2,1); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes view-push { from { opacity: .3; transform: translateX(48px); } }
@keyframes view-back { from { opacity: .3; transform: translateX(-48px); } }
#nav button.active svg, #nav button.active .nav-avatar { animation: nav-pop .32s cubic-bezier(.3,1.6,.5,1); }
@keyframes nav-pop { 40% { transform: scale(1.08); } }
.view.active .wbar i, .view.active .spark i { transform-origin: bottom; animation: bar-grow .55s cubic-bezier(.2,.8,.2,1) both; }
.wbar:nth-child(2) i, .spark i:nth-child(2) { animation-delay: .04s; }
.wbar:nth-child(3) i, .spark i:nth-child(3) { animation-delay: .08s; }
.wbar:nth-child(4) i, .spark i:nth-child(4) { animation-delay: .12s; }
.wbar:nth-child(5) i, .spark i:nth-child(5) { animation-delay: .16s; }
.wbar:nth-child(6) i, .spark i:nth-child(6) { animation-delay: .2s; }
.wbar:nth-child(7) i, .spark i:nth-child(7) { animation-delay: .24s; }
@keyframes bar-grow { from { transform: scaleY(0); } }
.act-group, .pr-card, .cal { animation: card-in .4s cubic-bezier(.2,.8,.2,1) both; }
.pr-card { animation-delay: .06s; }
.cal { animation-delay: .1s; }
.act-group { animation-delay: .14s; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px); } }
.btn, .chip, .round, .map-btn, .cal-nav, .pr { transition: transform .12s ease, background-color .2s, color .2s; }
.chip:active, .map-btn:active, .cal-nav:active, .pr:active { transform: scale(.96); }
@media (prefers-reduced-motion: reduce) {
  .view.enter, .view.enter-push, .view.enter-back, #nav button.active svg, #nav button.active .nav-avatar,
  .view.active .wbar i, .view.active .spark i, .act-group, .pr-card, .cal { animation: none; }
}

/* account & sync card */

/* ---------- ghost runner ---------- */
.ghost-chip {
  position: absolute; top: 46px; right: 10px; z-index: 500; max-width: 62%;
  border: 0; border-radius: 99px; padding: 6px 10px; background: var(--overlay);
  font-size: 0.7647rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.ghost-chip.ahead { color: var(--ok); }
.ghost-chip.behind { color: var(--slow); }
.ghost-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.55); border: 2px dashed #fff; font-size: 15px; line-height: 1;
  box-shadow: 0 1px 6px rgba(0,0,0,.35);
}
.fs-ghost.ahead b { color: var(--ok); }
.fs-ghost.behind b { color: var(--slow); }

/* stats page in dark mode: true black, so it's easy to read at a glance and light on OLED batteries */
:root:not([data-theme="light"]) #view-record.stats-full:not(.is-idle) { background: var(--bg); }
:root:not([data-theme="light"]) #view-record.stats-full:not(.is-idle) .fs-row { border-color: #1c1f26; }

/* ---------- sign-up / log-in gate (covers the app until you have an account) ---------- */
.gate {
  position: fixed; inset: 0; z-index: 4000; background: var(--bg-art); overflow-y: auto;
  display: flex; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.gate-box { width: 100%; max-width: 400px; margin: auto; }
.gate-logo { display: block; width: 168px; height: auto; margin: 0 auto 22px; overflow: visible; }
.gate h2 { font-size: 1.412rem; margin: 0 0 12px; }
.gate h2:empty { display: none; }
.gate-form { display: grid; gap: 4px; }
.gate-form .btn { width: 100%; margin-top: 8px; }
.gate-note { color: var(--muted); font-size: 0.8824rem; margin: 0 0 8px; }
.gate-legal { order: 3; text-align: center; margin: 14px 0 0; }
.gate-legal a { color: var(--accent-text); text-decoration: none; }
a.set-row { color: inherit; text-decoration: none; }
.native-app .web-only { display: none; }   /* website-only tips, e.g. "Add to Home Screen" */
.gate-link { order: 2; border: 0; background: none; color: var(--muted); font-size: 0.8824rem; padding: 10px 0 0; }
.gate-link b { color: var(--accent-text); }
.gate-msg { order: 1; margin: 8px 0 0; font-size: 0.8824rem; font-weight: 600; color: var(--danger); min-height: 1em; }
.gate-msg.ok { color: var(--ok); }
.gate-msg:empty { display: none; }
.gate-spin { display: block; margin: 20px auto; width: 28px; height: 28px; }

/* ---------- maps blend into the page: soft fade at the top and bottom ---------- */
/* the map itself fades to transparent, so the page background shows through without a seam */
.map-wrap > .map {
  -webkit-mask-image: none; mask-image: none;
}

/* ---------- account page without boxes: content straight on the background ---------- */
#view-account .profile-card,
#view-friend .profile-card,
#view-group .profile-card,
#view-account .link-card,
#view-account .card { background: none; border: 0; border-radius: 0; box-shadow: none; }
#view-account .link-card,
#view-account .card { width: auto; margin: 0 16px; padding: 16px 0; border-top: .5px solid var(--line); }
#view-account .avatar-stack .avatar { border-color: var(--bg); }

/* profile header: bio under the name, Edit profile button, runs grid */
.pc-bio { margin: 8px auto 0; max-width: 320px; font-size: 1rem; line-height: 1.4; white-space: pre-line; }
.pc-bio:empty { display: none; }
.pc-edit { width: 100%; margin-top: 16px; }
#view-account .pc-meta { margin-top: 6px; }
.run-grid-head { display: flex; align-items: baseline; gap: 8px; margin: 0 16px; padding: 16px 0 10px; border-top: .5px solid var(--line); }
.run-grid-head b { font-size: 1.118rem; }
/* posters never touch: a gap between tiles and the page's side margin */
.run-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 16px; }
.run-tile {
  position: relative; aspect-ratio: 4 / 5; padding: 0; border: 0; overflow: hidden; border-radius: 10px;
  background: var(--card2);
}
.run-tile svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.run-tile svg g { stroke: var(--accent) !important;  }
.run-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.run-tile:active { opacity: .8; }
.run-grid-empty { grid-column: 1 / -1; padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.8824rem; }
:root[data-theme="light"] .run-tile { background: var(--card2); }
:root[data-theme="light"] .run-tile svg g { stroke: #244c65 !important; filter: none; }

/* ---------- post-run poster ----------
   A sheet rising from the bottom (at most about 90% of the screen, only as tall as it needs), with
   the app blurred behind it. The whole poster fits in its first view with the buttons under it;
   comments scroll inside, under a top bar that stays put (swipe it down to close at any point) and
   above a comment box that stays at the bottom. Swipe down, tap outside it or tap ✕ to close. */
.poster-sheet {
  --ps-h: min(90dvh, calc(100dvh - env(safe-area-inset-top) - 16px));
  --ps-room: calc(150px + env(safe-area-inset-bottom));   /* top bar, buttons and padding */
  position: fixed; inset: 0; z-index: 2450; display: flex; align-items: flex-end; justify-content: center;
  padding-top: env(safe-area-inset-top);
  background: rgba(0,0,0,.35); -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
  animation: ps-fade .2s ease-out;
}
:root[data-theme="light"] .poster-sheet { background: rgba(0,0,0,.2); }
.ps-inner {
  width: min(100vw, 520px); max-height: var(--ps-h); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px; padding: 0 16px;
  border-radius: 22px 22px 0 0; background: var(--card); box-shadow: 0 -10px 50px rgba(0,0,0,.3);
  animation: ps-in .32s cubic-bezier(.2,.8,.2,1);
}
/* room under the last item (when there's no comment box at the bottom) */
.ps-inner::after { content: ""; order: 20; flex: none; height: calc(4px + env(safe-area-inset-bottom)); margin-top: -14px; }
.poster-sheet:has(#psComments:not(.hidden)):not(.editing) .ps-inner::after { display: none; }
.ps-inner.dragging { transition: none; }
.ps-inner.settle { transition: transform .25s cubic-bezier(.2,.8,.2,1); }
/* top bar: the grabber, Edit and ✕; it stays at the top while the sheet scrolls */
.ps-top { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 12px; min-height: 52px;
  margin: 0 -16px; padding: 14px 16px 4px; background: var(--card); }
.ps-top::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px;
  border-radius: 3px; background: var(--line); }   /* grabber: swipe down to close */
.ps-top .ps-close { margin-left: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ps-edit { flex: none; position: relative; border: 0; background: none; padding: 4px 6px; color: var(--accent-text); font-size: 1rem; font-weight: 600; }
.ps-edit::before { content: ""; position: absolute; inset: -8px -4px; }   /* 44 px tap area */
.ps-close { flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--card2); color: var(--muted); position: relative; }
.ps-close::before { content: ""; position: absolute; inset: -7px; }   /* 44 px tap area */
.ps-close svg { width: 14px; height: 14px; }
/* the whole poster, as big as fits: its own shape, never cropped */
.ps-img { display: block; flex: none; align-self: center; width: auto; height: auto; max-width: 100%;
  max-height: calc(var(--ps-h) - var(--ps-room)); border-radius: 12px; background: var(--card2); }
.ps-img:not([src]) { width: 100%; aspect-ratio: 4 / 5; }
/* swiping between a grid's posters: the poster follows the finger, then slides */
.ps-img { transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s; touch-action: pan-y; }
.ps-img.dragging { transition: none; }
@media (prefers-reduced-motion: reduce) { .ps-img { transition: none; } }
/* first view: poster, then its buttons; likes, "shared to" and comments below them */
.ps-actions, .ps-friend, #psDone { order: 2; }
.ps-likes, .ps-shared, #psRemove { order: 3; }
/* leave room when the card shows more above the fold (after-run hint, a friend's likes + race) */
.poster-sheet:has(#psHint:not(.hidden)) .ps-img { max-height: calc(var(--ps-h) - var(--ps-room) - 50px); }
.poster-sheet:has(#psFriend:not(.hidden)) .ps-img { max-height: calc(var(--ps-h) - var(--ps-room) - 64px); }
@keyframes ps-fade { from { opacity: 0; } }
@keyframes ps-in { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .poster-sheet, .ps-inner { animation: none; } }
.ps-hint { margin: -4px 0 0; color: var(--muted); font-size: 0.8824rem; line-height: 1.45; }
.ps-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
#psRemove { align-self: center; }


/* ---------- friends page: search + list, no boxes ---------- */
.friend-search { margin: 4px 16px 6px; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); }
.search-field svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); padding: 12px 0; font-size: 1.059rem; outline: none; }
.search-field:focus-within { border-color: var(--accent-text); }
#view-people .friend { margin: 0 16px; padding: 12px 0; border-radius: 0; background: none; border-top: .5px solid var(--line); }
.friend-results .friend:first-child { border-top: 0; }
.fr-added { font-size: 0.8235rem; font-weight: 700; color: var(--ok); }
.friends-head { display: flex; align-items: baseline; gap: 8px; margin: 18px 16px 0; padding-bottom: 8px; }
.friends-head b { font-size: 1.118rem; }
.friends-empty { margin: 8px 16px; }
.invite-btn { margin: 16px; align-self: flex-start; }

/* ---------- friends: tabs, feed, likes, leaderboard, friend page, QR ---------- */
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card2); color: var(--text); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.friends-tabs { margin: 4px 16px 10px; }
.friends-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px; }

/* a friend's post: about 90% of the screen wide, centred, the poster with rounded corners */
.feed-item { width: 90%; max-width: 480px; margin: 0 auto 30px; }
.fi-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 0; border: 0; background: none; text-align: left; }
.fi-head b { display: block; font-size: 1rem; }
.fi-head .muted { display: block; font-size: 0.8235rem; }
.fi-poster {
  display: block; position: relative; width: 100%; aspect-ratio: 4 / 5; padding: 0; border: 0; overflow: hidden;
  border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.28);
  background: var(--card2);
}
.fi-poster img, .fi-poster svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* once drawn, a feed poster shows whole, at its real size */
.fi-poster:has(img) { aspect-ratio: auto; }
.fi-poster img { position: static; display: block; height: auto; }
.fi-poster svg g { stroke: var(--accent) !important; }
.fi-actions { display: flex; align-items: center; gap: 8px; padding: 10px 0 0; }
.fi-actions .muted { font-size: 0.8235rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-cms { display: flex; flex-direction: column; align-items: stretch; padding: 4px 0 0; }
.fi-cms:empty { display: none; }
.fi-all, .fi-cm { display: block; border: 0; background: none; padding: 3px 0; text-align: left; color: var(--text);
  font-size: 0.8824rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-all { color: var(--muted); }

.react-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 44px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 1.176rem; font-weight: 700;
}
.react-btn span { font-size: 0.8824rem; font-variant-numeric: tabular-nums; }
.react-btn span:empty { display: none; }
.react-btn .heart { width: 21px; height: 21px; }
.react-btn.on { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }   /* liked: the red heart */
.run-tile[data-kc]::after {
  content: "❤️ " attr(data-kc); position: absolute; right: 6px; top: 6px; padding: 3px 7px; border-radius: 99px;
  background: rgba(16,27,45,.82); color: #fff; font-size: 12px; font-weight: 700;
}

.lb-row {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 0 16px; padding: 12px 0;
  border: 0; border-top: .5px solid var(--line); background: none; text-align: left;
}
.lb-row:first-child { border-top: 0; }
.lb-row .f-avatar { width: 36px; height: 36px; font-size: 14px; flex: none; }
.lb-rank { flex: none; width: 22px; text-align: center; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row .grow { min-width: 0; }
.lb-row .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.me .lb-rank, .lb-row.me .grow b { color: var(--accent-text); }
.lb-bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--card2); }
.lb-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.lb-km { flex: none; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.8235rem; }
.lb-km b { font-size: 1.176rem; color: var(--text); }
.lb-km small { display: block; font-size: 0.7647rem; }

#view-friend .profile-card .avatar-xl, #view-group .profile-card .avatar-xl { margin: 0 auto; }
#fpAvatar { display: inline-block; }

.ps-likes { margin: 0; text-align: center; color: var(--muted); font-size: 0.8824rem; }
.ps-likes:empty { display: none; }
.ps-friend { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.ps-friend .react-btn { height: 48px; }

/* comments under a poster: any text or emoji, with a row of the most used emoji */
.ps-comments { order: 10; display: flex; flex-direction: column; gap: 10px; padding-top: 6px; scroll-margin-top: 60px; }   /* clear of the top bar */
.ps-comments.hidden { display: none; }
.ps-comments h3 { margin: 0; font-size: 1.059rem; }
.cm-list { display: flex; flex-direction: column; gap: 12px; }
.cm { display: flex; align-items: flex-start; gap: 10px; }
.cm.pending { opacity: .6; }
.cm-who { padding: 0; border: 0; background: none; flex: none; }
.cm .f-avatar { width: 32px; height: 32px; font-size: 13px; }
.cm .grow { min-width: 0; font-size: 1rem; line-height: 1.35; }
.cm-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.cm .muted { font-size: 0.7647rem; margin-top: 2px; }
.cm-del { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 0.8824rem; }
.cm-empty { margin: 0; font-size: 0.8824rem; }
.cm-quick { display: flex; justify-content: space-between; gap: 4px; }
.cm-quick button { flex: 1; height: 44px; border: 0; border-radius: 12px; background: var(--card); font-size: 26px; line-height: 1; }
.cm-quick button:active { background: var(--card2); transform: scale(.92); }
/* the comment box: pinned to the bottom of the sheet, full width, above the home bar */
.cm-form { order: 11; position: sticky; bottom: 0; z-index: 3; display: flex; gap: 8px;
  margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: .5px solid var(--line); }
.poster-sheet:has(#psComments.hidden) .cm-form, .poster-sheet.editing .cm-form { display: none; }
/* the first view keeps the whole poster above the comment box */
.poster-sheet:has(#psComments:not(.hidden)):not(.editing) { --ps-room: calc(206px + env(safe-area-inset-bottom)); }
.cm-form input {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 1.059rem;
}
.cm-send { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 1.294rem; font-weight: 700; }
:root[data-theme="light"] .cm-send { background: #1c7a5e; color: #fff; }
.n-quote { color: var(--muted); }

.qr-box { width: min(70vw, 280px); aspect-ratio: 1; margin: 0 auto; padding: 14px; border-radius: 12px; background: #fff; color: #111; display: grid; place-items: center; text-align: center; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-who { text-align: center; margin-top: 12px; }
.qr-actions .btn { flex: 1; }
.run-grid .friends-empty { grid-column: 1 / -1; }
.fi-head .f-avatar { width: 36px; height: 36px; font-size: 14px; flex: none; }

/* settings: a cog at the top right of your profile (scrolls along with the page) */
.icon-btn.settings-btn { position: absolute; top: 12px; right: 12px; z-index: 1; }   /* beats .icon-btn's position */

/* ---------- notifications ---------- */
.icon-btn { position: relative; }
.page-head.row .icon-btn + .icon-btn { margin-left: 2px; }
/* the bell's counter */
#bellBadge {
  position: absolute; top: -6px; right: -8px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  border: 2px solid var(--bg); background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; line-height: 15px; text-align: center;
}
nav button { position: relative; }
nav button[data-count]::after {
  content: attr(data-count); position: absolute; top: 5px; left: calc(50% + 5px); min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; border: 2px solid var(--nav-bg); background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 13px; text-align: center;
}
.notif { display: flex; align-items: center; gap: 12px; margin: 0 16px; padding: 12px 0; border-top: .5px solid var(--line); cursor: pointer; }
.notif .f-avatar { width: 44px; height: 44px; font-size: 18px; flex: none; }
.notif .grow { min-width: 0; }
.n-text { font-size: 0.8824rem; line-height: 1.35; }
.notif .muted { font-size: 0.7647rem; margin-top: 2px; }
.n-dot { flex: none; width: 8px; height: 8px; margin-right: -4px; border-radius: 50%; background: transparent; }
.notif.new .n-dot { background: var(--accent); }
.n-run { flex: none; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--card2); }
.n-run svg { display: block; width: 100%; height: 100%; }
.n-run svg g { stroke: var(--accent) !important; }

/* light mode: mint on white is too faint for text and lines, so use the deep mint */
:root[data-theme="light"] .lb-bar i,
:root[data-theme="light"] .notif.new .n-dot { background: #1c7a5e; }
/* light mode: your initials in white on petrol (on the light grey they were hard to read) */
:root[data-theme="light"] .avatar:not(.no-pic):not([style*="background"]) { background: #244c65; }

/* ---------- loading placeholders (grey shapes with a soft shimmer) ---------- */
.sk-line, .sk-circle, .sk-poster, .sk-tile {
  display: block; border-radius: 6px; background: var(--card2);
  background-image: linear-gradient(90deg, transparent 0, rgba(255,255,255,.06) 50%, transparent 100%);
  background-size: 200% 100%; background-repeat: no-repeat; animation: sk-shine 1.3s linear infinite;
}
:root[data-theme="light"] :is(.sk-line, .sk-circle, .sk-poster, .sk-tile) {
  background-image: linear-gradient(90deg, transparent 0, rgba(255,255,255,.7) 50%, transparent 100%);
}
.sk-line { height: 12px; margin: 5px 0; }
.sk-circle { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.sk-post { width: 90%; max-width: 480px; margin: 0 auto 30px; }
.sk-post .sk-head { padding: 8px 0; }
.sk-head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.sk-head .sk-line { flex: none; }
.sk-poster { aspect-ratio: 1080 / 1350; border-radius: 12px; margin: 4px 0; }
.sk-row { display: flex; align-items: center; gap: 12px; margin: 0 16px; padding: 12px 0; }
.sk-tile { aspect-ratio: 4 / 5; border-radius: 10px; }
@keyframes sk-shine { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line, .sk-circle, .sk-poster, .sk-tile { animation: none; } }

/* ---------- pull to refresh ---------- */
.ptr {
  position: absolute; top: 0; left: 50%; z-index: 30; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,.3);
  transform: translate(-50%, -50px); opacity: 0; pointer-events: none;
}
.ptr.back { transition: transform .25s, opacity .25s; }
.ptr-arrow { font-size: 20px; font-weight: 700; color: var(--muted); transition: transform .2s; }
.ptr.ready .ptr-arrow { transform: rotate(180deg); color: var(--accent); }
.ptr .spinner { display: none; }
.ptr.busy .ptr-arrow { display: none; }
.ptr.busy .spinner { display: block; }

/* ---------- welcome screens ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 3500; background: var(--bg-art); display: flex; flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.welcome-skip { align-self: flex-end; border: 0; background: none; color: var(--muted); font-size: 1rem; font-weight: 600; padding: 8px 4px; }
.welcome-skip.hidden { display: block !important; visibility: hidden; }
.welcome-slide { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; max-width: 420px; margin: 0 auto; }
.welcome-slide.in { animation: w-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes w-in { from { opacity: 0; transform: translateX(28px); } }
.welcome-art { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 120px; align-items: center; margin-bottom: 26px; }
.w-pill { padding: 10px 16px; border-radius: 99px; font-weight: 700; font-size: 16px; color: var(--accent-ink); }
.w-pill.slow { background: var(--slow); }
.w-pill.ok { background: var(--ok); }
.w-pill.fast { background: var(--fast); }
:root[data-theme="light"] .w-pill { color: #fff; }
.welcome h2 { font-size: 1.706rem; margin: 0 0 12px; }
.welcome p { margin: 0; color: var(--muted); font-size: 1.059rem; line-height: 1.5; }
.welcome-dots { display: flex; justify-content: center; gap: 8px; margin: 18px 0 20px; }
.welcome-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: width .25s, background .25s; }
.welcome-dots i.on { width: 22px; background: var(--accent); }
.w-ic { display: grid; place-items: center; width: 104px; height: 104px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text);
}
.w-ic svg { width: 50px; height: 50px; }
#wNext { flex: none; width: 100%; max-width: 420px; margin: 0 auto; }
@media (prefers-reduced-motion: reduce) { .welcome-slide.in { animation: none; } }

/* ---------- settings: open rows like the profile and friends pages ---------- */
.set-group { margin: 6px 0 18px; }
.set-group > h3 { margin: 0 16px 4px; }
.set-row {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 0 16px; padding: 13px 0;
  border: 0; border-top: .5px solid var(--line); background: none; color: var(--text); text-align: left; font: inherit;
}
.set-group > h3 + .set-row, .set-group > h3 + #soundRows > .set-row:first-child { border-top: 0; }
.set-row .grow { min-width: 0; }
.set-row b { display: block; font-size: 1rem; font-weight: 600; }
.set-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8235rem; line-height: 1.35; }
label.set-row { cursor: pointer; }
.set-danger b { color: var(--danger); }
.set-seg { margin: 6px 16px 0; }
.set-note { margin: 4px 16px 0; color: var(--muted); font-size: 0.8235rem; line-height: 1.45; }
.set-credits { margin: 8px 16px 12px; color: var(--muted); font-size: 0.7647rem; line-height: 1.5; text-align: center; }
.set-credits a { color: inherit; }
/* − 8 s + */
.stepper { display: flex; align-items: center; flex: none; gap: 2px; padding: 3px; border-radius: 99px; background: var(--card); }
.stepper button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--card2); color: var(--text); font-size: 1.176rem; font-weight: 700; line-height: 1; }
.stepper button:active { transform: scale(.92); }
.stepper input, .pace-in input {
  width: 38px; border: 0; background: none; color: var(--text); text-align: right; font-weight: 700; font-size: 1rem;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; padding: 0;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit, .pace-in .unit { color: var(--muted); font-size: 0.8235rem; margin: 0 6px 0 2px; }
/* 4:20 /km */
.pace-in { display: flex; align-items: baseline; flex: none; padding: 9px 8px 9px 14px; border-radius: 99px; background: var(--card); }
.pace-in input { width: 52px; text-align: center; font-size: 1.118rem; }
.pace-in:focus-within, .stepper:focus-within { box-shadow: 0 0 0 2px var(--accent); }
/* sound pickers: a pill with a chevron, and a round play button */
.sound-row select {
  flex: none; max-width: 52%; padding: 9px 30px 9px 14px; border: 0; border-radius: 99px; color: var(--text); font: inherit; font-size: 0.8824rem; font-weight: 600;
  -webkit-appearance: none; appearance: none;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238e9cb2' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center / 11px;
}
.sound-row .play { flex: none; }
/* delete account */
#delDlg { max-width: 400px; }
.del-form h2 { margin: 0 0 8px; }
.del-form p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; }
.del-form .btn:disabled { opacity: .45; }
.del-err { color: var(--danger) !important; font-weight: 600; margin: -4px 0 12px !important; }
.del-err:empty { display: none; }

/* ---------- groups ---------- */
.new-group, .group-row {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 0 16px; padding: 12px 0;
  border: 0; border-top: .5px solid var(--line); background: none; color: var(--text); text-align: left; font: inherit;
}
.new-group { border-top: 0; }
.new-group b, .group-row b { display: block; font-size: 1rem; font-weight: 700; }
.new-group small, .group-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8235rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-group .grow, .group-row .grow { min-width: 0; }
.ng-plus { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 1.412rem; font-weight: 700; }
:root[data-theme="light"] .ng-plus { background: #1c7a5e; color: #fff; }
.group-row .f-avatar, .group-member .f-avatar { width: 44px; height: 44px; font-size: 17px; flex: none; }
.group-row .chev { color: var(--muted); font-size: 1.412rem; flex: none; }
.group-card .pc-name { margin-top: 10px; }
.group-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.group-actions .btn { flex: none; min-width: 120px; }
.group-member { cursor: pointer; }
.group-member .more { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--card); color: var(--text); font-size: 1.176rem; font-weight: 700; line-height: 1; }
.join-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.join-box h2 { margin: 6px 0 0; }
.join-box p { margin: 0 0 10px; }
.join-box .btn-row { width: 100%; margin-top: 6px; }
#joinDlg, #groupDlg { max-width: 400px; }
/* add friends to a group, and the ⋯ menu for a member */
#addMembersDlg, #memberDlg { width: min(420px, calc(100vw - 32px)); }
.am-box h2, .mm-box h2 { margin: 0; }
.am-sub { margin: 4px 0 8px; }
.am-list { max-height: 55vh; overflow-y: auto; margin: 0 -16px 12px; }
.am-list .set-row { margin: 0 16px; width: calc(100% - 32px); }
.am-list .set-row:first-child { border-top: 0; }
.am-list .f-avatar { width: 40px; height: 40px; font-size: 15px; flex: none; }
#amDone, #mmClose { width: 100%; }
.mm-box:focus, .am-box:focus { outline: none; }   /* the dialog focuses itself when it opens, not its first button */
.mm-box { display: flex; flex-direction: column; align-items: center; text-align: center; }
.mm-box h2 { margin-top: 8px; }
.mm-box p.muted { margin: 2px 0 10px; }
.mm-box .set-row { width: 100%; margin: 0; }
.mm-box #mmClose { margin-top: 10px; }

/* share a run to your profile and/or groups (finish screen, poster) */
.share-to { margin: 4px 0 14px; }
.share-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.8824rem; font-weight: 600; }
.share-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.share-chip { border: 1px solid var(--line); border-radius: 99px; padding: 8px 14px; background: none; color: var(--muted); font: inherit; font-size: 0.8824rem; font-weight: 700; }
.share-chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--accent); }
:root[data-theme="light"] .share-chip.on { background: rgba(28,122,94,.1); border-color: #1c7a5e; color: #1c7a5e; }
#shareDlg { width: min(420px, calc(100vw - 32px)); }
#shareDlg .share-chips { margin: 4px 0 14px; }
.ps-shared { align-self: center; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.8235rem; padding: 2px 8px; }
.ps-shared b { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
/* invitations */
.invite-row .decline, .group-member .decline { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--card); color: var(--muted); font-size: 0.8824rem; }
.g-sub { margin: 14px 16px 0; color: var(--muted); font-size: 0.8235rem; font-weight: 700; }
.group-member.invited { opacity: .75; }

/* ---------- group photo, challenges ---------- */
.g-photo { position: relative; width: 104px; margin: 0 auto; }
.g-photo-btn { position: absolute; right: -4px; bottom: 0; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--bg);
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; padding: 0; }
.g-photo-btn svg { width: 17px; height: 17px; }
.group-actions { flex-wrap: wrap; }
.group-actions .btn { min-width: 0; flex: 1 1 0; }
.g-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 16px 10px; padding-top: 16px; border-top: .5px solid var(--line); }
.g-head b { font-size: 1.235rem; }
.btn.outline { background: none; border: 1px solid var(--line); }
.g-challenges { display: flex; flex-direction: column; gap: 10px; margin: 0 16px 18px; }
.ch-card { display: flex; flex-direction: column; gap: 9px; width: 100%; padding: 14px; border: 0; border-radius: 12px; background: var(--card);
  color: var(--text); text-align: left; font: inherit; }
.ch-card.ch-small { padding: 12px 14px; }
.ch-top { display: flex; align-items: center; gap: 10px; }
.ch-top .grow { min-width: 0; }
.ch-card b { display: block; font-size: 1rem; }
.ch-card small, .ch-line { display: block; font-size: 0.7647rem; color: var(--muted); }
.ch-right { text-align: right; flex: none; }
.ch-right b { font-size: 1rem; font-weight: 700; }
.ch-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card2); color: var(--text); }
.ch-ic svg { width: 21px; height: 21px; }
.ch-ic.lime { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.ch-ic.mint { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.ch-ic.orange { background: rgba(255,138,61,.14); color: var(--orange); }
.ch-ic.blue { background: rgba(74,168,255,.14); color: var(--fast); }
:root[data-theme="light"] .ch-ic.lime { color: #1c7a5e; background: rgba(28,122,94,.12); }
:root[data-theme="light"] .ch-ic.mint { color: #1c7a5e; background: rgba(28,122,94,.12); }
.ch-bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ch-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.ch-bar.big { height: 9px; }
.ch-bar.lime i { background: var(--accent); }
.ch-bar.blue i { background: var(--fast); }
:root[data-theme="light"] .ch-bar i { background: #1c7a5e; }
.ch-suggestion { border: 1px dashed var(--line); }
.ch-sug-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ch-sug-head small { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.ch-tag { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 0.7059rem; font-weight: 700; margin-top: 6px; }
.ch-tag.orange { background: rgba(255,138,61,.14); color: var(--orange); margin: 0; }
.ch-tag.mint { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.ch-tag.blue { background: rgba(74,168,255,.14); color: var(--fast); }
.ch-actions { display: flex; gap: 8px; }
.ch-actions .btn { flex: 1; }
.ch-withdraw { align-self: flex-start; }
/* a challenge's page */
.ch-body { display: flex; flex-direction: column; gap: 14px; padding: 0 16px 16px; }
.ch-panel { display: flex; flex-direction: column; gap: 9px; padding: 14px; border-radius: 12px; background: var(--card); }
.ch-row { display: flex; justify-content: space-between; font-size: 0.8824rem; color: var(--muted); }
.ch-row b { color: var(--text); }
.ch-mine { display: flex; align-items: baseline; gap: 8px; }
.ch-mine b { font-size: 1.824rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-mine span { color: var(--muted); }
.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chips span { padding: 6px 11px; border-radius: 99px; background: var(--card); font-size: 0.7647rem; font-weight: 600; color: var(--muted); }
.ch-list { display: flex; flex-direction: column; }
.lb2 { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-top: .5px solid var(--line); border-radius: 0; background: none; color: var(--text); font: inherit; text-align: left; }
.lb2:first-child { border-top: 0; }
.lb2.me { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 12px; border-top-color: transparent; }
.lb2.me + .lb2 { border-top-color: transparent; }
.lb2 .rk { width: 22px; text-align: center; font-weight: 700; color: var(--muted); }
.lb2 .f-avatar { width: 40px; height: 40px; font-size: 14px; flex: none; }
.lb2 .grow { min-width: 0; }
.lb2 .grow b { display: block; margin-bottom: 6px; }
.lb2 .pts { flex: none; text-align: right; }
.lb2 .pts b { display: block; font-size: 1rem; font-weight: 700; }
.lb2 .pts small { font-size: 0.7059rem; color: var(--muted); }
.ch-hint { margin: 0; text-align: center; font-size: 0.7647rem; color: var(--muted); }
.ch-del { width: 100%; margin: 6px 0 0; }
.ch-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; text-align: center; }
.pod b { display: block; font-size: 0.8235rem; margin-top: 6px; }
.pod small { display: block; font-size: 0.7647rem; color: var(--muted); margin-bottom: 6px; }
.pod .f-avatar { width: 52px; height: 52px; font-size: 17px; margin: 0 auto; }
.pod span { display: grid; place-items: center; border-radius: 12px 12px 0 0; background: var(--card2); font-weight: 700; font-size: 1.294rem; }
.pod.p1 span { height: 116px; background: var(--accent); color: var(--accent-ink); font-size: 1.529rem; }
.pod.p1 .f-avatar { width: 60px; height: 60px; border: 3px solid var(--accent); }
.pod.p2 span { height: 84px; }
.pod.p3 span { height: 62px; background: var(--card); }
.ch-won { margin: 0; text-align: center; font-weight: 700; }
/* how someone's points add up */
.cr-head { display: flex; align-items: center; gap: 12px; }
.cr-head .f-avatar { width: 44px; height: 44px; font-size: 15px; flex: none; }
.cr-head b { display: block; font-size: 1.118rem; }
.cr-head small { color: var(--muted); font-size: 0.7647rem; }
.cr-total { text-align: right; flex: none; }
.cr-total b { display: block; font-size: 1.412rem; font-weight: 700; color: var(--accent-text); }
.cr-run { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 12px; background: var(--card); }
.cr-run.off { background: none; border: 1px dashed var(--line); color: var(--muted); }
.cr-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cr-title small { color: var(--muted); font-size: 0.7647rem; }
.cr-ln, .cr-tot { display: flex; justify-content: space-between; font-size: 0.8235rem; font-variant-numeric: tabular-nums; }
.cr-ln { color: var(--muted); }
.cr-tot { border-top: .5px solid var(--line); padding-top: 8px; font-weight: 700; font-size: 0.8824rem; }
.cr-note { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 0.8235rem; line-height: 1.45; }
/* making a challenge */
.ce-intro { margin: 2px 0 4px; }
.ce-tpl { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid transparent; border-radius: 12px; background: var(--card);
  color: var(--text); text-align: left; font: inherit; }
.ce-tpl b { display: block; font-size: 1rem; }
.ce-tpl small { display: block; font-size: 0.8235rem; color: var(--muted); }
.ce-tpl:active { border-color: var(--accent); }
.ce-note { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--card); font-size: 0.8235rem; color: var(--muted); line-height: 1.45; }
.ce-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ce-dates .field, #view-cedit .field { margin: 0; }
.ce-sec { margin: 6px 0 0; line-height: 1.1; }   /* tight to its rows, without sliding under them */
.ce-mode { margin: 0; }
#view-cedit .set-row { width: 100%; margin: 0; }
.ce-rule.off .stepper { opacity: .45; }
.ce-switch { position: relative; flex: none; width: 46px; height: 28px; border: 0; border-radius: 99px; background: var(--card2); padding: 0; }
.ce-switch span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: left .2s; }
.ce-switch.on { background: var(--ok); }
.ce-switch.on span { left: 21px; background: #fff; }
.ce-check { flex: none; color: var(--accent); font-weight: 700; font-size: 1.059rem; }
.ce-val { min-width: 54px; text-align: center; font-weight: 700; font-size: 0.8824rem; font-variant-numeric: tabular-nums; }
.ce-example { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--card); font-size: 0.8235rem; line-height: 1.45; }
.ce-submit { width: 100%; padding: 16px; font-size: 1.059rem; }
/* after a run: the points it earned */
.sum-points { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.sum-points:empty { display: none; }
.sum-pts { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 16px; text-align: left;
  background: var(--card); }
.sum-pts-head { display: flex; align-items: center; gap: 10px; }
.sum-pts-head small { display: block; font-size: 0.8235rem; color: var(--muted); }
.sum-pts-head b { display: block; font-size: 1.588rem; font-weight: 700; color: var(--accent-text); }
.sum-pts-rank { font-weight: 700; }
.sum-pts-rank:empty { display: none; }
/* trophies on your profile */
.pc-trophies { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.trophy { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; background: var(--card); font-size: 0.7647rem; font-weight: 700; }
.trophy .ch-ic { width: 26px; height: 26px; border-radius: 50%; }
.trophy .ch-ic svg { width: 15px; height: 15px; }
.notif .ch-ic { width: 44px; height: 44px; border-radius: 50%; }

/* ---------- the floating notification bell (top right, stays put while you scroll) ---------- */
.float-bell {
  position: absolute; top: 10px; right: 12px; z-index: 20; width: 46px; height: 46px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  border: 0; background: var(--overlay);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.float-bell svg { width: 22px; height: 22px; }
#bellBadge { top: -3px; right: -3px; }
#bellBadge::before { content: none; }
.float-bell:active { transform: scale(.94); }

/* room for the bell: headers, the profile's settings gear, the record screen's chips, the feed tabs */
.page-head { padding-right: 70px; }
.icon-btn.settings-btn { right: 68px; top: 13px; }
.route-chip, .ghost-chip { right: 66px; }
#view-friends .friends-tabs { margin: 11px 70px 10px 16px; }
#view-activities { padding-top: 0; }   /* the large title sits level with the bell */

/* ---------- no scrollbar along the right edge (pages still scroll as normal) ---------- */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ---------- Feed · Groups: the open tab in mint ---------- */
#view-friends .friends-tabs { background: rgba(118,118,128,.24); }
:root[data-theme="light"] #view-friends .friends-tabs { background: rgba(118,118,128,.12); }
#view-friends .friends-tabs button { color: var(--text); }
#view-friends .friends-tabs button.active { background: #636366; color: var(--text); box-shadow: 0 3px 8px rgba(0,0,0,.12); }
:root[data-theme="light"] #view-friends .friends-tabs button.active { background: #fff; color: #000; }

/* ---------- suggested friends: a strip of cards you swipe sideways ---------- */
.suggest { margin: 2px 0 18px; }
.sg-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 16px 10px; }
.sg-head b { font-size: 1rem; }
.sg-all { border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 700; font-size: 0.8824rem; padding: 4px 0; }
.sg-row { display: flex; gap: 10px; overflow-x: auto; padding: 0 16px 4px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
.sg-card { position: relative; flex: none; width: 140px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px 12px; border-radius: 12px; background: var(--card); text-align: center; cursor: pointer; }
.sg-card .f-avatar { width: 60px; height: 60px; font-size: 20px; margin-bottom: 4px; }
.sg-card b { max-width: 100%; font-size: 0.8824rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-card small { max-width: 100%; font-size: 0.7059rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.sg-card .btn { align-self: stretch; }
.sg-x { position: absolute; top: 0; right: 0; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 0.7647rem; padding: 0; }
#feedList .suggest { margin: 4px 0 30px; }   /* after the first post */
/* Feed · Groups: in the page at the top; pinned to the top of the screen when you scroll back up */
#view-friends .friends-tabs { flex: none; z-index: 15; }
#view-friends .friends-tabs.pinned { position: sticky; top: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.28); animation: tabs-in .28s cubic-bezier(.2,.8,.2,1); }
#view-friends .friends-tabs.away { transform: translateY(calc(-100% - 16px)); opacity: 0; pointer-events: none; transition: transform .28s ease-in, opacity .2s; }
@keyframes tabs-in { from { transform: translateY(calc(-100% - 16px)); opacity: 0; } }
:root[data-theme="light"] #view-friends .friends-tabs.pinned { box-shadow: 0 6px 18px rgba(16,27,45,.12); }
@media (prefers-reduced-motion: reduce) { #view-friends .friends-tabs.pinned { animation: none; } }
/* challenge pages: section titles like the rest of the app, the chosen type in mint like Feed · Groups */
.ch-sec { margin: 6px 0 -4px; }
.ce-mode { background: rgba(118,118,128,.24); }
.ce-mode button.active { background: #636366; color: var(--text); }
:root[data-theme="light"] .ce-mode { background: rgba(118,118,128,.12); }
:root[data-theme="light"] .ce-mode button.active { background: #fff; color: #000; }

/* round buttons at the top are as big as the notification bell (46 px) and level with it */
.page-head { padding-top: 10px; }
.back, .page-head .icon-btn, .icon-btn.settings-btn { width: 46px; height: 46px; }
.back::before { width: 11px; height: 11px; }
.icon-btn.settings-btn { top: 10px; }
#view-friends .friends-tabs { margin-top: 11px; }

/* ---------- the round ＋ for a new group (Groups tab), bottom right above the bar ---------- */
.fab { position: absolute; right: 16px; bottom: 16px; z-index: 20; width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }
:root[data-theme="light"] .fab { background: #1c7a5e; color: #fff; box-shadow: 0 8px 20px rgba(16,27,45,.2); }
#ftab-groups { padding-bottom: 80px; }   /* the last group never hides under the ＋ */

/* your groups: a bit bigger */
.group-row { padding: 16px 0; gap: 14px; }
.group-row .f-avatar { width: 56px; height: 56px; font-size: 20px; }
.group-row b { font-size: 1.059rem; }
.group-row small { font-size: 0.8235rem; margin-top: 3px; }

/* a name field at its limit */
.limit-hint { display: block; margin-top: 5px; font-size: 0.7647rem; font-weight: 600; color: var(--slow); }
#groupList > .group-row:first-child, #groupList .friends-head + .group-row { border-top: 0; }

/* challenge settings: dates as 20-11-2026 in boxes of their own (the phone's date picker opens on tap), a bigger name box */
.ce-dates .field { min-width: 0; }
.field .date-box { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0;
  padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.field .date-val { display: block; margin: 0; font-size: 1rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-box svg { flex: none; width: 20px; height: 20px; color: var(--muted); }
.date-box input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; margin: 0; -webkit-appearance: none; appearance: none; cursor: pointer; }
.date-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
#ceName { padding: 15px 16px; font-size: 1.118rem; font-weight: 600; border-radius: 12px; background: var(--card); }

/* challenge settings: when it starts, and the fold-out with the less used settings */
.ce-when { display: block; margin: -6px 0 0; font-size: 0.8235rem; font-weight: 700; color: var(--accent); }
.ce-when:empty { display: none; }
:root[data-theme="light"] .ce-when { color: #1c7a5e; }
.ce-more { border-top: .5px solid var(--line); }
.ce-more > summary { display: flex; align-items: center; gap: 12px; padding: 14px 0; cursor: pointer; list-style: none; }
.ce-more > summary::-webkit-details-marker { display: none; }
.ce-more > summary b { display: block; font-size: 1rem; }
.ce-more > summary small { display: block; font-size: 0.8235rem; color: var(--muted); margin-top: 2px; }
.ce-more > summary::after { content: ""; flex: none; width: 9px; height: 9px; margin-right: 6px; border-right: 2.4px solid var(--muted);
  border-bottom: 2.4px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.ce-more[open] > summary::after { transform: rotate(-135deg); }
.ce-more[open] { display: flex; flex-direction: column; gap: 14px; padding-bottom: 4px; }
/* the description, on the card and the page */
.ch-desc { color: var(--text) !important; opacity: .85; }
.ch-about { margin: 0; font-size: 0.9412rem; line-height: 1.45; color: var(--muted); }
/* the collage at the end of a challenge */
.ch-collage { display: flex; flex-direction: column; gap: 12px; }
.ch-collage:empty { display: none; }
.ch-collage-img { width: 100%; aspect-ratio: 1080 / 1350; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.ch-collage-wait { display: grid; place-items: center; height: 120px; }

/* saving a run: which challenge it counts for */
.finish-note:empty { display: none; }
.finish-note { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.finish-note p { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 0.8824rem; line-height: 1.35; }
.finish-note .ch-ic { width: 32px; height: 32px; border-radius: 10px; }
.finish-note .ch-ic svg { width: 17px; height: 17px; }
.finish-note .fn-off { color: var(--muted); }

/* ---------- HIG compliance pass ----------
   Fixed per Apple HIG. Audit by HIG Compliance Auditor (Omraj Kumar). */

/* 44 x 44 pt minimum touch target: controls that look smaller get an invisible, centred tap area
   (:where keeps specificity at zero, so elements that are already positioned keep their position) */
:where(.cal-nav, .stepper button, .decline, .compass, .more, .icon-btn, .seg button, .plan-tabs button,
  .chip, .btn.small, .share-chip, .fs-back, .sg-all, .g-photo-btn, .ce-switch, .mini-switch .switch,
  .ps-shared, .gate-link, .welcome-skip) { position: relative; }
:is(.cal-nav, .stepper button, .decline, .compass, .more, .icon-btn, .seg button, .plan-tabs button,
  .chip, .btn.small, .share-chip, .fs-back, .sg-all, .g-photo-btn, .ce-switch, .mini-switch .switch,
  .ps-shared, .gate-link, .welcome-skip)::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: max(100%, 44px); height: max(100%, 44px);
  transform: translate(-50%, -50%);
}

/* the open tab's icon is filled, the others outlined */
nav button .fi { fill: none; transition: fill .15s; }
nav button.active .fi { fill: currentColor; }

/* Reduce Motion: no pulsing, popping or sliding; the km split card fades instead */
@media (prefers-reduced-motion: reduce) {
  .me-dot::after, .guard.pulse, .cd-center b.pop { animation: none; }
  .split-card { transform: none; opacity: 0; transition: opacity .2s; }
  .split-card.show { opacity: 1; }
  #view-record::after { transition: none; }
}

/* ---------- poster editor (inside the poster sheet) ---------- */
.ps-editor { display: none; order: 2; flex-direction: column; gap: 14px; }
.poster-sheet.editing .ps-editor { display: flex; }
.poster-sheet.editing :is(.ps-actions, .ps-likes, .ps-shared, .ps-friend, .ps-comments, .ps-hint, #psRemove, #psDone, #psEdit) { display: none; }
/* leave room for the controls under the poster */
.poster-sheet.editing .ps-img { max-height: max(240px, calc(var(--ps-h) - var(--ps-room) - 250px)); }
.pe-row { display: flex; flex-direction: column; gap: 8px; }
.pe-label { display: flex; justify-content: space-between; font-size: 0.7647rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.pe-label b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pe-seg { margin: 0; }
.pe-seg button:disabled { opacity: .35; }
#peOverlap { width: 100%; margin: 0; accent-color: var(--accent); }
#peStats { margin: 0; }
.pe-note { margin: 0; color: var(--muted); font-size: 0.8235rem; }
.pe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- weekly goal: the progress ring ---------- */
.ring { display: block; transform: rotate(-90deg); }   /* fills clockwise from the top */
.ring-track { fill: none; stroke: var(--card2); stroke-width: 9; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; animation: ring-in .9s cubic-bezier(.2,.8,.2,1) both; }
.ring.done .ring-fill { stroke: var(--ok); }
.ring.mini { width: 36px; height: 36px; flex: none; }
.ring.mini .ring-track, .ring.mini .ring-fill { stroke-width: 5; }
@keyframes ring-in { from { stroke-dasharray: 0 100; } }
@media (prefers-reduced-motion: reduce) { .ring-fill { animation: none; } }
/* in the Activities summary: beside the week's distance */
.hero-main { display: flex; align-items: center; gap: 12px; }
.goal-ring { position: relative; flex: none; width: 92px; height: 92px; padding: 0; border: 0; background: none; color: var(--text); }
.goal-ring .ring { width: 100%; height: 100%; }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.ring-label b { font-size: 1.118rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-label small { font-size: 0.6471rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.goal-left { margin-top: 4px; font-size: 0.8235rem; font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.goal-left.done { color: var(--ok); }
.goal-set { position: relative; margin-top: 6px; padding: 4px 0; border: 0; background: none; color: var(--accent-text); font-size: 0.8824rem; font-weight: 600; }
.goal-set::before { content: ""; position: absolute; inset: -8px -4px; }   /* 44 px tap area */
/* the goal dialog */
.goal-form h2 { margin-bottom: 4px; }
.goal-form > .muted { margin: 0 0 16px; }
.goal-pick { display: flex; align-items: center; justify-content: center; gap: 22px; }
.goal-val { min-width: 110px; text-align: center; }
.goal-val b { font-size: 3rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.goal-val span { margin-left: 4px; font-size: 1rem; font-weight: 600; color: var(--muted); }
.goal-chips { justify-content: center; flex-wrap: wrap; margin: 16px 0; }

/* ---------- pace trend (Activities) ---------- */
.trend-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trend-head h3 { margin: 0; }
.trend-seg { margin: 0; }
.trend-seg button { padding: 4px 12px; }
.trend-sum { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 10px 0 6px; }
.trend-sum b { font-size: 1.294rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.trend-sum b.faster { color: var(--ok); }
.trend-sum span { font-size: 0.8235rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend { display: block; width: 100%; height: auto; touch-action: pan-y; }
.tr-grid { stroke: var(--line); stroke-width: 1; }
.tr-y, .tr-x, .tr-tlabel { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.tr-y { text-anchor: end; }
.tr-x { text-anchor: middle; }
.tr-tlabel { text-anchor: end; }
.tr-target { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.tr-dot { fill: color-mix(in srgb, var(--accent) 55%, var(--card)); stroke: var(--card); stroke-width: 2; }
.tr-line { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.tr-cross { stroke: var(--muted); stroke-width: 1; }
.tr-sel { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.tr-hit { fill: transparent; cursor: crosshair; }
.trend-tip { display: block; width: 100%; min-height: 32px; margin-top: 4px; padding: 6px 0; border: 0; background: none;
  color: var(--muted); font-size: 0.8235rem; text-align: center; font-variant-numeric: tabular-nums; }
.trend-tip b { color: var(--text); }
.trend-empty { margin: 12px 0 4px; color: var(--muted); font-size: 0.8824rem; }

/* ================= Ice: ACE's look (2026-11) =================
   Light is a skating rink in daylight, dark is the same rink at night. Numbers lean forward in
   heavy italic (speed), and the main figure sits on a thin lime-to-mint "blade" line. */
:root :is(.hero-num, .rs-pace b, .rs-grid b, .fs-row b, .week-strip .grow b, .sc-time b, .stat b,
  .target-chip b, .totals b, .trend-sum b) { font-style: italic; font-weight: 800; letter-spacing: -.03em; }
.hero-num { display: inline-block; padding-bottom: 6px; background: var(--blade) left bottom / 100% 3px no-repeat; }
.fs-row small { text-transform: none; letter-spacing: 0; font-size: .9rem; }
h1 { font-weight: 800; letter-spacing: -.035em; }
.btn.primary { border-radius: 14px; font-weight: 700; letter-spacing: .01em; }
:root[data-theme="light"] :is(.hero, .card, .run-stats, .guard, .target-chip, .week-strip, .stat, .totals div) {
  box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(14,26,43,.05);
}
:root:not([data-theme="light"]) .hero { border: 1px solid rgba(113,214,179,.1); }
:root :is(.seg, .plan-tabs, .ce-mode), :root #view-friends .friends-tabs { background: var(--seg-bg); }
:root :is(.seg, .plan-tabs, .ce-mode) button.active, :root #view-friends .friends-tabs button.active { background: var(--seg-on); color: var(--text); }

/* ================= buttons: contents always centred =================
   Every button centres its text (and any icon or symbol next to it) both ways, so labels like
   "○ Loop" or "Set target" sit exactly in the middle whatever their font or size. */
/* :where() adds no weight, so a rule that hides one of these (e.g. "Open Settings" until location is off) still wins */
:where(.btn, .chip, .seg button, .plan-tabs button, .ce-mode button, #view-friends .friends-tabs button,
.stepper button, .fs-back, .icon-btn, .map-btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; line-height: 1.2;
}
.btn { min-height: 48px; }
.btn.small { min-height: 34px; }
.btn.big { min-height: 54px; }
.btn.lock-btn { min-height: 0; }
.stepper button { padding: 0 0 2px; font-size: 1.25rem; }   /* − and + sit a hair low in the font */
.stepper input { width: 30px; text-align: right; }   /* number and its unit read as one centred group */
.stepper .unit { margin: 0 8px 0 3px; }

/* Focus: no blue ring when you tap (a dialog focuses its first button as it opens); a mint ring
   only when moving through the app with a keyboard. */
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* phones: Safari counts a dialog focusing its first button as keyboard focus, so touch screens
   show no focus ring on buttons at all */
@media (hover: none) and (pointer: coarse) { button:focus-visible, .btn:focus-visible { outline: none; } }

/* ================= home page: just the map and Start =================
   The target pace and pace sounds are chosen on the run setup page after tapping Start; during a
   run the target row comes back so you can still change the pace. */
#view-record.is-idle .target-row { display: none; }

/* ================= run setup (between Start and the countdown) ================= */
.setup {
  position: fixed; inset: 0; z-index: 2400; display: flex; flex-direction: column; background: var(--bg);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.setup.hidden { display: none; }
.su-top { padding: 10px 16px 0; }
.su-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.su-body h1 { font-size: 2rem; margin: 4px 4px 0; }
.su-route { margin: -6px 4px 0; color: var(--accent-text); font-weight: 600; }
.su-card { background: var(--card); border-radius: var(--radius); padding: 14px; }
:root[data-theme="light"] .su-card { box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(14,26,43,.05); }
.su-seg { margin-bottom: 6px; }
.su-pace { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px 6px; }
.su-step { flex: none; width: 56px; height: 56px; border: 0; border-radius: 50%; background: var(--card2); color: var(--text);
  font-size: 1.7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 0 3px; }
.su-step:active { transform: scale(.94); }
.su-pace-num { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.su-pace-num input {
  width: 100%; border: 0; background: none; color: var(--text); text-align: center; padding: 0 0 8px;
  font-size: clamp(56px, 18vw, 76px); font-weight: 800; font-style: italic; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: var(--blade) center bottom / 56% 3px no-repeat;
}
.su-pace-num small { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.su-goal-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.su-goal-fields .field { margin: 0; }
.su-goal-pace { margin: 12px 2px 2px; color: var(--muted); }
.su-goal-pace b { color: var(--text); font-size: 1.3rem; font-style: italic; font-weight: 800; }
.su-opts { padding: 0 0 0 0; }
.su-opts .set-row { width: calc(100% - 28px); margin: 0 14px; }
.su-opts .set-row:first-child { border-top: 0; }
.su-foot { padding: 10px 16px 12px; }
.su-foot .btn { width: 100%; }

/* ================= home page: a liquid-glass Start button floating on the map =================
   Before a run the map fills the screen and Start floats over it as a pill of tinted glass: the map
   shows through, blurred, with a bright rim along the top edge like light on glass. */
#view-record.is-idle { padding-bottom: 0; }
#view-record.is-idle .rec-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; padding: 0 16px 18px; pointer-events: none;
}
#view-record.is-idle .rec-panel .controls { margin: 0; justify-content: center; }
#view-record.is-idle .map-btn { bottom: 26px; right: 16px; }   /* recenter: bottom-right corner, level with Start */
#view-record.is-idle #btnStart {
  pointer-events: auto; flex: none; width: min(calc(100% - 152px), 300px); min-height: 60px; border-radius: 999px;
  font-size: 1.2rem; -webkit-backdrop-filter: blur(10px) saturate(1.9); backdrop-filter: blur(10px) saturate(1.9);
}
#view-record.is-idle #btnStart:active { transform: scale(.96); opacity: 1; }

/* iPhone app: the real Liquid Glass Start button (native) sits on top; the web one only holds its place */
.native-start #view-record.is-idle #btnStart { visibility: hidden; }

/* ================= glass buttons (2026-11) =================
   The main buttons (Start, Start run, Set target, Resume, Create account, ...) are glass instead of
   mint: see-through and blurred, so they take their colour from whatever is behind them, with a
   bright rim along the top edge. In the iPhone app the Start button on the map is Apple's real
   Liquid Glass (AceNative.swift); the others follow the same rules here. */
:root {
  --g-fill: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.07));
  --g-rim: rgba(255,255,255,.26); --g-hi: rgba(255,255,255,.5); --g-ink: #ffffff;
  --g-shadow: 0 8px 22px rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.2);
}
:root[data-theme="light"] {
  --g-fill: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.5));
  --g-rim: rgba(255,255,255,.95); --g-hi: #ffffff; --g-ink: var(--text);
  --g-shadow: 0 8px 22px rgba(14,26,43,.14), 0 0 0 .5px rgba(14,26,43,.1);
}
:root .btn:is(.primary, .mint) {
  background: var(--g-fill); color: var(--g-ink); font-weight: 700;
  -webkit-backdrop-filter: blur(16px) saturate(1.8); backdrop-filter: blur(16px) saturate(1.8);
  border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), inset 0 -1px 0 rgba(255,255,255,.08), var(--g-shadow);
}
:root .btn:is(.primary, .mint):active { transform: scale(.97); opacity: 1; }
:root .btn:is(.primary, .mint):disabled { opacity: .55; transform: none; }

/* ================= Activities: one card for the period, swipeable insights, then its runs =================
   The top card has the distance, the goal ring (week) and a bar per day; pace trend, records and streak
   are cards you swipe through; the list shows the period's runs, or all of them. */
#weekHero .hero-sub { margin-top: 4px; }
#weekHero .hero-sub .delta { margin-left: 2px; }
.goal-ring.empty .ring-label b { font-size: 1.4rem; color: var(--accent-text); font-weight: 600; }
.insights {
  flex: none;   /* the page is a flex column: without this the scrolling row gets squashed */
  display: grid; grid-auto-flow: column; grid-auto-columns: calc(100% - 44px); gap: 10px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px; padding: 12px 16px 2px;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.insights::-webkit-scrollbar { display: none; }
.insights.hidden { display: none; }
.insights > .card { margin: 0; scroll-snap-align: start; min-width: 0; }
.ins-dots { display: flex; justify-content: center; gap: 4px; margin: 8px 0 0; }
.ins-dots.hidden { display: none; }
.ins-dots button { width: 22px; height: 22px; border: 0; padding: 0; background: none; display: grid; place-items: center; }
.ins-dots button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s; }
.ins-dots button.on::before { background: var(--text); }
.streak-card { display: flex; flex-direction: column; gap: 6px; }
.streak-card h3 { margin: 0; }
.streak-num { font-size: 2rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; line-height: 1.1; }
.streak-num small { font-size: 1rem; font-style: normal; font-weight: 600; color: var(--muted); margin-left: 4px; }
.streak-weeks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: auto; padding-top: 10px; }
.streak-weeks span { display: grid; gap: 4px; justify-items: center; font-size: .7rem; color: var(--muted); }
.streak-weeks i { width: 100%; height: 30px; border-radius: 8px; background: var(--card2); }
.streak-weeks .on i { background: var(--accent); }
.streak-weeks .now i { background: none; border: 2px dashed var(--accent); }
.streak-weeks .now.on i { background: var(--accent); border: 0; }
.act-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 20px 6px; }
.act-head b { font-size: 1.1rem; }
.act-head button { border: 0; background: none; padding: 6px 0; color: var(--accent-text); font-weight: 600; font-size: .9rem; }
.act-row.hl { background: var(--accent-soft); }
.act-none { margin: 0 16px; padding: 18px; border-radius: 12px; background: var(--card); color: var(--muted); text-align: center; font-size: .9rem; }

/* ================= Routes: the map fills the page, controls in a glass sheet =================
   Generate / Draw / Saved float at the top; the sheet holds the controls, and after generating it
   shows only the route (distance, save, another one, time at your pace, Run this). */
#view-routes { position: absolute; }
#view-routes .map-wrap { position: absolute; inset: 0; }
#view-routes.list-only .map-wrap { display: block; }
#view-routes .plan-tabs {
  position: absolute; z-index: 700; top: 10px; left: 50%; transform: translateX(-50%); margin: 0; padding: 3px; border-radius: 999px;
  background: color-mix(in srgb, var(--card) 62%, transparent); border: 1px solid var(--g-rim);
  -webkit-backdrop-filter: blur(16px) saturate(1.8); backdrop-filter: blur(16px) saturate(1.8);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow);
}
#view-routes .plan-tabs button { border-radius: 999px; padding: 7px 16px; }
#view-routes .plan-tabs button.active { background: var(--seg-on); box-shadow: none; }
@media (max-width: 380px) { #view-routes .plan-tabs { left: 12px; transform: none; } }
#view-routes .plan-panel {
  position: absolute; z-index: 700; left: 8px; right: 8px; bottom: 8px; max-height: 62%; overflow-y: auto;
  padding: 8px 14px 14px; border-radius: 26px;
  background: color-mix(in srgb, var(--bg) 84%, transparent); border: 1px solid var(--g-rim);
  -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 -6px 30px rgba(0,0,0,.3);
}
#view-routes.list-only .plan-panel { max-height: 70%; }
.sheet-grip { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.shape-btns { display: flex; gap: 6px; margin-bottom: 12px; }
.shape-btns button { flex: 1; display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border-radius: 14px; border: 1px solid var(--line);
  background: none; color: var(--text); font-weight: 600; font-size: .8rem; }
.shape-btns button svg { width: 26px; height: 18px; }
.shape-btns button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
#view-routes .dist-picker { margin-bottom: 12px; }
#view-routes .dist-val { background: none; }
#view-routes .dist-val b { font-size: 2.3rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; }
#view-routes .dist-val small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
#view-routes .plan-result { display: block; margin: 0; padding: 0; border: 0; }
.pr-top { display: flex; align-items: center; gap: 8px; }
.pr-top .muted { font-size: .85rem; }
.pr-km b { font-size: 2.4rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; line-height: 1.05; }
.pr-km small { font-size: 1rem; font-weight: 600; color: var(--muted); margin-left: 4px; }
#view-routes .plan-info { margin: 8px 0 12px; }
#view-routes .pi-stats { display: flex; gap: 22px; }
#view-routes .pi-stats div { background: none; padding: 0; border-radius: 0; }
#view-routes .pi-stats b { font-style: italic; font-weight: 800; font-size: 1.25rem; }
.pr-actions { display: flex; align-items: center; gap: 10px; }
.pr-link { border: 0; background: none; padding: 10px 0; color: var(--accent-text); font-weight: 600; font-size: .9rem; }
.pr-actions .run-this { flex: 1; margin-left: auto; min-height: 50px; }
#savedList .route-item { background: color-mix(in srgb, var(--card) 80%, transparent); }
#savedList .empty { padding: 18px 12px; }

/* ================= Feed: compact cards =================
   Each run is a short, wide picture with the whole route (on the map or plain, in pace colours or
   mint, as the runner chose), the numbers in a band along the bottom, then likes, comments and Race. */
.fi-pic { position: relative; display: block; width: 100%; aspect-ratio: 1080 / 560; padding: 0; border: 0; border-radius: 18px;
  overflow: hidden; background: #13202e; }
.fi-img, .fi-img img { position: absolute; inset: 0; width: 100%; height: 100%; }
.fi-img img { display: block; object-fit: cover; }
.fi-stats { position: absolute; left: 0; right: 0; bottom: 0; height: 30.4%; display: flex; align-items: flex-end; gap: 20px; padding: 0 14px 10px;
  background: linear-gradient(180deg, rgba(19,32,46,0), rgba(19,32,46,.92) 55%); color: #fff; text-align: left; }
.fi-stats span { display: block; }
.fi-stats b { display: block; font-size: 1.35rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fi-stats small { font-size: .68rem; color: #cfe0ea; }
.feed-item { margin-bottom: 22px; }
.feed-item .fi-actions { padding-top: 8px; }
.fi-race { margin-left: auto; }
.feed-item .fi-all { padding-top: 2px; }

/* ================= Account: highlight card =================
   Who you are and your year in running in one card (Share sends it as an image), the run grid below.
   Edit profile opens as a sheet. */
/* a liquid-glass box: see-through fill with a hint of mint, a bright rim along the top, soft shadow
   (#view-account so it beats the older "account page without boxes" rule) */
#view-account .profile-card.hl-card { position: relative; overflow: hidden; margin: 60px 12px 0; padding: 18px; text-align: left; border-radius: 28px;
  background: radial-gradient(120% 100% at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--g-fill);
  border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), inset 0 -1px 0 rgba(255,255,255,.06), var(--g-shadow); }
.hl-route { position: absolute; right: -20px; top: 8px; width: 170px; height: 170px; opacity: .3; pointer-events: none; }
.hl-route svg { width: 100%; height: 100%; }
.hl-top { position: relative; display: flex; align-items: center; gap: 12px; }
.avatar-hl { width: 52px; height: 52px; font-size: 19px; }
.hl-card .pc-name { font-size: 1.15rem; margin: 0; }
.hl-card .muted { font-size: .85rem; }
.hl-card .pc-bio { position: relative; margin: 10px 0 0; max-width: none; font-size: .92rem; }
.hl-card .pc-trophies { justify-content: flex-start; }
.hl-big { position: relative; margin-top: 18px; }
.hl-big span { display: inline-block; padding-bottom: 6px; background: var(--blade) left bottom / 100% 3px no-repeat;
  font-size: 3.4rem; font-weight: 800; font-style: italic; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.hl-big small { margin-left: 6px; font-size: 1.05rem; font-weight: 600; color: var(--muted); }
.hl-three { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.hl-three div { background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 12px; padding: 8px 10px; }
.hl-three b { display: block; font-size: 1.15rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hl-three small { font-size: .7rem; color: var(--muted); }
.hl-acts { position: relative; display: flex; gap: 8px; margin-top: 16px; }
.hl-acts .btn { flex: 1; }
/* Edit profile as a sheet */
#profileEdit:not(.hidden) { position: fixed; z-index: 2300; left: 0; right: 0; bottom: 0; margin: 0; max-height: 86vh; overflow-y: auto;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.4); }
.pe-backdrop { position: fixed; inset: 0; z-index: 2200; background: rgba(0,0,0,.45); }
.profile-card.hl-card { flex: none; }   /* the page is a flex column: without this the card gets squashed */
.pe-link { display: block; width: 100%; border: 0; border-top: .5px solid var(--line); background: none; padding: 13px 4px; text-align: left; color: var(--text); font-size: 1rem; }
.pe-link.danger { color: var(--danger); }

/* ================= Settings: glass boxes =================
   Each group is its title, then a liquid-glass box. Rows have their padding inside the box and labels
   can shrink, so steppers, switches and sound pickers always stay inside it. */
#view-settings .set-group { margin: 4px 12px 18px; }
#view-settings .set-group > h3 { margin: 0 6px 6px; }
.set-box { border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
#view-settings .set-box .set-row { width: auto; margin: 0; padding: 12px 14px; flex-wrap: nowrap; }
#view-settings .set-box button.set-row { width: 100%; }   /* buttons don't stretch on their own: the whole row is tappable */
#view-settings .set-box .set-row > :not(.grow) { flex: none; }
.set-box > .set-row:first-child, .set-box > #soundRows > .set-row:first-child { border-top: 0; }
#view-settings .set-box .set-seg { margin: 10px 12px; }
#view-settings .set-note { margin: 8px 6px 0; }
.set-more .chev { color: var(--muted); font-size: 1.3rem; line-height: 1; transition: transform .2s; }
.set-more[aria-expanded="true"] .chev { transform: rotate(90deg); }
.set-box .sound-row select { max-width: 48%; }
#view-settings .set-credits { margin-top: 0; }

/* ================= profiles (yours and a friend's): centred ring, glass pills ================= */
.prof-head { flex: none; display: grid; justify-items: center; text-align: center; padding: 56px 16px 0; }
#view-friend .prof-head { padding-top: 4px; }
.ring-av { position: relative; display: block; width: 112px; height: 112px; padding: 0; border: 0; background: none; }
.ring-svg, .ring-svg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-svg svg { transform: rotate(-90deg); }
.ring-av .avatar-ring, .ring-av #fpAvatar .avatar { position: absolute; inset: 10px; width: auto; height: auto; font-size: 32px; border: 0; }
.ring-av #fpAvatar { position: absolute; inset: 0; }
.prof-head .pc-name { font-size: 1.4rem; margin-top: 10px; }
.prof-head .muted { font-size: .88rem; }
.ring-tip { margin-top: 6px; color: var(--accent-text); font-size: .8rem; font-weight: 600; min-height: 1em; }
.ring-tip:empty { display: none; }
.prof-head .pc-bio { margin: 8px auto 0; max-width: 300px; font-size: .95rem; }
.prof-head .pc-trophies { justify-content: center; }
.prof-pills { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 12px 12px; }
.prof-pills > div { text-align: center; padding: 10px 6px; border-radius: 18px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.prof-pills b { display: block; font-size: 1.3rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.prof-pills small { font-size: .7rem; color: var(--muted); }
.prof-private { grid-column: 1 / -1; margin: 0; text-align: center; color: var(--muted); font-size: .88rem; }
.prof-acts { flex: none; display: flex; gap: 8px; margin: 0 12px 6px; }
.prof-acts .btn { flex: 1; }
.prof-acts .btn.on { color: var(--accent-text); }
#view-account .run-grid-head, #view-friend .run-grid-head { margin-top: 10px; }

/* ================= the route on the map: name + a real ✕ button =================
   A glass pill; the ✕ is a 44 pt round button (Apple's minimum tap size), split off by a line. */
#view-record .route-chip:not(.hidden) { display: flex; align-items: stretch; padding: 0; max-width: calc(100% - 20px); height: 44px; overflow: visible;
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow);
  -webkit-backdrop-filter: blur(16px) saturate(1.8); backdrop-filter: blur(16px) saturate(1.8); color: var(--text); font-size: .85rem; }
.route-chip .rc-main { display: flex; align-items: center; min-width: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; padding: 0 6px 0 14px; }
.route-chip .rc-x { flex: none; width: 44px; height: 42px; border: 0; border-left: 1px solid var(--line); border-radius: 0 99px 99px 0; background: none;
  color: var(--text); font-size: 1rem; display: grid; place-items: center; }
.route-chip .rc-x span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--text) 12%, transparent); }
.route-chip .rc-x:active span { background: color-mix(in srgb, var(--text) 24%, transparent); }
/* a message with a button (Undo) can be tapped */
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding-right: 8px; width: max-content; white-space: nowrap; }   /* one line: left 50% would otherwise cap it at half the screen */
.toast-action { border: 0; background: none; color: var(--toast-action); font: inherit; font-weight: 800; padding: 6px 10px; border-radius: 99px; }

/* the top row on the map: GPS label on the left, the route and ghost chips on the right, all left of the
   bell; only the route name shrinks ("…"). The row itself lets taps through to the map. */
.map-top { position: absolute; z-index: 500; top: 10px; left: 10px; right: 66px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-top .gps-pill, .map-top .route-chip, .map-top .ghost-chip { position: static; flex: none; }
#view-record .map-top .route-chip:not(.hidden) { flex: 0 1 auto; min-width: 0; max-width: none; margin-left: auto; }
.map-top .ghost-chip:not(.hidden) { flex: 0 1 auto; min-width: 0; max-width: none; }
.map-top .route-chip.hidden + .ghost-chip { margin-left: auto; }   /* no route: the ghost sits on the right */

/* ================= run screen: the glass dock =================
   During a run the map fills the screen and everything else is one glass panel at the bottom: the pace
   bar along its top edge with the status, the big pace, the target (tap to change), time / km / avg,
   then lock, Hold to pause (or Resume / Hold to finish) and pace sounds. */
#view-record:not(.is-idle) { padding-bottom: 0; }
#view-record:not(.is-idle) .rec-panel {
  position: absolute; z-index: 600; left: 8px; right: 8px; bottom: 8px; display: flex; flex-direction: column;
  padding: 0 16px 14px; border-radius: 30px; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), 0 -6px 30px rgba(0,0,0,.35);
}
#view-record .panel-handle, #view-record .full-stats, #view-record .rs-expand, #view-record #sLeftWrap { display: none !important; }
#view-record:not(.is-idle) .run-stats { display: contents; }
#view-record:not(.is-idle) .guard { order: 1; display: flex; flex-direction: column-reverse; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
#view-record:not(.is-idle) .gauge { margin: 14px 0 0; height: 6px; border-radius: 3px; opacity: 1; }   /* just inside the top, so the marker is never clipped */
#view-record:not(.is-idle) .guard-top { padding: 10px 0 0; }
#view-record:not(.is-idle) .rs-pace { order: 2; min-width: 0; text-align: center; margin-top: 2px; }
#view-record:not(.is-idle) .rs-pace b { font-size: 4.6rem; line-height: 1; }
#view-record:not(.is-idle) .rs-pace small { display: none; }
#view-record:not(.is-idle) .target-row { order: 3; justify-content: center; margin: 2px 0 0; }
#view-record:not(.is-idle) .target-chip { flex: none; width: auto; gap: 6px; background: none; box-shadow: none; border: 0; padding: 4px 8px; font-size: .8rem; color: var(--muted); }
#view-record:not(.is-idle) .target-chip .edit { margin-left: 2px; padding-left: 0; }
#view-record:not(.is-idle) .target-chip b { font-size: .9rem; }
#view-record:not(.is-idle) .rs-grid { order: 4; grid-template-columns: repeat(3, 1fr); gap: 0; padding: 0; border: 0; margin: 10px 0 14px; text-align: center; }
#view-record:not(.is-idle) .rs-grid > div + div { border-left: .5px solid var(--line); }
#view-record:not(.is-idle) .rs-grid b { font-size: 1.5rem; }
#view-record:not(.is-idle) .controls { order: 5; margin: 0; align-items: center; }
#view-record:not(.is-idle) .controls .btn { min-height: 50px; }
#view-record:not(.is-idle) #lockBtn, .snd-btn { flex: none; width: 50px; height: 50px; min-height: 50px; padding: 0; border-radius: 50%; }
#view-record:not(.is-idle) #lockBtn { background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi); font-size: 1.2rem; }
/* the pace sounds button: a speaker, crossed out when off */
.snd-btn { display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; color: var(--text);
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi); }
.snd-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.snd-btn svg { width: 22px; height: 22px; display: block; }
.snd-btn .snd-off, .snd-btn input:checked ~ .snd-on { display: block; }
.snd-btn .snd-on, .snd-btn input:checked ~ .snd-off { display: none; }
.snd-btn:has(input:not(:checked)) { color: var(--muted); }
.snd-btn:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
#view-record.is-idle .snd-btn { display: none; }
/* the map's own buttons stay clear of the dock */
#view-record:not(.is-idle) .map-btn { bottom: auto; top: 62px; right: 10px; }
#view-record:not(.is-idle) .split-card { top: 62px; }

/* the per-km split card hides well above the screen (it sits lower during a run, under the top row) */
.split-card { transform: translateY(calc(-100% - 90px)); }
.split-card.show { transform: translateY(0); }

/* Find friends from your contacts: only in the iPhone app */
.native-only { display: none; }
.native-app .native-only { display: block; }
.contacts-find { margin: 4px 16px 6px; }
.contacts-find .btn { width: 100%; }

/* profile: the friends pill is a button that looks like the other pills */
.prof-pills > .pill-btn { display: block; width: 100%; font: inherit; color: var(--text); text-align: center; padding: 10px 6px; border-radius: 18px;
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); cursor: pointer; }
.prof-pills > .pill-btn:active { transform: scale(.97); }
/* feed: add-friends button left of the bell, tabs make room for both */
#view-friends .feed-add { right: 64px; }
#view-friends .friends-tabs { margin-right: 122px; }

/* ---------- Friends page (A): glass boxes, three find chips, one Requests box ---------- */
#view-people .fr-box { margin: 0 16px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
#view-people .fr-box .friend { margin: 0; padding: 10px 14px; }
#view-people .fr-box .friend:first-child { border-top: 0; }
#view-people .fr-box .chev { color: var(--muted); font-size: 1.4rem; line-height: 1; padding-right: 2px; }
#view-people .fr-wait { padding-top: 8px; padding-bottom: 8px; font-size: .85rem; }
#view-people .fr-wait .btn { min-height: 32px; }
#view-people .friend-results .fr-box { margin-bottom: 8px; }
.fr-chips { display: flex; gap: 8px; margin: 8px 16px 4px; }
.fr-chip { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 20px;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--text);
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.fr-chip svg { width: 24px; height: 24px; }
.fr-chip:active { transform: scale(.97); }
.fr-chip:disabled { opacity: .6; }
.native-app .fr-chip.native-only { display: flex; }
#suggestList .sg-row { padding-bottom: 6px; }
#suggestList .sg-card { background: var(--g-fill); border: 1px solid var(--g-rim); border-radius: 22px; box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }

/* ---------- Groups (A): glass list, invitation cards, centred group page ---------- */
.g-sq { border-radius: 14px !important; }
.avatar-xl.g-sq { border-radius: 30px !important; border: 0; }
.g-invite { margin: 10px 16px 6px; padding: 14px; border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); display: flex; flex-direction: column; gap: 12px; }
.g-inv-top { display: flex; align-items: center; gap: 12px; }
.g-inv-top .grow { min-width: 0; }
.g-inv-top b { display: block; font-size: 1rem; }
.g-inv-top small { display: block; margin-top: 2px; color: var(--muted); font-size: .8235rem; }
.g-inv-top .f-avatar { width: 46px; height: 46px; font-size: 17px; flex: none; }
.g-inv-btns { display: flex; gap: 8px; }
.g-inv-btns .btn { flex: 1; }
.g-box { margin: 0 16px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
#groupList .g-box .group-row { width: 100%; margin: 0; padding: 12px 14px; gap: 12px; }
#groupList .g-box .group-row:first-child { border-top: 0; }
#groupList .g-box .group-row .f-avatar { width: 48px; height: 48px; font-size: 18px; }
.g-bar { display: block; height: 5px; margin-top: 7px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.g-bar i { display: block; height: 100%; border-radius: 3px; background: var(--blade); }
.g-new { display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 14px 16px 24px; padding: 12px 14px; border-radius: 22px;
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); color: var(--text); font: inherit; text-align: left; }
.g-new b { display: block; font-size: 1rem; }
.g-new small { display: block; margin-top: 2px; color: var(--muted); font-size: .8235rem; }
.g-new-ic { width: 48px; height: 48px; flex: none; border-radius: 14px; border: 1.5px dashed var(--muted); display: grid; place-items: center; font-size: 1.3rem; }
/* the group page: a column, so nothing in it may be squashed (that hid the group name) */
#view-group > * { flex: none; }
.g-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin: -24px 16px 0; }
.g-hero .pc-name { font-size: 1.5rem; font-weight: 800; margin-top: 10px; }
.g-hero .pc-bio { margin: 0; font-size: .95rem; }
.g-faces { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 8px; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; }
.g-face-row { display: flex; padding-left: 8px; }
.g-face-row:empty { display: none; }
.g-face { width: 28px !important; height: 28px !important; font-size: 11px !important; margin-left: -8px; border: 2px solid var(--bg); }
.g-more { background: var(--card2); color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.g-chips { margin: 14px 16px 6px; }
#view-group .g-challenges { margin: 0 16px 18px; }
#view-group .ch-card { border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.g-leave { margin: 10px 16px 24px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim); }
.g-leave .set-row { width: 100%; margin: 0; padding: 14px; border-top: 0; text-align: center; }

/* ---------- first screen, sign-up and log-in ---------- */
#gate[data-mode="start"] { background: radial-gradient(120% 70% at 50% 28%, color-mix(in srgb, var(--fast) 22%, var(--bg)) 0%, var(--bg) 65%); }
#gate[data-mode="signup"] .gate-logo, #gate[data-mode="login"] .gate-logo, #gate[data-mode="profile"] .gate-logo { display: none; }
#gate[data-mode="signup"] .gate-box, #gate[data-mode="login"] .gate-box, #gate[data-mode="profile"] .gate-box { margin-top: 0; }
#gate[data-mode="start"] .gate-box { display: flex; flex-direction: column; min-height: 100%; }
#gate[data-mode="start"] .gate-logo { width: 190px; margin: 48px auto 0; }
#gate[data-mode="start"] .gate-form { flex: 1; display: flex; flex-direction: column; }
.gate-form > * { order: 0; }
.g-h { font-size: 1.75rem; font-weight: 800; margin: 6px 4px 0; line-height: 1.2; }
.g-sub { margin: 6px 4px 14px; color: var(--muted); font-size: .95rem; font-weight: 400; line-height: 1.45; }
#gate[data-mode="start"] .g-h { text-align: center; margin-top: 34px; }
#gate[data-mode="start"] .g-sub { text-align: center; max-width: 320px; margin: 10px auto 0; font-size: 1rem; }
.g-start-btns { margin-top: auto; padding-top: 28px; display: grid; gap: 12px; }
.g-start-btns .btn { margin: 0; min-height: 54px; font-size: 1.06rem; }
.g-pace { margin-top: 44px; padding: 20px 18px; border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); display: grid; gap: 14px; }
.g-pace-l { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.g-pace-bar { position: relative; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, var(--slow) 0 30%, var(--ok) 38% 62%, var(--fast) 70% 100%); }
.g-pace-bar i { position: absolute; left: 47%; top: -7px; width: 6px; height: 24px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 3px rgba(10,19,29,.55);
  animation: g-needle 3.2s ease-in-out infinite alternate; }
@keyframes g-needle { from { left: 44%; } to { left: 54%; } }
@media (prefers-reduced-motion: reduce) { .g-pace-bar i { animation: none; } }
.g-pace-n { display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.g-pace-n b { font-size: 2.8rem; font-weight: 800; font-style: italic; letter-spacing: -.03em; line-height: 1; }
.g-pace-n span { color: var(--muted); }
.g-back { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--overlay); color: var(--text); font-size: 1.6rem; line-height: 1; margin-bottom: 14px; }
.g-fields { margin-bottom: 14px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.gfield { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 14px 0 16px; }
.gfield + .gfield { border-top: .5px solid var(--line); }
.gfield > span { width: 88px; flex: none; color: var(--muted); font-size: .95rem; }
.gfield input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font-size: 1rem; outline: none; padding: 14px 0; }
.gfield:focus-within { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.g-free { flex: none; font-size: .8rem; font-weight: 700; }
.g-free.ok { color: var(--ok); }
.g-free.bad { color: var(--danger); }
.g-eye { flex: none; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.g-eye svg { width: 20px; height: 20px; }
.g-eye.on { color: var(--accent-text); }
.gate-form .gate-legal { order: 0; text-align: left; margin: 0 6px 6px; font-size: .82rem; }
.gate-form .gate-link { order: 0; }
.gate-form .gate-msg { order: 0; }
.g-forgot { justify-self: end; padding: 0 6px 6px; }
.gate-form .btn.primary { min-height: 54px; font-size: 1.06rem; }

/* ---------- welcome slides: pictures of the real thing ---------- */
.welcome-art { min-height: 220px; }
.w-card { width: 100%; max-width: 340px; border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); text-align: left; overflow: hidden; }
.w-states > div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.w-states > div + div { border-top: .5px solid var(--line); }
.w-states > div.on { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.w-states i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.w-states i.slow { background: var(--slow); } .w-states i.ok { background: var(--ok); } .w-states i.fast { background: var(--fast); }
.w-states b, .w-lock b, .w-ch b { display: block; font-size: 1rem; }
.w-states small, .w-lock small, .w-ch small { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.w-map { position: relative; height: 220px; background: var(--card); }
.w-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.w-streets path { stroke: var(--card2); stroke-width: 3; fill: none; }
.w-loop { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.w-ghost { fill: rgba(234,242,247,.3); stroke: var(--text); stroke-width: 2; stroke-dasharray: 3 3; }
.w-you-h { fill: rgba(10,132,255,.25); } .w-you { fill: #0a84ff; stroke: #fff; stroke-width: 2.5; }
.w-tag { position: absolute; padding: 6px 12px; border-radius: 14px; font-size: .8rem; font-weight: 600; background: var(--overlay);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.w-tag.tl { left: 12px; top: 12px; } .w-tag.br { right: 12px; bottom: 12px; }
.w-ch { padding: 16px; display: grid; gap: 10px; }
.w-ch-top { display: flex; align-items: baseline; gap: 8px; }
.w-ch-top b:first-child { flex: 1; }
.w-pct { font-size: 1.2rem !important; font-style: italic; }
.w-bar { display: block; height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.w-bar i { display: block; height: 100%; border-radius: 3px; background: var(--blade); }
.w-lock { display: flex; align-items: center; gap: 14px; padding: 14px; }
.w-lock .w-ic { width: 56px; height: 56px; flex: none; }
.w-lock .w-ic svg { width: 28px; height: 28px; }

/* ---------- after a run (A): big distance, glass route, one stats strip, pace breakdown ---------- */
.summary { background: var(--bg); }
.sum-inner { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.sum-head { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.sum-km { display: inline-flex; align-items: baseline; gap: 6px; align-self: center; padding-bottom: 6px;
  background: var(--blade) left bottom / 100% 4px no-repeat; }
.sum-km b { font-size: 5.2rem; font-weight: 900; font-style: italic; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-km small { font-size: 1.3rem; font-weight: 700; color: var(--muted); }
.sum-route, .sum-stats, .sum-zones, .sum-badge { background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.sum-route { margin: 0; border-radius: 22px; }
.sum-stats { display: flex; gap: 0; border-radius: 22px; overflow: hidden; }
.sum-stats div { flex: 1; background: none; border-radius: 0; padding: 12px 4px; }
.sum-stats div + div { border-left: .5px solid var(--line); }
.sum-stats b { font-size: 1.4rem; font-weight: 800; font-style: italic; letter-spacing: -.02em; }
.sum-zones { border-radius: 22px; padding: 14px; display: grid; gap: 10px; text-align: left; }
.sum-zones:empty { display: none; }
.sz-top { display: flex; justify-content: space-between; align-items: baseline; }
.sz-top b { font-size: 1rem; }
.sz-top small, .sz-leg { color: var(--muted); font-size: .75rem; }
.sz-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.sz-bar i.slow { background: var(--slow); } .sz-bar i.ok { background: var(--ok); } .sz-bar i.fast { background: var(--fast); }
.sz-leg { display: flex; justify-content: space-between; gap: 6px; }
.sum-badges { flex-direction: row; flex-wrap: wrap; margin: 0; }
.sum-badge { border-radius: 16px; padding: 8px 12px; font-size: .9rem; font-weight: 600; }
.sum-badge span { font-size: 18px; }
.sum-badge.gold { border-color: var(--hero-border); }
.sum-actions { margin-top: 8px; gap: 10px; }
.sum-actions > .btn { min-height: 54px; font-size: 1.06rem; }
.sum-sub { gap: 10px; }
.sum-sub .btn { flex: 1; color: var(--text); min-height: 46px; }

/* ---------- run details (B): map to the top, three numbers, Pace / Splits / On pace ---------- */
#view-detail > * { flex: none; }
#view-detail .detail-map { height: 300px; min-height: 0; margin: 0; border-radius: 0; }
.d-round { position: absolute; top: 10px; z-index: 5; width: 46px; height: 46px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; color: var(--text); background: var(--overlay); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 2px 10px rgba(0,0,0,.15); font-size: 1.6rem; line-height: 1; }
.d-round svg { width: 21px; height: 21px; }
.d-back { left: 12px; }
.d-del { right: 12px; color: var(--danger); }
.d-head { margin: 14px 16px 0; }
.d-head .muted { font-size: .85rem; }
.d-head h1 { margin: 2px 0 0; font-size: 1.5rem; }
.d-stats { display: flex; margin: 12px 16px 0; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.d-stats div { flex: 1; text-align: center; padding: 11px 4px; }
.d-stats div + div { border-left: .5px solid var(--line); }
.d-stats b { display: block; font-size: 1.35rem; font-weight: 800; font-style: italic; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.d-stats small { color: var(--muted); font-size: .72rem; }
.d-tabs { margin: 12px 16px 0; }
.d-panel { margin: 10px 16px 0; padding: 14px; border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.d-panel .zone-legend { margin: 8px 0 0; }
#dGuard { display: grid; gap: 10px; }
#dGuard.hidden { display: none; }
.d-best { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: .5px solid var(--line); }
.splits .split { grid-template-columns: 30px 46px 1fr 46px; gap: 8px; }
.sp-key { font-size: .72rem; }
.sp-k3 { display: flex; justify-content: space-between; }
.dev { position: relative; height: 10px; border-radius: 5px; background: var(--card2); }
.dev::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--muted); opacity: .6; }
.dev i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.dev i.ok { background: var(--ok); } .dev i.slow { background: var(--slow); } .dev i.fast { background: var(--fast); }
.d-diff { text-align: right; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.d-diff.slow { color: var(--slow); } .d-diff.fast { color: var(--fast); }
.d-actions { display: flex; gap: 8px; margin: 14px 16px 8px; }
.d-actions .btn { flex: 1; min-height: 48px; padding: 0 6px; }

/* ---------- notifications (A): New and Earlier, each in a glass box ---------- */
.n-box { margin: 0 16px 6px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.n-box .notif { margin: 0; padding: 11px 14px; }
.n-box .notif:first-child { border-top: 0; }
.n-box .notif .f-avatar, .n-box .notif .ch-ic { width: 40px; height: 40px; font-size: 16px; }
.n-box .notif .ch-ic { border-radius: 12px; }
.n-box .n-run { flex: none; }
.n-box .notif > .btn { flex: none; }

/* ---------- challenge page (A): your place up top, leaderboard in one glass box ---------- */
#view-challenge > *, #view-cruns > *, #view-cedit > * { flex: none; }   /* a column: nothing may be squashed (that hid the title) */
#view-challenge .page-head .muted { font-size: .85rem; }
.ch-more { color: var(--danger); }
.ch-hero, #view-challenge .ch-panel, #view-challenge .ch-list { border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.ch-hero { display: flex; align-items: center; gap: 16px; padding: 16px; }
.ch-ring { width: 80px; height: 80px; flex: none; }
.ch-ring .trk { fill: none; stroke: var(--card2); stroke-width: 7; }
.ch-ring .fil { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; }
.ch-ring .n { font-size: 20px; font-weight: 800; fill: var(--text); }
.ch-ring .u { font-size: 9.5px; fill: var(--muted); }
.ch-you { display: flex; flex-direction: column; min-width: 0; }
.ch-you small { color: var(--muted); font-size: .8rem; }
.ch-you b { font-size: 2.4rem; font-weight: 900; font-style: italic; line-height: 1.05; letter-spacing: -.02em; }
.ch-you span { font-size: .9rem; margin-top: 2px; }
.ch-you em { font-style: normal; color: var(--accent-text); }
#view-challenge .ch-list { overflow: hidden; }
#view-challenge .lb2.me { border-radius: 0; }
.lb2 .rk.m1 { color: #ffd60a; } .lb2 .rk.m2 { color: #c7d2db; } .lb2 .rk.m3 { color: #d08a4a; }
#view-challenge .ch-chips span { background: var(--g-fill); border: 1px solid var(--g-rim); color: var(--text); }

/* ---------- group members: Admins / Members / Invited in glass boxes; options slide up from the bottom ---------- */
#view-gmembers > * { flex: none; }
#view-gmembers .page-head .muted { font-size: .85rem; }
.gm-box { margin: 0 16px 6px; border-radius: 22px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.gm-box .group-member { width: 100%; margin: 0; padding: 10px 14px; }
.gm-box .group-member:first-child { border-top: 0; }
.gm-box .group-member .f-avatar { width: 40px; height: 40px; font-size: 15px; }
.gm-box .group-member .more { width: 34px; height: 34px; background: var(--g-fill); border: 1px solid var(--g-rim); }
.gm-tag { flex: none; font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 9px; color: var(--accent-text);
  background: color-mix(in srgb, var(--accent) 16%, transparent); }
.gm-invite { display: flex; align-items: center; gap: 12px; width: calc(100% - 32px); margin: 8px 16px 4px; padding: 12px 14px; border-radius: 22px;
  background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); color: var(--text); font: inherit; text-align: left; }
.gm-plus { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1.5px dashed var(--muted); display: grid; place-items: center; }
#memberDlg { width: 100%; max-width: 100%; margin: auto 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; }
#memberDlg .mm-box { align-items: stretch; text-align: left; gap: 12px; }
.mm-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; }
.mm-who { display: flex; align-items: center; gap: 14px; padding: 2px 4px 0; }
.mm-who .f-avatar { width: 56px; height: 56px; font-size: 20px; }
.mm-who h2 { margin: 0; font-size: 1.25rem; }
#memberDlg .mm-who p.muted { margin: 2px 0 0; }
.mm-group { border-radius: 18px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim); }
.mm-group .set-row { padding: 14px; border-top: .5px solid var(--line); }
.mm-group .set-row:first-child { border-top: 0; }
#memberDlg #mmClose { margin-top: 0; }

/* ---------- pop-ups (B): centred glass cards, the same look for all of them ---------- */
dialog:not(#memberDlg):not(.sheet-dlg) {
  width: min(92vw, 380px); padding: 22px 18px 18px; border-radius: 30px; border: 1px solid var(--g-rim);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card2) 94%, transparent), color-mix(in srgb, var(--card) 94%, transparent));
  -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: inset 0 1px 0 var(--g-hi), 0 24px 60px rgba(0,0,0,.45);
}
dialog:not(#memberDlg):not(.sheet-dlg)::backdrop { background: rgba(0,0,0,.45); }
dialog:not(#memberDlg):not(.sheet-dlg) h2 { text-align: center; font-size: 1.25rem; font-weight: 800; margin: 0 0 4px; }
dialog:not(#memberDlg):not(.sheet-dlg) > form > p.muted, dialog .am-sub, .goal-form > p.muted { text-align: center; margin: 0 0 14px; }
dialog:not(#memberDlg):not(.sheet-dlg) .field input, dialog:not(#memberDlg):not(.sheet-dlg) .field textarea {
  border-radius: 14px; background: var(--g-fill); border: 1px solid var(--g-rim); padding: 13px 14px; }
dialog:not(#memberDlg):not(.sheet-dlg) .field span { text-transform: none; letter-spacing: 0; font-size: .8rem; }
dialog .dlg-sum { padding: 10px 4px; border-radius: 18px; background: var(--g-fill); border: 1px solid var(--g-rim); }
dialog .dlg-sum b { font-weight: 800; font-style: italic; }
dialog .dlg-actions, dialog .btn-row { display: flex; gap: 10px; margin-top: 14px; }
dialog .dlg-actions .btn, dialog .btn-row .btn { flex: 1; min-height: 48px; }
.goal-val b { font-size: 3.6rem; font-weight: 900; font-style: italic; letter-spacing: -.03em; }
.goal-pick .round { width: 52px; height: 52px; border-radius: 50%; background: var(--g-fill); border: 1px solid var(--g-rim); color: var(--text); font-size: 1.5rem; }
dialog .goal-chips { display: flex; gap: 5px; margin-top: 16px; }
dialog .goal-chips .chip { flex: 1; min-width: 0; justify-content: center; }
dialog .qr-box { border-radius: 20px; }

/* ---------- countdown (A): glass over the blurred map ---------- */
.countdown { justify-content: flex-start; gap: 24px; padding: calc(env(safe-area-inset-top) + 70px) 24px calc(env(safe-area-inset-bottom) + 28px);
  background: color-mix(in srgb, var(--bg) 55%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
.cd-chip { padding: 8px 14px; border-radius: 16px; font-size: .88rem; font-weight: 600; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.cd-track { stroke-width: 7; }
.cd-prog { stroke-width: 7; }
.cd-center b { font-size: clamp(90px, 34vw, 140px); font-weight: 900; font-style: italic; letter-spacing: -.04em; }
.countdown[data-phase="gps"] .cd-center b { display: none; }
.countdown[data-phase="gps"] .cd-center small { color: var(--text); font-weight: 700; margin-top: 10px; }
.cd-bars { display: none; align-items: flex-end; gap: 5px; height: 44px; }
.countdown[data-phase="gps"] .cd-bars { display: flex; }
.cd-bars i { width: 12px; border-radius: 3px; background: var(--card2); transition: background .3s; }
.cd-bars i:nth-child(1) { height: 14px; } .cd-bars i:nth-child(2) { height: 24px; } .cd-bars i:nth-child(3) { height: 34px; } .cd-bars i:nth-child(4) { height: 44px; }
.cd-bars i.on { background: var(--accent); }
.cd-msg { max-width: 310px; font-size: .95rem; line-height: 1.4; }
.cd-msg b { display: block; color: var(--text); font-size: 1.25rem; font-weight: 800; margin-bottom: 6px; }
.cd-actions { margin-top: auto; }
.cd-actions .btn { flex: 1; min-height: 52px; font-size: 1.06rem; background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }

/* ---------- challenge editor and points: glass boxes like Settings ---------- */
#view-cedit > *, #view-cruns > * { flex: none; }
#view-cedit .page-head .muted { font-size: .85rem; }
.ce-box, .cr-box, .ce-tpl, .ce-example, .cr-note, #view-cedit .ce-more { border-radius: 22px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.ce-box, .cr-box { overflow: hidden; }
.ce-box .set-row { width: 100%; margin: 0; padding: 12px 14px; }
.ce-box .set-row:first-child, .ce-box .gfield:first-child { border-top: 0; }
.ce-box .gfield { border-top: .5px solid var(--line); }
.ce-date .date-box { flex: 1; min-height: 0; padding: 0; background: none; border: 0; }
.ce-sec { color: var(--muted); font-size: .9rem; margin: 10px 6px 0; }
.ce-tpl { border-color: var(--g-rim); }
.ce-example { padding: 14px; font-size: .9rem; }
.ce-example b { color: var(--accent-text); }
.ce-submit { min-height: 54px; font-size: 1.06rem; }
.cr-box .cr-run { background: none; border: 0; border-radius: 0; }
.cr-box .cr-run + .cr-run { border-top: .5px solid var(--line); }
.cr-box .cr-run.off { opacity: .6; }
.cr-tot span:last-child { color: var(--accent-text); font-weight: 800; }
#view-cedit .ce-more > summary { padding: 12px 14px; }
#view-cedit .ce-more[open] { padding-bottom: 12px; }
#view-cedit .ce-more .ce-box { margin: 0 12px; }

/* ---------- poster screen (A): title, icon buttons in glass; editor with picture tiles ---------- */
.ps-title { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 800; }
.pe-top-btn { display: none; flex: none; border: 0; background: none; padding: 8px 4px; font: inherit; font-weight: 600; color: var(--muted); }
.pe-top-btn.pe-done { color: var(--accent-text); font-weight: 800; }
.poster-sheet.editing .pe-top-btn { display: block; }
.poster-sheet.editing .ps-title { text-align: center; }
.poster-sheet.editing .ps-close { display: none; }
.ps-actions { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.ps-act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; min-height: 0; border-radius: 20px; font-size: .8rem; }
.ps-act svg { width: 24px; height: 24px; }
.ps-shared { align-self: stretch; text-align: left; padding: 12px 14px; border-radius: 18px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); color: var(--muted); font-size: .9rem; }
.ps-shared b { color: var(--accent-text); text-decoration: none; float: right; }
.ps-img { border-radius: 18px; box-shadow: 0 16px 40px rgba(0,0,0,.45); }
/* editor */
#peLayout { background: none; padding: 0; gap: 6px; }
#peLayout button { display: flex; flex-direction: column; align-items: center; gap: 6px; height: auto; padding: 8px 4px; border-radius: 16px;
  border: 1px solid var(--g-rim); background: var(--g-fill); font-size: .75rem; box-shadow: none; }
#peLayout button.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
#peLayout button:disabled { opacity: .45; }
.pe-mini { position: relative; width: 38px; height: 48px; border-radius: 6px; background: #000; overflow: hidden; }
.pe-mini.m-overlap { background: linear-gradient(180deg, #5b6f86 0 55%, #000 55%); }
.pe-mini.m-side { background: linear-gradient(90deg, #5b6f86 0 50%, #15202b 50%); }
.pe-mini.m-photo { background: linear-gradient(180deg, #5b6f86 0 70%, #000 70%); }
.pe-mini.m-route { background: linear-gradient(180deg, #15202b 0 65%, #000 65%); }
.pe-mini.m-overlap::after, .pe-mini.m-route::after { content: ""; position: absolute; left: 8px; top: 9px; width: 20px; height: 14px; border: 2px solid var(--fast); border-radius: 50%; }
.pe-box { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: 20px; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.pe-box .pe-row { flex-direction: row; align-items: center; gap: 10px; }
.pe-box .pe-label { width: 64px; flex: none; text-transform: none; letter-spacing: 0; font-size: .85rem; }
.pe-box .pe-seg { flex: 1; }
.pe-label { text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 700; }
#peStats .share-chip { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; }
.poster-sheet.editing .ps-img { max-height: 270px; }
#peStats .share-chip.on::after { content: "✓"; order: -1; }   /* ::before is the 44 px tap area */
#poster.editing .ps-img { max-height: 270px !important; width: auto; }   /* beats the :has(#psHint) sizes above */

/* ---------- lock screen (A): the run stays visible; a chip on top, a glass hold button over the run buttons ---------- */
.lock-overlay { background: rgba(0,0,0,.12); }
.lock-chip { position: fixed; top: calc(env(safe-area-inset-top) + 66px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 16px; font-size: .9rem; font-weight: 700; color: var(--text); background: var(--overlay);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--g-rim); }
.lock-chip svg { width: 16px; height: 16px; }
.lock-overlay #unlockBtn { display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 28px; font-size: 1.06rem; font-weight: 700;
  color: var(--text); background-color: color-mix(in srgb, var(--card2) 92%, transparent); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow);
  background-image: linear-gradient(90deg, color-mix(in srgb, #b9e83a 45%, transparent), color-mix(in srgb, #71d6b3 45%, transparent)); }
.lock-overlay #unlockBtn svg { width: 20px; height: 20px; }

/* loading screen (B): the pace bar under ACE, its white marker moving from slow to fast as the app loads */
.sp-track { fill: url(#spPace); }
.sp-fill { display: none; }
.sp-dot { fill: #fff; stroke: rgba(10,19,29,.6); stroke-width: 10; paint-order: stroke; }

/* ---------- comments under a poster: one glass box, glass emoji keys, a glass comment bar ---------- */
.ps-comments h3 { font-size: 1.1rem; font-weight: 800; }
.cm-list { gap: 0; border-radius: 20px; overflow: hidden; background: var(--g-fill); border: 1px solid var(--g-rim);
  box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
.cm-list .cm { padding: 10px 6px 10px 12px; align-items: center; }
.cm-list .cm + .cm { border-top: .5px solid var(--line); }
.cm-list .cm .f-avatar { width: 34px; height: 34px; }
.cm-list .cm-empty { padding: 14px; text-align: center; }
.cm-quick { gap: 6px; }
.cm-quick button { border-radius: 16px; background: var(--g-fill); border: 1px solid var(--g-rim); box-shadow: inset 0 1px 0 var(--g-hi); }
.cm-form { background: var(--overlay); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-top: 1px solid var(--g-rim); }
.cm-form input { background: var(--g-fill); border: 1px solid var(--g-rim); }
.cm-form input:focus { outline: none; border-color: var(--accent); }
.cm-send { background: var(--g-fill); border: 1px solid var(--g-rim); color: var(--accent-text); box-shadow: inset 0 1px 0 var(--g-hi), var(--g-shadow); }
:root[data-theme="light"] .cm-send { background: var(--g-fill); color: var(--accent-text); }
.ps-comments h3 { text-transform: none; letter-spacing: 0; color: var(--text); }
.cm-quick button { min-width: 0; font-size: 22px; padding: 0; }

/* ---------- report and block ---------- */
.fp-more { font-size: 1.3rem; font-weight: 700; line-height: 1; }
dialog.sheet-dlg { width: 100%; max-width: 100%; margin: auto 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0;
  border: 0; border-top: 1px solid var(--g-rim); background: var(--card); }
dialog.sheet-dlg::backdrop { background: rgba(0,0,0,.45); }
.sheet-dlg .mm-box { display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 12px; }
.sheet-dlg .mm-group .set-row { width: 100%; margin: 0; padding: 14px; border-top: .5px solid var(--line); gap: 12px; }
.sheet-dlg .mm-group .set-row:first-child { border-top: 0; }
.mod-opt svg { width: 22px; height: 22px; flex: none; }
.sheet-dlg h2 { margin: 0; font-size: 1.3rem; font-weight: 800; }
.rp-sub { margin: 2px 0 0; font-size: .9rem; }
.rp-reasons .set-row { cursor: pointer; }
.rp-reasons input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
#rpDetails { width: 100%; border-radius: 16px; padding: 12px 14px; font: inherit; color: var(--text); background: var(--g-fill); border: 1px solid var(--g-rim); resize: none; }
.rp-block { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.rp-block input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.sheet-dlg .btn { min-height: 48px; }
.blocked-row .f-avatar { width: 36px; height: 36px; font-size: 13px; flex: none; }
.g-agree { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 14px; padding: 14px; border-radius: 20px; font-size: .9rem; line-height: 1.45; color: var(--muted);
  background: var(--g-fill); border: 1px solid var(--g-rim); }
.g-agree input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--accent); }
.g-agree a { color: var(--accent-text); }
