/**
 * Exam Mode for LearnDash — exam UI stylesheet.
 *
 * Design tokens are split in two layers:
 *
 *  1. BRAND tokens (--lem-primary, --lem-answered, …) are printed inline by
 *     LEM_Shortcode from each exam's own saved "Exam Appearance" colors, so
 *     they must never be redefined here outside the :root fallback block.
 *  2. SURFACE tokens (backgrounds, borders, ink) are theme-dependent and are
 *     redefined under [data-lem-theme="dark"]. exam.js resolves the "auto"
 *     setting to a literal light/dark value on the root element (and re-runs
 *     on OS theme change), so this file never needs a prefers-color-scheme
 *     branch of its own — one code path, no duplicated rules.
 */

:root {
	/* Brand defaults — overridden per-exam by the inline <style> block. */
	--lem-primary: #4f46e5;
	--lem-primary-dark: #191733;
	--lem-answered: #16a34a;
	--lem-not-answered: #dc2626;
	--lem-not-visited: #94a3b8;
	--lem-marked: #9333ea;
	--lem-answered-marked: #f59e0b;
	--lem-mark-action: #2563eb;
}

/* ---------------------------------------------------------------- tokens */

/**
 * Declared on :root as well as on the two shortcode roots, because dialogs
 * and toasts are appended straight to <body> — outside both roots — and a
 * token that resolves to nothing makes `background: var(--lem-surface)`
 * compute to transparent, which is how a modal ends up with no card behind
 * its text. Keeping the roots in the selector list too means a page can
 * still scope different brand colours per shortcode.
 */
