:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #f1efec;
  --text: #1d1b19;
  --muted: #6a645e;
  --border: #e2ded8;
  --accent: #c0392b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e6;
  --gold: #b8860b;
  --gold-soft: #fff4d6;
  --bar: #d9a49c;
  --chart-line: #c0392b;
  --tier-1: #7a1c12; --tier-1-bg: #f9d9d3;
  --tier-5: #8a3a06; --tier-5-bg: #fde5cf;
  --tier-10: #6b5300; --tier-10-bg: #fbefc4;
  --tier-25: #2f5a1d; --tier-25-bg: #e1f0d6;
  --tier-50: #24506e; --tier-50-bg: #dcebf6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151412; --surface: #1f1d1b; --surface-2: #282624; --text: #f1eee9; --muted: #a59e96; --border: #3a3633;
    --accent: #e8604f; --accent-ink: #1a0d0b; --accent-soft: #3a211d; --gold: #e6b84a; --gold-soft: #3a3120;
    --bar: #7a4a43; --chart-line: #e8604f;
    --tier-1: #ffb4a8; --tier-1-bg: #4a1f19; --tier-5: #ffc79a; --tier-5-bg: #45291a; --tier-10: #f2d77c; --tier-10-bg: #3d3519;
    --tier-25: #b5dc9c; --tier-25-bg: #24341b; --tier-50: #a9d1ef; --tier-50-bg: #1d3140;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151412; --surface: #1f1d1b; --surface-2: #282624; --text: #f1eee9; --muted: #a59e96; --border: #3a3633;
  --accent: #e8604f; --accent-ink: #1a0d0b; --accent-soft: #3a211d; --gold: #e6b84a; --gold-soft: #3a3120;
  --bar: #7a4a43; --chart-line: #e8604f;
  --tier-1: #ffb4a8; --tier-1-bg: #4a1f19; --tier-5: #ffc79a; --tier-5-bg: #45291a; --tier-10: #f2d77c; --tier-10-bg: #3d3519;
  --tier-25: #b5dc9c; --tier-25-bg: #24341b; --tier-50: #a9d1ef; --tier-50-bg: #1d3140;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { padding-top: 16px; padding-bottom: 8px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
