:root {
  color-scheme: light;
  --ink: #142724;
  --muted: #5e6d68;
  --paper: #f4f0e6;
  --surface: #fffdf7;
  --surface-2: #e7efe8;
  --line: #d8d8ca;
  --green: #174e45;
  --green-2: #2f7467;
  --lime: #c8de7c;
  --orange: #ed9d3e;
  --orange-soft: #fae4c3;
  --red: #a33b46;
  --red-soft: #f8e2e1;
  --shadow: 0 20px 60px rgba(21, 47, 42, .10);
  --radius: 24px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eff5ed;
  --muted: #aab8b2;
  --paper: #0d1715;
  --surface: #14211e;
  --surface-2: #1b302b;
  --line: #31443f;
  --green: #8dd1bb;
  --green-2: #a7dec9;
  --lime: #d4e891;
  --orange: #f5b963;
  --orange-soft: #3f3020;
  --red: #f2a0a8;
  --red-soft: #402529;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "DM Sans", system-ui, sans-serif; line-height: 1.55; }
button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.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; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { transform: none; }

.topbar { max-width: 1180px; margin: 0 auto; padding: 22px 28px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { width: 33px; height: 33px; display: grid; place-content: center; gap: 2px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); }
.brand-mark span { display: block; width: 15px; height: 2px; border-radius: 2px; background: var(--green); }
.brand-mark span:nth-child(2) { width: 9px; margin-left: 6px; }
.top-actions { display: flex; gap: 8px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 50%; cursor: pointer; }
.icon-button:hover { border-color: var(--green-2); transform: translateY(-1px); }

.hero { min-height: 590px; max-width: 1180px; margin: 0 auto; padding: 55px 28px 80px; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 48px; }
.eyebrow { margin: 0 0 12px; color: var(--green-2); font-size: .78rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { font-family: "Fraunces", Georgia, serif; letter-spacing: -.045em; line-height: 1.05; }
h1 { max-width: 700px; margin: 0; font-size: clamp(3.2rem, 7.4vw, 6.7rem); }
h1 em { color: var(--green-2); font-style: normal; }
.hero-lede { max-width: 590px; margin: 28px 0; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.25rem); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-stats span { padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 75%, transparent); color: var(--muted); font-size: .88rem; }
.hero-stats b { color: var(--ink); }
.neural-visual { position: relative; min-height: 460px; display: grid; place-items: center; }
.neural-visual svg { width: min(100%, 520px); overflow: visible; }
.axon-lines path { stroke: var(--green-2); stroke-width: 3; opacity: .7; stroke-dasharray: 7 9; animation: signal 8s linear infinite; }
.nodes circle { stroke: var(--green-2); stroke-width: 3; }
.cell { transform-origin: 266px 213px; animation: breathe 5s ease-in-out infinite; }
.orbit { position: absolute; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); font-size: .8rem; font-weight: 700; }
.orbit-a { top: 17%; right: 2%; }.orbit-b { bottom: 18%; left: 2%; }.orbit-c { bottom: 4%; right: 20%; }
@keyframes signal { to { stroke-dashoffset: -80; } }
@keyframes breathe { 50% { transform: scale(1.04) rotate(2deg); } }

