/* ==========================================================================
   AL-BIRUNI'S CHALLENGE 2026 — Core stylesheet
   Theme: Heritage Excellence — astronomy, measurement, scholarship
   Palette: Burgundy #642B36 · Blush #DFA6A1 · Gold #B78B3C · Ivory #FFF9EF
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- 1. Design tokens ---------- */
:root {
  --burgundy: #642B36;
  --burgundy-700: #4E2029;
  --burgundy-900: #34131A;
  --burgundy-050: #F6EDEC;
  --blush: #DFA6A1;
  --blush-soft: #F0D8D5;
  --gold: #B78B3C;
  --gold-600: #A0782F;
  --gold-300: #D8BC7E;
  --gold-050: #FAF3E4;
  --ivory: #FFF9EF;
  --ivory-2: #FDF4E6;
  --paper: #FEFBF6;

  --ink: #2B1A1D;
  --ink-2: #4A3437;
  --muted: #7C6669;
  --muted-2: #9C8B8D;
  --line: rgba(100, 43, 54, 0.16);
  --line-gold: rgba(183, 139, 60, 0.42);

  --success: #2E6B4F;
  --success-050: #E8F2EC;
  --warning: #A8781F;
  --warning-050: #FBF1DC;
  --danger: #9B2C2C;
  --danger-050: #F8E8E8;
  --info: #2F5D7C;
  --info-050: #E6EEF4;

  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-sm: 0 1px 2px rgba(52, 19, 26, 0.06), 0 2px 6px rgba(52, 19, 26, 0.05);
  --shadow-md: 0 4px 12px rgba(52, 19, 26, 0.08), 0 12px 28px rgba(52, 19, 26, 0.07);
  --shadow-lg: 0 12px 32px rgba(52, 19, 26, 0.12), 0 32px 64px rgba(52, 19, 26, 0.10);

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;

  --shell: 1200px;
  --shell-narrow: 900px;
  --nav-h: 68px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--ivory);
  /* Parchment paper texture + faint astrolabe rings */
  background-image:
    radial-gradient(circle at 12% 8%, rgba(223, 166, 161, 0.10), transparent 42%),
    radial-gradient(circle at 88% 4%, rgba(183, 139, 60, 0.08), transparent 40%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.48 0 0 0 0 0.40 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg { max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  color: var(--burgundy);
  margin: 0 0 0.5em;
  letter-spacing: 0.005em;
}
h1 { font-size: clamp(2.1rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.65rem, 3.4vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2.2vw, 1.55rem); }
h4 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--burgundy); text-decoration-color: var(--line-gold); text-underline-offset: 3px; }
a:hover { color: var(--burgundy-700); }

hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-gold), transparent);
  margin: 2.25rem 0;
}

::selection { background: var(--blush-soft); color: var(--burgundy-900); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--burgundy); color: var(--ivory);
  padding: 0.6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

main { flex: 1 0 auto; }

/* ---------- 3. Layout helpers ---------- */
.shell { width: min(100% - 2.5rem, var(--shell)); margin-inline: auto; }
.shell-narrow { width: min(100% - 2.5rem, var(--shell-narrow)); margin-inline: auto; }
.section { padding: clamp(3rem, 7vw, 5.5rem) 0; }
.section-tight { padding: clamp(2rem, 4vw, 3rem) 0; }
.section-alt { background: linear-gradient(180deg, var(--paper), var(--ivory-2)); border-block: 1px solid var(--line); }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.flex { display: flex; gap: 1rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.flex-center { display: flex; align-items: center; gap: 0.6rem; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

/* ---------- 4. Ornament: rules, corners, astrolabe ---------- */
.eyebrow {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-600);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.eyebrow::before, .eyebrow::after {
  content: '';
  width: 28px; height: 1px;
  background: var(--line-gold);
}
.eyebrow.left::before { display: none; }

.ornament-rule {
  display: flex; align-items: center; justify-content: center;
  gap: 0.85rem; margin: 2.5rem 0;
  color: var(--gold);
}
.ornament-rule::before, .ornament-rule::after {
  content: ''; height: 1px; flex: 1;
  background: linear-gradient(90deg, transparent, var(--line-gold));
}
.ornament-rule::after { background: linear-gradient(270deg, transparent, var(--line-gold)); }
.ornament-rule .glyph {
  font-size: 1.15rem; line-height: 1;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  font-family: var(--serif);
}

/* Gold hairline frame with corner ticks */
.frame {
  position: relative;
  border: 1px solid var(--line-gold);
  background: var(--paper);
  padding: clamp(1.5rem, 3vw, 2.5rem);
}
.frame::before, .frame::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 1px solid var(--gold);
  opacity: 0.75;
}
.frame::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.frame::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }

/* Astrolabe watermark */
.astrolabe-watermark {
  position: relative;
  isolation: isolate;
}
.astrolabe-watermark::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: 50%; left: 50%;
  width: min(760px, 120%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400' fill='none' stroke='%23B78B3C' stroke-width='0.7'%3E%3Ccircle cx='200' cy='200' r='196'/%3E%3Ccircle cx='200' cy='200' r='168'/%3E%3Ccircle cx='200' cy='200' r='112'/%3E%3Ccircle cx='200' cy='200' r='56'/%3E%3Cellipse cx='200' cy='200' rx='196' ry='70'/%3E%3Cellipse cx='200' cy='200' rx='196' ry='130'/%3E%3Cellipse cx='200' cy='200' rx='70' ry='196'/%3E%3Cellipse cx='200' cy='200' rx='130' ry='196'/%3E%3Cpath d='M200 4v392M4 200h392'/%3E%3Cpath d='M60 60l280 280M340 60L60 340'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.72rem 1.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--burgundy); color: var(--ivory); border-color: var(--burgundy); }
.btn-primary:hover:not(:disabled) { background: var(--burgundy-700); border-color: var(--burgundy-700); color: #fff; box-shadow: var(--shadow-sm); }

.btn-gold { background: var(--gold); color: var(--burgundy-900); border-color: var(--gold); }
.btn-gold:hover:not(:disabled) { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }

.btn-outline { background: transparent; color: var(--burgundy); border-color: var(--line-gold); }
.btn-outline:hover:not(:disabled) { border-color: var(--burgundy); background: var(--burgundy-050); }

.btn-secondary { background: var(--ivory-2); color: var(--ink-2); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--blush-soft); border-color: var(--line-gold); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #7f2222; }

.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 0.45rem 0.6rem; }
.btn-ghost:hover:not(:disabled) { color: var(--burgundy); background: var(--burgundy-050); }

.btn-sm { font-size: 0.82rem; padding: 0.42rem 0.8rem; }
.btn-lg { font-size: 1.04rem; padding: 0.9rem 1.9rem; }
.btn-block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ---------- 6. Cards & panels ---------- */
.card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-gold); }
.card-accent { border-top: 3px solid var(--gold); }
.card h3 { margin-bottom: 0.4rem; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1.1rem 1.35rem;
  background: linear-gradient(180deg, var(--ivory-2), var(--paper));
  border-bottom: 1px solid var(--line);
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1.22rem; }
.panel-body { padding: 1.35rem; }
.panel-body.tight { padding: 0; }
.panel-footer { padding: 1rem 1.35rem; border-top: 1px solid var(--line); background: var(--ivory-2); }

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
}
.stat-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.stat-value { font-family: var(--serif); font-size: 2.1rem; line-height: 1.1; color: var(--burgundy); font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 0.82rem; color: var(--muted); }
.stat.burgundy { border-left-color: var(--burgundy); }
.stat.success { border-left-color: var(--success); }
.stat.info { border-left-color: var(--info); }
.stat.warning { border-left-color: var(--warning); }