/* the logo has a white background: on dark themes it sits on a white plate */
.logo { --logo-h: 64px; height: var(--logo-h); width: auto; display: block; border-radius: 8px; background: #fff; }
/* white-lettered logos (FireFit Europe) run to the image edge: shown 15% smaller on a black plate
   the size of the full image (aspect-ratio keeps the box; padding is 7.5% of the height per side) */
.logo[data-plate="dark"] {
  background: #000; aspect-ratio: 713 / 207; object-fit: contain;
  padding: calc(var(--logo-h) * .075);
}
/* logos with a transparent background that read on both themes (FCL) */
.logo[data-plate="none"] { background: none; border-radius: 0; }
.logo[hidden] { display: none; } /* leagues without a logo (leagues.js) */
.tagline { margin: 0; color: var(--muted); }
.theme-toggle {
  margin-left: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
/* the button shows the theme it switches to */
.theme-toggle .icon-sun, .theme-toggle.is-dark .icon-moon { display: none; }
.theme-toggle.is-dark .icon-sun { display: inline; }
/* league switch: a segmented control above the tabs */
.league-bar { display: flex; align-items: center; gap: 10px; padding-top: 4px; padding-bottom: 6px; flex-wrap: wrap; }
.league-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* .seg: the same segmented control for event days and genders */
.league-switch, .seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.league-switch button, .seg button {
  appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: .9rem; font-weight: 600;
  padding: 6px 14px; min-height: 32px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.league-switch button:hover, .seg button:hover { color: var(--text); }
.league-switch button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.league-switch button { display: inline-flex; align-items: center; gap: 7px; }
.league-icon { width: 18px; height: 18px; flex: none; }
.league-icon .leaf { fill: #d52b1e; }
/* on the selected (red) button the leaf takes the button's text colour */
.league-switch button[aria-pressed="true"] .leaf { fill: currentColor; }
.league-icon .eu-disc { fill: #003399; }
.league-icon .eu-stars { fill: #ffcc00; }
.league-icon.flag { width: 22px; }
.league-icon .us-red { fill: #b31942; }
.league-icon .us-white { fill: #fff; }
.league-icon .us-blue { fill: #0a3161; }
/* keeps the white stripes visible on light backgrounds and the red ones on the red selected button */
.league-icon .flag-edge { fill: none; stroke: rgba(0, 0, 0, .35); stroke-width: .2; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; padding-top: 16px; padding-bottom: 4px; }
.filters[hidden] { display: none; }
.filter { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.filter > label, .filter legend { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0; }
fieldset.filter { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
fieldset.filter legend { width: 100%; margin-bottom: 4px; }
.inline { display: flex; align-items: center; gap: 6px; }
.filter > label.check, .check { display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 400; }
.hint { font-size: .85rem; color: var(--muted); }
select, input {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 38px;
}
/* a select inside a heading ("Fastest [10] personal bests") */
.inline-select { min-height: 0; padding: 2px 6px; margin: 0 2px; font-weight: 600; }
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }

/* cards */
main { padding-top: 12px; padding-bottom: 32px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head p { margin: 0 0 8px; }
.card.error { border-color: var(--accent); background: var(--accent-soft); }

/* compare form */
.compare-form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .big-label { font-weight: 600; }
.field small { color: var(--muted); font-size: .8rem; }
.time-input { display: flex; align-items: center; gap: 3px; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.time-input input { font-size: inherit; text-align: center; padding: 7px 4px; }
#c-min { width: 2.2em; }
#c-sec, #c-hun { width: 2.9em; }
.time-input span { font-weight: 600; color: var(--muted); }
button.primary {
  font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 8px; padding: 9px 22px; min-height: 40px; cursor: pointer; margin-bottom: 18px;
}
button.primary:hover { filter: brightness(1.05); }

/* result hero */
.result-hero { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 20px; align-items: center; }
.eyebrow { margin: 0; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hero-time { font-size: 2.6rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero-line { margin: 0 0 10px; }
.hero-chart svg { width: 100%; height: auto; display: block; }

/* badges */
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.big { font-size: .9rem; padding: 4px 12px; }
.badge.league { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tier-1 { color: var(--tier-1); background: var(--tier-1-bg); }
.tier-5 { color: var(--tier-5); background: var(--tier-5-bg); }
.tier-10 { color: var(--tier-10); background: var(--tier-10-bg); }
.tier-25 { color: var(--tier-25); background: var(--tier-25-bg); }
.tier-50 { color: var(--tier-50); background: var(--tier-50-bg); }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.kpis > div { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.kpis dt { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpis dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpis .rec { background: var(--gold-soft); }
.kpis .rec dd { color: var(--gold); }

/* tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.stats { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stats th, .stats td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.stats thead th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.stats .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats tr.group th { background: var(--surface-2); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.stats tbody th { font-weight: 600; white-space: nowrap; }
.stats td.rec { font-weight: 700; }
.record-time { background: var(--gold-soft); color: var(--gold); padding: 2px 8px; border-radius: 6px; }
.stats tr.record-row td { background: var(--gold-soft); }
.stats tr.current th, .stats tr.current td { background: var(--accent-soft); }
.stats tr.you td { background: var(--accent-soft); color: var(--text); }
.athlete-link { font-weight: 600; text-decoration: none; }
.athlete-link:hover { text-decoration: underline; }
button.linkish { appearance: none; background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-align: left; }
button.linkish:hover { text-decoration: underline; }
button.linkish[aria-pressed="true"] { color: var(--text); }
.team-type { margin-bottom: 10px; max-width: 260px; }

/* charts */
svg .bar { fill: var(--bar); }
svg .axis { stroke: var(--border); }
svg .tick, svg .pt-label { fill: var(--muted); font-size: 11px; }
svg .cut { stroke: var(--muted); stroke-dasharray: 3 3; }
svg .cut-label { fill: var(--muted); font-size: 10px; }
svg .marker { stroke: var(--accent); stroke-width: 2.5; }
svg .marker-label { fill: var(--accent); font-size: 11px; font-weight: 700; }
svg.season { width: 100%; max-width: 620px; height: auto; display: block; }
svg .line { fill: none; stroke: var(--chart-line); stroke-width: 2; }
svg .dot { fill: var(--surface); stroke: var(--chart-line); stroke-width: 2; }

/* athlete */
#a-search { width: 100%; max-width: 480px; display: block; margin: 6px 0 4px; font-size: 1.05rem; }
.suggest { list-style: none; margin: 8px 0 0; padding: 0; max-width: 720px; }
.suggest li a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.suggest li a:hover, .suggest li a:focus-visible { background: var(--surface-2); }
.suggest li.muted { padding: 8px 10px; }
.profile-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.profile-head p { margin: 0; }
.pb { display: flex; flex-direction: column; align-items: flex-end; background: var(--gold-soft); border-radius: 8px; padding: 8px 14px; }
.pb strong { font-size: 1.8rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.stands { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.stand { display: flex; flex-direction: column; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 10px 14px; min-width: 190px; }
.stand strong { font-size: 1.5rem; }
.stand .badge { align-self: flex-start; margin-top: 4px; }

/* event results */
.event-picker { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.event-picker .grow { flex: 1 1 280px; }
.event-picker .grow select { width: 100%; max-width: 560px; }
.event-head h2 { font-size: 1.35rem; margin-top: 2px; }
.event-head > p.muted { margin: 0 0 10px; }
.event-days { margin-top: 12px; }
.event-days p { margin: 6px 0 0; }
.event-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; margin: 4px 0 6px; }
.jump { margin: 12px 0 0; }
.note { background: var(--gold-soft); border-left: 4px solid var(--gold); border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: .9rem; }
.event-link { text-decoration: none; }
.event-link:hover { text-decoration: underline; }
.stats tr.muted td { color: var(--muted); }

.site-footer { padding-bottom: 28px; }

@media (max-width: 720px) {
  h1 { font-size: 1.35rem; }
  .logo { --logo-h: 48px; }
  .header-inner { gap: 6px 14px; }
  /* phones: logo and theme button on one row, title below */
  .theme-toggle { order: 2; align-self: center; }
  .header-inner > div { order: 3; flex-basis: 100%; }
  .result-hero { grid-template-columns: 1fr; }
  .hero-time { font-size: 2.2rem; }
  .card { padding: 14px; }
  .filters { gap: 10px 16px; }
  .pb { align-items: flex-start; }
}
