:root {
  color-scheme: light;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202124;
  background: #f5f5f7;
  --accent: #8b0000;
  --line: #e3e3e8;
  --muted: #63636b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main, .masthead { width: min(100% - 36px, 960px); margin-inline: auto; }
main { padding-bottom: 48px; }
.masthead { min-height: 64px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.masthead strong { font-size: 17px; letter-spacing: -.025em; }
.masthead span { color: var(--muted); font-size: 13px; }
h1 { font-size: clamp(26px, 4vw, 36px); letter-spacing: -.045em; line-height: 1.15; margin: 24px 0 20px; }
h2 { font-size: 18px; letter-spacing: -.015em; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p, label { margin: .65rem 0; }
small, .muted { color: var(--muted); }
h2 small { margin-right: 6px; font-weight: 500; }
a { color: var(--accent); }
.workspace-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 16px 0 22px; }
.workspace-nav > * { color: var(--muted); text-decoration: none; font: inherit; font-weight: 550; background: transparent; border: 1px solid transparent; padding: 7px 11px; border-radius: 8px; }
.workspace-nav [aria-current] { background: white; border-color: var(--line); color: var(--accent); }
.workspace-nav #logout { margin-left: auto; }
section, #login { padding: clamp(16px, 4vw, 28px); margin: 12px 0; background: white; border: 1px solid var(--line); border-radius: 16px; }
#login { max-width: 410px; margin-top: 26px; }
#login h1, #heatlist h1, #presenter h1 { margin-top: 0; }
label { display: block; font-weight: 550; }
label:not(:has([type=checkbox])) :is(input,select,textarea) { display: block; margin-top: 4px; }
input, select, textarea, button { font: inherit; padding: 7px 10px; max-width: 100%; border: 1px solid #d8d8df; border-radius: 8px; background: white; color: inherit; }
textarea, .share { width: 100%; }
.line > .share { flex: 1 1 240px; min-width: 0; }
input[type=checkbox] { accent-color: var(--accent); }
button { cursor: pointer; font-weight: 550; }
button:hover, .workspace-nav a:hover { background: #f0f0f4; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary, #heatlist #save, #editor button:not([type=button]) { color: white; background: var(--accent); border-color: var(--accent); }
.primary:hover, #heatlist #save:hover, #editor button:not([type=button]):hover { background: #720000; }
fieldset { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
fieldset button { margin: 2px 4px 2px 0; }
fieldset select { margin-left: 6px; }
#status, #msg { white-space: pre-wrap; }
#status:empty, #msg:empty, #message:empty { display: none; }
.line, .save, .documents footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.line h2, .documents footer p { margin-right: auto; }
.toggle { font-weight: 500; }
#selected { padding-left: 24px; }
#selected li { padding: 6px 0; border-bottom: 1px solid var(--line); }
#selected li span { display: inline-block; margin-right: 8px; }
#selected li button { padding: 3px 8px; margin: 2px; }
#selected li.empty-output, #selected li.missing { color: var(--accent); }
details, .save { margin-top: 16px; }
summary { cursor: pointer; font-weight: 600; }
#search { margin: 10px 0; width: 100%; }
#available { max-height: 360px; overflow: auto; }
#available .output-group { padding: 6px 0; border: 0; }
#available button { display: block; margin: 4px 0; width: 100%; text-align: left; }
#eventOptions { margin-top: 8px; }

#category-controls { padding: 14px; }
.category-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.category-toolbar label { margin: 0; }
.category-toolbar input[type="checkbox"], .category-event-row input[type="checkbox"] { margin: 0; }
#category-count { color: var(--muted); }
.category-events { border-top: 1px solid var(--line); }
.category-event-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.category-event-row small { display: block; }
.category-event-row strong, .category-badge { overflow-wrap: anywhere; }
.category-badge { max-width: 12rem; padding: 2px 8px; border-radius: 5px; background: #f1f1f5; font-size: .85rem; }
@media (max-width: 520px) {
  .category-event-row { grid-template-columns: auto minmax(0, 1fr); }
  .category-badge { grid-column: 2; justify-self: start; }
}
.mapping-editor { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #ddd; }
.program-editor-head, .program-editor-row { display: grid; grid-template-columns: minmax(8rem, 1.1fr) repeat(2, minmax(5.5rem, .7fr)) minmax(8rem, 2fr) 7.5rem; gap: .45rem; align-items: center; }
.program-editor-head { font-weight: 700; color: var(--muted); font-size: .85rem; }
.program-editor-row { margin-bottom: .45rem; }
.program-editor-row label { margin: 0; min-width: 0; }
.program-editor-row label span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.program-editor-row label input { width: 100%; min-width: 0; margin-top: 0; }
.program-row-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem; }
.program-row-actions button { margin: 0; padding-inline: 0; min-height: 2.35rem; }
@media (max-width: 42rem) {
  .program-editor-head { display: none; }
  .program-editor-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .6rem; border: 1px solid var(--line); border-radius: .5rem; }
  .program-editor-row label:has([name="label"]) { grid-column: 1 / -1; }
  .program-editor-row label span { position: static; width: auto; height: auto; clip-path: none; }
  .program-row-actions { grid-column: 1 / -1; justify-self: end; width: 9rem; }
}
.mapping-group { margin: 0 0 1rem; min-width: 0; }
.mapping-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; align-items: start; padding: .55rem 0; border-bottom: 1px solid #e4e4e4; }
.mapping-row label { margin: 0; }
.mapping-row small { display: block; margin-top: .2rem; }
.mapping-row input { width: 100%; min-width: 0; box-sizing: border-box; }
.mapping-row code { overflow-wrap: anywhere; }

.category-event-row { cursor: auto; }
.category-event-edit {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
  overflow-wrap: anywhere;
}
#details-settings input[type="checkbox"] { width: auto; }
#details-editor details + details { margin-top: 1rem; }
#details-editor summary { cursor: pointer; font-weight: 700; }

#details-editor summary { margin-block: .5rem; }
#details-editor textarea { width: 100%; font: inherit; }
#details-editor input[type="checkbox"] { width: auto; }
#details-modules > button { margin-top: .75rem; }

.race-admin-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
}
.race-admin-heading :is(h1, h2) { margin: 0; }
.race-admin-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .85rem;
  border: 1px solid var(--accent);
  border-radius: .6rem;
  font-weight: 700;
  text-decoration: none;
}
.race-admin-link:hover { background: #fff4f3; }
.race-admin-settings { display: grid; gap: .5rem; margin: 1.25rem 0 1.75rem; }
.race-admin-settings > details {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: #fafafc;
}
.race-admin-settings summary { padding: .7rem .85rem; }
.race-admin-settings summary::marker { color: var(--accent); }
.race-admin-settings > details[open] > summary { border-bottom: 1px solid var(--line); }
.race-admin-settings form { padding: 0 .85rem; }
.race-admin-events { padding-top: 1rem; border-top: 1px solid var(--line); }
.race-admin-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.race-admin-filters :is(input, select) { width: 100%; margin-left: 0; }
#race-center .category-event-row:hover { background: #fafafc; }

.race-options p[role="status"]:empty { display: none; }
.option-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: .6rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.option-row label { margin: 0; }
.option-row [data-key="code"] { width: 7rem; }
.option-row input[type="color"], .race-options input[type="color"] { width: 3rem; min-height: 2.35rem; padding: .25rem; }
.preset-row { padding: .75rem 0; border-top: 1px solid var(--line); }
.preset-visibility { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .5rem; }
.preset-visibility fieldset { min-width: 0; margin: 0; }
