:root {
  --primary:      #2563eb;
  --primary-dk:   #1d4ed8;
  --primary-lt:   #eff6ff;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --success-bdr:  #86efac;
  --error:        #dc2626;
  --error-bg:     #fee2e2;
  --error-bdr:    #fca5a5;
  --warn:         #d97706;
  --warn-bg:      #fef3c7;
  --bg:           #f1f5f9;
  --card:         #ffffff;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 2px 8px rgba(0,0,0,.08);
  --shadow-md:    0 4px 20px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
}

/* ── Layout ── */
.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* ── Header ── */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-header a { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.1rem; }
.site-header .spacer { flex: 1; }
.site-header .back-link {
  font-size: .875rem;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-header .back-link:hover { opacity: 1; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 20px;
}
.card + .card { margin-top: 16px; }

/* ── Typography ── */
h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-center { text-align: center; }

/* ── Home — test list ── */
.test-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }

.test-card {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .1s;
  gap: 16px;
}
.test-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.test-card__icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.test-card__body { flex: 1; min-width: 0; }
.test-card__title { font-weight: 600; font-size: 1rem; }
.test-card__meta { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.test-card__arrow { color: var(--text-muted); font-size: 1.2rem; flex-shrink: 0; }

/* ── Detail page — section picker ── */
.section-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.section-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.section-item:hover { border-color: var(--primary); background: var(--primary-lt); }
.section-item input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.section-item label { cursor: pointer; font-size: .95rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dk); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-lt); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803d; }

.btn-lg { padding: 15px 32px; font-size: 1.05rem; width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ── Progress bar ── */
.progress-wrap {
  margin-bottom: 20px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.progress-bar-bg {
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 99px;
  transition: width .3s ease;
}

/* ── Quiz question ── */
.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 22px;
}

.options-form { display: flex; flex-direction: column; gap: 10px; }

.opt-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .97rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s, transform .08s;
  min-height: 56px;
}
.opt-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-lt);
  transform: translateX(2px);
}
.opt-btn:active:not(:disabled) { transform: scale(.98); }

.opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
  transition: background .12s, border-color .12s, color .12s;
}
.opt-btn:hover:not(:disabled) .opt-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Static (feedback) option display */
.opt-static {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .97rem;
  min-height: 56px;
  background: var(--bg);
}

.opt-static.opt-correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.opt-static.opt-correct .opt-letter {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.opt-static.opt-wrong {
  border-color: var(--error);
  background: var(--error-bg);
}
.opt-static.opt-wrong .opt-letter {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.opt-badge {
  margin-left: auto;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Feedback banner ── */
.feedback-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-top: 18px;
  font-size: .95rem;
}
.feedback-banner.correct {
  background: var(--success-bg);
  border: 1.5px solid var(--success-bdr);
  color: #14532d;
}
.feedback-banner.wrong {
  background: var(--error-bg);
  border: 1.5px solid var(--error-bdr);
  color: #7f1d1d;
}
.feedback-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }
.feedback-text strong { display: block; margin-bottom: 2px; }

/* ── Results ── */
.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border: 6px solid currentColor;
}
.score-circle .pct { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.score-circle .label { font-size: .75rem; font-weight: 600; opacity: .75; margin-top: 2px; }

.score-excellent { color: var(--success); }
.score-good      { color: var(--primary); }
.score-ok        { color: var(--warn); }
.score-poor      { color: var(--error); }

.score-sub {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Section stats table */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-top: 12px;
}
.stats-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stats-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}
.stats-table tr:last-child td { border-bottom: none; }

.mini-bar-bg {
  background: var(--bg);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  min-width: 60px;
  flex: 1;
}
.mini-bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 99px;
}
.mini-bar-fill.green { background: var(--success); }
.mini-bar-fill.red   { background: var(--error); }
.mini-bar-wrap { display: flex; align-items: center; gap: 8px; }

/* Review accordion */
.review-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.review-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.review-item.correct { border-color: var(--success-bdr); }
.review-item.wrong   { border-color: var(--error-bdr); }

.review-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-size: .9rem;
  font-weight: 500;
}
.review-summary::-webkit-details-marker { display: none; }
.review-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.review-body {
  padding: 0 14px 12px 38px;
  font-size: .875rem;
  color: var(--text-muted);
}
.review-body .ans-row { display: flex; gap: 6px; align-items: baseline; margin-top: 4px; }
.review-body .ans-label { font-weight: 600; color: var(--text); white-space: nowrap; }
.badge-correct { color: var(--success); font-weight: 700; }
.badge-wrong   { color: var(--error);   font-weight: 700; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Utilities ── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Mobile tweaks ── */
@media (max-width: 480px) {
  .card { padding: 18px 16px; }
  h1 { font-size: 1.35rem; }
  .question-text { font-size: 1.05rem; }
  .opt-btn, .opt-static { padding: 13px 14px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
  .score-circle { width: 120px; height: 120px; }
  .score-circle .pct { font-size: 2rem; }
  .stats-table { font-size: .82rem; }
}
