:root {
  --maroon: #7f403b;
  --maroon-dark: #512826;
  --maroon-soft: #a56d64;
  --sage: #c9c9b5;
  --sage-light: #eeeee5;
  --cream: #f7f4e9;
  --paper: #fffdf7;
  --ink: #211f1b;
  --muted: #69665d;
  --line: #d7d2c2;
  --gold: #b48a4b;
  --success: #32644c;
  --danger: #9a3e38;
  --shadow: 0 18px 50px rgba(55, 40, 28, .12);
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--sage-light);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 75% 0, rgba(127,64,59,.10), transparent 34rem), var(--sage-light); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.masthead { min-height: 76px; padding: 0 4vw; display: flex; align-items: center; gap: 2rem; position: sticky; top: 0; z-index: 20; background: rgba(127,64,59,.97); border-bottom: 2px solid #2e6580; color: white; }
.brand { display: flex; align-items: center; gap: .7rem; color: white; text-decoration: none; margin-right: auto; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--cream); color: var(--maroon); border: 3px solid rgba(255,255,255,.45); transform: rotate(45deg); }
.brand-mark::first-letter { transform: rotate(-45deg); }
.brand strong { font-family: Georgia, 'Times New Roman', serif; font-size: 1.55rem; display: block; line-height: 1; }
.brand small { display: block; text-transform: uppercase; letter-spacing: .13em; font-size: .68rem; margin-top: .25rem; }
nav { display: flex; align-items: center; gap: .25rem; }
nav a { color: rgba(255,255,255,.78); text-decoration: none; padding: .75rem .8rem; border-radius: .35rem; font-weight: 700; font-size: .92rem; }
nav a:hover, nav a.active { color: white; background: rgba(255,255,255,.13); }
.quiet-btn, .primary-btn, .answer, .topic-link { min-height: 44px; border-radius: .35rem; border: 1px solid var(--line); cursor: pointer; }
.quiet-btn { background: transparent; color: inherit; padding: .65rem 1rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.masthead .quiet-btn { color: white; border-color: rgba(255,255,255,.42); }
.primary-btn { background: var(--maroon); color: white; border-color: var(--maroon); padding: .75rem 1.15rem; font-weight: 700; box-shadow: 0 6px 16px rgba(81,40,38,.18); }
.primary-btn:hover { background: var(--maroon-dark); }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }
main { min-height: calc(100vh - 150px); }
.page { width: min(1180px, 92vw); margin: 0 auto; padding: 3rem 0 4rem; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.eyebrow { margin: 0 0 .45rem; text-transform: uppercase; letter-spacing: .14em; color: var(--maroon); font-weight: 800; font-size: .78rem; }
h1, h2, h3 { margin-top: 0; }
h1, .display { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2.25rem, 5vw, 4.6rem); line-height: .98; letter-spacing: -.035em; margin-bottom: .8rem; }
h2 { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1.55rem, 3vw, 2.4rem); }
h3 { font-size: 1.08rem; }
p { line-height: 1.62; }
.lede { max-width: 720px; color: var(--muted); font-size: 1.06rem; }
.hero-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 1.2rem; margin-bottom: 2rem; }
.hero-card { min-height: 310px; padding: clamp(1.6rem, 4vw, 3.4rem); background: linear-gradient(135deg, rgba(247,244,233,.96), rgba(201,201,181,.90)); border: 1px solid rgba(127,64,59,.18); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero-card::after { content: ''; position: absolute; width: 280px; height: 280px; border: 38px solid rgba(127,64,59,.055); border-radius: 50%; right: -70px; bottom: -110px; }
.hero-card .primary-btn { position: relative; z-index: 1; }
.snapshot { background: var(--maroon-dark); color: white; padding: 1.6rem; display: grid; align-content: space-between; box-shadow: var(--shadow); }
.snapshot .metric strong { display: block; font-family: Georgia, serif; font-size: 2.5rem; }
.snapshot .metric span { color: rgba(255,255,255,.7); font-size: .9rem; }
.ready-badge { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem .75rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); width: fit-content; }
.ready-badge i { width: 9px; height: 9px; border-radius: 50%; background: #d2ad68; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2.4rem 0 1rem; }
.section-bar h2 { margin: 0; font-size: 1.65rem; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.module-card { background: var(--paper); border: 1px solid var(--line); padding: 1.25rem; display: flex; flex-direction: column; min-height: 240px; box-shadow: 0 10px 25px rgba(55,40,28,.05); }
.module-card:hover { border-color: var(--maroon-soft); transform: translateY(-2px); transition: .18s ease; }
.module-number { color: var(--maroon); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .75rem; }
.module-card h3 { font-family: Georgia, serif; font-size: 1.35rem; margin: .7rem 0; }
.module-card p { color: var(--muted); font-size: .92rem; margin: 0 0 1rem; }
.module-card .card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.pill { border-radius: 100px; padding: .35rem .6rem; font-size: .75rem; font-weight: 700; background: var(--sage-light); color: var(--muted); }
.pill.done { background: #dce9df; color: var(--success); }
.text-link { border: 0; background: transparent; color: var(--maroon); font-weight: 800; cursor: pointer; padding: .4rem 0; }
.learn-layout { display: grid; grid-template-columns: 270px minmax(0,1fr); gap: 1.4rem; align-items: start; }
.topic-nav { position: sticky; top: 94px; background: var(--paper); border: 1px solid var(--line); padding: .65rem; max-height: calc(100vh - 120px); overflow: auto; }
.topic-link { display: block; width: 100%; text-align: left; background: transparent; border-color: transparent; padding: .7rem; color: var(--ink); }
.topic-link.active { background: var(--maroon); color: white; }
.topic-content { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.topic-title { padding: 2rem 2.2rem; background: linear-gradient(90deg, var(--sage), var(--cream)); border-bottom: 3px solid var(--maroon); }
.topic-title h1 { font-size: clamp(2rem, 4vw, 3.5rem); }
.topic-body { padding: 2rem 2.2rem; }
.lesson { padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.lesson:last-of-type { border: 0; }
.lesson h3 { color: var(--maroon-dark); font-size: 1.2rem; }
.lesson ul { padding-left: 1.3rem; line-height: 1.65; }
.lesson li + li { margin-top: .45rem; }
.source-note { color: var(--muted); font-size: .82rem; }
.action-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.setup-grid, .progress-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.setup-card, .stat-card { background: var(--paper); border: 1px solid var(--line); padding: 1.35rem; }
.setup-card h3 { font-family: Georgia, serif; font-size: 1.35rem; }
.setup-card.selected { border: 2px solid var(--maroon); }
.choice-row { display: flex; flex-wrap: wrap; gap: .65rem; }
.choice-chip { border: 1px solid var(--line); background: var(--paper); padding: .65rem .8rem; cursor: pointer; min-height: 44px; }
.choice-chip.selected { background: var(--maroon); color: white; border-color: var(--maroon); }
select, input { width: 100%; min-height: 46px; border: 1px solid var(--line); background: white; padding: .7rem .8rem; border-radius: .3rem; color: var(--ink); }
label { display: block; font-weight: 700; margin: 1rem 0 .4rem; }
.quiz-shell { width: min(880px, 92vw); margin: 0 auto; padding: 2.5rem 0 4rem; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.progress-track { height: 8px; background: #ddd9ca; overflow: hidden; flex: 1; }
.progress-track span { display: block; height: 100%; background: var(--maroon); transition: width .25s ease; }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--maroon-dark); }
.question-card { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); padding: clamp(1.3rem, 4vw, 2.5rem); }
.question-card h2 { font-family: Arial, sans-serif; font-size: clamp(1.35rem, 3vw, 1.8rem); line-height: 1.35; }
.answers { display: grid; gap: .7rem; margin: 1.4rem 0; }
.answer { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: .75rem; text-align: left; padding: .85rem 1rem; background: white; border-color: var(--line); color: var(--ink); }
.answer:hover { border-color: var(--maroon); }
.answer.selected { border: 2px solid var(--maroon); background: #f7efea; }
.answer.correct { border-color: var(--success); background: #e6f0e8; }
.answer.wrong { border-color: var(--danger); background: #f8e7e5; }
.answer-letter { width: 30px; height: 30px; display: grid; place-items: center; background: var(--sage-light); border-radius: 50%; font-weight: 800; }
.flag-control { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; cursor: pointer; }
.flag-control input { width: 20px; min-height: 20px; accent-color: var(--maroon); }
.explanation { margin-top: 1.2rem; border-left: 4px solid var(--gold); background: #f6f0df; padding: 1rem 1.1rem; }
.results-hero { background: var(--maroon-dark); color: white; padding: 2rem; display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; }
.score-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; border: 12px solid var(--gold); font-family: Georgia, serif; font-size: 2.4rem; }
.review-list { display: grid; gap: .8rem; margin-top: 1.2rem; }
.review-item { background: var(--paper); border: 1px solid var(--line); padding: 1rem 1.1rem; }
.review-item h3 { margin-bottom: .4rem; }
.review-item p { margin: .25rem 0; }
.stat-card strong { display: block; font-family: Georgia, serif; font-size: 2.25rem; color: var(--maroon-dark); }
.mastery-row { display: grid; grid-template-columns: minmax(170px, 1fr) 2fr 55px; gap: 1rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.bar { height: 10px; background: #dedacb; }
.bar span { display: block; height: 100%; background: var(--maroon); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
footer { min-height: 74px; padding: 1.2rem 4vw; display: flex; justify-content: space-between; gap: 1rem; background: #dedacb; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
dialog { width: min(480px, 90vw); border: 1px solid var(--line); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(30,22,19,.6); }
dialog form { padding: 2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.5rem; }
dialog .quiet-btn { color: var(--ink); }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; background: var(--maroon-dark); color: white; padding: .85rem 1rem; box-shadow: var(--shadow); transform: translateY(140%); transition: transform .2s ease; }
.toast.show { transform: translateY(0); }
@media (max-width: 850px) {
  .masthead { padding: .75rem 4vw; flex-wrap: wrap; gap: .5rem; }
  .brand { width: calc(100% - 80px); }
  nav { width: 100%; overflow-x: auto; order: 3; }
  nav a { white-space: nowrap; }
  .hero-grid, .learn-layout { grid-template-columns: 1fr; }
  .module-grid, .setup-grid { grid-template-columns: repeat(2, 1fr); }
  .topic-nav { position: static; display: flex; overflow-x: auto; max-height: none; }
  .topic-link { min-width: 180px; }
}
@media (max-width: 580px) {
  .page { width: min(94vw, 1180px); padding-top: 1.6rem; }
  .module-grid, .setup-grid, .progress-grid { grid-template-columns: 1fr; }
  .hero-card { min-height: 280px; }
  .topic-title, .topic-body { padding: 1.35rem; }
  .results-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .score-ring { width: 125px; height: 125px; }
  .mastery-row { grid-template-columns: 1fr 55px; }
  .mastery-row .bar { grid-row: 2; grid-column: 1 / 3; }
  footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