/* A row of stat tiles. Auto-fit rather than a fixed four columns, so a
   dashboard on a phone stacks instead of squeezing four numbers into 320px. */
.stat-row {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* A result the team has invalidated. It stays in the table on purpose — it is
   part of the record — but it must never be mistaken for a live score. */
.row-invalidated td { opacity: 0.55; }
.row-invalidated td strong { text-decoration: line-through; }

/* ---------- 7. Badges, pills, alerts ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line-gold);
  background: var(--gold-050);
  color: var(--gold-600);
  white-space: nowrap;
}
.badge-ok { background: var(--success-050); border-color: rgba(46,107,79,0.3); color: var(--success); }
.badge-warn { background: var(--warning-050); border-color: rgba(168,120,31,0.3); color: var(--warning); }
.badge-danger { background: var(--danger-050); border-color: rgba(155,44,44,0.3); color: var(--danger); }
.badge-info { background: var(--info-050); border-color: rgba(47,93,124,0.3); color: var(--info); }
.badge-burgundy { background: var(--burgundy-050); border-color: rgba(100,43,54,0.25); color: var(--burgundy); }
.badge-muted { background: var(--ivory-2); border-color: var(--line); color: var(--muted); }

.alert {
  display: flex; gap: 0.85rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  background: var(--gold-050);
  font-size: 0.93rem;
}
.alert strong { display: block; margin-bottom: 0.15rem; }
.alert-warn { border-left-color: var(--warning); background: var(--warning-050); }
.alert-danger { border-left-color: var(--danger); background: var(--danger-050); }
.alert-ok { border-left-color: var(--success); background: var(--success-050); }
.alert-info { border-left-color: var(--info); background: var(--info-050); }

/* ---------- 8. Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field > label, .label {
  display: block;
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-2);
  margin-bottom: 0.4rem;
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.97rem;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.68rem 0.85rem;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
  -webkit-appearance: none; appearance: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-gold); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(183, 139, 60, 0.16);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--ivory-2); color: var(--muted); cursor: not-allowed; }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237C6669' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.3rem;
}

.field-hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.35rem; }
.field-error { font-size: 0.82rem; color: var(--danger); margin-top: 0.35rem; display: none; }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.field.invalid .field-error { display: block; }

.checkline { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.93rem; margin-bottom: 0.6rem; }
.checkline input[type='checkbox'], .checkline input[type='radio'] { margin-top: 0.28rem; width: 1.05em; height: 1.05em; accent-color: var(--burgundy); flex: none; }
.checkline label { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 0.93rem; }

.form-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1.1rem; margin: 0 0 1.25rem; }
legend { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--burgundy); padding: 0 0.4rem; }

/* Radio cards (category / option pickers) */
.choice-grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.choice {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ivory);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.choice:hover { border-color: var(--line-gold); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .choice-title { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--burgundy); display: block; }
.choice .choice-desc { font-size: 0.86rem; color: var(--muted); display: block; margin-top: 0.2rem; }
.choice:has(input:checked) {
  border-color: var(--gold);
  background: var(--gold-050);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.choice:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Filter pills */
.pill {
  border: 1px solid var(--line); background: var(--ivory); color: var(--ink-2);
  border-radius: 999px; padding: 0.35rem 0.85rem;
  font-size: 0.84rem; font-weight: 500; cursor: pointer;
  transition: all 0.14s var(--ease);
}
.pill:hover { border-color: var(--line-gold); }
.pill.active { background: var(--burgundy); border-color: var(--burgundy); color: var(--gold-300); font-weight: 600; }

/* Rubric editor row */
.rubric-row {
  display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap;
  padding: 0.75rem 0; border-bottom: 1px solid var(--line);
}
.rubric-row .field { margin: 0; flex: 0 1 220px; }
.rubric-row .field.grow { flex: 1 1 240px; }
.rubric-row .field.short { flex: 0 0 92px; }

/* Admin round rows and task list */
.admin-round {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.admin-round:last-child { border-bottom: 0; }
.admin-round:hover .admin-round-name { color: var(--burgundy); }
.admin-round-name { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.admin-round-meta { font-size: 0.84rem; color: var(--muted); margin-top: 0.15rem; }

.admin-task {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--ivory); text-decoration: none; color: inherit;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease);
}
.admin-task:hover { border-color: var(--line-gold); background: var(--gold-050); }
.admin-task .n {
  min-width: 2.4rem; height: 2.4rem; padding: 0 0.5rem;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 1.1rem; font-weight: 600;
  background: var(--ivory-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2);
}
.admin-task.urgent .n { background: var(--danger-050); border-color: rgba(178, 58, 48, 0.35); color: var(--danger); }
.admin-task .t { display: grid; gap: 0.1rem; min-width: 0; }
.admin-task .l { font-size: 0.9rem; }
.admin-task .c { font-size: 0.78rem; color: var(--muted); }

/* Filter bar used across admin tables */
.filter-bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-bar .input { flex: 1 1 220px; margin: 0; }
.filter-count { font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* User avatar */
.user-avatar {
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--burgundy); color: var(--gold-300);
  font-family: var(--serif); font-size: 1.25rem; font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 3px var(--burgundy-050);
}

/* Certificate card */
.cert-card {
  position: relative;
  padding: 1.15rem 1.25rem 1.35rem;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(183, 139, 60, 0.10), transparent 60%),
    linear-gradient(180deg, var(--ivory) 0%, #FBF4E6 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.cert-theta {
  position: absolute; right: 1rem; top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif); font-size: 3.4rem; line-height: 1;
  color: var(--gold-300); opacity: 0.35; pointer-events: none;
}
.cert-rule {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--burgundy) 0%, var(--gold) 55%, transparent 100%);
  margin-bottom: 1rem;
}

