/* Exam page — clean, focused, responsive. Loaded after the main shell styles. */
:root {
  --exam-bg: #f3f3f3;
  --exam-text: #20202a;
  --exam-muted: #667085;
  --exam-card: #ffffff;
  --exam-border: #d8dbe2;
  --exam-primary: #24245e;
  --exam-accent: #c34f4f;
  --exam-success: #14804a;
  --exam-warning: #b86a00;
  --exam-danger: #c0362c;
  --exam-shadow: 0 4px 17px rgba(0, 0, 0, .20);
}

body.exam-mode {
  background: var(--exam-bg) !important;
  color: var(--exam-text) !important;
  overflow-x: hidden !important;
}
body.theme-dark.exam-mode {
  --exam-bg: #000;
  --exam-text: #f3f4f8;
  --exam-muted: #a9adbc;
  --exam-card: #1f1f1f;
  --exam-border: #3a3a3a;
  --exam-shadow: 0 8px 28px rgba(0,0,0,.50);
}
body.exam-mode #codeScreen,
body.exam-mode #resultScreen[hidden] { display: none !important; }
body.exam-mode .exam-session {
  display: block !important;
  min-height: 100vh !important;
  background: var(--exam-bg) !important;
  color: var(--exam-text) !important;
}
body.exam-mode .exam-meta-hidden,
body.exam-mode #examClockBar,
body.exam-mode .exam-logo-wrap,
body.exam-mode .exam-profile { display: none !important; }

/* Desktop layout: readable paper + discreet sticky navigation */
body.exam-mode .exam-stage {
  width: min(1280px, calc(100vw - 40px)) !important;
  margin: 0 auto !important;
  padding: 34px 0 80px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 930px) 282px !important;
  justify-content: center !important;
  align-items: start !important;
  gap: 30px !important;
}
body.exam-mode .exam-paper-area { min-width: 0 !important; }
body.exam-mode #questionArea {
  display: flex !important;
  flex-direction: column !important;
  gap: 26px !important;
}

body.exam-mode .student-question-card {
  width: 100% !important;
  max-width: 930px !important;
  margin: 0 auto !important;
  background: var(--exam-card) !important;
  color: var(--exam-text) !important;
  border: 1px solid rgba(0,0,0,.10) !important;
  border-radius: 17px !important;
  box-shadow: var(--exam-shadow) !important;
  padding: 30px 42px 24px !important;
  scroll-margin-top: 28px !important;
}
body.theme-dark.exam-mode .student-question-card { border-color: rgba(255,255,255,.10) !important; }
body.exam-mode .student-question-card.active-question-card { box-shadow: 0 6px 24px rgba(36,36,94,.24) !important; }
body.exam-mode .student-question-card.missing-question-card { border-color: #df8c00 !important; box-shadow: 0 8px 24px rgba(223,140,0,.16) !important; }

body.exam-mode .question-card-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 18px !important;
  margin-bottom: 26px !important;
}
body.exam-mode .question-card-header h1 {
  margin: 0 !important;
  color: var(--exam-text) !important;
  font-family: Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
  font-size: clamp(22px, 2vw, 29px) !important;
  font-weight: 500 !important;
  line-height: 1.28 !important;
  letter-spacing: .01em !important;
}
body.exam-mode .question-score {
  flex: none !important;
  min-width: 76px !important;
  text-align: right !important;
  color: var(--exam-muted) !important;
  font-size: 12px !important;
}
body.exam-mode .question-score span { display: block !important; margin-bottom: 2px !important; }
body.exam-mode .question-score strong { display: block !important; color: var(--exam-text) !important; font-size: 15px !important; font-weight: 600 !important; }

