/* Display face for titles and numbers (SIL OFL, see fonts/LICENSE.txt). Preloaded by the layout
   under these exact URLs; `block` so a late font never shows as a swap from the fallback face. */
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: block; src: url("/assets/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: block; src: url("/assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
/* "Weekend first" (docs/design-system.md): Retorta navy is the ground of the whole app, like a
   timing screen; yellow is "the split" and marks only what is celebrated (gold, records, this
   week). Every colour below is a role, so a theme is a different set of values for these names. */
:root {
  --ground: #090b26;
  --card: #181f57;
  --raised: #252e73;
  --line: rgb(255 255 255 / 0.1);
  --line-strong: #36418f;
  --ink: #eeeef8;
  --muted: #a4a8d4;
  --blue: #1040c0;
  --blue-hover: #1a4fe0;
  --link: #b4c4ff;
  --focus: #7f9cff;
  --yellow: #f0c020;
  --on-yellow: #0d1035;
  --silver: #c9ced8;
  --bronze: #d9965b;
  /* The medal colours as text or icon, where a fill would not do. */
  --gold-ink: #f0c020;
  --silver-ink: #c9ced8;
  --bronze-ink: #d9965b;
  /* Behind the phone's status bar and the app bar: navy in every theme (iOS writes the status bar in white). */
  --chrome: #0d1035;
  /* What lifts a card off the ground: a hairline in dark, a soft shadow in light. */
  --card-edge: inset 0 0 0 1px rgb(255 255 255 / 0.06);
  --selected: #eeeef8;
  --on-selected: #0d1035;
  --field: #090b26;
  --danger: #c8372b;
  --danger-ink: #ff9d94;
  --ok-bg: #123a2c;
  --ok-ink: #a5e8c2;
  --error-bg: #4a1b20;
  --error-ink: #ffb8b0;
  --bar: rgb(13 16 53 / 0.92);
  --shadow: 0 8px 28px rgb(0 0 0 / 0.45);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a4a8d4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --radius: 18px;
  --display: "Barlow Condensed", Inter, system-ui, sans-serif;
  color-scheme: dark;
}
/* The light theme (chosen in "Eu", see the script in the layout's head): the same roles on paper.
   The app bar stays navy, so its own roles keep their dark values. */
:root[data-theme="light"] {
  --ground: #f1f1f8;
  --card: #ffffff;
  --raised: #e7e8f6;
  --line: rgb(13 16 53 / 0.08);
  --line-strong: #cfd1ea;
  --ink: #0d1035;
  --muted: #555872;
  --blue-hover: #0b2f90;
  --link: #1040c0;
  --focus: #1040c0;
  --gold-ink: #8a6a00;
  --silver-ink: #5d6475;
  --bronze-ink: #9a5216;
  --selected: #0d1035;
  --on-selected: #ffffff;
  --field: #ffffff;
  --danger: #b42318;
  --danger-ink: #b42318;
  --ok-bg: #e9f6ee;
  --ok-ink: #14532d;
  --error-bg: #fdecea;
  --error-ink: #8a1c13;
  --bar: rgb(255 255 255 / 0.92);
  --shadow: 0 8px 28px rgb(13 16 53 / 0.18);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555872' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --card-edge: 0 1px 2px rgb(13 16 53 / 0.08);
  color-scheme: light;
}
:root[data-theme="light"] .appbar { --ink: #eeeef8; --muted: #a4a8d4; --raised: #252e73; --line-strong: #36418f; }
:root[data-theme="light"] .user-menu-list { --ink: #0d1035; --muted: #555872; --raised: #e7e8f6; --line: rgb(13 16 53 / 0.08); }
/* The theme button shows where a press leads: the sun in dark, the moon in light. */
.when-light, :root[data-theme="light"] .when-dark { display: none; }
:root[data-theme="light"] .when-light { display: contents; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  -webkit-text-size-adjust: 100%;
  /* Installed iPhone app (translucent status bar): the strip behind the status bar shows this
     colour, so it must match the app bar; iOS also blurs it into the top of the page. */
  background: var(--chrome);
  /* Without this the layout viewport stops one status-bar height short of the screen, leaving a
     gap under the fixed tab bar. */
  min-height: calc(100% + env(safe-area-inset-top));
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); }
a:hover { color: var(--ink); }
h1 { font: 700 2.6rem/0.92 var(--display); text-transform: uppercase; letter-spacing: 0.005em; margin: 0 0 0.75rem; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 0.75rem; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* The split: a slanted yellow bar that ends the big titles and cuts the brand tile. */
.split { display: inline-block; width: 0.11em; height: 0.74em; margin-left: 0.06em; background: var(--yellow); transform: skewX(-18deg); }

/* App chrome */
.env-banner { background: var(--yellow); color: var(--on-yellow); text-align: center; padding: 4px 8px; font-size: 13px; font-weight: 600; }
.appbar {
  background: var(--chrome); color: var(--ink); padding: 6px 16px; padding-top: calc(20px + env(safe-area-inset-top));
  /* iOS 26 ignores theme-color: Safari and the installed app paint the status bar area from a
     fixed/sticky element touching the top, else from the body background. */
  position: sticky; top: 0; z-index: 15;
}
.appbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; }
.topnav { display: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-tile {
  position: relative; overflow: hidden; width: 32px; height: 32px; border-radius: 9px; background: var(--yellow); color: var(--on-yellow);
  display: grid; place-items: center; font: 700 20px/1 var(--display); flex: none;
}
.brand-tile::after { content: ""; position: absolute; right: 6px; top: -8px; width: 3px; height: 48px; background: var(--on-yellow); transform: rotate(28deg); }
.brand-text { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.brand-text small { font-size: 11px; color: var(--muted); }
.brand-text strong { font: 700 22px/1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-button {
  width: 44px; height: 44px; min-height: 0; border-radius: 22px; display: grid; place-items: center;
  background: var(--raised); color: var(--ink); border: 0; padding: 0; cursor: pointer; text-decoration: none;
}
.icon-button:hover { color: var(--ink); background: var(--line-strong); }
main { width: 100%; max-width: 1212px; margin: 0 auto; padding: 8px 16px 112px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bar); border-top: 1px solid var(--raised);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] svg { color: var(--gold-ink); }

/* Page header: navigation, a small kicker, the big title, then the numbers. */
.page-head { margin: 0 0 18px; }
.page-head h1 { margin: 0; }
/* Back on the left, the other side of the same thing (public <-> admin) on the right. */
.page-nav { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 6px; }
.page-nav > .back { margin-bottom: 0; margin-right: auto; }
.page-nav > .button-small:first-child { margin-left: auto; }
.page-head-row > :first-child { flex: 1 1 auto; min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; font-weight: 600; text-decoration: none; margin-bottom: 4px; color: var(--ink); }
.eyebrow, .kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.section-title, .side-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
  margin: 22px 2px 10px;
}
.section-title:first-child { margin-top: 0; }
.page-sub { display: block; margin-top: 8px; color: var(--muted); font-weight: 500; font-size: 15px; }
/* The numbers under a title: a ruled row of big figures. Yellow (`.kpi-hot`) only for podiums and records. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 0 12px; margin: 18px 0 0; border-top: 1px solid var(--line-strong); }
.kpis > div { display: flex; flex-direction: column-reverse; padding-top: 12px; }
.kpis dd { margin: 0; font: 700 36px/1 var(--display); }
.kpis dt { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpis .kpi-hot dd { color: var(--gold-ink); }

/* Cards and lists */
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-edge); }
.card + .card { margin-top: 12px; }
.card-body { padding: 14px 16px; }
.card-link { display: block; padding: 14px 16px; color: var(--ink); text-decoration: none; }
.card-link:hover { color: var(--ink); background: var(--raised); }
.card-title { font: 700 1.5rem/0.95 var(--display); text-transform: uppercase; letter-spacing: 0.005em; margin: 0; overflow-wrap: anywhere; }
.card-meta { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 4px; }
.card-foot { display: block; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); min-height: 48px; }
.rows > li > .grow, .grow { flex: 1; min-width: 0; }
/* A race row starts with its day, like a timetable. */
.row-date { flex: none; width: 50px; font: 700 17px/1.1 var(--display); text-transform: uppercase; color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ellipsis { display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .badge-podium {
  display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 6px; border-radius: 6px; background: var(--raised); color: var(--ink); white-space: nowrap;
}
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* Forms */
.narrow { max-width: 460px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.field span { font-weight: 600; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--yellow); }
input, select, textarea {
  font: inherit; font-size: 16px; color: inherit; background: var(--field);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 48px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; }
/* Own chevron instead of each system's control. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; font-weight: 500; text-overflow: ellipsis; cursor: pointer;
  background: var(--field) var(--chevron) no-repeat right 12px center / 16px;
}
/* iOS Safari draws date/time inputs centred and wider than the card; make them plain fields. */
input[type="date"], input[type="time"] { appearance: none; -webkit-appearance: none; display: block; min-width: 0; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.code-input { font-size: 28px; font-weight: 700; letter-spacing: 0.3em; text-align: center; }
.field-error { color: var(--danger-ink); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.row .field { flex: 1 1 200px; }
.inline { display: inline; }
button, .button {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; min-height: 48px; padding: 0 18px;
  background: var(--blue); color: #fff; border: 0; border-radius: 999px;
}
button:hover, .button:hover { background: var(--blue-hover); color: #fff; }
.button-block { width: 100%; }
.button-small { min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 14px; }
a.button-small { display: inline-flex; align-items: center; font-weight: 600; text-decoration: none; }
a.button-small:not(.button-outline) { background: var(--blue); color: #fff; }
.button-outline, a.button-small.button-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--line-strong); }
.button-outline:hover { background: var(--raised); color: var(--ink); }
/* A choice that is on ("Vou · 10 km"): the split colour. */
button[aria-pressed="true"], .button[aria-pressed="true"] { background: var(--yellow); color: var(--on-yellow); border-color: var(--yellow); }
button[aria-pressed="true"]:hover, .button[aria-pressed="true"]:hover { background: var(--yellow); color: var(--on-yellow); }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger); }
p > a.button-small { margin-top: 12px; } /* a button after a card or form never touches it */
label.button { cursor: pointer; }
label.button:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Secondary actions under a form: one column of equal outline buttons. */
.actions { display: grid; gap: 10px; margin-top: 14px; }
.actions:empty { display: none; }
.actions > form { display: grid; }
.actions .button, .actions button { width: 100%; }
/* A folded confirm (e.g. "Remover utilizador") among the actions opens like the buttons next to it. */
.actions > details.tools { margin: 0; }
.actions > details.tools > summary { display: flex; justify-content: center; min-height: 48px; margin: 0; font-size: inherit; }
.actions > details.tools[open] > form { margin-top: 12px; }
/* A primary and its opposite on the same rows (Aprovar / Rejeitar marcados): stacked full width on phones, side by side on wide screens. */
.pair { display: grid; gap: 10px; }
@media (min-width: 860px) { .pair { grid-auto-flow: column; justify-content: start; } }
.stack > .card-heading { margin-bottom: 0; }
.stack > .card + .card { margin-top: 0; }
.notice { padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 500; }
.notice-ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice-error { background: var(--error-bg); color: var(--error-ink); }

/* Pills: the tabs of an admin section */
.subnav { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.subnav a, .adm-menu a {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; display: inline-flex; align-items: center;
  background: var(--card); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
}
.subnav a[aria-current="page"], .adm-menu a[aria-current="page"] { background: var(--selected); color: var(--on-selected); }

/* The account menu under the avatar (a <details>; app.js closes it on a press elsewhere). */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu-list { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px; box-shadow: var(--shadow), var(--card-edge); }
/* A question for whoever just arrived (visitors: are you one of ours?), above the tab bar. */
.sheet {
  position: fixed; left: 8px; right: 8px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 20; max-width: 460px; margin: 0 auto;
  background: var(--raised); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.sheet h2 { margin: 0 0 4px; }
.sheet p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.sheet .actions { margin: 0; }

/* Install banner */
.install-banner {
  position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 20; max-width: 520px; margin: 0 auto;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow); display: grid; gap: 8px;
}
.install-banner p { margin: 0; }
.share-icon { vertical-align: -4px; }

/* Avatars: initials (or the account photo) on a navy disc; a ring in the medal colour for a podium. */
.avatar {
  width: 60px; height: 60px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--line-strong); color: var(--ink); font-weight: 600; font-size: 20px;
}
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.avatar-small { width: 34px; height: 34px; font-size: 12px; }
.avatar.podium-1 { box-shadow: 0 0 0 2px var(--yellow); }
.avatar.podium-2 { box-shadow: 0 0 0 2px var(--silver); }
.avatar.podium-3 { box-shadow: 0 0 0 2px var(--bronze); }
.avatar-link { border-radius: 50%; text-decoration: none; display: block; }
/* In the app bar the avatar is one more round button: the size and ground of `.icon-button`. */
.avatar-link .avatar { width: 44px; height: 44px; font-size: 14px; background: var(--raised); }
.avatar-link[aria-current="page"] .avatar { box-shadow: 0 0 0 2px var(--yellow); }

/* Page-specific bits */
.login-join { margin-top: 14px; margin-bottom: 0; }
.card-heading { margin-bottom: 12px; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile h1 { margin: 0; font-size: 2rem; }
.profile p { margin: 4px 0 0; }
.menu-row {
  width: 100%; min-height: 52px; justify-content: flex-start; border-radius: 0; background: transparent; color: var(--ink);
  font-weight: 500; padding: 0 16px; border-top: 1px solid var(--line);
}
.menu-row:hover { background: var(--raised); color: var(--ink); }
a.menu-row { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.menu-row svg { margin-left: auto; color: var(--muted); }
.card > .menu-row:first-child, .card > form:first-child .menu-row { border-top: 0; }
.empty-state { text-align: center; padding: 32px 20px; display: flex; flex-direction: column; align-items: center; }
.empty-state h1 { font-size: 1.6rem; margin: 12px 0 6px; }
.empty-state p { margin: 0; max-width: 34ch; }
.empty-icon { width: 64px; height: 64px; border-radius: 32px; display: grid; place-items: center; background: var(--raised); color: var(--gold-ink); }

/* Admin lists */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.cards > .card { padding: 14px 16px; margin: 0; }
.cards > .card + .card { margin-top: 0; }
.list { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-edge); }
.list > li { padding: 12px 16px; border-top: 1px solid var(--line); min-height: 48px; display: flex; align-items: center; overflow-wrap: anywhere; }
.list > li:first-child { border-top: 0; }
/* Row titles (a plain link or <strong>) are names in ink, the same in every list; buttons keep their own colours. */
.rows a:not([class*="button"]), .list a:not([class]), .cards > .card a:not([class]) { color: var(--ink); font-weight: 600; text-decoration: none; }
.rows a:not([class*="button"]):hover, .list a:not([class]):hover, .cards > .card a:not([class]):hover { color: var(--link); }
section > h2 { margin: 20px 4px 8px; }
.member-head { display: flex; flex-direction: column; min-width: 0; margin-bottom: 8px; }
.cards .row { margin-top: 8px; }
.cards form.inline { display: inline-flex; }

.sr-only, .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.search-form { margin-top: 12px; flex-wrap: nowrap; max-width: 560px; }
.search-form .field { flex: 1; margin: 0; }
.card-body.chips { padding-top: 0; }
.card-actions { padding-top: 0; }

/* Busy feedback (see app.js): top progress bar and a spinner on the button that was pressed */
.progress-bar { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; height: 3px; z-index: 100; overflow: hidden; background: transparent; }
.progress-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--yellow);
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide { to { left: 100%; } }
button.is-loading { opacity: 0.85; cursor: progress; }
button.is-loading::before {
  content: ""; width: 1em; height: 1em; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .progress-bar::before { animation: none; left: 0; width: 100%; opacity: 0.8; }
  button.is-loading::before { animation-duration: 2s; }
}

/* Result collection */
.spinner {
  display: inline-block; width: 0.9em; height: 0.9em; margin-right: 0.4em; vertical-align: -0.1em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.list .job { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.list .job > :first-child { flex: 1 1 14rem; min-width: 0; }
.list .job > .check input { flex: none; }
.edition-meta { display: block; }
.picker summary { cursor: pointer; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.25rem 1rem; max-height: 16rem; overflow-y: auto; }
/* Race logos are drawn for white paper: they sit on a white tile. */
.race-logo { display: block; max-height: 72px; max-width: 160px; object-fit: contain; margin-bottom: 12px; padding: 6px; border-radius: 10px; background: #fff; }

/* The weeks: the team's calendar as one row. Past weeks hold results, weeks ahead hold who is going. */
.weeks { display: flex; gap: 6px; margin: 0 0 14px; }
.weeks a { flex: 1 1 0; min-width: 0; min-height: 52px; padding: 8px 4px 9px; text-align: center; box-shadow: var(--card-edge); border-radius: 14px; background: var(--card); color: var(--ink); text-decoration: none; }
.weeks a b { display: block; font: 700 17px/1.15 var(--display); text-transform: uppercase; white-space: nowrap; }
.weeks a small { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.weeks a[aria-current="page"] { background: var(--selected); color: var(--on-selected); box-shadow: none; }
.weeks a[aria-current="page"] small { color: inherit; opacity: 0.7; }
.weeks .week-now:not([aria-current]) small { color: var(--gold-ink); }
/* The ends of the row lead out of the weeks: the results archive behind, the races ahead. */
.weeks .week-more { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.weeks .week-more b { display: grid; place-items: center; height: 20px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); margin-right: 5px; }

/* The bulletin: what the team did in a week. */
.hero { margin-bottom: 20px; }
.hero h1 { font-size: 3.4rem; line-height: 0.88; margin: 0; }
.reel { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px 6px; scrollbar-width: none; list-style: none; }
.reel::-webkit-scrollbar { display: none; }
/* Every card of the row is as tall as the tallest. */
.reel > li { display: flex; }
/* A highlight: one thing to celebrate, shaped like a story card. Gold for podiums, blue for records. */
.highlight {
  position: relative; overflow: hidden; flex: none; width: 150px; padding: 12px 14px; border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 10px; background: var(--card); color: var(--ink); text-decoration: none;
}
.highlight:hover { color: var(--ink); }
.highlight::after { content: ""; position: absolute; right: -18px; top: -10px; width: 26px; height: 120px; background: currentColor; opacity: 0.12; transform: rotate(28deg); }
.highlight-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.highlight-big { display: block; font: 700 32px/0.9 var(--display); }
.highlight-who { display: block; font: 700 18px/1 var(--display); text-transform: uppercase; margin-top: 4px; }
.highlight-what { display: block; font-size: 12px; font-weight: 500; line-height: 1.3; margin-top: 4px; opacity: 0.75; }
.highlight-gold, .highlight-gold:hover { background: var(--yellow); color: var(--on-yellow); }
.highlight-silver, .highlight-silver:hover { background: var(--silver); color: var(--on-yellow); }
.highlight-bronze, .highlight-bronze:hover { background: var(--bronze); color: var(--on-yellow); }
.highlight-record, .highlight-record:hover { background: var(--blue); color: #fff; }

/* The board: a race's results as the team's own leaderboard. */
.boards { display: grid; gap: 14px; align-items: start; }
.boards > .card + .card { margin-top: 0; }
.board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px 12px; color: var(--ink); text-decoration: none; }
a.board-head:hover { color: var(--ink); background: var(--raised); }
.board-head > :first-child { flex: 1; min-width: 0; }
.team-place { flex: none; min-width: 52px; text-align: center; background: var(--ground); border-radius: 12px; padding: 6px 9px 5px; }
.team-place strong { display: block; font: 700 22px/1 var(--display); }
.team-place.podium-1 strong { color: var(--gold-ink); }
.team-place.podium-2 strong { color: var(--silver-ink); }
.team-place.podium-3 strong { color: var(--bronze-ink); }
.team-place small { display: block; max-width: 84px; font-size: 9px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results { list-style: none; margin: 0; padding: 0; }
.result { display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--line); min-height: 56px; }
.results-plain .result { grid-template-columns: minmax(0, 1fr) auto; }
.result-pos { font: 700 17px/1 var(--display); color: var(--muted); text-align: center; }
.result-name { display: block; font-weight: 600; font-size: 15px; line-height: 1.2; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.result-name:hover { color: var(--link); }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; margin-top: 3px; font-size: 12px; font-weight: 500; color: var(--muted); }
.result-meta > span:empty { display: none; }
.result-gap { height: 3px; margin-top: 6px; border-radius: 2px; background: var(--line-strong); }
.result-gap i { display: block; height: 100%; border-radius: 2px; background: var(--muted); }
.result-time { text-align: right; white-space: nowrap; }
.result-time strong { display: block; font: 700 24px/1 var(--display); }
.result-time small { display: block; margin-top: 2px; font-size: 11px; font-weight: 500; color: var(--muted); }
.result-time.muted { font-size: 12px; font-weight: 500; }
/* Medals: gold (Retorta yellow), silver, bronze. A record is the split colour too. */
.badge-podium, .chip-record { background: var(--yellow); color: var(--on-yellow); }
.badge-podium.podium-2 { background: var(--silver); }
.badge-podium.podium-3 { background: var(--bronze); }
.course-head { padding: 10px 16px 6px; border-top: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.standings-head { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }
.standings-list { list-style: none; margin: 0; padding: 0; }
.standing { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--line); }
.standing-own { background: var(--raised); font-weight: 700; }
.standing-pos { width: 2.5em; flex: none; }
.standing-total { white-space: nowrap; }
.standings-scorers { padding-top: 8px; margin: 0; border-top: 1px solid var(--line); }
.boards > .pager, .boards > .empty { grid-column: 1 / -1; }
.page-foot { margin-top: 20px; }
.calendar-list { max-width: 760px; }
.pager { display: flex; justify-content: space-between; gap: 8px; }

/* The start grid: a race ahead, one lane per distance with who is going and "Vou" in one tap. */
.grid-card { padding: 16px; }
.when { display: flex; align-items: center; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.when-soon { color: var(--gold-ink); }
.grid-card .card-title { font-size: 1.9rem; }
.grid-card .card-title a { color: var(--ink); text-decoration: none; }
.lanes { list-style: none; margin: 14px 0 0; padding: 0; }
.lane { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 0; border-top: 1px solid var(--line); }
.lane:last-child { padding-bottom: 0; }
.lane-distance { flex: none; width: 76px; font: 700 20px/1 var(--display); text-transform: uppercase; }
.lane-distance small { display: block; margin-top: 3px; font: 500 11px/1.2 Inter, system-ui, sans-serif; text-transform: none; color: var(--muted); }
.lane-who { flex: 1; min-width: 0; display: flex; }
.lane-who .avatar { width: 30px; height: 30px; font-size: 11px; margin-left: -8px; border: 2px solid var(--card); }
.lane-who .avatar:first-child { margin-left: 0; }
.lane-who .avatar-more { background: var(--ground); color: var(--muted); }
.lane form { flex: none; margin: 0; }

/* The athlete card: who, their best marks, how the year is going. */
.athlete-hero { display: flex; align-items: flex-end; gap: 16px; }
.athlete-hero h1 { font-size: 2.6rem; }
.athlete-photo {
  position: relative; overflow: hidden; flex: none; width: 104px; height: 128px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--line-strong), var(--raised)); font: 700 44px/1 var(--display);
}
.athlete-photo::after { content: ""; position: absolute; right: 12px; top: -20px; width: 8px; height: 180px; background: var(--yellow); transform: rotate(28deg); }
.marks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mark { box-shadow: var(--card-edge); background: var(--card); border-radius: 16px; padding: 12px 14px; min-width: 0; color: var(--ink); text-decoration: none; }
.mark small { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.mark strong { display: block; margin-top: 6px; font: 700 34px/1 var(--display); }
.mark .card-meta { margin-top: 6px; }
.mark-new { box-shadow: inset 0 0 0 2px var(--yellow); }
.mark-new small { color: var(--gold-ink); }
.athlete-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.athlete-grid > .card { margin: 0; }
.athlete-grid a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); font-weight: 600; text-decoration: none; }
.athlete-grid a:hover { background: var(--raised); }

/* Filters */
/* Filters sit under the page title: one row of round outline controls, no card around them. */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; max-width: 560px; }
.filters > a.button-small { justify-content: center; }
.filters select, .filters input[type="search"] { font-size: 14px; }
.filters .field-compact { margin: 0; }
.filters select, .filters input[type="search"] { min-height: 40px; padding-top: 6px; padding-bottom: 6px; border-width: 1.5px; border-radius: 20px; background-color: transparent; font-weight: 600; }

/* Light theme in the installed iPhone app (iOS 26): the status bar area is a soft blend of the body
   background, not of the sticky app bar like in Safari, so the body is navy and the page area paints the paper. */
@media (display-mode: standalone) {
  :root[data-theme="light"] body { background: var(--chrome); display: flex; flex-direction: column; }
  :root[data-theme="light"] main { flex: 1; background: var(--ground); box-shadow: 0 0 0 100vmax var(--ground); clip-path: inset(0 -100vmax); }
}

/* Page changes: the browser keeps the old page on screen and cross-fades to the new one, while the
   app bar and tab bar stay put, so moving between pages feels like one app instead of a reload. */
@view-transition {
  navigation: auto;
}
.appbar {
  view-transition-name: appbar;
}
.tabbar {
  view-transition-name: tabbar;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 150ms;
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
/* Two columns from 860px: content and a side panel; on phones one column in source order. */
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.cols > * { min-width: 0; }
.cols > .card { margin-top: 0; }
.cols + p { margin-top: 16px; }
.card > .side-title { margin: 0; padding: 14px 16px 8px; }
.cols-main > h2:not([class]) { margin: 20px 4px 8px; }
.cols-main > h2:first-child { margin-top: 0; }

/* Calendar: each race is a card with the "Vou" button on its right; months are plain headings
   between the cards (cards in a month sit closer, the month is the bigger break). */
h2.month-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 22px 2px 0; font: 700 1.25rem/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); }
h2.month-title:first-child { margin-top: 0; }
.month-title small { font: 600 13px/1.2 Inter, system-ui, sans-serif; text-transform: none; letter-spacing: 0; }
.stack > .month-title + .race-card, .stack > .calendar-race + .calendar-race { margin-top: 0; }
.race-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.race-head > a { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.race-head > a:hover .card-title { color: var(--link); }
.race-head > div:first-child { flex: 1; min-width: 0; }
.race-mark { flex: none; margin: 0; }
.race-mark button, label.race-mark { white-space: nowrap; gap: 4px; }
label.race-mark { display: inline-flex; align-items: center; cursor: pointer; font-weight: 600; }
.race-pick { display: none; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.race-pick > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.pick-toggle:checked ~ .race-pick { display: flex; }
.pick-toggle:checked + .race-head label.race-mark { background: var(--raised); }
.pick-toggle:focus-visible + .race-head label.race-mark { outline: 2px solid var(--focus); outline-offset: 2px; }
.race-section > .race-head { border-bottom: 1px solid var(--line); }

/* Admin pages */
.page-head .subnav { margin-bottom: 14px; }
.admin-narrow > :not(.adm-menu) { max-width: 560px; }
.admin-narrow > form:not([class]) { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.admin-narrow > form:not([class]) > .field { width: 100%; }
/* Four sections (pills on a phone, a side menu from 860px), a to-do home, one collect box. */
.adm-menu { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.adm-menu a { flex-direction: column; align-items: flex-start; justify-content: center; min-height: 44px; border-radius: 22px; }
.adm-menu small { display: none; }
.adm-sub { margin: -6px 0 14px; }
.adm-empty { margin-top: 16px; }
.collect > form > label { display: block; font-weight: 700; margin-bottom: 8px; }
.collect-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.collect-row input { flex: 1 1 0; min-width: 0; min-height: 48px; }
.warn, .ok { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--error-bg); color: var(--error-ink); }
.ok { background: var(--ok-bg); color: var(--ok-ink); }
/* Review: one result per row, the same cells aligned in columns on wide screens. */
.review-sub { display: block; font-weight: 400; }
.review-cells { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.review-cells > span:empty, .review-warn:empty { display: none; }
.review-warn { display: flex; flex-wrap: wrap; gap: 4px; }
.list .row-warn { background: rgb(200 55 43 / 0.12); }
fieldset.field { border: 0; padding: 0; margin: 0 0 12px; }
fieldset.field legend { padding: 0; font-weight: 600; }

/* Admin athletes */
.athletes-form { margin-top: 16px; }
.bulk-help { margin: 8px 4px; }
/* Sticks above the phone tab bar while the list scrolls. */
.bulk-bar { position: sticky; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 5; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 8px 4px; background: var(--ground); }
.tools .card { margin-bottom: 8px; }
.tools { margin-top: 20px; }
.tools summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; margin-bottom: 10px; border: 1.5px solid var(--line-strong); border-radius: 999px; color: var(--ink); font-size: 14px; font-weight: 600; list-style: none; }
.tools summary::-webkit-details-marker { display: none; }
.tool { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 10px; }
.athletes-form .list > li { padding: 2px 16px; }

@media (min-width: 860px) {
  .tabbar { display: none; }
  .appbar { padding-top: env(safe-area-inset-top); padding-bottom: 0; border-bottom: 1px solid var(--raised); }
  .appbar-inner { justify-content: flex-start; gap: 28px; min-height: 64px; }
  .topnav { display: flex; flex: 1; gap: 6px; }
  .topnav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 10px; color: var(--muted); font-size: 15px; font-weight: 600; text-decoration: none; }
  .topnav a:hover { color: var(--ink); }
  .topnav a[aria-current="page"] { background: var(--raised); color: var(--ink); }
  main { padding: 26px 16px 48px; }
  h1 { font-size: 3.4rem; }
  .hero h1 { font-size: 5.5rem; }
  .athlete-hero h1 { font-size: 4rem; }
  .page-head { margin-bottom: 24px; }
  .page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 48px; }
  .page-head-row > .kpis { flex: 0 1 420px; }
  .kpis dd { font-size: 52px; }
  .weeks { margin: 0 0 22px; max-width: 560px; }
  .reel { margin: 0 0 8px; padding: 0 0 6px; }
  .highlight { width: 200px; }
  .install-banner { bottom: 16px; }
  .sheet { left: auto; right: 24px; bottom: 24px; width: 400px; }
  .narrow { margin-left: auto; margin-right: auto; }
  /* The last row takes the spare height, so side cards stay packed at the top. */
  .cols { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: repeat(3, auto) 1fr; gap: 28px; }
  .cols > .cols-main { grid-column: 1; grid-row: 1 / span 4; }
  .cols > .cols-side { grid-column: 2; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
  .marks { grid-template-columns: repeat(4, 1fr); }
  section:has(> .adm-menu) { position: relative; padding-left: 238px; min-height: 300px; }
  .adm-menu { position: absolute; left: 0; top: 0; width: 210px; flex-direction: column; gap: 2px; overflow: visible; }
  .adm-menu a { min-height: 52px; padding: 6px 12px; border-radius: 12px; background: none; font-size: 15px; }
  .adm-menu a:hover { background: var(--card); }
  .adm-menu small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
  .adm-menu a[aria-current="page"] small { color: inherit; opacity: 0.7; }
  .list .review-row { display: grid; grid-template-columns: minmax(0, 1fr) 290px 150px auto; gap: 12px; }
  .review-cells { display: grid; grid-template-columns: 90px 120px 56px; }
  .review-cells > span:empty, .review-warn:empty { display: block; }
  .review-row > .row { flex-wrap: nowrap; }
}
/* Two boards side by side once each still fits a full row. */
@media (min-width: 1100px) { .boards-wide { grid-template-columns: 1fr 1fr; } }
