:root {
  color-scheme: light;
  --charcoal: #2d3436;
  --pink: #ff6b9d;
  --magenta: #d94a8e;
  --paper: #ffffff;
  --neutral: #f7f6f4;
  --muted: #565d60;
  --line: #d8d6d2;
  --danger: #8d183f;
  --danger-bg: #fff0f5;
  --warning-bg: #fff5d9;
  --success: #286044;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--charcoal);
  background: var(--neutral);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--neutral);
}

[hidden] { display: none !important; }

a { color: var(--charcoal); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--pink); }

.skip-link {
  opacity: 0;
  position: fixed;
  z-index: 20;
  left: 16px;
  top: 8px;
  transform: translateY(-150%);
  padding: 8px 12px;
  background: var(--paper);
  border: 2px solid var(--charcoal);
}

.skip-link:focus { transform: translateY(0); opacity: 1; }

.site-header,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(20px, calc((100vw - 1120px) / 2));
  color: var(--paper);
  background: var(--charcoal);
}

.site-header { min-height: 64px; border-bottom: 4px solid var(--pink); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.brand span {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 4px;
  color: var(--charcoal);
  background: var(--pink);
}

.product-name { font-weight: 700; }

.workspace {
  width: min(100% - 32px, 960px);
  min-height: calc(100vh - 150px);
  margin: 32px auto 56px;
}

.workspace-wide { width: min(100% - 32px, 1280px); }

.panel,
.assessment-heading,
.question-section,
.submit-panel,
#candidate-panel,
.admin-page #admin-view > section {
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--pink);
  border-radius: 4px;
  background: var(--paper);
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 { margin-bottom: 16px; font-size: clamp(1.75rem, 4vw, 2rem); line-height: 1.2; }
h2 { margin-bottom: 12px; font-size: 1.35rem; line-height: 1.3; }
h3 { margin-bottom: 8px; font-size: 1.08rem; }

.eyebrow {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.lede { max-width: 72ch; font-size: 1.08rem; }

.instruction-list,
.rules ul { padding-left: 24px; }

.instruction-list li,
.rules li { margin: 8px 0; }

.sitting-details {
  margin: 24px 0;
  padding: 20px;
  background: var(--neutral);
}

dl { margin: 0; }

dl > div {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 3fr;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

dl > div:last-child { border-bottom: 0; }
dt { color: var(--muted); font-weight: 700; }
dd { margin: 0; }

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--charcoal);
  border-radius: 4px;
  background: var(--paper);
}

.notice p:last-child { margin-bottom: 0; }
.notice-error { border-color: var(--danger); background: var(--danger-bg); }
.notice-warning { border-color: #9b6900; background: var(--warning-bg); }

.check-row {
  display: flex;
  min-height: 44px;
  align-items: flex-start;
  gap: 12px;
  margin: 24px 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.check-row input {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--charcoal);
}

button,
input,
textarea { font: inherit; font-size: 1rem; }

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid #777d7f;
  border-radius: 4px;
  color: var(--charcoal);
  background: var(--paper);
}

textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
}

:focus-visible {
  outline: 3px solid var(--magenta);
  outline-offset: 3px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 2px solid var(--charcoal);
  border-radius: 4px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
}

