/* ==========================================================================
   Quiz Manager — createquiz.css
   Paper / workbook authoring system: warm paper ground, black structural
   borders, serif titles, uppercase Helvetica metadata. Building a quiz should
   feel like setting an exam paper, not filling a SaaS form. Colour is reserved
   and meaningful — blue == selected / active, green == correct / confirm,
   red == error / delete, amber == non-blocking warning. Mathematics keeps its
   own Computer Modern type (MathJax previews are never re-fonted). Motion is
   fade-only — no scale, lift, bounce or glow.
   ========================================================================== */

:root{
    --bg:          #e8e4dc;   /* paper page ground */
    --surface:     #efede8;   /* raised card / panel */
    --surfaceAlt:  #e1ddd4;   /* hover / nested wash */
    --field:       #f5f3ee;   /* input + writing surfaces — clearly visible */
    --border:      #111111;   /* structural black */
    --border2:     #111111;   /* (kept black; width differentiates weight) */
    --hair:        rgba(17,17,17,.18);   /* faint inner row dividers */
    --text:        #111111;
    --textMuted:   #6d685f;
    /* Colour is restrained and meaningful — never decorative. A single muted
       blue carries "active / selected"; amber warns; green confirms; red blocks.
       Question types get muted, distinct hues so they read at a glance. */
    --accent:      #2f5f8f;   /* blue == active / selected */
    --accentHover: #244c73;
    --accentSoft:  rgba(47, 95, 143, .12);
    --danger:      #b84f4f;   /* red == blocking error / delete */
    --dangerHover: #a23f3f;
    --dangerSoft:  rgba(184, 79, 79, .10);
    --warning:     #9a7a3f;   /* amber == non-blocking warning */
    --warningSoft: rgba(154, 122, 63, .14);
    --success:     #4f8f68;   /* green == confirmation / correct */
    --successSoft: rgba(79, 143, 104, .12);

    /* Muted, colour-coded answer-format labels (editorial, not playful). */
    --type-mcq:     #2f5f8f;  /* blue   */
    --type-short:   #3f7f6f;  /* teal   */
    --type-math:    #6a4f9a;  /* violet */
    --type-chem:    #9a7a3f;  /* amber  */
    --type-organic: #4f8f68;  /* green  */
    --type-extended: #8f5f7a; /* plum — teacher-reviewed written response */

    --radius:      4px;
    --radiusLg:    4px;
    --speed:       .15s;
    --label-font:  Helvetica, Arial, sans-serif;
}

/* The [hidden] attribute must always win — several components below set a
   display (flex/grid) that would otherwise keep an empty element on screen.
   (This is why the draft/editing banners used to show as two empty boxes.) */
[hidden]{
    display:none !important;
}

/* ---- Access gate (teacher / admin sign-in) ---- */
.accessGate{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
    background:var(--bg);
}
.accessCard{
    width:100%;
    max-width:440px;
    background:var(--surface);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:32px;
}
.accessCard h1{ font-size:1.6rem; margin-bottom:8px; }
.accessIntro{ color:var(--textMuted); margin-bottom:20px; line-height:1.5; }
.accessCard label{
    display:block;
    font-family:var(--label-font);
    font-size:.72rem; font-weight:700; letter-spacing:.14em; text-transform:uppercase;
    color:var(--textMuted); margin-bottom:8px;
}
.accessCard input{
    width:100%;
    background:var(--field);
    border:2px solid var(--border);
    border-radius:var(--radius);
    color:var(--text);
    font:inherit; font-size:1rem;
    padding:12px 14px; margin-bottom:16px;
    outline:none;
}
.accessCard input:focus{ border-color:var(--accent); }
.accessActions{ display:flex; gap:12px; flex-wrap:wrap; }
.accessActions button{ flex:1 1 auto; }
.accessMsg{
    margin-top:14px; color:var(--danger); font-weight:600; font-size:.9rem;
    background:var(--dangerSoft); border:1px solid var(--danger);
    border-radius:var(--radius); padding:10px 12px;
}
.accessNote{ margin-top:18px; color:var(--textMuted); font-size:.82rem; line-height:1.5; }

/* ---- Mode bar (current access + admin tools + sign out) ---- */
.modeBar{
    display:flex; align-items:center; gap:12px; flex-wrap:wrap;
    margin-left:auto;
}
.modeLabel{
    font-family:var(--label-font);
    font-size:.72rem; font-weight:700; letter-spacing:.12em; text-transform:uppercase;
    padding:6px 12px; border:2px solid var(--border); border-radius:var(--radius);
}
.modeLabel.admin{ background:var(--accent); color:var(--bg); border-color:var(--accent); }
.modeLabel.teacher{ background:var(--surfaceAlt); color:var(--text); }
.adminTools{ display:inline-flex; align-items:center; gap:12px; flex-wrap:wrap; }
.showDeletedToggle{
    display:inline-flex; align-items:center; gap:6px;
    font-family:var(--label-font); font-size:.78rem; color:var(--textMuted); cursor:pointer;
}
.showDeletedToggle input{ width:16px; height:16px; accent-color:var(--accent); }

/* ---- Quiz card ownership / lifecycle badges (admin view) ---- */
.quizCardBadges{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.ownerBadge, .deletedBadge{
    font-family:var(--label-font);
    font-size:.66rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
    padding:3px 8px; border-radius:var(--radius); border:1px solid var(--hair);
    color:var(--textMuted);
}
.deletedBadge{ background:var(--dangerSoft); border-color:var(--danger); color:var(--danger); }
.quizCard.isDeleted{ opacity:.72; }

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    border-radius:0;            /* sharp by default; surfaces opt into --radius */
}

