/* ---------------------------------------------------------------------------
   Design tokens — Quiz Master Pro Design System v1.0, applied here to the
   student exam interface only (this redesign stage is scoped to the exam
   screen; admin.css is untouched and still carries its own, different token
   values for now — the two will be reconciled when the admin panel is
   redesigned in a later stage).
--------------------------------------------------------------------------- */
:root {
	--qm-color-primary: #1B4B73;
	--qm-color-primary-hover: #163C5C;
	--qm-color-primary-active: #102C44;
	--qm-color-primary-tint: #E4EEF8;

	--qm-color-secondary: #5B6472;

	--qm-color-bg: #F5F6F8;
	--qm-color-surface: #FFFFFF;
	--qm-color-border: #D7DBE0;
	--qm-color-border-strong: #87919C;

	--qm-color-text: #1A1D23;
	--qm-color-text-muted: #5B6472;

	--qm-color-success: #1E7B34;
	--qm-color-success-bg: #E6F4E9;
	--qm-color-warning: #92620A;
	--qm-color-warning-bg: #FBF0DC;
	--qm-color-error: #B42318;
	--qm-color-error-bg: #FBE7E5;
	--qm-color-error-solid: #B42318;
	--qm-color-info: #205A96;
	--qm-color-info-bg: #E4EEF8;
	--qm-color-marked: #6E3FA3;

	--qm-color-selected-bg: #EAF1F8;
	--qm-color-selected-border: #1B4B73;
	--qm-color-focus: #0B5FFF;

	--qm-color-disabled-bg: #F0F1F3;
	--qm-color-disabled-text: #9AA1AB;
	--qm-color-disabled-border: #E1E4E8;

	--qm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	--qm-space-1: 4px;
	--qm-space-2: 8px;
	--qm-space-3: 12px;
	--qm-space-4: 16px;
	--qm-space-5: 24px;
	--qm-space-6: 32px;
	--qm-space-7: 48px;
	--qm-space-8: 64px;

	--qm-radius-sm: 4px;
	--qm-radius-md: 6px;
	--qm-radius-lg: 8px;

	--qm-shadow-overlay: 0 2px 8px rgba(16, 20, 24, 0.16), 0 1px 2px rgba(16, 20, 24, 0.08);

	--qm-duration-fast: 120ms;
	--qm-duration-base: 180ms;
	--qm-easing: cubic-bezier(0.2, 0, 0, 1);

	--qm-touch-min: 44px;
}