.button-primary { color: var(--paper); background: var(--charcoal); }
.button-primary:hover:not(:disabled) { color: var(--charcoal); background: var(--pink); }
.button-secondary { color: var(--charcoal); background: var(--paper); }
.button-secondary:hover:not(:disabled) { background: #ffe5ee; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-compact { padding: 7px 11px; font-size: .9rem; }

.attempt-bar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(150px, .7fr) minmax(230px, 1.6fr);
  gap: 16px;
  padding: 10px max(20px, calc((100vw - 960px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.attempt-bar > div { display: flex; flex-direction: column; }
.attempt-bar strong { line-height: 1.35; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.2rem; }
.deadline-at { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.timer-urgent { color: var(--danger); }
.save-block { min-width: 0; }

.assessment-heading,
.question-section,
.submit-panel,
#candidate-panel { margin-bottom: 24px; }

.rules {
  max-width: 72ch;
  margin-top: 20px;
  padding: 16px;
  border-left: 4px solid var(--pink);
  background: var(--neutral);
}

.rules h2 { font-size: 1.05rem; }

.section-heading,
.admin-heading,
.submit-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.section-heading > p { max-width: 420px; color: var(--muted); }

.data-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.data-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.table-region {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
}

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { white-space: nowrap; background: var(--neutral); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #fbfaf9; }

.question-section > header {
  margin: -24px -24px 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--neutral);
}

.question-group + .question-group { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
.question-group label { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 5px; font-weight: 700; }
.question-id { flex: 0 0 auto; padding: 1px 6px; border-radius: 4px; background: var(--pink); font-size: .8rem; }
.question-hint, .character-limit { margin-bottom: 8px; color: var(--muted); font-size: .9rem; }
.character-limit { margin-top: 4px; text-align: right; }

.submit-panel { border-top-color: var(--charcoal); }
.submit-panel p:last-child { margin-bottom: 0; }

dialog {
  width: min(100% - 32px, 520px);
  padding: 24px;
  border: 2px solid var(--charcoal);
  border-radius: 4px;
  color: var(--charcoal);
  background: var(--paper);
}

dialog::backdrop { background: rgb(45 52 54 / 70%); }
.dialog-actions, .action-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.receipt dd { overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; }

footer { min-height: 54px; color: #f7f6f4; font-size: .875rem; }
footer a { color: var(--paper); }

.login-panel { width: min(100%, 520px); margin-inline: auto; }
.login-panel form { display: grid; gap: 8px; margin-top: 20px; }
.login-panel form .button { margin-top: 8px; }
.admin-heading { margin-bottom: 24px; }
.admin-heading h1 { margin-bottom: 0; }
.admin-candidate-heading { align-items: flex-end; }
.admin-candidate-heading h2 { margin-bottom: 2px; }
.admin-candidate-heading p:last-child { margin-bottom: 0; }
.secondary-line { display: block; margin-top: 2px; color: var(--muted); }
.summary-line { font-weight: 700; }
.empty-state { padding: 16px; border: 1px dashed var(--line); background: var(--paper); }
.code-cell { font-family: ui-monospace, Consolas, monospace; font-weight: 700; white-space: nowrap; }
.timing-cell { min-width: 180px; }
.admin-page table:not(.candidate-table) { min-width: 660px; }
.candidate-table { min-width: 1060px; }
.candidate-table td:last-child { min-width: 300px; }
.incident-controls { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 8px; }

.status-badge { display: inline-block; padding: 2px 7px; border: 1px solid currentColor; border-radius: 4px; white-space: nowrap; font-size: .82rem; font-weight: 700; }
.status-submitted { color: var(--success); background: #edf8f1; }
.status-expired { color: var(--danger); background: var(--danger-bg); }
.status-in-progress { color: #704900; background: var(--warning-bg); }

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

@media (max-width: 760px) {
  .workspace { width: min(100% - 20px, 960px); margin-top: 20px; }
  .site-header, footer { padding-inline: 12px; }
  .product-name { font-size: .9rem; }
  .attempt-bar { grid-template-columns: 1fr 1fr; padding: 8px 12px; }
  .save-block { grid-column: 1 / -1; padding-top: 6px; border-top: 1px solid var(--line); }
  .data-stack { grid-template-columns: 1fr; }
  .section-heading, .admin-heading, .submit-panel, .admin-candidate-heading { align-items: stretch; flex-direction: column; }
  .section-heading > p { max-width: none; }
  .action-row { justify-content: flex-start; }
  .submit-panel .button { width: 100%; }
  dl > div { grid-template-columns: 1fr; gap: 0; }
  .panel, .assessment-heading, .question-section, .submit-panel, #candidate-panel, .admin-page #admin-view > section { padding: 18px; }
  .question-section > header { margin: -18px -18px 20px; padding: 14px 18px; }
}

@media (max-width: 480px) {
  .incident-controls { grid-template-columns: 1fr; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  footer { align-items: flex-start; flex-direction: column; }
}