html{
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    text-rendering:optimizeLegibility;
}

body{
    background:var(--bg);
    color:var(--text);
    font-family:"Iowan Old Style", "Baskerville", "Times New Roman", Times, serif;
    font-size:17px;
    line-height:1.7;
    font-weight:400;
}

::selection{ background:#111; color:var(--bg); }

body.noScroll{
    overflow:hidden;
}

img{
    max-width:100%;
}

.wrapper{
    max-width:880px;            /* comfortable authoring column */
    margin:auto;
    padding:64px 24px 96px;
}

/* ---------- Header / tabs ---------- */

.pageHeader h1{
    font-size:38px;
    font-weight:500;
    letter-spacing:-.01em;
    margin-bottom:28px;
}

.tabs{
    display:flex;
    gap:28px;
    margin-bottom:48px;
    border-bottom:2px solid var(--border);
}

.tab{
    background:none;
    border:none;
    color:var(--textMuted);
    padding:0 0 14px;
    font-family:var(--label-font);
    font-size:12px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.16em;
    cursor:pointer;
    border-bottom:2px solid transparent;
    margin-bottom:-2px;
    transition:color var(--speed) ease, border-color var(--speed) ease;
}

.tab:hover{
    color:var(--text);
}

.tab.active{
    color:var(--text);
    border-bottom-color:var(--accent);   /* selected nav → accent */
}

/* ---------- Cards & form controls ---------- */

.card{
    background:var(--surface);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:40px;
    margin-bottom:24px;
}

label{
    display:block;
    margin-top:24px;
    margin-bottom:8px;
    font-family:var(--label-font);
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.16em;
    color:var(--textMuted);
}

input,
textarea,
select{
    width:100%;
    background:var(--field);
    border:2px solid var(--border);
    border-radius:var(--radius);
    color:var(--text);
    padding:12px 14px;
    font:inherit;
    font-size:16px;
    transition:border-color var(--speed) ease;
}

input:focus,
textarea:focus,
select:focus{
    outline:none;
    border-color:var(--accent);   /* focus == active → blue */
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible{
    outline:2px solid var(--accent);
    outline-offset:2px;
}

textarea{
    min-height:104px;
    resize:vertical;
}

select{
    margin-bottom:8px;
}

/* The quiz title reads like the title of a paper rather than a form field. */
#quizTitle{
    font-size:30px;
    font-weight:500;
    background:transparent;
    border:none;
    border-radius:0;
    border-bottom:2px solid var(--border);
    padding:8px 0;
}

#quizTitle:focus{
    border-bottom-color:var(--accent);
}

button{
    cursor:pointer;
    font:inherit;
}

button:disabled{
    opacity:.4;
    cursor:not-allowed;
}

.fieldRow{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
    gap:0 24px;
}

/* ---------- Buttons: one editorial treatment, invert on hover ---------- */

.primaryButton,
.secondaryButton,
.dangerButton{
    background:transparent;
    color:var(--text);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:12px 22px;
    font-family:var(--label-font);
    font-size:12px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.16em;
    transition:background var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}

.primaryButton:hover:not(:disabled),
.secondaryButton:hover:not(:disabled){
    background:#111;
    color:var(--bg);
    border-color:#111;
}

.secondaryButton{
    margin-top:10px;
    padding:10px 18px;
    font-size:11px;
}

/* Destructive (Delete) carries red — the only red on a button. */
.dangerButton{
    color:var(--danger);
    border-color:var(--danger);
}
.dangerButton:hover:not(:disabled){
    background:var(--danger);
    color:var(--bg);
    border-color:var(--danger);
}

.iconButton{
    background:transparent;
    color:var(--text);
    border:2px solid var(--border);
    border-radius:var(--radius);
    width:38px;
    height:38px;
    flex:0 0 38px;
    font-size:18px;
    line-height:1;
    transition:background var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}

.iconButton:hover:not(:disabled){
    background:#111;
    color:var(--bg);
    border-color:#111;
}

.iconButton.dangerIcon{
    color:var(--danger);
    border-color:var(--danger);
}
.iconButton.dangerIcon:hover:not(:disabled){
    background:var(--danger);
    color:var(--bg);
    border-color:var(--danger);
}

.actionRow{
    display:flex;
    flex-wrap:wrap;
    gap:12px;
    margin-top:32px;
}

.actionRow button{
    margin-top:0;
}

.actionRow .primaryButton:last-child{
    margin-left:auto;
}

/* ---------- Banners (draft restore / editing notice) ---------- */

.banner{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    background:var(--surface);
    border:2px solid var(--border);
    border-left:6px solid var(--border);
    border-radius:var(--radius);
    padding:16px 22px;
    margin-bottom:24px;
}

.banner p{
    color:var(--textMuted);
}

.banner strong{
    color:var(--text);
    font-weight:600;
}

.bannerActions{
    display:flex;
    gap:10px;
}

.bannerActions button{
    margin-top:0;
}

/* ---------- Question cards ---------- */

.questionCard{
    margin-top:24px;
    animation:cardIn var(--speed) ease;
}

@keyframes cardIn{
    from{ opacity:0; }
    to{   opacity:1; }
}

