/* Acadlix Portal — Exam screen styles (strict reference rebuild).
   THEMING: chrome colours come from the shared CSS variables in
   assets/css/style.css (:root light palette, [data-theme="dark"] dark
   palette). The exam's OWN state colours stay verbatim per the brief:
   blue #1a7fd4 (active tab / Save & Next / Submit), Answered #43A047,
   Not Answered #E53935, Not Visited #9E9E9E, Marked #7B1FA2,
   Answered & Marked #8E24AA (violet + green tick), dark bar #1a1a1a,
   gold section title. The dark instruction bar stays dark in both modes;
   in dark mode the white question area becomes a dark surface.
   Font family is the admin's Design Studio choice (var(--font)); the
   font-size dropdown scales the root (html[data-font-size]) site-wide. */

/* ---------- Fixed-chrome shell (attempt screen only) ----------
   Truly FIXED layout, exactly like the reference: the shell is pinned to
   the viewport (position:fixed; inset:0) and is a grid with explicit
   rows — top bar / dark time bar / preview banner / body. Nothing in
   the chrome ever scrolls away; only three regions scroll internally —
   the question text, the answer/options area and the palette grid.
   Heights are dynamic by construction: the body row is minmax(0,1fr),
   i.e. viewport height minus the fixed rows. The page itself never
   scrolls (see the html/body.exam-attempt rule below — exam.js adds
   that class — and the shell being fixed, so there is no second
   scrollbar). */

/* The attempt page itself does not scroll: only the question text,
   the answer area and the palette grid scroll internally. exam.js
   adds .exam-attempt to <html>/<body> on the attempt screen only. */
html.exam-attempt, html.exam-attempt body { overflow:hidden; height:100%; overscroll-behavior:none; }