body.exam-mode .missing-inline-warning {
  margin: -6px 0 22px !important;
  padding: 10px 12px !important;
  border: 1px solid rgba(223, 140, 0, .35) !important;
  border-radius: 10px !important;
  background: rgba(255, 247, 225, .88) !important;
  color: #8a4b00 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
}
body.theme-dark.exam-mode .missing-inline-warning { background: rgba(138,75,0,.24) !important; color: #ffd48a !important; }

body.exam-mode .question-statement-block { margin: 0 0 28px !important; }
body.exam-mode .question-statement-block h2 { display: none !important; }
body.exam-mode .statement {
  font-family: Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
  font-size: clamp(18px, 1.55vw, 22px) !important;
  line-height: 1.48 !important;
  color: var(--exam-text) !important;
  letter-spacing: .002em !important;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
}
body.exam-mode .statement p,
body.exam-mode .statement div { margin: 0 0 16px !important; }
body.exam-mode .statement p:last-child,
body.exam-mode .statement div:last-child { margin-bottom: 0 !important; }
body.exam-mode .statement ul,
body.exam-mode .statement ol { margin: 10px 0 16px 1.25em !important; padding-left: 1.15em !important; }
body.exam-mode .statement li { margin: 5px 0 !important; }

body.exam-mode .question-options {
  display: flex !important;
  flex-direction: column !important;
  margin: 22px -18px 0 !important;
}
body.exam-mode .choice {
  display: grid !important;
  grid-template-columns: 64px 1fr !important;
  align-items: center !important;
  width: 100% !important;
  min-height: 92px !important;
  border: 0 !important;
  border-top: 1px solid var(--exam-border) !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--exam-text) !important;
  text-align: left !important;
  padding: 22px 18px !important;
  cursor: pointer !important;
  transition: background .16s ease, color .16s ease !important;
}
body.exam-mode .choice:last-child { border-bottom: 1px solid var(--exam-border) !important; }
body.exam-mode .choice:hover { background: rgba(36,36,94,.055) !important; }
body.theme-dark.exam-mode .choice:hover { background: rgba(255,255,255,.055) !important; }
body.exam-mode .choice .letter {
  width: 47px !important;
  height: 47px !important;
  border: 2px solid var(--exam-primary) !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
  font-size: 18px !important;
  color: var(--exam-primary) !important;
  background: var(--exam-card) !important;
}
body.theme-dark.exam-mode .choice .letter { border-color: #c9c8ff !important; color: #fff !important; }
body.exam-mode .choice .option-text {
  font-family: Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
  font-size: clamp(17px, 1.45vw, 21px) !important;
  line-height: 1.42 !important;
  color: var(--exam-text) !important;
}
body.exam-mode .choice.selected { background: rgba(36,36,94,.09) !important; }
body.exam-mode .choice.selected .letter { background: var(--exam-primary) !important; color: #fff !important; }
body.exam-mode .choice.correct-choice { background: rgba(20,128,74,.09) !important; }
body.exam-mode .choice.correct-choice .letter { border-color: var(--exam-success) !important; background: var(--exam-success) !important; color: #fff !important; }
body.exam-mode .choice.wrong-choice { background: rgba(192,54,44,.09) !important; }
body.exam-mode .choice.wrong-choice .letter { border-color: var(--exam-danger) !important; background: var(--exam-danger) !important; color: #fff !important; }
body.exam-mode .choice.disabled-choice { cursor: default !important; }

body.exam-mode .feedback-box,
body.exam-mode .essay-answer-card {
  margin-top: 22px !important;
  padding: 16px !important;
  border-radius: 13px !important;
  border: 1px solid var(--exam-border) !important;
  background: rgba(248,250,252,.72) !important;
}
body.theme-dark.exam-mode .feedback-box,
body.theme-dark.exam-mode .essay-answer-card { background: rgba(255,255,255,.04) !important; }
body.exam-mode .feedback-box strong { display: block !important; margin-bottom: 4px !important; }
body.exam-mode .ok-feedback { border-color: rgba(20,128,74,.28) !important; color: var(--exam-success) !important; }
body.exam-mode .wrong-feedback { border-color: rgba(192,54,44,.28) !important; color: var(--exam-danger) !important; }
body.exam-mode .essay-answer-card h2 { margin: 0 0 10px !important; font-size: 16px !important; }
body.exam-mode .essay-input {
  width: 100% !important;
  min-height: 160px !important;
  border: 1px solid var(--exam-border) !important;
  border-radius: 12px !important;
  padding: 14px !important;
  resize: vertical !important;
  font: 16px/1.5 Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
  background: var(--exam-card) !important;
  color: var(--exam-text) !important;
}
body.exam-mode .save-note { margin-top: 8px !important; color: var(--exam-muted) !important; font-size: 12px !important; }

/* Desktop right panel */
body.exam-mode .exam-question-drawer {
  position: sticky !important;
  top: 30px !important;
  width: 282px !important;
  max-height: calc(100vh - 60px) !important;
  overflow: auto !important;
  background: rgba(255,255,255,.86) !important;
  color: var(--exam-text) !important;
  border: 1px solid rgba(36,36,94,.08) !important;
  border-radius: 18px !important;
  box-shadow: 0 10px 28px rgba(15,23,42,.11) !important;
  backdrop-filter: blur(10px) !important;
  padding: 14px !important;
  opacity: .74 !important;
  transition: opacity .18s ease, box-shadow .18s ease, transform .18s ease !important;
}
body.exam-mode .exam-question-drawer:hover,
body.exam-mode .exam-question-drawer:focus-within { opacity: 1 !important; box-shadow: 0 14px 36px rgba(15,23,42,.18) !important; }
body.theme-dark.exam-mode .exam-question-drawer { background: rgba(24,24,24,.86) !important; border-color: rgba(255,255,255,.10) !important; }
body.exam-mode .drawer-header { display: flex !important; justify-content: space-between !important; align-items: flex-start !important; gap: 10px !important; margin-bottom: 12px !important; cursor: default !important; }
body.exam-mode .drawer-kicker { display: block !important; color: var(--exam-muted) !important; font-size: 10px !important; font-weight: 800 !important; text-transform: uppercase !important; letter-spacing: .08em !important; }
body.exam-mode .drawer-title { margin: 2px 0 0 !important; font-size: 17px !important; font-weight: 800 !important; }
body.exam-mode .mobile-timer-text { display: none !important; }
body.exam-mode .drawer-tools { display: flex !important; align-items: center !important; gap: 8px !important; }
body.exam-mode .drawer-close { display: none !important; }
body.exam-mode #exam-theme-switch-container { width: auto !important; height: auto !important; background: transparent !important; box-shadow: none !important; }
body.exam-mode #exam-theme-switch-container .toggle { display: block !important; width: 45px !important; height: 24px !important; }
body.exam-mode #exam-theme-switch-container .toggle__input { display: none !important; }
body.exam-mode #exam-theme-switch-container .toggle__fill {
  width: 45px !important; height: 24px !important; border-radius: 999px !important; position: relative !important;
  background: rgba(36,36,94,.17) !important; box-shadow: none !important; border: 0 !important; cursor: pointer !important;
}
body.exam-mode #exam-theme-switch-container .toggle__fill::after {
  content: '' !important; position: absolute !important; width: 22px !important; height: 22px !important; top: 1px !important; left: 1px !important;
  border-radius: 50% !important; background: #fff !important; box-shadow: 0 2px 7px rgba(0,0,0,.20) !important; transition: transform .18s ease !important;
}
body.exam-mode #exam-theme-switch-container .toggle__input:checked + .toggle__fill { background: rgba(255,255,255,.18) !important; }
body.exam-mode #exam-theme-switch-container .toggle__input:checked + .toggle__fill::after { transform: translateX(21px) !important; }
body.exam-mode #exam-theme-switch-container .toggle__icon { position: absolute !important; top: 50% !important; transform: translateY(-50%) !important; font-size: 12px !important; z-index: 2 !important; pointer-events: none !important; }
body.exam-mode #exam-theme-switch-container .toggle__icon-light { left: 7px !important; color: #f59e0b !important; }
body.exam-mode #exam-theme-switch-container .toggle__icon-dark { right: 7px !important; color: #facc15 !important; }

body.exam-mode .exam-side-card { border: 1px solid var(--exam-border) !important; border-radius: 14px !important; padding: 12px !important; margin-bottom: 11px !important; background: rgba(255,255,255,.70) !important; }
body.theme-dark.exam-mode .exam-side-card { background: rgba(255,255,255,.04) !important; }
body.exam-mode .side-info-row { display: grid !important; gap: 3px !important; margin-bottom: 10px !important; }
body.exam-mode .side-info-row:last-child { margin-bottom: 0 !important; }
body.exam-mode .side-info-row span,
body.exam-mode .timer-box span,
body.exam-mode .progress-label,
body.exam-mode .side-card-help { color: var(--exam-muted) !important; font-size: 11px !important; font-weight: 700 !important; }
body.exam-mode .side-info-row strong { font-size: 12px !important; line-height: 1.25 !important; }
body.exam-mode .timer-box strong { display: block !important; margin-top: 4px !important; font-size: 28px !important; line-height: 1 !important; color: var(--exam-primary) !important; }
body.theme-dark.exam-mode .timer-box strong { color: #f8f8ff !important; }
body.exam-mode .timer-box.timer-warning strong { color: var(--exam-warning) !important; }
body.exam-mode .timer-box.timer-danger strong { color: var(--exam-danger) !important; }
body.exam-mode .progress-track { height: 8px !important; margin: 8px 0 !important; background: rgba(36,36,94,.12) !important; border-radius: 999px !important; overflow: hidden !important; }
body.exam-mode #progressFill { display: block !important; height: 100% !important; width: 0; background: linear-gradient(90deg, #24245e, #4f46e5) !important; border-radius: inherit !important; }
body.exam-mode #progressHint { color: var(--exam-muted) !important; font-size: 11px !important; line-height: 1.35 !important; }
body.exam-mode .side-card-title { font-size: 13px !important; font-weight: 800 !important; margin-bottom: 3px !important; }
body.exam-mode .side-card-help { margin: 0 0 10px !important; line-height: 1.35 !important; }
body.exam-mode .qstatus { display: grid !important; grid-template-columns: repeat(5, 1fr) !important; gap: 7px !important; }
body.exam-mode .qbox { height: 34px !important; border-radius: 10px !important; border: 1px solid var(--exam-border) !important; background: #fff !important; color: #24245e !important; font-weight: 800 !important; cursor: pointer !important; }
body.theme-dark.exam-mode .qbox { background: #242424 !important; color: #fff !important; }
body.exam-mode .qbox.done { background: #eaf7ef !important; color: #116b3d !important; border-color: #b8e3c8 !important; }
body.exam-mode .qbox.current { outline: 2px solid rgba(36,36,94,.38) !important; outline-offset: 2px !important; }
body.exam-mode .qbox.missing { background: #fff7e6 !important; color: #925000 !important; border-color: #ffd08a !important; }
body.exam-mode .qstatus-legend { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; margin-top: 10px !important; color: var(--exam-muted) !important; font-size: 10px !important; }
body.exam-mode .legend-dot { width: 8px !important; height: 8px !important; border-radius: 50% !important; display: inline-block !important; margin-right: 4px !important; background: #d0d5dd !important; }
body.exam-mode .legend-dot.done { background: #14804a !important; }
body.exam-mode .legend-dot.current { background: #24245e !important; }
body.exam-mode .legend-dot.missing { background: #df8c00 !important; }
body.exam-mode .exam-panel-actions .btn { width: 100% !important; height: 44px !important; border-radius: 13px !important; }

/* Modal submit */
body.exam-mode .submit-card { max-width: 620px !important; border-radius: 18px !important; }
body.exam-mode .submit-icon { width: 56px !important; height: 56px !important; border-radius: 50% !important; display: grid !important; place-items: center !important; margin: 22px auto 0 !important; background: #ecfdf3 !important; color: var(--exam-success) !important; font-size: 24px !important; }
body.exam-mode .submit-icon-warning { background: #fff7e6 !important; color: var(--exam-warning) !important; }
body.exam-mode .submit-head { text-align: center !important; }
body.exam-mode .submit-head p { margin: 8px auto 0 !important; max-width: 420px !important; color: var(--exam-muted) !important; }
body.exam-mode .submit-summary-grid { display: grid !important; grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; }
body.exam-mode .submit-summary-grid > div { border: 1px solid var(--exam-border) !important; border-radius: 12px !important; padding: 11px !important; }
body.exam-mode .submit-summary-grid span { color: var(--exam-muted) !important; font-size: 11px !important; font-weight: 700 !important; }
body.exam-mode .submit-summary-grid strong { display: block !important; margin-top: 4px !important; }
body.exam-mode .missing-chip-list { margin-top: 14px !important; display: flex !important; flex-wrap: wrap !important; gap: 8px !important; }
body.exam-mode .missing-chip { border: 1px solid #ffd08a !important; background: #fff7e6 !important; color: #925000 !important; border-radius: 999px !important; padding: 8px 10px !important; font-weight: 800 !important; cursor: pointer !important; }
body.exam-mode .ready-summary { margin-top: 14px !important; color: var(--exam-success) !important; font-weight: 800 !important; display: flex !important; gap: 8px !important; align-items: center !important; justify-content: center !important; }

/* Result */
.result-screen { min-height: 100vh !important; background: var(--exam-bg, #f3f3f3) !important; color: var(--exam-text, #20202a) !important; padding: 34px 18px !important; }
body.theme-dark .result-screen { background: #000 !important; color: #f8f8f8 !important; }
.result-card { width: min(940px, 100%) !important; margin: 0 auto !important; background: var(--exam-card, #fff) !important; border: 1px solid var(--exam-border, #d8dbe2) !important; border-radius: 18px !important; box-shadow: var(--exam-shadow, 0 4px 17px rgba(0,0,0,.2)) !important; padding: 26px !important; }
.result-card h1 { margin: 0 0 18px !important; font-size: 26px !important; }
.status-row { display: grid !important; grid-template-columns: 140px 1fr !important; gap: 12px !important; border-top: 1px solid var(--exam-border, #d8dbe2) !important; padding: 12px 0 !important; }
.status-row div:first-child { color: var(--exam-muted, #667085) !important; font-weight: 800 !important; }
.review-question-card { margin-top: 22px !important; border: 1px solid var(--exam-border, #d8dbe2) !important; border-left-width: 5px !important; border-radius: 15px !important; padding: 20px !important; background: rgba(255,255,255,.72) !important; }
body.theme-dark .review-question-card { background: rgba(255,255,255,.04) !important; }
.review-question-card.is-correct { border-left-color: #14804a !important; }
.review-question-card.is-wrong { border-left-color: #c0362c !important; }
.review-question-card.is-blank { border-left-color: #b86a00 !important; }
.review-question-header { display: flex !important; justify-content: space-between !important; gap: 12px !important; align-items: flex-start !important; }
.review-question-header h3 { margin: 0 !important; font-size: 18px !important; }
.review-status-pill { border-radius: 999px !important; background: #f2f4f7 !important; padding: 6px 10px !important; font-size: 12px !important; font-weight: 800 !important; }
.review-statement { margin-top: 14px !important; line-height: 1.55 !important; white-space: pre-wrap !important; }
.review-answer-title { margin: 16px 0 8px !important; font-weight: 800 !important; }
.review-choice { display: grid !important; grid-template-columns: 46px 1fr !important; gap: 12px !important; align-items: center !important; padding: 12px !important; border-radius: 12px !important; background: #f8fafc !important; }
body.theme-dark .review-choice { background: rgba(255,255,255,.05) !important; }
.review-choice span { width: 38px !important; height: 38px !important; border-radius: 50% !important; display: grid !important; place-items: center !important; background: #fff !important; border: 1px solid var(--exam-border, #d8dbe2) !important; font-weight: 800 !important; }
.review-choice.correct { background: rgba(20,128,74,.10) !important; }
.review-choice.user-wrong { background: rgba(192,54,44,.10) !important; }
.essay-review { white-space: pre-wrap !important; line-height: 1.55 !important; border: 1px solid var(--exam-border, #d8dbe2) !important; border-radius: 12px !important; padding: 12px !important; }

/* Mobile: easy bottom sheet, no distracting side panel. */
@media (max-width: 980px) {
  body.exam-mode .exam-stage {
    width: 100% !important;
    padding: 18px 12px 120px !important;
    display: block !important;
  }
  body.exam-mode .student-question-card {
    max-width: none !important;
    border-radius: 14px !important;
    padding: 24px 18px 20px !important;
    box-shadow: 0 3px 13px rgba(0,0,0,.20) !important;
  }
  body.exam-mode .question-card-header { display: block !important; margin-bottom: 24px !important; }
  body.exam-mode .question-card-header h1 { font-size: clamp(23px, 6.2vw, 32px) !important; line-height: 1.22 !important; }
  body.exam-mode .question-score { text-align: left !important; margin-top: 12px !important; }
  body.exam-mode .statement { font-size: clamp(20px, 5.2vw, 29px) !important; line-height: 1.42 !important; }
  body.exam-mode .question-options { margin-left: -10px !important; margin-right: -10px !important; }
  body.exam-mode .choice { grid-template-columns: 58px 1fr !important; min-height: 86px !important; padding: 20px 10px !important; }
  body.exam-mode .choice .letter { width: 46px !important; height: 46px !important; }
  body.exam-mode .choice .option-text { font-size: clamp(19px, 5vw, 28px) !important; }

  body.exam-mode .exam-topbar { display: none !important; }
  body.exam-mode .exam-question-drawer {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    top: auto !important;
    width: auto !important;
    max-height: min(76vh, 620px) !important;
    overflow: auto !important;
    border-radius: 20px !important;
    padding: 12px !important;
    opacity: 1 !important;
    transform: translateY(calc(100% - 74px)) !important;
    z-index: 130 !important;
  }
  body.exam-mode .exam-question-drawer.open { transform: translateY(0) !important; }
  body.exam-mode .drawer-header { min-height: 50px !important; align-items: center !important; cursor: pointer !important; margin-bottom: 10px !important; }
  body.exam-mode .drawer-kicker { font-size: 10px !important; }
  body.exam-mode .drawer-title { font-size: 16px !important; margin: 1px 0 0 !important; }
  body.exam-mode .mobile-timer-text { display: inline-block !important; margin-top: 3px !important; font-size: 18px !important; font-weight: 900 !important; color: var(--exam-primary) !important; }
  body.theme-dark.exam-mode .mobile-timer-text { color: #fff !important; }
  body.exam-mode .drawer-close { display: inline-grid !important; place-items: center !important; width: 34px !important; height: 34px !important; border: 0 !important; border-radius: 50% !important; background: rgba(36,36,94,.08) !important; color: inherit !important; }
  body.exam-mode .exam-question-drawer:not(.open) .drawer-close { display: none !important; }
  body.exam-mode .exam-side-info { display: none !important; }
  body.exam-mode .exam-question-drawer:not(.open) .exam-side-card:not(.timer-box):not(.progress-card),
  body.exam-mode .exam-question-drawer:not(.open) .exam-panel-actions { display: none !important; }
  body.exam-mode .exam-question-drawer:not(.open) .timer-box { display: none !important; }
  body.exam-mode .exam-question-drawer:not(.open) .progress-card { margin-bottom: 0 !important; padding: 0 !important; border: 0 !important; background: transparent !important; }
  body.exam-mode .exam-question-drawer:not(.open) #progressHint,
  body.exam-mode .exam-question-drawer:not(.open) .progress-label { display: none !important; }
  body.exam-mode .qstatus { grid-template-columns: repeat(7, 1fr) !important; }
  .submit-summary-grid { grid-template-columns: 1fr !important; }
  .status-row { grid-template-columns: 1fr !important; gap: 3px !important; }
}

@media (max-width: 520px) {
  body.exam-mode .exam-stage { padding-left: 8px !important; padding-right: 8px !important; }
  body.exam-mode .student-question-card { padding: 22px 14px 18px !important; }
  body.exam-mode .question-options { margin-left: -6px !important; margin-right: -6px !important; }
  body.exam-mode .qstatus { grid-template-columns: repeat(5, 1fr) !important; }
}

/* v36: keep desktop and mobile test layouts fully separated, and honor editor typography */
body.exam-mode .statement {
  font-size: 18px !important;
  line-height: 1.48 !important;
}
body.exam-mode .statement,
body.exam-mode .statement div,
body.exam-mode .statement p,
body.exam-mode .statement span,
body.exam-mode .statement li,
.review-statement,
.review-statement div,
.review-statement p,
.review-statement span,
.review-statement li {
  font-family: Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
}
body.exam-mode .statement div,
body.exam-mode .statement p,
.review-statement div,
.review-statement p {
  white-space: pre-wrap !important;
}
body.exam-mode .statement [style*="text-align"],
.review-statement [style*="text-align"] {
  display: block !important;
}

@media (min-width: 981px) {
  body.exam-mode .exam-stage {
    width: min(1280px, calc(100vw - 40px)) !important;
    margin: 0 auto !important;
    padding: 34px 0 80px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 930px) 282px !important;
    justify-content: center !important;
    align-items: start !important;
    gap: 30px !important;
  }
  body.exam-mode .exam-question-drawer {
    position: sticky !important;
    top: 30px !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 282px !important;
    max-height: calc(100vh - 60px) !important;
    transform: none !important;
    opacity: .80 !important;
    border-radius: 18px !important;
    padding: 14px !important;
  }
  body.exam-mode .exam-question-drawer.open {
    transform: none !important;
  }
  body.exam-mode .exam-topbar,
  body.exam-mode .drawer-close,
  body.exam-mode .mobile-timer-text {
    display: none !important;
  }
  body.exam-mode .exam-side-info,
  body.exam-mode .timer-box,
  body.exam-mode .progress-card,
  body.exam-mode .exam-side-card,
  body.exam-mode .exam-panel-actions {
    display: block !important;
  }
  body.exam-mode .question-card-header {
    display: flex !important;
  }
}

@media (max-width: 980px) {
  body.exam-mode .exam-stage {
    grid-template-columns: 1fr !important;
  }
}

/* v37 final test-page stability fixes: desktop fixed panel, margins, and switch parity with index */
body.exam-mode #exam-theme-switch-container {
  width: 62px !important;
  height: 40px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: visible !important;
}
body.exam-mode #exam-theme-switch-container .toggle {
  width: 62px !important;
  height: 40px !important;
  display: block !important;
  position: relative !important;
  cursor: pointer !important;
}
body.exam-mode #exam-theme-switch-container .toggle__input {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
}
body.exam-mode #exam-theme-switch-container .toggle__fill {
  position: absolute !important;
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent url('/assets/img/theme-light.png') center / contain no-repeat !important;
  box-shadow: none !important;
  transition: none !important;
  image-rendering: auto !important;
  cursor: pointer !important;
}
body.exam-mode #exam-theme-switch-container .toggle__fill::after {
  display: none !important;
  content: none !important;
}
body.exam-mode #exam-theme-switch-container .toggle__icon {
  display: none !important;
}
body.exam-mode #exam-theme-switch-container .toggle__input:checked + .toggle__fill {
  background-image: url('/assets/img/theme-dark.png') !important;
  background-color: transparent !important;
}

@media (min-width: 981px) {
  body.exam-mode .exam-stage {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 30px 340px 86px 30px !important;
    display: block !important;
  }
  body.exam-mode .exam-paper-area {
    width: min(930px, 100%) !important;
    max-width: 930px !important;
    margin: 0 auto !important;
    min-width: 0 !important;
  }
  body.exam-mode .student-question-card {
    width: 100% !important;
    max-width: 930px !important;
    padding: 30px 42px 26px !important;
    margin: 0 auto !important;
  }
  body.exam-mode .exam-question-drawer {
    position: fixed !important;
    top: 50% !important;
    right: 28px !important;
    bottom: auto !important;
    left: auto !important;
    transform: translateY(-50%) !important;
    width: 270px !important;
    max-height: calc(100vh - 64px) !important;
    overflow: auto !important;
    z-index: 120 !important;
    opacity: .86 !important;
    border-radius: 18px !important;
    padding: 14px !important;
  }
  body.exam-mode .exam-question-drawer.open {
    transform: translateY(-50%) !important;
  }
  body.exam-mode .exam-question-drawer:hover,
  body.exam-mode .exam-question-drawer:focus-within {
    opacity: 1 !important;
  }
  body.exam-mode .exam-side-info .side-info-row {
    margin-bottom: 0 !important;
  }
}

@media (min-width: 981px) and (max-width: 1240px) {
  body.exam-mode .exam-stage {
    padding: 26px 304px 82px 18px !important;
  }
  body.exam-mode .exam-paper-area {
    max-width: 850px !important;
  }
  body.exam-mode .student-question-card {
    max-width: 850px !important;
    padding-left: 34px !important;
    padding-right: 34px !important;
  }
  body.exam-mode .exam-question-drawer {
    right: 18px !important;
    width: 252px !important;
  }
}

/* v40: reference-like statement spacing with admin-controlled line height preserved */
body.exam-mode .statement {
  font-size: 18px !important;
  line-height: 1.45 !important;
}
body.exam-mode .statement div,
body.exam-mode .statement p {
  margin: 0 0 18px !important;
}
body.exam-mode .student-question-card {
  padding-top: 30px !important;
  padding-bottom: 26px !important;
}


/* v41: result rich text mirrors the active test page spacing and labels */
.review-statement.rich-review-content,
.essay-review.rich-review-content {
  font-family: Montserrat, Avenir, Helvetica, Arial, sans-serif !important;
  font-size: 18px !important;
  line-height: 1.45 !important;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere !important;
}
.review-statement.rich-review-content div,
.review-statement.rich-review-content p,
.essay-review.rich-review-content div,
.essay-review.rich-review-content p {
  margin: 0 0 18px !important;
  white-space: pre-wrap !important;
}
.review-statement.rich-review-content div:last-child,
.review-statement.rich-review-content p:last-child,
.essay-review.rich-review-content div:last-child,
.essay-review.rich-review-content p:last-child {
  margin-bottom: 0 !important;
}
.review-statement.rich-review-content ul,
.review-statement.rich-review-content ol,
.essay-review.rich-review-content ul,
.essay-review.rich-review-content ol {
  margin: 10px 0 18px 1.25em !important;
  padding-left: 1.15em !important;
}
.review-statement.rich-review-content li,
.essay-review.rich-review-content li {
  margin: 5px 0 !important;
}
.review-statement.rich-review-content [style*="text-align"],
.essay-review.rich-review-content [style*="text-align"] {
  display: block !important;
}
.expected-essay-answer {
  background: rgba(20,128,74,.07) !important;
}
.user-essay-answer {
  background: rgba(36,36,94,.035) !important;
}
body.theme-dark .user-essay-answer {
  background: rgba(255,255,255,.045) !important;
}


/* v42: do not override rich-editor inline typography/alignment in test/result pages */
body.exam-mode .statement [style*="text-align"],
.review-statement.rich-review-content [style*="text-align"],
.essay-review.rich-review-content [style*="text-align"] {
  display: block !important;
}


/* v44: render durable rich-text alignment from admin editor */
body.exam-mode .statement [data-align="left"],
.review-statement.rich-review-content [data-align="left"],
.essay-review.rich-review-content [data-align="left"] { text-align: left !important; }
body.exam-mode .statement [data-align="center"],
.review-statement.rich-review-content [data-align="center"],
.essay-review.rich-review-content [data-align="center"] { text-align: center !important; }
body.exam-mode .statement [data-align="right"],
.review-statement.rich-review-content [data-align="right"],
.essay-review.rich-review-content [data-align="right"] { text-align: right !important; }
body.exam-mode .statement [data-align="justify"],
.review-statement.rich-review-content [data-align="justify"],
.essay-review.rich-review-content [data-align="justify"] { text-align: justify !important; }

/* v45: rich text images pasted from admin editor */
body.exam-mode .statement img,
.review-statement.rich-review-content img,
.essay-review.rich-review-content img {
  max-width: 100% !important;
  height: auto !important;
  display: inline-block !important;
  border-radius: 10px !important;
  margin: 10px 0 !important;
}
body.exam-mode .statement [data-align="center"] img,
.review-statement.rich-review-content [data-align="center"] img,
.essay-review.rich-review-content [data-align="center"] img {
  margin-left: auto !important;
  margin-right: auto !important;
}