/* ---------- 9. Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { padding: 0.72rem 0.85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); background: var(--ivory-2);
  position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line-gold);
}
table.data tbody tr:hover { background: var(--ivory-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: wrap; }
.rank-cell { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; color: var(--burgundy); }
tr.rank-1 .rank-cell { color: var(--gold-600); }
tr.rank-2 .rank-cell, tr.rank-3 .rank-cell { color: var(--ink-2); }

/* ---------- 10. Tabs ---------- */
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tab {
  font-family: var(--sans); font-size: 0.9rem; font-weight: 600;
  color: var(--muted); background: none; border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 0.95rem; cursor: pointer;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.tab:hover { color: var(--burgundy); }
.tab[aria-selected='true'] { color: var(--burgundy); border-bottom-color: var(--gold); }
.tabpanel[hidden] { display: none; }

/* ---------- 11. Modal & toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(52, 19, 26, 0.55);
  display: grid; place-items: center;
  padding: 1.25rem;
  animation: fade 0.18s var(--ease);
  overflow-y: auto;
}
.modal-overlay.closing { animation: fade 0.18s var(--ease) reverse; }
.modal {
  width: min(100%, 620px);
  max-height: calc(100vh - 2.5rem);
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s var(--ease);
}
.modal.wide { width: min(100%, 940px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--line); }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 0.25rem; }
.modal-close:hover { color: var(--burgundy); }
.modal-body { padding: 1.35rem; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 1rem 1.35rem; border-top: 1px solid var(--line); background: var(--ivory-2); flex-wrap: wrap; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

#abc-toasts {
  position: fixed; top: 1rem; right: 1rem; z-index: 1200;
  display: flex; flex-direction: column; gap: 0.6rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--paper);
  border: 1px solid var(--line-gold);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.8rem 0.9rem;
  font-size: 0.9rem;
  opacity: 0; transform: translateX(12px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-message { flex: 1; }
.toast-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0; }
.toast-ok { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warning); }

/* ---------- 12. Empty / loading states ---------- */
.empty-state { text-align: center; padding: clamp(2rem, 6vw, 3.5rem) 1.5rem; color: var(--muted); }
.empty-state .glyph { font-size: 2.2rem; color: var(--gold); display: block; margin-bottom: 0.6rem; }
.empty-state h3 { color: var(--ink-2); }
.empty-state p { max-width: 46ch; margin-inline: auto; }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--line-gold);
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block; vertical-align: middle;
}
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; gap: 0.75rem; padding: 2.5rem; color: var(--muted); }

.skeleton {
  background: linear-gradient(90deg, var(--ivory-2) 25%, var(--blush-soft) 37%, var(--ivory-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  height: 1rem;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 13. Site header & navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 249, 239, 0.94);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header::after {
  content: ''; display: block; height: 2px;
  background: linear-gradient(90deg, var(--burgundy) 0%, var(--gold) 50%, var(--burgundy) 100%);
  opacity: 0.65;
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.25rem;
  min-height: var(--nav-h);
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--burgundy); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 1.22rem; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.64rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold-600); font-weight: 600; }

.nav-links { display: flex; align-items: center; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.nav-links > li { min-width: 0; }
.nav-links a {
  display: block; padding: 0.5rem 0.7rem;
  font-size: 0.9rem; font-weight: 500;
  color: var(--ink-2); text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.16s var(--ease), background 0.16s var(--ease);
}
.nav-links a:hover { color: var(--burgundy); background: var(--burgundy-050); }
.nav-links a[aria-current='page'] { color: var(--burgundy); font-weight: 600; box-shadow: inset 0 -2px 0 var(--gold); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

/* The nav's Register CTA is an `<a class="btn btn-primary">`. The rule above
   targets `.nav-links a` (0,1,1), which outranks `.btn-primary` (0,1,0), so the
   button kept its burgundy fill but inherited the nav's `--ink-2` text colour:
   #4A3437 on #642B36, a contrast ratio of 1.06 and effectively black-on-black.
   Restate the button palette here so it wins on specificity, hover included. */
.nav-links a.btn { color: var(--ivory); }
.nav-links a.btn:hover { color: #fff; background: var(--burgundy-700); }
.nav-links a.btn.btn-outline { color: var(--burgundy); }
.nav-links a.btn.btn-outline:hover { color: var(--burgundy); background: var(--burgundy-050); }

.nav-toggle {
  display: none;
  background: none; border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem; cursor: pointer; color: var(--burgundy);
}
.nav-toggle span { display: block; width: 20px; height: 1.5px; background: currentColor; margin: 4px 0; transition: transform 0.2s var(--ease), opacity 0.2s var(--ease); }
.nav-toggle[aria-expanded='true'] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nav-toggle[aria-expanded='true'] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded='true'] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* ---------- 14. Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 78% 18%, rgba(223, 166, 161, 0.22), transparent 55%),
    linear-gradient(165deg, var(--burgundy-900) 0%, var(--burgundy) 55%, #7A3540 100%);
  color: var(--ivory);
  padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(3rem, 8vw, 5.5rem);
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400' fill='none' stroke='%23B78B3C' stroke-width='0.5' opacity='0.5'%3E%3Ccircle cx='200' cy='200' r='196'/%3E%3Ccircle cx='200' cy='200' r='150'/%3E%3Ccircle cx='200' cy='200' r='100'/%3E%3Cpath d='M200 4v392M4 200h392'/%3E%3Cpath d='M56 56l288 288'/%3E%3Ccircle cx='200' cy='200' r='4'/%3E%3C/svg%3E") right -8% top 50% translateY(-50%) / 460px no-repeat;
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.98 0 0 0 0 0.94 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}
.hero .shell { position: relative; z-index: 1; }
.hero-grid { display: grid; gap: clamp(2rem, 5vw, 3.5rem); align-items: center; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
.hero h1 { color: var(--ivory); margin-bottom: 0.75rem; }
.hero h1 .theta { color: var(--gold-300); font-style: italic; }
.hero-lead { font-size: clamp(1.02rem, 1.7vw, 1.2rem); color: var(--blush-soft); max-width: 54ch; }
.hero-eyebrow { color: var(--gold-300); }
.hero-eyebrow::before, .hero-eyebrow::after { background: rgba(216, 188, 126, 0.5); }
.hero-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; }
.hero-pill {
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  border: 1px solid rgba(216, 188, 126, 0.45);
  color: var(--gold-300); background: rgba(255, 249, 239, 0.06);
}
.hero-art { position: relative; display: grid; place-items: center; }
.astrolabe {
  width: 100%;
  max-width: 340px;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.3));
  animation: abc-arrive 1.2s cubic-bezier(0.22, 0.9, 0.28, 1) both;
}
/* Rotating an SVG child about the middle of the viewBox needs an explicit
   box and origin, otherwise each group turns about the browser's default. */
