:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #1f2a24;
  --muted: #5b6a63;
  --line: #dbe3dd;
  --accent: #2f7d4f;
  --accent-dark: #1f5c39;
  --easy: #4ea362;
  --medium: #d2952b;
  --hard: #b7443b;
  --correct: #1f7a3a;
  --correct-bg: #e3f3e7;
  --wrong: #b7443b;
  --wrong-bg: #fbe5e2;
  --shadow: 0 2px 6px rgba(20, 40, 30, 0.06);
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 28px 0 22px;
}

.site-header.compact { padding: 18px 0; }

.site-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.back-link {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.back-link:hover { text-decoration: underline; }

main { padding: 28px 0 80px; }

h2 {
  margin: 28px 0 12px;
  font-size: 1.25rem;
}

.intro p {
  max-width: 70ch;
  color: var(--muted);
}
.hero-subtitle {
  margin: -6px 0 14px;
  font-size: 1.05rem;
  color: var(--muted);
  font-style: italic;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 18px 0 28px;
}

.level-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, border-color 0.1s ease;
  position: relative;
}
.level-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.level-card .badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  margin-bottom: 10px;
}
.level-card.easy .badge { background: var(--easy); }
.level-card.medium .badge { background: var(--medium); }
.level-card.hard .badge { background: var(--hard); }
.level-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.level-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}
.level-meta {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}
.progress-note {
  display: block;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-weight: 600;
  min-height: 1.1em;
}

.footer-note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 8px;
}
.footer-note ul { margin: 8px 0 0; padding-left: 20px; }
.footer-note li { margin: 4px 0; color: var(--muted); font-size: 0.95rem; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px 0;
  color: var(--muted);
}
.site-footer small { font-size: 0.85rem; }
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}
.footer-links a:hover { text-decoration: underline; }
.footer-links .sep { margin: 0 4px; color: var(--line); }

/* -------- Quiz page -------- */
.sticky-status {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.97);
  backdrop-filter: saturate(180%) blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
#answered-count {
  font-weight: 600;
  color: var(--ink);
}
.status-actions { display: flex; gap: 8px; }

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { color: var(--muted); }

.question {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

.q-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.q-number {
  font-weight: 700;
  color: var(--accent-dark);
}

.q-unit {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.q-prompt {
  margin: 0 0 10px;
  white-space: pre-wrap;
}

.choices {
  list-style: none;
  padding: 0;
  margin: 0;
}
.choices li { margin: 4px 0; }
.choice {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: #fbfcfb;
}
.choice:hover { border-color: var(--accent); }
.choice input { margin-right: 10px; }
.choice.selected {
  background: #edf6ef;
  border-color: var(--accent);
}

/* Results / feedback coloring */
.choice.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
}
.choice.wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
}
.answer-line {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.answer-line.right { color: var(--correct); font-weight: 600; }
.answer-line.wrong { color: var(--wrong); font-weight: 600; }

/* FRQ */
.frq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.frq h3 { margin: 0 0 8px; }
.frq .frq-body {
  white-space: pre-wrap;
  color: var(--ink);
  margin: 0 0 12px;
}
.frq textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  background: #fbfcfb;
}
.note {
  color: var(--muted);
  font-size: 0.92rem;
  background: #f0f4f1;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 4px;
}

/* Results summary */
.results {
  margin: 24px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.results h2 { margin-top: 0; }
.score-big {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent-dark);
}
.score-pct {
  color: var(--muted);
  font-weight: 500;
  margin-left: 8px;
}
.unit-breakdown {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.unit-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.92rem;
  border-bottom: 1px dashed var(--line);
}
.unit-row:last-child { border-bottom: none; }

.hidden { display: none !important; }

