:root {
  --fg: #1b1f24;
  --bg: #ffffff;
  --accent: #c2410c;
  --muted: #5b6470;
}
@media (prefers-color-scheme: dark) {
  :root { --fg: #e6e8eb; --bg: #121417; --accent: #fb923c; --muted: #9aa3ad; }
}
html { font-size: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}
.site-header { padding: 0.75rem 1rem; border-bottom: 0.0625rem solid var(--muted); }
.site-header a { color: var(--accent); font-weight: 700; text-decoration: none; }
main { max-width: 48rem; margin: 0 auto; padding: 1rem; }
.site-header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.muted { color: var(--muted); }
.error { color: #b91c1c; font-weight: 600; }
.notice { padding: 0.5rem 0.75rem; border-left: 0.25rem solid var(--accent); word-break: break-all; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; max-width: 32rem; }
form.inline { display: inline; }
button, .button {
  font: inherit; padding: 0.4rem 0.9rem; border-radius: 0.375rem; border: 0.0625rem solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-block;
}
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
input, select { font: inherit; padding: 0.35rem; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 0.0625rem solid color-mix(in srgb, var(--muted) 40%, transparent); vertical-align: top; }
.tabs { display: flex; gap: 1rem; border-bottom: 0.0625rem solid var(--muted); margin-bottom: 1rem; }
.tabs a { padding: 0.4rem 0; color: var(--fg); text-decoration: none; }
.tabs a[aria-current="page"] { border-bottom: 0.1875rem solid var(--accent); font-weight: 600; }
fieldset { border: 0.0625rem solid color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 0.5rem; margin: 0 0 1rem; padding: 0.5rem 1rem; }
legend { font-weight: 700; padding: 0 0.25rem; }
.setting { display: grid; gap: 0.25rem 1rem; grid-template-columns: 1fr; padding: 0.6rem 0; border-bottom: 0.0625rem dashed color-mix(in srgb, var(--muted) 30%, transparent); }
.setting:last-child { border-bottom: none; }
.setting-head label { font-weight: 600; }
.setting .help { margin: 0; font-size: 0.875rem; }
.setting .participant { font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.setting.has-error { border-left: 0.25rem solid #b91c1c; padding-left: 0.5rem; }
.choices { display: inline-flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; }
input.short { width: 5rem; }
@media (min-width: 48rem) {
  .setting { grid-template-columns: 2fr 1fr; }
  .setting .participant { grid-column: 1 / -1; }
}
.map { height: 70vh; min-height: 20rem; border-radius: 0.5rem; }
.editor-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 64rem) {
  main:has(.editor-grid) { max-width: 90rem; }
  .editor-grid { grid-template-columns: 3fr 2fr; }
  .editor-grid .map { height: 75vh; }
}
.row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: end; }
.row label, .stack label { display: flex; flex-direction: column; gap: 0.15rem; }
.panel { border: 0.0625rem solid color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 0.5rem; padding: 0.75rem 1rem; max-width: none; }
.panel h3 { margin: 0; }
textarea { font: inherit; padding: 0.35rem; }
.preview { border-left: 0.25rem solid var(--muted); padding-left: 0.75rem; }
table.compact th, table.compact td { padding: 0.2rem 0.4rem; }
.tag { font-size: 0.75rem; border: 0.0625rem solid var(--accent); border-radius: 0.25rem; padding: 0 0.25rem; color: var(--accent); }
.leaflet-marker-icon.ctl-marker { display: grid; place-items: center; border: 0.1875rem solid #c026d3; border-radius: 50%; background: rgb(255 255 255 / 0.6); color: #86198f; font-weight: 700; font-size: 0.75rem; }
.leaflet-marker-icon.ctl-marker.dnf { border-color: #b91c1c; color: #b91c1c; }
.stack.wide { max-width: 48rem; }
.subnav { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.danger-zone { margin-top: 2rem; }
button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.tree, .tree ul, .tree ol { list-style: none; padding-left: 0; margin: 0; }
.tree .children { padding-left: 1.25rem; border-left: 0.125rem solid color-mix(in srgb, var(--muted) 35%, transparent); margin: 0.25rem 0 0.25rem 0.4rem; }
.node { margin: 0.2rem 0; }
.node-head { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.node-type { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.node-actions { margin-left: auto; display: inline-flex; gap: 0.5rem; }
.node-fields summary { font-size: 0.85rem; color: var(--accent); cursor: pointer; }
.add-form { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.25rem 0 0.5rem 1.6rem; }
.option-key { font-weight: 600; font-size: 0.9rem; }
.node-stage > .node-head, .node-variant > .node-head { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 0.25rem; padding: 0.1rem 0.3rem; }
.ctl-label { background: transparent; border: none; box-shadow: none; color: #86198f; font-weight: 700; }
.warning { color: #92400e; border-left: 0.25rem solid #f59e0b; padding-left: 0.5rem; }
.calib-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 64rem) { main:has(.calib-grid) { max-width: 90rem; } .calib-grid { grid-template-columns: 1fr 1fr; } }
.calib-map { height: 60vh; }
#image-map { background: #f4f4f5; }
.calib-tools { margin: 0.75rem 0; }
.leaflet-marker-icon.calib-pin { display: grid; place-items: center; border-radius: 50%; background: #c2410c; color: #fff; font-weight: 700; font-size: 0.75rem; border: 0.125rem solid #fff; }
.field-editor { border-bottom: 0.0625rem dashed color-mix(in srgb, var(--muted) 35%, transparent); padding: 0.35rem 0; }
.field-editor summary { cursor: pointer; }
.ff { margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.2rem; }
.ff.has-error { border-left: 0.25rem solid #b91c1c; padding-left: 0.5rem; }
.ff[hidden] { display: none; }
.preview-form { pointer-events: none; opacity: 0.9; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.qr svg { width: 12rem; height: 12rem; background: #fff; padding: 0.5rem; }
.run-head h1 { margin-bottom: 0; }
.run-head p { margin: 0.2rem 0; }
.run-feedback { font-size: 1.25rem; font-weight: 700; min-height: 1.6em; padding: 0.4rem 0.6rem; border-radius: 0.4rem; }
.run-feedback.good { background: color-mix(in srgb, #16a34a 18%, transparent); color: #14532d; }
.run-feedback.bad { background: color-mix(in srgb, #dc2626 18%, transparent); color: #7f1d1d; }
.run-actions { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.75rem 0; }
.big-button { font-size: 1.4rem; padding: 0.9rem 1rem; width: 100%; }
.big-button:disabled { opacity: 0.5; }
.widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem; }
.widget { border: 0.0625rem solid color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 0.5rem; padding: 0.4rem 0.7rem; }
.widget h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 0; }
.widget p { margin: 0.2rem 0; }
.widget .big { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.widget .big.late { color: #b91c1c; }
.widget-map, .widget-punch_list { grid-column: 1 / -1; }
.run-map { height: 55vh; min-height: 16rem; }
.punch-list { margin: 0; padding-left: 1.4rem; max-height: 14rem; overflow-y: auto; }
.scan-dialog video { width: 100%; max-height: 60vh; background: #000; }
.after-punch { max-width: 40rem; width: calc(100% - 2rem); }
.after-punch .media-embed { width: 100%; aspect-ratio: 16 / 9; border: 0; }
.after-punch video, .after-punch audio { width: 100%; }
.table-scroll { overflow-x: auto; }
table.results td.col-time, table.results td.col-points, table.results td.col-int { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.results tr:not(.status-ok) { color: var(--muted); }
table.results tr:not(.status-ok) a { color: inherit; }
table.splits td { white-space: nowrap; font-size: 0.9rem; }
.small { font-size: 0.85rem; }
.exports { margin-top: 1.5rem; }
.exports .button { margin: 0 0.25rem 0.4rem 0; }
.subnav a[aria-current="page"] { font-weight: 700; color: var(--fg); text-decoration: none; }
table.results th, table.results td { padding: 0.35rem 0.4rem; }
table.results td .muted { font-size: 0.85rem; }
.new-key code { word-break: break-all; }
.new-key code.key { font-size: 1.1rem; font-weight: 700; }
pre.snippet { white-space: pre-wrap; word-break: break-all; background: color-mix(in srgb, var(--muted) 12%, transparent); padding: 0.5rem; border-radius: 0.25rem; }
tr.key-revoked, tr.key-expired { color: var(--muted); }
body.embed main { max-width: none; padding: 0.5rem; }
.embed-title { font-size: 1.25rem; margin: 0 0 0.5rem; }
.embed-series h2 { font-size: 1.05rem; margin: 1rem 0 0.25rem; }
.tabs { flex-wrap: wrap; column-gap: 1rem; row-gap: 0.25rem; }
.stack fieldset label { flex-direction: row; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.inline-check { flex-direction: row !important; gap: 0.4rem; align-items: center; }
.tracking-head h1 { margin-bottom: 0.2rem; }
.tracking { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
.tracking-map { height: 60vh; min-height: 18rem; }
@media (min-width: 60rem) {
  main:has(.tracking) { max-width: 90rem; }
  .tracking { grid-template-columns: 1fr 20rem; }
  .tracking-map { height: 75vh; }
  .tracking-side { max-height: 75vh; overflow-y: auto; }
}
.entry-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.entry-list li { padding: 0.25rem 0; border-bottom: 0.0625rem solid color-mix(in srgb, var(--muted) 25%, transparent); }
.entry-list li.following { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.entry-list .small { display: block; }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; vertical-align: middle; }
.leaflet-marker-icon.team-marker { background: none; border: none; }
.team-marker span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; color: #fff; font-weight: 700; font-size: 0.75rem; padding: 0.05rem 0.35rem; border-radius: 0.6rem; border: 0.125rem solid #fff; box-shadow: 0 0 0.2rem rgb(0 0 0 / 0.5); }
.live-state.on { color: #16a34a; font-weight: 700; }
.replay-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.replay-controls input[type=range] { width: 100%; }
.replay-clock { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0; width: 100%; }
.series-filter label { display: inline-flex; gap: 0.25rem; margin-right: 0.75rem; }
.tracking-edit-map, .follow-map { height: 60vh; min-height: 18rem; }
.map.drawing { cursor: crosshair; }
.leaflet-marker-icon.point-marker { background: none; border: none; }
.point-marker span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; background: #ea580c; color: #fff; font-weight: 700; font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: 0.25rem; border: 0.125rem solid #fff; box-shadow: 0 0 0.2rem rgb(0 0 0 / 0.5); }
.point-marker.visited span { background: #16a34a; }
.point-list { padding-left: 1.5rem; }
.point-list li { margin: 0.2rem 0; }
.share-url { word-break: break-all; }
.marshal .team-input { font-size: 2rem; width: 100%; text-transform: uppercase; letter-spacing: 0.05em; }
.marshal .team-label { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.75rem 0; }
.marshal .control-select { font-size: 1.2rem; }
.suggestions { display: flex; flex-direction: column; gap: 0.3rem; }
.suggestion { text-align: left; background: none; color: var(--fg); border-color: var(--muted); }
.confirm { border: 0.125rem solid var(--accent); border-radius: 0.5rem; padding: 0.75rem; margin: 0.5rem 0; }
.confirm-team { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.5rem; }
.visited-list li, .not-visited-list li { padding: 0.15rem 0; }
table.compact tr.late td { color: #b91c1c; font-weight: 600; }
.entry-map { height: 50vh; min-height: 16rem; } .punch-table tr.punch-voided td, .punch-table tr.punch-superseded td { color: var(--muted); text-decoration: line-through; } .punch-table details form { margin: 0.3rem 0; }

/* Left-aligned admin forms: one field per line, label above the input. */
.form { max-width: 40rem; }
.form fieldset { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
.form label { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.form label.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.form input:not([type="checkbox"]):not([type="radio"]):not(.short), .form select, .form textarea { width: 100%; max-width: 28rem; }
.form fieldset > label:has(textarea), .form fieldset > label:has(input[name="name"]) { align-self: stretch; }
.form .pair { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: flex-end; }
.form .help { margin: 0; }
.form > button { margin-top: 0.5rem; }
.participant-settings table { width: 100%; }
.participant-settings td label { display: inline-flex; gap: 0.35rem; align-items: center; margin-right: 0.75rem; }
tr.problem td { background: color-mix(in srgb, #b91c1c 8%, transparent); }

/* Punch page: compact header, navigation behind a menu button. */
.site-header.compact { position: relative; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.menu > summary { list-style: none; cursor: pointer; font-size: 1.6rem; line-height: 1; padding: 0.25rem 0.5rem; border-radius: 0.375rem; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: color-mix(in srgb, var(--muted) 20%, transparent); }
.menu-items { position: absolute; right: 0.5rem; top: 100%; z-index: 1000; display: flex; flex-direction: column; gap: 0.25rem; min-width: 14rem; padding: 0.5rem; background: var(--bg, #fff); border: 0.0625rem solid color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 0.5rem; box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 15%); }
.menu-items a, .menu-items button { display: block; width: 100%; padding: 0.6rem 0.75rem; text-align: left; font: inherit; font-weight: 600; text-decoration: none; }
.menu-items form { margin: 0; }
.run-head h1 { font-size: 1.4rem; margin: 0.25rem 0; }
.run-head p { margin: 0; }
.update-bar { position: sticky; top: 0; z-index: 2000; padding: 0.5rem 1rem; background: var(--accent); color: #fff; text-align: center; }
.update-bar button { margin-left: 0.5rem; }

/* Punch page GPS state: grey = idle, pulsing amber = waiting for an
   accurate position, green = accurate enough to punch. */
.gps-state { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0 0.75rem; font-size: 0.95rem; }
.gps-dot { width: 0.85rem; height: 0.85rem; border-radius: 50%; flex: none; background: #9ca3af; }
.gps-state[data-state="ok"] .gps-dot { background: #16a34a; }
.gps-state[data-state="weak"] .gps-dot, .gps-state[data-state="none"] .gps-dot, .gps-state[data-state="old"] .gps-dot { background: #d97706; animation: gps-pulse 1.2s ease-in-out infinite; }
@keyframes gps-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.75); } }
@media (prefers-reduced-motion: reduce) { .gps-state .gps-dot { animation: none !important; } }
code.copy { display: block; padding: 0.5rem; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; background: color-mix(in srgb, var(--muted) 15%, transparent); border-radius: 0.375rem; }