@media (prefers-reduced-motion: reduce) {
	.qm-exam-wrap * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.qm-exam-wrap { max-width: 1100px; margin: 0 auto; font-family: var(--qm-font); color: var(--qm-color-text); background: var(--qm-color-bg); }

/* Visible keyboard-focus indicator for every interactive element in the exam UI.
   Deliberately independent of the host theme's own focus styling (which is
   often suppressed by resets) and independent of :hover/color-only states used
   elsewhere — this must remain visible even for someone who cannot perceive
   the color-coded states themselves. */
.qm-exam-wrap a:focus-visible,
.qm-exam-wrap button:focus-visible,
.qm-exam-wrap input:focus-visible,
.qm-exam-wrap select:focus-visible,
.qm-exam-wrap textarea:focus-visible,
.qm-exam-wrap [tabindex]:focus-visible,
.qm-modal a:focus-visible,
.qm-modal button:focus-visible,
.qm-fullscreen-resume button:focus-visible {
	outline: 3px solid var(--qm-color-focus);
	outline-offset: 2px;
}
/* The option row itself is the actual click target (see .qm-option in exam.js);
   give it a focus ring too so keyboard users tabbing through options (not just
   clicking) see exactly which option is focused. */
.qm-option:focus-within {
	outline: 3px solid var(--qm-color-focus);
	outline-offset: 2px;
}

/* When the quiz container itself is the fullscreen element (not the whole page —
   see tryFullScreen() in exam.js), make it fill the screen properly and stay
   scrollable, since the browser doesn't do this automatically for arbitrary
   in-flow elements. */
.qm-exam-wrap:fullscreen,
.qm-exam-wrap:-webkit-full-screen {
	max-width: 100%;
	width: 100%;
	height: 100%;
	overflow-y: auto;
	background: #f0f0f1;
	padding: 20px;
	box-sizing: border-box;
}
.qm-lead-form { max-width: 420px; margin: 0 auto; background: #fff; border: 1px solid #dcdcde; border-radius: 8px; padding: 26px; }
.qm-lead-form h3 { margin-top: 0; }
.qm-lead-form .qm-field { margin-bottom: 14px; text-align: left; }
.qm-lead-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #646970; }
.qm-lead-form input { width: 100%; padding: 10px; border: 1px solid #dcdcde; border-radius: 6px; font-size: 15px; box-sizing: border-box; }
.qm-lead-form .qm-btn { width: 100%; margin-top: 6px; }
.qm-consent-field { margin-top: 18px; }
.qm-checkbox-label { display: flex !important; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 400 !important; color: #3c434a; cursor: pointer; }
.qm-checkbox-label input[type="checkbox"] { width: auto !important; margin-top: 2px; flex-shrink: 0; }
.qm-checkbox-label a { color: #2271b1; text-decoration: underline; }

.qm-btn { display: inline-block; padding: 10px 22px; border-radius: 6px; text-decoration: none; font-weight: 600; cursor: pointer; border: none; font-size: 14px; }
.qm-btn-primary { background: #2271b1; color: #fff; }
.qm-btn-primary:hover { background: #135e96; color: #fff; }
.qm-btn-secondary { background: #f0f0f1; color: #1d2327; }
.qm-btn-danger { background: #d63638; color: #fff; }
.qm-btn-large { padding: 14px 30px; font-size: 16px; }
.qm-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Instructions */
.qm-meta-row span { display: inline-block; background: #f0f6fc; color: #135e96; padding: 4px 12px; border-radius: 14px; margin-right: 8px; font-size: 13px; }
.qm-instructions-body { background: #fff; border: 1px solid #dcdcde; border-radius: 8px; padding: 16px; margin: 16px 0; }
.qm-section-preview { width: 100%; border-collapse: collapse; margin: 12px 0; }
.qm-section-preview th, .qm-section-preview td { border: 1px solid #dcdcde; padding: 8px 12px; text-align: left; }
.qm-general-instructions { margin: 16px 0; line-height: 1.8; }
.qm-note { background: #fff8e5; padding: 10px 14px; border-radius: 6px; }

/* ==========================================================================
   Exam interface — Quiz Master Pro Design System v1.0
   ========================================================================== */

.qm-loading { padding: 40px; text-align: center; color: var(--qm-color-text-muted); }
.qm-load-error { padding: 30px; text-align: center; background: var(--qm-color-error-bg); border-radius: var(--qm-radius-md); color: var(--qm-color-error); }
.qm-load-error p { margin: 0 0 12px; }
/* Empty states: say what is missing, why, and what the reader can do. */
.qm-empty-state { background: var(--qm-color-surface); border: 1px dashed var(--qm-color-border-strong); border-radius: var(--qm-radius-md); padding: var(--qm-space-4) var(--qm-space-5); margin: var(--qm-space-3) 0 var(--qm-space-4); max-width: 640px; }
.qm-empty-state p { margin: 6px 0 0; color: var(--qm-color-text-muted); font-size: 14px; line-height: 1.6; }

/* ---- Header ---------------------------------------------------------- */
.qm-exam-header {
	position: sticky; top: 0; z-index: 20;
	background: var(--qm-color-surface); border-bottom: 1px solid var(--qm-color-border);
	border-radius: var(--qm-radius-lg) var(--qm-radius-lg) 0 0;
}
.qm-header-top {
	display: flex; align-items: center; justify-content: space-between; gap: var(--qm-space-3);
	padding: var(--qm-space-3) var(--qm-space-4);
}
.qm-header-title {
	font-size: 15px; font-weight: 700; color: var(--qm-color-text);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto;
}
.qm-header-controls { display: flex; align-items: center; gap: var(--qm-space-2); flex-shrink: 0; }
.qm-header-sub {
	display: flex; align-items: center; gap: var(--qm-space-3); flex-wrap: wrap;
	padding: 0 var(--qm-space-4) var(--qm-space-3);
	font-size: 13px; color: var(--qm-color-text-muted);
}
.qm-header-section {
	font-weight: 600; color: var(--qm-color-primary); background: var(--qm-color-primary-tint);
	padding: 3px 10px; border-radius: var(--qm-radius-sm);
}
.qm-header-progress { font-weight: 600; }

.qm-btn-icon {
	display: inline-flex; align-items: center; justify-content: center;
	width: var(--qm-touch-min); height: var(--qm-touch-min); border-radius: var(--qm-radius-md);
	background: transparent; border: 1px solid transparent; color: var(--qm-color-text-muted); cursor: pointer;
}
.qm-btn-icon:hover { background: var(--qm-color-bg); color: var(--qm-color-text); }
.qm-icon { display: inline-flex; }
.qm-icon svg { display: block; }
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }

/* Timer — four tiers, none of them relying on color alone: size/weight also
   step up, and the critical/expired tiers add an icon, so the urgency reads
   even in grayscale or to a colorblind student. Sits inline in the header
   (not floating over content), so it's always visible without ever
   obstructing the question itself. */
.qm-timer {
	display: inline-flex; align-items: center; gap: 6px;
	font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
	background: var(--qm-color-bg); color: var(--qm-color-text);
	padding: 7px 14px; border-radius: var(--qm-radius-md); border: 1px solid var(--qm-color-border);
}
.qm-timer::before { content: ""; width: 16px; height: 16px; flex-shrink: 0; display: none; }
.qm-timer.qm-timer-warning { background: var(--qm-color-warning-bg); color: var(--qm-color-warning); border-color: #F0DCA8; }
.qm-timer.qm-timer-critical {
	background: var(--qm-color-error-bg); color: var(--qm-color-error); border-color: #F2C6C1;
	font-size: 16px; font-weight: 800;
}
.qm-timer.qm-timer-critical::before,
.qm-timer.qm-timer-expired::before {
	display: inline-block;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.75' stroke-linejoin='round' d='M12 3 2 20h20L12 3z'/%3E%3Cline x1='12' y1='9' x2='12' y2='14' stroke='%23000' stroke-width='1.75' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17.5' r='0.6' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.75' stroke-linejoin='round' d='M12 3 2 20h20L12 3z'/%3E%3Cline x1='12' y1='9' x2='12' y2='14' stroke='%23000' stroke-width='1.75' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17.5' r='0.6' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}
.qm-timer.qm-timer-expired { background: var(--qm-color-error); color: #fff; border-color: var(--qm-color-error); }

/* Mobile-only palette toggle — hidden entirely at desktop widths (≥960px),
   see the media query below where it becomes visible and the sidebar
   becomes a drawer. */
.qm-palette-toggle {
	display: none; align-items: center; gap: 6px; height: var(--qm-touch-min);
	padding: 0 12px; border-radius: var(--qm-radius-md); border: 1px solid var(--qm-color-border-strong);
	background: var(--qm-color-surface); color: var(--qm-color-text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.qm-palette-scrim { display: none; }

/* ---- Layout ------------------------------------------------------------ */
.qm-exam-body { display: flex; gap: 0; border: 1px solid var(--qm-color-border); border-top: none; background: var(--qm-color-surface); min-height: 480px; border-radius: 0 0 var(--qm-radius-lg) var(--qm-radius-lg); overflow: hidden; }
/* min-width: 0 is required here, not optional — without it this flex item (the
   entire question + options column) refuses to shrink below its content's
   natural width when that content contains a long unbroken string or URL, which
   means the word-break/overflow-wrap rules on .qm-q-text/.qm-option-text never
   get the chance to trigger at all: the parent never shrinks, so nothing ever
   needs to wrap. This was the actual root cause of wrapping appearing broken. */
.qm-question-area { flex: 3 1 0%; min-width: 0; padding: var(--qm-space-5); max-width: 100%; }
.qm-palette-area { flex: 1; min-width: 260px; border-left: 1px solid var(--qm-color-border); padding: var(--qm-space-4); background: var(--qm-color-bg); }

/* ---- Question content --------------------------------------------------
   Question text is deliberately the largest, loosest text in the whole
   plugin (17px / 1.65) — it's read once, under time pressure, and must not
   need a second pass. */
.qm-q-topline { display: flex; align-items: center; flex-wrap: wrap; gap: var(--qm-space-3); margin-bottom: var(--qm-space-4); }
.qm-q-number { font-size: 15px; font-weight: 700; color: var(--qm-color-text); }
.qm-q-type-tag { font-size: 11px; font-weight: 600; color: var(--qm-color-text-muted); background: var(--qm-color-bg); border: 1px solid var(--qm-color-border); padding: 2px 8px; border-radius: var(--qm-radius-sm); }
.qm-q-subject { font-size: 12px; color: var(--qm-color-text-muted); background: var(--qm-color-bg); border: 1px solid var(--qm-color-border); padding: 2px 8px; border-radius: var(--qm-radius-sm); }
.qm-q-marks { display: inline-flex; gap: 6px; margin-left: auto; }
.qm-marks-chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--qm-radius-sm); border: 1px solid transparent; white-space: nowrap; }
.qm-marks-positive { background: var(--qm-color-success-bg); color: var(--qm-color-success); border-color: #C7E6CD; }
.qm-marks-negative { background: var(--qm-color-error-bg); color: var(--qm-color-error); border-color: #F2C6C1; }
.qm-marks-neutral { background: var(--qm-color-bg); color: var(--qm-color-text-muted); border-color: var(--qm-color-border); }

.qm-q-passage-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--qm-color-text-muted); margin-bottom: 6px; }
.qm-q-passage {
	background: var(--qm-color-bg); border: 1px solid var(--qm-color-border); border-left: 3px solid var(--qm-color-primary);
	border-radius: 0 var(--qm-radius-md) var(--qm-radius-md) 0; padding: var(--qm-space-3) var(--qm-space-4); margin-bottom: var(--qm-space-4);
	font-size: 14px; line-height: 1.6;
	white-space: normal !important; overflow-wrap: anywhere !important; word-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important;
}
.qm-q-text {
	font-size: 17px; font-weight: 500; line-height: 1.65; margin-bottom: var(--qm-space-4); color: var(--qm-color-text);
	/* Long words, long unbroken strings, and URLs must wrap — never truncate,
	   never scroll horizontally. !important here is deliberate: this widget is
	   embedded inside an arbitrary theme's page template, and theme stylesheets
	   commonly load AFTER this one with equal-or-higher specificity, silently
	   overriding plain word-break/overflow-wrap rules. Wrapping is a hard
	   requirement for this widget, not a preference the host theme should be
	   able to override. */
	white-space: normal !important; overflow-wrap: anywhere !important; word-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important;
}
.qm-q-image { max-width: 100%; margin-bottom: var(--qm-space-4); border-radius: var(--qm-radius-md); border: 1px solid var(--qm-color-border); }
.qm-q-images { margin: 4px 0 var(--qm-space-4); display: flex; flex-wrap: wrap; gap: var(--qm-space-2); }
.qm-q-images .qm-inline-image, .qm-option-images .qm-inline-image { max-width: 100%; height: auto; border-radius: var(--qm-radius-sm); display: block; }
.qm-q-images .qm-inline-image { max-height: 360px; width: auto; }
.qm-option-images { margin-top: 8px; }
.qm-option-images .qm-inline-image { max-height: 160px; width: auto; }

.qm-answer-instruction { font-size: 12px; color: var(--qm-color-text-muted); margin-bottom: var(--qm-space-3); }

/* ---- Answer options ------------------------------------------------------
   Full-row click target (not just the input), a lettered identifier so an
   option can be referred to unambiguously ("option C"), and every state
   the spec calls for: hover, focus (via :focus-within, see the token block
   above), selected, and disabled. */
.qm-options-list { display: flex; flex-direction: column; gap: var(--qm-space-2); }
/* True/False: two short options side by side rather than a full-width stacked
   row each — same .qm-option card, just arranged for its content. */
.qm-options-list.qm-options-inline { display: grid; grid-template-columns: 1fr 1fr; gap: var(--qm-space-2); }
.qm-options-list.qm-options-inline .qm-option { justify-content: center; text-align: center; flex-direction: column; gap: 6px; }
.qm-options-list.qm-options-inline .qm-option-id { margin: 0 auto; }
.qm-options-list.qm-options-inline .qm-option-body { flex: none; padding-top: 0; }
/* Match the Following: option text is usually a combination string
   ("A-3, B-1, C-4, D-2") — tabular numerals keep digits aligned across rows. */
.qm-option-text-tabular { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* Admin-authored tables can appear inside question text, a passage, or an
   explanation (all raw HTML fields) — give them one consistent, readable
   treatment and let them scroll horizontally rather than overflow the
   question column on a narrow screen. */
.qm-q-text table, .qm-q-passage table, .qm-review-question table, .qm-review-explanation table {
	display: block; overflow-x: auto; border-collapse: collapse; margin: var(--qm-space-3) 0; font-size: 14px; max-width: 100%;
}
.qm-q-text table th, .qm-q-passage table th, .qm-review-question table th, .qm-review-explanation table th,
.qm-q-text table td, .qm-q-passage table td, .qm-review-question table td, .qm-review-explanation table td {
	border: 1px solid var(--qm-color-border); padding: 6px 10px; text-align: left; white-space: nowrap;
}
.qm-q-text table th, .qm-q-passage table th, .qm-review-question table th, .qm-review-explanation table th { background: var(--qm-color-bg); font-weight: 700; }
.qm-option {
	display: flex; align-items: flex-start; gap: var(--qm-space-3);
	padding: var(--qm-space-3) var(--qm-space-4); min-height: var(--qm-touch-min);
	background: var(--qm-color-surface); border: 1px solid var(--qm-color-border); border-radius: var(--qm-radius-md);
	cursor: pointer; transition: border-color var(--qm-duration-fast) var(--qm-easing), background-color var(--qm-duration-fast) var(--qm-easing);
}
.qm-option:hover { border-color: var(--qm-color-border-strong); background: var(--qm-color-bg); }
.qm-option.qm-selected { border-color: var(--qm-color-selected-border); background: var(--qm-color-selected-bg); }
.qm-option-id {
	flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--qm-radius-sm);
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 12px; font-weight: 700; margin-top: 1px;
	background: var(--qm-color-bg); color: var(--qm-color-text-muted); border: 1px solid var(--qm-color-border);
}
.qm-option.qm-selected .qm-option-id { background: var(--qm-color-primary); color: #fff; border-color: var(--qm-color-primary); }
.qm-option input { margin-top: 5px; flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--qm-color-primary); }
/* min-width: 0 overrides the flexbox default (min-width: auto), which otherwise
   lets a flex item's un-breakable content force it — and the row — wider than
   the container even with word-break rules applied to the text inside it. This
   is the single most common reason "correct" wrap CSS still doesn't wrap inside
   a flex layout. */
.qm-option-body { display: block; min-width: 0 !important; flex: 1 1 0%; padding-top: 3px; }
.qm-option-text {
	font-size: 15px; line-height: 1.6; color: var(--qm-color-text);
	/* Same wrap rules as the question text — an option must never overlap its
	   radio/checkbox or run off the container, no matter how long it is. */
	white-space: normal !important; overflow-wrap: anywhere !important; word-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important;
	display: block;
}
.qm-options-locked .qm-option, .qm-option.qm-option-disabled {
	cursor: not-allowed; background: var(--qm-color-disabled-bg); border-color: var(--qm-color-disabled-border);
}
.qm-options-locked .qm-option:hover, .qm-option.qm-option-disabled:hover { border-color: var(--qm-color-disabled-border); background: var(--qm-color-disabled-bg); }
.qm-options-locked .qm-option .qm-option-text, .qm-option.qm-option-disabled .qm-option-text { color: var(--qm-color-disabled-text); }
.qm-options-locked .qm-option .qm-option-id, .qm-option.qm-option-disabled .qm-option-id { background: var(--qm-color-disabled-bg); color: var(--qm-color-disabled-text); border-color: var(--qm-color-disabled-border); }

.qm-numeric-input, .qm-text-input {
	padding: 9px 12px; width: 100%; max-width: 300px; min-height: var(--qm-touch-min); font-size: 15px;
	border: 1px solid var(--qm-color-border-strong); border-radius: var(--qm-radius-sm); font-family: var(--qm-font);
}
.qm-numeric-input:focus-visible, .qm-text-input:focus-visible { outline: none; border-color: var(--qm-color-focus); box-shadow: 0 0 0 3px rgba(11,95,255,0.18); }
.qm-locked-banner {
	display: flex; align-items: center; gap: 8px;
	background: var(--qm-color-warning-bg); color: var(--qm-color-warning);
	padding: var(--qm-space-3) var(--qm-space-4); border-radius: var(--qm-radius-md); margin-bottom: var(--qm-space-4); font-weight: 600; font-size: 13px;
}

/* ---- Fullscreen resume banner --------------------------------------------
   Shown when fullscreen is lost mid-exam for any reason other than the
   student explicitly choosing to exit it (see the fullscreenchange handler
   in exam.js). Browsers require a fresh user gesture to re-enter fullscreen;
   this banner is the actual best available fallback, not a cosmetic choice. */
.qm-fullscreen-resume {
	position: fixed; bottom: var(--qm-space-5); left: 50%; transform: translateX(-50%); z-index: 99998;
	background: var(--qm-color-text); color: #fff; padding: var(--qm-space-3) var(--qm-space-4); border-radius: var(--qm-radius-md);
	box-shadow: var(--qm-shadow-overlay); display: flex; align-items: center; gap: var(--qm-space-3); font-size: 14px;
}
.qm-fullscreen-resume button { background: var(--qm-color-primary); color: #fff; border: none; min-height: var(--qm-touch-min); padding: 0 var(--qm-space-4); border-radius: var(--qm-radius-sm); cursor: pointer; font-weight: 600; }

/* ---- Save status ----------------------------------------------------------
   Small text next to the timer: "Saving…", "Answer saved", or — when a save
   fails — "Not saved – retrying" with a Retry button. Words carry the meaning;
   the warning colors only reinforce it. */
.qm-save-status { font-size: 12px; color: var(--qm-color-text-muted); white-space: nowrap; }
.qm-save-status:empty { display: none; }
.qm-save-status[data-state="error"], .qm-save-status[data-state="rejected"] {
	color: var(--qm-color-error); font-weight: 700; background: var(--qm-color-error-bg);
	border: 1px solid #F2C6C1; border-radius: var(--qm-radius-sm); padding: 3px 8px;
}
.qm-save-retry {
	background: none; border: none; padding: 0 0 0 4px; margin: 0; font: inherit; font-weight: 700;
	color: var(--qm-color-error); text-decoration: underline; cursor: pointer; min-height: 24px;
}

/* ---- Navigation ---------------------------------------------------------- */
.qm-nav-buttons { display: flex; gap: var(--qm-space-2); margin-top: var(--qm-space-5); flex-wrap: wrap; }
.qm-nav-buttons .qm-btn { min-height: var(--qm-touch-min); }

.qm-submit-bar { margin-top: var(--qm-space-4); text-align: right; }

/* ---- Palette -------------------------------------------------------------
   Rectangular chips, not pills, per the design system's radius rule — the
   one place this plugin still used a fully-rounded shape by default. */
.qm-palette-legend { display: flex; flex-wrap: wrap; gap: var(--qm-space-3); margin-bottom: var(--qm-space-4); font-size: 12px; color: var(--qm-color-text-muted); }
.qm-palette-legend span { display: flex; align-items: center; gap: 5px; }
.qm-legend-dot { width: 18px; height: 18px; border-radius: var(--qm-radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; background: var(--qm-color-disabled-text); color: #fff; }
.qm-legend-dot.qm-p-answered { background: var(--qm-color-success); }
.qm-legend-dot.qm-p-unanswered { background: var(--qm-color-error-solid); }
.qm-legend-dot.qm-p-marked_review { background: var(--qm-color-marked); }

.qm-palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--qm-space-2); margin-bottom: var(--qm-space-4); }
/* Each button carries its own state via a color class (background) AND a small
   glyph (✓ / ! / ★, see qm-palette-glyph) so the state is never conveyed by
   color alone — a colorblind or low-vision student sees the same information. */
.qm-palette-btn {
	position: relative; width: 44px; height: 44px; border-radius: var(--qm-radius-md);
	border: 1px solid var(--qm-color-border-strong); background: var(--qm-color-surface);
	cursor: pointer; font-size: 13px; font-weight: 600; color: var(--qm-color-text);
}
.qm-palette-btn:hover:not(:disabled) { border-color: var(--qm-color-primary); }
.qm-palette-btn.qm-p-answered { background: var(--qm-color-success); color: #fff; border-color: var(--qm-color-success); }
.qm-palette-btn.qm-p-unanswered { background: var(--qm-color-error-solid); color: #fff; border-color: var(--qm-color-error-solid); }
.qm-palette-btn.qm-p-marked_review { background: var(--qm-color-marked); color: #fff; border-color: var(--qm-color-marked); }
.qm-palette-btn.qm-p-answered_marked_review { background: var(--qm-color-marked); color: #fff; border-color: var(--qm-color-marked); box-shadow: inset 0 0 0 3px var(--qm-color-success); }
/* Current is a shape change (a persistent ring), not a color swap — so it
   stays distinguishable even layered on top of any of the four status
   colors above, and even for a viewer who can't perceive color at all. */
.qm-palette-btn.qm-p-current { outline: 3px solid var(--qm-color-primary); outline-offset: 2px; }
.qm-palette-btn:disabled { cursor: not-allowed; opacity: .5; }
.qm-palette-glyph { position: absolute; bottom: 1px; right: 3px; font-size: 9px; line-height: 1; letter-spacing: -1px; }
/* Section grouping: a small heading above each section's own sub-grid on
   sectional exams, so a 100-question palette isn't one undifferentiated wall
   of buttons — students can see and jump between section boundaries at a glance. */
.qm-palette-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--qm-color-text-muted); margin: var(--qm-space-4) 0 6px; }
.qm-palette-section-label:first-child { margin-top: 0; }

.qm-section-tabs { display: flex; gap: 6px; margin-bottom: var(--qm-space-4); flex-wrap: wrap; align-items: flex-start; }
.qm-section-tab-wrap { position: relative; display: inline-flex; align-items: center; }
.qm-section-stats-tooltip {
	position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; width: 230px; padding: 10px 12px;
	border: 1px solid var(--qm-color-border-strong); border-radius: var(--qm-radius-md);
	background: var(--qm-color-surface); color: var(--qm-color-text); box-shadow: 0 8px 24px rgba(0,0,0,.12);
	display: none; font-size: 12px; line-height: 1.35; pointer-events: none;
}
.qm-section-tab-wrap:hover .qm-section-stats-tooltip,
.qm-section-tab-wrap:focus-within .qm-section-stats-tooltip { display: block; }
.qm-section-stats-tooltip strong { display: block; margin-bottom: 7px; font-size: 12px; }
.qm-section-stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.qm-section-stat-row b, .qm-section-stat-total b { font-variant-numeric: tabular-nums; }
.qm-section-stat-total { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--qm-color-border); margin-top: 5px; padding-top: 6px; font-weight: 700; }
.qm-section-tab {
	padding: 6px 12px; border-radius: var(--qm-radius-sm); background: var(--qm-color-surface);
	border: 1px solid var(--qm-color-border-strong); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--qm-color-text);
	min-height: var(--qm-touch-min); display: inline-flex; align-items: center;
}
.qm-section-tab.qm-active { background: var(--qm-color-primary); border-color: var(--qm-color-primary); color: #fff; }

/* ---- Buttons (exam screen only — scoped under .qm-exam-wrap so this does
   not affect any other screen's .qm-btn usage, e.g. the public quiz list). */
.qm-exam-wrap .qm-btn {
	font-family: var(--qm-font); font-size: 14px; font-weight: 600; line-height: 1;
	border-radius: var(--qm-radius-md); border: 1px solid transparent; cursor: pointer;
	padding: 0 var(--qm-space-4); min-height: var(--qm-touch-min);
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	transition: background-color var(--qm-duration-fast) var(--qm-easing), border-color var(--qm-duration-fast) var(--qm-easing);
}
.qm-exam-wrap .qm-btn-sm { min-height: 36px; padding: 0 var(--qm-space-3); font-size: 13px; }
.qm-exam-wrap .qm-btn-primary { background: var(--qm-color-primary); border-color: var(--qm-color-primary); color: #fff; }
.qm-exam-wrap .qm-btn-primary:hover { background: var(--qm-color-primary-hover); border-color: var(--qm-color-primary-hover); }
.qm-exam-wrap .qm-btn-primary:active { background: var(--qm-color-primary-active); border-color: var(--qm-color-primary-active); }
.qm-exam-wrap .qm-btn-secondary { background: var(--qm-color-surface); border-color: var(--qm-color-border-strong); color: var(--qm-color-text); }
.qm-exam-wrap .qm-btn-secondary:hover { background: var(--qm-color-bg); }
.qm-exam-wrap .qm-btn-destructive-solid, .qm-exam-wrap .qm-btn-danger { background: var(--qm-color-error); border-color: var(--qm-color-error); color: #fff; }
.qm-exam-wrap .qm-btn-destructive-solid:hover, .qm-exam-wrap .qm-btn-danger:hover { background: #94190F; border-color: #94190F; }
.qm-exam-wrap .qm-btn:disabled { background: var(--qm-color-disabled-bg); border-color: var(--qm-color-disabled-border); color: var(--qm-color-disabled-text); cursor: not-allowed; }

/* ---- Modal ---------------------------------------------------------------
   Standard / confirmation / destructive-confirmation / information all share
   this one structure — only which button is qm-btn-destructive-solid vs
   qm-btn-primary changes, decided at the call site (see showModal/showNotice
   in exam.js). Overlay dims but never blurs the page (no decorative cost). */
.qm-modal-overlay { position: fixed; inset: 0; background: rgba(20,22,26,.45); display: flex; align-items: center; justify-content: center; z-index: 99999; padding: var(--qm-space-4); }
.qm-modal { background: var(--qm-color-surface); border-radius: var(--qm-radius-lg); box-shadow: var(--qm-shadow-overlay); padding: var(--qm-space-5); max-width: 420px; width: 100%; }
.qm-modal h3 { margin: 0 0 8px; font-size: 16px; color: var(--qm-color-text); }
.qm-modal p { margin: 0; color: var(--qm-color-text-muted); font-size: 14px; line-height: 1.6; }
.qm-modal-actions { display: flex; justify-content: flex-end; gap: var(--qm-space-2); margin-top: var(--qm-space-5); flex-wrap: wrap; }

/* Results — restyled onto the same tokens as the exam screen, so review
   reads as the same platform, not a separate visual system. */
.qm-result-summary { display: flex; gap: var(--qm-space-5); align-items: center; background: var(--qm-color-surface); border: 1px solid var(--qm-color-border); border-radius: var(--qm-radius-lg); padding: var(--qm-space-5); margin: var(--qm-space-4) 0; flex-wrap: wrap; }
.qm-result-score { text-align: center; }
.qm-score-big { font-size: 42px; font-weight: 800; color: var(--qm-color-primary); }
.qm-score-total { font-size: 20px; color: var(--qm-color-text-muted); }
.qm-score-caption { font-size: 11px; color: var(--qm-color-text-muted); margin-top: 4px; }
.qm-result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--qm-space-4); flex: 1; }
.qm-result-stats div { text-align: center; }
.qm-result-stats strong { display: block; font-size: 18px; }
.qm-result-stats span { font-size: 12px; color: var(--qm-color-text-muted); }

/* The one summary chart on this page — a single stacked bar, not a dashboard
   of similar-looking charts, answering "how did I perform" before any table
   is read. Each color is also named in the legend beneath it. */
.qm-outcome-bar { display: flex; height: 14px; border-radius: var(--qm-radius-sm); overflow: hidden; background: var(--qm-color-bg); margin: 0 0 var(--qm-space-2); }
.qm-outcome-seg { height: 100%; }
.qm-outcome-correct { background: var(--qm-color-success); }
.qm-outcome-wrong { background: var(--qm-color-error); }
.qm-outcome-unattempted { background: var(--qm-color-border-strong); }
.qm-outcome-legend { display: flex; gap: var(--qm-space-4); font-size: 12px; color: var(--qm-color-text-muted); margin-bottom: var(--qm-space-5); flex-wrap: wrap; }
.qm-outcome-legend .qm-legend-dot { width: 10px; height: 10px; border-radius: 2px; }

.qm-breakdown-h { font-size: 14px; margin: var(--qm-space-4) 0 var(--qm-space-2); }
.qm-breakdown-table { margin-bottom: var(--qm-space-4) !important; }
/* Shared mini accuracy-bar, reused identically across Section/Subject/Chapter
   breakdown tables — one visual language for "how well did I do here",
   regardless of which dimension the table is sliced by. */
.qm-bar-cell { min-width: 140px; }
.qm-mini-bar { display: inline-block; width: 80px; height: 8px; border-radius: 4px; background: var(--qm-color-bg); overflow: hidden; vertical-align: middle; margin-right: 8px; }
.qm-mini-bar-fill { height: 100%; background: var(--qm-color-primary); }
.qm-mini-bar-label { font-size: 12px; font-weight: 600; color: var(--qm-color-text-muted); }

.qm-review-scheme { font-weight: 400; color: var(--qm-color-text-muted); font-size: 12px; }
.qm-review-time { color: var(--qm-color-text-muted); font-size: 12px; }
/* Responsive horizontal scroll for wide tables (breakdown tables on the
   result page) — the table keeps its natural column widths and only this
   wrapper scrolls, so the page itself never scrolls sideways. */
.qm-table-scroll { overflow-x: auto; margin-bottom: var(--qm-space-4); }
.qm-table-scroll table { margin-bottom: 0; }

.qm-result-table { width: 100%; border-collapse: collapse; margin-bottom: var(--qm-space-5); }
.qm-result-table th, .qm-result-table td { border: 1px solid var(--qm-color-border); padding: 8px 12px; text-align: left; }
.qm-topic-grid { display: flex; flex-wrap: wrap; gap: var(--qm-space-2); margin-bottom: var(--qm-space-5); }
.qm-topic-pill { padding: 4px 10px; border-radius: var(--qm-radius-sm); font-size: 13px; font-weight: 600; }
.qm-perf-strong { background: var(--qm-color-success-bg); color: var(--qm-color-success); }
.qm-perf-average { background: var(--qm-color-warning-bg); color: var(--qm-color-warning); }
.qm-perf-weak { background: var(--qm-color-error-bg); color: var(--qm-color-error); }
.qm-weak-box { background: var(--qm-color-warning-bg); border-radius: var(--qm-radius-md); padding: var(--qm-space-3) var(--qm-space-4); margin-bottom: var(--qm-space-5); }
.qm-weak-box span { display: inline-block; background: var(--qm-color-surface); padding: 3px 9px; border-radius: var(--qm-radius-sm); margin: 4px 4px 0 0; font-size: 13px; }

.qm-review-item { border: 1px solid var(--qm-color-border); border-radius: var(--qm-radius-md); padding: var(--qm-space-4); margin-bottom: var(--qm-space-3); background: var(--qm-color-surface); }
.qm-review-item.qm-status-correct { border-left: 4px solid var(--qm-color-success); }
.qm-review-item.qm-status-wrong { border-left: 4px solid var(--qm-color-error); }
.qm-review-item.qm-status-unattempted { border-left: 4px solid var(--qm-color-warning); }
.qm-review-head { display: flex; gap: var(--qm-space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--qm-space-3); font-size: 13px; color: var(--qm-color-text-muted); }
.qm-review-type-tag { font-size: 11px; font-weight: 600; color: var(--qm-color-text-muted); background: var(--qm-color-bg); border: 1px solid var(--qm-color-border); padding: 2px 8px; border-radius: var(--qm-radius-sm); }
.qm-review-badge { font-weight: 700; padding: 2px 9px; border-radius: var(--qm-radius-sm); font-size: 11px; }
.qm-review-badge.qm-badge-correct { background: var(--qm-color-success-bg); color: var(--qm-color-success); }
.qm-review-badge.qm-badge-wrong { background: var(--qm-color-error-bg); color: var(--qm-color-error); }
.qm-review-badge.qm-badge-unattempted { background: var(--qm-color-warning-bg); color: var(--qm-color-warning); }
.qm-review-marks { margin-left: auto; font-weight: 600; }
.qm-review-question { font-size: 15px; line-height: 1.6; margin-bottom: var(--qm-space-3); white-space: normal !important; overflow-wrap: anywhere !important; word-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important; }
.qm-review-explanation { background: var(--qm-color-bg); padding: var(--qm-space-3) var(--qm-space-4); border-radius: var(--qm-radius-md); font-size: 14px; margin-top: var(--qm-space-3); white-space: normal !important; overflow-wrap: anywhere !important; word-wrap: break-word !important; word-break: break-word !important; max-width: 100% !important; }

/* Review option states — reuses the exact same .qm-option/.qm-option-id
   markup as the live exam screen (see the "Answer options" rules above), so
   a student recognizes the same component, just now read-only and carrying
   the outcome instead of an input. Every state pairs color with a text tag
   ("Your answer" / "Correct answer"), never color alone. */
.qm-options-review .qm-option { cursor: default; }
.qm-options-review .qm-option:hover { border-color: var(--qm-color-border); background: var(--qm-color-surface); }
.qm-review-correct-selected { border-color: var(--qm-color-success) !important; background: var(--qm-color-success-bg) !important; }
.qm-review-correct-selected .qm-option-id { background: var(--qm-color-success); color: #fff; border-color: var(--qm-color-success); }
.qm-review-correct { border-color: var(--qm-color-success) !important; background: var(--qm-color-surface) !important; }
.qm-review-correct .qm-option-id { background: var(--qm-color-success-bg); color: var(--qm-color-success); border-color: var(--qm-color-success); }
.qm-review-wrong-selected { border-color: var(--qm-color-error) !important; background: var(--qm-color-error-bg) !important; }
.qm-review-wrong-selected .qm-option-id { background: var(--qm-color-error); color: #fff; border-color: var(--qm-color-error); }
.qm-review-tag { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--qm-radius-sm); }
.qm-review-tag-selected { background: var(--qm-color-text); color: #fff; }
.qm-review-tag-correct { background: var(--qm-color-success); color: #fff; }

/* Text-answer types (Numerical, Fill-in-the-Blank) have no option list, so
   review shows a paired answer card instead — same color language as above. */
.qm-review-answers { display: flex; flex-direction: column; gap: var(--qm-space-2); margin-bottom: var(--qm-space-3); }
.qm-review-answer-row { display: flex; align-items: center; gap: var(--qm-space-3); font-size: 14px; }
.qm-review-answer-label { color: var(--qm-color-text-muted); min-width: 110px; }
.qm-review-answer-value { font-weight: 600; padding: 3px 10px; border-radius: var(--qm-radius-sm); background: var(--qm-color-bg); }
.qm-review-answer-value.qm-review-correct { background: var(--qm-color-success-bg); color: var(--qm-color-success); }
.qm-review-answer-value.qm-review-wrong-selected { background: var(--qm-color-error-bg); color: var(--qm-color-error); }

.qm-public-list { display: flex; flex-wrap: wrap; gap: 16px; }
.qm-quiz-card { border: 1px solid #dcdcde; border-radius: 8px; padding: 18px; width: 260px; background: #fff; }

@media (max-width: 782px) {
	.qm-result-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   Responsive — exam interface only. Two breakpoints (960px / 600px), per the
   design system. Below 960px the palette stops being a permanent sidebar and
   becomes an off-canvas drawer (opened via the header's palette-toggle
   button) — a deliberate choice, not the desktop sidebar simply squeezed
   narrower, since a permanent sidebar at phone width would leave less than
   half the screen for the actual question.
   ========================================================================== */
@media (max-width: 959px) {
	.qm-exam-body { display: block; }
	.qm-question-area { padding: var(--qm-space-4); }

	.qm-palette-toggle { display: inline-flex; }

	.qm-palette-area {
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
		max-height: 75vh; overflow-y: auto;
		border-left: none; border-top: 1px solid var(--qm-color-border);
		border-radius: var(--qm-radius-lg) var(--qm-radius-lg) 0 0;
		box-shadow: var(--qm-shadow-overlay);
		transform: translateY(100%);
		transition: transform var(--qm-duration-base) var(--qm-easing);
		padding-bottom: calc(var(--qm-space-4) + env(safe-area-inset-bottom, 0px));
	}
	.qm-palette-open .qm-palette-area { transform: translateY(0); }
	.qm-palette-scrim {
		display: block; position: fixed; inset: 0; background: rgba(20,22,26,.45);
		z-index: 55; opacity: 0; pointer-events: none; transition: opacity var(--qm-duration-base) var(--qm-easing);
	}
	.qm-palette-open .qm-palette-scrim { opacity: 1; pointer-events: auto; }
}

/* Below 600px, additionally: nav buttons become a fixed bottom bar (Clear +
   Mark on top, Previous + Save & Next below — the two most consequential
   actions get the more prominent lower row), so all four actions stay within
   thumb's reach without the student ever scrolling back up past a long
   question to find them. */
@media (max-width: 599px) {
	.qm-header-top { flex-direction: column; align-items: stretch; gap: 6px; padding: var(--qm-space-2) var(--qm-space-3); }
	.qm-header-title { font-size: 14px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
	.qm-header-controls { justify-content: flex-end; }
	.qm-header-sub { padding: 0 var(--qm-space-3) var(--qm-space-2); font-size: 12px; }
	.qm-timer { font-size: 14px; padding: 6px 10px; }
	.qm-save-status[data-state="saving"], .qm-save-status[data-state="saved"] { display: none; }
	.qm-save-status[data-state="error"], .qm-save-status[data-state="rejected"] { white-space: normal; }
	.qm-timer.qm-timer-critical { font-size: 15px; }

	.qm-question-area { padding: var(--qm-space-3) var(--qm-space-3) 132px; } /* bottom padding clears the fixed nav bar below */

	.qm-nav-buttons {
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
		margin: 0; background: var(--qm-color-surface); border-top: 1px solid var(--qm-color-border);
		box-shadow: var(--qm-shadow-overlay);
		display: grid; grid-template-columns: 1fr 1fr; gap: var(--qm-space-2);
		padding: var(--qm-space-2) var(--qm-space-3) calc(var(--qm-space-2) + env(safe-area-inset-bottom, 0px));
	}
	.qm-nav-buttons .qm-btn { width: 100%; }
	#qm-clear { order: 1; }
	#qm-mark { order: 2; }
	#qm-prev { order: 3; }
	#qm-savenext { order: 4; }
	/* Locked-section state renders only a lone Previous button — let it span
	   the full width rather than sitting alone in a half-empty grid cell. */
	.qm-locked-banner + .qm-nav-buttons { grid-template-columns: 1fr; }

	.qm-submit-bar { margin-bottom: 96px; } /* Submit Section bar: keep clear of the fixed bar below it too */
}

/* Added strict section-lock states; existing section styles remain intact. */
.qm-section-tab.qm-section-disabled, .qm-section-tab:disabled { cursor:not-allowed; opacity:.55; }
.qm-section-tab.qm-section-disabled:not(.qm-active) { background:var(--qm-color-disabled-bg); border-color:var(--qm-color-disabled-border); color:var(--qm-color-disabled-text); }

/* v1.35 presentation-first student experience */
#qm-exam-app{--qm-accent:#4F46E5;--qm-accent-rgb:79,70,229;position:relative}
.qm-presentation-stage{position:relative;width:100%;min-height:560px;height:auto;max-width:1920px;margin:0 auto;border-radius:16px;background:#0F172A;box-shadow:0 12px 40px rgba(15,23,42,.12);border:1px solid rgba(255,255,255,.08)}
.qm-presentation-stage .qm-exam-header,.qm-presentation-stage .qm-exam-body{position:relative;z-index:5}
.qm-exam-header{background:rgba(255,255,255,.98)!important;border-bottom:1px solid #E5E7EB!important}
.qm-exam-body{display:flex;min-height:500px;height:auto;overflow:visible}
.qm-question-area{flex:1 1 auto;min-height:480px;height:auto;overflow:visible;position:relative;display:flex;flex-direction:column}
.qm-palette-area{max-height:100%;overflow-y:auto}

/* Fullscreen mode adaptations */
:fullscreen .qm-presentation-stage,
:-webkit-full-screen .qm-presentation-stage,
.qm-is-fullscreen .qm-presentation-stage{height:100%;max-height:100vh;overflow:hidden;border-radius:0}
:fullscreen .qm-presentation-stage .qm-exam-body,
:-webkit-full-screen .qm-presentation-stage .qm-exam-body,
.qm-is-fullscreen .qm-presentation-stage .qm-exam-body{height:calc(100% - 70px);overflow:hidden}
:fullscreen .qm-presentation-stage .qm-question-area,
:-webkit-full-screen .qm-presentation-stage .qm-question-area,
.qm-is-fullscreen .qm-presentation-stage .qm-question-area{height:100%;overflow-y:auto}

.qm-is-fullscreen{position:fixed!important;inset:0!important;width:100vw!important;height:100vh!important;height:100dvh!important;z-index:999999!important;background:#0F172A!important;margin:0!important;padding:0!important}
body.qm-body-fullscreen{overflow:hidden!important}

.qm-motion-layer{position:absolute;inset:0;z-index:1;pointer-events:none;overflow:hidden;background:radial-gradient(circle at 12% 14%,rgba(79,70,229,.15),transparent 32%),radial-gradient(circle at 88% 78%,rgba(255,107,90,.10),transparent 34%);}.qm-motion-grid{position:absolute;inset:-30% -10%;background-image:linear-gradient(rgba(255,255,255,.05) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.05) 1px,transparent 1px);background-size:52px 52px;transform:perspective(600px) rotateX(58deg) translateY(25%);opacity:.50;animation:qm-grid-drift 16s linear infinite}.qm-motion-glow{position:absolute;width:340px;height:340px;border-radius:50%;filter:blur(24px);opacity:.30}.qm-glow-a{left:-80px;top:-120px;background:rgba(79,70,229,.50);animation:qm-glow-a 10s ease-in-out infinite alternate}.qm-glow-b{right:-120px;bottom:-140px;background:rgba(255,107,90,.32);animation:qm-glow-b 13s ease-in-out infinite alternate}.qm-motion-beam{position:absolute;width:110%;height:90px;left:-5%;top:40%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.06),transparent);transform:rotate(-8deg);animation:qm-beam 7s ease-in-out infinite}.qm-motion-particles{position:absolute;inset:0}.qm-motion-particle{position:absolute;width:6px;height:6px;border-radius:50%;left:calc((var(--i) * 8.3%) + 3%);top:calc(14% + (var(--i) % 5) * 15%);background:rgba(255,255,255,.40);box-shadow:0 0 16px rgba(255,255,255,.20);animation:qm-particle 5s ease-in-out infinite;animation-delay:calc(var(--i) * -.37s)}.qm-motion-soft .qm-motion-grid,.qm-motion-soft .qm-motion-beam,.qm-motion-soft .qm-motion-particle{animation-duration:24s;opacity:.28}.qm-motion-off .qm-motion-layer{display:none}.qm-timer-wrap{position:relative;display:flex;align-items:center;justify-content:center;width:78px;height:48px}.qm-timer-ring{position:relative;width:44px;height:44px}.qm-timer-ring svg{width:44px;height:44px;transform:rotate(-90deg)}.qm-timer-track,.qm-timer-progress{fill:none;stroke-width:3.5}.qm-timer-track{stroke:#E9EEF4}.qm-timer-progress{stroke:var(--qm-accent);stroke-linecap:round;transition:stroke-dashoffset .6s linear,stroke .2s ease}.qm-timer-ring>span{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:11px;line-height:1;font-variant-numeric:tabular-nums}.qm-timer-bar{position:absolute;left:0;right:0;bottom:0;height:3px;border-radius:4px;background:#EDF0F4;overflow:hidden;display:none}.qm-timer-bar span{display:block;height:100%;background:var(--qm-accent);transition:width .8s linear}.qm-timer-style-bar .qm-timer-bar{display:block}.qm-timer-style-bar .qm-timer-ring{display:none}.qm-timer-style-numeric{width:auto}.qm-timer-style-numeric .qm-timer-ring svg,.qm-timer-style-numeric .qm-timer-track,.qm-timer-style-numeric .qm-timer-progress{display:none}.qm-timer-style-numeric .qm-timer-ring{width:auto}.qm-timer-style-numeric .qm-timer-ring>span{position:static;font-size:14px;white-space:nowrap;font-variant-numeric:tabular-nums}.qm-timer-warning .qm-timer-progress{stroke:#D97706}.qm-timer-critical .qm-timer-progress{stroke:#DC2626}.qm-timer-critical .qm-timer-ring{animation:qm-timer-pulse 1s ease-in-out infinite}.qm-timer-expired .qm-timer-progress{stroke:#B42318}.qm-feedback-card{display:flex;align-items:flex-start;gap:14px;margin:16px 0;padding:16px 18px;border-radius:14px;border:1px solid rgba(var(--qm-accent-rgb),.22);background:linear-gradient(135deg,rgba(var(--qm-accent-rgb),.06),#fff);box-shadow:0 10px 25px rgba(15,23,42,.06);animation:qm-feedback-in .24s ease-out}.qm-feedback-card.is-correct{border-color:#A7F3D0;background:linear-gradient(135deg,#ECFDF5,#fff)}.qm-feedback-card.is-incorrect{border-color:#FECACA;background:linear-gradient(135deg,#FEF2F2,#fff)}.qm-feedback-icon{width:36px;height:36px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:900;background:var(--qm-accent);color:#fff;box-shadow:0 6px 16px rgba(var(--qm-accent-rgb),.20);flex:0 0 36px}.is-correct .qm-feedback-icon{background:#059669}.is-incorrect .qm-feedback-icon{background:#DC2626}.qm-feedback-body{min-width:0}.qm-feedback-body strong{display:block;font-size:14px;color:#111827}.qm-feedback-explanation{margin-top:5px;color:#4B5563;line-height:1.55}.qm-annotation-toolbar{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:12px;padding:6px 10px;border:1px solid #E5E7EB;border-radius:10px;background:rgba(255,255,255,.94);position:relative;z-index:8}.qm-tool-btn{border:1px solid #D1D5DB;background:#fff;color:#374151;border-radius:6px;padding:6px 10px;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s ease}.qm-tool-btn:hover{border-color:#9CA3AF;background:#F9FAFB}.qm-tool-active{border-color:var(--qm-accent);color:var(--qm-accent);background:rgba(var(--qm-accent-rgb),.08)}.qm-annotation-canvas-wrap{position:absolute;inset:0;z-index:7;pointer-events:none;margin:0;min-height:0}.qm-annotation-canvas-wrap canvas{position:absolute;inset:0;width:100%;height:100%;z-index:7;pointer-events:none}.qm-question-area{position:relative}.qm-question-area>*:not(.qm-annotation-canvas-wrap):not(.qm-annotation-toolbar){position:relative;z-index:2}.qm-presentation-16x9 .qm-question-area{padding:2.5% 4%}.qm-presentation-16x9 .qm-options-list{grid-template-columns:repeat(2,minmax(0,1fr))}.qm-presentation-16x9 .qm-q-text{font-size:clamp(22px,1.9vw,34px);line-height:1.32;font-weight:600}.qm-presentation-16x9 .qm-option{min-height:64px}.qm-presentation-16x9 .qm-option-text{font-size:clamp(15px,1.15vw,20px)}@keyframes qm-grid-drift{from{transform:perspective(600px) rotateX(58deg) translateY(25%)}to{transform:perspective(600px) rotateX(58deg) translateY(35%)}}@keyframes qm-glow-a{from{transform:translate(0,0)}to{transform:translate(120px,80px)}}@keyframes qm-glow-b{from{transform:translate(0,0)}to{transform:translate(-80px,-80px)}}@keyframes qm-beam{0%,100%{transform:translateX(-20%) rotate(-8deg)}50%{transform:translateX(20%) rotate(-8deg)}}@keyframes qm-particle{0%,100%{transform:translateY(0) scale(.8);opacity:.3}50%{transform:translateY(-22px) scale(1.1);opacity:.8}}@keyframes qm-timer-pulse{50%{transform:scale(1.05)}}@keyframes qm-feedback-in{from{opacity:0;transform:translateY(8px) scale(.985)}to{opacity:1;transform:translateY(0) scale(1)}}@media(max-width:960px){.qm-presentation-stage{aspect-ratio:auto;min-height:640px;border-radius:14px}.qm-presentation-16x9 .qm-question-area{padding:16px}.qm-presentation-16x9 .qm-options-list{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){.qm-motion-layer *,.qm-timer-critical .qm-timer-ring,.qm-feedback-card{animation:none!important;transition:none!important}.qm-motion-layer{display:none!important}}

/* v1.35.1 presentation and annotation correction */
.qm-question-area{position:relative;display:flex;flex-direction:column;min-height:480px;height:auto;flex:1 1 auto;overflow:visible}
.qm-question-area .qm-annotation-toolbar{flex:0 0 auto}
.qm-question-area .qm-feedback-card{flex:0 0 auto}
.qm-question-area .qm-nav-buttons{display:flex!important;align-items:center!important;gap:10px!important;margin-top:auto!important;padding:14px 0!important;border-top:1px solid #E5E7EB!important;background:#FFFFFF!important;position:sticky!important;bottom:0!important;z-index:25!important;flex-wrap:wrap!important;width:100%!important;box-shadow:0 -4px 14px rgba(0,0,0,.04)!important}
.qm-question-area .qm-nav-buttons .qm-btn{border-radius:8px!important;padding:10px 18px!important;font-weight:600!important;font-size:14px!important;cursor:pointer!important;min-height:42px!important;display:inline-flex!important;align-items:center!important;justify-content:center!important}
#qm-savenext{background:var(--qm-accent,#4F46E5)!important;color:#FFFFFF!important;border-color:var(--qm-accent,#4F46E5)!important;margin-left:auto!important}
#qm-submit-test{flex-shrink:0!important;white-space:nowrap!important;font-weight:700!important;min-height:38px!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;z-index:25!important}
.qm-annotation-canvas-wrap{z-index:7}
.qm-annotation-toolbar{z-index:8!important}
.qm-annotation-toolbar button{pointer-events:auto!important}
.qm-motion-layer{will-change:transform}
.qm-presentation-stage .qm-exam-header{flex:0 0 70px}
.qm-presentation-stage .qm-exam-body{display:flex;min-height:500px;height:auto;overflow:visible}
.qm-presentation-16x9 .qm-question-area{padding:2.6% 4% 2%;}
.qm-presentation-16x9 .qm-q-topline{margin-bottom:1rem}
.qm-presentation-16x9 .qm-q-text{max-width:100%;margin-bottom:1rem}
.qm-presentation-16x9 .qm-options-list{gap:.85rem}
.qm-presentation-16x9 .qm-option{min-height:60px;padding:12px 16px}
.qm-timer-ring{filter:drop-shadow(0 2px 6px rgba(15,23,42,.08))}
.qm-timer-critical .qm-timer-display,.qm-timer-critical #qm-timer-display{font-variant-numeric:tabular-nums}
.qm-feedback-card{position:relative}.qm-feedback-card:after{content:attr(data-countdown);display:block;margin-top:8px;font-size:12px;font-weight:700;color:#6B7280}.qm-feedback-card.is-correct:after{color:#059669}.qm-feedback-card.is-incorrect:after{color:#DC2626}

/* v1.35.1 visible presentation motion */
.qm-presentation-stage>.qm-motion-layer{z-index:1;display:block}.qm-presentation-stage{isolation:isolate}.qm-presentation-stage .qm-exam-header,.qm-presentation-stage .qm-exam-body{z-index:5}.qm-presentation-stage .qm-exam-body{background:#F8FAFC!important}.qm-presentation-stage .qm-question-area{background:#FFFFFF;backdrop-filter:blur(3px)}.qm-presentation-stage .qm-palette-area{background:#F8FAFC}.qm-presentation-stage .qm-motion-layer:after{content:"";position:absolute;inset:0;border:1px solid rgba(255,255,255,.12);box-shadow:inset 0 0 50px rgba(79,70,229,.10);pointer-events:none}.qm-presentation-stage .qm-timer-wrap{width:78px;height:52px}.qm-presentation-stage .qm-timer-ring{width:48px;height:48px}.qm-presentation-stage .qm-timer-ring svg{width:48px;height:48px}.qm-presentation-stage .qm-timer-ring>span{font-size:11px}.qm-presentation-stage .qm-timer-normal .qm-timer-ring{animation:qm-timer-breathe 3.2s ease-in-out infinite}.qm-presentation-stage .qm-timer-warning .qm-timer-ring{animation:qm-timer-warning 1.4s ease-in-out infinite}.qm-timer-style-bar{width:140px!important;height:24px!important}.qm-timer-style-bar .qm-timer-bar{height:5px;bottom:2px}.qm-timer-style-bar .qm-timer-ring{display:none}.qm-motion-full .qm-motion-grid{opacity:.65}.qm-motion-full .qm-motion-beam{opacity:.45}@keyframes qm-timer-breathe{0%,100%{filter:drop-shadow(0 2px 6px rgba(79,70,229,.05))}50%{filter:drop-shadow(0 4px 12px rgba(79,70,229,.18))}}@keyframes qm-timer-warning{50%{transform:scale(1.04)}}

/* 1.35.2 interaction + presentation hardening */
.qm-question-transition{animation:qm-question-enter .28s cubic-bezier(.2,.75,.2,1) both}
.qm-question-transition .qm-option{animation:qm-option-enter .28s ease both}
.qm-question-transition .qm-option:nth-child(2){animation-delay:.03s}.qm-question-transition .qm-option:nth-child(3){animation-delay:.06s}.qm-question-transition .qm-option:nth-child(4){animation-delay:.09s}.qm-question-transition .qm-option:nth-child(5){animation-delay:.12s}.qm-question-transition .qm-option:nth-child(6){animation-delay:.15s}
@keyframes qm-question-enter{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes qm-option-enter{from{opacity:0;transform:translateY(6px) scale(.995)}to{opacity:1;transform:none}}
.qm-question-area .qm-nav-buttons{position:relative;z-index:12}
.qm-question-area .qm-submit-bar{position:relative;z-index:12}
.qm-teaching-controls{position:relative;z-index:12;display:flex;align-items:center;gap:10px;margin-top:12px;padding:8px 12px;border:1px solid #E5E7EB;border-radius:10px;background:#FFFFFF}
.qm-teaching-hint{font-size:12px;color:#6B7280;font-weight:600}
.qm-teaching-reveal{border-color:#A7F3D0!important;box-shadow:0 12px 30px rgba(16,185,129,.10)!important}
.qm-teaching-explanation{margin-top:8px;padding-top:8px;border-top:1px solid rgba(16,185,129,.15)}
.qm-question-area .qm-nav-buttons,.qm-question-area .qm-submit-bar,.qm-annotation-toolbar,.qm-teaching-controls{z-index:12!important}
@media(prefers-reduced-motion:reduce){.qm-question-transition,.qm-question-transition .qm-option{animation:none!important}}

/* Clean, modern presentation shell styling */
.qm-presentation-16x9 .qm-presentation-stage{background:#0F172A;border:1px solid rgba(255,255,255,.08)}
.qm-presentation-16x9 .qm-presentation-stage .qm-exam-header{background:#FFFFFF!important;color:#111827;border-bottom:1px solid #E5E7EB}
.qm-presentation-16x9 .qm-presentation-stage .qm-header-title{color:#111827;font-size:clamp(15px,1vw,18px);font-weight:700;letter-spacing:-.01em}
.qm-presentation-16x9 .qm-presentation-stage .qm-header-sub{color:#6B7280}
.qm-presentation-16x9 .qm-presentation-stage .qm-header-section{background:#EEF2FF;color:#4F46E5;border:1px solid #E0E7FF;border-radius:6px}
.qm-presentation-16x9 .qm-presentation-stage .qm-header-progress{color:#4B5563;font-weight:600}
.qm-presentation-16x9 .qm-presentation-stage .qm-btn-icon{color:#6B7280;border:1px solid #E5E7EB;border-radius:8px}
.qm-presentation-16x9 .qm-presentation-stage .qm-btn-icon:hover{background:#F3F4F6;color:#111827}
.qm-presentation-16x9 .qm-presentation-stage .qm-save-status{color:#059669;font-weight:600}
.qm-presentation-16x9 .qm-presentation-stage .qm-exam-body{background:#F8FAFC!important;border:0;gap:0;padding:0;box-sizing:border-box}
.qm-presentation-16x9 .qm-presentation-stage .qm-question-area{background:#FFFFFF;border:none;border-radius:0;box-shadow:none;padding:clamp(18px,2.2%,30px) clamp(22px,3.2%,48px)}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-area{flex:0 0 clamp(240px,20vw,320px);min-width:0;border-left:1px solid #E5E7EB;border-radius:0;background:#F8FAFC;color:#1F2937;padding:16px;box-sizing:border-box}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-legend{color:#6B7280}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-section-label{color:#4B5563;font-weight:700}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-btn{background:#FFFFFF;color:#1F2937;border-color:#D1D5DB;border-radius:8px}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-btn:hover{background:#F3F4F6}
.qm-presentation-16x9 .qm-presentation-stage .qm-palette-btn.qm-p-current{background:var(--qm-accent);border-color:var(--qm-accent);color:#fff;box-shadow:0 4px 12px rgba(var(--qm-accent-rgb),.25)}
.qm-presentation-16x9 .qm-presentation-stage .qm-q-number{color:#111827;font-size:clamp(15px,1vw,18px);font-weight:700}
.qm-presentation-16x9 .qm-presentation-stage .qm-q-type-tag,.qm-presentation-16x9 .qm-presentation-stage .qm-q-subject{background:#F3F4F6;border-color:#E5E7EB;color:#4B5563;border-radius:6px}
.qm-presentation-16x9 .qm-presentation-stage .qm-q-text{font-size:clamp(20px,1.8vw,30px);font-weight:600;letter-spacing:-.015em;line-height:1.35;color:#111827;margin-bottom:1.1rem}
.qm-presentation-16x9 .qm-presentation-stage .qm-answer-instruction{font-size:12px;font-weight:600;color:#6B7280;margin-bottom:10px;text-transform:none;letter-spacing:normal}
.qm-presentation-16x9 .qm-presentation-stage .qm-options-list{gap:10px}
.qm-presentation-16x9 .qm-presentation-stage .qm-option{min-height:58px;padding:12px 16px;border-radius:10px;border:1.5px solid #E5E7EB;background:#FFFFFF;box-shadow:0 1px 3px rgba(0,0,0,.03);transition:all .15s ease}
.qm-presentation-16x9 .qm-presentation-stage .qm-option:hover{border-color:#9CA3AF;background:#F9FAFB}
.qm-presentation-16x9 .qm-presentation-stage .qm-option.qm-selected{background:#EEF2FF;border-color:var(--qm-accent);box-shadow:0 2px 8px rgba(var(--qm-accent-rgb),.15)}
.qm-presentation-16x9 .qm-presentation-stage .qm-option-id{width:28px;height:28px;border-radius:6px;background:#F3F4F6;border-color:#E5E7EB;color:#4B5563;font-size:12px;font-weight:700}
.qm-presentation-16x9 .qm-presentation-stage .qm-option.qm-selected .qm-option-id{background:var(--qm-accent);border-color:var(--qm-accent);color:#fff}
.qm-presentation-16x9 .qm-presentation-stage .qm-option-text{font-size:clamp(15px,1.05vw,18px);line-height:1.45;font-weight:500;color:#1F2937}
.qm-presentation-16x9 .qm-presentation-stage .qm-nav-buttons{gap:10px}
.qm-presentation-16x9 .qm-presentation-stage .qm-nav-buttons .qm-btn{border-radius:8px;padding:9px 18px;font-weight:600;font-size:13px}
.qm-presentation-16x9 .qm-presentation-stage .qm-submit-bar{text-align:left}
.qm-presentation-16x9 .qm-presentation-stage .qm-feedback-card{margin-top:12px;border-radius:12px;padding:14px 16px;box-shadow:0 4px 12px rgba(0,0,0,.05)}
.qm-presentation-16x9 .qm-presentation-stage .qm-feedback-icon{width:36px;height:36px;border-radius:10px;flex-basis:36px;font-size:18px}
.qm-presentation-16x9 .qm-presentation-stage .qm-feedback-body strong{font-size:14px}
.qm-presentation-16x9 .qm-presentation-stage .qm-feedback-explanation{font-size:13px;line-height:1.55}
.qm-presentation-16x9 .qm-presentation-stage .qm-feedback-card:after{display:inline-flex;margin-left:auto;align-self:flex-end;min-width:110px;justify-content:center;padding:4px 8px;border-radius:999px;background:#F3F4F6}
.qm-presentation-16x9 .qm-presentation-stage .qm-annotation-toolbar{background:#FFFFFF;border-color:#E5E7EB;padding:6px;border-radius:10px;box-shadow:0 2px 8px rgba(0,0,0,.04)}
.qm-presentation-16x9 .qm-presentation-stage .qm-annotation-canvas-wrap{border-radius:10px}
.qm-presentation-16x9 .qm-presentation-stage .qm-motion-layer{opacity:.85}
.qm-presentation-16x9 .qm-presentation-stage .qm-motion-layer:before{content:"";position:absolute;left:3%;right:3%;top:9%;height:1px;background:linear-gradient(90deg,transparent,rgba(79,70,229,.35),rgba(255,107,90,.25),transparent);animation:qm-ambient-line 6s ease-in-out infinite}
.qm-presentation-16x9 .qm-presentation-stage .qm-motion-layer:after{border-color:rgba(255,255,255,.12);box-shadow:inset 0 0 60px rgba(79,70,229,.12),inset 0 0 30px rgba(255,107,90,.05)}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-wrap{width:78px;height:50px}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-ring{width:46px;height:46px}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-ring svg{width:46px;height:46px}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-ring>span{font-size:11px;color:#111827;font-weight:700}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-track{stroke:#E5E7EB}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-progress{stroke:var(--qm-accent)}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-bar{background:#E5E7EB}
.qm-presentation-16x9 .qm-presentation-stage .qm-timer-bar span{background:linear-gradient(90deg,#059669,#D97706,#DC2626)}
@keyframes qm-ambient-line{0%,100%{transform:translateX(-4%);opacity:.35}50%{transform:translateX(4%);opacity:.75}}
@media(max-width:960px){.qm-presentation-16x9 .qm-presentation-stage .qm-exam-body{padding:0;gap:0}.qm-presentation-16x9 .qm-presentation-stage .qm-palette-area{flex-basis:auto}.qm-presentation-16x9 .qm-presentation-stage .qm-question-area{border-radius:0}.qm-presentation-16x9 .qm-presentation-stage .qm-q-text{font-size:clamp(18px,4vw,26px)}}
@media(prefers-reduced-motion:reduce){.qm-presentation-16x9 .qm-presentation-stage .qm-motion-layer:before{animation:none}.qm-presentation-16x9 .qm-presentation-stage .qm-option{transition:none}}

/* ---- Screen-reader utility ---- */
.qm-sr-only,
.screen-reader-text {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ---- RTL layout support ---- */
[dir="rtl"] .qm-exam-wrap,
.rtl .qm-exam-wrap {
	direction: rtl;
	text-align: right;
}
[dir="rtl"] .qm-option,
.rtl .qm-option {
	flex-direction: row-reverse;
	text-align: right;
}
[dir="rtl"] .qm-nav-buttons,
.rtl .qm-nav-buttons {
	flex-direction: row-reverse;
}
[dir="rtl"] .qm-q-topline,
.rtl .qm-q-topline {
	flex-direction: row-reverse;
	text-align: right;
}
[dir="rtl"] .qm-palette-area,
.rtl .qm-palette-area {
	border-right: none;
	border-left: 1px solid var(--qm-color-border);
}
[dir="rtl"] .qm-section-tabs,
.rtl .qm-section-tabs {
	flex-direction: row-reverse;
}


/* v1.38.2 corrective layout layer — keep the exam inside the available screen.
   The v1.35 presentation rules overrode the earlier mobile drawer rule because
   their selectors were more specific. This layer intentionally comes last. */
.qm-exam-wrap {
	width: 100%; max-width: 1500px; min-width: 0; margin-inline: auto; box-sizing: border-box;
}
.qm-exam-wrap *, .qm-exam-wrap *::before, .qm-exam-wrap *::after { box-sizing: border-box; }
#qm-exam-app { width: 100%; max-width: 1500px; min-width: 0; margin-inline: auto; }
#qm-exam-app .qm-presentation-stage {
	width: 100%; max-width: 100%; min-width: 0; min-height: 0; box-sizing: border-box; overflow: hidden;
	display: flex; flex-direction: column;
}
#qm-exam-app .qm-presentation-stage .qm-exam-body {
	display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 310px); align-items: stretch;
	width: 100%; min-width: 0; height: clamp(360px, calc(100dvh - 260px), 740px);
	min-height: 360px; max-height: calc(100dvh - 220px); overflow: hidden;
}
#qm-exam-app .qm-presentation-stage .qm-question-area {
	min-width: 0; min-height: 0; width: auto; max-width: 100%; height: auto;
	overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere; padding: clamp(16px, 2.5vw, 36px);
}
#qm-exam-app .qm-presentation-stage .qm-palette-area {
	min-width: 0; width: auto; max-width: 100%; min-height: 0; max-height: 100%; height: auto;
	overflow-x: hidden; overflow-y: auto; border-left: 1px solid var(--qm-color-border);
}
#qm-exam-app .qm-presentation-stage .qm-q-text,
#qm-exam-app .qm-presentation-stage .qm-option-text,
#qm-exam-app .qm-presentation-stage .qm-option-body { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
#qm-exam-app .qm-presentation-stage .qm-options-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#qm-exam-app.qm-is-fullscreen .qm-presentation-stage,
#qm-exam-app:fullscreen .qm-presentation-stage,
#qm-exam-app:-webkit-full-screen .qm-presentation-stage {
	height: 100%; min-height: 0; max-height: 100dvh; overflow: hidden;
}
#qm-exam-app.qm-is-fullscreen .qm-presentation-stage .qm-exam-body,
#qm-exam-app:fullscreen .qm-presentation-stage .qm-exam-body,
#qm-exam-app:-webkit-full-screen .qm-presentation-stage .qm-exam-body {
	flex: 1 1 auto; height: auto; min-height: 0; max-height: none; overflow: hidden;
}
#qm-exam-app.qm-is-fullscreen .qm-presentation-stage .qm-question-area,
#qm-exam-app:fullscreen .qm-presentation-stage .qm-question-area,
#qm-exam-app:-webkit-full-screen .qm-presentation-stage .qm-question-area { min-height: 0; height: auto; overflow-y: auto; }
#qm-exam-app.qm-is-fullscreen .qm-presentation-stage .qm-palette-area,
#qm-exam-app:fullscreen .qm-presentation-stage .qm-palette-area,
#qm-exam-app:-webkit-full-screen .qm-presentation-stage .qm-palette-area { min-height: 0; max-height: none; height: auto; }

@media (max-width: 959px) {
	.qm-exam-wrap { max-width: 100%; padding-inline: 8px; }
	#qm-exam-app { max-width: 100%; }
	#qm-exam-app .qm-presentation-stage { min-height: 0; max-height: none; height: auto; overflow: visible; }
	#qm-exam-app .qm-presentation-stage .qm-exam-body { display: block; height: auto; min-height: 0; max-height: none; overflow: visible; }
	#qm-exam-app .qm-presentation-stage .qm-question-area { min-height: 380px; height: auto; overflow: visible; padding: 16px; }
	#qm-exam-app .qm-presentation-stage .qm-options-list { grid-template-columns: minmax(0, 1fr); }
	#qm-exam-app .qm-presentation-stage .qm-palette-area {
		position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 100001;
		width: auto; min-width: 0; max-width: 100vw; max-height: 75dvh; height: auto;
		overflow-y: auto; overflow-x: hidden; border: 1px solid var(--qm-color-border); border-bottom: 0;
		border-radius: var(--qm-radius-lg) var(--qm-radius-lg) 0 0; box-shadow: var(--qm-shadow-overlay);
		transform: translateY(105%); transition: transform var(--qm-duration-base) var(--qm-easing);
		padding-bottom: calc(var(--qm-space-4) + env(safe-area-inset-bottom, 0px));
	}
	#qm-exam-app.qm-palette-open .qm-presentation-stage .qm-palette-area { transform: translateY(0); }
	#qm-exam-app .qm-presentation-stage .qm-palette-scrim {
		display: block; position: fixed; inset: 0; z-index: 100000; background: rgba(20,22,26,.45);
		opacity: 0; pointer-events: none; transition: opacity var(--qm-duration-base) var(--qm-easing);
	}
	#qm-exam-app.qm-palette-open .qm-presentation-stage .qm-palette-scrim { opacity: 1; pointer-events: auto; }
	#qm-exam-app.qm-is-fullscreen .qm-presentation-stage .qm-exam-body,
	#qm-exam-app:fullscreen .qm-presentation-stage .qm-exam-body,
	#qm-exam-app:-webkit-full-screen .qm-presentation-stage .qm-exam-body { display: block; height: auto; overflow: visible; }
	#qm-exam-app.qm-is-fullscreen .qm-presentation-stage .qm-question-area,
	#qm-exam-app:fullscreen .qm-presentation-stage .qm-question-area,
	#qm-exam-app:-webkit-full-screen .qm-presentation-stage .qm-question-area { min-height: 0; max-height: calc(100dvh - 150px); overflow-y: auto; }
}
@media (min-width: 960px) and (max-height: 650px) {
	#qm-exam-app .qm-presentation-stage .qm-exam-body { height: calc(100dvh - 260px); min-height: 300px; }
}

/* ==========================================================================
   Exam header v1.38.5 — two containers.
   Left: section tabs, question counter and the current section's statistics.
   Right: full screen, instructions, timer, Submit Test (and the palette toggle on small screens).
   The quiz title is no longer repeated here.
   ========================================================================== */
#qm-exam-app .qm-exam-header { display: flex; align-items: stretch; padding: 0; flex: 0 0 auto; min-height: 70px; z-index: 8; }
#qm-exam-app .qm-header-left { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 16px; }
#qm-exam-app .qm-header-right { flex: 0 0 auto; display: flex; align-items: center; padding: 8px 16px; border-left: 1px solid #E5E7EB; background: #F8FAFC; }
#qm-exam-app .qm-header-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
#qm-exam-app .qm-header-row .qm-section-tabs { margin: 0; gap: 4px; flex-wrap: wrap; }
#qm-exam-app .qm-header-row .qm-section-tab { min-height: 26px; padding: 2px 10px; font-size: 12px; border-radius: 6px; }
#qm-exam-app .qm-header-row .qm-header-progress { margin-left: auto; font-size: 12px; font-weight: 600; color: #4B5563; white-space: nowrap; }

#qm-exam-app .qm-header-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; font-size: 11px; line-height: 1.3; color: #6B7280; }
#qm-exam-app .qm-hs-item { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
#qm-exam-app .qm-hs-item b { font-size: 12px; font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; }
#qm-exam-app .qm-hs-item::before { content: ""; width: 7px; height: 7px; border-radius: 2px; align-self: center; background: #9CA3AF; }
#qm-exam-app .qm-hs-answered::before { background: #15803D; }
#qm-exam-app .qm-hs-unanswered::before { background: #B91C1C; }
#qm-exam-app .qm-hs-notvisited::before { background: #9CA3AF; }
#qm-exam-app .qm-hs-marked::before { background: #6D28D9; }
#qm-exam-app .qm-hs-both::before { background: linear-gradient(135deg, #6D28D9 50%, #15803D 50%); }
#qm-exam-app .qm-hs-total { margin-left: auto; padding-left: 10px; border-left: 1px solid #E5E7EB; }
#qm-exam-app .qm-hs-total::before { display: none; }

@media (max-width: 959px) {
	#qm-exam-app .qm-header-right { padding: 8px 12px; }
}
@media (max-width: 599px) {
	#qm-exam-app .qm-exam-header { flex-direction: column; }
	#qm-exam-app .qm-header-left { padding: 8px 12px 6px; }
	#qm-exam-app .qm-header-right { border-left: 0; border-top: 1px solid #E5E7EB; justify-content: flex-end; padding: 6px 12px; }
	#qm-exam-app .qm-hs-total { margin-left: 0; border-left: 0; padding-left: 0; }
}


/* v1.38.8 exam usability repair: use the available viewport and keep palette
   state colors visible even inside presentation-mode specificity overrides. */
#qm-exam-app .qm-presentation-stage .qm-exam-body {
	height: min( 760px, calc( 100dvh - 150px ) );
	max-height: calc( 100dvh - 150px );
	min-height: min( 400px, calc( 100dvh - 220px ) );
}
#qm-exam-app .qm-presentation-stage .qm-palette-area { padding: 14px; }
#qm-exam-app .qm-palette-stats {
	margin: 0 0 14px; padding: 0 0 12px; gap: 7px 10px;
	border-bottom: 1px solid var(--qm-color-border); align-items: center;
}
#qm-exam-app .qm-palette-stats .qm-hs-item { white-space: normal; }
#qm-exam-app .qm-palette-stats .qm-hs-total { margin-left: auto; }
#qm-exam-app .qm-palette-section-wrap { padding: 0 0 8px; margin: 0 0 8px; }
#qm-exam-app .qm-palette-section-wrap.is-current-section {
	border-left: 3px solid var(--qm-color-primary); padding-left: 8px;
	background: color-mix(in srgb, var(--qm-color-primary) 5%, transparent);
}
#qm-exam-app .qm-palette-section-wrap.is-current-section .qm-palette-section-label { color: var(--qm-color-primary); }
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-answered {
	background: var(--qm-color-success) !important; color: #fff !important; border-color: var(--qm-color-success) !important;
}
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-unanswered {
	background: var(--qm-color-error-solid) !important; color: #fff !important; border-color: var(--qm-color-error-solid) !important;
}
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-marked_review {
	background: var(--qm-color-marked) !important; color: #fff !important; border-color: var(--qm-color-marked) !important;
}
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-answered_marked_review {
	background: var(--qm-color-marked) !important; color: #fff !important; border-color: var(--qm-color-marked) !important;
	box-shadow: inset 0 0 0 3px var(--qm-color-success) !important;
}
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-not_visited {
	background: var(--qm-color-surface) !important; color: var(--qm-color-text) !important; border-color: var(--qm-color-border-strong) !important;
}
#qm-exam-app .qm-presentation-stage .qm-palette-btn.qm-p-current {
	outline: 3px solid var(--qm-color-primary) !important; outline-offset: 2px;
}
@media (min-width: 960px) and (max-height: 650px) {
	#qm-exam-app .qm-presentation-stage .qm-exam-body {
		height: calc( 100dvh - 170px ); max-height: calc( 100dvh - 140px ); min-height: 300px;
	}
}
@media (max-width: 959px) {
	#qm-exam-app .qm-presentation-stage .qm-exam-body { height: auto; min-height: 0; max-height: none; }
	#qm-exam-app .qm-presentation-stage .qm-palette-stats { padding-bottom: 10px; }
	#qm-exam-app .qm-presentation-stage .qm-palette-stats .qm-hs-total { margin-left: 0; }
}

#qm-exam-app .qm-palette-legend .qm-legend-dot.qm-p-answered_marked_review {
	background: var(--qm-color-marked); color: #fff; box-shadow: inset 0 0 0 3px var(--qm-color-success);
}

.qm-feedback-correct{margin-top:5px;font-weight:600;color:#065F46}
