:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5ea;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --correct: #16a34a;
  --correct-bg: #ecfdf3;
  --wrong: #dc2626;
  --wrong-bg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 8px;
}

h1 {
  font-size: 2rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lede {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto 24px;
}

.save-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.save-note code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
}

.save-note-error { color: var(--wrong); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: #c7cad1; }

.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* Topic list on the landing page */

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.topic-num {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.topic-card-body { flex: 1; min-width: 0; }
.topic-card-body h3 { margin: 0 0 2px; font-size: 1rem; }
.topic-card-body p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }

.topic-count {
  flex: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* Quiz cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
}

.quiz-shell { display: flex; flex-direction: column; }

.question-text { font-size: 1.25rem; margin-bottom: 20px; }

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.option:hover { border-color: var(--primary); background: #fafaff; }

.option input[type="radio"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  flex: none;
}

.options-readonly .option-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
}

.option-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.option-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.tag-correct { background: var(--correct); color: #fff; }
.tag-wrong { background: var(--wrong); color: #fff; }

.result-banner {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 18px 0 6px;
}

.feedback-card.is-correct .result-banner { color: var(--correct); }
.feedback-card.is-incorrect .result-banner { color: var(--wrong); }

.explanation {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 20px;
}

/* Progress bar */

.progress-wrap { margin-bottom: 18px; }

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

.progress-fill {
  fill: var(--primary);
  transition: width 0.25s ease;
}

/* Bars are SVG rects so their width is an attribute, not an inline style
   (the Content-Security-Policy doesn't allow inline styles). */
.bar {
  display: block;
  width: 100%;
  height: 100%;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* Topic intro / summary */

.topic-intro, .topic-summary { text-align: center; }
.topic-score {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0 16px;
}

/* Results table */

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.score-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 10px;
}

.score-table td {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.mini-bar-track {
  background: var(--bg);
  border-radius: 999px;
  height: 6px;
  width: 120px;
  overflow: hidden;
}

.mini-bar-fill {
  fill: var(--primary);
}

.review-item {
  border-top: 1px solid var(--border);
  padding: 18px 0;
}

.review-item:first-child { border-top: none; padding-top: 0; }

.review-topic {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  font-weight: 700;
  margin: 0 0 4px;
}

.review-question { font-weight: 600; margin: 0 0 8px; }
.review-line { font-size: 0.9rem; margin: 4px 0; display: flex; align-items: center; gap: 8px; }

.celebrate { text-align: center; color: var(--text-muted); }

@media (max-width: 480px) {
  .page { padding: 32px 14px 60px; }
  h1 { font-size: 1.6rem; }
  .card { padding: 20px; }
}

/* Admin area */

.page-narrow { max-width: 440px; }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; text-decoration: none; }

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.admin-bar form { margin: 0; }

.admin-brand {
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 600; }

.field input {
  font: inherit;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.field input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }

.form-error {
  background: var(--wrong-bg);
  color: var(--wrong);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.back-link { text-align: center; font-size: 0.9rem; }
.back-link a, .report-body a { color: var(--primary); }

.report-link { color: inherit; text-decoration: none; transition: border-color 0.12s ease; }
.report-link:hover { border-color: var(--primary); }

.report-score { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.report-score .mini-bar-track { width: 90px; }

.report-nav { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 24px; }

.report-body h2 { margin-top: 24px; }
.report-body h2:first-child { margin-top: 0; }
.report-body h3 { font-size: 1rem; color: var(--primary); margin: 20px 0 8px; }
.report-body ul { padding-left: 20px; margin: 0 0 16px; }
.report-body li { margin: 2px 0; font-size: 0.92rem; }
.report-body p { margin: 0 0 8px; }
.report-body hr { border: none; border-top: 1px solid var(--border); margin: 24px 0 12px; }
.report-body em { color: var(--text-muted); font-size: 0.85rem; }
.report-body .score-table { margin-bottom: 8px; }
.report-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 0.85em;
}