/* -------- Static SEO catalog + FAQ -------- */
.static-catalog, .faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 20px 0;
}
.static-catalog h3, .faq h3 {
  margin: 16px 0 6px;
  font-size: 1rem;
  color: var(--accent-dark);
}
.static-catalog ul { margin: 6px 0 8px; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.static-catalog li { margin: 2px 0; }
.faq p { color: var(--muted); margin: 4px 0 10px; font-size: 0.95rem; }

/* -------- Catalog UI -------- */
.catalog-filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}
.catalog-filters label { display: inline-flex; align-items: center; gap: 6px; }
.catalog-filters select, .catalog-filters input {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.catalog-section { margin: 20px 0 24px; }
.catalog-section h3 {
  margin: 12px 0 8px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.exam-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exam-card h3 { font-size: 1.05rem; margin: 0 0 4px; }
.exam-card .badge {
  align-self: flex-start;
  background: var(--muted);
}
.exam-card.status-available .badge { background: var(--accent); }
.exam-card.status-coming-soon .badge { background: #9aa3a0; }
.exam-card.status-portfolio-only .badge { background: #8a6cbf; }
.exam-card.status-coming-soon { opacity: 0.7; }
.exam-card.status-coming-soon:hover { transform: none; border-color: var(--line); }

.exam-meta { color: var(--ink); margin: 2px 0 4px; font-size: 0.92rem; }
.exam-note { color: var(--muted); font-size: 0.82rem; font-style: italic; margin: 2px 0; }
.exam-level-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.exam-level-row .btn { padding: 6px 14px; font-size: 0.9rem; font-weight: 700; }
.level-btn {
  color: #fff;
  border: 1px solid transparent;
  text-decoration: none;
}
.level-btn.level-easy   { background: var(--easy);   border-color: var(--easy); }
.level-btn.level-medium { background: var(--medium); border-color: var(--medium); }
.level-btn.level-hard   { background: var(--hard);   border-color: var(--hard); }
.level-btn.level-easy:hover,
.level-btn.level-medium:hover,
.level-btn.level-hard:hover { filter: brightness(0.92); }

/* -------- 10AP brand + exam-mode additions -------- */

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; }

.exam-header-meta { flex: 1 1 auto; }
.exam-header-meta h1 { margin: 0 0 2px; font-size: 1.15rem; }

/* Start screen card */
.screen { padding: 28px 0 60px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  max-width: 760px;
  margin: 0 auto;
}
.rules {
  margin: 12px 0 20px;
  padding-left: 18px;
  color: var(--muted);
}
.rules li { margin: 6px 0; }
.btn.large { padding: 12px 22px; font-size: 1rem; font-weight: 700; }

/* Sticky status bar */
.sticky-status .row { gap: 14px; }
.section-label {
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: #e8f2ec;
  color: var(--accent-dark);
  min-width: 72px;
  text-align: center;
}
.timer.warn {
  background: #fbe5e2;
  color: var(--wrong);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 1; } to { opacity: 0.7; } }

/* MCQ layout with nav panel */
.mcq-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
  padding-top: 20px;
}
.nav-panel {
  position: sticky;
  top: 60px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.nav-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  border: 1px solid var(--line);
}
.swatch.current   { background: var(--accent); border-color: var(--accent); }
.swatch.answered  { background: #cfe5d6; border-color: #9dcaab; }
.swatch.flagged   { background: #ffd966; border-color: #d2952b; }
.swatch.unanswered{ background: #fff; }

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.nav-cell {
  padding: 6px 0;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink);
}
.nav-cell:hover { border-color: var(--accent); }
.nav-cell.answered {
  background: #cfe5d6;
  border-color: #9dcaab;
}
.nav-cell.flagged {
  background: #ffd966;
  border-color: #d2952b;
}
.nav-cell.flagged.answered {
  background: linear-gradient(135deg, #ffd966 50%, #cfe5d6 50%);
}
.nav-cell.current {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  font-weight: 700;
}

.mcq-pane {}
.mcq-controls {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn.flag-on {
  background: #ffd966;
  border-color: #d2952b;
  color: #6b4a00;
}

/* Disable text-select on questions during exam */
.exam-mode .question .q-prompt,
.exam-mode .question .choice,
.exam-mode .frq .frq-body {
  user-select: none;
  -webkit-user-select: none;
}
/* Allow selection on review screen */
.exam-mode #screen-review .question .q-prompt,
.exam-mode #screen-review .question .choice,
.exam-mode #screen-review .frq .frq-body {
  user-select: text;
  -webkit-user-select: text;
}

/* FRQ word count + submit row */
.word-count {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}
.frq-submit-row {
  margin: 24px 0 40px;
  display: flex;
  justify-content: flex-end;
}
.frq-response {
  white-space: pre-wrap;
  font: inherit;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

@media (max-width: 720px) {
  .mcq-layout { grid-template-columns: 1fr; }
  .nav-panel { position: static; }
  .nav-grid { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 600px) {
  .site-header h1 { font-size: 1.1rem; }
  .q-unit { display: none; }
  .sticky-status .row { justify-content: space-between; }
  .btn { padding: 7px 10px; font-size: 0.9rem; }
  .timer { font-size: 0.95rem; }
}