.exam-shell { position:fixed; inset:0; height:100vh; height:100dvh; display:grid; grid-template-rows:auto auto auto minmax(0, 1fr); grid-template-columns:minmax(0, 1fr); background:var(--bg, #f4f6fb); color:var(--text, #111827); font-family:var(--font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif); overflow:hidden; }
/* Grid children must be allowed to shrink below their content's
   min-content width, or a wide row (e.g. the section tabs) would blow
   its track out and the bars / bottom bar would overflow the viewport. */
.exam-shell > * { min-width:0; }
.exam-main-col > * { min-width:0; }

/* Top white bar: BACK ICON (far left, before the logo) + logo +
   centred dark-navy title + language selector + calculator.
   Pinned row 1, never scrolls. */
.exam-topbar-ref { display:flex; align-items:center; gap:8px; background:#fff; border-bottom:1px solid #e5e7eb; padding:3px 12px; min-height:40px; }
/* Back control: a chevron icon (not text), dark navy on the white bar,
   first element in the header, leftmost before the logo. 44×44px touch
   target so it is tappable on mobile. */
.exam-back { flex:none; display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; min-width:44px; min-height:44px; border:0; border-radius:8px; background:transparent; color:#12294d; cursor:pointer; padding:0; }
.exam-back svg { width:26px; height:26px; display:block; }
.exam-back:hover { color:#1a7fd4; background:#eef2f7; }
.exam-brand { flex:none; display:inline-flex; align-items:center; }
.exam-brand-logo { height:24px; max-width:140px; object-fit:contain; }
.exam-brand-mark { display:inline-flex; align-items:center; justify-content:center; width:24px; height:24px; border-radius:8px; background:#4f46e5; color:#fff; font-weight:800; font-size:1rem; }
.exam-title { flex:1; min-width:0; margin:0; text-align:center; font-size:1.05rem; font-weight:700; color:#12294d; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.exam-calc-btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-width:44px; min-height:44px; flex:none; background:transparent; border:0; outline:0; box-shadow:none; border-radius:8px; color:#12294d; cursor:pointer; padding:0 6px; font-size:.95rem; font-weight:600; font-family:inherit; }
/* Pass 6: NO outer box — bare icon + "Calculator" text on desktop,
   bare icon only at ≤1023px (the label is hidden there) so a long
   translated word such as Telugu "కాలిక్యులేటర్" cannot eat header
   space. The 44px tap target stays. */
.exam-calc-btn:hover { background:#eef2f7; color:#1a7fd4; }
.exam-calc-btn:focus-visible { outline:2px solid #1a7fd4; outline-offset:1px; }
.exam-calc-btn .exam-calc-icon { display:inline-flex; color:inherit; }
.exam-calc-btn .exam-calc-icon .ew-ic { display:block; }
/* Language selector in the top bar (pass 7): the ONE language control
   on the attempt screen — globe + 2-letter code + ▾, same dropdown
   menu as before. Light treatment on the white bar (the dark-bar
   button style below does not apply here). */
.exam-top-lang-btn { background:#fff; border-color:#d1d5db; color:#111827; padding:6px 9px; }
.exam-top-lang-btn:hover { background:#f3f4f6; border-color:#9ca3af; }
.exam-top-lang-btn .ew-ic { display:block; flex:none; }
.exam-top-lang-btn .caret { color:#6b7280; }
.exam-top-lang-current { font-size:.8rem; letter-spacing:.02em; }
[data-theme="dark"] .exam-top-lang-btn { background:#2b3a55; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-top-lang-btn:hover { background:#33415e; }
[data-theme="dark"] .exam-top-lang-btn .caret { color:#94a3b8; }

/* Dark bar (#1a1a1a by default): gold section title LEFT, Time Left CENTRED.
   Pinned row 2. Pass 7: no language control here any more — the top bar
   holds the single language selector. The background comes from
   --exam-timebar-bg (Design Studio "Exam time bar background", set on
   .exam-shell by exam/interface.php); it wins in both themes. */
.exam-darkbar { display:flex; align-items:center; gap:8px; background:var(--exam-timebar-bg, #1a1a1a); color:#fff; padding:5px 16px; min-height:40px; flex-wrap:wrap; }
.exam-darkbar-section { color:#f2c230; font-weight:700; font-size:1rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:38%; }
.exam-darkbar-time { flex:1; text-align:center; font-weight:600; font-size:1rem; white-space:nowrap; font-variant-numeric:tabular-nums; }
.exam-timer { font-weight:700; font-variant-numeric:tabular-nums; }
.exam-timer.warning { color:#ff8080; animation:exam-pulse 1s infinite; }
@keyframes exam-pulse { 0%,100% { opacity:1; } 50% { opacity:.55; } }
/* Language dropdown — the single top-bar selector (pass 7). The shared
   button base below is dark; .exam-top-lang-btn above overrides it
   with the light treatment for the white top bar. */
.exam-lang-menu { position:relative; flex:none; }
.exam-lang-dd-btn { display:inline-flex; align-items:center; gap:6px; background:#2b2b2b; border:1px solid #4b4b4b; border-radius:999px; padding:7px 11px; cursor:pointer; font-size:.9rem; font-weight:700; color:#fff; font-family:inherit; line-height:1; white-space:nowrap; }
.exam-lang-dd-btn:hover { background:#3a3a3a; border-color:#666; }
.exam-lang-dd-btn .caret { color:#cbd5e1; font-size:.7rem; }
.exam-lang-dd { display:none; position:absolute; right:0; top:calc(100% + 8px); background:var(--surface, #fff); border:1px solid var(--border, #e5e7eb); border-radius:12px; box-shadow:0 8px 30px rgba(0,0,0,.25); min-width:190px; padding:6px; z-index:70; }
.exam-lang-menu.open .exam-lang-dd { display:block; }
.exam-lang-opt { display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; background:none; border:0; padding:9px 12px; border-radius:8px; color:var(--text, #111827); font-weight:600; font-size:.95rem; font-family:inherit; cursor:pointer; text-align:left; }
.exam-lang-opt:hover { background:var(--primary-soft, #eef2ff); color:var(--primary, #4f46e5); }
.exam-lang-opt.selected { background:var(--primary-soft, #eef2ff); color:var(--primary, #4f46e5); }
.exam-lang-tick { visibility:hidden; color:#43A047; font-weight:800; }
.exam-lang-opt.selected .exam-lang-tick { visibility:visible; }
/* Pass 6: a language the current question has no text in is hidden
   from both menus (exam.js toggles this class per question). */
.exam-lang-opt.lang-unavailable { display:none; }
.exam-instr-btn { display:inline-flex; align-items:center; gap:6px; background:transparent; border:0; color:#fff; font-size:.95rem; font-weight:600; font-family:inherit; cursor:pointer; padding:6px 4px; white-space:nowrap; }
.exam-instr-btn:hover { color:#bfdbfe; }
.exam-info-ic { display:inline-flex; align-items:center; justify-content:center; width:18px; height:18px; border-radius:50%; background:#1a7fd4; color:#fff; font-size:12px; font-weight:800; font-style:italic; flex:none; }

/* Preview banner (premium without access): grid row 3, fixed. */
.exam-preview-banner { background:#fef3c7; color:#92400e; padding:8px 16px; font-size:.92rem; border-bottom:1px solid #fcd34d; }
.exam-preview-banner.exam-preview-timeup { background:#fee2e2; color:#991b1b; border-bottom-color:#fca5a5; font-weight:700; }

/* ---------- Layout: question column + palette column ----------
   Two-column grid, grid row 4 of the shell (the only dynamic-height
   row: viewport minus the fixed rows above). The question column is
   itself a grid — sections row / scroll area / bottom bar — so the
   bottom bar lives INSIDE the question column's grid cell and its
   width equals the question box width by construction, at every
   viewport width. The palette spans both body rows on the right;
   its number grid scrolls internally and its Submit stays pinned
   at the bottom of the palette column. */
/* grid-row:4 is load-bearing: the shell has 4 rows (top bar / dark bar /
   preview banner / body) and with no preview banner only 3 visible
   children exist, so auto-placement used to drop this element into the
   AUTO row 3 and leave the 1fr body row empty — the bottom bar then
   stopped ~70-145px above the viewport bottom on every width. Pinned
   to row 4, the body row fills the viewport and the bottom bar sits
   exactly at bottom:0. */
.exam-layout-ref { grid-row:4; display:grid; grid-template-columns:minmax(0, 1fr) 300px; grid-template-rows:auto minmax(0, 1fr); min-height:0; min-width:0; }
.exam-main-col { grid-column:1; grid-row:1 / -1; display:grid; grid-template-rows:auto minmax(0, 1fr) auto; grid-template-columns:minmax(0, 1fr); min-width:0; min-height:0; background:#fff; }
.exam-shell.exam-collapsed .exam-layout-ref { grid-template-columns:minmax(0, 1fr) 0; }
.exam-shell.exam-collapsed .exam-palette-scroll,
.exam-shell.exam-collapsed .exam-palette-submit { display:none; }
.exam-shell.exam-collapsed .exam-palette { border-left:0; }

/* Sections row: label + ONE-ROW scrollable tabs + edge arrows. Pinned
   under the time bar (grid row 1 of the question column), never scrolls
   itself. Pass 7: the tabs strip is a single row (nowrap) with hidden
   horizontal overflow — swipe/scroll to reach later sections, no
   visible scrollbar. This replaces pass 6's wrapping (which made the
   row ~90px tall on phones and forced the short-viewport hide below).
   The edge arrows are wired in exam.js (scrollBy ±220); they show only
   when the strip actually overflows (.has-overflow on the row). */
.exam-sections-row { display:flex; align-items:center; gap:8px; padding:8px 16px 0; background:#fff; }
.exam-sections-label { font-weight:600; flex:none; }
.exam-tabs-arrow { display:none; flex:none; align-items:center; justify-content:center; width:32px; height:36px; min-width:32px; border:1px solid #d1d5db; background:#eef0f3; color:#111827; border-radius:4px; cursor:pointer; font-size:1.1rem; font-weight:700; line-height:1; padding:0; }
.exam-tabs-arrow:hover { background:#e2e8f0; border-color:#9ca3af; }
.exam-sections-row.has-overflow .exam-tabs-arrow { display:inline-flex; }
.exam-subject-tabs { flex:1; min-width:0; display:flex; flex-wrap:nowrap; gap:8px; overflow-x:auto; scrollbar-width:none; }
.exam-subject-tabs::-webkit-scrollbar { display:none; }
.exam-subject-tabs button[data-subject] { padding:8px 14px; border:1px solid #d1d5db; background:#eef0f3; color:#111827; border-radius:4px; cursor:pointer; font-size:.95rem; font-family:inherit; white-space:nowrap; flex:none; }
.exam-subject-tabs button[data-subject].active { background:#1a7fd4; color:#fff; border-color:#1a7fd4; }
/* Pass 16: the per-tab info ("i") icon was removed — no .exam-tab-info
   / .exam-tab-wrap rules remain. */

/* Question area (grid row 2 of the question column). Pass 6 scroll
   model: only the question text, the answer/options area and the
   palette grid scroll — the page, header, timer bar, sections row,
   legend and bottom bar never scroll. */
.exam-scroll { min-height:0; overflow:hidden; padding:10px 14px 14px; background:#fff; }
.exam-panel { display:none; }
.exam-panel.active { display:flex; flex-direction:column; height:100%; min-height:100%; box-sizing:border-box; }
/* Pass 6 scroll model: ONLY three regions scroll — (1) the question
   text, (2) the answer/options area, (3) the palette grid. The panel
   itself is a flex column filling the scroll area; the fixed rows
   (type row, question header) never shrink away, the hint and any
   check result stay pinned below the answer area. */
.exam-qtype-row, .exam-qhead, .exam-check-result, .exam-hint { flex:none; }
.exam-answer { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
.exam-card { background:var(--surface, #fff); border:1px solid var(--border, #e5e7eb); border-radius:var(--radius, 12px); padding:20px; box-shadow:var(--shadow, 0 1px 3px rgba(0,0,0,.06)); color:var(--text, #111827); }
.exam-panel.exam-card { border:0; box-shadow:none; border-radius:0; padding:4px 4px 12px; }
.exam-qtype-row { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:6px; font-size:.95rem; }
/* Question header actions: Check button + bare ⚠️ report icon sit
   before the marks pills at the top right of the question area.
   Pass 7: no language menu here any more — the top bar holds the
   single language selector. */
.exam-qactions { display:inline-flex; align-items:center; gap:6px; flex-wrap:wrap; }
.exam-qactions .btn-check { min-height:36px; padding:4px 12px; }
.exam-report-btn { display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; min-width:36px; background:transparent; border:0; outline:0; box-shadow:none; border-radius:8px; cursor:pointer; padding:0; color:#d97706; }
.exam-report-btn:hover { background:#fef3c7; }
.exam-report-btn:focus-visible { outline:2px solid #d97706; outline-offset:1px; }
.exam-report-btn svg { width:22px; height:22px; }
.exam-check-result { margin:12px 0 0; font-weight:700; }
.exam-check-result:empty { display:none; }
/* Pass 13: marks back as pills (pass-10 style, restored at the user's
   2026-11-21 correction) — green "+1" pill, and a red "−0.25" pill only
   when the question has negative marking AND the quiz negative_marking
   toggle is on. Numbers only: no "Negative" word, no tooltip. Solid
   coloured backgrounds with white text, readable in both themes. The
   wrapper never wraps or shrinks inside the crowded type row (Check /
   report / marks) on a 360px phone. */
.exam-marks { display:inline-flex; gap:6px; align-items:center; white-space:nowrap; flex:none; }
.exam-marks-pill { display:inline-block; padding:2px 10px; border-radius:999px; font-weight:700; font-size:0.9rem; line-height:1.5; color:#fff; white-space:nowrap; }
.exam-marks-pos { background:#2E7D32; }
.exam-marks-neg { background:#D32F2F; }
.exam-qhead { display:flex; justify-content:space-between; gap:10px; align-items:baseline; flex-wrap:wrap; margin-bottom:8px; }
.exam-qno { font-weight:700; }
.exam-qtext { flex:0 1 auto; min-height:0; max-height:45%; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; font-size:1.1rem; line-height:1.6; margin:0 0 12px; color:var(--text, #111827); }
.exam-options { display:flex; flex-direction:column; gap:10px; }
.exam-option { display:flex; gap:10px; align-items:flex-start; border:1px solid #d1d5db; border-radius:8px; padding:12px 14px; cursor:pointer; min-height:44px; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-option:hover { border-color:#1a7fd4; }
.exam-option.selected { border-color:#1a7fd4; background:#e8f2fd; }
.exam-option input { width:20px; height:20px; margin-top:2px; flex:none; accent-color:#1a7fd4; }
.exam-option span { line-height:1.5; }
.exam-hint { margin-top:14px; background:#fffbeb; border:1px solid #fde68a; color:#92400e; border-radius:8px; padding:10px 12px; font-size:.95rem; }
.exam-blank { width:180px; max-width:100%; min-height:44px; padding:8px 10px; border:1px solid var(--border, #d1d5db); border-radius:8px; font-size:1rem; margin:2px 4px; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-match-row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:10px; }
.exam-match-row .left { flex:1 1 160px; font-weight:600; }
.exam-match-row select { flex:1 1 180px; min-height:44px; padding:8px 10px; border:1px solid var(--border, #d1d5db); border-radius:8px; font-size:1rem; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-textarea { width:100%; min-height:140px; padding:12px; border:1px solid var(--border, #d1d5db); border-radius:10px; font-size:1rem; font-family:inherit; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-only-en { display:inline-block; font-size:.72rem; font-weight:700; color:#92400e; background:#fef3c7; border:1px solid #fcd34d; border-radius:999px; padding:2px 8px; margin-left:8px; vertical-align:middle; }
.exam-only-en[hidden] { display:none; }

/* ---------- Right palette panel (pale blue) ----------
   Fixed in place beside the question box: grid column 2, spanning
   both body rows. Flex column: legend + grid scroll internally,
   Submit is pinned at the bottom of the column. */
.exam-palette { grid-column:2; grid-row:1 / -1; position:relative; display:flex; flex-direction:column; min-height:0; background:#eaf3fb; border-left:1px solid #cfe0f0; color:#111827; }
.exam-palette-scroll { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:12px 12px 16px; }
/* User card below the subject name (pass 6, moved pass 33): small round photo — or the
   student's initial in a coloured circle when no photo is uploaded —
   with the display name beside it, one compact row. No background
   box, so it adds only one row of height to the palette. */
.exam-user-card { display:flex; align-items:center; gap:10px; margin-bottom:8px; min-width:0; }
.exam-user-avatar { width:36px; height:36px; min-width:36px; min-height:36px; border-radius:50%; object-fit:cover; flex:none; }
.exam-user-initials { display:inline-flex; align-items:center; justify-content:center; background:var(--grad-brand, linear-gradient(135deg,#4f46e5,#7c3aed)); color:#fff; font-weight:800; font-size:1rem; }
.exam-user-name { font-weight:700; font-size:.98rem; color:#111827; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
[data-theme="dark"] .exam-user-name { color:#f1f5f9; }
/* Legend (colour-indication boxes): soft card, rounded colour chips,
   count as a pill badge, subtle separators between rows. The state
   colours and counts are unchanged — only the spacing (pass 6). */
.exam-legend { display:flex; flex-direction:column; margin-bottom:8px; font-size:.9rem; background:rgba(255,255,255,.65); border:1px solid #dbe7f3; border-radius:12px; padding:3px 12px; }
.exam-legend > div { display:flex; align-items:center; gap:8px; padding:5px 0; }
.exam-legend > div + div { border-top:1px solid #e2e8f0; }
.exam-legend > div.exam-legend-am { white-space:normal; }
.exam-legend-label { flex:1; min-width:0; }
.exam-legend-count { flex:none; margin-left:auto; background:#eef2f7; border:1px solid #e2e8f0; color:#1e293b; border-radius:999px; padding:1px 8px; font-weight:700; font-size:.82rem; min-width:30px; text-align:center; }
.exam-legend-note { font-size:.8rem; color:#4b5563; }
.exam-dot { position:relative; width:18px; height:18px; border-radius:6px; display:inline-block; flex:none; box-shadow:0 1px 3px rgba(15,23,42,.25); }
.exam-dot-tick { position:absolute; top:-7px; right:-7px; width:14px; height:14px; border-radius:50%; background:#43A047; color:#fff; font-size:9px; font-weight:800; display:flex; align-items:center; justify-content:center; border:1px solid #fff; line-height:1; }
/* Pass 34: the blue subject-name strip is shown again (pass 6 hid
   it; the user asked for the subject name above the user card on
   desktop too). Restored pre-pass-6 styling — blue #1a7fd4, white
   bold text — with the negative side margins matched to the palette
   scroll padding (12px) so the strip runs edge to edge without
   overflow, and the bottom margin matched to the legend / user-card
   8px rhythm. Desktop only: at <=1023px the palette is a drawer and
   the subject name already shows at its top (the dark-bar title
   relocated there by exam.js), so the strip stays hidden there and
   the mobile drawer is unchanged. The name itself is kept current by
   exam.js showQuestion(), which already sets #palette-section-name
   alongside the dark-bar title. */
.exam-palette-section { background:#1a7fd4; color:#fff; font-weight:700; padding:8px 14px; margin:0 -12px 8px; }
@media (max-width:1023px) {
  .exam-palette-section { display:none; }
}
.exam-grid-title { margin:0 0 8px; font-size:.95rem; font-weight:700; color:#111827; }
.exam-grid { display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; }
.exam-grid button { position:relative; min-width:0; min-height:44px; border:1px solid #9E9E9E; border-radius:6px; cursor:pointer; font-weight:700; font-size:.95rem; font-family:inherit; background:#fff; color:#474747; }
.exam-grid button.st-answered { background:#43A047; border-color:#43A047; color:#fff; }
.exam-grid button.st-not_answered { background:#E53935; border-color:#E53935; color:#fff; }
.exam-grid button.st-marked { background:#7B1FA2; border-color:#7B1FA2; color:#fff; }
.exam-grid button.st-answered_marked { background:#8E24AA; border-color:#8E24AA; color:#fff; }
.exam-grid-tick { position:absolute; top:-7px; right:-7px; width:16px; height:16px; border-radius:50%; background:#43A047; color:#fff; font-size:10px; font-weight:800; display:flex; align-items:center; justify-content:center; border:1px solid #fff; line-height:1; }
.exam-grid button.current { outline:2px solid #E53935; outline-offset:1px; }
.exam-drawer-backdrop { display:none; }
.exam-drawer-close { display:none; }
/* Collapse arrow on the palette's left edge (desktop / tablet landscape). */
.exam-palette-edge { position:absolute; left:-14px; top:44%; z-index:5; width:28px; height:56px; background:#e2e8f0; border:1px solid #cbd5e1; border-right:0; border-radius:6px 0 0 6px; color:#334155; font-size:20px; line-height:1; cursor:pointer; padding:0; }
.exam-palette-edge:hover { background:#cbd5e1; }
/* Show/hide tab for the drawer (mobile / tablet portrait only). */
.exam-palette-edge-tab { display:none; }
/* Submit sits at the bottom of the palette column, pinned there
   (bottom:0 of the column on desktop / tablet landscape; bottom of
   the palette drawer on mobile / tablet portrait) — always visible
   without scrolling the palette grid. */
.exam-palette-submit { flex:none; padding:12px 14px; border-top:1px solid #cfe0f0; background:#eaf3fb; position:sticky; bottom:0; z-index:3; }
.exam-palette-submit .exam-btn { width:100%; justify-content:center; }

/* ---------- Bottom bar (question column): fixed to the bottom of
   the question column ----------
   The bar is grid row 3 of the question column, inside the same grid
   cell as the question box — so its width equals the question box
   width exactly (never under the palette), at every viewport width. */
.exam-qbar { background:#fff; border-top:1px solid #e5e7eb; padding:8px 16px; }
.exam-qbar-buttons { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
/* Flexible bar buttons: they share the row and shrink (font + width)
   so every enabled button fits without overlap or cut-off at 360px. */
.exam-qbar-buttons .exam-btn { flex:1 1 auto; min-width:0; font-size:clamp(11px, 2.6vw, 13px); padding:6px clamp(8px, 2vw, 18px); white-space:nowrap; }
.exam-btn { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:6px 18px; border-radius:4px; border:1px solid #dededd; background:#fff; color:#000; cursor:pointer; font-size:13px; font-weight:600; font-family:inherit; box-shadow:none; }
.exam-btn-white:hover { background:#1a7fd4; border-color:#1a7fd4; color:#fff; }
.exam-btn-blue { background:#1a7fd4; border-color:#1a7fd4; color:#fff; }
.exam-btn-blue:hover { background:#1565b0; border-color:#1565b0; }
.exam-btn-green { background:#5cb85c; border-color:#4cae4c; color:#fff; }
.exam-btn-green:hover { background:#449d44; border-color:#398439; }
.exam-btn-orange { background:#f0ad4e; border-color:#eea236; color:#fff; }
.exam-btn-orange:hover { background:#ec971f; border-color:#d58512; }
.exam-btn-submit { background:#1a7fd4; border-color:#1a7fd4; color:#fff; }
.exam-btn-submit:hover { background:#1565b0; border-color:#1565b0; }
.exam-btn-submit:disabled { background:#74c5f0; border-color:#74c5f0; cursor:not-allowed; }
.exam-btn-locked { background:#52657d; border-color:#52657d; color:#fff; }
.exam-btn-locked:hover { background:#42536a; border-color:#42536a; }
/* Pass 13: locked Submit — a standalone lock icon sits BEFORE the
   Submit button (palette submit + overview-off bottom bar) in preview
   mode, server-rendered only when the quiz is locked. Tapping the icon
   opens the unlock modal, same as Submit. 44px touch target, clear at
   desktop and at 360px. */
.exam-submit-lock { flex:none; width:44px; min-height:44px; display:inline-flex; align-items:center; justify-content:center; font-size:1.3rem; line-height:1; background:#fff; border:1px solid #cbd5e1; border-radius:8px; cursor:pointer; padding:0; }
.exam-submit-lock:hover { background:#f1f5f9; border-color:#94a3b8; }
[data-theme="dark"] .exam-submit-lock { background:#1e293b; border-color:#475569; }
[data-theme="dark"] .exam-submit-lock:hover { background:#334155; }
.exam-palette-submit { display:flex; align-items:center; gap:10px; }
.exam-palette-submit .exam-btn { flex:1 1 auto; min-width:0; width:auto; }
.exam-btn:disabled { opacity:.65; cursor:not-allowed; }
.clear-short, .mark-short, .save-short { display:none; }
.exam-save-status { font-size:.9rem; color:var(--muted, #6b7280); display:block; }
.exam-save-status:empty { display:none; }

/* ---------- Modals ---------- */
.exam-modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); display:none; align-items:center; justify-content:center; z-index:60; padding:16px; }
.exam-modal-backdrop.open { display:flex; }
.exam-modal { background:var(--surface, #fff); color:var(--text, #111827); border:1px solid var(--border, #e5e7eb); border-radius:var(--radius, 12px); padding:24px; max-width:480px; width:100%; max-height:85vh; overflow-y:auto; }
.exam-modal-wide { max-width:640px; }
.exam-modal h2 { margin-top:0; }
/* Pass 16: the submit modal is wider than the default so the 8-column
   subject table fits without scrolling on desktop (still width:100% on
   phones). */
.exam-modal.exam-submit-wide { max-width:860px; }
/* Pass 16: subject-wise submit-confirmation table (built live by exam.js
   into #submit-counts). Horizontally scrollable on narrow screens so the
   8 columns never break the modal. */
.exam-submit-counts { overflow-x:auto; margin:12px 0 4px; }
.exam-submit-counts table { width:100%; border-collapse:collapse; font-size:.85rem; }
.exam-submit-counts th, .exam-submit-counts td { padding:8px 8px; border:1px solid var(--border, #e5e7eb); text-align:center; white-space:nowrap; }
.exam-submit-counts th:first-child, .exam-submit-counts td:first-child { text-align:left; white-space:normal; }
.exam-submit-counts thead th { background:var(--surface-2, #f3f4f6); font-weight:700; }
.exam-submit-counts tfoot td { font-weight:800; background:var(--surface-2, #f3f4f6); }
.exam-submit-note { font-size:.85rem; color:var(--muted, #6b7280); margin:4px 0 0; }
.exam-modal .row { display:flex; gap:10px; justify-content:flex-end; margin-top:18px; flex-wrap:wrap; }
/* Pass 13: locked-Submit unlock modal — where this quiz is available
   (direct buy, memberships, courses, test series). Rows wrap and the
   buttons go full-width at <=480px so the modal stays usable at 360px;
   the modal itself already scrolls (max-height:85vh, overflow-y:auto). */
.exam-modal h3 { margin:18px 0 6px; font-size:1rem; }
.exam-unlock-list { list-style:none; margin:0 0 8px; padding:0; }
.exam-unlock-list li { display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:10px 0; border-bottom:1px solid var(--border, #e5e7eb); }
.exam-unlock-list li:last-child { border-bottom:0; }
.exam-unlock-name { flex:1 1 160px; min-width:0; font-weight:600; }
.exam-unlock-meta { display:block; font-weight:400; font-size:.85rem; color:var(--muted, #6b7280); }
.exam-unlock-price { font-weight:700; white-space:nowrap; }
.exam-unlock-list .btn { white-space:nowrap; text-align:center; }
@media (max-width:480px) {
  .exam-unlock-list .btn { flex:1 1 100%; justify-content:center; }
}
.exam-result-ring { width:180px; height:180px; border-radius:50%; display:flex; flex-direction:column; align-items:center; justify-content:center; margin:0 auto; color:#fff; font-weight:700; }
.exam-review-q { margin-bottom:20px; }
.exam-review-q .correct-opt { border-color:var(--success, #43a047) !important; background:#e8f5e9 !important; }
.exam-review-q .wrong-opt { border-color:var(--danger, #e53935) !important; background:#fdecea !important; }
.exam-badge { display:inline-block; padding:2px 10px; border-radius:999px; font-size:.85rem; font-weight:700; }
.exam-badge.pass { background:#dcfce7; color:#166534; }
.exam-badge.fail { background:#fee2e2; color:#991b1b; }
.exam-badge.pending { background:#fef3c7; color:#92400e; }

/* Start screen */
.exam-start-facts { line-height:1.9; padding-left:20px; }
.exam-count-picker { border:1px solid var(--border, #e5e7eb); border-radius:10px; padding:14px 16px; margin:16px 0; color:var(--text, #111827); }
.exam-count-picker legend { font-weight:700; padding:0 6px; }
.exam-count-options { display:flex; flex-wrap:wrap; gap:10px; }
.exam-count-options[hidden] { display:none; }
.exam-start-hint { color:var(--muted, #6b7280); font-size:.9rem; margin:6px 0 0; }
.exam-count-opt { border:1px solid var(--border, #d1d5db); border-radius:999px; padding:8px 16px; cursor:pointer; min-height:44px; display:inline-flex; align-items:center; gap:6px; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-count-opt:has(input:checked) { border-color:var(--primary, #4f46e5); background:var(--primary-soft, #eef2ff); font-weight:700; }
.exam-count-note { color:var(--muted, #6b7280); font-size:.9rem; margin-bottom:0; }
/* Random / Sequence segmented control + From–To sequence options. */
.exam-mode-seg { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom:12px; }
.exam-mode-label { font-weight:600; }
.exam-mode-opt { border:1px solid var(--border, #d1d5db); border-radius:999px; padding:8px 16px; cursor:pointer; min-height:44px; display:inline-flex; align-items:center; gap:6px; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-mode-opt:has(input:checked) { border-color:var(--primary, #4f46e5); background:var(--primary-soft, #eef2ff); font-weight:700; }
.exam-seq-opts { display:flex; flex-wrap:wrap; align-items:center; gap:14px; margin-top:12px; }
.exam-seq-opts[hidden] { display:none; }
.exam-seq-opt { display:inline-flex; align-items:center; gap:6px; cursor:pointer; min-height:44px; }
.exam-range { display:inline-flex; align-items:center; gap:6px; flex-wrap:wrap; }
.exam-range[hidden] { display:none; }
.exam-range input[type="number"], .exam-count-custom input[type="number"] { width:72px; min-height:40px; padding:6px 8px; border:1px solid var(--border, #d1d5db); border-radius:8px; font-size:1rem; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-count-custom input[type="number"] { width:64px; min-height:36px; }
.exam-start-btn { min-height:48px; padding:10px 28px; font-size:1.05rem; }
.exam-lock ul { line-height:2; }
.exam-muted { color:var(--muted, #6b7280); }
.exam-note-amber { color:var(--warning, #92400e); background:#fef3c7; border-radius:8px; padding:10px; }

/* Scientific calculator — draggable popup (desktop), bottom sheet (mobile) */
.calc-panel { position:fixed; z-index:70; width:463px; max-width:calc(100vw - 16px); background:var(--surface, #f5f5f5); color:var(--text, #111827); border:1px solid var(--border, #999); box-shadow:0 8px 30px rgba(0,0,0,.35); top:80px; right:24px; font-family:Arial, Helvetica, sans-serif; user-select:none; }
.calc-titlebar { display:flex; justify-content:space-between; align-items:center; background:var(--primary, #0c7cd5); color:#fff; padding:6px 10px; cursor:move; font-weight:700; font-size:14px; touch-action:none; }
.calc-titlebar button { background:transparent; border:1px solid rgba(255,255,255,.6); color:#fff; min-width:32px; min-height:32px; border-radius:4px; cursor:pointer; font-size:15px; margin-left:4px; }
.calc-body { padding:10px; }
.calc-body.minimised { display:none; }
.calc-expr { width:100%; box-sizing:border-box; border:1px solid var(--border, #bbb); background:var(--surface, #fff); color:var(--muted, #333); font-size:13px; padding:6px 8px; min-height:30px; text-align:right; }
.calc-display-row { display:flex; align-items:center; gap:6px; margin-top:4px; }
.calc-entry { flex:1; box-sizing:border-box; border:1px solid var(--border, #bbb); background:var(--surface, #fff); color:var(--text, #111827); font-size:22px; padding:6px 8px; min-height:44px; text-align:right; }
.calc-memory { font-size:13px; font-weight:700; color:var(--primary, #0c7cd5); }
.calc-row { display:flex; gap:4px; margin-top:5px; }
.calc-key { flex:1 1 0; min-width:0; min-height:44px; border:1px solid var(--border, #999); border-radius:3px; background:var(--surface, #fff); color:var(--text, #111827); font-size:13px; cursor:pointer; padding:2px; white-space:nowrap; overflow:hidden; }
.calc-key:hover { background:var(--primary-soft, #dbeafe); }
.calc-key:active { background:var(--primary-soft, #bfdbfe); }
.calc-num { background:var(--surface, #fff); font-weight:700; }
.calc-op { background:var(--bg, #e8e8e8); }
.calc-fn { background:var(--bg, #f0f0f0); font-size:12px; }
.calc-const { background:var(--bg, #e8f5e9); }
.calc-mem { background:var(--bg, #fff8e1); font-size:12px; }
.calc-cmd { background:var(--bg, #ffecb3); font-weight:700; }
.calc-eq { background:var(--primary, #0c7cd5); color:#fff; border-color:var(--primary, #0c7cd5); font-size:18px; }
.calc-degrad { flex:2 1 0; display:flex; align-items:center; gap:8px; font-size:12px; }
.calc-degrad label { display:flex; align-items:center; gap:3px; cursor:pointer; }
.calc-note { font-size:11px; color:var(--muted, #666); margin:8px 0 0; line-height:1.5; }

/* ---------- Dark mode (follows the site's data-theme) ---------- */
[data-theme="dark"] .exam-shell { background:#0b1120; }
[data-theme="dark"] .exam-topbar-ref { background:#1a2438; border-bottom-color:#2b3a55; }
[data-theme="dark"] .exam-title { color:#f1f5f9; }
[data-theme="dark"] .exam-back { color:#e2e8f0; }
[data-theme="dark"] .exam-calc-btn { color:#e2e8f0; }
[data-theme="dark"] .exam-calc-btn:hover { background:#2b3a55; color:#7fb8ec; }
[data-theme="dark"] .exam-back:hover { color:#7fb8ec; }
[data-theme="dark"] .exam-darkbar { background:var(--exam-timebar-bg, #1a1a1a); }
[data-theme="dark"] .exam-preview-banner { background:#451a03; color:#fde68a; border-bottom-color:#78350f; }
[data-theme="dark"] .exam-main-col,
[data-theme="dark"] .exam-sections-row,
[data-theme="dark"] .exam-scroll { background:#1a2438; }
[data-theme="dark"] .exam-sections-label { color:#f1f5f9; }
[data-theme="dark"] .exam-tabs-arrow { background:#2b3a55; border-color:#3d4f6e; color:#e2e8f0; }
[data-theme="dark"] .exam-subject-tabs button[data-subject] { background:#2b3a55; border-color:#3d4f6e; color:#e2e8f0; }
[data-theme="dark"] .exam-subject-tabs button[data-subject].active { background:#1a7fd4; border-color:#1a7fd4; color:#fff; }
[data-theme="dark"] .exam-panel.exam-card { background:#1a2438; }
[data-theme="dark"] .exam-qtype-row,
[data-theme="dark"] .exam-qno,
[data-theme="dark"] .exam-qtext { color:#f1f5f9; }
[data-theme="dark"] .exam-marks-pos { background:#43A047; }
[data-theme="dark"] .exam-marks-neg { background:#EF5350; }
[data-theme="dark"] .exam-option { background:#1a2438; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-option:hover { border-color:#1a7fd4; }
[data-theme="dark"] .exam-option.selected { background:#1e3a5f; border-color:#1a7fd4; }
[data-theme="dark"] .exam-hint { background:#2b2305; border-color:#713f12; color:#fde68a; }
[data-theme="dark"] .exam-match-row select,
[data-theme="dark"] .exam-textarea,
[data-theme="dark"] .exam-blank { background:#1a2438; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-palette { background:#16233a; border-left-color:#2b3a55; color:#e2e8f0; }
[data-theme="dark"] .exam-grid-title { color:#f1f5f9; }
[data-theme="dark"] .exam-legend { background:rgba(43,58,85,.55); border-color:#2b3a55; }
[data-theme="dark"] .exam-legend > div + div { border-color:#2b3a55; }
[data-theme="dark"] .exam-legend-count { background:#2b3a55; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-legend-note { color:#94a3b8; }
[data-theme="dark"] .exam-report-btn { background:transparent; border:0; color:#fbbf24; }
[data-theme="dark"] .exam-report-btn:hover { background:#3b2f0b; }
[data-theme="dark"] .exam-grid button { background:#2b3a55; border-color:#64748b; color:#f1f5f9; }
[data-theme="dark"] .exam-grid button.st-answered { background:#43A047; border-color:#43A047; color:#fff; }
[data-theme="dark"] .exam-grid button.st-not_answered { background:#E53935; border-color:#E53935; color:#fff; }
[data-theme="dark"] .exam-grid button.st-marked { background:#7B1FA2; border-color:#7B1FA2; color:#fff; }
[data-theme="dark"] .exam-grid button.st-answered_marked { background:#8E24AA; border-color:#8E24AA; color:#fff; }
[data-theme="dark"] .exam-palette-edge { background:#2b3a55; border-color:#3d4f6e; color:#e2e8f0; }
[data-theme="dark"] .exam-palette-submit { background:#16233a; border-top-color:#2b3a55; }
[data-theme="dark"] .exam-qbar { background:#1a2438; border-top-color:#2b3a55; }
[data-theme="dark"] .exam-qbar .exam-btn-white { background:#2b3a55; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-qbar .exam-btn-white:hover { background:#1a7fd4; border-color:#1a7fd4; color:#fff; }
[data-theme="dark"] .exam-save-status { color:#94a3b8; }

/* ---------- Palette top control box (pass 6) ----------
   ONE single row — dark-mode toggle, question font sizer (A− / A+),
   instruction icon — on desktop, tablet and mobile alike. Compact
   icon-sized controls with small gaps and no wrapping, so the row
   holds on one line even at 360px. The row lives at the top of the
   palette scroll area, above the legend. */
.exam-drawer-controls { display:flex; align-items:center; gap:8px; flex-wrap:nowrap; margin-bottom:8px; }
.exam-drawer-controls .theme-toggle { flex:none; width:36px; height:36px; min-width:36px; min-height:36px; padding:0; }
.exam-font-sizer { display:inline-flex; align-items:center; gap:2px; flex:none; }
.exam-font-step { display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; min-width:36px; min-height:36px; padding:0; border:1px solid var(--border, #d1d5db); background:var(--surface, #fff); color:var(--text, #111827); border-radius:8px; font-size:.95rem; font-weight:700; font-family:inherit; cursor:pointer; }
.exam-font-step:hover { border-color:#1a7fd4; color:#1a7fd4; }
.exam-font-sizer-current { min-width:22px; text-align:center; font-weight:800; font-size:1rem; color:var(--text, #111827); }
.exam-drawer-controls .exam-instr-btn { flex:none; width:36px; height:36px; min-width:36px; min-height:36px; padding:0; justify-content:center; border-radius:8px; color:#1a7fd4; }
.exam-drawer-controls .exam-instr-btn:hover { color:#0d5fa8; background:rgba(26,127,212,.1); }
.exam-drawer-controls .exam-instr-btn .exam-info-ic { width:22px; height:22px; font-size:14px; }
[data-theme="dark"] .exam-drawer-controls .exam-instr-btn { color:#7fb8ec; }
[data-theme="dark"] .exam-drawer-controls .exam-instr-btn:hover { background:rgba(127,184,236,.15); }

/* ---------- Mobile instruction panel ----------
   On phones (≤767px) and tablet portrait, exam.js moves the dark
   bar's section title into the palette drawer (top), and the dark bar
   becomes a slim timer-only row — so the question box gets maximum
   height. Pass 7: only the section title moves (the language menu
   used to move with it; it now lives in the top bar). The palette
   top control box (dark-mode toggle, font sizer, instruction icon)
   is rendered server-side above it on every screen size. Desktop and
   tablet landscape keep the full dark bar (no class = no change). */
.exam-drawer-instructions { display:none; }
.exam-shell.exam-mobile-instructions .exam-darkbar { min-height:30px; padding:2px 12px; justify-content:center; }
.exam-shell.exam-mobile-instructions .exam-darkbar-time { flex:none; text-align:center; font-size:.95rem; }
.exam-shell.exam-mobile-instructions .exam-drawer-instructions { display:flex; flex-direction:column; gap:10px; background:rgba(255,255,255,.7); border:1px solid #dbe7f3; border-radius:12px; padding:12px; margin-bottom:8px; }
.exam-shell.exam-mobile-instructions .exam-drawer-instructions .exam-darkbar-section { color:#12294d; max-width:none; font-size:1rem; }
[data-theme="dark"] .exam-shell.exam-mobile-instructions .exam-drawer-instructions { background:rgba(43,58,85,.55); border-color:#2b3a55; }
[data-theme="dark"] .exam-shell.exam-mobile-instructions .exam-drawer-instructions .exam-darkbar-section { color:#f1f5f9; }

/* ---------- Tablet portrait / mobile: palette becomes a drawer ---------- */
@media (max-width:1023px) {
  .exam-layout-ref { grid-template-columns:minmax(0, 1fr); }
  .exam-shell.exam-collapsed .exam-layout-ref { grid-template-columns:minmax(0, 1fr); }
  .exam-drawer-backdrop { display:none; position:fixed; inset:0; z-index:49; background:rgba(0,0,0,.45); }
  .exam-drawer-backdrop.open { display:block; }
  body.exam-drawer-open { overflow:hidden; }
  .exam-palette { position:fixed; top:0; right:0; bottom:0; width:min(340px, 92vw); z-index:50; border-left:0; box-shadow:-4px 0 16px rgba(0,0,0,.2); transform:translateX(105%); transition:transform .25s ease; }
  .exam-palette.open { transform:translateX(0); }
  .exam-drawer-close { display:inline-block; min-width:44px; min-height:44px; float:right; border:1px solid var(--border, #d1d5db); background:var(--surface, #fff); color:var(--text, #111827); border-radius:8px; font-size:1.2rem; cursor:pointer; }
  .exam-palette-edge-tab { display:flex; align-items:center; justify-content:center; position:fixed; right:0; top:45%; z-index:48; width:30px; height:60px; background:#1a7fd4; border:0; border-radius:8px 0 0 8px; color:#fff; font-size:22px; line-height:1; cursor:pointer; padding:0; box-shadow:-2px 0 8px rgba(0,0,0,.2); }
  body.exam-drawer-open .exam-palette-edge-tab { display:none; }
  .exam-palette-edge { left:-14px; }
  /* Calculator: icon-only button at ≤1023px (44px touch target, same
     topbar position); the text label is hidden, the glyph shown. */
  .exam-calc-btn { width:44px; height:44px; min-height:44px; padding:0; }
  .exam-calc-btn .exam-calc-label { display:none; }
  .exam-calc-btn .exam-calc-icon { display:inline-flex; }
  .calc-panel { top:auto !important; bottom:0; left:0 !important; right:0; width:100%; max-width:100%; max-height:72vh; overflow-y:auto; border-radius:12px 12px 0 0; }
  .calc-titlebar { cursor:default; }
  .calc-key { min-height:48px; font-size:14px; }
}
@media (max-width:640px) {
  /* Dark bar wraps: section on row one, Time Left centred on its own row. */
  .exam-darkbar { gap:8px; padding:5px 10px; }
  .exam-darkbar-section { max-width:46%; font-size:.92rem; }
  .exam-darkbar-time { order:3; flex:1 1 100%; font-size:.95rem; }
  .exam-topbar-ref { padding:2px 8px; gap:8px; min-height:38px; }
  /* Pass 5 fix (verification): the header buttons stay 44px tap
     targets on mobile (SPEC: tap targets >= 44px) even though the bar
     itself is compact — the 40px min-height + 4px padding still make
     the rendered bar shorter than pass 4 (53px vs 57px). Shrinking
     these buttons to 40px broke the pass-3 calculator check. */
  .exam-back { width:44px; height:44px; min-width:44px; min-height:44px; }
  .exam-brand-logo { height:22px; }
  .exam-brand-mark { width:22px; height:22px; }
  .exam-calc-btn { width:44px; height:44px; min-height:44px; }
  .exam-title { font-size:1rem; }
  .exam-sections-row { padding:8px 10px 0; }
  .exam-scroll { padding:8px 10px 12px; }
  .exam-qbar { padding:6px 10px; }
  .exam-qbar-buttons { gap:6px; }
  .exam-btn { padding:6px 12px; font-size:12px; min-height:44px; }
  .exam-subject-tabs button[data-subject] { flex:0 0 auto; }
  .exam-shell .font-size-btn .fs-btn-name { display:none; }
}
@media (max-width:480px) {
  .exam-panel.exam-card { padding:4px 2px 16px; }
  .exam-qtext { font-size:1rem; }
  .clear-long, .mark-long, .save-long { display:none; }
  .clear-short, .mark-short, .save-short { display:inline; }
  .calc-key { font-size:12px; min-height:46px; }
}

/* ---------- Short viewports (phone landscape) ----------
   Pass 7: the sections row is NO LONGER hidden here. Pass 6 hid it
   because the wrapping tabs made the row ~90px tall and starved the
   flex column; with nowrap (pass 7) the row is exactly one tab tall,
   so it stays visible as a single scrollable row at every height.
   The minimum heights below still guarantee the question stays
   readable and at least one option stays reachable. */
@media (max-height:500px) {
  .exam-panel.exam-card { padding-bottom:8px; }
  .exam-qtext { min-height:2.2em; }
  .exam-answer { min-height:44px; }
}

/* ---------- Pass 5: bottom bar pinned to the visual viewport ----------
   The shell already uses 100dvh, but phones with a dynamic toolbar /
   home indicator still need the safe-area inset or the bar's bottom
   padding eats into the last row of buttons. env() is 0 where the
   browser does not support it, so desktop is unchanged. Placed last
   so it wins over the padding shorthands above. */
.exam-qbar { padding-bottom:calc(8px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Pass 16: start screen + instruction page ----------
   Global site header on, site footer off (see header.php
   $ew_global_header + $GLOBALS['ew_no_footer']). Back arrow sits in a
   slim bar under the global header; the Start button is pinned in a
   bottom bar fixed at bottom:0 with the button centred; the page
   content gets bottom padding so the bar never overlaps it. */
.exam-start-backbar { padding:12px 20px 0; }
.exam-back-arrow { display:inline-flex; align-items:center; gap:6px; min-height:44px; padding:8px 16px; border:1px solid var(--border, #d1d5db); border-radius:999px; background:var(--surface, #fff); color:var(--text, #111827); text-decoration:none; font-weight:600; cursor:pointer; }
.exam-back-arrow:hover { border-color:var(--primary, #4f46e5); color:var(--primary, #4f46e5); }
.exam-start-bottombar { position:fixed; left:0; right:0; bottom:0; z-index:60; display:flex; justify-content:center; align-items:center; gap:10px; padding:10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background:var(--surface, #fff); border-top:1px solid var(--border, #e5e7eb); box-shadow:0 -4px 16px rgba(0,0,0,.08); }
.exam-start-bottombar .exam-start-btn { margin:0; }
.exam-universal-instructions { background:var(--bg, #f4f6fb); border-left:4px solid var(--primary, #4f46e5); border-radius:8px; padding:12px 14px; margin:0 0 16px; }
.exam-universal-instructions h3 { margin:0 0 8px; }
[data-theme="dark"] .exam-start-bottombar { background:#1a2438; border-top-color:#2b3a55; }
[data-theme="dark"] .exam-back-arrow { background:#1a2438; border-color:#3d4f6e; color:#f1f5f9; }
[data-theme="dark"] .exam-universal-instructions { background:#16233a; }

/* ---------- Pass 8: full-width start screen + instruction page ----------
   The exam start screen and the instruction page between it and the
   exam screen are FULL WIDTH — no centred narrow container, no side
   gutters — the same treatment as the exam screen itself. The site
   header stays; only the content card goes edge to edge. */
.exam-start-main { margin:0; padding:0 0 96px; }
.exam-start-full { margin:0; max-width:none; border-radius:0; border-left:0; border-right:0; padding:24px 20px; }
.exam-instr-page { margin:0; max-width:none; border-radius:0; border-left:0; border-right:0; padding:24px 20px; }
.exam-instr-page h2 { margin:24px 0 10px; }
.exam-instr-table { width:100%; border-collapse:collapse; margin:8px 0 4px; background:var(--surface, #fff); color:var(--text, #111827); }
.exam-instr-table th, .exam-instr-table td { border:1px solid var(--border, #e5e7eb); padding:10px 12px; text-align:left; }
.exam-instr-table thead th { background:var(--primary, #4f46e5); color:#fff; font-weight:700; }
.exam-instr-table tfoot th { background:var(--bg, #f4f6fb); font-weight:800; }
.exam-instr-table tbody tr:nth-child(even) td { background:var(--bg, #f9fafb); }
.exam-instr-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin:24px 0 8px; }
[data-theme="dark"] .exam-instr-table thead th { background:#3730a3; }
[data-theme="dark"] .exam-instr-table tfoot th { background:#1a2438; }
[data-theme="dark"] .exam-instr-table tbody tr:nth-child(even) td { background:#16233a; }
@media (max-width:640px) {
  .exam-start-full, .exam-instr-page { padding:16px 12px; }
  .exam-instr-table th, .exam-instr-table td { padding:8px; }
}

/* ---------- v1.0.27 ---------- */
/* Colourful light gradient around "How many questions do you want to
   attempt?" — the legend itself is a bright gradient pill, the picker
   has a pastel gradient border, and the selected Random / count pill
   gets a soft pastel gradient fill. */
.exam-count-picker-gradient { border:2px solid transparent; background:linear-gradient(var(--surface, #fff), var(--surface, #fff)) padding-box, linear-gradient(120deg, #f0abfc, #a5b4fc, #67e8f9, #86efac, #fde68a) border-box; border-radius:16px; box-shadow:0 4px 18px rgba(139, 92, 246, .12); }
.exam-count-picker-gradient legend { background:linear-gradient(90deg, #ec4899, #8b5cf6, #3b82f6, #06b6d4, #22c55e); color:#fff; padding:6px 16px; border-radius:999px; font-weight:800; box-shadow:0 2px 8px rgba(139, 92, 246, .35); }
.exam-count-picker-gradient .exam-count-opt:has(input:checked), .exam-count-picker-gradient .exam-mode-opt:has(input:checked) { background:linear-gradient(120deg, #fce7f3, #e0e7ff, #cffafe); border-color:#a78bfa; color:#4c1d95; }
[data-theme="dark"] .exam-count-picker-gradient { background:linear-gradient(#1e293b, #1e293b) padding-box, linear-gradient(120deg, #f0abfc, #a5b4fc, #67e8f9, #86efac, #fde68a) border-box; }
[data-theme="dark"] .exam-count-picker-gradient .exam-count-opt:has(input:checked), [data-theme="dark"] .exam-count-picker-gradient .exam-mode-opt:has(input:checked) { background:linear-gradient(120deg, #4c1d95, #1e3a8a); border-color:#a78bfa; color:#fff; }

/* Exam top-bar Aa (same panel as the main header). The dropdown is
   position:fixed in style.css, so it drops below the top bar. */
.exam-topbar-ref .aa-menu { flex:none; }
.exam-topbar-ref .aa-btn { width:40px; height:40px; min-width:40px; min-height:40px; }
.exam-aa-dropdown .aa-lang-row { font-weight:700; }
.exam-aa-dropdown .exam-lang-opt { width:100%; }
.exam-aa-dropdown .aa-search input { width:100%; }

/* Palette: Question Paper button (replaces dark-mode + font sizer). */
.exam-drawer-controls .exam-qpaper-btn { flex:1; display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:40px; padding:8px 12px; border:1px solid #d1d5db; border-radius:10px; background:linear-gradient(120deg, #eef2ff, #fdf4ff); color:#4f46e5; font-weight:700; font-size:.95rem; font-family:inherit; cursor:pointer; }
.exam-drawer-controls .exam-qpaper-btn:hover { border-color:#a78bfa; background:linear-gradient(120deg, #e0e7ff, #fae8ff); }
[data-theme="dark"] .exam-drawer-controls .exam-qpaper-btn { background:linear-gradient(120deg, #312e81, #4c1d95); border-color:#6366f1; color:#fff; }
/* Question Paper popup: numbered list, subject in small caps, no options. */
.exam-qpaper-modal { max-width:760px; }
.exam-qpaper-list { margin:12px 0; padding-left:26px; line-height:1.55; }
.exam-qpaper-list li { margin-bottom:14px; }
.exam-qpaper-subject { display:block; font-size:.78rem; font-weight:700; letter-spacing:.04em; text-transform:uppercase; color:var(--primary, #4f46e5); margin-bottom:2px; }

/* Offline exam (v1.0.27): amber banner while the exam is offline. exam.js
   toggles body.exam-offline and sets the banner text; the banner is
   created by exam.js at the top of the exam shell. */
#exam-offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #f59e0b;
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}
body.exam-offline #exam-offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
[data-theme="dark"] #exam-offline-banner {
  background: #451a03;
  color: #fde68a;
  border-bottom-color: #92400e;
}
/* Cancel button for a mistaken offline submit (v1.0.27): only shown
   while a student-requested submit is waiting for the network. */
.exam-offline-cancel {
  background: #ffffff;
  color: #92400e;
  border: 1px solid #d97706;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.exam-offline-cancel:hover { background: #ffedd5; }
[data-theme="dark"] .exam-offline-cancel {
  background: transparent;
  color: #fde68a;
  border-color: #92400e;
}
[data-theme="dark"] .exam-offline-cancel:hover { background: #78350f; }