.astrolabe g { transform-box: view-box; transform-origin: 50% 50%; }

.astrolabe__ticks   { animation: abc-turn 84s linear infinite; }
.astrolabe__scale   { animation: abc-turn-back 56s linear infinite; }
.astrolabe__rete    { animation: abc-turn 40s linear infinite; }
.astrolabe__alidade { animation: abc-turn-back 68s linear infinite; }
.astrolabe__orbit-a { animation: abc-turn 22s linear infinite; }
.astrolabe__orbit-b { animation: abc-turn-back 15s linear infinite; }
.astrolabe__core    { animation: abc-breathe 5.5s ease-in-out infinite; }

@keyframes abc-turn       { to { transform: rotate(360deg); } }
@keyframes abc-turn-back  { to { transform: rotate(-360deg); } }
@keyframes abc-breathe {
  0%, 100% { opacity: 0.82; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.05); }
}
/* The entrance is the only thing that plays once. No `from { opacity: 0 }` on
   the element itself, so if animations are switched off entirely the astrolabe
   is still fully visible rather than stuck invisible at the first frame. */
@keyframes abc-arrive {
  from { opacity: 0; transform: rotate(-16deg) scale(0.8); }
  to   { opacity: 1; transform: rotate(0deg) scale(1); }
}
/* Anyone who asks for reduced motion gets the astrolabe as a still drawing.
   `animation: none` rather than a 0.01ms duration, so it rests on its natural
   state - fully drawn - instead of snapping to a rotated end frame. */
@media (prefers-reduced-motion: reduce) {
  .astrolabe, .astrolabe g { animation: none !important; }
}

.page-head {
  background: linear-gradient(180deg, var(--burgundy-050), var(--ivory));
  border-bottom: 1px solid var(--line);
  padding: clamp(2.5rem, 6vw, 4rem) 0;
}
.page-head h1 { margin-bottom: 0.4rem; }
.page-head .lead { font-size: 1.05rem; color: var(--ink-2); max-width: 70ch; }

.breadcrumb { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); margin-bottom: 0.85rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--burgundy); text-decoration: underline; }
.breadcrumb span[aria-current] { color: var(--burgundy); font-weight: 600; }

/* ---------- 15. Feature / round cards ---------- */
.round-card { display: flex; flex-direction: column; height: 100%; }
.round-index {
  font-family: var(--serif); font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-600);
}
.round-card h3 { margin: 0.35rem 0 0.5rem; }
.round-card .round-tagline { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--muted); margin-bottom: 0.75rem; }
.round-meta { list-style: none; margin: auto 0 0; padding: 1rem 0 0; border-top: 1px dashed var(--line-gold); font-size: 0.88rem; }
.round-meta li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.28rem 0; }
.round-meta li span:first-child { color: var(--muted); }
.round-meta li span:last-child { font-weight: 600; color: var(--ink-2); text-align: right; }

.timeline { position: relative; padding-left: 2.25rem; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--line-gold); }
.timeline-item { position: relative; padding-bottom: 1.75rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -2.25rem; top: 5px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ivory); border: 1px solid var(--gold);
  box-shadow: 0 0 0 4px var(--ivory);
}
.timeline-item.done::before { background: var(--gold); }
.timeline-item h4 { margin: 0 0 0.2rem; }

/* ---------- 15b. Dated timeline ---------- */
.timeline-events { list-style: none; margin: 0; padding: 0; }
.timeline-event + .timeline-event { margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px dotted var(--line-gold); }

/* The date sits on the spine rather than above the text, so a column of dates
   reads as a column. That is the whole point of the layout: a student scanning
   it is looking for "what day is it", not for a paragraph. */
.timeline-body { display: block; }
.timeline-date {
  display: inline-flex; align-items: baseline; gap: 0.4rem; margin-bottom: 0.3rem;
  font-family: var(--serif); line-height: 1;
}
.timeline-day { font-size: 1.7rem; font-weight: 700; color: var(--burgundy); }
.timeline-month { font-size: 0.82rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-600); }
.timeline-state { margin-bottom: 0.35rem; }

.timeline-item.done .timeline-day { color: var(--muted-2); }
.timeline-item.done .timeline-month { color: var(--muted-2); }
.timeline-item.done h4 { color: var(--muted); }

/* Whatever is next gets a gold rule down its side. Not the date that happens
   to be closest — the next one that has not passed yet — so the pointer is
   still in the right place on the morning of the day itself. */
.timeline-item[data-next] .timeline-body {
  border-left: 2px solid var(--gold); padding-left: 0.9rem; margin-left: -0.15rem;
}
.timeline-item[data-next] h4 { color: var(--burgundy); }
.timeline-now .timeline-day { color: var(--success); }
.timeline-now .timeline-month { color: var(--success); }
.timeline-span-note { margin: 0.5rem 0 0; }

/* Compact variant for the home page: the date and the headline only, with the
   detail kept for the full page. */
