:root {
    color-scheme: light;
    --ink: #15354d;
    --accent: #98243c;
    --border: #d9e3eb;
    --muted: #506478;
    --paper: #fff;
    font: 16px/1.55 system-ui, sans-serif;
    color: var(--ink);
    background: #f3f7fa;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: #194664; text-underline-offset: .2em; }
.top { background: #194664; border-bottom: 4px solid var(--accent); }
.top nav { max-width: 1440px; margin: auto; padding: .85rem 1.25rem; display: flex; align-items: center; gap: 1.1rem 1.65rem; flex-wrap: wrap; }
.top a { color: white; text-decoration: none; }
.top a:hover { text-decoration: underline; }
.brand { font-size: 1.18rem; font-weight: 850; letter-spacing: .07em; margin-right: auto; }
.brand span { color: #ffd262; }
main, footer { max-width: 1440px; padding: 1.5rem clamp(.85rem, 3vw, 2.5rem); margin: auto; }
footer { color: var(--muted); }
.eyebrow { font-size: .76rem; font-weight: 800; letter-spacing: .14em; color: var(--accent); margin: .45rem 0; }
h1, h2, p { margin: 0 0 .75rem; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { font-size: 1.25rem; line-height: 1.25; }
.event-title { margin-top: 1rem; font-size: 1.5rem; }
.lead { color: var(--muted); }
.muted, small { color: var(--muted); font-size: .86rem; }
.actions, .filters { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem 1rem; margin: 0 0 .9rem; }
.actions a { padding: .25rem 0; }
.panel { background: var(--paper); padding: clamp(.85rem, 2vw, 1.35rem); border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.results-layout, .registration-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 1rem; align-items: start; }
.registration-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.results-layout > :first-child, .registration-layout > :first-child { min-width: 0; }
.event-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: .65rem; margin: 1rem 0; }
.event { display: grid; align-content: start; gap: .2rem; padding: .85rem; background: var(--paper); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.event:hover { border-color: #194664; text-decoration: underline; }
.event span { color: var(--muted); }
label { display: grid; gap: .25rem; font-weight: 650; font-size: .9rem; }
input, select, button { font: inherit; color: inherit; }
input:not([type=radio]):not([type=checkbox]), select { width: 100%; min-height: 2.65rem; border: 1px solid #a9bac8; border-radius: 7px; padding: .4rem .55rem; background: white; }
select { max-width: min(100%, 28rem); }
input[type=radio], input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
button { cursor: pointer; min-height: 2.65rem; padding: .4rem .85rem; border: 1px solid transparent; border-radius: 7px; background: var(--accent); color: white; font-weight: 700; }
button:hover { filter: brightness(.9); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: #f5f9fc; color: var(--ink); border-color: #a9bac8; }
button.cancel { color: var(--accent); }
:focus-visible { outline: 3px solid #9b5c00; outline-offset: 2px; }
.scroll { overflow-x: auto; }
#runner-rows td:nth-child(5), #runner-rows td:nth-child(6) { white-space: nowrap; }
#result-view .panel:first-child .scroll { max-height: 70vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem; border-bottom: 1px solid var(--border); }
thead th { background: #eaf2f8; white-space: nowrap; position: sticky; top: 0; }
td small { display: block; }
.compact-only { display: none; }
tr.selected { background: #fff3d6; }
.splits td, .splits tbody th { white-space: nowrap; }
.splits thead th { white-space: normal; overflow-wrap: anywhere; }
.splits th:first-child { position: sticky; left: 0; background: #eaf2f8; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.legend li { border-left: 4px solid; background: #f4f7fa; padding: .25rem .5rem; }
.chart { margin: .75rem 0; font-size: .86rem; }
.chart svg { display: block; width: 100%; max-width: 420px; font-size: 11px; fill: var(--ink); }
.notice, .success, .error, .deadline { border-radius: 8px; padding: .65rem .85rem; margin-bottom: .85rem; }
.notice { background: #e9f0f6; }
.deadline { display: inline-block; background: #fff0cb; color: #643b0a; font-weight: 650; }
.success { background: #e6f4e8; color: #174f2e; }
.error { background: #fde9ed; color: #80152d; }
.participant { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 .75rem; padding: .85rem; min-width: 0; }
legend, summary { font-weight: 750; }
summary { cursor: pointer; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.distances { padding: 0; border: 0; margin: .75rem 0; min-width: 0; }
.distances label { display: flex; align-items: center; padding: .45rem; border: 1px solid var(--border); border-radius: 7px; }
.distances label:has(:checked) { border-color: var(--accent); background: #faedf0; }
.block-field, .manage, .remove-participant { margin: .75rem 0; }
.manage button { margin-left: .45rem; }
.edit-entry { margin-bottom: 0; }
.passkey { margin-bottom: 1rem; }
.passkey button { margin: .25rem .25rem .25rem 0; }
.passkey p { margin: .35rem 0 0; }
.count { font-size: .8em; background: #eaf2f8; padding: .15em .55em; border-radius: 1em; }
.entries { list-style: none; padding: 0; margin: 0; }
.entries li { display: flex; justify-content: space-between; gap: .7rem; padding: .55rem .25rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.entries strong { color: var(--accent); }
@media (max-width: 960px) {
    .results-layout { grid-template-columns: minmax(0, 1fr); }
    #result-view .panel:first-child .scroll { max-height: 45vh; }
}
@media (max-width: 700px) {
    .registration-layout { grid-template-columns: minmax(0, 1fr); }
    .runner-table .compact-only { display: block; }
    .runner-table .wide-col { display: none; }
    .runner-table .pick-header span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .runner-table :is(th, td) { padding: .45rem .3rem; }
    #runner-rows td:nth-child(5) { white-space: normal; overflow-wrap: anywhere; max-width: 7rem; }

    .top nav { gap: .4rem 1rem; }
    .brand { flex-basis: 100%; }
}

.winter-round { margin-bottom: .9rem; border-top: 3px solid var(--accent); }
.winter-round .event-title { margin: .55rem 0 .3rem; }
.winter-round .lead { margin-bottom: .55rem; }
.round-picker { display: grid; gap: .35rem; margin-bottom: 0; }
.round-picker select { max-width: none; }
.round-picker label, .public-filters label { min-width: 0; }
.winter-page :is(input, select) { min-width: 0; }
.passkey-login { display: grid; justify-items: start; gap: .35rem; }
.passkey p + .passkey-login { margin-top: .65rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.passkey form { align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.passkey details ul { margin: .35rem 0 .65rem; padding-left: 1.25rem; }
.winter-page .distances label { min-height: 44px; }
.winter-page .distances input { flex: none; margin: 0; }
.winter-page .manage p { margin-top: .55rem; }

@media (max-width: 700px) {
    .top nav { padding: .6rem .85rem; }
    .top nav > a:not(.brand) { padding-block: .25rem; font-size: .9rem; }
    .winter-page .panel { padding: .85rem; }
    .winter-round .eyebrow { margin-top: 0; }
    .winter-round .deadline { padding: .4rem .6rem; font-size: .875rem; }
    .winter-page .round-picker { gap: .4rem; }
    .winter-page select { max-width: none; }
    .winter-page :is(input:not([type=radio]):not([type=checkbox]), select) { min-height: 44px; font-size: 1rem; }
    .winter-page button { min-height: 44px; }
    .winter-page :is(#registration-form > button, .passkey [data-passkey=enroll]) { width: 100%; }
    .winter-page .participant { padding: .6rem; }
    .winter-page .edit-entry { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .winter-page .edit-entry label { grid-column: 1 / -1; }
    .winter-page .edit-entry button { padding-inline: .35rem; font-size: .875rem; }
    .winter-page .public-filters { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: .5rem; }
    .winter-page .manage button { margin: .4rem 0 0; }
    .winter-page .manage a { display: block; }
}

@media (max-width: 700px) {
    .winter-page .passkey-login button { width: 100%; margin-right: 0; }
}

.winter-page .participant .fields > label { min-width: 0; }
.winter-page input[type=date] { max-width: 100%; }

@media (max-width: 700px) {
    .winter-page .participant details .fields { grid-template-columns: minmax(0, 1fr); }
}

/* Gaujas Ziema registration */
.winter-page { max-width: 1160px; margin-inline: auto; }
.winter-page .winter-round { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: end; gap: 1rem 2rem; padding: clamp(1rem, 3vw, 2rem); background: linear-gradient(125deg, #fff 40%, #eaf4f9); }
.winter-round .round-picker { align-items: end; }
.winter-round .deadline { margin-bottom: 0; }
.winter-jumps { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .8rem; }
.winter-jumps a { display: inline-flex; align-items: center; min-height: 42px; gap: .4rem; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .8rem; background: white; font-weight: 700; text-decoration: none; }
.winter-jumps a:hover { border-color: #194664; }
.winter-jumps span { color: var(--muted); font-size: .85em; }
#winter-entry, #winter-roster { scroll-margin-top: .75rem; }
.winter-page .registration-layout { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.winter-page .passkey { background: #edf5fa; }
.winter-page .participant { background: #f8fbfd; }
.winter-page .participant legend { padding-inline: .3rem; }
.winter-page .distances label { background: white; gap: .55rem; }
.winter-page .distances label:has(:checked) { background: #faedf0; }
.winter-page .distances label small { display: block; }
.winter-page .participant details { border-top: 1px solid var(--border); padding-top: .5rem; }
.winter-page .participant details .fields { margin-top: .55rem; }
.winter-page .entry-submit { border-top: 1px solid var(--border); padding-top: .75rem; }
.winter-page .ticket-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .65rem; justify-content: space-between; }
.ticket-status { font-size: .83rem; border: 1px solid currentColor; border-radius: 20px; padding: .12rem .5rem; }
.winter-ticket .edit-entry { margin-top: .65rem; }
.winter-roster .entries strong { background: #faedf0; border-radius: 5px; padding: .05rem .4rem; }

@media (max-width: 700px) {
    .winter-page :is(.winter-round, .registration-layout) { grid-template-columns: minmax(0, 1fr); }
    .winter-page .winter-round { gap: .7rem; }
    .winter-page .entry-submit button { width: 100%; }
    .winter-page .participant > .fields { grid-template-columns: minmax(0, 1fr); }
}

.split-chart-tools { align-items: end; }
.split-chart-tools a { padding-block: .55rem; }
.leg-chart { margin: .75rem 0 1.25rem; font-size: .9rem; }
.leg-chart figcaption { font-weight: 750; margin-bottom: .2rem; }
.leg-highlights { padding: .55rem .7rem; margin: 0 0 .75rem; list-style: none; background: #edf5fa; border-radius: 7px; font-size: .82rem; font-weight: 650; }
.leg-axis { display: grid; grid-template-columns: 1fr auto 1fr; gap: .15rem; margin: 0 4rem .3rem 5.25rem; font-size: .75rem; color: var(--muted); }
.leg-axis span:last-child { text-align: end; }
.leg-list { padding: 0; margin: 0; list-style: none; border-top: 1px solid var(--border); }
.leg-row { display: grid; grid-template-columns: 4.9rem minmax(0, 1fr); gap: .35rem; align-items: center; border-bottom: 1px solid var(--border); padding: .35rem 0; }
.leg-row:nth-child(even) { background: #f7fafc; }
.leg-name { font-size: .8rem; overflow-wrap: anywhere; }
.leg-track { display: grid; grid-template-columns: minmax(0, 1fr) 3.7rem; gap: .3rem; align-items: center; min-height: 1.4rem; }
.leg-plot { position: relative; height: 1.4rem; }
.leg-plot::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 50%; border-inline-start: 1px solid #899ba9; }
.leg-bar { position: absolute; min-width: 2px; inset-block: .31rem; border-radius: 3px; }
.leg-value { border-inline-end: 3px solid; padding-inline-end: .25rem; text-align: end; font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 390px) {
    .leg-axis { margin-inline-start: 4rem; }
    .leg-row { grid-template-columns: 3.65rem minmax(0, 1fr); }
}

.public-filter-feedback { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; margin-bottom: .6rem; }
.public-filter-feedback p { margin: 0 auto 0 0; }
.winter-page .distances > p { margin: .15rem 0 .5rem; }
.winter-entry .passkey { margin-top: 1rem; }
.winter-entry .manage { margin-bottom: 1.15rem; }

.leg-progress { grid-column: 1 / -1; text-align: end; font-size: .78rem; font-variant-numeric: tabular-nums; }
.leg-track + .leg-track { margin-top: .25rem; }
.checkpoint-times { display: grid; gap: .3rem; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.checkpoint-times li { border-inline-start: 3px solid; background: #f4f7fa; padding: .25rem .5rem; }
.checkpoint-hit { fill: transparent; cursor: pointer; }
.checkpoint-hit:hover { fill: #19466412; }

.leg-frame { position: relative; }
.leg-trend { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.leg-trend path { fill: none; stroke-width: 2; stroke-opacity: .52; stroke-dasharray: 4 3; stroke-linejoin: round; }
.leg-bar { z-index: 1; }
.leg-trend-key::before { content: ''; display: inline-block; width: 1.5em; margin-inline-end: .45em; border-top: 2px dashed currentColor; vertical-align: .2em; }

.passkey-heading { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-bottom: .5rem; }
.passkey-heading h2 { margin: 0; font-size: 1.07rem; }
.passkey-heading-text { min-width: 0; }
.passkey-heading form, .passkey-heading button { margin: 0; }
.passkey-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 11px; background: #194664; color: white; }
.passkey-icon-open { background: #176441; }
.passkey-icon svg { width: 1.4rem; height: 1.4rem; }
.passkey-connected { color: #176441; font-size: .85rem; }
.passkey-connected::before { content: ''; display: inline-block; width: .45rem; height: .45rem; margin-inline-end: .4rem; border-radius: 50%; background: currentColor; vertical-align: .1em; }
.passkey-waiting #passkey-status::before { content: ''; display: inline-block; width: .8em; height: .8em; margin-inline-end: .45em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
    .passkey-waiting #passkey-status::before { animation: passkey-spin .85s linear infinite; }
}
@keyframes passkey-spin { to { transform: rotate(1turn); } }

.passkey-settings { margin-top: .55rem; color: var(--muted); font-size: .85rem; }
.passkey-settings summary { width: fit-content; padding-block: .35rem; font-weight: 600; }
button.secondary.passkey-logout { display: inline-grid; place-items: center; width: 44px; min-height: 44px; padding: 0; background: transparent; border-color: transparent; }
button.secondary.passkey-logout:hover { background: #dfeef6; border-color: #bfd4e0; }
.passkey-logout svg { width: 1.25rem; height: 1.25rem; }

.comparison-actions { gap: .45rem; margin-bottom: .55rem; }
.comparison-actions button { font-size: .85rem; }
.comparison-legend { margin: .6rem 0; }
.comparison-legend .legend, .checkpoint-times { max-height: 13rem; overflow-y: auto; }
.splits thead th:not(:first-child) { min-width: 5.5rem; }