.questionCard.hasErrors{
    border-color:var(--warning);   /* incomplete (guidance), not a hard error → amber */
}

.cardHeaderBar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    cursor:pointer;
    user-select:none;
}

.cardHeaderInfo{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:14px;
    min-width:0;
}

.cardHeaderInfo h2{
    font-size:18px;
    font-weight:600;
}

.typeBadge{
    color:var(--textMuted);
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.10em;
    white-space:nowrap;
}

.errorBadge{
    color:var(--warning);
    border:1px solid var(--warning);
    font-size:10px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.10em;
    padding:3px 9px;
    white-space:nowrap;
}

.cardControls{
    display:flex;
    align-items:center;
    gap:8px;
    flex:0 0 auto;
}

.chevron{
    color:var(--textMuted);
    transition:transform var(--speed) ease;
    margin-left:4px;
}

.questionCard.expanded .chevron{
    transform:rotate(180deg);
}

/* Collapsed summary line (hidden while expanded) */

.cardSummary{
    color:var(--textMuted);
    font-size:.95rem;
    margin-top:12px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.questionCard.expanded .cardSummary{
    display:none;
}

/* Smooth expand/collapse without JS measurements */

.cardBody{
    display:grid;
    grid-template-rows:0fr;
    transition:grid-template-rows var(--speed) ease;
}

.cardBody > .cardBodyInner{
    overflow:hidden;
    visibility:hidden;
    transition:visibility var(--speed);
}

.questionCard.expanded .cardBody{
    grid-template-rows:1fr;
}

.questionCard.expanded .cardBody > .cardBodyInner{
    visibility:visible;
}

.cardSummaryMeta{
    opacity:.7;
}

/* ---------- Multipart: parent meta + total marks ---------- */

.fieldOptional{
    color:var(--textMuted);
    font-size:.85em;
    font-weight:400;
    text-transform:none;
    letter-spacing:0;
}

.totalMarks{
    display:flex;
    align-items:baseline;
    gap:8px;
    margin-top:28px;
    padding-top:24px;
    border-top:1px solid var(--border);
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.14em;
    color:var(--textMuted);
}

.totalMarksValue{
    color:var(--text);
    font-size:16px;
    letter-spacing:0;
}

.totalMarksAuto{
    color:var(--textMuted);
    font-size:11px;
    font-weight:400;
}

/* ---------- Multipart: parts (left-ruled sections, not nested boxes) ---------- */

.questionParts{
    margin-top:24px;
}

.partBlock{
    background:var(--surfaceAlt);
    border:2px solid var(--border);
    border-left:6px solid var(--border);
    border-radius:var(--radius);
    padding:18px 24px 22px;
    margin-top:24px;
    animation:cardIn var(--speed) ease;
}

.partHeader{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:6px;
    padding-bottom:12px;
    border-bottom:1px solid var(--hair);
}

.partHeaderInfo{
    display:flex;
    align-items:baseline;
    gap:12px;
    min-width:0;
}

.partLabel{
    font-family:var(--label-font);
    font-size:13px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.14em;
}

.partMarks{
    color:var(--textMuted);
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.08em;
    white-space:nowrap;
}

.partControls{
    display:flex;
    align-items:center;
    gap:6px;
    flex:0 0 auto;
}

/* Compact controls inside a part so they don't crowd the row */
.partControls .iconButton{
    width:32px;
    height:32px;
    flex:0 0 32px;
    font-size:16px;
}

.addPartBtn{
    margin-top:24px;
}

/* ---------- Inline validation ---------- */

.cardErrors,
.formErrors{
    background:var(--dangerSoft);
    border:1px solid var(--danger);
    padding:12px 16px 12px 18px;
    margin-top:16px;
    color:var(--text);
    font-size:.92rem;
    list-style-position:inside;
}

.formErrors{
    margin-top:0;
    margin-bottom:24px;
}

/* ---------- Option / answer rows ---------- */

.optionRow{
    display:flex;
    align-items:center;
    gap:15px;
    margin-bottom:10px;
    min-width:0;
}

.optionRow input[type="text"]{
    min-width:0;
}

/* Math accepted answers: the raw-LaTeX text input is swapped for a live
   MathQuill field at mount time (WYSIWYG). Styled to sit exactly like the
   input it replaces; MathQuill's own border/shadow chrome is overridden. */
.optionRow .mqAnswerField{
    flex:1 1 auto;
    min-width:0;
    background:var(--field);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:10px 14px;
    font-size:18px;
    cursor:text;
    transition:border-color var(--speed) ease;
}
.optionRow .mqAnswerField.mq-focused{
    border-color:var(--accent);
    box-shadow:none;
    outline:none;
}

/* MCQ options are inline mixed-content editors — the editor takes the remaining
   width; the Correct toggle + remove button align to the top of the surface. */
.optionRow:has(.optionDocMount){ align-items:flex-start; }
.optionDocMount{
    flex:1 1 auto;
    min-width:0;
    margin:0;
}
.optionDocMount .idocSurface{
    min-height:52px;
    font-size:16px;
}
/* Options are narrower than the full-width prompt editor, so let the toolbar
   wrap rather than clip its labels when the row gets tight. */
.optionDocMount .idocToolbar{
    width:auto;
    flex-wrap:wrap;
    overflow:visible;
}
.optionRow:has(.optionDocMount) .correctMark,
.optionRow:has(.optionDocMount) > .iconButton{
    margin-top:6px;   /* line the controls up with the toolbar row, not the surface */
}

.optionRow input[type="checkbox"]{
    width:20px;
    height:20px;
    flex:0 0 20px;
    accent-color:var(--text);
}

.fieldHint{
    color:var(--textMuted);
    font-size:0.88rem;
    margin-top:8px;
}

/* ---------- Editor mounts (MathQuill / mhchem / organic) ---------- */

.editorMount{
    background:transparent;
    border:1px dashed var(--border2);
    padding:18px;
    color:var(--textMuted);
    margin-top:10px;
}

/* ---------- Image upload (drag & drop / paste / click) ---------- */

.imageUploader{
    margin-top:8px;
    margin-bottom:6px;
}

/* The drop target — a dashed frame when empty, a solid framed preview when full.
   Rendered as a <button> in the empty state for free keyboard + focus support. */
.imageDropzone{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:8px;
    width:100%;
    min-height:150px;
    padding:24px;
    text-align:center;
    color:var(--textMuted);
    background:transparent;
    border:2px dashed var(--border);
    border-radius:var(--radius);
    transition:border-color var(--speed) ease, background var(--speed) ease, color var(--speed) ease;
}

button.imageDropzone{
    cursor:pointer;
    font:inherit;
}

.imageDropzone:hover{
    border-color:var(--text);
    color:var(--text);
    background:var(--surfaceAlt);
}

/* Active drag-over highlight (blue == active) */
.imageDropzone.dragOver{
    border-color:var(--accent);
    background:var(--accentSoft);
    color:var(--text);
}

.imageDropIcon{
    width:36px;
    height:36px;
    opacity:.7;
}

.imageDropTitle{
    font-size:.98rem;
    font-weight:600;
    color:var(--text);
}

.imageDropHint{
    font-size:.84rem;
}

.imageDropHint kbd{
    background:var(--bg);
    border:1px solid var(--border);
    padding:1px 6px;
    font:inherit;
    font-size:.8rem;
}

/* Filled state: solid frame, preview stretches to width, action buttons below. */
.imageDropzone.hasImage{
    align-items:stretch;
    gap:14px;
    padding:14px;
    border-style:solid;
    border-width:2px;
    border-color:var(--border);
    cursor:default;
    background:var(--surfaceAlt);
}

.imageDropzone.hasImage:hover{
    border-color:var(--border);
    background:var(--surfaceAlt);
}

.imageActions{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    justify-content:center;
}

.imageActions button{
    margin-top:0;
}

/* Shared preview image — fills the available width, aspect ratio preserved. */
.imagePreview{
    display:block;
    max-width:100%;
    max-height:360px;
    width:auto;
    height:auto;
    margin:10px auto 0;
    border:2px solid var(--border);
    border-radius:var(--radius);
    object-fit:contain;
}

.imageDropzone.hasImage .imagePreview{
    margin:0 auto;
}

/* ---------- Explanation images (a list, unlike the single question image) ---------- */
.explImageGallery{
    display:flex;
    flex-wrap:wrap;
    gap:12px;
    margin:8px 0 6px;
}

.explImageItem{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:8px;
    width:160px;
    padding:10px;
    border:2px solid var(--border);
    border-radius:var(--radius);
    background:var(--surfaceAlt);
}

.explImageItem .imagePreview{
    margin:0;
    max-height:120px;
}

.explImageRemove{
    margin-top:0;
    align-self:stretch;
}

/* ---------- Empty states & library ---------- */

.empty{
    background:transparent;
    border:2px dashed var(--border);
    border-radius:var(--radius);
    padding:48px 30px;
    text-align:center;
    color:var(--textMuted);
}

.libraryItem{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:20px;
}

.libraryItem p{
    color:var(--textMuted);
    margin-top:6px;
}

.libraryMeta{
    color:var(--textMuted);
    font-size:0.85rem;
    margin-top:6px;
}

.libraryActions{
    display:flex;
    gap:10px;
    flex:0 0 auto;
}

.libraryActions button{
    margin-top:0;
}

/* ---------- Student preview overlay ---------- */

.previewOverlay{
    position:fixed;
    inset:0;
    background:rgba(17, 17, 17, .55);
    overflow-y:auto;
    padding:48px 16px;
    z-index:50;
}

.previewPanel{
    max-width:760px;
    margin:0 auto;
    background:var(--surface);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:48px;
    animation:cardIn var(--speed) ease;
}

.previewTopBar{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:16px;
    margin-bottom:24px;
    padding-bottom:24px;
    border-bottom:1px solid var(--border);
}

.previewTopBar h2{
    font-size:24px;
    font-weight:600;
}

.previewMeta{
    color:var(--textMuted);
    font-size:.9rem;
    margin-top:6px;
}

.previewNote{
    color:var(--textMuted);
    font-size:.85rem;
    margin-bottom:24px;
}

.previewQHeader{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:14px;
}

.previewQHeader h3{
    font-size:13px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.14em;
    color:var(--textMuted);
}

.timeBadge{
    color:var(--textMuted);
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.08em;
    white-space:nowrap;
}

.previewQuestionText{
    margin-bottom:14px;
    font-size:20px;
    line-height:1.5;
}

/* Multipart parts inside the student preview */
.previewPart{
    border-left:2px solid var(--border);
    padding-left:18px;
    margin-top:24px;
}

.previewPartHeader{
    display:flex;
    align-items:center;
    gap:12px;
    margin-bottom:10px;
}

.previewOption{
    display:flex;
    align-items:center;
    gap:14px;
    background:transparent;
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:13px 16px;
    margin-top:10px;
    /* This row is a <label>, so without this it would inherit the editor's
       global `label{ text-transform:uppercase }` and force teacher-entered MCQ
       option text to ALL CAPS. Keep the typed casing exactly. Applies to both
       preview surfaces (the per-part .partPreview and the full .previewOverlay)
       because the class — not the container — carries the reset. */
    text-transform:none;
}

.previewOption input{
    width:18px;
    height:18px;
    flex:0 0 18px;
    accent-color:var(--text);
}

/* ---------- Status toast ---------- */

.statusToast{
    position:fixed;
    bottom:24px;
    left:50%;
    transform:translateX(-50%);
    background:var(--surface);
    border:1px solid var(--border);
    border-left:2px solid var(--border2);
    padding:14px 22px;
    max-width:90vw;
    z-index:60;
    animation:cardIn var(--speed) ease;
}

.statusToast.error{
    border-left-color:var(--danger);
}

.statusToast.success{
    border-left-color:var(--success);
}

/* ---------- Responsive ---------- */

@media (max-width:600px){
    .wrapper{
        padding:40px 16px 64px;
    }

    .card{
        padding:28px 20px;
    }

    .cardHeaderBar{
        flex-wrap:wrap;
    }

    .cardControls{
        width:100%;
        justify-content:flex-end;
    }

    .actionRow .primaryButton:last-child{
        margin-left:0;
    }

    .libraryItem{
        flex-direction:column;
        align-items:flex-start;
    }
}


/* ==========================================================================
   INLINE MIXED-CONTENT EDITOR (prompt + explanation)
   A document surface, not a form field: a large readable writing column in
   Times New Roman with sharp edges. Mathematics / Chemistry sit inline as
   atomic objects carrying a hairline border only while editing. Colour stays
   reserved for validation / confirmation — never for these objects.
   ========================================================================== */
.inlineDocEditor{
    margin-bottom:8px;
}

/* Minimal toolbar: three hairline-separated text buttons, nothing floating. */
.idocToolbar{
    display:flex;
    width:max-content;
    max-width:100%;
    margin-bottom:8px;
    border:2px solid var(--border);
    border-radius:var(--radius);
    overflow:hidden;
}
.idocTool{
    background:transparent;
    color:var(--textMuted);
    border:none;
    border-right:1px solid var(--border);
    padding:7px 14px;
    font-family:var(--label-font);
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.14em;
    cursor:pointer;
    transition:background var(--speed) ease, color var(--speed) ease;
}
.idocTool:last-child{ border-right:none; }
.idocTool:hover{ background:#111; color:var(--bg); }

/* The writing surface — a touch larger than form inputs; this is the page. */
.idocSurface{
    width:100%;
    min-height:104px;
    background:var(--field);
    border:2px solid var(--border);
    border-radius:var(--radius);
    color:var(--text);
    padding:14px 16px;
    font:inherit;
    font-size:18px;
    line-height:1.7;
    transition:border-color var(--speed) ease;
}
.idocSurface:focus{
    outline:none;
    border-color:var(--accent);
}
.idocSurface:empty::before{
    content:attr(data-placeholder);
    color:var(--textMuted);
    opacity:.7;
}

/* Inline atomic objects — hairline border WHILE EDITING only (the shared
   renderer used in preview / live play has no such border). */
.inlineObj{
    display:inline-block;
    vertical-align:middle;
    margin:0 2px;
    padding:1px 5px;
    background:var(--surface);
    border:1px solid var(--border2);
    cursor:text;
}
.inlineObj:hover{ border-color:var(--textMuted); }

.idocMathField{ display:inline-block; min-width:1ch; }
/* Strip MathQuill's own focus chrome so objects read as plain inline type. */
.idocMathObj .mq-editable-field,
.idocMathObj .mq-editable-field.mq-focused{ border:none; box-shadow:none; }

.idocChemObj .idocChemPreview{ display:inline-block; }
.idocChemObj .idocChemInput{
    width:auto;
    min-width:220px;
    display:inline-block;
    margin:0 0 0 6px;
    padding:2px 6px;
    font-size:15px;
    background:var(--field);
    border:1px solid var(--border2);
    vertical-align:middle;
}
.idocPlaceholder{ color:var(--textMuted); font-style:italic; }

/* Shared-renderer output (student preview / live quiz): inline, NO border. */
.idoc-math,
.idoc-chem{ display:inline; }


/* ==========================================================================
   REFINEMENT PASS — colour-coded type labels, MCQ correct marking, Advanced
   Options, live validation, per-part preview, drag reordering, autosave status,
   and the card-based quiz library. Same editorial system throughout: sharp
   corners, hairline rules, whitespace, restrained and meaningful colour.
   ========================================================================== */

/* ---- Part header: colour-coded answer-format label (colour set inline) ---- */
.partType{
    font-family:var(--label-font);
    font-size:11px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.14em;
    white-space:nowrap;
}

/* ---- MCQ: explicit "Correct" toggle + highlighted correct row ---- */
.optionRow{
    border-left:3px solid transparent;   /* constant rail → no shift when ticked */
    padding-left:12px;
    transition:border-color var(--speed) ease;
}
.optionRow.isCorrect{
    border-left-color:var(--success);
}
.correctMark{
    display:inline-flex;
    align-items:center;
    gap:7px;
    flex:0 0 auto;
    margin:0;                            /* override the global label top-margin */
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.10em;
    color:var(--textMuted);
    cursor:pointer;
    white-space:nowrap;
}
.optionRow.isCorrect .correctMark{ color:var(--success); }
.correctMark input[type="checkbox"]{
    width:18px;
    height:18px;
    flex:0 0 18px;
    accent-color:var(--success);
    cursor:pointer;
}

/* ---- Advanced Options (progressive disclosure) ---- */
.advanced{
    margin-top:22px;
    border-top:1px solid var(--border);
    padding-top:4px;
}
.advancedToggle{
    display:inline-flex;
    align-items:center;
    gap:8px;
    background:none;
    border:none;
    color:var(--textMuted);
    padding:12px 0;
    font:inherit;
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.12em;
    cursor:pointer;
    transition:color var(--speed) ease;
}
.advancedToggle:hover,
.advancedToggle.open{ color:var(--text); }
.advancedChevron{
    display:inline-block;
    font-size:10px;
    transition:transform var(--speed) ease;
}
.advancedToggle.open .advancedChevron{ transform:rotate(90deg); }

/* ---- "No time limit" checkbox (reads as a sentence, not a field label) ---- */
.checkboxField{
    display:flex;
    align-items:center;
    gap:9px;
    margin-top:10px;
    text-transform:none;
    letter-spacing:0;
    font-size:14px;
    font-weight:400;
    color:var(--text);
    cursor:pointer;
}
.checkboxField input[type="checkbox"]{
    width:18px;
    height:18px;
    flex:0 0 18px;
    accent-color:var(--accent);
    cursor:pointer;
}

/* ---- Live validation checklist (✓ satisfied / ⚠ outstanding) ---- */
.partValidation{
    display:flex;
    flex-wrap:wrap;
    gap:6px 18px;
    margin-top:14px;
}
.partValidation:empty{ display:none; }
.checkItem{
    display:inline-flex;
    align-items:center;
    gap:7px;
    font-size:.86rem;
}
.checkItem .checkIcon{ font-size:.92em; line-height:1; }
.checkItem.ok{   color:var(--success); }
.checkItem.warn{ color:var(--warning); }

/* ---- Per-part live student preview ---- */
.partPreview{
    margin-top:24px;
    border-top:1px solid var(--border);
    padding-top:18px;
}
.partPreviewLabel{
    font-size:11px;
    font-weight:500;
    text-transform:uppercase;
    letter-spacing:.14em;
    color:var(--textMuted);
    margin-bottom:12px;
}
.partPreviewBody{
    background:var(--bg);
    border:1px solid var(--border);
    border-left:2px solid var(--accent);   /* "this is the student's view" */
    padding:18px 20px;
}
.partPreviewBody .previewQuestionText{
    font-size:18px;
    margin-bottom:12px;
}
.partPreviewBody input{ pointer-events:none; }   /* preview is read-only */

/* ---- Drag-to-reorder ---- */
/* The handle reads as a physical grip: a bordered tab holding a 2×3 dot grid
   that fills black on hover so it is obviously the thing you grab. */
.dragHandle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    cursor:grab;
    color:var(--textMuted);
    padding:0;
    width:28px;
    height:28px;
    border:2px solid var(--border);
    border-radius:var(--radius);
    background:transparent;
    user-select:none;
    touch-action:none;          /* let a touch-drag grab the handle, not scroll */
    transition:background var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}
.dragHandle .dragGrip{ display:block; pointer-events:none; }
.dragHandle:hover{ background:#111; color:var(--bg); border-color:#111; }
.dragHandle:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.dragHandle:active{ cursor:grabbing; }
.questionCard.dragging{ opacity:.5; }
.questionCard.dropBefore{ box-shadow:inset 0 3px 0 0 var(--accent); }
.questionCard.dropAfter{  box-shadow:inset 0 -3px 0 0 var(--accent); }

/* ---- Autosave status + keyboard-shortcut hint ---- */
.saveStatus{
    align-self:center;
    font-size:.82rem;
    color:var(--textMuted);
    min-height:1em;
}
.saveStatus.saved{  color:var(--success); }
.saveStatus.error{  color:var(--danger); }

.shortcutHint{
    margin-top:16px;
    color:var(--textMuted);
    font-size:.82rem;
}
.shortcutHint kbd{
    background:var(--surface);
    border:1px solid var(--border);
    padding:1px 6px;
    font:inherit;
    font-size:.78rem;
}

/* ---- Status toast: message + optional action (Undo) ---- */
.statusToast{
    display:flex;
    align-items:center;
    gap:18px;
}
.statusToastAction{
    background:none;
    border:none;
    color:var(--accent);
    font:inherit;
    font-size:.9rem;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.08em;
    cursor:pointer;
    padding:0;
}
.statusToastAction:hover{ color:var(--accentHover); text-decoration:underline; }

/* ---- Library: search + filter chips ---- */
.libraryToolbar{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:16px;
    margin-bottom:28px;
}
.quizSearch{
    flex:1 1 240px;
    width:auto;
    max-width:360px;
}
.quizFilters{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}
.filterChip{
    background:transparent;
    border:2px solid var(--border);
    border-radius:var(--radius);
    color:var(--textMuted);
    padding:7px 14px;
    font-family:var(--label-font);
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.14em;
    cursor:pointer;
    transition:background var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}
.filterChip:hover{ color:var(--text); }
.filterChip.active{
    background:var(--accentSoft);
    border-color:var(--accent);
    color:var(--text);
}

/* ---- Library: quiz cards ---- */
.quizGrid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(300px, 1fr));
    gap:20px;
}
.quizCard{
    display:flex;
    flex-direction:column;
    justify-content:space-between;
    gap:22px;
    margin-bottom:0;            /* the grid gap handles spacing */
    padding:28px;
    transition:border-color var(--speed) ease;
}
.quizCard:hover{ background:var(--surfaceAlt); }
.quizCardTitle{ font-size:27px; font-weight:500; line-height:1.1; letter-spacing:-.01em; }
.quizCardDesc{ color:var(--textMuted); margin-top:10px; }
.quizCardMeta{
    font-family:var(--label-font);
    color:var(--textMuted);
    font-size:10px;
    text-transform:uppercase;
    letter-spacing:.14em;
    margin-top:10px;
}
.quizCardStats{
    display:flex;
    flex-wrap:wrap;
    gap:6px 16px;
    margin-top:14px;
    padding-top:14px;
    border-top:1px solid var(--hair);
    color:var(--textMuted);
    font-family:var(--label-font);
    font-size:10px;
    text-transform:uppercase;
    letter-spacing:.12em;
}
.quizCardActions{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
}
.quizCardActions button{ margin-top:0; }