.timeline-compact .timeline-item { padding-bottom: 1.1rem; }
.timeline-compact .timeline-day { font-size: 1.35rem; }
.timeline-compact .timeline-event { display: inline; }
.timeline-compact .timeline-events { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }
.timeline-compact .timeline-event + .timeline-event { margin: 0; padding: 0; border: 0; }
.timeline-compact h4 { font-size: 0.95rem; }

/* The figure strip under the timeline: how long is left, in words. */
.timeline-countdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.timeline-countdown .card { padding: 1rem 1.1rem; text-align: center; }
.timeline-countdown .figure-value { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--burgundy); line-height: 1.1; }
.timeline-countdown .figure-label { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* ---------- 16. Portal (student) layout ---------- */
.portal { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 1.75rem; align-items: start; padding: 1.75rem 0 4rem; }
.portal-side { position: sticky; top: calc(var(--nav-h) + 1rem); }
.portal-user { padding: 1.15rem 1.2rem; border-bottom: 1px solid var(--line); }
.portal-user .name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--burgundy); line-height: 1.2; }
.portal-user .meta { font-size: 0.82rem; color: var(--muted); }
.portal-nav { list-style: none; margin: 0; padding: 0.6rem; }
.portal-nav li { margin: 0; }
.portal-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 0.92rem; font-weight: 500;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.portal-nav a:hover { background: var(--burgundy-050); color: var(--burgundy); }
.portal-nav a[aria-current='page'] { background: var(--burgundy); color: var(--ivory); font-weight: 600; }
.portal-nav a .nudge { margin-left: auto; }
.portal-nav .nav-section {
  font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted-2); padding: 1rem 0.75rem 0.4rem; font-weight: 700;
}
.portal-nav .glyph { width: 1.1em; text-align: center; color: var(--gold-600); }
.portal-nav a[aria-current='page'] .glyph { color: var(--gold-300); }

/* Progress stepper on dashboard */
.stepper { display: grid; gap: 0.9rem; }
.step {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0.9rem;
  padding: 1.05rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  position: relative;
}
.step + .step::before {
  content: ''; position: absolute; left: 1.9rem; top: -0.9rem; width: 1px; height: 0.9rem;
  background: var(--line-gold);
}
.step-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-gold); background: var(--ivory);
  font-family: var(--serif); font-weight: 600; color: var(--muted);
  font-size: 1.05rem;
}
.step.done .step-dot { background: var(--burgundy); border-color: var(--burgundy); color: var(--gold-300); }
.step.current .step-dot { background: var(--gold-050); border-color: var(--gold); color: var(--gold-600); box-shadow: 0 0 0 4px rgba(183, 139, 60, 0.14); }
.step-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--burgundy); display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.step-body { font-size: 0.92rem; color: var(--muted); }
.step-body .figures { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.35rem; }
.step-body .figure-label { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); display: block; }
.step-body .figure-value { font-family: var(--serif); font-size: 1.45rem; color: var(--burgundy); font-variant-numeric: tabular-nums; }

/* ---------- 17. Admin layout ---------- */
.admin-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.admin-side {
  background: linear-gradient(180deg, var(--burgundy-900), var(--burgundy-700));
  color: var(--ivory);
  padding: 1.25rem 0.9rem 2rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.6rem 1rem; margin-bottom: 0.75rem; border-bottom: 1px solid rgba(255, 249, 239, 0.16); }
