:root {
  --navy: #183148;
  --navy-deep: #11283c;
  --ink: #25394b;
  --muted: #667b8c;
  --line: #d8e4eb;
  --rail: #f5f8f9;
  --blue: #31a9dc;
  --blue-dark: #1389bd;
  --blue-soft: #eaf7fd;
  --footer: #e3f5fc;
  --red: #d9534f;
  --green: #2ea664;
  --green-soft: #e9f7ee;
  --base-text-size: 1rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; font-size: 16px; }

body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #fff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: var(--base-text-size);
}

button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, [data-highlight-target]:focus-visible {
  outline: 3px solid rgba(49, 169, 220, .28);
  outline-offset: 3px;
}

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(420px, 1.5fr) auto;
  align-items: stretch;
  color: #fff;
  background: var(--navy);
  position: relative;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; padding: 0 16px; white-space: nowrap; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .6);
  border-radius: 10px;
  color: var(--blue);
  font-size: 1.3rem;
  font-weight: 800;
}
.brand-copy { display: grid; gap: 1px; }
.brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: -.025em; }
.brand-product { color: #a9dcef; font-size: .69rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.exam-context { display: flex; justify-content: center; align-items: center; gap: 34px; min-width: 0; }
.exam-title { overflow: hidden; color: #d9e3e9; font-size: .98rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.timer { display: flex; align-items: center; gap: 18px; white-space: nowrap; }
.timer-label { color: #b7c5cf; font-size: .8rem; font-weight: 750; letter-spacing: .12em; }
.timer strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.top-actions { display: flex; align-self: stretch; }
.top-button {
  min-width: 150px;
  padding: 0 18px;
  border: 0;
  color: #fff;
  background: transparent;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .09em;
  white-space: nowrap;
}
.top-button:last-child { min-width: 126px; }
.top-button:hover, .top-button[aria-expanded="true"] { background: rgba(0, 0, 0, .16); }

.lecture-home {
  height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 56px clamp(28px, 6vw, 112px) 72px;
  background: linear-gradient(180deg, #f7fbfd 0, #fff 280px);
}
.lecture-home-copy { max-width: 850px; margin: 0 auto 38px; text-align: center; }
.home-kicker { color: var(--blue-dark); font-size: .78rem; font-weight: 850; letter-spacing: .16em; }
.lecture-home h1 { margin: 10px 0 12px; color: var(--navy); font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.04em; }
.lecture-home-copy p { max-width: 720px; margin: 0 auto; color: var(--muted); font-size: 1.02rem; line-height: 1.65; }
.home-summary { margin-top: 16px; color: #4f6879; font-size: .83rem; font-weight: 750; }
.lecture-grid {
  width: min(1380px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.lecture-card {
  min-height: 160px;
  padding: 20px;
  border: 1px solid #d6e3e9;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  color: var(--ink);
  background: #fff;
  text-align: left;
  box-shadow: 0 7px 22px rgba(24, 49, 72, .055);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.lecture-card:hover { transform: translateY(-2px); border-color: #95d6ee; box-shadow: 0 12px 30px rgba(24, 49, 72, .1); }
.lecture-card.comprehensive { grid-column: 1 / -1; min-height: 142px; border-color: #9fd9ef; background: linear-gradient(135deg, #effaff, #fff); }
.lecture-card-code { color: var(--blue-dark); font-size: .74rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.lecture-card-title { margin: 9px 0 22px; color: #263e50; font-size: 1rem; font-weight: 780; line-height: 1.38; }
.lecture-card-meta { margin-top: auto; display: flex; justify-content: space-between; gap: 12px; color: #718492; font-size: .75rem; }
.lecture-card-meta strong { color: var(--navy); font-size: .83rem; }

.app-shell { height: calc(100vh - 164px); display: grid; grid-template-columns: 94px minmax(0, 1fr); }
.question-rail { overflow: hidden; border-right: 1px solid #d4e0e6; background: var(--rail); }
.rail-toolbar {
  height: 48px;
  position: relative;
  display: grid;
  place-items: center;
}
.rail-toolbar::after { content: "⌃"; color: #5f7382; font-size: 1.3rem; pointer-events: none; }
.rail-toolbar label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rail-toolbar select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.question-grid {
  height: calc(100% - 48px);
  padding: 8px 12px 50px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  justify-items: center;
  gap: 10px;
  scrollbar-width: thin;
}
.nav-question {
  width: 52px;
  min-height: 52px;
  position: relative;
  border: 0;
  border-radius: 50%;
  color: #657989;
  background: transparent;
  font-size: 1rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.nav-question:hover { color: var(--blue-dark); background: #eaf3f7; }
.nav-question.current { color: #fff; background: var(--green); box-shadow: 0 0 0 6px #def1e6; }
.nav-question.submitted:not(.current) { background: #fff; box-shadow: inset 0 0 0 1px #cbd8df; }
.nav-question.correct:not(.current) { color: #287d4d; }
.nav-question.incorrect:not(.current) { color: #a64a47; }
.nav-question.correct::after,
.nav-question.incorrect::after,
.nav-question.flagged::after {
  position: absolute;
  right: -2px;
  bottom: 1px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #fff;
  font-size: .62rem;
  font-weight: 900;
  line-height: 1;
}
.nav-question.correct::after { content: "✓"; color: var(--green); }
.nav-question.incorrect::after { content: "×"; color: var(--red); }
.nav-question.flagged:not(.correct):not(.incorrect)::after { content: "!"; color: #e5912b; }

.exam-surface { min-width: 0; overflow-y: auto; background: #fff; }
.question-toolbar {
  min-height: 164px;
  padding: 74px 92px 26px 124px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.question-identity { min-width: 0; }
.learning-objective {
  margin-bottom: 9px;
  color: var(--blue);
  font-size: .87rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.question-count { color: #5e7282; font-size: 1.05rem; font-weight: 750; }
.source-number { display: none; }
.flag-button {
  min-height: 46px;
  margin-left: auto;
  padding: 0 18px;
  border: 1px solid #d3e0e7;
  border-radius: 10px;
  color: #607385;
  background: #fff;
  font-size: 1rem;
  font-weight: 650;
}
.flag-button:hover, .flag-button[aria-pressed="true"] { border-color: var(--blue); color: var(--blue-dark); background: #f5fbfe; }
.font-tools, .mobile-questions { display: none; }

.question-card { width: auto; max-width: 1480px; padding: 0 92px 80px 124px; margin: 0; }
.question-stem {
  max-width: 1080px;
  margin: 0 0 30px;
  color: #24394b;
  font-size: 1.08em;
  line-height: 1.8;
}
.stem-lead { margin-top: 24px; font-weight: 760; line-height: 1.5; }
.question-media { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 26px; }
.source-figure { max-width: min(540px, 100%); margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fafcfd; }
.source-figure img { display: block; max-width: 100%; height: auto; }
.source-figure figcaption { padding: 7px 10px; color: var(--muted); font-size: .76rem; }
.answer-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.answer-list { display: grid; gap: 14px; }
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 14px; align-items: center; }
.answer-choice {
  width: 100%;
  min-height: 66px;
  padding: 10px 20px 10px 16px;
  border: 2px solid transparent;
  border-radius: 999px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #273d50;
  background: #f4f6f8;
  text-align: left;
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.answer-choice:hover { background: #eef4f7; }
.answer-row.selected .answer-choice { border-color: #a6def4; background: #f5fbfe; box-shadow: 0 0 0 1px rgba(49, 169, 220, .08); }
.answer-letter {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #cad9e1;
  border-radius: 50%;
  color: #617788;
  background: #fff;
  font-size: .88rem;
  font-weight: 750;
}
.answer-text { min-width: 0; font-size: 1.02em; line-height: 1.45; user-select: text; }
.strikeout-button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid #d4e1e8;
  border-radius: 50%;
  color: #7e94a3;
  background: #fff;
  font-size: 1.05rem;
  font-weight: 800;
}
.strikeout-button:hover { border-color: var(--blue); color: var(--blue-dark); background: #f6fbfe; }
.answer-row.struck .answer-text { color: #80909b; text-decoration: line-through 2px; text-decoration-color: #778a97; }
.answer-row.struck .answer-choice { background: #f7f8f9; }
.answer-row.struck .strikeout-button { color: var(--red); border-color: #e4b7b4; background: #fff8f7; }
.answer-row.correct .answer-choice { border-color: #75c996; background: var(--green-soft); }
.answer-row.correct .answer-letter { color: #287d4d; border-color: #75c996; }
.answer-row.reviewed-wrong.selected .answer-choice { border-color: #e29b98; background: #fff3f2; }
.option-rationale {
  grid-column: 1 / -1;
  margin: -4px 66px 2px 18px;
  padding: 9px 14px;
  border-left: 3px solid #c9dbe4;
  color: #5d7180;
  font-size: .82rem;
  line-height: 1.5;
}

mark { padding: .06em .04em; color: inherit; border-radius: 2px; }
mark.highlight-yellow { background: #ffe56d; }
mark.highlight-green { background: #a9edbd; }
mark.highlight-blue { background: #a8def6; }
mark.highlight-pink { background: #f8b7d0; }

.explanation {
  max-width: 1120px;
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid #cee1e9;
  border-top: 4px solid var(--blue);
  border-radius: 8px;
  background: #f7fcfe;
}
.explanation.correct-result { border-top-color: var(--green); background: #f8fdfa; }
.explanation.incorrect-result { border-top-color: var(--red); background: #fffafa; }
.explanation h2 { margin: 8px 0 8px; font-size: 1rem; }
.explanation p { margin: 0; font-size: .94rem; line-height: 1.6; }
#explanationText { white-space: pre-line; }
.result-badge { display: inline-block; color: var(--ink); font-size: .75rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.correct-result .result-badge { color: var(--green); }
.incorrect-result .result-badge { color: var(--red); }
.source-note { margin-top: 10px !important; color: var(--muted); font-size: .76rem !important; }
.lecture-reference { margin-top: 22px; padding-top: 20px; border-top: 1px solid #d7e5eb; }
.reference-kicker { margin-bottom: 6px; color: var(--blue-dark); font-size: .73rem; font-weight: 850; letter-spacing: .11em; }
.lecture-reference h3 { margin: 0; color: #263e50; font-size: 1.05rem; }
.reference-block { margin-top: 18px; }
.reference-block h4 { margin: 0 0 9px; color: #516a7a; font-size: .78rem; font-weight: 850; letter-spacing: .055em; text-transform: uppercase; }
.objective-list, .key-point-list { margin: 0; padding: 0; list-style: none; }
.objective-list { display: grid; gap: 9px; }
.objective-list li { padding: 11px 13px; border-left: 4px solid var(--blue); border-radius: 0 7px 7px 0; background: #edf8fc; }
.objective-list strong { display: block; margin-bottom: 4px; color: var(--blue-dark); font-size: .72rem; overflow-wrap: anywhere; }
.objective-list span { color: #314b5d; font-size: .88rem; line-height: 1.5; }
.key-point-list { display: grid; gap: 7px; padding-left: 20px; list-style: disc; }
.key-point-list li { color: #3d5666; font-size: .87rem; line-height: 1.5; }
.reference-slide { margin: 20px 0 0; overflow: hidden; border: 1px solid #c9dbe4; border-radius: 9px; background: #fff; box-shadow: 0 5px 18px rgba(24, 49, 72, .08); }
.reference-slide a { display: block; background: #eef3f6; }
.reference-slide img { display: block; width: 100%; height: auto; max-height: 780px; object-fit: contain; }
.reference-slide figcaption { padding: 10px 13px; color: #617685; background: #f8fbfc; font-size: .76rem; line-height: 1.4; }

.footerbar {
  height: 92px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 230px minmax(160px, 1fr) auto;
  align-items: center;
  gap: 30px;
  border-top: 1px solid #c9e8f4;
  background: var(--footer);
}
.footer-progress-copy { display: grid; gap: 3px; }
.footer-progress-copy strong { color: #243b4d; font-size: .78rem; letter-spacing: .08em; }
.footer-progress-copy span { color: #708491; font-size: .76rem; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #c5e5f1; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .2s ease; }
.footer-actions { display: flex; gap: 14px; }
.secondary-button, .primary-button {
  min-width: 145px;
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 750;
}
.secondary-button { color: #fff; background: #91a9b8; }
.secondary-button:hover:not(:disabled) { background: #728d9e; }
.secondary-button:disabled { opacity: .55; cursor: default; }
.primary-button { color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }

.popover {
  position: fixed;
  right: 18px;
  top: 82px;
  z-index: 80;
  width: min(360px, calc(100vw - 36px));
  padding: 20px;
  border: 1px solid #cfdee6;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(13, 38, 55, .22);
}
.popover h2 { margin: 0 0 14px; font-size: 1.05rem; }
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #e5ecef; font-size: .88rem; }
.audit-note { color: var(--muted); font-size: .79rem; line-height: 1.5; }
.danger-button { width: 100%; margin-top: 7px; padding: 11px; border: 1px solid #dcaaaa; border-radius: 6px; color: var(--red); background: #fff; font-weight: 750; }
.toolkit { display: grid; gap: 10px; max-height: calc(100vh - 175px); overflow-y: auto; }
.toolkit textarea, .toolkit input { width: 100%; border: 1px solid #c9d6dd; border-radius: 6px; padding: 10px; color: var(--ink); background: #fbfcfd; }
.toolkit label, .tool-label { margin-top: 3px; font-size: .8rem; font-weight: 750; }
.tool-section { padding-bottom: 11px; border-bottom: 1px solid #e5edf1; }
.highlight-swatches { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.highlight-swatch { width: 30px; height: 30px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #c8d5dc; }
.highlight-swatch.yellow { background: #ffe56d; }
.highlight-swatch.green { background: #a9edbd; }
.highlight-swatch.blue { background: #a8def6; }
.highlight-swatch.pink { background: #f8b7d0; }
.clear-highlights { margin-left: auto; padding: 6px 9px; border: 1px solid #cedbe2; border-radius: 5px; color: #617584; background: #fff; font-size: .76rem; font-weight: 700; }
.tool-help { margin: 7px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.calculator-row { display: grid; grid-template-columns: 1fr 44px; gap: 7px; }
.calculator-row button { border: 0; border-radius: 6px; color: #fff; background: var(--blue); font-weight: 800; }
#calculatorOutput { min-height: 22px; color: var(--blue-dark); font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 108px; z-index: 100; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 11px 15px; border-radius: 6px; color: #fff; background: var(--navy-deep); box-shadow: 0 8px 30px rgba(0,0,0,.2); font-size: .87rem; font-weight: 700; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand-name { font-size: .94rem; }
  .exam-context { gap: 18px; }
  .timer-label { display: none; }
  .top-button { min-width: 108px; font-size: .7rem; }
  .question-toolbar { padding-left: 70px; padding-right: 50px; }
  .question-card { padding-left: 70px; padding-right: 50px; }
}

@media (max-width: 800px) {
  .topbar { height: 62px; grid-template-columns: auto minmax(0, 1fr) auto; }
  .brand { padding: 0 10px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-copy { display: none; }
  .exam-context { justify-content: flex-start; }
  .exam-title { font-size: .8rem; }
  .timer { display: none; }
  .top-button { min-width: 52px; width: 52px; padding: 0; font-size: 0; }
  #lectureHomeButton::before { content: "☰"; font-size: 1rem; }
  .top-button span { font-size: 1rem; }
  .app-shell { height: calc(100vh - 140px); grid-template-columns: 58px minmax(0, 1fr); }
  .question-rail { width: 58px; }
  .nav-question { width: 38px; min-height: 38px; font-size: .8rem; }
  .question-toolbar { min-height: 120px; padding: 38px 24px 22px 30px; }
  .question-card { padding: 0 24px 70px 30px; }
  .learning-objective { font-size: .75rem; }
  .question-stem { font-size: 1em; line-height: 1.65; }
  .answer-row { grid-template-columns: minmax(0, 1fr) 46px; gap: 8px; }
  .answer-choice { min-height: 58px; }
  .strikeout-button { width: 44px; height: 44px; }
  .footerbar { height: 78px; grid-template-columns: 150px 1fr auto; gap: 14px; padding: 0 10px; }
  .footer-progress-copy strong { font-size: .65rem; }
  .secondary-button, .primary-button { min-width: 94px; height: 44px; padding: 0 14px; font-size: .88rem; }
}

@media (max-width: 560px) {
  .exam-title { display: none; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .question-toolbar { padding: 26px 14px 18px; min-height: 105px; }
  .question-card { padding: 0 12px 60px 14px; }
  .flag-button { min-height: 40px; padding: 0 10px; font-size: .84rem; }
  .question-stem { margin-bottom: 22px; }
  .stem-lead { margin-top: 18px; }
  .answer-choice { min-height: 54px; padding: 8px 12px; grid-template-columns: 32px minmax(0, 1fr); }
  .answer-letter { width: 28px; height: 28px; }
  .answer-text { font-size: .92em; }
  .answer-row { grid-template-columns: minmax(0, 1fr) 40px; }
  .strikeout-button { width: 38px; height: 38px; }
  .footerbar { grid-template-columns: 1fr auto; }
  .progress-track { display: none; }
  .footer-progress-copy { padding-left: 2px; }
  .secondary-button { display: none; }
  .primary-button { min-width: 90px; }
  .lecture-home { height: calc(100vh - 62px); padding: 32px 14px 50px; }
  .lecture-grid { grid-template-columns: 1fr; }
}

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