/* ==========================================================================
   EDITORIAL PASS 2 — Create Quiz reads like an exam paper, not a form builder.
   Each question is a strongly-bordered exam-paper block: the question number is
   the serif section heading, ruled off from its body; management controls retreat
   into a drag handle, a ⋮ menu and Advanced Options. The open block is the active
   one and carries the blue accent frame.
   ========================================================================== */

/* The quiz meta block is a clean masthead, not a bordered panel. */
.quizMeta{ margin-bottom:8px; }

/* Field labels stay as uppercase Helvetica captions (set in the base rule);
   here we only tune their rhythm inside the dense card. */
label{ margin-top:22px; }
.correctMark{ letter-spacing:.10em; }

/* A question is an exam-paper block: surface ground, strong black frame, a serif
   number heading ruled off from the answer body. The open block reads as active
   via a blue accent frame (the one place blue appears here). */
.questionCard{
    margin:0 0 24px;
    animation:cardIn var(--speed) ease;
    background:var(--surface);
    border:2px solid var(--border);
    border-radius:var(--radius);
    padding:26px 30px;
}
.questionCard.expanded{ border-color:var(--accent); }   /* open == active → blue frame */
.cardHeaderBar{
    padding:0 0 14px;
    border-bottom:2px solid var(--border);
}
.cardHeaderInfo{ gap:14px; }
.cardHeaderInfo h2{
    font-size:25px;
    font-weight:500;
    letter-spacing:0;
}
.questionMarks{
    font-family:var(--label-font);
    color:var(--textMuted);
    font-size:10px;
    text-transform:uppercase;
    letter-spacing:.14em;
    white-space:nowrap;
}
.cardBodyInner{ padding-top:10px; }

