:root {
  --bg: #f6f5f2; --card: #ffffff; --fg: #141414; --muted: #6e6e73; --line: #e7e5e0;
  --field: #ffffff; --accent: #ff4d2e; --accent-soft: #ff4d2e1a; --ok: #12a150; --ok-soft: #12a1501a;
  --track: #e4e2dc; --warn-bg: #fff6dd; --warn-fg: #6b4e00;
  --shadow: 0 1px 2px #0000000a, 0 8px 24px #0000000d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0d; --card: #17171a; --fg: #f4f4f5; --muted: #9a9aa1; --line: #ffffff14;
    --field: #17171a; --accent-soft: #ff4d2e26; --ok: #2fd27a; --ok-soft: #2fd27a1f;
    --track: #2a2a2f; --warn-bg: #332900; --warn-fg: #ffe08a; --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 460px; margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Top bar: back + progress */
.topbar { display: flex; align-items: center; gap: 14px; height: 40px; margin-bottom: 20px; }
.back {
  border: 0; background: none; padding: 6px 8px 6px 0; font-size: 17px; font-weight: 600; color: var(--muted);
}
.progress { flex: 1; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .35s ease; }

/* Steps */
.step { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.step[data-step="welcome"] { padding-top: 12vh; }
@keyframes rise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }

.eyebrow {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
h1 { margin: 8px 0 12px; font-size: 40px; line-height: 1.05; letter-spacing: -.03em; font-weight: 800; }
.lede { margin: 0 0 20px; color: var(--muted); font-size: 18px; }
h2 { margin: 0; letter-spacing: -.01em; }
.q { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; margin: 0 0 6px; }
.sub { margin: 0 0 22px; color: var(--muted); }
.center { text-align: center; }
.hint { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px;
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b5b5ba; flex: none; }
.pill.live { color: var(--fg); }
.pill.live::before { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); animation: pulse 2s infinite; }

/* Fields */
input:not([type=range]), textarea {
  width: 100%; font: inherit; font-size: 20px; padding: 16px 18px; margin: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--field); color: var(--fg);
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: none; font-size: 18px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
::placeholder { color: var(--muted); opacity: .7; }
.counter { margin: 6px 4px 0; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Buttons */
button.big {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 60px; margin-top: 18px; padding: 0 20px;
  font-size: 18px; font-weight: 700; letter-spacing: -.01em;
  border: 0; border-radius: 16px; color: #fff; background: var(--accent);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
  transition: transform .1s, opacity .15s;
}
button.big:active { transform: scale(.98); }
button.big:disabled { opacity: .4; transform: none; }
button.send { background: #12a150; } /* the deeper green in dark mode too: readable white text (as in the app) */
button.secondary { background: var(--card); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; }
.row button { flex: 1; }

/* Choice cards */
.choices { display: grid; gap: 12px; margin-top: 22px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 18px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--card);
  box-shadow: var(--shadow); transition: border-color .15s, transform .1s;
  touch-action: manipulation;
}
.choice:active { transform: scale(.985); }
.choice:disabled { opacity: .4; }
.choice::after { content: "›"; margin-left: auto; font-size: 26px; line-height: 1; color: var(--muted); }
.choice.selected { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.choice-icon {
  display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px;
  background: var(--bg); font-size: 22px;
}
.choice-text strong { display: block; font-size: 18px; }
.choice-text small { display: block; font-size: 14px; color: var(--muted); }
.choices + .banner { margin-top: 16px; }

/* Distance picker */
.km-picker {
  margin-top: 14px; padding: 22px 20px 20px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: rise .3s ease both;
}
.km-row { display: flex; align-items: center; justify-content: space-between; }
.km-readout { font-size: 56px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.km-readout .unit { font-size: 22px; font-weight: 700; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.step-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  font-size: 26px; line-height: 1; touch-action: manipulation;
}
.km-note { margin: 8px 0 18px; text-align: center; font-size: 15px; font-weight: 600; color: var(--ok); }
.km-note.taken { color: var(--accent); }

.slider { position: relative; height: 36px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; position: relative; z-index: 1;
  width: 100%; height: 36px; margin: 0; background: transparent; touch-action: none;
}
input[type=range]:focus { outline: none; }
/* The track itself is invisible: the bricks underneath are the timeline. */
input[type=range]::-webkit-slider-runnable-track { height: 8px; background: transparent; }
input[type=range]::-moz-range-track { height: 8px; background: transparent; }
input[type=range]::-moz-range-progress { background: transparent; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 4px #0000004d, 0 0 0 1px #0000000f;
}
input[type=range]::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 1px 4px #0000004d;
}
/* The timeline: a flat bar of bricks, 3 per bookable distance (its places), filling as cheers are booked. Each
   distance's 3 bricks sit centred under the thumb's spot for it. With many distances (e.g. a marathon) the gaps
   go, so it reads as one continuous line with booked stretches. */
.bricks { position: absolute; left: 15px; right: 15px; top: 12px; height: 12px; display: flex; gap: 2px;
  border-radius: 3px; overflow: hidden; pointer-events: none; }
.bricks i { flex: 1; min-width: 0; display: flex; gap: 1px; }
.bricks.tight, .bricks.tight i { gap: 0; }
.bricks b { flex: 1; background: var(--track); }
.bricks b.on { background: var(--accent); }
.slider-ends { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; color: var(--muted); }
.brick-key { display: inline-block; width: 6px; height: 12px; border-radius: 2px; background: var(--accent); vertical-align: -1px; margin-right: 2px; }

/* Recorder */
.rec-area { display: flex; flex-direction: column; align-items: center; padding: 28px 0 8px; }
.mic {
  display: grid; place-items: center; width: 132px; height: 132px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; box-shadow: 0 12px 32px #ff4d2e55;
  touch-action: manipulation; transition: transform .1s, background .2s;
}
.mic:active { transform: scale(.96); }
.mic svg { width: 52px; height: 52px; fill: currentColor; }
.mic .i-stop { display: none; }
.mic.recording { background: var(--fg); color: var(--bg); animation: ring 1.5s infinite; }
.mic.recording .i-mic { display: none; }
.mic.recording .i-stop { display: block; }
.rec-label { margin: 16px 0 0; font-weight: 600; color: var(--muted); }
.countdown { margin-top: 4px; font-size: 40px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
audio { width: 100%; margin-top: 8px; }

/* Done */
.step[data-step="done"] { padding-top: 8vh; }
.done-badge {
  display: grid; place-items: center; width: 88px; height: 88px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--ok); color: #fff; box-shadow: 0 0 0 10px var(--ok-soft);
  animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.done-badge svg { width: 44px; height: 44px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

.status { min-height: 1.4em; margin: 14px 0 0; font-size: 15px; font-weight: 600; }
.status:empty { min-height: 0; margin: 0; }

/* Banners */
.banner {
  background: var(--warn-bg); color: var(--warn-fg); padding: 14px 16px;
  border-radius: 16px; margin: 0 0 16px; font-size: 15px;
}
.banner.error { background: var(--accent-soft); color: var(--fg); border: 1px solid var(--accent); }
.banner ul { margin: 6px 0 0; padding-left: 20px; }

/* Sent list */
.list-title { font-size: 15px; color: var(--muted); font-weight: 600; margin: 40px 4px 10px; }
#sentList { list-style: none; padding: 0; margin: 0; }
#sentList li {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 8px; font-size: 15px;
}
#sentList li span { display: block; }
#sentList li span + span { margin-top: 2px; font-size: 14px; color: var(--muted); }
#sentList li span.played { color: var(--ok); font-weight: 600; }
.sent-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sent-actions button {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600;
}
.sent-actions button.danger { color: var(--accent); }
.sent-actions button.danger.confirm { background: var(--accent); border-color: var(--accent); color: #fff; }
.avatar {
  display: block; width: 72px; height: 72px; margin: 0 0 16px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--card); box-shadow: var(--shadow); background: var(--line);
}
.replace-note {
  margin: 0 0 16px; padding: 10px 14px; border-radius: 14px; font-size: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent);
}

/* Landing page (/) */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
code { font-size: .9em; padding: 2px 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }

@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 #ff4d2e80; } 100% { box-shadow: 0 0 0 18px #ff4d2e00; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Live tracking */
.track {
  margin-top: 28px; padding: 18px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.track-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.track-km { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.track-km .unit { font-size: 18px; font-weight: 700; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.track-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.track-note { margin: 8px 0 14px; font-size: 12px; color: var(--muted); }
.track-stats div { display: flex; flex-direction: column; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.track-stats .stat-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.track-age { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
.track-age::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #b5b5ba; }
.track-age.live::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.track-bar { height: 6px; margin: 14px 0; border-radius: 6px; background: var(--track); overflow: hidden; }
.track-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .6s ease; }
.map-wrap { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.map { height: 260px; background: var(--bg); }
.follow {
  position: absolute; z-index: 500; right: 10px; bottom: 26px; padding: 8px 12px; border-radius: 999px;
  border: 0; background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
}
.leaflet-container { font: inherit; }
.leaflet-tile-pane { filter: saturate(.6) contrast(.95); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.4); }
}
.leaflet-control-attribution { font-size: 10px; }
.km-mark { width: 0; height: 0; }
.km-mark span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 16px;
  background: #fff; color: #141414; border: 1px solid #0000002a; box-shadow: 0 1px 3px #00000033;
}
.km-mark.end span { background: #141414; color: #fff; }

/* Run over */
.ended { padding-top: 14vh; text-align: center; animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.ended-badge { font-size: 40px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* Privacy and contact links at the bottom of each page */
.footer-links { margin: 32px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.footer-links a { color: inherit; }
