:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #16191d; --muted: #5d6670; --line: #dde1e6;
  --accent: #1f6feb; --good: #1a7f37; --bad: #c62828; --warn: #b35900; --area: #c9d8f0;
  /* Heart-rate zones, Garmin's usual colours: below z1, z1 grey, z2 blue, z3 green, z4 orange, z5 red */
  --stat: #3f74a3;  /* steel blue: the stats row's values */
  --crew: #0f8b8d;  /* crew phones on the map (teal: apart from the runner's red and the estimate's amber) */
  --z0: #b8bec6; --z1: #7d8590; --z2: #2f7fd6; --z3: #2e9a47; --z4: #e08a00; --z5: #d6332e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1215; --panel: #181c21; --text: #e8eaed; --muted: #98a2ad; --line: #2b3138;
    --accent: #5b9bff; --good: #4cc26b; --bad: #ff6b6b; --warn: #f0a050; --area: #2a3c5a;
    --stat: #7fb2de;
    --crew: #3cc7c0;
    --z0: #5c636b; --z1: #9aa3ad; --z2: #5aa2f0; --z3: #4cc26b; --z4: #f2a33a; --z5: #ff6b6b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.3rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.card.big { text-align: center; padding: 18px 14px; }
.label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.eta { font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.val { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.val.sm { font-size: 1rem; }
.sub { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.row .card { margin: 0; }
.fresh { padding: 8px 12px; border-radius: 8px; font-weight: 600; text-align: center; }
.fresh.ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.fresh.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.fresh.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.warn { color: var(--warn); } .good { color: var(--good); } .bad { color: var(--bad); }
.bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: 12px 0 4px; }
.bar div { height: 100%; background: var(--accent); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.profile { width: 100%; height: auto; display: block; }
.profile .area { fill: var(--area); stroke: var(--accent); stroke-width: 1; }
.profile .st { stroke: var(--muted); stroke-dasharray: 3 3; }
.profile .me { stroke: var(--bad); stroke-width: 2; }
nav { display: flex; gap: 6px; margin-bottom: 12px; }
nav button, .btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer; }
nav button[aria-selected="true"], .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
input[type=text], input[type=number], select, textarea { font: inherit; padding: 7px 9px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
label.f { display: block; margin: 8px 0 4px; color: var(--muted); font-size: .9rem; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input[type=text] { flex: 1 1 220px; }
.err { color: var(--bad); font-size: .9rem; white-space: pre-wrap; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); } .chart .axis { fill: var(--muted); font-size: 11px; }
.filters { margin: 4px 0 6px; } .filters select { width: auto; }
.chart .grid { stroke: var(--line); } .chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.hrl .ln .main path { stroke-width: 2.25; stroke-linecap: round; fill: none; }
.hrl .ln.active .main path { stroke-width: 3; }
.hrl .hit { fill: transparent; stroke: none; pointer-events: all; }
.hrl .ln { cursor: pointer; transition: opacity .12s; }
.hrl .hrlabel { fill: var(--muted); font-size: 11px; }
.hrl.hovering:not(.selected) .ln:not(.hot) { opacity: .2; }
.hrl .ln.hot .main path { stroke-width: 3.5; }
.hrl .ln.hot .hrlabel, .hrl .ln.active .hrlabel { fill: var(--text); font-weight: 700; }
.hrl .pc > path { stroke-width: 1.1; fill: none; stroke-linecap: round; }
.hrl .pclabel { fill: var(--muted); font-size: 9.5px; cursor: default; }
.hrl.hovering .pc:not(.hot) { opacity: .35; }
.hrl .pc.hot > path { stroke-width: 2.2; }
.hrl .pclabel.hot { fill: var(--text); font-weight: 700; }
#t-sel:empty { display: none; }
#t-sel { margin: 0 0 6px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.hrl .pband { display: none; }
.hrl .pc.hot .pband { display: inline; }
.hrl .pband path { opacity: .28; stroke: none; }
.hrl .bhit { fill: transparent; stroke: none; pointer-events: all; }
.plegend { display: inline-flex; align-items: center; gap: 0; margin-left: 12px; }
.plegend i { display: inline-block; width: 14px; height: 10px; }
.plegend .sub { margin: 0 6px; font-size: .8rem; }
.map { height: 420px; border-radius: 10px; border: 1px solid var(--line); margin: 10px 0; z-index: 0; }
@media (max-width: 600px) { .map { height: 320px; } }
.hidden { display: none !important; }

/* ---- crew page: full-screen map, race panel in front ---- */
body.crew { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; }
/* The browser's text zoom doesn't apply: the panel is laid out to fit. On body's children, as some
   browsers apply the zoom as a style on html or body itself (it's inherited, so this overrides it). */
body.crew, body.crew > * { -webkit-text-size-adjust: 100% !important; text-size-adjust: 100% !important; }
body.crew #map { position: fixed; inset: 0; z-index: 0; background: #fff; }
/* Map tiles at 50% (blended towards white) so the course, track and markers stand out. */
body.crew .leaflet-tile-pane { opacity: .5; }
#panel { position: fixed; z-index: 500; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 18px rgb(0 0 0 / .12);
  transition: height .2s ease; padding-bottom: env(safe-area-inset-bottom); }
/* min: header + next checkpoint; open: the height dragged to (inline style); full: whole screen */
#panel[data-size="min"] { height: auto; }
#panel[data-size="open"] { height: 52vh; max-height: 100dvh; }
#panel[data-size="full"] { height: 100dvh; border-radius: 0; }
#panel[data-size="min"] .pbody, #panel[data-size="min"] .pgraphs, #panel[data-size="min"] .replay { display: none; }
/* Fixed at the top of the panel (no scrolling): replay speed, next checkpoint, graphs. Only the
   checkpoint table below scrolls. */
.pgraphs { flex: none; padding: 0 12px 6px; position: relative; }
.stats > div[hidden] { display: none; }
/* Graph tooltip and the cursor it puts on every graph */
.gtip { position: absolute; z-index: 3; max-width: 240px; padding: 6px 9px; border-radius: 8px; font-size: .78rem; line-height: 1.35;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 2px 10px rgb(0 0 0 / .18);
  pointer-events: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gtip[hidden] { display: none; }
.pf-cur { stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.replay[hidden] { display: none; }
#panel.dragging { transition: none; }
/* Map buttons: Leaflet's zoom buttons and ours (Follow, estimate) look the same, in light and dark. */
.follow-btn { background: var(--panel); color: var(--text); border: 2px solid rgb(0 0 0 / .2); border-radius: 4px;
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center; cursor: pointer; }
body.crew .leaflet-bar { border-color: rgb(0 0 0 / .2); border-radius: 4px; }
body.crew .leaflet-bar a, body.crew .leaflet-bar a:hover { background: var(--panel); color: var(--text); border-bottom-color: var(--line); }
body.crew .leaflet-bar a:hover { background: color-mix(in srgb, var(--text) 8%, var(--panel)); }
body.crew .leaflet-bar a.leaflet-disabled { color: var(--muted); background: var(--panel); }
body.crew .leaflet-touch .leaflet-bar a, body.crew .leaflet-bar a { width: 30px; height: 30px; line-height: 30px; }
@media (prefers-color-scheme: dark) { body.crew .leaflet-bar, .follow-btn { border-color: rgb(255 255 255 / .18); } }
.follow-btn.on { background: var(--warn); color: var(--panel); border-color: var(--warn); }   /* amber, like the estimate */
.grab { display: flex; justify-content: center; align-items: center; height: 22px; flex: none; cursor: ns-resize; touch-action: none; }
.grab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.grab span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
#next { touch-action: none; }
.fs-btn { position: absolute; top: 4px; right: 8px; z-index: 2; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer; }
.fs-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fs-btn[hidden], .fs-collapse, .is-fs .fs-expand { display: none; }
.is-fs .fs-collapse { display: block; }
/* Full screen on a phone: keep the handle and the button clear of the status bar / notch. */
#panel[data-size="full"] { padding-top: env(safe-area-inset-top); }
#panel[data-size="full"] .fs-btn { top: calc(env(safe-area-inset-top) + 4px); }
@media (min-width: 900px) { .fs-btn { display: none; } }
@media (max-width: 899px) { .fs-btn:not([hidden]) ~ .next { padding-right: 50px; } }
@media (min-width: 900px) {
  #panel { left: 12px; top: 12px; bottom: auto; right: auto; width: 410px; border: 1px solid var(--line); border-radius: 12px;
    max-height: calc(100dvh - 24px); }
  #panel[data-size="min"] { height: auto; }
  #panel[data-size="open"] { height: calc(100dvh - 24px); }
  #panel[data-size="full"] { left: 0; top: 0; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
  .grab { order: 99; }   /* side panel: the handle is on the bottom edge */
}
/* A desktop: as tall as what's in it, up to the window (then the checkpoint list scrolls); no
   handle, no resizing (crew.js keeps it "open"). */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  #panel[data-size="open"] { height: auto; }
  #panel .pbody { flex: 0 1 auto; }
  #panel .grab { display: none; }
}
.offline-banner { position: fixed; z-index: 600; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 120px); white-space: pre; overflow: hidden; text-overflow: ellipsis; text-align: center; line-height: 1.3;
  font-size: .8rem; padding: 3px 12px; border-radius: 12px; font-variant-numeric: tabular-nums; pointer-events: none; color: var(--text);
  background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  box-shadow: 0 1px 4px rgb(0 0 0 / .12); }
.offline-banner[hidden] { display: none; }
@media (min-width: 900px) { .offline-banner { left: calc(434px + (100vw - 434px) / 2); max-width: calc(100vw - 560px); } }
/* Next checkpoint: "Name at 1:02 pm in 0:18", distance and climb under it. Also the drag area. */
.next { flex: none; padding: 0 12px 8px; min-height: 2.9em; cursor: ns-resize;
  background: color-mix(in srgb, var(--accent) 9%, transparent); }
.next-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.1rem; }
.nx-in, #nx-at, #nx-meta { font-variant-numeric: tabular-nums; }
.nx-in { font-size: .75em; }  /* three-quarters of the arrival time before it */
#nx-note:empty { display: none; }
.gtoggles { display: flex; gap: 6px; margin: 2px 0 6px; }
.gtoggles button[data-g] { font: inherit; font-size: .78rem; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted); }
.gtoggles button[data-g][aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }
.graph[hidden] { display: none; }
.graph + .graph { margin-top: 2px; }
.pf-line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pf-rank { stroke: var(--text); opacity: .7; } .pf-dots { fill: none; stroke: var(--text); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.gtoggles button[hidden] { display: none; }
.pf-pace { stroke: var(--accent); } .pf-ele { stroke: var(--muted); } /* HR: zone gradient in the graph's own units. No non-scaling stroke here: with it, WebKit lays the
   gradient out in screen space, so page zoom (pinch) shifts the zone colours off the values. The
   width is in viewBox units instead (600 wide: about 2 px on a phone, 3 on a wide panel). */
.pf-hr { stroke: url(#hrz); stroke-width: 3.2; vector-effect: none; stroke-linejoin: round; stroke-linecap: round; }
.pbody { overflow-y: auto; padding: 0 12px 12px; flex: 1; min-height: 0; }
.profile-wrap .pf { width: 100%; height: auto; display: block; }
.pf.clickable { cursor: zoom-in; }
.pf-area { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 1; }
.pf-done { fill: color-mix(in srgb, var(--accent) 45%, transparent); }
.pf-st { stroke: var(--muted); stroke-dasharray: 2 3; } .pf-st.w { stroke-dasharray: 1 4; }
.pf-ax { fill: var(--muted); font-size: 10px; }
.pf-me { stroke: var(--warn); stroke-width: 2; } .pf-last { stroke: var(--bad); stroke-width: 2; }
/* Graphs full screen: the panel covers the screen with only the graphs and their toggles; each
   graph full width at the panel's aspect ratio (600:50). Their viewBox is their size in pixels,
   so nothing is stretched. */
body.gfs #panel { inset: 0; width: auto; height: 100dvh !important; max-height: none; border: 0; border-radius: 0;
  background: var(--panel); backdrop-filter: none; transition: none; box-shadow: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.gfs #panel > :not(.pgraphs) { display: none !important; }
body.gfs .pgraphs { display: flex !important; flex: 1; flex-direction: column; min-height: 0; padding: 8px 12px 12px; }
body.gfs .gtoggles { min-height: 34px; align-items: center; }
body.gfs #profile { flex: 1; min-height: 0; overflow-y: auto; touch-action: none; }
body.gfs .graph + .graph { margin-top: 8px; }
body.gfs .profile-wrap .pf { width: 100%; height: auto; aspect-ratio: 600 / 50; cursor: crosshair; user-select: none; -webkit-user-select: none; }
body.gfs .pf-ax { font-size: 12px; }
body.gfs .pf-hr { stroke-width: 2.5; }
.gclose { margin-left: auto; flex: none; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--text); cursor: pointer; }
.gclose[hidden] { display: none; }
.replay { flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 4px; font-size: .85rem; white-space: nowrap; }
.replay input { flex: 1; min-width: 0; }
@media (max-width: 899px) { .fs-btn:not([hidden]) ~ .replay { padding-right: 50px; } }
table.cps { table-layout: fixed; width: 100%; }
/* One line per checkpoint: km and name | ETA with countdown | change and its trend, small and quiet. */
table.cps th { padding: 2px 4px; font-size: .78rem; color: var(--muted); font-weight: 600; text-align: left; }
table.cps td { padding: 3px 4px; line-height: 1.2; vertical-align: top; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
table.cps tbody tr + tr td { border-top: 1px solid color-mix(in srgb, var(--muted) 15%, transparent); }
table.cps .c-name { width: auto; text-overflow: ellipsis; }
table.cps .c-eta { width: 9.2em; }
table.cps .c-chg { width: 4.2em; color: var(--muted); font-size: .75rem; }
.cp-nm { overflow: hidden; text-overflow: ellipsis; }
.cp-sub, .cp-est { color: var(--muted); font-size: .75rem; }
.cp-nm { display: flex; gap: .4em; align-items: baseline; }
.cp-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cp-est { flex: none; color: var(--muted); font-size: .75rem; }
/* Completed checkpoints fade out; ones the estimate has passed (no data yet) fade less. */
table.cps tr.passed { opacity: .4; }
table.cps tr.est-passed { opacity: .7; }
table.cps tr { transition: opacity .3s; }
table.cps tr.est-passed .cp-est, table.cps tr.est-passed .cp-time { color: var(--warn); }
.chg { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chg { min-height: 1.2em; }
.chg.later { color: var(--bad); } .chg.earlier { color: var(--good); }
.spark { display: block; width: 3.6em; height: 1.1em; opacity: .55; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* Stats at the top of the panel: value with a small label above. */
.stats { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; padding: 0 12px 6px;
  font-variant-numeric: tabular-nums; cursor: ns-resize; touch-action: none; }
.stats > div { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; white-space: nowrap; }
.stats > div > span { max-width: 100%; }
.stats > div > span.est:nth-child(2), .stats .st-pace > .est, .gait-ic.est { color: var(--warn); }  /* offline: estimated, like the estimate on the map */
/* The pace is centred in its cell like the other values; the gait figure hangs off its left. */
.stats > div > span.st-pace:nth-child(2) { position: relative; overflow: visible; }
.gait-ic { position: absolute; right: calc(100% + 1px); top: 50%; transform: translateY(-50%); width: 11.6px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stats > div > span:nth-child(2) { font-weight: 400; color: var(--stat); font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; }
.st-l { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; line-height: 1.3; }
@media (max-width: 899px) { .fs-btn:not([hidden]) ~ .stats { padding-right: 50px; } }
/* .est-icon is Leaflet's absolutely positioned marker element: don't override its position. */
.est-ring { width: 30px; height: 30px; border-radius: 50%; border: 3px dashed var(--warn); box-sizing: border-box;
  background: color-mix(in srgb, var(--warn) 18%, transparent); animation: estpulse 2s ease-in-out infinite; }
@keyframes estpulse { 50% { transform: scale(1.18); opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .est-ring { animation: none; } }

/* /admin events list */

/* ===== /admin: dense, typographic; rules instead of boxes, text actions instead of big buttons ===== */
body.admin { font-size: 14.5px; line-height: 1.45; }
body.admin main { max-width: 1120px; padding: 12px 20px 40px; }
body.admin h1 { font-size: 1rem; font-weight: 700; letter-spacing: .02em; margin: 0 0 6px; }
body.admin nav { gap: 18px; border-bottom: 1px solid var(--line); margin: 0 0 4px; }
body.admin nav button { background: none; border: 0; border-radius: 0; padding: 6px 0; color: var(--muted);
  font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
body.admin nav button[aria-selected="true"] { color: var(--text); background: none; border-bottom-color: var(--text); }
body.admin h2 { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
body.admin p { margin: 4px 0; }
body.admin .sub { font-size: .85rem; }
body.admin .card { border: 0; border-radius: 0; background: none; padding: 0; margin: 8px 0; }
/* inputs */
body.admin input[type=text], body.admin input[type=password], body.admin input[type=number], body.admin input[type=datetime-local], body.admin select, body.admin textarea {
  font: inherit; font-size: .92rem; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel); color: var(--text); width: 100%; min-width: 0; }
body.admin input:focus-visible, body.admin select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
body.admin input[type=range] { width: 100%; accent-color: var(--accent); }
body.admin .w-auto { width: auto; } body.admin .w-5 { width: 5em; flex: none; } body.admin .w-6 { width: 6em; flex: none; }
/* actions: one solid button per form, the rest are text */
body.admin .btn { padding: 3px 12px; border-radius: 4px; font-size: .88rem; line-height: 1.5; background: var(--panel); }
body.admin .btn.primary { background: var(--text); color: var(--panel); border-color: var(--text); }
body.admin .tbtn { background: none; border: 0; padding: 2px 4px; color: var(--accent); font: inherit; font-size: .88rem; cursor: pointer; }
body.admin .tbtn:hover { text-decoration: underline; }
body.admin .tbtn.danger { color: var(--bad); }
body.admin .tbtn[hidden] { display: none; }
body.admin label.file { display: inline-block; }
/* label | field grid */
body.admin .form { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 6px 14px; align-items: center; max-width: 760px; }
body.admin .form > label { color: var(--muted); font-size: .85rem; }
body.admin .field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
body.admin .field[hidden] { display: none; }
body.admin .field > input[type=text], body.admin .field > select { flex: 1 1 14em; width: auto; }
body.admin .field > input[type=range] { flex: 1 1 12em; }
body.admin .inl, body.admin .chk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .85rem; }
@media (max-width: 640px) { body.admin .form { grid-template-columns: 1fr; gap: 2px; } body.admin .form > span:empty { display: none; }
  body.admin .form > label { margin-top: 6px; } }
/* events: list | editor */
body.admin .split { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 28px; }
@media (max-width: 860px) { body.admin .split { grid-template-columns: 1fr; gap: 0; } }
body.admin .evlist { list-style: none; margin: 0; padding: 0; }
body.admin .evlist li { padding: 6px 8px; border-left: 2px solid transparent; }
body.admin .evlist li.sel { border-left-color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
body.admin .evlist a { color: var(--text); text-decoration: none; font-weight: 600; }
body.admin .evlist a:hover { text-decoration: underline; }
body.admin .evlist li:not(.active) a { font-weight: 400; }
body.admin .newev { margin-top: 8px; }
body.admin .edcol[hidden] { display: none; }
/* checkpoint reconciliation */
body.admin table.rec { font-size: .88rem; }
body.admin table.rec th, body.admin table.rec td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
body.admin table.rec th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
body.admin table.rec .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.admin table.rec td.warn { color: var(--warn); font-weight: 700; }
body.admin table.rec tr.off td { color: var(--muted); }
body.admin table.rec tr.off input[type=text] { color: var(--muted); }
body.admin table.rec input[type=text] { min-width: 9em; }
body.admin table.rec select { max-width: 17em; }
body.admin #rp-live[hidden] { display: none; }
body.admin table.rec td.on { font-weight: 600; color: var(--text); }
body.admin table.rec td:has(> .pick) { width: 1.6em; }
body.admin table.rec tr.off td { color: var(--muted); }
/* checkpoints: GPX | UTMB | Custom | Crew, a row each; the pressed one is the checkpoint. On a phone
   each row is a block: one line per option, tagged with where it's from. */
body.admin .cpgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 3rem; gap: 3px 10px; max-width: 900px; margin: 6px 0 10px; }
body.admin .cprow { display: contents; }
body.admin .cphead { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 2px 2px; }
body.admin .cpcell { min-width: 0; }
body.admin .cpend { display: block; font-size: .88rem; padding: 3px 8px; color: var(--muted); }
body.admin .cpcrewcell { display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
body.admin .cpcrewcell span { display: none; }
body.admin .cpcustomcell { display: flex; align-items: center; gap: 6px; }
body.admin .cpkm { flex: none; font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
body.admin input.cpcustom { flex: 1; min-width: 0; width: auto; box-sizing: border-box; font: inherit; font-size: .88rem; padding: 3px 8px; border-radius: 4px;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); margin: 0; }
body.admin input.cpcustom:hover { border-color: var(--muted); }
body.admin input.cpcustom.on { background: var(--text); color: var(--panel); border-color: var(--text); }
@media (max-width: 640px) {
  body.admin .cpgrid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  body.admin .cphead { display: none; }
  body.admin .cprow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); }
  body.admin .cprow > .cpcell { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr); align-items: center; gap: 8px; }
  body.admin .cprow > .cpcell::before { content: attr(data-src); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  body.admin .cprow > .cpcell:empty { display: none; }
  body.admin .cprow > .cpcustomcell { display: flex; }
  body.admin .cprow > .cpcustomcell::before { flex: none; width: 3.6rem; }
  body.admin .cprow > .cpcrewcell { display: flex; justify-content: flex-start; padding-left: calc(3.6rem + 8px); }
  body.admin .cprow > .cpcrewcell::before { content: none; }
  body.admin .cpcrewcell span { display: inline; font-size: .88rem; }
  body.admin .cpendrow { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  body.admin .cpendrow > .cpend { display: block; padding: 3px 0; color: var(--text); }
  body.admin .cpendrow > .cpcrewcell { padding-left: 0; }
}
body.admin .cpbtn { display: block; width: 100%; text-align: left; font: inherit; font-size: .88rem; padding: 3px 8px; border-radius: 4px; cursor: pointer;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums; }
body.admin .cpbtn:hover { border-color: var(--muted); }
body.admin .cpbtn[aria-pressed="true"] { background: var(--text); color: var(--panel); border-color: var(--text); }
body.admin .cpbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* crew phones' name labels */
.leaflet-tooltip.crew-label { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: none;
  padding: 0 5px; font-size: 11px; line-height: 16px; }
.leaflet-tooltip.crew-label::before { display: none; }

/* name dialog (location sharing) */
.name-dlg { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--panel); color: var(--text);
  width: min(320px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgb(0 0 0 / .25); }
.name-dlg::backdrop { background: rgb(0 0 0 / .35); }
.name-dlg label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.name-dlg input { width: 100%; font: inherit; font-size: 16px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); }
.name-dlg .dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.name-dlg button { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.name-dlg button.primary { background: var(--text); color: var(--panel); border-color: var(--text); }
.name-dlg button.link { border: 0; background: none; color: var(--accent); padding: 6px 4px; margin-right: auto; }
.name-dlg .dlg-err { color: var(--bad); font-size: .85rem; margin: 8px 0 0; min-height: 1em; }
.name-dlg .dlg-err:empty { display: none; }
.name-dlg p { margin: 0 0 6px; }
.auth-dlg #auth-login, .auth-dlg #auth-join { display: flex; flex-direction: column; gap: 10px; }
.auth-dlg [hidden] { display: none !important; }
.auth-dlg label { margin-bottom: -4px; }
.auth-dlg button { width: 100%; padding: 9px 14px; }
.auth-dlg button.link { margin: 0; padding: 4px; }

/* admin sign-in */
body.login main, body.login { min-height: 100vh; }
body.login { display: grid; place-items: center; margin: 0; }
.loginf { display: flex; flex-direction: column; gap: 6px; width: min(300px, calc(100vw - 32px)); }
.loginf label { color: var(--muted); font-size: .85rem; }
.loginf input { margin-bottom: 6px; }
.loginf .btn { margin-top: 6px; padding: 6px 12px; }
.loginf .err:empty { display: none; }
body.admin #ac-pks { flex-direction: column; align-items: flex-start; gap: 0; }
body.admin .pk { font-size: .85rem; color: var(--muted); }
.loginf[hidden] { display: none; }
.loginf .tbtn { align-self: center; }
/* Crew photos: round thumbnails on the map; the photo itself in a popup. */
.photo-pin img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; display: block;
  box-sizing: border-box; box-shadow: 0 1px 4px rgb(0 0 0 / .45); background: var(--panel); cursor: pointer; }
.photo-dlg { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; overflow: visible; }
.photo-dlg::backdrop { background: rgb(0 0 0 / .8); }
.photo-dlg img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  border-radius: 6px; }
.photo-close { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; cursor: pointer; }
.photo-del { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); border: 0; border-radius: 17px; padding: 8px 16px;
  background: rgb(0 0 0 / .65); color: #fff; font: inherit; cursor: pointer; }
.photo-del[hidden] { display: none; }
/* Crew page dialogs: the spectator link. */
.crew-dlg { width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 64px); overflow-y: auto; }
.crew-dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.crew-dlg .dlg-close { border: 0; background: none; color: var(--muted); padding: 4px; cursor: pointer; display: grid; place-items: center; }
.crew-dlg h3 { font-size: .8rem; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.crew-dlg ul { list-style: none; margin: 0; padding: 0; }
.crew-dlg li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.crew-dlg li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-dlg li button { font: inherit; font-size: .85rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; flex: none; }
.crew-dlg li button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.link-dlg input { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 7px 9px; margin: 8px 0 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.link-dlg #link-share, .link-dlg #lt-go { display: block; width: 100%; padding: 10px 14px; font-weight: 600; }
.link-dlg #lt-go:disabled { opacity: .5; cursor: default; }

/* Drop pin (crew page, testing) */
.pin-icon .pin { width: 22px; height: 22px; margin: 0 0 0 0; background: var(--warn); border: 2px solid #fff; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg) translate(2px, -2px); box-shadow: 0 1px 4px rgb(0 0 0 / .5); }

/* Several athletes: a dropdown names the one in focus; it lists them all (crew: tick to show, tap to
   focus). Phone: over the map, top left. Desktop: the side panel's first row. */
.athletes { position: relative; flex: none; }
.athletes[hidden] { display: none; }
body > .athletes { position: fixed; z-index: 600; top: calc(env(safe-area-inset-top) + 10px); left: 10px; max-width: calc(100vw - 80px); }
#panel > .athletes { padding: 10px 12px 2px; z-index: 3; }
body.no-athlete #panel:not(:has(> .athletes)) { display: none; }
body.no-athlete #panel { height: auto !important; overflow: visible; }
body.no-athlete #panel > :not(.athletes) { display: none; }
body.no-athlete #panel > .athletes { padding-bottom: 10px; }
.ath-btn { display: flex; align-items: center; gap: 6px; max-width: 100%; box-sizing: border-box; font: inherit; font-weight: 600; font-size: .95rem;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer;
  box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
#panel .ath-btn { box-shadow: none; }
.ath-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ath-menu { position: absolute; top: calc(100% + 4px); left: 0; width: min(300px, calc(100vw - 24px)); max-height: 60vh; overflow-y: auto;
  box-sizing: border-box; padding: 6px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 18px rgb(0 0 0 / .2); }
#panel .ath-menu { left: 12px; }
.ath-menu[hidden] { display: none; }
.ath-menu li { justify-content: flex-start; }
.ath-menu li label.chk { display: flex; align-items: center; }
.ath-menu li label.chk[hidden] { display: none; }
.ath-menu .rn-focus { flex: 1; text-align: left; font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: none; color: var(--text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ath-menu .rn-focus.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ath-menu .rn-focus:disabled { opacity: .5; cursor: default; }
.ath-menu .rn-lt { white-space: nowrap; }
/* The offline banner moves down clear of the dropdown over the map. */
body.has-athletes .offline-banner { top: calc(env(safe-area-inset-top) + 52px); }
@media (min-width: 900px) { body.has-athletes .offline-banner { top: calc(env(safe-area-inset-top) + 8px); } }
.leaflet-tooltip.runner-label { font-weight: 600; }
.follow-btn[hidden] { display: none; }

/* /admin: the athlete switcher, beside the title. */
body.admin .titlebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
body.admin .titlebar h1 { margin-right: auto; }
body.admin .titlebar select { font: inherit; font-size: 1rem; padding: 4px 8px; max-width: 100%; }
body.admin .evlist li .tbtn { margin-left: 6px; }