/* A sole part renders bare — as if it were the question itself (the card frames it). */
.partBlock.solePart{
    background:transparent;
    border:none;
    border-radius:0;
    padding:0;
    margin-top:0;
    animation:none;
}

/* Answer sub-headings (Options, Accepted answers…) read as uppercase section labels. */
.partBlock h3{
    font-family:var(--label-font);
    font-size:11px;
    font-weight:600;
    text-transform:uppercase;
    letter-spacing:.16em;
    color:var(--textMuted);
    margin-top:22px;
    margin-bottom:6px;
}

/* ⋮ overflow menu (Duplicate / Add part / Delete) */
.cardControls{ position:relative; }
.menuBtn{ font-size:17px; line-height:1; }
.cardMenu{
    position:absolute;
    top:calc(100% + 4px);
    right:0;
    z-index:30;
    min-width:170px;
    display:flex;
    flex-direction:column;
    background:var(--surface);
    border:2px solid var(--border);
    border-radius:var(--radius);
    box-shadow:0 8px 24px rgba(17,17,17,.20);   /* dropdown — the one allowed shadow */
}
.cardMenu button{
    background:none;
    border:none;
    color:var(--text);
    text-align:left;
    padding:11px 16px;
    font:inherit;
    font-size:.92rem;
    cursor:pointer;
    transition:background var(--speed) ease;
}
.cardMenu button:hover{ background:var(--surfaceAlt); }
.cardMenu button:disabled{ color:var(--textMuted); opacity:.5; cursor:default; background:none; }
.cardMenu .menuDanger{ color:var(--danger); }
.cardMenu .menuDanger:hover{ background:var(--dangerSoft); }

