:root {
  --ink: #14221d;
  --muted: #66766f;
  --paper: #f5f7f3;
  --card: #ffffff;
  --line: #dfe6e1;
  --forest: #123f31;
  --forest-2: #1d5b47;
  --mint: #dff2e9;
  --mint-2: #edf8f3;
  --correct: #16845b;
  --correct-bg: #e8f7f0;
  --wrong: #c44949;
  --wrong-bg: #fff0ef;
  --pending: #8a6c24;
  --pending-bg: #fff8df;
  --shadow: 0 14px 40px rgba(24, 49, 39, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 0%, rgba(194, 224, 209, 0.35), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
button, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 30px 22px;
  background: #10231d;
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: #d8f3e7;
  color: var(--forest);
  flex: 0 0 auto;
}
.brand-mark svg { width: 24px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand strong { display: block; font-size: 17px; letter-spacing: -0.01em; }
.brand small { display: block; color: #9fb5aa; font-size: 12px; margin-top: 1px; }
.sidebar-label {
  margin: 46px 8px 12px;
  color: #83998e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.chapter-nav { display: grid; gap: 8px; }
.chapter-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #c5d3cc;
  background: transparent;
  text-align: left;
  transition: 160ms ease;
}
.chapter-button:hover { background: rgba(255,255,255,.06); color: white; }
.chapter-button.active { color: white; background: #1d4638; border-color: #315b4d; }
.chapter-button span:first-child { font-weight: 700; }
.chapter-button .chapter-total {
  min-width: 29px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  color: #bdd4c9;
  font-size: 11px;
  text-align: center;
}
.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #29453b;
  border-radius: 14px;
  display: flex;
  gap: 10px;
  color: #9fb5aa;
  font-size: 12px;
}
.sidebar-note p { margin: 0; }
.note-dot { width: 8px; height: 8px; border-radius: 50%; background: #79d1a9; margin-top: 5px; flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(121,209,169,.12); }

.main-content { margin-left: 260px; padding: 38px clamp(24px, 5vw, 76px) 110px; max-width: 1500px; }
.mobile-header { display: none; }
.hero {
  min-height: 166px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 8px 0 30px;
}
.eyebrow { margin: 0 0 8px; color: var(--forest-2); font-size: 11px; font-weight: 850; letter-spacing: .14em; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(32px, 4.2vw, 54px); line-height: 1.05; letter-spacing: -.035em; }
.chapter-description { margin: 12px 0 0; color: var(--muted); max-width: 650px; }
.hero-count { width: 118px; height: 118px; border-radius: 50%; background: var(--forest); color: white; display: grid; place-content: center; text-align: center; flex: 0 0 auto; box-shadow: var(--shadow); }
.hero-count strong { font-family: Georgia, serif; font-size: 38px; line-height: 1; }
.hero-count span { margin-top: 5px; font-size: 11px; color: #b9d1c7; }

.control-panel {
  position: sticky;
  top: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 26px;
  padding: 18px;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(30,62,49,.08);
}
.control-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 7px; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: #eef2ef; }
.segment { border: 0; border-radius: 9px; padding: 8px 12px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 750; }
.segment.active { background: white; color: var(--forest); box-shadow: 0 2px 8px rgba(20,45,35,.09); }
.progress-copy { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 12px; }
.progress-copy strong { color: var(--ink); }
.progress-track { height: 7px; margin-top: 9px; background: #e8eeea; border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#28775b,#6fc79f); transition: width .25s ease; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.button { border: 1px solid transparent; border-radius: 12px; padding: 10px 15px; font-size: 13px; font-weight: 800; transition: 150ms ease; white-space: nowrap; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--forest); color: white; box-shadow: 0 7px 18px rgba(18,63,49,.16); }
.button-primary:hover { background: #0c3327; }
.button-ghost { background: white; border-color: var(--line); color: var(--ink); }
.button-light { background: white; color: var(--forest); }

.result-panel { margin-top: 24px; padding: 28px; border-radius: var(--radius); color: white; background: linear-gradient(125deg,#123f31,#1c5c47); box-shadow: var(--shadow); }
.result-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.result-heading .eyebrow { color: #a8ddc6; }
.result-heading h2 { margin: 0; font-family: Georgia,serif; font-size: 30px; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 22px; }
.stat-card { min-height: 82px; padding: 14px 17px; border-radius: 14px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12); display: flex; align-items: end; justify-content: space-between; }
.stat-card span { color: #c2dbd0; font-size: 12px; }
.stat-card strong { font-family: Georgia,serif; font-size: 32px; line-height: 1; }
.filter-row { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.filter-row .control-label { color: #b6d2c6; margin: 0; }
.filter-buttons { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-button { border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 7px 12px; background: transparent; color: #d8e8e1; font-size: 12px; font-weight: 750; }
.filter-button.active { background: white; color: var(--forest); border-color: white; }

.navigator { margin: 22px 0 0; border: 1px solid var(--line); border-radius: 15px; background: white; }
.navigator summary { list-style: none; cursor: pointer; padding: 14px 17px; font-size: 13px; font-weight: 800; display: flex; justify-content: space-between; }
.navigator summary::-webkit-details-marker { display: none; }
.navigator summary::after { content: "+"; font-size: 18px; line-height: 1; color: var(--forest-2); }
.navigator[open] summary::after { content: "−"; }
.question-navigator { padding: 0 17px 17px; display: grid; grid-template-columns: repeat(auto-fill,minmax(38px,1fr)); gap: 7px; }
.nav-number { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); font-size: 12px; font-weight: 750; }
.nav-number.answered { background: var(--mint-2); border-color: #a8d7c2; color: var(--forest); }
.nav-number.correct { background: var(--correct-bg); border-color: #93d8bc; color: var(--correct); }
.nav-number.wrong { background: var(--wrong-bg); border-color: #efb8b5; color: var(--wrong); }
.nav-number.unanswered { background: var(--pending-bg); border-color: #ead79c; color: var(--pending); }

.question-list { margin-top: 22px; display: grid; gap: 15px; }
.question-card { scroll-margin-top: 125px; padding: 24px 26px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 25px rgba(23,48,39,.045); transition: border-color .18s ease, transform .18s ease; }
.question-card:hover { border-color: #c7d6ce; }
.question-card.status-correct { border-left: 5px solid var(--correct); }
.question-card.status-wrong { border-left: 5px solid var(--wrong); }
.question-card.status-unanswered { border-left: 5px solid #d1a936; }
.question-topline { display: flex; gap: 13px; align-items: flex-start; }
.question-number { min-width: 38px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 9px; background: var(--mint); color: var(--forest); font-size: 12px; font-weight: 850; }
.question-title { margin: 1px 0 0; font-size: 16px; font-weight: 780; line-height: 1.55; }
.options { display: grid; gap: 9px; margin: 17px 0 0 51px; }
.option { position: relative; display: grid; grid-template-columns: 31px 1fr; align-items: start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfb; cursor: pointer; transition: 150ms ease; }
.option:hover { border-color: #a9c5b8; background: #f7fbf9; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-key { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: #edf1ee; color: #4d5e56; font-size: 12px; font-weight: 850; transition: inherit; }
.option-text { padding-top: 3px; color: #35443d; font-size: 14px; }
.option.selected { border-color: #79ae96; background: var(--mint-2); }
.option.selected .option-key { background: var(--forest); color: white; }
.option.reveal-correct { border-color: #79c6a6; background: var(--correct-bg); }
.option.reveal-correct .option-key { background: var(--correct); color: white; }
.option.reveal-wrong { border-color: #e8a7a3; background: var(--wrong-bg); }
.option.reveal-wrong .option-key { background: var(--wrong); color: white; }
.review-note { margin: 13px 0 0 51px; font-size: 13px; font-weight: 750; }
.review-note.correct { color: var(--correct); }
.review-note.wrong { color: var(--wrong); }
.review-note.unanswered { color: var(--pending); }
.empty-state { margin: 28px 0; padding: 44px 20px; display: grid; text-align: center; background: white; border: 1px dashed #c8d3cd; border-radius: var(--radius); }
.empty-state span { color: var(--muted); font-size: 13px; margin-top: 5px; }

.bottom-submit { display: none; }
footer { margin-top: 58px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%,20px); padding: 11px 16px; border-radius: 12px; background: #10231d; color: white; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 50; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 1050px) {
  .sidebar { width: 220px; padding-inline: 16px; }
  .main-content { margin-left: 220px; padding-inline: 28px; }
  .control-panel { grid-template-columns: 1fr 1fr; }
  .toolbar-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 760px) {
  body { background: var(--paper); }
  .sidebar { display: none; }
  .main-content { margin: 0; padding: 0 15px 100px; }
  .mobile-header { position: sticky; top: 0; z-index: 30; margin: 0 -15px; padding: 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(16,35,29,.96); color: white; backdrop-filter: blur(12px); }
  .brand.compact .brand-mark { width: 35px; height: 35px; border-radius: 10px; }
  .brand.compact .brand-mark svg { width: 20px; }
  .mobile-select-label select { max-width: 166px; border: 1px solid #3a594e; border-radius: 10px; padding: 8px 30px 8px 10px; color: white; background: #1b3c31; font-size: 12px; font-weight: 700; }
  .hero { min-height: auto; padding: 30px 5px 22px; align-items: center; }
  .hero-count { width: 76px; height: 76px; }
  .hero-count strong { font-size: 27px; }
  .hero-count span { font-size: 9px; }
  h1 { font-size: 34px; }
  .chapter-description { font-size: 13px; }
  .control-panel { position: static; grid-template-columns: 1fr; gap: 17px; padding: 15px; }
  .toolbar-actions { grid-column: auto; justify-content: stretch; }
  .toolbar-actions .button { flex: 1; }
  #submitBtn { display: none; }
  .result-panel { padding: 20px; }
  .result-heading { align-items: flex-start; flex-direction: column; }
  .result-heading h2 { font-size: 25px; }
  .result-stats { gap: 7px; }
  .stat-card { min-height: 74px; padding: 11px; flex-direction: column; align-items: flex-start; }
  .stat-card strong { font-size: 27px; }
  .filter-row { align-items: flex-start; flex-direction: column; }
  .question-card { padding: 19px 15px; border-radius: 16px; scroll-margin-top: 70px; }
  .question-topline { gap: 9px; }
  .question-number { min-width: 34px; }
  .question-title { font-size: 15px; }
  .options { margin-left: 0; }
  .option { padding: 11px; }
  .review-note { margin-left: 0; }
  .bottom-submit { position: fixed; z-index: 25; inset: auto 0 0; padding: 11px 15px calc(11px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 15px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); }
  .bottom-submit div { display: grid; font-size: 10px; color: var(--muted); }
  .bottom-submit strong { color: var(--ink); font-size: 14px; }
  footer { padding-bottom: 20px; flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
