:root {
  --ink: #14233b;
  --muted: #657187;
  --line: #dce2e9;
  --surface: #ffffff;
  --canvas: #f3f8fa;
  --navy: #164b73;
  --navy-strong: #0b304d;
  --teal: #008b80;
  --teal-soft: #ddf7f2;
  --coral: #c43f55;
  --coral-soft: #fff0f3;
  --amber: #a66700;
  --focus: #1675d1;
  --control: #edf3f6;
  --input: #ffffff;
  --header-accent: #14a69a;
  --shadow: 0 12px 32px rgba(19, 55, 78, .1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}
[data-theme="dark"] {
  --ink: #edf7fa;
  --muted: #a8bac4;
  --line: #344d5a;
  --surface: #172a34;
  --canvas: #0d1d25;
  --navy: #39a7d8;
  --navy-strong: #d7f3ff;
  --teal: #42d3bd;
  --teal-soft: #153d3b;
  --coral: #ff8192;
  --coral-soft: #45252d;
  --amber: #ffc55c;
  --focus: #73bfff;
  --control: #243c48;
  --input: #10232d;
  --header-accent: #42d3bd;
  --shadow: 0 14px 34px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); font-size: 16px; line-height: 1.5; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--navy); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent); outline-offset: 2px; }
.site-header { height: 68px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--surface); border-bottom: 3px solid var(--header-accent); }
.site-header nav { display: flex; align-items: center; gap: 22px; }
.site-header nav a, .link-button { color: var(--ink); font-weight: 650; text-decoration: none; border: 0; background: none; cursor: pointer; padding: 8px 0; }
.inline-form { display: inline; margin: 0; }
.theme-toggle { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--control); color: var(--ink); cursor: pointer; font-size: 1.15rem; }
.theme-toggle:hover { border-color: var(--teal); color: var(--teal); }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--navy-strong); font-weight: 800; text-decoration: none; }
.brand-lockup img { width: 34px; height: 34px; }
.brand-lockup-large { font-size: 1.15rem; margin-bottom: 28px; }
.brand-lockup-large img { width: 42px; height: 42px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy-strong); border-top: 8px solid var(--teal); }
.auth-panel { width: min(100%, 430px); background: var(--surface); border-radius: 8px; padding: clamp(28px, 6vw, 48px); box-shadow: var(--shadow); }
.auth-panel h1 { margin: 0; font-size: 2rem; line-height: 1.15; }
.muted, .auth-panel p { color: var(--muted); }
.form-stack { display: grid; gap: 18px; margin-top: 28px; }
label { font-weight: 650; }
input[type="email"], input[type="password"], input[type="text"], input[type="number"] { width: 100%; min-height: 48px; margin-top: 7px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--input); color: var(--ink); }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 6px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; text-decoration: none; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { background: var(--navy); color: #fff; box-shadow: 0 5px 14px color-mix(in srgb, var(--navy) 24%, transparent); }
[data-theme="dark"] .button-primary { color: #071c26; }
.button-primary:hover:not(:disabled) { background: var(--navy-strong); }
.button-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.alert { margin: 20px 0; padding: 12px 14px; border: 1px solid; border-radius: 6px; }
.alert-error { color: #8a2029; background: var(--coral-soft); border-color: #e9a9ae; }
.alert-success { color: #08625d; background: var(--teal-soft); border-color: #9bd3ce; }
.page-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 32px; }
.page-heading h1 { margin: 4px 0 0; font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1.15; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--teal); font-size: .82rem; font-weight: 800; text-transform: uppercase; }
.subject-list { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.subject-list > legend { font-size: 1rem; font-weight: 750; margin-bottom: 10px; }
.subject-row { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; transition: border-color .15s ease, box-shadow .15s ease; }
.subject-row.is-selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.subject-check { min-height: 72px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.subject-check input, .topic-grid input { width: 20px; height: 20px; accent-color: var(--teal); flex: 0 0 auto; }
.subject-check span { display: grid; }
.subject-check small { color: var(--muted); font-weight: 500; }
.subject-options { padding: 0 18px 18px 52px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 9px 14px; font-size: .9rem; }
.segmented input:checked + span { background: var(--navy); color: #fff; }
.topic-grid { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.topic-grid label { display: flex; gap: 10px; align-items: start; font-weight: 550; }
.practice-actions { margin-top: 28px; padding: 20px; background: var(--surface); border-top: 3px solid var(--navy); display: flex; justify-content: space-between; align-items: end; gap: 24px; box-shadow: var(--shadow); }
.practice-actions label { width: 210px; }
.empty-state { text-align: center; background: var(--surface); border: 1px solid var(--line); padding: 64px 24px; }
.quiz-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(0, 1fr) 280px; padding-bottom: 78px; }
.quiz-main { width: min(900px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 64px; }
.quiz-meta { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: .92rem; }
.quiz-meta span { color: var(--teal); font-weight: 750; }
.progress-track { height: 5px; background: var(--control); margin: 12px 0 24px; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--teal); transition: width .2s ease; }
.question-stage { min-height: 250px; padding: clamp(18px, 3.5vw, 34px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.question-asset, .explanation-asset, .question-figure, .explanation-figure { display: block; width: 100%; height: auto; object-fit: contain; }
.question-asset + .question-asset, .explanation-asset + .explanation-asset, .question-figure + .question-figure, .explanation-figure + .explanation-figure { margin-top: 10px; }
.question-copy { white-space: pre-line; font-family: Georgia, "Times New Roman", serif; font-size: 1.24rem; line-height: 1.65; }
.question-copy + .question-figure { margin-top: 22px; }
.explanation-copy { white-space: pre-line; font-size: 1rem; line-height: 1.7; }
.explanation-copy + .explanation-figure { margin-top: 20px; }
.skeleton { color: var(--muted); padding: 60px 0; text-align: center; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.answer-button { min-height: 64px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); display: grid; grid-template-columns: 38px 1fr; grid-template-rows: 1fr auto; align-items: center; text-align: left; cursor: pointer; }
.answer-button > span { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--control); font-weight: 850; }
.answer-button strong { font-size: 1rem; line-height: 1.4; }
.answer-button em { min-height: 18px; font-size: .78rem; font-style: normal; color: var(--muted); }
.answer-button:hover:not(:disabled) { border-color: var(--navy); }
.answer-button.is-correct { border-color: var(--teal); background: var(--teal-soft); }
.answer-button.is-correct > span { background: var(--teal); color: #fff; }
.answer-button.is-incorrect { border-color: var(--coral); background: var(--coral-soft); }
.answer-button.is-incorrect > span { background: var(--coral); color: #fff; }
.reveal-panel { margin-top: 24px; padding: clamp(18px, 3vw, 30px); background: var(--surface); border-left: 4px solid var(--teal); }
.reveal-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.reveal-panel h2 { font-size: 1.2rem; margin: 22px 0 14px; }
.text-correct { color: var(--teal); }
.text-incorrect { color: var(--coral); }
.navigator-panel { background: var(--surface); border-left: 1px solid var(--line); padding: 24px 20px; }
.navigator-heading { display: flex; align-items: center; justify-content: space-between; }
.navigator-heading h2 { margin: 0 0 18px; font-size: 1rem; }
.icon-button { display: none; border: 0; background: none; font-size: 1.8rem; cursor: pointer; }
.navigator-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.navigator-item { aspect-ratio: 1; min-width: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); cursor: pointer; position: relative; }
.navigator-item.is-current { outline: 3px solid var(--navy); outline-offset: 1px; }
.navigator-item.is-correct { border-color: var(--teal); background: var(--teal-soft); }
.navigator-item.is-incorrect { border-color: var(--coral); background: var(--coral-soft); }
.navigator-item.is-marked::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); position: absolute; top: 3px; right: 3px; }
.quiz-controls { position: fixed; z-index: 20; left: 0; right: 280px; bottom: 0; min-height: 72px; padding: 12px max(20px, calc((100vw - 1180px) / 2)); display: flex; gap: 10px; justify-content: space-between; background: var(--surface); border-top: 1px solid var(--line); }
.quiz-controls .is-active { border-color: var(--amber); color: var(--amber); }
.nav-toggle { display: none; }
.result-shell { max-width: 820px; text-align: center; }
.result-hero { padding: 24px 0 32px; }
.result-hero h1 { margin: 8px 0 0; font-size: clamp(3.5rem, 9vw, 6.5rem); line-height: 1; }
.result-avatar { width: min(320px, 80vw); height: auto; max-height: 320px; object-fit: contain; margin-bottom: 18px; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); margin-bottom: 24px; }
.result-stats div { padding: 20px 10px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border-right: 0; }
.result-stats strong, .result-stats span { display: block; }
.result-stats strong { font-size: 1.7rem; }
.result-stats span { color: var(--muted); font-size: .9rem; }
.breakdown { text-align: left; background: var(--surface); border: 1px solid var(--line); padding: 20px; margin-bottom: 24px; }
.breakdown h2 { font-size: 1rem; margin: 0 0 12px; }
.breakdown div { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.admin-section { margin-bottom: 32px; }
.admin-section h2 { font-size: 1.05rem; }
.import-list { display: grid; gap: 10px; }
.import-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.import-row > div { display: grid; gap: 4px; }
.import-row span { color: var(--muted); font-size: .9rem; }
.import-row progress { width: 220px; accent-color: var(--teal); }
.user-create { max-width: 560px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.user-create h2 { margin-top: 0; }
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.user-table th, .user-table td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--line); }
.user-table th { color: var(--muted); font-size: .85rem; text-transform: uppercase; }
@media (max-width: 800px) {
  .site-header { height: 60px; padding: 0 16px; }
  .site-header nav { gap: 14px; }
  .theme-toggle { width: 36px; height: 36px; }
  .site-header .brand-lockup span { display: none; }
  .page-shell { width: min(100% - 24px, 1120px); padding-top: 28px; }
  .page-heading { align-items: start; flex-direction: column; }
  .topic-grid { grid-template-columns: 1fr; }
  .subject-options { padding-left: 18px; }
  .practice-actions { align-items: stretch; flex-direction: column; }
  .practice-actions label { width: 100%; }
  .quiz-shell { display: block; min-height: calc(100vh - 60px); }
  .quiz-main { width: calc(100% - 20px); padding-top: 18px; }
  .answer-grid { grid-template-columns: 1fr; }
  .navigator-panel { position: fixed; z-index: 40; inset: 60px 0 0 15%; border-left: 1px solid var(--line); transform: translateX(110%); transition: transform .2s ease; box-shadow: -16px 0 40px rgba(20,35,59,.18); }
  .navigator-panel.is-open { transform: translateX(0); }
  .icon-button, .nav-toggle { display: inline-grid; place-items: center; }
  .quiz-controls { right: 0; min-height: 68px; padding: 10px; }
  .quiz-controls .button { min-width: 48px; padding: 8px 12px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-stats div:nth-child(2) { border-right: 0; }
  .result-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .import-row { align-items: stretch; flex-direction: column; }
  .import-row progress { width: 100%; }
}
@media (max-width: 430px) {
  .site-header nav { gap: 10px; }
  .site-header nav a { font-size: .9rem; }
  .segmented { display: grid; }
  .quiz-controls .button span { display: none; }
  .question-stage { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