/* The reorder actions form their own group, separated from Duplicate/Delete. */
.cardMenu .cardMenuGroup{
    display:flex;
    flex-direction:column;
    padding-bottom:4px;
    margin-bottom:4px;
    border-bottom:2px solid var(--border);
}
.cardMenu .cardMenuGroup button{ width:100%; }

/* Inline "New question" inserter — a quiet affordance between sections, like
   adding a paragraph. Faint until hovered. */
.questionInserter{
    display:flex;
    justify-content:center;
    padding:4px 0;
    margin:14px 0;
}
/* The "New question" control is a primary authoring action, so it reads clearly
   rather than hiding as faint text: a full-width dashed "insert here" affordance
   in the active blue, filling solid on hover/focus. */
.inserterBtn{
    width:100%;
    background:var(--accentSoft);
    border:1.5px dashed var(--accent);
    color:var(--accent);
    font:inherit;
    font-weight:600;
    font-size:.95rem;
    letter-spacing:.02em;
    cursor:pointer;
    padding:11px 16px;
    transition:background var(--speed) ease, color var(--speed) ease, border-color var(--speed) ease;
}
.inserterBtn:hover,
.inserterBtn:focus-visible{
    background:var(--accent);
    border-color:var(--accent);
    color:var(--field);
    outline:none;
}