:root,
#lem-exam-root,
#lem-history-root,
.lem-schedule,
.lem-ranks,
.lem-portal {
	/* Neutral / surface scale — light theme. */
	--lem-bg: #eef1f7;
	--lem-bg-grad: radial-gradient(1200px 600px at 15% -10%, #e6ecff 0%, transparent 60%),
	               radial-gradient(900px 500px at 100% 0%, #f2e9ff 0%, transparent 55%);
	--lem-surface: #ffffff;
	--lem-surface-2: #f6f8fc;
	--lem-surface-3: #eceff6;
	--lem-border: #e2e6ef;
	--lem-border-strong: #cbd2e0;
	--lem-ink: #161a26;
	--lem-ink-soft: #5c6478;
	--lem-ink-faint: #8b93a7;
	--lem-overlay: rgba(14, 16, 28, .55);
	--lem-focus: color-mix(in srgb, var(--lem-primary) 45%, transparent);

	--lem-radius-xs: 8px;
	--lem-radius-sm: 10px;
	--lem-radius: 14px;
	--lem-radius-lg: 20px;
	--lem-radius-pill: 999px;

	--lem-shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
	--lem-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 16px -6px rgba(16, 24, 40, .10);
	--lem-shadow-md: 0 2px 4px rgba(16, 24, 40, .05), 0 18px 36px -12px rgba(16, 24, 40, .18);
	--lem-shadow-lg: 0 32px 64px -20px rgba(16, 24, 40, .35);

	--lem-ease: cubic-bezier(.22, .68, .36, 1);
	--lem-dur: .18s;

	/* Scaled by the A-/A+ reader control; every body-copy size below is
	   expressed as a multiple of this so one variable resizes the lot. */
	--lem-font-scale: 1;

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

/* Matched on <html> too (exam.js stamps the attribute there as well as on
   the shortcode root), so a dialog outside the root still goes dark. */
:root[data-lem-theme="dark"],
#lem-exam-root[data-lem-theme="dark"],
#lem-history-root[data-lem-theme="dark"],
.lem-schedule[data-lem-theme="dark"],
.lem-ranks[data-lem-theme="dark"],
.lem-portal[data-lem-theme="dark"] {
	--lem-bg: #0d1017;
	--lem-bg-grad: radial-gradient(1200px 600px at 15% -10%, #17203a 0%, transparent 60%),
	               radial-gradient(900px 500px at 100% 0%, #221a38 0%, transparent 55%);
	--lem-surface: #161b26;
	--lem-surface-2: #1c222f;
	--lem-surface-3: #232a39;
	--lem-border: #2a3243;
	--lem-border-strong: #3b465c;
	--lem-ink: #eef1f7;
	--lem-ink-soft: #a3adc2;
	--lem-ink-faint: #78829a;
	--lem-overlay: rgba(4, 6, 12, .7);

	--lem-shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
	--lem-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px -6px rgba(0, 0, 0, .5);
	--lem-shadow-md: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 36px -12px rgba(0, 0, 0, .6);
	--lem-shadow-lg: 0 32px 64px -20px rgba(0, 0, 0, .75);
}

/* ------------------------------------------------------------- base shell */

#lem-exam-root,
.lem-portal {
	font-family: var(--lem-font);
	color: var(--lem-ink);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* Takes over the whole viewport rather than sitting inside the LearnDash
   lesson page's header/sidebar/footer, closer to how a real proctored exam
   looks. z-index clears WP's admin bar (99999). */
#lem-exam-root {
	position: fixed;
	inset: 0;
	z-index: 100000;
	overflow-y: auto;
	overscroll-behavior: contain;
	background-color: var(--lem-bg);
	background-image: var(--lem-bg-grad);
	padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

body:has(#lem-exam-root) { overflow: hidden; }

#lem-exam-root *,
.lem-portal * { box-sizing: border-box; }

#lem-exam-root :focus-visible,
.lem-portal :focus-visible {
	outline: 3px solid var(--lem-focus);
	outline-offset: 2px;
	border-radius: var(--lem-radius-xs);
}

.lem-shell { max-width: 1320px; margin: 0 auto; }

/**
 * Applied to <html> for one frame while the theme flips. Two reasons, one
 * cosmetic and one a genuine correctness fix:
 *
 *  - cross-fading a few hundred elements at once reads as a glitch, not as
 *    polish;
 *  - more importantly, Chromium does not re-resolve a *transitioned*
 *    background-color / border-color when the custom property behind it
 *    changes. Without this, every .lem-btn-ghost, option card and panel
 *    stays stuck on the previous theme's colours — white-on-white in dark
 *    mode — until some unrelated restyle happens to shake it loose.
 */
.lem-theme-switching *,
.lem-theme-switching *::before,
.lem-theme-switching *::after {
	transition: none !important;
}

/* LearnDash's own "Mark Complete" control, hidden on any lesson/topic page
   carrying this shortcode — submitting the exam calls LearnDash's
   learndash_process_mark_complete() automatically (class-lem-rest.php), so
   the native button would be redundant here. Best-effort across LD's
   classic and Focus Mode templates. */
#learndash_mark_complete_button,
.learndash_mark_complete_placement,
.learndash-complete-step,
.ld-complete-lesson-wrapper,
.ld-complete-topic-wrapper,
.ld-status-bar .ld-complete-button,
.ld-tabs .ld-complete-button { display: none !important; }

/* ------------------------------------------------------------- utilities */

.lem-sr-only {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Anything authored by the question writer (question body, option text,
   solution HTML) goes through this: raster images shrink to fit, SVG
   diagrams keep their authored size and scroll horizontally inside their
   own box instead, so fine labels stay legible on a phone. */
.lem-rich { overflow-wrap: break-word; max-width: 100%; }
.lem-rich img { max-width: 100%; height: auto; }
.lem-rich svg { max-width: none; }
.lem-rich table { max-width: 100%; }
.lem-rich pre, .lem-rich table { overflow-x: auto; display: block; }
.lem-rich p:first-child { margin-top: 0; }
.lem-rich p:last-child { margin-bottom: 0; }

/**
 * Authored content pasted from Word or Google Docs routinely carries its
 * own inline `style="color:#000"` on every <p>/<strong>/<li> it contains -
 * confirmed on this site's own exam descriptions. That is invisible in
 * light mode (black text was the author's real intent, on a white page)
 * and unreadable in dark mode, which is why "some text stays black in dark
 * mode" only ever shows up there.
 *
 * A rule on .lem-rich itself cannot fix this. Inline `style` lives on the
 * DESCENDANT (`<p style="color:#000">`), and a child that sets its own
 * color is never inheriting one from its parent in the first place - no
 * selector targeting .lem-rich, however specific, touches it. Only
 * !important on the descendants themselves wins, which is what earns it a
 * place here.
 *
 * DARK ONLY. Whatever an author's colour choice renders as in light mode is
 * left exactly alone - this exists to fix illegibility, not to strip
 * colour generally.
 */
:root[data-lem-theme="dark"] .lem-rich,
:root[data-lem-theme="dark"] .lem-rich *,
#lem-exam-root[data-lem-theme="dark"] .lem-rich,
#lem-exam-root[data-lem-theme="dark"] .lem-rich *,
#lem-history-root[data-lem-theme="dark"] .lem-rich,
#lem-history-root[data-lem-theme="dark"] .lem-rich *,
.lem-portal[data-lem-theme="dark"] .lem-rich,
.lem-portal[data-lem-theme="dark"] .lem-rich * {
	color: var(--lem-ink) !important;
}

/* --------------------------------------------------------------- buttons */

.lem-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 18px !important;
	border: 1px solid transparent !important;
	border-radius: var(--lem-radius-sm) !important;
	background: var(--lem-surface-2);
	color: var(--lem-ink) !important;
	font-family: inherit;
	font-size: 13.5px !important;
	font-weight: 650 !important;
	line-height: 1.2 !important;
	letter-spacing: .01em;
	cursor: pointer !important;
	opacity: 1 !important;
	text-shadow: none !important;
	text-transform: none !important;
	box-shadow: var(--lem-shadow-xs) !important;
	transition: transform var(--lem-dur) var(--lem-ease),
	            box-shadow var(--lem-dur) var(--lem-ease),
	            background-color var(--lem-dur) var(--lem-ease),
	            border-color var(--lem-dur) var(--lem-ease),
	            filter var(--lem-dur) var(--lem-ease);
}
.lem-btn:hover { transform: translateY(-1px); box-shadow: var(--lem-shadow) !important; }
.lem-btn:active { transform: translateY(0) scale(.99); }
.lem-btn[disabled] { opacity: .5 !important; cursor: not-allowed !important; transform: none !important; }

.lem-btn svg { width: 16px; height: 16px; flex: none; }

.lem-btn-primary { background: var(--lem-primary) !important; color: #fff !important; }
.lem-btn-save { background: var(--lem-answered) !important; color: #fff !important; }
.lem-btn-savemark { background: var(--lem-answered-marked) !important; color: #fff !important; }
.lem-btn-mark { background: var(--lem-mark-action) !important; color: #fff !important; }
.lem-btn-submit { background: var(--lem-answered) !important; color: #fff !important; }
.lem-btn-danger { background: var(--lem-not-answered) !important; color: #fff !important; }
.lem-btn-primary:hover, .lem-btn-save:hover, .lem-btn-savemark:hover,
.lem-btn-mark:hover, .lem-btn-submit:hover, .lem-btn-danger:hover { filter: brightness(1.06); }

.lem-btn-ghost {
	background: var(--lem-surface) !important;
	color: var(--lem-ink) !important;
	border-color: var(--lem-border) !important;
}
.lem-btn-ghost:hover { background: var(--lem-surface-2) !important; border-color: var(--lem-border-strong) !important; }

.lem-btn-quiet {
	background: transparent !important;
	color: var(--lem-ink-soft) !important;
	border-color: transparent !important;
	box-shadow: none !important;
}
.lem-btn-quiet:hover { background: var(--lem-surface-2) !important; color: var(--lem-ink) !important; }

.lem-btn-sm { padding: 8px 13px !important; font-size: 12.5px !important; }

/* Icon-only header tools (theme, text size, shortcuts, fullscreen). */
.lem-tool {
	width: 38px; height: 38px;
	display: inline-flex; align-items: center; justify-content: center;
	padding: 0 !important;
	border: 1px solid var(--lem-border) !important;
	border-radius: var(--lem-radius-sm) !important;
	background: var(--lem-surface) !important;
	color: var(--lem-ink-soft) !important;
	cursor: pointer !important;
	opacity: 1 !important;
	box-shadow: none !important;
	transition: background-color var(--lem-dur) var(--lem-ease),
	            color var(--lem-dur) var(--lem-ease),
	            border-color var(--lem-dur) var(--lem-ease);
}
.lem-tool:hover { background: var(--lem-surface-2) !important; color: var(--lem-ink) !important; border-color: var(--lem-border-strong) !important; }
.lem-tool.is-on { background: color-mix(in srgb, var(--lem-primary) 14%, var(--lem-surface)) !important; color: var(--lem-primary) !important; border-color: color-mix(in srgb, var(--lem-primary) 40%, var(--lem-border)) !important; }
.lem-tool svg { width: 18px; height: 18px; }

.lem-tool-group { display: inline-flex; gap: 6px; align-items: center; flex: none; }

/* --------------------------------------------------------------- top bar */

.lem-topbar {
	display: flex;
	align-items: center;
	gap: 14px;
	background: color-mix(in srgb, var(--lem-surface) 88%, transparent);
	-webkit-backdrop-filter: saturate(180%) blur(14px);
	backdrop-filter: saturate(180%) blur(14px);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	padding: 12px 18px;
	position: sticky;
	top: 0;
	z-index: 30;
	box-shadow: var(--lem-shadow);
}

.lem-topbar-id { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
/* With the language menu and calculator in the tool group, a narrow theme
   column ran out of room and crushed the candidate's name to a few letters.
   The tools now drop to their own row instead. */
.lem-topbar { flex-wrap: wrap; }
.lem-topbar-id { flex-basis: 180px; }

.lem-avatar {
	width: 42px; height: 42px; flex: none;
	display: grid; place-items: center;
	border-radius: 50%;
	background: linear-gradient(140deg,
		color-mix(in srgb, var(--lem-primary) 85%, #fff),
		color-mix(in srgb, var(--lem-primary) 55%, #000));
	color: #fff;
	font-weight: 800;
	font-size: 15px;
	letter-spacing: .02em;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.lem-id-text { min-width: 0; }
.lem-id-name {
	font-size: 14.5px; font-weight: 700; line-height: 1.25;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lem-id-meta {
	font-size: 12.5px; color: var(--lem-ink-soft); line-height: 1.3; margin-top: 2px;
	display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.lem-id-meta .lem-sep { opacity: .5; }
.lem-section-chip {
	display: inline-flex; align-items: center; gap: 5px;
	background: color-mix(in srgb, var(--lem-primary) 12%, var(--lem-surface));
	color: var(--lem-primary);
	border-radius: var(--lem-radius-pill);
	padding: 2px 9px;
	font-weight: 700; font-size: 11.5px;
	max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Timer: an SVG ring that drains over the full duration, with the digits
   beside it. --lem-timer-dash is written by exam.js each tick. */
.lem-timer-wrap {
	display: flex; align-items: center; gap: 10px;
	flex: none;
	padding: 4px 14px 4px 4px;
	border-radius: var(--lem-radius-pill);
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border);
	transition: background-color .3s var(--lem-ease), border-color .3s var(--lem-ease);
}
.lem-timer-ring { position: relative; width: 40px; height: 40px; flex: none; }
.lem-timer-ring svg { width: 40px; height: 40px; transform: rotate(-90deg); display: block; }
.lem-timer-ring circle { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.lem-timer-track { stroke: var(--lem-border-strong); opacity: .5; }
.lem-timer-progress {
	stroke: var(--lem-primary);
	stroke-dasharray: 113.1;
	stroke-dashoffset: var(--lem-timer-dash, 0);
	transition: stroke-dashoffset 1s linear, stroke .3s var(--lem-ease);
}
.lem-timer-ring-icon {
	position: absolute; inset: 0; display: grid; place-items: center;
	color: var(--lem-primary); pointer-events: none;
}
.lem-timer-ring-icon svg { width: 15px; height: 15px; transform: none; }

.lem-timer-text { line-height: 1.1; }
.lem-timer-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--lem-ink-faint); }
.lem-timer {
	font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums;
	color: var(--lem-ink); letter-spacing: .02em; display: block;
}

.lem-timer-wrap.is-caution { background: color-mix(in srgb, var(--lem-answered-marked) 14%, var(--lem-surface)); border-color: color-mix(in srgb, var(--lem-answered-marked) 40%, var(--lem-border)); }
.lem-timer-wrap.is-caution .lem-timer-progress { stroke: var(--lem-answered-marked); }
.lem-timer-wrap.is-caution .lem-timer-ring-icon { color: var(--lem-answered-marked); }
.lem-timer-wrap.is-caution .lem-timer { color: color-mix(in srgb, var(--lem-answered-marked) 70%, var(--lem-ink)); }

.lem-timer-wrap.is-danger { background: color-mix(in srgb, var(--lem-not-answered) 15%, var(--lem-surface)); border-color: color-mix(in srgb, var(--lem-not-answered) 45%, var(--lem-border)); animation: lem-breathe 1.6s ease-in-out infinite; }
.lem-timer-wrap.is-danger .lem-timer-progress { stroke: var(--lem-not-answered); }
.lem-timer-wrap.is-danger .lem-timer-ring-icon { color: var(--lem-not-answered); }
.lem-timer-wrap.is-danger .lem-timer { color: var(--lem-not-answered); }

@keyframes lem-breathe {
	0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lem-not-answered) 45%, transparent); }
	50% { box-shadow: 0 0 0 7px transparent; }
}

/* ------------------------------------------------------- progress strip */

.lem-progress {
	display: flex; align-items: center; gap: 14px;
	margin: 10px 4px 14px;
	font-size: 12.5px; color: var(--lem-ink-soft); font-weight: 600;
}
.lem-progress-track {
	flex: 1; height: 7px; border-radius: var(--lem-radius-pill);
	background: var(--lem-surface-3); overflow: hidden; display: flex;
	box-shadow: inset 0 0 0 1px var(--lem-border);
}
.lem-progress-fill { height: 100%; transition: width .35s var(--lem-ease); }
.lem-progress-answered { background: var(--lem-answered); }
.lem-progress-marked { background: var(--lem-answered-marked); }
.lem-progress-count { flex: none; font-variant-numeric: tabular-nums; }
.lem-progress-count b { color: var(--lem-ink); }

/* -------------------------------------------------------------- fs banner */

.lem-fs-banner {
	display: flex; align-items: center; justify-content: space-between;
	gap: 12px; flex-wrap: wrap;
	background: color-mix(in srgb, var(--lem-not-answered) 12%, var(--lem-surface));
	border: 1px solid color-mix(in srgb, var(--lem-not-answered) 35%, var(--lem-border));
	border-radius: var(--lem-radius);
	padding: 12px 16px;
	margin-bottom: 12px;
	font-size: 13.5px; font-weight: 600;
	animation: lem-slide-down .25s var(--lem-ease);
}
@keyframes lem-slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.lem-violation-note {
	font-size: 13px; font-weight: 600; color: var(--lem-not-answered); margin: 0 0 16px;
}

/* ----------------------------------------------------------------- body */

.lem-body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 330px;
	gap: 18px;
	align-items: start;
}

.lem-card {
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	box-shadow: var(--lem-shadow);
}

/* ------------------------------------------------------- question panel */

.lem-question-panel { padding: 22px 26px 20px; min-height: 380px; min-width: 0; }

.lem-q-head {
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	padding-bottom: 14px; margin-bottom: 18px;
	border-bottom: 1px solid var(--lem-border);
}
.lem-q-num { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.lem-q-num span { color: var(--lem-ink-faint); font-weight: 600; }
.lem-q-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.lem-tag {
	display: inline-flex; align-items: center; gap: 4px;
	font-size: 11px; font-weight: 700; letter-spacing: .02em;
	padding: 4px 9px; border-radius: var(--lem-radius-pill);
	background: var(--lem-surface-2); color: var(--lem-ink-soft);
	border: 1px solid var(--lem-border);
	white-space: nowrap;
}
.lem-tag svg { width: 13px; height: 13px; }
.lem-tag-positive { color: var(--lem-answered); border-color: color-mix(in srgb, var(--lem-answered) 35%, var(--lem-border)); background: color-mix(in srgb, var(--lem-answered) 10%, var(--lem-surface)); }
.lem-tag-negative { color: var(--lem-not-answered); border-color: color-mix(in srgb, var(--lem-not-answered) 35%, var(--lem-border)); background: color-mix(in srgb, var(--lem-not-answered) 10%, var(--lem-surface)); }
.lem-tag-marked { color: var(--lem-marked); border-color: color-mix(in srgb, var(--lem-marked) 35%, var(--lem-border)); background: color-mix(in srgb, var(--lem-marked) 10%, var(--lem-surface)); }
.lem-tag-time { font-variant-numeric: tabular-nums; }

.lem-q-title {
	font-size: calc(17.5px * var(--lem-font-scale));
	font-weight: 600;
	line-height: 1.6;
	margin-bottom: 20px;
}

/* Whole option row is the hit target — the numbered badge, the control and
   the option text all belong to one <label>, so a tap anywhere selects it.
   (2.5.x listed option text separately from a numbered radio strip; merging
   them removes the "which number was that again?" hop that cost students
   time on phones.) */
.lem-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.lem-option {
	display: flex; align-items: flex-start; gap: 12px;
	padding: 13px 15px;
	border: 1.5px solid var(--lem-border);
	border-radius: var(--lem-radius);
	background: var(--lem-surface);
	cursor: pointer;
	transition: border-color var(--lem-dur) var(--lem-ease),
	            background-color var(--lem-dur) var(--lem-ease),
	            transform var(--lem-dur) var(--lem-ease),
	            box-shadow var(--lem-dur) var(--lem-ease);
}
.lem-option:hover { border-color: color-mix(in srgb, var(--lem-primary) 45%, var(--lem-border)); background: var(--lem-surface-2); }
.lem-option:active { transform: scale(.995); }
.lem-option.is-selected {
	border-color: var(--lem-primary);
	background: color-mix(in srgb, var(--lem-primary) 8%, var(--lem-surface));
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--lem-primary) 14%, transparent);
}

.lem-option-key {
	flex: none;
	width: 28px; height: 28px;
	display: grid; place-items: center;
	border-radius: 9px;
	background: var(--lem-surface-3);
	color: var(--lem-ink-soft);
	font-size: 12.5px; font-weight: 800;
	transition: background-color var(--lem-dur) var(--lem-ease), color var(--lem-dur) var(--lem-ease);
}
.lem-option.is-selected .lem-option-key { background: var(--lem-primary); color: #fff; }

.lem-option-text { flex: 1; min-width: 0; font-size: calc(14.5px * var(--lem-font-scale)); line-height: 1.65; padding-top: 3px; }

.lem-option input[type="radio"],
.lem-option input[type="checkbox"] {
	width: 19px; height: 19px; flex: none; margin: 5px 0 0;
	accent-color: var(--lem-primary);
	cursor: pointer;
}

.lem-multi-hint {
	font-size: 12.5px; color: var(--lem-ink-soft); font-weight: 600;
	margin: -8px 0 14px; display: flex; align-items: center; gap: 6px;
}
.lem-multi-hint svg { width: 14px; height: 14px; flex: none; }

.lem-free-answer { margin-bottom: 20px; }
.lem-free-input {
	width: 100%; box-sizing: border-box;
	padding: 13px 15px;
	border: 1.5px solid var(--lem-border);
	border-radius: var(--lem-radius);
	background: var(--lem-surface);
	color: inherit;
	font-size: calc(14.5px * var(--lem-font-scale));
	line-height: 1.65;
	transition: border-color var(--lem-dur) var(--lem-ease),
	            background-color var(--lem-dur) var(--lem-ease),
	            box-shadow var(--lem-dur) var(--lem-ease);
}
.lem-free-input:focus {
	outline: none;
	border-color: var(--lem-primary);
	background: color-mix(in srgb, var(--lem-primary) 8%, var(--lem-surface));
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--lem-primary) 14%, transparent);
}

/* ------------------------------------------------------------- actions */

.lem-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lem-actions-primary { padding-top: 18px; border-top: 1px solid var(--lem-border); }
.lem-actions-nav { margin-top: 12px; align-items: center; }
.lem-actions-nav .lem-spacer { flex: 1; }

/* Uppercase, tightly tracked labels on the answer-action row — the wording,
   order and colour of these four are what a candidate already knows from a
   real exam portal, so they are matched rather than reinterpreted. */
.lem-actions-primary .lem-btn,
.lem-actions-nav .lem-btn {
	/* !important because the .lem-btn base sets text-transform:none the same
	   way, to survive themes that shout at every button on the page. */
	text-transform: uppercase !important;
	letter-spacing: .03em;
	font-size: 12.5px !important;
	font-weight: 750 !important;
}

/* --------------------------------------------------------- navigator panel */

.lem-nav-panel { padding: 18px; position: sticky; top: 84px; }
.lem-nav-handle { display: none; }

.lem-nav-title {
	font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
	color: var(--lem-ink-faint); margin: 0 0 12px;
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.lem-sections { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.lem-section-btn {
	display: flex; justify-content: space-between; align-items: center; gap: 8px;
	width: 100%; text-align: left;
	padding: 10px 12px !important;
	border: 1px solid var(--lem-border) !important;
	background: var(--lem-surface) !important;
	border-radius: var(--lem-radius-sm) !important;
	cursor: pointer; opacity: 1 !important; box-shadow: none !important;
	font-family: inherit; font-weight: 650; font-size: 13px;
	color: var(--lem-ink-soft) !important;
	transition: all var(--lem-dur) var(--lem-ease);
}
.lem-section-btn:hover { border-color: var(--lem-primary) !important; color: var(--lem-primary) !important; }
.lem-section-btn.active {
	background: color-mix(in srgb, var(--lem-primary) 12%, var(--lem-surface)) !important;
	border-color: var(--lem-primary) !important;
	color: var(--lem-primary) !important;
}
.lem-section-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lem-section-count { flex: none; font-variant-numeric: tabular-nums; opacity: .9; font-size: 12px; }

/* One timer per topic: a closed section and one still to come are shown
   but cannot be entered. */
.lem-section-btn.is-locked,
.lem-section-btn.is-locked:hover {
	cursor: not-allowed;
	border-color: var(--lem-border) !important;
	color: var(--lem-ink-soft) !important;
	background: var(--lem-surface) !important;
	opacity: .65 !important;
}
.lem-section-btn.is-locked .lem-section-name { display: inline-flex; align-items: center; gap: 6px; }
.lem-section-btn.is-locked .lem-section-name svg { width: 13px; height: 13px; flex: none; }

/* Legend doubles as a filter: clicking a status dims every palette button
   that isn't in that state, which is how a student finds "the three I
   marked" in a 100-question paper without scanning the grid twice. */
.lem-legend {
	display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
	margin-bottom: 14px;
}
.lem-legend-item {
	display: flex; align-items: center; gap: 7px;
	padding: 7px 8px !important;
	border: 1px solid transparent !important;
	background: var(--lem-surface-2) !important;
	border-radius: var(--lem-radius-xs) !important;
	font-family: inherit; font-size: 11.5px; font-weight: 650;
	color: var(--lem-ink-soft) !important;
	cursor: pointer; opacity: 1 !important; box-shadow: none !important;
	text-align: left; min-width: 0;
	transition: all var(--lem-dur) var(--lem-ease);
}
.lem-legend-item:hover { border-color: var(--lem-border-strong) !important; }
.lem-legend-item.is-active { border-color: var(--lem-primary) !important; background: color-mix(in srgb, var(--lem-primary) 10%, var(--lem-surface)) !important; color: var(--lem-ink) !important; }
.lem-legend-item.is-empty { opacity: .45 !important; }
.lem-legend-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lem-legend-item .lem-count {
	flex: none; display: inline-grid; place-items: center;
	min-width: 22px; height: 20px; padding: 0 5px; border-radius: 6px;
	color: #fff; font-weight: 800; font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.lem-legend-full { grid-column: 1 / -1; }

.lem-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.lem-bg-answered, .lem-dot-answered { background: var(--lem-answered); }
.lem-bg-not_visited, .lem-dot-not_visited { background: var(--lem-not-visited); }
.lem-bg-not_answered, .lem-dot-not_answered { background: var(--lem-not-answered); }
.lem-bg-marked, .lem-dot-marked { background: var(--lem-marked); }
.lem-bg-answered_marked, .lem-dot-answered_marked { background: var(--lem-answered-marked); }
.lem-dot-not_evaluated { background: var(--lem-marked); }

.lem-nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.lem-nav-btn {
	position: relative;
	aspect-ratio: 1;
	border: none !important;
	border-radius: var(--lem-radius-xs) !important;
	color: #fff !important;
	font-family: inherit;
	font-weight: 750 !important;
	font-size: 13px !important;
	cursor: pointer !important;
	opacity: 1 !important;
	box-shadow: none !important;
	overflow: hidden;
	transition: transform .12s var(--lem-ease), opacity var(--lem-dur) var(--lem-ease), box-shadow var(--lem-dur) var(--lem-ease);
}
.lem-nav-btn:hover { transform: translateY(-2px) scale(1.06); box-shadow: var(--lem-shadow); }
.lem-nav-btn.lem-state-not_visited { background: var(--lem-not-visited) !important; }
.lem-nav-btn.lem-state-answered { background: var(--lem-answered) !important; }
.lem-nav-btn.lem-state-not_answered { background: var(--lem-not-answered) !important; }
.lem-nav-btn.lem-state-marked { background: var(--lem-marked) !important; }
.lem-nav-btn.lem-state-answered_marked { background: var(--lem-answered-marked) !important; }
.lem-nav-btn.current {
	box-shadow: 0 0 0 2px var(--lem-surface), 0 0 0 4px var(--lem-primary);
	transform: scale(1.04);
}
.lem-nav-btn.is-dimmed { opacity: .22 !important; }

/* Corner flag on both "marked" states so review status reads without
   relying on color alone (colorblind students). */
.lem-nav-btn.lem-state-marked::after,
.lem-nav-btn.lem-state-answered_marked::after {
	content: "";
	position: absolute; top: 0; right: 0;
	border-style: solid; border-width: 0 11px 11px 0;
	border-color: transparent rgba(255, 255, 255, .92) transparent transparent;
}

.lem-nav-foot { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--lem-border); }
.lem-nav-foot .lem-btn { width: 100%; }
.lem-nav-savestate { display: flex; justify-content: center; }

/* ------------------------------------------------------------ mobile bar */

.lem-mobile-bar { display: none; }
.lem-drawer-backdrop { display: none; }

/* ------------------------------------------------------------ save pill */

.lem-savestate {
	display: inline-flex; align-items: center; gap: 6px;
	font-size: 11.5px; font-weight: 700;
	color: var(--lem-ink-faint);
	transition: color var(--lem-dur) var(--lem-ease);
}
.lem-savestate svg { width: 13px; height: 13px; }
.lem-savestate.is-saving { color: var(--lem-ink-soft); }
.lem-savestate.is-saved { color: var(--lem-answered); }
.lem-savestate.is-error { color: var(--lem-not-answered); }
.lem-savestate.is-saving svg { animation: lem-spin 1s linear infinite; }
@keyframes lem-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- toasts */

.lem-toasts {
	position: fixed;
	left: 50%; transform: translateX(-50%);
	bottom: calc(24px + env(safe-area-inset-bottom));
	z-index: 100060;
	display: flex; flex-direction: column; gap: 8px; align-items: center;
	pointer-events: none;
	width: min(420px, calc(100vw - 32px));
}
.lem-toast {
	display: flex; align-items: center; gap: 10px;
	background: var(--lem-ink, #161a26);
	color: var(--lem-surface, #fff);
	border-radius: var(--lem-radius-pill);
	padding: 11px 18px;
	font-family: var(--lem-font);
	font-size: 13.5px; font-weight: 650;
	box-shadow: var(--lem-shadow-md);
	animation: lem-toast-in .25s var(--lem-ease);
	max-width: 100%;
}
.lem-toast.is-out { animation: lem-toast-out .2s var(--lem-ease) forwards; }
.lem-toast svg { width: 16px; height: 16px; flex: none; }
.lem-toast-success svg { color: #4ade80; }
.lem-toast-warn svg { color: #fbbf24; }
.lem-toast-error svg { color: #f87171; }
@keyframes lem-toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes lem-toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------------------------------------------------------- rules screen */

.lem-rules-screen {
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	box-shadow: var(--lem-shadow-md);
	max-width: 820px; margin: 24px auto;
	overflow: hidden;
	animation: lem-fade-up .3s var(--lem-ease);
}
@keyframes lem-fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.lem-rules-hero {
	padding: 30px 32px 26px;
	background:
		radial-gradient(600px 200px at 10% 0%, color-mix(in srgb, var(--lem-primary) 22%, transparent), transparent 70%),
		linear-gradient(135deg, color-mix(in srgb, var(--lem-primary) 92%, #000), color-mix(in srgb, var(--lem-primary) 55%, #4c1d95));
	color: #fff;
}
.lem-rules-eyebrow { font-size: 11.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .82; }
.lem-rules-hero h2 { margin: 8px 0 18px; font-size: 26px; line-height: 1.25; color: #fff; font-weight: 800; letter-spacing: -.02em; }

.lem-rules-facts { display: flex; gap: 10px; flex-wrap: wrap; }
.lem-fact {
	display: flex; align-items: center; gap: 9px;
	background: rgba(255, 255, 255, .14);
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: var(--lem-radius);
	padding: 9px 14px;
	-webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.lem-fact svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.lem-fact-label { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .78; }
.lem-fact-value { font-size: 14.5px; font-weight: 800; line-height: 1.2; }

.lem-rules-body { padding: 26px 32px 30px; }
.lem-rules-description { font-size: calc(14.5px * var(--lem-font-scale)); line-height: 1.7; margin-bottom: 24px; color: var(--lem-ink); }
.lem-rules-description ul, .lem-rules-description ol { padding-left: 22px; margin: 12px 0; }
.lem-rules-description li { margin-bottom: 6px; }

.lem-rules-checklist { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.lem-rules-sections { list-style: none; counter-reset: lem-sec; margin: 0 0 22px; padding: 0; border: 1px solid var(--lem-border); border-radius: var(--lem-radius-sm); }
.lem-rules-sections li { counter-increment: lem-sec; display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 14px; color: var(--lem-ink); }
.lem-rules-sections li + li { border-top: 1px solid var(--lem-border); }
.lem-rules-sections li > span:first-child::before { content: counter(lem-sec) ". "; color: var(--lem-ink-soft); }
.lem-rules-sections li > span:last-child { color: var(--lem-ink-soft); white-space: nowrap; }
.lem-check {
	display: flex; gap: 11px; align-items: flex-start;
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius);
	padding: 12px 14px;
	font-size: 13.5px; line-height: 1.55; color: var(--lem-ink-soft);
}
.lem-check svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--lem-primary); }
.lem-check b { color: var(--lem-ink); font-weight: 700; }

.lem-rules-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lem-rules-actions .lem-btn-start { padding: 14px 34px !important; font-size: 15px !important; flex: 1; min-width: 200px; }
.lem-rules-note { font-size: 12.5px; color: var(--lem-ink-faint); margin: 14px 0 0; }

.lem-resume-flag {
	display: flex; gap: 10px; align-items: center;
	background: color-mix(in srgb, var(--lem-answered-marked) 14%, var(--lem-surface));
	border: 1px solid color-mix(in srgb, var(--lem-answered-marked) 38%, var(--lem-border));
	color: color-mix(in srgb, var(--lem-answered-marked) 70%, var(--lem-ink));
	border-radius: var(--lem-radius); padding: 12px 14px; margin-bottom: 18px;
	font-size: 13.5px; font-weight: 650;
}
.lem-resume-flag svg { width: 18px; height: 18px; flex: none; }

/* --------------------------------------------------------------- skeleton */

.lem-loading { text-align: center; color: var(--lem-ink-soft); padding: 40px 0; font-weight: 600; }
.lem-skeleton { max-width: 1320px; margin: 0 auto; }
.lem-skel {
	background: linear-gradient(100deg, var(--lem-surface-2) 30%, var(--lem-surface-3) 50%, var(--lem-surface-2) 70%);
	background-size: 220% 100%;
	animation: lem-shimmer 1.4s linear infinite;
	border-radius: var(--lem-radius-sm);
}
@keyframes lem-shimmer { to { background-position: -220% 0; } }
.lem-skel-topbar { height: 66px; border-radius: var(--lem-radius-lg); margin-bottom: 18px; }
.lem-skel-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
.lem-skel-panel { height: 420px; border-radius: var(--lem-radius-lg); }
.lem-skel-side { height: 420px; border-radius: var(--lem-radius-lg); }

/* ---------------------------------------------------------------- modals */

.lem-modal-backdrop {
	position: fixed; inset: 0;
	background: var(--lem-overlay, rgba(14, 16, 28, .55));
	-webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
	display: flex; align-items: center; justify-content: center;
	z-index: 100050;
	padding: 16px;
	animation: lem-fade .2s var(--lem-ease);
}
@keyframes lem-fade { from { opacity: 0; } to { opacity: 1; } }

.lem-modal {
	font-family: var(--lem-font);
	color: var(--lem-ink);
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	padding: 26px;
	max-width: 500px; width: 100%;
	max-height: calc(100vh - 40px); overflow-y: auto;
	box-shadow: var(--lem-shadow-lg);
	animation: lem-modal-in .24s var(--lem-ease);
}
.lem-modal-wide { max-width: 640px; }
@keyframes lem-modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

.lem-modal h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; color: var(--lem-ink); }
.lem-modal p { font-size: 13.5px; line-height: 1.6; color: var(--lem-ink-soft); margin: 0 0 12px; }
.lem-modal-icon {
	width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
	margin-bottom: 14px;
}
.lem-modal-icon svg { width: 24px; height: 24px; }
.lem-modal-icon-warn { background: color-mix(in srgb, var(--lem-not-answered) 14%, var(--lem-surface)); color: var(--lem-not-answered); }
.lem-modal-icon-info { background: color-mix(in srgb, var(--lem-primary) 14%, var(--lem-surface)); color: var(--lem-primary); }

.lem-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin: 16px 0 18px; }
.lem-summary-cell {
	background: var(--lem-surface-2); border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius); padding: 12px 10px; text-align: center;
}
.lem-summary-cell b { display: block; font-size: 21px; font-weight: 800; line-height: 1.1; }
.lem-summary-cell span { font-size: 11px; font-weight: 650; color: var(--lem-ink-soft); display: block; margin-top: 4px; line-height: 1.3; }
.lem-summary-cell-answered b { color: var(--lem-answered); }
.lem-summary-cell-not_answered b { color: var(--lem-not-answered); }
.lem-summary-cell-not_visited b { color: var(--lem-not-visited); }
.lem-summary-cell-marked b { color: var(--lem-marked); }
.lem-summary-cell-answered_marked b { color: var(--lem-answered-marked); }

.lem-summary-note {
	display: flex; gap: 9px; align-items: flex-start;
	font-size: 13px; font-weight: 650; line-height: 1.5;
	border-radius: var(--lem-radius); padding: 12px 14px; margin: 0 0 14px;
}
.lem-summary-note svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.lem-note-warn { background: color-mix(in srgb, var(--lem-not-answered) 10%, var(--lem-surface)); color: var(--lem-not-answered); }
.lem-note-ok { background: color-mix(in srgb, var(--lem-answered) 10%, var(--lem-surface)); color: var(--lem-answered); }

.lem-req-table { width: 100%; margin: 0 0 16px; border-collapse: collapse; }
.lem-req-table td { padding: 8px 0; border-bottom: 1px solid var(--lem-border); font-size: 13px; color: var(--lem-ink-soft); }
.lem-req-table td:last-child { text-align: right; font-weight: 700; color: var(--lem-ink); }

.lem-modal .lem-actions { margin-top: 4px; }
.lem-modal .lem-actions .lem-btn { flex: 1; }

/* ------------------------------------------------------------- shortcuts */

.lem-kbd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; margin: 16px 0 20px; }
.lem-kbd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--lem-border); font-size: 13px; color: var(--lem-ink-soft); }
.lem-kbd-keys { display: flex; gap: 4px; flex: none; }
kbd.lem-kbd {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 11px; font-weight: 700;
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border-strong);
	border-bottom-width: 2px;
	border-radius: 6px;
	padding: 3px 7px;
	color: var(--lem-ink);
	white-space: nowrap;
}

/* ---------------------------------------------------------- result screen */

.lem-result-screen {
	max-width: 900px; margin: 0 auto;
	font-family: var(--lem-font);
	color: var(--lem-ink);
	animation: lem-fade-up .35s var(--lem-ease);
}

.lem-result-hero {
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	box-shadow: var(--lem-shadow-md);
	padding: 34px 30px 30px;
	text-align: center;
	position: relative;
	overflow: hidden;
}
.lem-result-hero::before {
	content: ""; position: absolute; inset: 0 0 auto; height: 5px;
	background: linear-gradient(90deg, var(--lem-primary), color-mix(in srgb, var(--lem-primary) 40%, var(--lem-answered)));
}
.lem-result-hero.is-fail::before { background: linear-gradient(90deg, var(--lem-not-answered), var(--lem-answered-marked)); }

.lem-result-screen h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--lem-ink); }
.lem-result-sub { font-size: 13.5px; color: var(--lem-ink-soft); margin: 0 0 20px; }

.lem-pass-badge {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 6px 16px; border-radius: var(--lem-radius-pill);
	font-size: 13px; font-weight: 750; margin-bottom: 20px;
}
.lem-pass-badge svg { width: 15px; height: 15px; }
.lem-pass-badge-pass { background: color-mix(in srgb, var(--lem-answered) 14%, var(--lem-surface)); color: var(--lem-answered); }
.lem-pass-badge-fail { background: color-mix(in srgb, var(--lem-not-answered) 12%, var(--lem-surface)); color: var(--lem-not-answered); }

/* SVG ring rather than a conic-gradient: it animates smoothly on load and
   stays crisp at any zoom level. */
.lem-score-ring { position: relative; width: 190px; height: 190px; margin: 0 auto 22px; }
.lem-score-ring svg { width: 190px; height: 190px; transform: rotate(-90deg); display: block; }
.lem-score-ring circle { fill: none; stroke-width: 13; stroke-linecap: round; }
.lem-score-track { stroke: var(--lem-surface-3); }
.lem-score-value {
	stroke: var(--lem-answered);
	stroke-dasharray: 502.4;
	stroke-dashoffset: 502.4;
	animation: lem-ring-fill 1.1s var(--lem-ease) forwards;
}
.lem-score-ring.is-fail .lem-score-value { stroke: var(--lem-not-answered); }
@keyframes lem-ring-fill { to { stroke-dashoffset: var(--lem-ring-offset, 502.4); } }

.lem-score-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.lem-score-percent { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.lem-score-percent.lem-result-pass { color: var(--lem-answered); }
.lem-score-percent.lem-result-fail { color: var(--lem-not-answered); }
.lem-score-raw { font-size: 14px; font-weight: 650; color: var(--lem-ink-soft); margin-top: 6px; font-variant-numeric: tabular-nums; }
.lem-score-cut { font-size: 11.5px; color: var(--lem-ink-faint); font-weight: 650; margin-top: 3px; }

.lem-result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.lem-stat-chip {
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius);
	padding: 13px 12px;
	font-size: 12px; font-weight: 650; color: var(--lem-ink-soft);
	text-align: center;
}
.lem-stat-chip b { display: block; font-size: 22px; font-weight: 800; color: var(--lem-ink); line-height: 1.15; margin-bottom: 4px; }
.lem-stat-correct b { color: var(--lem-answered); }
.lem-stat-wrong b { color: var(--lem-not-answered); }
.lem-stat-skipped b { color: var(--lem-not-visited); }
.lem-stat-neval b { color: var(--lem-marked); }

.lem-result-toolbar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }

/* ------------------------------------------------------------ result tabs */

.lem-result-tabs {
	display: flex; gap: 4px; justify-content: center;
	margin: 24px auto 18px;
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-pill);
	padding: 4px;
	width: fit-content;
	max-width: 100%;
	flex-wrap: wrap;
}
.lem-result-tab {
	background: transparent !important; border: none !important; box-shadow: none !important;
	padding: 9px 18px !important; border-radius: var(--lem-radius-pill) !important;
	font-family: inherit; font-size: 13.5px !important; font-weight: 700 !important;
	color: var(--lem-ink-soft) !important; cursor: pointer !important; opacity: 1 !important;
	transition: all var(--lem-dur) var(--lem-ease);
}
.lem-result-tab:hover { color: var(--lem-ink) !important; }
.lem-result-tab.active { background: var(--lem-surface) !important; color: var(--lem-primary) !important; box-shadow: var(--lem-shadow-xs) !important; }
.lem-result-tab-panel { text-align: left; }

/* --------------------------------------------------------------- analysis */

.lem-analysis { margin-top: 4px; }
.lem-analysis-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 14px; }
.lem-analysis-card {
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	padding: 20px;
	box-shadow: var(--lem-shadow-xs);
}
.lem-analysis-card-full { grid-column: 1 / -1; }
.lem-analysis-card-title {
	font-size: 11.5px; font-weight: 800; color: var(--lem-ink-faint);
	text-transform: uppercase; letter-spacing: .07em; margin-bottom: 16px;
}

.lem-donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
.lem-donut { width: 130px; height: 130px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.lem-donut-inner {
	width: 94px; height: 94px; border-radius: 50%; background: var(--lem-surface);
	display: grid; place-content: center; text-align: center;
	box-shadow: inset 0 0 0 1px var(--lem-border);
}
.lem-donut-total { font-size: 22px; font-weight: 800; color: var(--lem-ink); line-height: 1.1; }
.lem-donut-total-label { font-size: 10.5px; color: var(--lem-ink-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.lem-donut-legend { display: flex; flex-direction: column; gap: 9px; font-size: 13px; min-width: 190px; }
.lem-donut-legend span { display: flex; align-items: center; gap: 9px; color: var(--lem-ink-soft); font-weight: 600; }
.lem-donut-legend b { color: var(--lem-ink); font-weight: 800; margin-left: auto; font-variant-numeric: tabular-nums; }

.lem-topic-bars { display: flex; flex-direction: column; gap: 15px; }
.lem-topic-bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 650; margin-bottom: 7px; color: var(--lem-ink-soft); }
.lem-topic-bar-label b { color: var(--lem-ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.lem-topic-bar-label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A subtopic under its topic in "Topic-wise accuracy". */
.lem-topic-bar-sub { padding-left: 16px; }
.lem-topic-bar-sub .lem-topic-bar-label { font-weight: 550; font-size: 12px; }
.lem-topic-bar-sub .lem-topic-bar-track { height: 6px; }
.lem-topic-bar-track { display: flex; height: 10px; border-radius: var(--lem-radius-pill); overflow: hidden; background: var(--lem-surface-3); }
.lem-topic-bar-segment { height: 100%; transition: width .6s var(--lem-ease); }
.lem-topic-bar-correct { background: var(--lem-answered); }
.lem-topic-bar-wrong { background: var(--lem-not-answered); }
.lem-topic-bar-not-evaluated { background: var(--lem-marked); }
.lem-topic-bar-skipped { background: var(--lem-not-visited); }

.lem-compare-row { margin-bottom: 14px; }
.lem-compare-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; margin-bottom: 7px; color: var(--lem-ink-soft); }
.lem-compare-label b { color: var(--lem-ink); font-weight: 800; }
.lem-compare-track { height: 10px; border-radius: var(--lem-radius-pill); background: var(--lem-surface-3); overflow: hidden; }
.lem-compare-fill { height: 100%; border-radius: var(--lem-radius-pill); transition: width .6s var(--lem-ease); }
.lem-compare-you { background: var(--lem-primary); }
.lem-compare-avg { background: var(--lem-not-visited); }
.lem-compare-best { background: var(--lem-answered-marked); }
.lem-compare-note { font-size: 12.5px; color: var(--lem-ink-soft); margin: 12px 0 0; text-align: center; line-height: 1.5; }
.lem-compare-note b { color: var(--lem-ink); }

.lem-line-chart-wrap { overflow-x: auto; }
.lem-line-chart { width: 100%; min-width: 320px; height: auto; display: block; }
.lem-line-axis { stroke: var(--lem-border); stroke-width: 1; }
.lem-line-grid { stroke: var(--lem-border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.lem-line-area { fill: color-mix(in srgb, var(--lem-primary) 14%, transparent); stroke: none; }
.lem-line-path { fill: none; stroke: var(--lem-primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.lem-line-dot { fill: var(--lem-surface); stroke: var(--lem-primary); stroke-width: 2.5; }
.lem-line-value { font-size: 10.5px; font-weight: 800; fill: var(--lem-ink); text-anchor: middle; }
.lem-line-label { font-size: 10.5px; fill: var(--lem-ink-faint); text-anchor: middle; font-weight: 600; }

/* Insight strip — the plain-language "what to do next" read of the data,
   which is the part students actually act on. */
.lem-insights { display: flex; flex-direction: column; gap: 10px; }
.lem-insight {
	display: flex; gap: 11px; align-items: flex-start;
	background: var(--lem-surface-2);
	border: 1px solid var(--lem-border);
	border-left-width: 3px;
	border-radius: var(--lem-radius);
	padding: 13px 15px;
	font-size: 13.5px; line-height: 1.55; color: var(--lem-ink-soft);
}
.lem-insight b { color: var(--lem-ink); font-weight: 750; }
.lem-insight svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.lem-insight-good { border-left-color: var(--lem-answered); }
.lem-insight-good svg { color: var(--lem-answered); }
.lem-insight-bad { border-left-color: var(--lem-not-answered); }
.lem-insight-bad svg { color: var(--lem-not-answered); }
.lem-insight-info { border-left-color: var(--lem-primary); }
.lem-insight-info svg { color: var(--lem-primary); }
.lem-insight-warn { border-left-color: var(--lem-answered-marked); }
.lem-insight-warn svg { color: var(--lem-answered-marked); }

/* ------------------------------------------------------ question analysis */

.lem-qa-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.lem-qa-filter {
	padding: 7px 14px !important;
	border-radius: var(--lem-radius-pill) !important;
	border: 1px solid var(--lem-border) !important;
	background: var(--lem-surface) !important;
	color: var(--lem-ink-soft) !important;
	font-family: inherit; font-size: 12.5px !important; font-weight: 700 !important;
	cursor: pointer !important; opacity: 1 !important; box-shadow: none !important;
	transition: all var(--lem-dur) var(--lem-ease);
}
.lem-qa-filter:hover { border-color: var(--lem-border-strong) !important; color: var(--lem-ink) !important; }
.lem-qa-filter.active { background: var(--lem-primary) !important; border-color: var(--lem-primary) !important; color: #fff !important; }

.lem-qa-empty { text-align: center; color: var(--lem-ink-soft); padding: 30px 0; font-weight: 600; }

.lem-qa-card {
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-left: 4px solid var(--lem-not-visited);
	border-radius: var(--lem-radius);
	padding: 18px 20px;
	margin-bottom: 12px;
	box-shadow: var(--lem-shadow-xs);
}
.lem-qa-card-correct { border-left-color: var(--lem-answered); }
.lem-qa-card-wrong { border-left-color: var(--lem-not-answered); }
.lem-qa-card-skipped { border-left-color: var(--lem-not-visited); }
.lem-qa-card-not_evaluated { border-left-color: var(--lem-marked); }
.lem-qa-card.is-hidden { display: none; }

.lem-qa-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.lem-qa-meta { font-size: 11.5px; font-weight: 750; color: var(--lem-ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.lem-qa-status {
	margin-left: auto; font-size: 11px; font-weight: 800; padding: 3px 10px;
	border-radius: var(--lem-radius-pill); white-space: nowrap;
}
.lem-qa-status-correct { background: color-mix(in srgb, var(--lem-answered) 14%, var(--lem-surface)); color: var(--lem-answered); }
.lem-qa-status-wrong { background: color-mix(in srgb, var(--lem-not-answered) 14%, var(--lem-surface)); color: var(--lem-not-answered); }
.lem-qa-status-skipped { background: var(--lem-surface-2); color: var(--lem-ink-soft); }
.lem-qa-status-not_evaluated { background: color-mix(in srgb, var(--lem-marked) 14%, var(--lem-surface)); color: var(--lem-marked); }

.lem-qa-title { font-size: calc(15px * var(--lem-font-scale)); font-weight: 600; margin-bottom: 14px; line-height: 1.6; }

.lem-qa-not-evaluated-tag {
	display: inline-flex; align-items: center; gap: 6px;
	font-size: 12px; font-weight: 650; color: var(--lem-marked);
	background: color-mix(in srgb, var(--lem-marked) 12%, var(--lem-surface));
	border-radius: var(--lem-radius-xs); padding: 6px 11px; margin-bottom: 12px;
}

.lem-qa-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.lem-qa-option {
	display: flex; align-items: center; flex-wrap: wrap; gap: 9px;
	background: var(--lem-surface-2); border: 1.5px solid var(--lem-border);
	border-radius: var(--lem-radius-sm); padding: 10px 13px;
	font-size: calc(13.5px * var(--lem-font-scale));
}
.lem-qa-option-text { flex: 1; min-width: 0; }
.lem-qa-option-correct { border-color: var(--lem-answered); background: color-mix(in srgb, var(--lem-answered) 9%, var(--lem-surface)); }
.lem-qa-option-wrong { border-color: var(--lem-not-answered); background: color-mix(in srgb, var(--lem-not-answered) 9%, var(--lem-surface)); }

.lem-qa-badge { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: var(--lem-radius-pill); white-space: nowrap; }
.lem-qa-badge-yours { background: color-mix(in srgb, var(--lem-primary) 15%, var(--lem-surface)); color: var(--lem-primary); }
.lem-qa-badge-correct { background: color-mix(in srgb, var(--lem-answered) 16%, var(--lem-surface)); color: var(--lem-answered); }

.lem-qa-free-answer { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.lem-qa-free-given,
.lem-qa-free-accepted {
	display: flex; align-items: center; flex-wrap: wrap; gap: 9px;
	background: var(--lem-surface-2); border: 1.5px solid var(--lem-border);
	border-radius: var(--lem-radius-sm); padding: 10px 13px;
	font-size: calc(13.5px * var(--lem-font-scale));
}
.lem-qa-free-given { border-color: var(--lem-primary); background: color-mix(in srgb, var(--lem-primary) 8%, var(--lem-surface)); }
.lem-qa-free-accepted { border-color: var(--lem-answered); background: color-mix(in srgb, var(--lem-answered) 9%, var(--lem-surface)); }

.lem-qa-solution {
	font-size: calc(13px * var(--lem-font-scale)); color: var(--lem-ink-soft);
	background: var(--lem-surface-2); border: 1px dashed var(--lem-border);
	border-radius: var(--lem-radius-sm); padding: 12px 14px; line-height: 1.6;
}
.lem-qa-solution b { color: var(--lem-ink); }

/* ---------------------------------------------------------- history list */

#lem-history-root {
	max-width: 900px; margin: 0 auto;
	font-family: var(--lem-font);
	color: var(--lem-ink);
}
.lem-history-empty { text-align: center; color: var(--lem-ink-soft); padding: 44px 0; font-weight: 600; }

.lem-history-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 18px; }
.lem-history-stat {
	background: var(--lem-surface); border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius); padding: 14px 16px; box-shadow: var(--lem-shadow-xs);
}
.lem-history-stat b { display: block; font-size: 23px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.lem-history-stat span { font-size: 11.5px; font-weight: 700; color: var(--lem-ink-faint); text-transform: uppercase; letter-spacing: .05em; }

.lem-history-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.lem-history-search {
	flex: 1; min-width: 180px;
	padding: 10px 14px !important;
	border: 1px solid var(--lem-border) !important;
	border-radius: var(--lem-radius-sm) !important;
	background: var(--lem-surface) !important;
	color: var(--lem-ink) !important;
	font-family: inherit; font-size: 13.5px !important;
	box-shadow: none !important;
}
.lem-history-search::placeholder { color: var(--lem-ink-faint); }
.lem-history-select {
	padding: 10px 14px !important;
	border: 1px solid var(--lem-border) !important;
	border-radius: var(--lem-radius-sm) !important;
	background: var(--lem-surface) !important;
	color: var(--lem-ink) !important;
	font-family: inherit; font-size: 13.5px !important; font-weight: 600;
	cursor: pointer;
}

.lem-history-list { display: flex; flex-direction: column; gap: 10px; }
.lem-history-row {
	display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
	background: var(--lem-surface); border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius); padding: 15px 18px;
	box-shadow: var(--lem-shadow-xs);
	transition: transform var(--lem-dur) var(--lem-ease), box-shadow var(--lem-dur) var(--lem-ease), border-color var(--lem-dur) var(--lem-ease);
}
.lem-history-row:hover { transform: translateY(-1px); box-shadow: var(--lem-shadow); border-color: var(--lem-border-strong); }
.lem-history-rank {
	width: 42px; height: 42px; flex: none; border-radius: var(--lem-radius-sm);
	display: grid; place-items: center;
	background: var(--lem-surface-2); border: 1px solid var(--lem-border);
	font-size: 13px; font-weight: 800; color: var(--lem-ink-soft);
	font-variant-numeric: tabular-nums;
}
.lem-history-rank.is-best {
	background: color-mix(in srgb, var(--lem-answered-marked) 16%, var(--lem-surface));
	border-color: color-mix(in srgb, var(--lem-answered-marked) 40%, var(--lem-border));
	color: var(--lem-answered-marked);
}
.lem-history-rank svg { width: 18px; height: 18px; }
.lem-history-row-main { flex: 1 1 200px; min-width: 160px; }
.lem-history-exam { font-weight: 750; font-size: 14.5px; }
.lem-history-date { font-size: 12.5px; color: var(--lem-ink-soft); margin-top: 3px; }
.lem-history-score { font-weight: 800; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lem-history-score span { font-weight: 600; color: var(--lem-ink-soft); font-size: 13px; }
.lem-history-row .lem-pass-badge { margin-bottom: 0; }
.lem-history-back { margin-bottom: 16px; }

/* ---------------------------------------------------------------- print */

@media print {
	body:has(#lem-exam-root) { overflow: visible; }
	#lem-exam-root { position: static; overflow: visible; background: #fff; padding: 0; }
	.lem-result-toolbar, .lem-result-tabs, .lem-history-back, .lem-qa-toolbar,
	.lem-topbar, .lem-nav-panel, .lem-mobile-bar, .lem-toasts,
	.lem-history-toolbar { display: none !important; }
	.lem-result-tab-panel { display: block !important; }
	.lem-analysis-card, .lem-qa-card, .lem-result-hero { break-inside: avoid; box-shadow: none; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
	#lem-exam-root *, .lem-portal *, .lem-modal-backdrop *, .lem-toast {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
	}
	.lem-score-value { stroke-dashoffset: var(--lem-ring-offset, 502.4); }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
	.lem-body, .lem-skel-body { grid-template-columns: minmax(0, 1fr) 290px; }
}

@media (max-width: 880px) {
	#lem-exam-root { padding: 10px 10px calc(84px + env(safe-area-inset-bottom)); }

	.lem-body, .lem-skel-body { grid-template-columns: minmax(0, 1fr); }
	.lem-skel-side { display: none; }

	.lem-topbar { padding: 10px 12px; gap: 10px; border-radius: var(--lem-radius); }
	.lem-avatar { width: 36px; height: 36px; font-size: 13px; }
	.lem-id-name { font-size: 13.5px; }
	.lem-id-meta { font-size: 11.5px; }
	.lem-timer-wrap { padding: 3px 11px 3px 3px; gap: 8px; }
	.lem-timer-ring, .lem-timer-ring svg { width: 34px; height: 34px; }
	.lem-timer { font-size: 16.5px; }
	.lem-topbar .lem-tool-group { display: none; }

	.lem-question-panel { padding: 18px 16px; min-height: 0; }
	.lem-actions-primary .lem-btn { flex: 1 1 calc(50% - 5px); }
	.lem-actions-nav { display: none; }

	/* The palette becomes a slide-up sheet reached from the mobile bar — on
	   a phone it would otherwise push the question off-screen. */
	.lem-nav-panel {
		position: fixed;
		left: 0; right: 0; bottom: 0; top: auto;
		max-height: 82vh; overflow-y: auto;
		border-radius: var(--lem-radius-lg) var(--lem-radius-lg) 0 0;
		z-index: 100040;
		transform: translateY(101%);
		transition: transform .28s var(--lem-ease);
		padding-bottom: calc(18px + env(safe-area-inset-bottom));
		box-shadow: var(--lem-shadow-lg);
	}
	.lem-nav-panel.is-open { transform: none; }
	.lem-nav-handle {
		display: block; width: 42px; height: 4px; border-radius: 2px;
		background: var(--lem-border-strong); margin: 0 auto 12px;
	}
	.lem-nav-grid { grid-template-columns: repeat(6, 1fr); }

	.lem-drawer-backdrop {
		display: block; position: fixed; inset: 0;
		background: var(--lem-overlay); z-index: 100035;
		opacity: 0; pointer-events: none; transition: opacity .25s var(--lem-ease);
	}
	.lem-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

	.lem-mobile-bar {
		display: flex; align-items: center; gap: 8px;
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 100038;
		padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
		background: color-mix(in srgb, var(--lem-surface) 92%, transparent);
		-webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
		border-top: 1px solid var(--lem-border);
	}
	.lem-mobile-bar .lem-btn { flex: 1; }
	.lem-mobile-bar .lem-tool { flex: none; }
	.lem-mobile-palette-btn { flex: none !important; padding: 11px 15px !important; }

	.lem-rules-hero { padding: 24px 20px 22px; }
	.lem-rules-hero h2 { font-size: 21px; }
	.lem-rules-body { padding: 20px; }
	.lem-rules-actions .lem-btn-start { min-width: 0; }

	.lem-score-ring, .lem-score-ring svg { width: 158px; height: 158px; }
	.lem-score-percent { font-size: 34px; }
	.lem-result-hero { padding: 26px 18px 24px; }
	.lem-legend { grid-template-columns: 1fr; }
	.lem-history-row { align-items: flex-start; }
}

@media (max-width: 420px) {
	.lem-nav-grid { grid-template-columns: repeat(5, 1fr); }
	.lem-actions-primary .lem-btn { flex: 1 1 100%; }
	.lem-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Section-wise result: each topic's score against its cut-off. */
.lem-section-results {
	margin: 18px 0 6px;
	padding: 18px 20px;
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-sm);
}
.lem-section-results h3 { margin: 0 0 12px; font-size: 16px; color: var(--lem-ink); }
.lem-section-results .lem-cutoff-verdict { margin-bottom: 12px; }
.lem-sec-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.lem-sec-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--lem-ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--lem-border); }
.lem-sec-table td { padding: 10px; border-bottom: 1px solid var(--lem-border); color: var(--lem-ink); }
.lem-sec-table td:nth-child(2), .lem-sec-table td:nth-child(3) { white-space: nowrap; }
.lem-sec-table tr:last-child td { border-bottom: 0; }
.lem-sec-table tr.is-fail td:first-child { color: var(--lem-not-answered); font-weight: 650; }
.lem-sec-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; white-space: nowrap; }
.lem-sec-status svg { width: 16px; height: 16px; }
.lem-sec-status.is-pass { color: var(--lem-answered); }
.lem-sec-status.is-fail { color: var(--lem-not-answered); }
@media (max-width: 560px) {
	.lem-section-results { padding: 14px; }
	.lem-sec-table th, .lem-sec-table td { padding: 8px 6px; font-size: 13px; }
}
.lem-qa-partial-tag { color: var(--lem-answered-marked); }

/* Question language switch (English / Hindi), shown only for a paper that
   has a second language. */
.lem-lang { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px 0 0; font-size: 12px; color: inherit; }
.lem-lang-label { opacity: .8; white-space: nowrap; }
.lem-lang select {
	font: inherit; font-size: 13px; font-weight: 600;
	padding: 4px 24px 4px 8px; min-height: 32px;
	border-radius: var(--lem-radius-sm);
	border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
	background-color: transparent; color: inherit;
}
.lem-lang select option { color: #111; }
@media (max-width: 640px) { .lem-lang-label { display: none; } }

/* On-screen scientific calculator (GATE / JAM style). Fixed, draggable by
   its title bar; above the exam screen (100000) and its drawer, below
   dialogs (100050). */
.lem-calc {
	position: fixed; right: 24px; bottom: 24px; z-index: 100045;
	width: 452px; max-width: calc(100vw - 16px);
	background: #eef0f3; color: #111;
	border: 1px solid #b8bec8; border-radius: 10px;
	box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	user-select: none; touch-action: none;
}
.lem-calc[hidden] { display: none; }
.lem-calc.is-dragging { opacity: .92; }
.lem-calc-bar {
	display: flex; align-items: center; justify-content: space-between;
	padding: 6px 8px 6px 12px; cursor: move;
	background: #2f3b52; color: #fff; border-radius: 9px 9px 0 0;
	font-size: 13px; font-weight: 650;
}
.lem-calc-close { background: none; border: 0; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 6px; }
.lem-calc-screen { margin: 8px 8px 4px; background: #fff; border: 1px solid #b8bec8; border-radius: 4px; padding: 4px 8px; }
.lem-calc-expr {
	width: 100%; border: 0 !important; outline: none; box-shadow: none !important;
	background: transparent; font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	text-align: right; color: #333; padding: 0 !important; user-select: text;
}
.lem-calc-result { text-align: right; font: 600 22px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 31px; overflow-x: auto; white-space: nowrap; }
.lem-calc-top { display: flex; align-items: center; gap: 4px; padding: 2px 8px 4px; font-size: 12px; }
.lem-calc-top label { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; cursor: pointer; }
.lem-calc-mem { font-weight: 700; min-width: 12px; }
.lem-calc-spacer { flex: 1; }
.lem-calc-keys { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; padding: 4px 8px 10px; }
.lem-calc-key {
	min-width: 0; height: 32px; padding: 0 2px;
	border: 1px solid #a9b0bb; border-radius: 4px;
	background: linear-gradient(#fff, #e3e6ea); color: #111;
	font: 600 12.5px/1 system-ui, sans-serif; cursor: pointer;
}
.lem-calc-key:hover { border-color: #5b6b86; }
.lem-calc-key:active { background: #d6dae0; }
.lem-calc-key.is-fn { font-size: 10.5px; font-weight: 600; letter-spacing: -.02em; color: #1d2a44; white-space: nowrap; overflow: hidden; }
.lem-calc-key.is-mem { height: 26px; padding: 0 7px; font-size: 11.5px; }
.lem-calc-key.is-ctl { background: linear-gradient(#fdf2e3, #f2dcbc); }
.lem-calc-key.is-danger { background: linear-gradient(#fbe3e3, #f0c2c2); color: #8a1111; }
.lem-calc-key.is-eq { background: linear-gradient(#e2f2e5, #bfe3c6); color: #0f5a22; font-size: 16px; height: auto; }
.lem-calc-key.is-wide { grid-column: span 2; }
@media (max-width: 520px) {
	.lem-calc { right: 8px; bottom: 8px; }
	.lem-calc-keys { gap: 3px; padding: 4px 6px 8px; }
	.lem-calc-key { height: 30px; font-size: 11px; }
	.lem-calc-key.is-fn { font-size: 10px; }
}

/* Optional sections (GATE XL / XE): an optional section must be selected
   before it can be answered. The bar above its questions says which, and
   holds the Select / Deselect button. */
.lem-choice-bar {
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	margin: 0 0 16px; padding: 10px 14px;
	border-radius: var(--lem-radius-sm);
	font-size: 13px; line-height: 1.5;
}
.lem-choice-bar > svg { width: 17px; height: 17px; flex: none; }
.lem-choice-bar > div { flex: 1 1 220px; min-width: 0; }
.lem-choice-bar.is-locked { background: var(--lem-surface-2); color: var(--lem-ink-soft); border: 1px dashed var(--lem-border); }
.lem-choice-bar.is-chosen { background: color-mix(in srgb, var(--lem-answered) 10%, var(--lem-surface)); color: var(--lem-answered); }
.lem-option.is-disabled { cursor: not-allowed; opacity: .6; }
.lem-option.is-disabled:hover { border-color: var(--lem-border); background: var(--lem-surface); }
.lem-btn[disabled] { cursor: not-allowed; opacity: .55; }

.lem-section-tag {
	display: inline-block; margin-left: 4px; padding: 0 6px;
	border-radius: 999px; border: 1px solid currentColor;
	font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; opacity: .8;
}
.lem-section-btn.is-unselected { border-style: dashed !important; opacity: .75 !important; }

/* Before starting (GATE XH / GG): pick the optional sections on the rules
   screen. */
.lem-rules-choice { margin: 0 0 22px; font-size: 14px; color: var(--lem-ink); }
.lem-rules-choice p { margin: 0 0 10px; }
.lem-choice-item {
	display: flex; align-items: center; gap: 10px;
	padding: 10px 14px; border: 1px solid var(--lem-border); cursor: pointer;
}
.lem-choice-item + .lem-choice-item { border-top: 0; }
.lem-choice-item:first-of-type { border-radius: var(--lem-radius-sm) var(--lem-radius-sm) 0 0; }
.lem-choice-item:last-of-type { border-radius: 0 0 var(--lem-radius-sm) var(--lem-radius-sm); }
.lem-choice-item > span:nth-child(2) { flex: 1; }
.lem-choice-count { color: var(--lem-ink-soft); white-space: nowrap; }
.lem-btn-start[disabled] { cursor: not-allowed; opacity: .55; }

/* Question language, picked on the rules screen before starting. */
.lem-rules-lang { margin: 0 0 22px; padding: 0; border: 0; font-size: 14px; color: var(--lem-ink); min-width: 0; }
.lem-rules-lang legend { padding: 0; margin: 0 0 6px; font-weight: 700; }
.lem-rules-lang p { margin: 0 0 10px; color: var(--lem-ink-soft); }
.lem-lang-options { display: flex; flex-wrap: wrap; gap: 10px; }
.lem-lang-option {
	display: flex; align-items: center; gap: 8px; cursor: pointer;
	padding: 10px 16px; border: 1px solid var(--lem-border); border-radius: var(--lem-radius-sm);
	flex: 1 1 140px; min-width: 0;
}
.lem-lang-option:has(input:checked) { border-color: var(--lem-primary); box-shadow: 0 0 0 1px var(--lem-primary); }
.lem-lang-option input { margin: 0; accent-color: var(--lem-primary); }

.lem-sec-auto { font-size: 12px; font-weight: 600; color: var(--lem-ink-soft); }
.lem-sec-not-selected { margin: 12px 0 0; font-size: 13px; color: var(--lem-ink-soft); }

/* Cloze, essay, sorting and matching questions */
.lem-cloze { line-height: 2.2; }
.lem-cloze .lem-gap { min-width: 8em; padding: 2px 8px; margin: 0 4px; font: inherit; border: 1px solid var(--lem-border, #cbd5e1); border-radius: 6px; background: var(--lem-surface, #fff); color: inherit; }
.lem-essay-input { width: 100%; min-height: 12em; font: inherit; padding: 10px 12px; border: 1px solid var(--lem-border, #cbd5e1); border-radius: 8px; background: var(--lem-surface, #fff); color: inherit; box-sizing: border-box; }
.lem-sort { list-style: decimal; padding-left: 1.6em; margin: 12px 0; }
.lem-sort-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--lem-border, #cbd5e1); border-radius: 8px; }
.lem-sort-moves { display: flex; gap: 4px; flex-shrink: 0; }
.lem-matrix { display: grid; gap: 10px; margin: 12px 0; }
.lem-matrix-row { display: grid; grid-template-columns: 1fr minmax(10em, 1fr); gap: 12px; align-items: center; }
.lem-matrix-row .lem-match { font: inherit; padding: 6px 8px; border: 1px solid var(--lem-border, #cbd5e1); border-radius: 6px; background: var(--lem-surface, #fff); color: inherit; max-width: 100%; }
@media (max-width: 600px) { .lem-matrix-row { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- break */

/* The compulsory break between two sections (Sections::onBreak()). The
   exam is hidden underneath, not just covered, so it cannot be tabbed to
   or read out; the server refuses answers until the break ends anyway. */
.lem-shell.is-on-break { visibility: hidden; }

.lem-rules-sections li.lem-rules-break { counter-increment: none; background: var(--lem-surface-2); color: var(--lem-ink-soft); }
.lem-rules-sections li.lem-rules-break > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.lem-rules-sections li.lem-rules-break > span:first-child::before { content: none; }
.lem-rules-sections li.lem-rules-break svg { width: 15px; height: 15px; }

.lem-break {
	position: fixed; inset: 0; z-index: 1;
	display: flex; align-items: center; justify-content: center;
	padding: 16px;
	overflow-y: auto;
	background-color: var(--lem-bg);
	background-image: var(--lem-bg-grad);
	outline: none;
}
.lem-break-card {
	width: min(520px, 100%);
	background: var(--lem-surface);
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius-lg);
	box-shadow: var(--lem-shadow-md);
	padding: 32px 28px 24px;
	text-align: center;
}
.lem-break-eyebrow {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 4px 12px; border-radius: var(--lem-radius-pill);
	background: color-mix(in srgb, var(--lem-primary) 12%, var(--lem-surface));
	color: var(--lem-primary);
	font-size: 12px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
}
.lem-break-eyebrow svg { width: 14px; height: 14px; }
.lem-break-card h2 { margin: 14px 0 20px; font-size: 22px; line-height: 1.3; color: var(--lem-ink); }
.lem-break-clock-label { font-size: 13px; color: var(--lem-ink-soft); }
.lem-break-clock {
	margin: 4px 0 14px;
	font-size: clamp(44px, 12vw, 64px); font-weight: 800; line-height: 1.1;
	font-variant-numeric: tabular-nums; letter-spacing: -.02em;
	color: var(--lem-ink);
}
.lem-break-bar {
	height: 6px; border-radius: var(--lem-radius-pill);
	background: var(--lem-surface-3); overflow: hidden; margin: 0 0 20px;
}
.lem-break-bar span {
	display: block; height: 100%; width: 0;
	background: var(--lem-primary); border-radius: inherit;
	transition: width 1s linear;
}
.lem-break-next { margin: 0 0 18px; font-size: 14px; line-height: 1.6; color: var(--lem-ink-soft); }
.lem-break-next b { color: var(--lem-ink); }
.lem-break .lem-summary-note { text-align: left; margin: 0; }

@media (prefers-reduced-motion: reduce) { .lem-break-bar span { transition: none; } }
@media (max-width: 480px) { .lem-break-card { padding: 24px 18px 18px; } }

/* "Students may submit early" off (Rules): where the Submit button was. */
.lem-rules-body > .lem-summary-note { margin-top: 18px; }
.lem-nav-nosubmit {
	display: flex; gap: 8px; align-items: center; justify-content: center;
	margin: 0; padding: 10px 12px;
	border-radius: var(--lem-radius-sm);
	background: var(--lem-surface-2);
	color: var(--lem-ink-soft);
	font-size: 13px; font-weight: 600; text-align: center;
}
.lem-nav-nosubmit svg { width: 15px; height: 15px; flex: none; }

/* ------------------------------------------------ schedule and ranks
   [turgee_exam_schedule] and [turgee_exam_ranks] sit on the site's own pages,
   so each block carries its own surface: the host theme's background is not
   known, and the dark tokens would otherwise put light text on it. */
.lem-schedule,
.lem-ranks {
	box-sizing: border-box;
	max-width: 100%;
	margin: 1em 0;
	padding: 14px;
	border: 1px solid var(--lem-border);
	border-radius: var(--lem-radius);
	background: var(--lem-surface-2);
	color: var(--lem-ink);
	font-family: var(--lem-font);
	-webkit-font-smoothing: antialiased;
}
.lem-schedule-group { margin: 1.2em 0 .5em; font-size: 15px; font-weight: 800; color: var(--lem-ink); }
.lem-schedule-group:first-child { margin-top: 0; }
.lem-schedule-day { margin: 1em 0 .4em; font-size: 13px; font-weight: 700; color: var(--lem-ink-soft); }
.lem-schedule-card {
	margin: 0 0 10px; padding: 14px 16px;
	border: 1px solid var(--lem-border); border-radius: var(--lem-radius-sm);
	background: var(--lem-surface); box-shadow: var(--lem-shadow-xs);
	overflow-wrap: anywhere;
}
.lem-schedule-card.lem-stage-live { border-color: var(--lem-primary); }
.lem-schedule-title { margin: 0 0 4px; font-size: 16px; line-height: 1.3; color: var(--lem-ink); }
.lem-schedule-meta { margin: 0 0 8px; font-size: 13.5px; color: var(--lem-ink-soft); }
.lem-schedule-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; font-size: 13.5px; color: var(--lem-ink); }
.lem-schedule-actions .lem-btn { text-decoration: none; }
.lem-schedule-countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--lem-ink); }
.lem-schedule-empty,
.lem-ranks-pending { margin: 0; color: var(--lem-ink-soft); font-weight: 600; }
.lem-ranks-me { margin: 0 0 12px; font-weight: 700; }
.lem-ranks-table { width: 100%; border-collapse: collapse; background: var(--lem-surface); }
.lem-ranks-table th,
.lem-ranks-table td { padding: 8px 10px; border-bottom: 1px solid var(--lem-border); text-align: left; color: var(--lem-ink); overflow-wrap: anywhere; }
.lem-ranks-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--lem-ink-soft); }
@media (max-width: 480px) {
	.lem-schedule,
	.lem-ranks { padding: 10px; }
	.lem-schedule-card { padding: 12px; }
	.lem-schedule-actions .lem-btn { flex: 1 1 100%; }
	.lem-ranks-table th,
	.lem-ranks-table td { padding: 6px 6px; }
}