.admin-brand .brand-name { color: var(--ivory); font-size: 1.1rem; }
.admin-brand .brand-sub { color: var(--gold-300); }
.admin-nav { list-style: none; margin: 0; padding: 0; }
.admin-nav a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  color: rgba(255, 249, 239, 0.82); text-decoration: none; font-size: 0.9rem;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.admin-nav a:hover { background: rgba(255, 249, 239, 0.1); color: #fff; }
.admin-nav a[aria-current='page'] { background: var(--burgundy); color: #fff; font-weight: 600; box-shadow: inset 2px 0 0 var(--gold); }
.admin-nav .glyph { width: 1.15em; text-align: center; color: var(--gold-300); }
.admin-nav .nav-section { font-size: 0.65rem; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(216, 188, 126, 0.7); padding: 1.1rem 0.7rem 0.35rem; font-weight: 700; }
.admin-main { min-width: 0; background: var(--ivory); }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.9rem clamp(1rem, 2.5vw, 1.9rem);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.admin-topbar h1 { font-size: 1.5rem; margin: 0; }
.admin-content { padding: clamp(1.1rem, 2.5vw, 1.9rem); }
.admin-content > * + * { margin-top: 1.5rem; }

.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .grow { flex: 1 1 220px; }

/* ---------- 18. Quiz ---------- */
.quiz-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5rem; align-items: start; }

.quiz-topbar {
  position: sticky; top: var(--nav-h); z-index: 60;
  background: var(--burgundy);
  color: var(--ivory);
  border-bottom: 2px solid var(--gold);
}
.quiz-topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.75rem 0; }
.quiz-topbar .q-label { font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--blush-soft); }
.quiz-timer {
  font-family: var(--mono); font-size: 1.35rem; font-weight: 500;
  color: var(--gold-300); font-variant-numeric: tabular-nums;
  padding: 0.2rem 0.7rem; border: 1px solid rgba(216, 188, 126, 0.4); border-radius: var(--radius-sm);
}
.quiz-timer.warn { color: #F0C36D; border-color: rgba(240, 195, 109, 0.6); }
.quiz-timer.critical { color: #F5B7B7; border-color: #F5B7B7; animation: pulse 1s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.quiz-progress { height: 4px; background: rgba(255, 249, 239, 0.2); border-radius: 999px; overflow: hidden; }
.quiz-progress-bar { height: 100%; background: var(--gold); transition: width 0.3s var(--ease); }

.quiz-nav-panel { position: sticky; top: calc(var(--nav-h) + 74px); }
.qindex { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 0.4rem; padding: 1rem; }
.qindex button {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--ivory); color: var(--ink-2);
  font-family: var(--mono); font-size: 0.82rem; cursor: pointer;
  transition: all 0.14s var(--ease);
}
.qindex button:hover { border-color: var(--gold); }
.qindex button.answered { background: var(--success-050); border-color: rgba(46, 107, 79, 0.45); color: var(--success); font-weight: 600; }
.qindex button.current { background: var(--burgundy); border-color: var(--burgundy); color: var(--gold-300); font-weight: 600; }
.qindex button.flagged { box-shadow: inset 0 0 0 1px var(--warning); }
.qindex button:disabled { cursor: default; opacity: 0.55; }

.quiz-card { padding: clamp(1.35rem, 3vw, 2.1rem); }
.quiz-meta { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quiz-question { font-family: var(--serif); font-size: clamp(1.2rem, 2.3vw, 1.5rem); line-height: 1.45; color: var(--ink); margin-bottom: 1.5rem; }
.quiz-question .notation { font-family: var(--serif); font-style: italic; color: var(--burgundy); }

.options { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: 0.7rem; }
.option {
  display: flex; align-items: flex-start; gap: 0.8rem;
  padding: 0.9rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ivory);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.option:hover { border-color: var(--line-gold); background: var(--ivory-2); }
.option input { margin-top: 0.22rem; width: 1.1em; height: 1.1em; accent-color: var(--burgundy); flex: none; }
.option .opt-key {
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-gold);
  font-family: var(--serif); font-weight: 600; font-size: 0.9rem; color: var(--gold-600);
  background: var(--paper);
}
.option:has(input:checked) { border-color: var(--gold); background: var(--gold-050); box-shadow: inset 0 0 0 1px var(--gold); }
.option:has(input:checked) .opt-key { background: var(--burgundy); border-color: var(--burgundy); color: var(--gold-300); }
.option .opt-text { flex: 1; }
.option:disabled { cursor: not-allowed; opacity: 0.75; }

.quiz-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding-top: 1.1rem; border-top: 1px dashed var(--line-gold); flex-wrap: wrap; }
.save-state { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.save-state.saving .dot { background: var(--warning); }
.save-state.error .dot { background: var(--danger); }

/* ---------- 19. Certificate ---------- */
.certificate {
  position: relative;
  background: var(--ivory);
  border: 2px solid var(--gold);
  padding: clamp(1.75rem, 4vw, 3rem);
  text-align: center;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.certificate::before {
  content: '';
  position: absolute; inset: 8px;
  border: 1px solid var(--line-gold);
  pointer-events: none;
}
.certificate::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400' fill='none' stroke='%23B78B3C' stroke-width='0.4' opacity='0.35'%3E%3Ccircle cx='200' cy='200' r='190'/%3E%3Ccircle cx='200' cy='200' r='160'/%3E%3Ccircle cx='200' cy='200' r='40'/%3E%3Cpath d='M200 10v380M10 200h380'/%3E%3C/svg%3E") center/cover no-repeat;
  pointer-events: none;
}
.certificate > * { position: relative; z-index: 1; }
.certificate .cert-kicker { font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-600); font-weight: 600; }
.certificate h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); margin: 0.6rem 0 0.4rem; }
.certificate .cert-name {
  font-family: var(--serif); font-size: clamp(1.5rem, 4vw, 2.3rem);
  color: var(--burgundy); border-bottom: 1px solid var(--line-gold);
  display: inline-block; padding: 0 1.5rem 0.3rem; margin: 0.6rem 0 1rem;
}
.certificate .cert-body { max-width: 62ch; margin-inline: auto; color: var(--ink-2); }
.certificate .cert-meta { margin-top: 1.75rem; display: flex; justify-content: space-around; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.certificate .cert-meta strong { display: block; color: var(--burgundy); font-size: 0.95rem; }
.cert-ribbon {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  background: var(--burgundy); color: var(--gold-300);
  padding: 0.3rem 0.9rem; border-radius: 2px;
}

/* ---------- 20. Leaderboard ---------- */
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line-gold); }
.leaderboard td { padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); }
.leaderboard .pos { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--burgundy); width: 4.5rem; }
.leaderboard tr.medal-1 { background: linear-gradient(90deg, rgba(183, 139, 60, 0.14), transparent 60%); }
.leaderboard tr.medal-2 { background: linear-gradient(90deg, rgba(157, 157, 157, 0.12), transparent 60%); }
.leaderboard tr.medal-3 { background: linear-gradient(90deg, rgba(205, 127, 50, 0.12), transparent 60%); }
.leaderboard .pts { font-family: var(--mono); font-weight: 500; }
.cutoff-note { font-size: 0.84rem; color: var(--muted); padding: 0.85rem 0.9rem; background: var(--ivory-2); border-top: 1px dashed var(--line-gold); }

.trophy { font-size: 1.35rem; }

/* ---------- 21. Auth pages ---------- */
.auth-page { display: grid; grid-template-columns: 1fr minmax(0, 480px); min-height: 100vh; }
.auth-aside {
  position: relative; overflow: hidden; padding: clamp(2.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, var(--burgundy-900), var(--burgundy) 70%, #7A3540);
  color: var(--ivory);
}
.auth-aside::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400' fill='none' stroke='%23B78B3C' stroke-width='0.5' opacity='0.55'%3E%3Ccircle cx='200' cy='200' r='196'/%3E%3Ccircle cx='200' cy='200' r='140'/%3E%3Ccircle cx='200' cy='200' r='84'/%3E%3Cellipse cx='200' cy='200' rx='196' ry='78'/%3E%3Cellipse cx='200' cy='200' rx='78' ry='196'/%3E%3Cpath d='M200 4v392M4 200h392'/%3E%3C/svg%3E") center/520px no-repeat;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside h1 { color: var(--ivory); }
.auth-aside p { color: var(--blush-soft); }
.auth-aside .steps { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 0.85rem; }
.auth-aside .steps li { display: flex; gap: 0.75rem; font-size: 0.94rem; color: var(--blush-soft); }
.auth-aside .steps .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgba(216, 188, 126, 0.5); color: var(--gold-300);
  display: grid; place-items: center; font-family: var(--serif); font-size: 0.85rem;
}
.auth-main { display: grid; place-items: center; padding: clamp(2rem, 5vw, 3.5rem) 1.5rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1.5rem; }
.auth-tabs button {
  font-family: var(--sans); font-size: 0.92rem; font-weight: 600; padding: 0.7rem;
  background: var(--ivory-2); color: var(--muted); border: 0; cursor: pointer;
}
.auth-tabs button[aria-selected='true'] { background: var(--burgundy); color: var(--ivory); }