/* ==========================================================================
   EXPLANATION PREVIEW — the post-question results screen as students see it.
   Mirrors the live quiz reveal markup/classes so the preview matches the game.
   Colour stays reserved: green == correct, red == incorrect. Scoped under the
   shared .previewOverlay so it never leaks into the editor surface.
   ========================================================================== */
.previewOverlay{
    --correct:   #4f8f68;
    --incorrect: #b84f4f;
}

/* Correct-answer banner (single-question reveal). */
.previewOverlay .correct-banner{
    display:flex; align-items:center; gap:12px;
    background:transparent; border:2px solid var(--correct);
    border-radius:6px; padding:14px 16px; margin:18px 0;
}
.previewOverlay .cb-label{
    font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase;
    color:var(--correct);
}
.previewOverlay .cb-value{ font-size:19px; margin-top:4px; color:var(--text); word-break:break-word; }

/* Per-student result block + correct/incorrect indicator. */
.previewOverlay .your-result{
    border:2px solid var(--border); border-radius:6px; padding:14px 16px; margin:16px 0;
}
.previewOverlay .your-result.correct{ border-color:var(--correct); }
.previewOverlay .your-result.incorrect{ border-color:var(--incorrect); }
.previewOverlay .yr-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.previewOverlay .yr-status{ font-size:13px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; }
.previewOverlay .your-result.correct .yr-status{ color:var(--correct); }
.previewOverlay .your-result.incorrect .yr-status{ color:var(--incorrect); }
.previewOverlay .yr-points{
    font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
    color:var(--textMuted); font-variant-numeric:tabular-nums;
}
.previewOverlay .yr-answer-row{ margin-top:12px; }
.previewOverlay .yr-label{
    font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:var(--textMuted);
}
.previewOverlay .yr-value{ font-size:18px; margin-top:3px; color:var(--text); word-break:break-word; }

