:root {
  color-scheme: light;
  --ink: #102334;
  --muted: #5e7182;
  --navy: #17324d;
  --navy-2: #234d6f;
  --teal: #0e7c7b;
  --teal-dark: #08605f;
  --cream: #f5f1e8;
  --paper: #fffdfa;
  --line: #dbe3e7;
  --danger: #a33d3d;
  --success: #24705a;
  --shadow: 0 18px 50px rgba(20, 48, 70, 0.12);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

* {
  box-sizing: border-box;
}
html {
  min-height: 100%;
  background: var(--cream);
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(14, 124, 123, 0.12), transparent 28rem),
    linear-gradient(145deg, #f9f6ef, #eef4f3);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
a {
  color: var(--teal-dark);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: white;
  background: var(--navy);
  box-shadow: 0 8px 20px rgba(23, 50, 77, 0.2);
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.user-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid rgba(219, 227, 231, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 42px);
}
.auth-card {
  width: min(520px, calc(100% - 32px));
  margin: 8vh auto 0;
}
.eyebrow {
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1,
h2,
h3 {
  color: var(--navy);
  line-height: 1.12;
  margin: 0.35em 0;
}
h1 {
  font-size: clamp(34px, 6vw, 58px);
  letter-spacing: -0.045em;
}
h2 {
  font-size: clamp(25px, 3vw, 34px);
  letter-spacing: -0.03em;
}
p {
  line-height: 1.62;
}
.lede {
  color: var(--muted);
  font-size: 17px;
  margin-bottom: 28px;
}
.field {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}
.field label {
  font-weight: 750;
  font-size: 14px;
}
input,
textarea,
select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd7dc;
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition:
    0.18s border,
    0.18s box-shadow;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(14, 124, 123, 0.12);
}
textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
  text-decoration: none;
  transition:
    transform 0.15s,
    background 0.15s;
}
.button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.button.secondary {
  color: var(--navy);
  background: #e8eff1;
}
.button.danger {
  background: var(--danger);
}
.button.ghost {
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--line);
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}
.full {
  width: 100%;
}

.notice {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 16px 0;
  background: #edf6f4;
  color: #225f54;
  border: 1px solid #cbe4dd;
  line-height: 1.45;
}
.notice.error {
  color: #823333;
  background: #fbefef;
  border-color: #efcccc;
}
.notice.warn {
  color: #72591c;
  background: #fff8df;
  border-color: #eadb9c;
}
.muted {
  color: var(--muted);
}
.hidden {
  display: none !important;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.exam-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: start;
}
.exam-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.progress {
  height: 8px;
  border-radius: 99px;
  background: #e5ecee;
  overflow: hidden;
  margin: 16px 0 28px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #2ca59c);
  border-radius: inherit;
  transition: width 0.25s;
}
.timer-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
}
.timer {
  border-radius: 18px;
  padding: 19px;
  color: white;
  background: var(--navy);
}
.timer-label {
  color: #bcd0df;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}
.timer-value {
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 850;
  letter-spacing: -0.04em;
  margin-top: 2px;
}
.timer.urgent {
  background: var(--danger);
}
.small-card {
  background: rgba(255, 253, 250, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 17px;
}
.option-list {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}
.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}
.option:has(input:checked) {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.1);
}
.option input {
  width: 18px;
  height: 18px;
}
.option-letter {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #eaf1f2;
  font-weight: 850;
}
.matching-grid {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}
.matching-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: #f4f7f7;
}
.save-state {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}
.rules {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
}
.rules li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  line-height: 1.48;
}
.rules li::before {
  content: '✓';
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: white;
  background: var(--teal);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.stat-value {
  color: var(--navy);
  font-size: 28px;
  font-weight: 850;
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
}
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 20px 0;
}
.section {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}
th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
th {
  color: #fff;
  background: var(--navy);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tr:last-child td {
  border-bottom: 0;
}
.badge {
  display: inline-flex;
  border-radius: 99px;
  padding: 5px 9px;
  background: #eaf1f2;
  color: var(--navy);
  font-size: 11px;
  font-weight: 850;
}
.badge.good {
  background: #e4f3ed;
  color: var(--success);
}
.badge.warn {
  background: #fff2ce;
  color: #765812;
}
dialog {
  width: min(900px, calc(100% - 28px));
  max-height: 88vh;
  border: 0;
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.3);
}
dialog::backdrop {
  background: rgba(12, 30, 44, 0.68);
}
.dialog-body {
  padding: 26px;
  overflow: auto;
  max-height: 88vh;
}
.answer-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
}
.answer-card pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f4f7f7;
  padding: 12px;
  border-radius: 10px;
}

@media (max-width: 800px) {
  .exam-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .timer-panel {
    position: static;
    grid-template-columns: 1fr 1fr;
    order: -1;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .matching-row {
    grid-template-columns: 1fr;
  }
  .user-strip span {
    display: none;
  }
}

@media (max-width: 500px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 14px;
  }
  .card {
    border-radius: 18px;
    padding: 20px;
  }
  .timer-panel {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .exam-head {
    display: block;
  }
}
