@import url('https://fonts.googleapis.com/css2?family=Aleo:wght@400;600;700&display=swap');

:root {
  --green-dark: #207233;
  --green-mid: #488343;
  --green-pale: #e7f0e3;
  --cream: #fdf9e2;
  --cream-alt: #f5f0d3;
  --ink: #2a2a22;
  --red: #a3352b;
  --red-bg: #fbe9e7;
  --amber: #9c7a12;
  --amber-bg: #fbf3d9;
  --line: #ddd6b3;
  --shadow: 0 2px 10px rgba(32, 60, 20, 0.12);
  --radius: 8px;
}

* { box-sizing: border-box; }

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

h1, h2, h3, .brand-title {
  font-family: 'Aleo', Georgia, serif;
  color: var(--green-dark);
  font-weight: 600;
  margin: 0 0 0.4em 0;
}

a { color: var(--green-mid); }

.site-header {
  position: relative;
  background: #1b1b16 url('../assets/header-forest.webp') center 30%/cover no-repeat;
  padding: 28px 20px 22px;
  text-align: center;
  color: #fff;
}
.site-header::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,20,10,0.55) 0%, rgba(10,20,10,0.72) 100%);
}
.site-header > * { position: relative; z-index: 1; }
.site-header img.logo {
  height: 84px;
  width: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  margin-bottom: 8px;
}
.site-header h1 {
  color: #fff;
  font-size: 28px;
  margin: 4px 0 2px;
}
.site-header .subtitle {
  color: #e9e6cf;
  font-size: 15px;
  margin-bottom: 10px;
}
.site-header .backlink {
  display: inline-block;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.55);
  padding: 5px 14px;
  border-radius: 999px;
  opacity: 0.9;
}
.site-header .backlink:hover { background: rgba(255,255,255,0.12); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--green-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 24px 22px;
  margin-bottom: 20px;
}

.btn {
  display: inline-block;
  background: var(--green-dark);
  color: #fff;
  border: none;
  padding: 12px 26px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--green-mid); }
.btn:disabled { background: #b9c9b5; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--green-dark);
  border: 1.5px solid var(--green-dark);
}
.btn.secondary:hover:not(:disabled) { background: var(--green-pale); }
.btn.block { display: block; width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0 0 18px 0;
}
legend {
  font-family: 'Aleo', Georgia, serif;
  color: var(--green-dark);
  font-weight: 600;
  padding: 0 8px;
}

.chapter-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid #eee6c8;
}
.chapter-option:last-child { border-bottom: none; }
.chapter-option input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--green-dark); }
.chapter-option label { flex: 1; cursor: pointer; }
.chapter-option .chapter-count { color: #756f4d; font-size: 13.5px; }
.chapter-option .chapter-note { color: #8a5c1d; font-size: 13px; margin-top: 2px; }

.count-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.count-buttons button {
  border: 1.5px solid var(--green-dark);
  background: #fff;
  color: var(--green-dark);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.count-buttons button.active,
.count-buttons button:hover { background: var(--green-dark); color: #fff; }

.custom-count {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.custom-count input[type=number] {
  width: 90px;
  padding: 8px 10px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
}

.available-note {
  font-size: 13.5px;
  color: #5c5a3f;
  margin-top: 6px;
}

details.advanced { margin-bottom: 18px; }
details.advanced summary {
  cursor: pointer;
  color: var(--green-mid);
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 10px;
}
.advanced-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14.5px; }
.advanced-row input[type=number] { width: 70px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-family: inherit; }

.exam-box {
  background: var(--green-pale);
  border: 1px solid #bfd8b6;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.exam-box h3 { margin-bottom: 6px; }
.exam-box ul { margin: 8px 0 0 0; padding-left: 20px; font-size: 14.5px; }

/* ---- Quiz screen ---- */
.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14.5px;
  color: #5c5a3f;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.quiz-topbar .timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.quiz-topbar .timer.warn { color: var(--red); }

.progress-bar {
  height: 7px;
  background: #eee6c8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-bar > div {
  height: 100%;
  background: var(--green-mid);
  transition: width 0.2s ease;
}

.q-tag {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #8a824f;
  margin-bottom: 8px;
}
.q-text {
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 18px;
  white-space: pre-wrap;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: var(--green-mid); }
.option input { margin-top: 3px; width: 19px; height: 19px; accent-color: var(--green-dark); flex-shrink: 0; }
.option .opt-text { flex: 1; }

.option.correct { border-color: var(--green-mid); background: var(--green-pale); }
.option.incorrect { border-color: var(--red); background: var(--red-bg); }
.option.missed { border-color: var(--amber); background: var(--amber-bg); }
.option.locked { cursor: default; }
.option .mark { font-weight: 700; margin-left: 6px; }
.option.correct .mark { color: var(--green-dark); }
.option.incorrect .mark { color: var(--red); }
.option.missed .mark { color: var(--amber); }

textarea.own-answer {
  width: 100%;
  min-height: 90px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  margin-bottom: 14px;
}

.model-answer {
  background: var(--green-pale);
  border: 1px solid #bfd8b6;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  white-space: pre-wrap;
}
.model-answer .label { font-weight: 700; color: var(--green-dark); display:block; margin-bottom: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }

.self-assess { display: flex; gap: 12px; margin-bottom: 16px; }
.self-assess button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: #fff;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  font-size: 15px;
}
.self-assess button.yes:hover, .self-assess button.yes.chosen { border-color: var(--green-mid); background: var(--green-pale); color: var(--green-dark); }
.self-assess button.no:hover, .self-assess button.no.chosen { border-color: var(--red); background: var(--red-bg); color: var(--red); }

/* ---- Results screen ---- */
.result-banner {
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  text-align: center;
}
.result-banner.pass { background: var(--green-pale); border: 1.5px solid var(--green-mid); }
.result-banner.oral { background: var(--amber-bg); border: 1.5px solid var(--amber); }
.result-banner.fail { background: var(--red-bg); border: 1.5px solid var(--red); }
.result-banner .big { font-family: 'Aleo', Georgia, serif; font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.result-banner.pass .big { color: var(--green-dark); }
.result-banner.oral .big { color: var(--amber); }
.result-banner.fail .big { color: var(--red); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-grid .stat {
  background: var(--cream-alt);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-grid .stat .num { font-family: 'Aleo', Georgia, serif; font-size: 24px; font-weight: 700; color: var(--green-dark); }
.stat-grid .stat .label { font-size: 12.5px; color: #5c5a3f; margin-top: 2px; }

table.chapter-breakdown { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 14.5px; }
table.chapter-breakdown th, table.chapter-breakdown td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.chapter-breakdown th { color: #5c5a3f; font-weight: 600; }

.review-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.review-item:last-child { border-bottom: none; }
.review-item .rq { font-weight: 600; margin-bottom: 6px; }
.review-item .ra { font-size: 14.5px; color: #444; }
.review-item .tag-wrong { color: var(--red); font-weight: 700; font-size: 13px; }

footer.site-footer {
  text-align: center;
  font-size: 13px;
  color: #7a7454;
  padding: 20px;
}

html.embedded .site-header { display: none; }
html.embedded main { padding-top: 8px; padding-bottom: 24px; }
html.embedded footer.site-footer { padding: 8px 18px 14px; }

[hidden] { display: none !important; }

@media (max-width: 480px) {
  .site-header h1 { font-size: 22px; }
  .q-text { font-size: 17px; }
  main { padding: 20px 12px 50px; }
  .card { padding: 18px 16px; }
}
