:root {
  --bg: #f4f5fb;
  --panel: #ffffff;
  --ink: #161a2b;
  --muted: #6b7280;
  --muted-soft: #9aa1b2;
  --line: #e5e7f0;
  --line-strong: #d7dae6;

  --primary: #4f46e5;
  --primary-dark: #3f37c9;
  --primary-soft: #eef0fe;
  --primary-ring: rgba(79, 70, 229, 0.18);

  --green: #16a34a;
  --green-soft: #eafbf1;
  --green-line: #a7e3c1;

  --amber: #d97706;
  --amber-soft: #fff6e6;
  --amber-line: #f0cf8e;

  --red: #dc2626;
  --red-soft: #fdecec;
  --red-line: #f0b4ae;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05), 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 8px 24px rgba(23, 27, 55, 0.08);
  --shadow-lg: 0 24px 60px rgba(23, 27, 55, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Legacy token aliases (admin.css still references these names) */
  --blue: var(--primary);
  --blue-dark: var(--primary-dark);
  --soft-blue: var(--primary-soft);
  --soft-green: var(--green-soft);
  --soft-amber: var(--amber-soft);
  --shadow: var(--shadow-lg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 480px at 12% -10%, rgba(79, 70, 229, 0.10), transparent),
    radial-gradient(900px 420px at 100% 0%, rgba(22, 163, 74, 0.07), transparent),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  font-family: var(--font);
}

::selection {
  background: var(--primary-ring);
}

.app-shell {
  min-height: 100vh;
  padding: 28px 20px;
}

.auth-panel,
.schedule-panel,
.exam-panel,
.result-panel {
  width: min(1200px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-panel,
.schedule-panel {
  max-width: 620px;
}

.auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 30px 32px 24px;
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 6px 32px 32px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: #fbfbfe;
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 600;
  font-size: 14px;
}

.instruction-box {
  margin: 0 32px 22px;
  border: 1px solid var(--primary-ring);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
  line-height: 1.5;
  font-size: 14px;
}

.scheduled-tests {
  display: grid;
  gap: 12px;
  padding: 0 32px 32px;
}

.scheduled-test-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  background: white;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.scheduled-test-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--line-strong);
}

.scheduled-test-card strong,
.scheduled-test-card span,
.scheduled-test-card em {
  display: block;
}

.scheduled-test-card strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.3;
  font-weight: 700;
}

.scheduled-test-card span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
  font-size: 13.5px;
}

.scheduled-test-card em {
  margin-top: 8px;
  color: var(--amber);
  font-style: normal;
  font-weight: 700;
  font-size: 13.5px;
}

.scheduled-test-card.completed {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.scheduled-test-card.completed em {
  color: var(--green);
}

.scheduled-actions {
  display: grid;
  gap: 8px;
}

.done-chip {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--green-line);
  padding: 0 16px;
  background: white;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}

.empty-state {
  margin: 0;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  padding: 20px;
  background: #fafafe;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: #fbfbfe;
}

.admin-link {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.secret-admin-trigger {
  cursor: pointer;
  user-select: none;
}

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

h1 {
  margin-bottom: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.timer {
  min-width: 128px;
  padding: 9px 16px;
  border: 1.5px solid var(--green-line);
  border-radius: var(--radius-pill);
  background: var(--green-soft);
  text-align: right;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.timer-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timer strong {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: color 0.25s ease;
}

.timer.timer-warn {
  border-color: var(--amber-line);
  background: var(--amber-soft);
}

.timer.timer-warn strong {
  color: var(--amber);
}

.timer.timer-danger {
  border-color: var(--red-line);
  background: var(--red-soft);
  animation: timer-pulse 1s ease-in-out infinite;
}

.timer.timer-danger strong {
  color: var(--red);
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.content-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 130px);
}

.sidebar {
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfbfe;
}

.candidate {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.candidate span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--primary), var(--primary-dark));
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  color: var(--muted);
  font-size: 12.5px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: #cbd1dc;
}

.dot.answered {
  background: var(--green);
}

.dot.current {
  background: var(--primary);
}

.dot.review {
  background: var(--amber);
}

.progress-box {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: #e6e8f2;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--primary), #7c73f0);
  transition: width 0.25s ease;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin-bottom: 22px;
}

.nav-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.nav-btn.current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.nav-btn.answered {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green);
}

.nav-btn.review {
  background: var(--amber-soft);
  border-color: var(--amber-line);
  color: var(--amber);
}

.question-card {
  display: flex;
  flex-direction: column;
  padding: 32px 36px;
}

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question-card h2 {
  min-height: 60px;
  margin-bottom: 24px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.5;
  white-space: pre-line;
  letter-spacing: -0.01em;
}

.question-image {
  display: block;
  width: min(520px, 100%);
  max-height: 360px;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  object-fit: contain;
  background: white;
}

.stimulus-panel {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfbfe;
  overflow: hidden;
}

.stimulus-rule {
  border-bottom: 1px solid var(--line);
  padding: 11px 16px;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 13px;
  background: var(--primary-soft);
}