/* ---------- 22. Footer ---------- */
.site-footer {
  margin-top: 3rem;
  background: linear-gradient(180deg, var(--burgundy-900), #2B1017);
  color: var(--blush-soft);
  padding: clamp(2.5rem, 5vw, 3.5rem) 0 1.5rem;
  position: relative;
}
.site-footer::before {
  content: ''; position: absolute; inset-inline: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--burgundy), var(--gold), var(--burgundy));
}
.site-footer a { color: var(--blush-soft); text-decoration: none; }
.site-footer a:hover { color: var(--gold-300); text-decoration: underline; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.footer-grid h4 { color: var(--gold-300); font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 0.85rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; font-size: 0.9rem; }
.footer-brand .brand-name { color: var(--ivory); }
.footer-brand .brand-sub { color: var(--gold-300); }
.footer-base { margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid rgba(255, 249, 239, 0.14); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; color: rgba(223, 166, 161, 0.75); }

/* ---------- 23. Misc components ---------- */
.countdown { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.countdown .unit {
  min-width: 78px; text-align: center;
  background: rgba(255, 249, 239, 0.08);
  border: 1px solid rgba(216, 188, 126, 0.3);
  border-radius: var(--radius-sm); padding: 0.6rem 0.5rem;
}
.countdown .unit .n { font-family: var(--mono); font-size: 1.5rem; color: var(--gold-300); display: block; }
.countdown .unit .l { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blush-soft); }

.tabs-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  font-family: var(--sans); font-size: 0.84rem; font-weight: 500;
  padding: 0.42rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--ivory); color: var(--ink-2);
  cursor: pointer; transition: all 0.15s var(--ease);
}
.chip:hover { border-color: var(--line-gold); }
.chip[aria-pressed='true'] { background: var(--burgundy); border-color: var(--burgundy); color: var(--ivory); font-weight: 600; }

.prize-card { text-align: center; position: relative; overflow: hidden; }
.prize-card .amount { font-family: var(--serif); font-size: 2.2rem; color: var(--burgundy); line-height: 1.1; }
.prize-card .amount small { font-size: 1rem; color: var(--muted); display: block; font-family: var(--sans); letter-spacing: 0.1em; text-transform: uppercase; }
.prize-card .glyph-lg { font-size: 2.6rem; color: var(--gold); display: block; margin-bottom: 0.5rem; }
.prize-card.winner { border-top: 3px solid var(--gold); }
.prize-card.runner { border-top: 3px solid var(--blush); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.1rem; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }

.callout {
  border-left: 3px solid var(--gold);
  background: var(--gold-050);
  padding: 1.1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.94rem;
}

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting-row:last-child { border-bottom: 0; }
.setting-row .name { font-weight: 600; }
.setting-row .desc { font-size: 0.85rem; color: var(--muted); }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--muted-2); border-radius: 999px; transition: background 0.18s var(--ease); cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.18s var(--ease); }
.switch input:checked + .track { background: var(--burgundy); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

.import-drop {
  border: 2px dashed var(--line-gold); border-radius: var(--radius);
  padding: 2.25rem 1.5rem; text-align: center; background: var(--ivory-2);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease);
}
.import-drop.dragging { background: var(--gold-050); border-color: var(--gold); }

.diff-strip { display: inline-flex; border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.diff-strip span { font-size: 0.7rem; padding: 0.15rem 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; }
.diff-easy { background: var(--success-050); color: var(--success); }
.diff-medium { background: var(--warning-050); color: var(--warning); }
.diff-hard { background: var(--danger-050); color: var(--danger); }

.qa-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); align-items: start; }
.qa-row:last-child { border-bottom: 0; }
.qa-text { font-size: 0.93rem; }
.qa-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }

.announcement {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 1.1rem;
  padding: 1.35rem 0; border-bottom: 1px solid var(--line);
}
.announcement:last-child { border-bottom: 0; }
.announcement .date-block { text-align: center; border: 1px solid var(--line-gold); border-radius: var(--radius-sm); padding: 0.5rem 0.25rem; background: var(--ivory-2); }
.announcement .date-block .d { font-family: var(--serif); font-size: 1.5rem; line-height: 1; color: var(--burgundy); }
.announcement .date-block .m { font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.announcement h3 { font-size: 1.15rem; margin-bottom: 0.3rem; }
.announcement .body { font-size: 0.93rem; color: var(--ink-2); }
.announcement .audience { font-size: 0.76rem; color: var(--muted); margin-top: 0.5rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

/* ---------- 24. Responsive ---------- */
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { order: -1; max-width: 260px; margin-inline: auto; }
  .admin-shell { grid-template-columns: 220px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .portal { grid-template-columns: 1fr; }
  .portal-side { position: static; }
  .portal-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.25rem; }
  .portal-nav .nav-section { display: none; }
  .quiz-shell { grid-template-columns: 1fr; }
  .quiz-nav-panel { position: static; }
  .qindex { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { order: 2; padding: 2.5rem 1.5rem; }
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side {
    position: fixed; inset: 0 auto 0 0; z-index: 200;
    width: 272px; transform: translateX(-100%);
    transition: transform 0.24s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .admin-side.open { transform: none; }
  .admin-scrim { position: fixed; inset: 0; z-index: 190; background: rgba(52, 19, 26, 0.5); }
  .admin-topbar { padding-left: 1rem; }
  .admin-menu-btn { display: inline-flex !important; }
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line-gold);
    box-shadow: var(--shadow-md);
    padding: 0.5rem 1rem 1rem;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-links li:last-child { margin-top: 0.6rem; }
  .shell, .shell-narrow { width: min(100% - 1.75rem, var(--shell)); }
  .quiz-topbar { top: 0; }
  .certificate { padding: 1.5rem 1.1rem; }
  .certificate::before { inset: 5px; }
  .announcement { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

@media (max-width: 480px) {
  body { font-size: 15.5px; }
  .stat-value { font-size: 1.7rem; }
  .btn { padding: 0.66rem 1.1rem; }
  .btn-row .btn { flex: 1 1 100%; }
  .quiz-nav { flex-direction: column-reverse; align-items: stretch; }
  .quiz-nav .btn { width: 100%; }
}

.admin-menu-btn { display: none; }

@media print {
  .site-header, .site-footer, .portal-side, .admin-side, .admin-topbar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .certificate { box-shadow: none; page-break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   Password visibility toggle
   ============================================================
   The input and the button sit in one relative box so the button can overlap
   the field without affecting the field's own padding. The padding-right is
   what keeps the typed text from running underneath the icon. */
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap .input {
  padding-right: 3rem;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--gold-600);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.password-toggle:hover {
  background: rgba(139, 105, 20, .1);
  color: var(--burgundy);
}
/* The focus ring is on the button, and it is deliberately visible: the whole
   point of the control is to be reachable without a mouse. */
.password-toggle:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 1px;
}
.password-toggle .eye-icon {
  display: block;
  width: 20px;
  height: 20px;
}

/* ============================================================
   Google sign-in
   ============================================================ */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #fff;
  color: #3c4043;
  border: 1px solid var(--line, #d8cfc0);
  font-weight: 600;
}
.btn-google:hover:not(:disabled) {
  background: #f7f5f1;
  border-color: var(--gold-600);
  color: var(--burgundy);
}
.btn-google:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.btn-google .google-mark {
  display: block;
  flex: none;
}

/* The rule that divides password sign-in from Google sign-in. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--ink-soft);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .14em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line, #d8cfc0);
}

/* ============================================================
   Official logos
   ============================================================
   The organiser's untouched master artwork lives in `logos/`. Both files are
   square 1000x1000 canvases holding a wide wordmark, so each canvas carries a
   lot of transparent margin:

     logos/albiruni.png     visible mark 957 x 470  (2.04:1)
     logos/mathsimized.png  visible mark 925 x 714  (1.30:1)

   Nothing here redraws, recolours, crops or regenerates that artwork - the
   <img> is always the original file. `--logo-h` is the rendered *canvas*
   height and `--logo-trim` is half the canvas's vertical transparent margin,
   which lets the two variants reclaim that margin as pure CSS so the visible
   wordmark, not the empty canvas, sets the layout box.

   On light surfaces `brand-logo--trim` pulls the margin back with a negative
   block margin. On the dark burgundy panels (hero, auth aside, admin sidebar,
   footer) `brand-logo--plate` puts the dark artwork on an ivory plate so it
   stays legible without the file being touched.                          */
.brand-logo {
  --logo-h: 78px;
  --logo-trim: 0.265;                 /* Al-Biruni: 26.5% top + 26.5% bottom */
  --plate-pad: 0.1;                   /* share of --logo-h kept clear inside the circle */
  display: block;
  /* Both axes are pinned to the canvas height so the square box is reserved
     before the file decodes - a lazy-loaded logo in the footer would otherwise
     collapse horizontally for a moment and shift the page. */
  width: var(--logo-h);
  height: var(--logo-h);
  max-width: min(80vw, 280px);
  object-fit: contain;
  object-position: center;
}
.brand-logo--mathsimized {
  --logo-trim: 0.143;                 /* 14.3% top + 14.3% bottom */
  --plate-pad: 0.16;                  /* its 1.30:1 mark sits taller in the circle */
}

/* Reclaim the canvas's transparent margin: the outer box collapses from
   --logo-h down to the visible mark, so flex centring lines up on the art. */
.brand-logo--trim {
  margin-block: calc(var(--logo-h) * var(--logo-trim) * -1);
}

/* Ivory plate for the dark burgundy panels. The canvas keeps its own
   transparent margin, which reads here as deliberate tile padding. */
.brand-logo--plate {
  margin-block: 0;
  /* A square canvas in a circle: padding is uniform so the wordmark keeps an
     even margin all the way round, and --logo-h is the circle's diameter. */
  padding: calc(var(--logo-h) * var(--plate-pad));
  background: var(--ivory);
  border: 1px solid rgba(216, 188, 126, 0.55);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

/* Per-surface sizes. Light surfaces trim, dark surfaces get a plate. */
.site-header .brand-logo                  { --logo-h: 78px; }
[data-brand-card] .brand-logo            { --logo-h: 168px; }
.auth-aside .brand-logo                   { --logo-h: 92px; }
.admin-brand .brand-logo                  { --logo-h: 64px; }
.site-footer .brand-logo                  { --logo-h: 92px; }
.site-footer .brand-logo--mathsimized     { --logo-h: 58px; }

.brand-logo-fallback { display: none; }
/* The official wordmark already spells the name, so the text wordmark steps
   aside. The small "by MATHSIMIZED" / section line stays visible. */
.brand.has-logo .brand-name { display: none; }
.brand:not(.has-logo) .brand-logo { display: none; }

@media (max-width: 480px) {
  .site-header .brand-logo              { --logo-h: 58px; }
  [data-brand-card] .brand-logo        { --logo-h: 132px; }
  .auth-aside .brand-logo               { --logo-h: 76px; }
  .site-footer .brand-logo              { --logo-h: 76px; }
  .site-footer .brand-logo--mathsimized { --logo-h: 50px; }
}

/* ============================================================
   Brand Ambassador dropdown + eligibility states
   ============================================================ */
.ba-select-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  align-items: end;
}

/* Four eligibility states, each with its own colour. Colour alone is not the
   only signal — every badge carries its label as text. */
.eligibility-badge { font-weight: 600; }
.eligibility-not-submitted { color: var(--ink-soft); }
.eligibility-under-review { color: var(--gold-700, #8a6914); }
.eligibility-action-required { color: #a4341f; }
.eligibility-verified { color: #1f6b4a; }

/* The organiser's message to a student who must send another document. It is
   quoted verbatim, so it needs to read as someone speaking to them. */
.admin-message {
  border-left: 3px solid var(--gold-600);
  background: var(--blush, #fbf1ee);
  padding: .9rem 1rem;
  border-radius: 0 .4rem .4rem 0;
  font-size: .95rem;
  line-height: 1.6;
}
.admin-message strong {
  display: block;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--gold-600);
  margin-bottom: .3rem;
}

/* The three reassurances on the registration aside. They answer the questions a
   student actually asks before typing an email address. */
.auth-aside-points {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  font-size: .9rem;
  line-height: 1.6;
  color: rgba(223, 166, 161, .9);
}
.auth-aside-points li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: .55rem;
}
.auth-aside-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #D8BC7E;
}
