:root {
  color-scheme: dark;
  --bg: #111112;
  --header: #151516;
  --surface: #1e1e20;
  --raised: #262629;
  --inset: #161618;
  --line: #403b34;
  --input-line: #7b7162;
  --text: #f6f2eb;
  --muted: #c0b8ac;
  --gold: #e3bc70;
  --gold-bright: #f3d594;
  --on-gold: #241a0a;
  --gold-surface: #312718;
  --danger: #ffb6ae;
  --danger-surface: #422529;
  --danger-line: #b56f71;
  --success: #bce1c2;
  --success-surface: #22332a;
  --radius: 10px;
  --card-radius: 18px;
  --header-width: 1120px;
  --column-width: 29rem;
  --workspace-width: 48rem;
  font: 16px/1.55 system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
img { display: block; max-width: 100%; }
a { color: var(--gold-bright); text-underline-offset: .22em; }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--on-gold); }

.skip-link {
  position: fixed;
  z-index: 1;
  inset: .75rem auto auto .75rem;
  transform: translateY(-250%);
  padding: .6rem 1rem;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--on-gold);
}
.skip-link:focus { transform: none; color: var(--on-gold); }

.site-header {
  background: var(--header);
  border-bottom: 1px solid var(--line);
}
.site-header-inner {
  max-width: var(--header-width);
  min-height: 76px;
  margin-inline: auto;
  padding: 12px clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.brand {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  max-width: 100%;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}
.brand-emblem {
  width: clamp(48px, 7vw, 58px);
  aspect-ratio: 1;
  background: var(--gold);
  mask: url("divtsov-monogram.png") center 35% / 140% no-repeat;
}
.brand-name { font-size: 1.15rem; font-weight: 750; letter-spacing: .12em; line-height: 1.15; }
.brand-caption { color: var(--muted); font-size: .8125rem; line-height: 1.3; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a,
.pagination a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 6px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.nav a:hover,
.pagination a:hover { background: var(--raised); color: var(--text); }
.nav a[aria-current] { background: var(--gold-surface); color: var(--gold-bright); }

.page {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 16px;
  padding: clamp(24px, 6vw, 72px) clamp(14px, 4vw, 32px) 56px;
}
.card {
  width: min(100%, var(--column-width));
  min-width: 0;
  padding: clamp(20px, 5vw, 36px);
  border: 1px solid var(--line);
  border-top-color: var(--input-line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: 0 14px 32px #0003;
  overflow-wrap: anywhere;
}
.card-wide { width: min(100%, var(--workspace-width)); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
h1, h2, h3 { color: var(--text); line-height: 1.2; }
h1 { margin: 0 0 .7em; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -.03em; }
h2 { margin: 1.45em 0 .55em; font-size: clamp(1.2rem, 2.8vw, 1.4rem); }
h3 { font-size: 1.05rem; }
h1 + p { margin-top: 0; color: var(--muted); }

label { display: block; margin-bottom: 6px; font-weight: 650; }
input:not([type="checkbox"], [type="radio"], [type="hidden"]),
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: var(--radius);
  background: var(--inset);
  color: var(--text);
  font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 6px 0 0;
  accent-color: var(--gold);
  vertical-align: -.15em;
}
select[multiple] { min-height: 8rem; }
textarea { resize: vertical; }
input[type="file"]::file-selector-button {
  margin-right: .65rem;
  padding: .35rem .65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--gold-bright);
  font: inherit;
  cursor: pointer;
}
.field { margin: 0 0 16px; }
.field small, .helptext { display: block; margin-top: 5px; color: var(--muted); }
fieldset {
  min-inline-size: 0;
  margin: 0 0 16px;
  padding: .6rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
legend { padding-inline: .4rem; color: var(--gold-bright); font-weight: 700; }
.choice-picker p { margin: .35rem 0 .75rem; color: var(--muted); }
.participant-form button[hidden] { display: none; }
[data-entry-form] button[hidden] { display: none; }
.trainer-choices {
  max-height: 16rem;
  overflow: auto;
  padding-inline: 5px;
}
.trainer-choices label, .duplicate-confirmation {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}
.trainer-choices input, .duplicate-confirmation input { flex: none; }
.duplicate-confirmation { margin-block: .5rem; }

button, .button {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--on-gold);
  font: inherit;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
button:not(:disabled):hover, .button:hover { background: var(--gold-bright); color: var(--on-gold); }
.secondary { border-color: var(--input-line); background: var(--raised); color: var(--text); }
.secondary:not(:disabled):hover { background: var(--gold-surface); color: var(--gold-bright); }
.danger { border-color: var(--danger-line); background: var(--danger-surface); color: var(--danger); }
.danger:not(:disabled):hover { border-color: var(--danger); background: var(--danger); color: #32171a; }
button:disabled { border-color: var(--line); background: var(--raised); color: var(--muted); cursor: wait; }
.button-inline { width: auto; min-height: 44px; margin: 0; padding-inline: 14px; }
.heading-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 1rem; }
.heading-row h1 { margin: 0; }

.messages { width: min(100%, var(--workspace-width)); }
.messages p, .hint {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-surface);
  color: var(--text);
}
.messages p:last-child { margin-bottom: 0; }
.messages .success { border-inline-start-color: var(--success); background: var(--success-surface); color: var(--success); }
.messages .error { border-inline-start-color: var(--danger); background: var(--danger-surface); color: var(--danger); }
.hint { margin: 16px 0; }
.hint p:last-child { margin-bottom: 0; }
.errorlist { margin-block: 6px; padding-left: 20px; color: var(--danger); }
.warning { color: var(--danger); font-weight: 650; }
[aria-invalid="true"] { border-color: var(--danger-line); }

.search { margin-bottom: 20px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.search-row button { width: auto; margin: 0; }
.entity-list, .compact-list, .participants { margin: 0 0 20px; padding: 0; list-style: none; }
.entity-list li, .participants li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.entity-list a { text-decoration: none; }
.entity-list a:hover { text-decoration: underline; }
.entity-list span, .participants span { display: block; margin-top: 4px; color: var(--muted); }
.compact-list li { padding: 4px 0; }
.details { margin: 0 0 20px; }
.details div {
  display: grid;
  grid-template-columns: minmax(8rem, .8fr) minmax(0, 1.4fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.details dt { color: var(--muted); }
.details dd { min-width: 0; margin: 0; }
.create-panel { margin-top: 22px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.create-panel summary { color: var(--gold-bright); cursor: pointer; font-weight: 700; }
.create-panel[open] summary { margin-bottom: 14px; }
.data-block { overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--inset); white-space: pre-wrap; overflow-wrap: anywhere; }
.candidate { margin: 10px 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised); }
.candidate p { margin: 4px 0 10px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 8px; margin-bottom: 1rem; }
.action-grid > .button, .action-grid button { margin: 0; }
.pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); }

@media (max-width: 730px) {
  .site-header-inner { align-items: flex-start; flex-direction: column; }
  .brand { align-self: center; }
  .nav { width: 100%; padding-top: 3px; border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .details div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
}

[data-entry-form] [hidden], [data-roster-selection] [hidden] { display: none !important; }

.roster-list > li { padding-block: .65rem; }
.roster-list p { margin-block: .3rem; }
.roster-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}
.roster-actions form { margin: 0; }
[data-roster-choices] label {
  display: flex;
  gap: .65rem;
  align-items: center;
  padding-block: .4rem;
  overflow-wrap: anywhere;
}
[data-roster-choices] label[hidden], [data-trainer-list] label[hidden] { display: none !important; }
