:root {
  /* Palette: steel blue #689BC0, Yale blue #023B67, Baltic blue #096297,
     dusty denim #6586A9, Yale blue 2 #014570. Text and surface tints are
     derived from it so text keeps at least 4.5:1 contrast. */
  --bg: #f2f6f9;
  --surface: #ffffff;
  --text: #0e2235;
  --muted: #4d6b88;
  --border: #d3dfe9;
  --primary: #096297;
  --primary-strong: #023b67;
  --primary-text: #ffffff;
  --primary-soft: #e1edf6;
  --danger: #c0262d;
  --danger-soft: #fde2e3;
  --success: #15803d;
  --success-soft: #dcf5e4;
  --warning: #a15c07;
  --warning-soft: #fdf0d5;
  --nav-bg: #023b67;
  --nav-text: #ffffff;
  --nav-muted: #b9d0e2;
  --nav-hover: #014570;
  --nav-active: #096297;
  --radius: 8px;
  --gap: 1rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #04172a;
    --surface: #0a2238;
    --text: #e3edf5;
    --muted: #9bb3c9;
    --border: #1c3b57;
    --primary: #689bc0;
    --primary-strong: #8fb6d3;
    --primary-text: #02223b;
    --primary-soft: #0f3452;
    --danger: #ff7b80;
    --danger-soft: #3a1c1e;
    --success: #5fd38b;
    --success-soft: #16301f;
    --warning: #f2b45a;
    --warning-soft: #33270f;
    --nav-bg: #012a4a;
    --nav-text: #ffffff;
    --nav-muted: #a9c3d8;
    --nav-hover: #014570;
    --nav-active: #096297;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 16px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
}
main { flex: 1; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .5rem 0; }
a { color: var(--primary); }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.code { background: var(--primary-soft); padding: .1rem .4rem; border-radius: 4px; word-break: break-all; }

.container { width: 100%; margin: 0 auto; padding: 1.5rem 24px; }
.narrow { max-width: 460px; padding-top: 3rem; }
/* CMS pages: text pages read at twice the narrow width, HTML pages use the full width. */
.medium { max-width: 920px; padding-top: 3rem; }
.wide { padding-top: 3rem; }
.wide #join .form { max-width: 460px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.plain { list-style: none; padding: 0; margin: .5rem 0; }
.plain li { padding: .25rem 0; }

/* Navigation: one header bar holds every menu. */
.navbar { background: var(--nav-bg); border-bottom: 1px solid var(--nav-hover); position: sticky; top: 0; z-index: 10; }
.navbar-container { padding: .5rem 24px; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
.navbar .logo { color: var(--nav-text); }
.navbar-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; flex: 1; }
.navbar-spacer { flex: 1; }
.navbar-nav > a, .menu > summary { display: block; padding: .45rem .7rem; border-radius: 6px; color: var(--nav-muted); text-decoration: none; font-weight: 500; cursor: pointer; white-space: nowrap; }
.navbar-nav > a:hover, .menu > summary:hover, .menu[open] > summary { color: var(--nav-text); background: var(--nav-hover); }
.navbar-nav > a.active, .menu > summary.active { color: var(--nav-text); background: var(--nav-active); font-weight: 600; }
.menu { position: relative; margin: 0; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; display: inline-block; margin-left: .4rem; vertical-align: .2em; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; }
.menu-list { position: absolute; left: 0; top: calc(100% + .25rem); min-width: 14rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .35rem; display: flex; flex-direction: column; z-index: 20; }
.menu-right { margin-left: auto; }
.menu-right .menu-list { left: auto; right: 0; }
.menu-list a, .menu-list button { display: block; width: 100%; text-align: left; padding: .45rem .7rem; border-radius: 6px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--primary-soft); }
.menu-list a.active { color: var(--primary); font-weight: 600; }
.menu-list form { margin: 0; border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .25rem; }
.footer { color: var(--muted); font-size: .875rem; border-top: 1px solid var(--border); }