/* Explanation block. */
.previewOverlay .explanation-block{ margin-top:20px; }
.previewOverlay .expl-section-title{
    font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase;
    color:var(--textMuted); margin:0 0 10px;
}
.previewOverlay .expl-text{
    font-size:16px; line-height:1.7; color:var(--text);
    border-left:2px solid var(--border); padding:2px 0 2px 16px;
}
.previewOverlay .expl-muted{ color:var(--textMuted); font-style:italic; }
.previewOverlay .expl-ans{ color:var(--correct); }
.previewOverlay .explanation-images{ margin-top:14px; display:flex; flex-direction:column; gap:12px; }
.previewOverlay .explanation-images img{
    display:block; max-width:100%; height:auto; border:2px solid var(--border); border-radius:6px;
}

/* Multipart: whole-question total + per-part feedback cards. */
.previewOverlay .mp-total{
    font-size:16px; font-weight:600; padding:12px 16px; margin:6px 0 14px;
    border:2px solid var(--border); border-radius:6px; font-variant-numeric:tabular-nums;
}
.previewOverlay .mp-total.correct{ border-color:var(--correct); }
.previewOverlay .mp-part{ border:1px solid var(--border); border-radius:6px; padding:16px 18px; margin:16px 0; }
.previewOverlay .mp-part-head{
    display:flex; align-items:baseline; justify-content:space-between; gap:12px;
    border-bottom:1px solid rgba(17,17,17,.18); padding-bottom:8px; margin-bottom:12px;
}
.previewOverlay .mp-part-label{ font-size:12px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--text); }
.previewOverlay .mp-part-marks{ font-size:11px; font-weight:700; color:var(--textMuted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.previewOverlay .mp-part-image{ display:block; max-width:100%; height:auto; margin:8px 0; border-radius:6px; }
.previewOverlay .mp-part-feedback{
    margin-top:12px; padding:12px 0 0 12px;
    border-top:1px dashed rgba(17,17,17,.18); border-left:3px solid rgba(17,17,17,.18);
}
.previewOverlay .mp-part-feedback.correct{ border-left-color:var(--correct); }
.previewOverlay .mp-part-feedback.incorrect{ border-left-color:var(--incorrect); }
.previewOverlay .mp-fb-result{ font-weight:600; font-variant-numeric:tabular-nums; margin-bottom:6px; }
.previewOverlay .mp-part-feedback.correct .mp-fb-result{ color:var(--correct); }
.previewOverlay .mp-part-feedback.incorrect .mp-fb-result{ color:var(--incorrect); }
.previewOverlay .mp-fb-your, .previewOverlay .mp-fb-correct{ margin:4px 0; }
.previewOverlay .mp-fb-correct span:last-child{ color:var(--correct); }
.previewOverlay .mp-fb-label{
    font-size:10px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--textMuted);
}
.previewOverlay .mp-fb-expl{ margin-top:6px; color:var(--textMuted); }