.section-wrap { max-width: 1180px; margin: 0 auto 80px; padding: 0 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 26px; }
h2 { margin: 0; font-size: clamp(2.2rem, 4vw, 3.7rem); }
.best-score { margin: 0; color: var(--muted); font-size: .9rem; }
.route-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.route-card { position: relative; min-height: 190px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: transform .2s, border-color .2s, box-shadow .2s; }
.route-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.route-card.selected { border: 2px solid var(--green-2); padding: 21px; background: var(--surface-2); }
.route-card input { position: absolute; opacity: 0; }
.route-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: #173229; background: var(--lime); font-size: 1.3rem; }
.route-card:nth-child(2) .route-icon { background: var(--orange-soft); }
.route-card:nth-child(3) .route-icon { background: #dce7f5; }
[data-theme="dark"] .route-card:nth-child(3) .route-icon { background: #283a4c; color: #dce7f5; }
.route-card h3 { margin: 22px 0 4px; font-size: 1.1rem; line-height: 1.25; }
.route-card p { margin: 0; color: var(--muted); font-size: .85rem; }
.route-count { position: absolute; top: 22px; right: 20px; color: var(--muted); font-size: .76rem; }
.control-panel { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr .75fr; gap: 18px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; font-weight: 700; }
.segmented { display: flex; gap: 6px; padding: 5px; border-radius: 13px; background: var(--paper); }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { min-height: 42px; display: grid; place-items: center; padding: 6px 9px; border-radius: 9px; text-align: center; font-size: .84rem; }
.segmented input:checked + span { background: var(--surface); box-shadow: 0 2px 9px rgba(0,0,0,.08); color: var(--green-2); font-weight: 700; }
.control-hint { margin: 8px 4px 0; color: var(--muted); font-size: .78rem; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.toggle-row span { display: flex; flex-direction: column; }.toggle-row small { color: var(--muted); }
.toggle-row input { width: 46px; height: 25px; accent-color: var(--green); cursor: pointer; }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 24px; }
.button { min-height: 48px; padding: 11px 20px; border: 1px solid transparent; border-radius: 13px; font-weight: 700; cursor: pointer; transition: transform .15s, filter .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: var(--surface); }
[data-theme="dark"] .button.primary { color: #10201c; }
.button.quiet { border-color: var(--line); background: var(--surface); }
.button.text-button { background: transparent; color: var(--green-2); }

.quiz-view { max-width: 900px; padding-top: 34px; }
.quiz-topline, .quiz-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quiz-status { color: var(--muted); font-size: .86rem; }
.streak, .timer { padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.timer.urgent { color: var(--red); border-color: var(--red); animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.progress { height: 7px; margin: 16px 0 24px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--green-2), var(--lime)); transition: width .3s ease; }
.question-card { padding: clamp(24px, 5vw, 52px); border: 1px solid var(--line); border-radius: 32px; background: var(--surface); box-shadow: var(--shadow); }
.question-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.topic-tag { color: var(--green-2); font-weight: 700; }
.question-card h2 { max-width: 760px; margin: 22px 0 30px; font-family: "DM Sans", sans-serif; font-size: clamp(1.5rem, 3.2vw, 2.25rem); line-height: 1.25; letter-spacing: -.025em; }
.answer-list { display: grid; gap: 10px; }
.answer { width: 100%; display: flex; align-items: center; gap: 14px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; cursor: pointer; }
.answer:hover:not(:disabled) { border-color: var(--green-2); background: var(--surface-2); }
.answer:disabled { cursor: default; }
.answer-key { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; font-weight: 700; }
.answer.correct { border-color: var(--green-2); background: var(--surface-2); }
.answer.correct .answer-key { background: var(--green-2); color: var(--surface); border-color: var(--green-2); }
.answer.incorrect { border-color: var(--red); background: var(--red-soft); }
.answer.incorrect .answer-key { background: var(--red); color: var(--surface); border-color: var(--red); }
.feedback-card { margin-top: 20px; padding: 17px; display: flex; gap: 14px; border-radius: 16px; background: var(--surface-2); }
.feedback-card.error { background: var(--red-soft); }
.feedback-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--green-2); color: var(--surface); font-weight: 700; }
.feedback-card.error .feedback-icon { background: var(--red); }
.feedback-card h3 { margin: 0 0 4px; font-size: 1rem; }.feedback-card p { margin: 0; color: var(--muted); }
.question-actions { min-height: 48px; margin-top: 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.key-hint { color: var(--muted); font-size: .78rem; }

.results-view { max-width: 960px; padding-top: 34px; }
.results-hero { display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 38px; padding: 34px; border-radius: 30px; color: #f4fff9; background: #173f38; }
.results-hero h2 { color: #fff; }.results-hero p { color: #d2e6df; }
.score-ring { width: 164px; height: 164px; display: grid; place-content: center; text-align: center; border: 10px solid #7fc5aa; border-radius: 50%; background: #214f46; }
.score-ring span { font-family: "Fraunces", serif; font-size: 2.9rem; line-height: 1; }.score-ring small { color: #c9ded7; }
.result-pills { display: flex; flex-wrap: wrap; gap: 8px; }.result-pills span { padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.1); font-size: .78rem; }
.results-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; margin-top: 16px; }
.result-card { padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.result-card h3 { margin-top: 0; }.topic-result { margin: 16px 0; }.topic-result p { display: flex; justify-content: space-between; gap: 10px; margin: 0 0 6px; font-size: .88rem; }
.mini-bar { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }.mini-bar span { display: block; height: 100%; background: var(--green-2); }
.review-panel { margin-top: 16px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.review-panel summary { cursor: pointer; font-weight: 700; }.review-panel li { margin: 20px 0; padding-left: 8px; }.review-panel p { margin: 5px 0; }.review-answer { color: var(--green-2); }.review-explanation { color: var(--muted); }

.teacher-view { padding-top: 34px; }.teacher-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; }.teacher-heading p { color: var(--muted); }.teacher-actions { display: flex; gap: 8px; }
.teacher-toolbar { margin: 28px 0 18px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.teacher-toolbar label { display: flex; align-items: center; gap: 10px; }.teacher-toolbar select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
.compact { min-width: 220px; }.teacher-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 0; list-style: none; counter-reset: item; }
.teacher-item { counter-increment: item; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }.teacher-item h3 { margin: 0 0 10px; font-size: 1rem; }.teacher-item h3::before { content: counter(item) ". "; color: var(--green-2); }.teacher-item ul { margin: 0; padding-left: 21px; color: var(--muted); font-size: .88rem; }.teacher-answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .87rem; }.teacher-answer b { color: var(--green-2); }

.sources { padding-top: 36px; border-top: 1px solid var(--line); }.source-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 24px; }.source-links a { display: flex; justify-content: space-between; gap: 12px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); text-decoration: none; }.source-links a:hover { border-color: var(--green-2); }.disclaimer { max-width: 780px; color: var(--muted); font-size: .82rem; }
footer { max-width: 1180px; margin: 0 auto; padding: 22px 28px 40px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translate(-50%, 140%); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--paper); transition: transform .25s; }.toast.show { transform: translate(-50%, 0); }

:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; } }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; padding-top: 35px; }.neural-visual { min-height: 380px; }.route-grid { grid-template-columns: repeat(2, 1fr); }.control-panel { grid-template-columns: 1fr 1fr; }.control-panel > :last-child { grid-column: 1 / -1; }.source-links { grid-template-columns: 1fr; }.teacher-list { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .topbar, .hero, .section-wrap, footer { padding-left: 18px; padding-right: 18px; }.hero { min-height: auto; padding-bottom: 55px; }.neural-visual { min-height: 300px; }.route-grid, .control-panel, .results-grid { grid-template-columns: 1fr; }.control-panel > :last-child { grid-column: auto; }.section-heading, .teacher-heading, .teacher-toolbar { align-items: stretch; flex-direction: column; }.results-hero { grid-template-columns: 1fr; text-align: center; }.score-ring { margin: auto; }.result-pills { justify-content: center; }.question-card { border-radius: 22px; }.quiz-topline { align-items: start; }.quiz-status { flex-wrap: wrap; justify-content: end; }.key-hint { display: none; }.question-actions { justify-content: flex-end; }.teacher-actions { flex-wrap: wrap; }.source-links { grid-template-columns: 1fr; } }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, #homeView, #setupView, #quizView, #resultsView, #sourcesView, footer, .teacher-actions, .teacher-toolbar { display: none !important; }
  #teacherView { display: block !important; max-width: none; margin: 0; padding: 0; }
  .teacher-list { display: block; }.teacher-item { break-inside: avoid; margin-bottom: 12px; border: 1px solid #aaa; }
}