/* Layout blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: var(--gap); }
.card-highlight { border-color: var(--primary); }
/* A second part inside a card, e.g. a team's submission under the team. */
.card-part { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.section { margin: 1.5rem 0; }
.section-head, .row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.section-head { margin-bottom: .75rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--gap); }
.grid > .card { margin-bottom: 0; }
.event-card { display: block; color: inherit; text-decoration: none; }
.event-card:hover { border-color: var(--primary); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }
.actions form, .actions-cell form { display: inline; margin: 0; }
.actions-cell { text-align: right; white-space: nowrap; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 1rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.hero h1 { font-size: 2rem; }
.error-page { text-align: center; padding: 2.5rem 1.25rem; }
.metric { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.metric-value { font-size: 2rem; font-weight: 700; }
.sparkline { flex: 1; min-width: 160px; height: 48px; color: var(--primary); }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.members { list-style: none; padding: 0; margin: .5rem 0; }
.members li { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.members li:last-child { border-bottom: 0; }
.members form { margin: 0; }
.waiver { border-left: 3px solid var(--border); padding-left: .75rem; }
.criterion { padding: .75rem 0; border-bottom: 1px solid var(--border); }
/* Score form: one compact row per criterion, name and slider side by side;
   the criterion's details and the justification open below on demand. */
.scoring .criterion { display: grid; grid-template-columns: minmax(8rem, 1fr) 3fr; gap: .35rem 1rem; align-items: center; padding: .4rem 0; }
.scoring fieldset { min-width: 0; }
.criterion-name { overflow-wrap: anywhere; }
.slider { display: flex; align-items: center; gap: .5rem; }
.slider input[type="range"] { flex: 1; min-width: 0; accent-color: var(--primary); padding: 0; border: 0; background: none; }
.slider output { min-width: 2.25rem; text-align: center; font-weight: 700; font-size: 1.1rem; border-radius: 6px; background: var(--primary-soft); padding: .1rem .35rem; }
.criterion-details, .justification { grid-column: 1 / -1; font-size: .875rem; }
.criterion-details { background: var(--primary-soft); border-radius: 6px; padding: .5rem .75rem; }
.criterion-details p { margin: .25rem 0; }
.toggle, .icon-hint { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 700; font-size: .85rem; line-height: 1; padding: 0; }
.icon-hint { width: 1.25rem; height: 1.25rem; font-size: .7rem; vertical-align: middle; }
.toggle { cursor: pointer; flex: none; }
.toggle:hover { background: var(--primary-soft); }
.toggle[aria-expanded="true"] { background: var(--primary); color: var(--primary-text); }
/* A dot on ✎ once the justification is written. */
.toggle.filled { position: relative; }
.toggle.filled::after { content: ""; position: absolute; top: -2px; right: -2px; width: .55rem; height: .55rem; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
.scoring [hidden] { display: none; }
.criterion:last-of-type { border-bottom: 0; }
.judge { padding: .75rem 0; border-top: 1px solid var(--border); }
.qr { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.qr img { background: #fff; padding: 6px; border-radius: 4px; }
details { margin-top: .75rem; }
summary { cursor: pointer; color: var(--primary); }

/* Judging */
.judging-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: var(--gap); }
.judging-progress { display: flex; align-items: center; gap: .75rem; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.score input { width: 6rem; }

/* Forms */
.form { display: flex; flex-direction: column; gap: .85rem; margin-top: .5rem; }
.form-row { display: flex; flex-wrap: wrap; gap: .85rem; }
.form-row > label { flex: 1 1 160px; }
.form-row > .grow { flex: 3 1 240px; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.form-inline input:not([type="file"]), .form-inline select { flex: 1 1 200px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .25rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .5rem .65rem; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input[readonly] { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
textarea { resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 500; padding: .5rem .9rem; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: transparent; color: var(--primary);
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-outline { border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger-outline { border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-link { padding-left: .4rem; padding-right: .4rem; }
.btn-link:hover { text-decoration: underline; }
.btn.danger { color: var(--danger); }
.btn-sm { padding: .3rem .6rem; font-size: .875rem; }
.btn-block { width: 100%; }
.htmx-request.btn, .htmx-request .btn { opacity: .6; }

/* Status */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: var(--gap); border: 1px solid; }
.alert-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-info { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--primary-soft); color: var(--text); vertical-align: middle; white-space: nowrap;
}
.badge-published, .badge-registered { background: var(--success-soft); color: var(--success); }
.badge-draft, .badge-waitlisted { background: var(--warning-soft); color: var(--warning); }
.badge-archived, .badge-cancelled { background: var(--border); color: var(--muted); }
.badge-primary { background: var(--primary); color: var(--primary-text); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .875rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.card:has(> .table) { overflow-x: auto; }

/* Sign-in */
.auth-card h1 { margin-bottom: 1rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1rem 0; font-size: .875rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-card .btn-block + .btn-block { margin-top: .5rem; }

@media (max-width: 720px) {
  .scoring .criterion { grid-template-columns: 1fr; }
  .rank-item { grid-template-columns: auto auto 1fr; }
  .rank-move { grid-column: 1 / -1; justify-content: flex-end; }
  .navbar-container, .container { padding-left: 16px; padding-right: 16px; }
  .navbar-nav { order: 3; flex-basis: 100%; }
  .facts { grid-template-columns: 1fr; }
}

/* Challenge ranking: a list sorted by drag and drop. */
.rank-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.rank-item { display: grid; grid-template-columns: auto auto 1fr auto; gap: .35rem .75rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); user-select: none; }
.rank-item.dragging { border-color: var(--primary); box-shadow: 0 6px 18px rgba(0, 0, 0, .25); position: relative; z-index: 1; cursor: grabbing; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: .35rem .2rem; touch-action: none; }
.rank-place { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary-soft); font-weight: 700; }
.rank-list > li:first-child .rank-place { background: var(--primary); color: var(--primary-text); }
.rank-main { min-width: 0; overflow-wrap: anywhere; }
.rank-links { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .15rem; }
.rank-move { display: flex; gap: .35rem; }
.rank-item .justification { grid-column: 1 / -1; font-size: .875rem; user-select: text; }
.rank-item [hidden] { display: none; }

/* Radio choices with a description, e.g. a team's challenge. */
.choices { display: grid; gap: .5rem; }
.form .choice, .choice { display: flex; flex-direction: row; gap: .75rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.choice input { width: auto; margin-top: .3rem; }
.choice-text { display: flex; flex-direction: column; gap: .15rem; font-weight: normal; }

/* Storage meter and upload progress (team files). */
.meter { height: .5rem; background: var(--border); border-radius: 999px; overflow: hidden; margin: .25rem 0 .75rem; }
.meter span { display: block; height: 100%; background: var(--primary); }
.upload progress { flex: 1 1 8rem; }
.nowrap { white-space: nowrap; }

/* Pages with a sidebar of their own (a team's settings, submission, files). */
.with-sidebar { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.sidebar { position: sticky; top: 4.5rem; display: flex; flex-direction: column; gap: .75rem; }
.sidebar-back { text-decoration: none; }
.sidebar-title { display: flex; flex-direction: column; }
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }
.sidebar-nav a { padding: .5rem .75rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidebar-nav a:hover { background: var(--primary-soft); }
.sidebar-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
@media (max-width: 720px) {
  .with-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
}

/* A generated password shown once (attendee password reset). */
.code.password { font-size: 1.25rem; letter-spacing: .05em; padding: .4rem .7rem; user-select: all; }

/* CMS page bodies; HTML pages bring their own headings, lists, images and tables. */
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.page-body { overflow-wrap: anywhere; }
.page-body > :first-child, .page-body .card > :first-child { margin-top: 0; }
.page-body h1, .page-body h2, .page-body h3, .page-body h4 { margin: 1.25rem 0 .5rem; }
.page-body ul, .page-body ol { padding-left: 1.5rem; }
.page-body img, .page-body video { max-width: 100%; height: auto; }
.page-body table { border-collapse: collapse; margin: .75rem 0; display: block; overflow-x: auto; }
.page-body th, .page-body td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; }
.page-body blockquote { margin: .75rem 0; padding-left: 1rem; border-left: 3px solid var(--primary-soft); color: var(--muted); }
.page-body pre { background: var(--primary-soft); padding: .75rem; border-radius: 6px; overflow-x: auto; }
.page-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