.stimulus-text {
  max-height: 380px;
  overflow: auto;
  margin: 0;
  padding: 18px 20px;
  font-size: 18px;
  line-height: 1.7;
  white-space: pre-line;
}

.stimulus-image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-bottom: 1px solid var(--line);
  background: white;
}

.options {
  display: grid;
  gap: 11px;
}

.option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}

.option:hover {
  border-color: var(--primary-ring);
  transform: translateY(-1px);
}

.option .option-letter {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: 12px;
  border-radius: 50%;
  background: #eef0f6;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
}

.option input {
  display: none;
}

.option span.option-text {
  padding: 15px 16px 15px 12px;
  font-size: 16.5px;
  line-height: 1.5;
}

.progress-box {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option.selected .option-letter {
  background: var(--primary);
  color: white;
}

.question-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 28px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  min-height: 44px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-btn {
  background: var(--ink);
  color: white;
}

.ghost-btn {
  border-color: var(--line-strong);
  background: white;
  color: var(--ink);
}

.ghost-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.danger-btn {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}

.danger-btn:hover {
  filter: brightness(0.97);
}

.result-panel {
  padding: 0;
}

.result-panel > h2,
.result-panel > p {
  padding-left: 32px;
  padding-right: 32px;
}

.result-panel > h2 {
  padding-top: 32px;
}

.result-actions {
  padding: 4px 32px 32px;
}

.review-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 32px 32px;
}

.review-milestones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 7px;
}

.review-milestone {
  min-height: 42px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.1s ease;
}

.review-milestone:hover {
  transform: translateY(-1px);
}

.review-milestone.correct {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green);
}

.review-milestone.wrong,
.review-milestone.unanswered {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}

.review-milestone.no-key {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
}

.review-milestone.active {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.review-detail-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: white;
}

.review-detail-card h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
}

.review-stimulus-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfbfe;
  overflow: hidden;
}

.review-stimulus-rule {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 12.5px;
}

.review-stimulus-image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-bottom: 1px solid var(--line);
  background: white;
}

.review-stimulus-text {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-line;
}

.review-question-block {
  display: grid;
  gap: 8px;
}

.review-question-block > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.review-status {
  justify-self: start;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line);
  padding: 6px 14px;
  font-weight: 800;
  font-size: 12.5px;
}

.review-status.correct {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green);
}

.review-status.wrong,
.review-status.unanswered {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}

.review-status.no-key {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
}

.review-question-image {
  width: min(720px, 100%);
  max-height: 340px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
}

.review-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
}

.review-answer-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #fbfbfe;
}

.review-answer-box.correct {
  border-left: 4px solid var(--green);
}

.review-answer-box.wrong {
  border-left: 4px solid var(--red);
}

.review-answer-box h4,
.review-explanation h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.review-answer-box p,
.review-explanation p {
  margin: 0;
  line-height: 1.55;
}

.review-option-list {
  display: grid;
  gap: 8px;
}

.review-option-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  overflow: hidden;
}

.review-option-row strong {
  display: grid;
  min-height: 44px;
  place-items: center;
  margin: 0;
  background: #f6f7fb;
  color: var(--muted);
  font-size: 12.5px;
}

.review-option-row span {
  padding: 12px 14px;
  line-height: 1.5;
}

.review-option-row.correct {
  border-color: var(--green-line);
  background: var(--green-soft);
}

.review-option-row.correct strong {
  background: var(--green);
  color: white;
}

.review-option-row.wrong {
  border-color: var(--red-line);
  background: var(--red-soft);
}

.review-option-row.wrong strong {
  background: var(--red);
  color: white;
}

.review-explanation {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}

.review-item.correct {
  border-left: 4px solid var(--green);
}

.review-item.wrong {
  border-left: 4px solid var(--red);
}

.review-item strong {
  display: block;
  margin-bottom: 8px;
}

.score-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0 32px 22px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-soft), #ffffff);
}

.score-gauge {
  --pct: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), #e3e5f3 0);
}

.score-gauge::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: white;
  box-shadow: inset 0 0 0 1px var(--line);
}

.score-gauge strong {
  position: relative;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
}

.score-summary-text strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
}

.score-summary-text span {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

@media (max-width: 780px) {
  .app-shell {
    padding: 12px;
  }

  .auth-panel,
  .schedule-panel,
  .exam-panel,
  .result-panel {
    border-radius: var(--radius-md);
  }

  .topbar,
  .auth-head,
  .question-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .scheduled-test-card {
    grid-template-columns: 1fr;
  }

  .review-comparison {
    grid-template-columns: 1fr;
  }

  .score-summary {
    flex-direction: column;
    text-align: center;
    margin: 0 16px 18px;
  }

  .timer {
    text-align: left;
    align-self: flex-start;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
  }

  .question-nav {
    grid-template-columns: repeat(6, 1fr);
  }

  .question-card {
    padding: 22px 18px;
  }

  .question-card h2 {
    min-height: auto;
    font-size: 20px;
  }

  .secondary-btn,
  .ghost-btn,
  .primary-btn {
    width: 100%;
  }

  .result-panel > h2,
  .result-panel > p,
  .review-list,
  .result-actions {
    padding-left: 18px;
    padding-right: 18px;
  }
}
