/* Weekly quiz scanner — styles.

   The look is taken from the answer sheet itself:
   - paper and graphite: cool paper, pencil-grey text, and primary buttons
     filled like a pencilled bubble;
   - drop-out ink: OMR forms are printed in a colour the scanner ignores, so
     that teal carries the app's structure (active tab, current step, focus,
     links) and never means a status;
   - bubbles and registration marks: the step tracker is a row of answer
     bubbles on a timing-mark rail, a <details> marker is a bubble that fills
     when opened, and drop zones carry the four corner squares the scanner
     looks for.
   Green, amber and red are kept for status only. */

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans Condensed";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-condensed-latin-500-normal.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans Condensed";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("fonts/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2");
}

:root {
    /* Paper and pencil */
    --paper: #f3f5f4;
    --sheet: #ffffff;
    --graphite: #262a2f;
    --graphite-hover: #3c434b;
    --lead: #5e6670;
    --rule: #d5dbd8;
    --rule-soft: #e6eae8;
    --rule-strong: #b6bfbb;

    /* Drop-out ink: structure, focus, links */
    --ink: #0f7a74;
    --ink-strong: #0b5e59;
    --ink-tint: #e2f0ee;

    /* Status */
    --ok: #2f7a3b;
    --ok-tint: #e4f1e5;
    --warn: #8a5300;
    --warn-text: #5c3a00;
    --warn-tint: #fcf0d9;
    --warn-rule: #efcf94;
    --bad: #b3261e;
    --bad-tint: #fbe8e6;
    --bad-rule: #f0b8b2;

    --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --radius-s: 4px;
    --radius: 6px;

    /* Names used by older rules and inline styles. */
    --bg: var(--paper);
    --surface: var(--sheet);
    --text: var(--graphite);
    --muted: var(--lead);
    --accent: var(--ink);
    --accent-light: var(--ink-tint);
    --danger: var(--bad);
    --danger-light: var(--bad-tint);
    --success: var(--ok);
    --success-light: var(--ok-tint);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    background: var(--paper);
    color: var(--graphite);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-cond);
    font-weight: 600;
    line-height: 1.2;
    color: var(--graphite);
}
h2 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.125rem; margin: 1.25rem 0 0.5rem; }
h4 { font-size: 1rem; }

p { max-width: 75ch; }
a { color: var(--ink-strong); }
code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--rule-soft);
    border-radius: 3px;
    padding: 0.05em 0.3em;
}
ul, ol { padding-left: 1.25rem; }
strong { font-weight: 600; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* ── Controls ──────────────────────────────────────────────────────────── */

button {
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    padding: 0.5rem 1rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
    color: var(--graphite);
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
button:hover:not(:disabled) { border-color: var(--graphite); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary: a pencilled-in bubble. */
.btn-primary,
.step-next-btn,
.queue-item-start {
    background: var(--graphite);
    border-color: var(--graphite);
    color: #fff;
}
.btn-primary:hover:not(:disabled),
.step-next-btn:hover:not(:disabled),
.queue-item-start:hover:not(:disabled) {
    background: var(--graphite-hover);
    border-color: var(--graphite-hover);
}

.btn-danger,
.batch-cancel-btn,
.wipe-btn,
.history-actions .history-delete {
    color: var(--bad);
    border-color: var(--bad-rule);
    background: var(--sheet);
}
.btn-danger:hover:not(:disabled),
.batch-cancel-btn:hover:not(:disabled),
.wipe-btn:hover:not(:disabled),
.history-actions .history-delete:hover:not(:disabled) {
    background: var(--bad-tint);
    border-color: var(--bad);
}

.link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--ink-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
}

select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"] {
    font: inherit;
    font-size: 0.9375rem;
    color: var(--graphite);
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-s);
    background: var(--sheet);
    min-height: 2.25rem;
}
select { padding-right: 1.75rem; }
select:focus,
input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px var(--ink-tint);
}
select:disabled { opacity: 0.55; cursor: not-allowed; }
input[type="checkbox"],
input[type="radio"],
input[type="range"] { accent-color: var(--ink); }
input[type="checkbox"],
input[type="radio"] { width: 1rem; height: 1rem; vertical-align: -0.15em; }
input[type="file"] { font: inherit; font-size: 0.875rem; }

/* <details>: the marker is an answer bubble that fills in when opened. */
details > summary {
    list-style: none;
    cursor: pointer;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
    content: "";
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    margin-right: 0.55rem;
    border: 1.5px solid var(--graphite);
    border-radius: 50%;
    vertical-align: -0.05em;
    transition: background-color 0.12s;
}
details[open] > summary::before { background: var(--graphite); }

.summary-note {
    margin-left: 0.5rem;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--lead);
}

/* ── Masthead ──────────────────────────────────────────────────────────── */

.masthead {
    background: var(--sheet);
    border-bottom: 1px solid var(--rule);
}
.masthead-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
}
.masthead-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.masthead h1 {
    font-size: 1.375rem;
    letter-spacing: -0.005em;
}
.masthead-sub {
    font-size: 0.875rem;
    color: var(--lead);
}

.app-mark {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
}
.app-mark rect { fill: var(--graphite); }
.app-mark circle { fill: var(--ink); }
.app-mark-lg { width: 3rem; height: 3rem; margin-bottom: 1rem; }

/* "What's new" (per-school changelog; see `School::changelog`) */
.changelog-card {
    font-size: 0.875rem;
}
.changelog-head {
    display: flex;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
    flex-wrap: wrap;
    padding: 0.35rem 0.25rem;
}
.changelog-head strong { font-weight: 600; }
.changelog-latest { color: var(--lead); }
.changelog-card[open] {
    flex-basis: 100%;
    order: 3;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}
.changelog-card[open] .changelog-head { padding: 0 0 0.5rem; }
.changelog-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.changelog-list li {
    display: flex;
    gap: 1rem;
    padding: 0.3rem 0;
    line-height: 1.45;
    border-top: 1px solid var(--rule-soft);
    max-width: 85ch;
}
.changelog-date {
    flex: 0 0 6.5rem;
    color: var(--lead);
    font-variant-numeric: tabular-nums;
}
.changelog-hint {
    margin-top: 0.6rem;
    color: var(--lead);
    font-size: 0.8125rem;
}

/* ── App frame ─────────────────────────────────────────────────────────── */

.omr-app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

/* Top-level sections: underline tabs sitting on the masthead. */
.main-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.75rem;
    border-bottom: 1px solid var(--rule);
}
.main-tab {
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 0.85rem 0.1rem 0.7rem;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--lead);
    margin-bottom: -1px;
}
.main-tab:hover:not(:disabled) { color: var(--graphite); border-color: transparent; border-bottom-color: var(--rule-strong); }
.main-tab.active,
.main-tab.active:hover:not(:disabled) {
    color: var(--graphite);
    font-weight: 600;
    border-bottom-color: var(--ink);
    cursor: default;
}

/* ── Step tracker: answer bubbles on a timing-mark rail ────────────────── */

.stepper-nav { margin: 1.75rem 0 0.25rem; }
.stepper {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 44rem;
}
.stepper-step {
    position: relative;
    display: flex;
    justify-content: center;
}
/* The rail from this bubble to the next: the sheet's timing marks while the
   step is open, a solid pencil line once it's done. */
.stepper-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 1.5rem;
    left: calc(50% + 1.75rem);
    right: calc(-50% + 1.75rem);
    height: 6px;
    margin-top: -3px;
    background: repeating-linear-gradient(
        90deg,
        var(--rule-strong) 0 4px,
        transparent 4px 10px
    );
}
.stepper-step.done:not(:last-child)::after {
    height: 2px;
    margin-top: -1px;
    background: var(--graphite);
}

.stepper-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem 0.35rem;
    border: none;
    border-radius: var(--radius);
    background: none;
    text-align: center;
    min-width: 7rem;
}
.stepper-pill:hover:not(:disabled) { border-color: transparent; }

.stepper-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 2px solid var(--graphite);
    background: var(--sheet);
    font-family: var(--font-cond);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--graphite);
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.stepper-pill:hover:not(:disabled) .stepper-bubble { box-shadow: 0 0 0 4px var(--rule-soft); }

.stepper-step.current .stepper-bubble {
    border: 3px solid var(--ink);
    color: var(--ink-strong);
    box-shadow: 0 0 0 4px var(--ink-tint);
}
.stepper-step.done .stepper-bubble {
    background: var(--graphite);
    color: #fff;
}
.stepper-step.locked .stepper-bubble {
    border: 2px dashed var(--rule-strong);
    color: var(--lead);
    background: var(--paper);
}
.stepper-step.locked .stepper-pill:disabled { opacity: 1; cursor: not-allowed; }

.stepper-text { display: flex; flex-direction: column; line-height: 1.25; }
.stepper-label {
    font-family: var(--font-cond);
    font-weight: 600;
    font-size: 1rem;
    color: var(--graphite);
}
.stepper-step.locked .stepper-label { color: var(--lead); }
.stepper-badge {
    font-size: 0.8125rem;
    color: var(--lead);
    font-variant-numeric: tabular-nums;
    min-height: 1.1em;
}

/* ── Step pages ────────────────────────────────────────────────────────── */

.step-head { margin: 1.75rem 0 1rem; }
.step-head h2 {
    font-size: 1.75rem;
    letter-spacing: -0.01em;
    margin: 0 0 0.4rem;
}
.step-lead {
    color: var(--lead);
    font-size: 1rem;
    max-width: 68ch;
}

.section-title { margin: 2rem 0 0.35rem; }
.section-hint {
    color: var(--lead);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

/* A stage within a page (Print sheets: 1 Load, 2 Download; PowerPoints). */
.stage {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}
.stage-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0 0 0.75rem;
    font-family: var(--font-cond);
    font-weight: 600;
    font-size: 1.125rem;
    line-height: 1.2;
}
.stage-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid var(--graphite);
    border-radius: 50%;
    font-size: 0.9rem;
}
.stage-waiting .stage-num { border-style: dashed; border-color: var(--rule-strong); color: var(--lead); }
.stage-waiting .stage-title { color: var(--lead); }

/* Which quiz/sheet the page is working on. */
.ht-week-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--graphite);
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius-s);
    padding: 0.3rem 0.7rem;
    margin-bottom: 1.25rem;
}
.ht-week-badge::before {
    content: "";
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--ink);
}

/* Sticky "next step" bar at the foot of a step. */
.step-next-row {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding: 0.75rem 0;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(4px);
    border-top: 1px solid var(--rule);
}
.step-next-note {
    flex: 1;
    color: var(--lead);
    font-size: 0.875rem;
}
.step-next-btn { font-size: 0.9375rem; padding: 0.6rem 1.4rem; }

/* ── Drop zones (scanned PDFs, pupil list, history import) ─────────────── */

.file-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 2.25rem 2rem;
    text-align: center;
    background-color: var(--sheet);
    /* the scanner's four registration squares */
    background-image:
        linear-gradient(var(--graphite), var(--graphite)),
        linear-gradient(var(--graphite), var(--graphite)),
        linear-gradient(var(--graphite), var(--graphite)),
        linear-gradient(var(--graphite), var(--graphite));
    background-size: 10px 10px;
    background-repeat: no-repeat;
    background-position: 12px 12px, calc(100% - 12px) 12px, 12px calc(100% - 12px), calc(100% - 12px) calc(100% - 12px);
    border: 1.5px dashed var(--rule-strong);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.file-upload:hover,
.file-upload.dragging {
    border-color: var(--ink);
    background-color: var(--ink-tint);
}
.file-upload.reading {
    border-color: var(--ink);
    background-color: var(--ink-tint);
    cursor: wait;
}
.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-upload:focus-within {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
.upload-icon {
    width: 2.5rem;
    height: 3rem;
    margin-bottom: 0.5rem;
    fill: none;
    stroke: var(--graphite);
    stroke-width: 1.75;
    stroke-linejoin: round;
}
.upload-icon circle { stroke-width: 1.5; }
.upload-icon circle.filled { fill: var(--graphite); }
.upload-title { font-weight: 500; font-size: 1rem; }
.upload-hint { font-size: 0.8125rem; color: var(--lead); }

.queue-upload-row { margin-bottom: 1.5rem; }
.queue-upload-row.compact .file-upload {
    flex-direction: row;
    padding: 0.85rem 2.5rem;
    background-size: 7px 7px;
    background-position: 8px 8px, calc(100% - 8px) 8px, 8px calc(100% - 8px), calc(100% - 8px) calc(100% - 8px);
}
.queue-upload-row.compact .upload-icon,
.queue-upload-row.compact .upload-hint { display: none; }
.queue-upload-row.compact .upload-title { font-size: 0.9375rem; }

.excel-upload {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
}
.excel-upload .excel-drop { padding: 1.5rem; }
.excel-upload .excel-drop p { margin: 0; }
.excel-status { color: var(--ok); font-size: 0.875rem; font-weight: 500; }
.excel-error { color: var(--bad); font-size: 0.875rem; margin-top: 0.4rem; }

/* ── Notes and alerts ──────────────────────────────────────────────────── */

.needs-answer-key-note,
.needs-pupils-note {
    color: var(--lead);
    background: var(--paper);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    font-size: 0.9375rem;
    margin: 0.5rem 0 1rem;
    max-width: none;
}

.week-override-note {
    background: var(--warn-tint);
    border: 1px solid var(--warn-rule);
    border-radius: var(--radius-s);
    color: var(--warn-text);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0 0.75rem;
    font-size: 0.875rem;
}

.failed-pages-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    background: var(--warn-tint);
    color: var(--warn-text);
    border: 1px solid var(--warn-rule);
    border-left: 4px solid var(--warn);
    border-radius: var(--radius-s);
    font-size: 0.9375rem;
}
.failed-pages-banner > span { flex: 1; min-width: 240px; }
.failed-pages-reasons {
    order: 10;
    flex-basis: 100%;
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.875rem;
}
.failed-pages-clear { background: transparent; }

.regrade-warning {
    background: var(--bad-tint);
    border: 1px solid var(--bad-rule);
    border-left: 4px solid var(--bad);
    border-radius: var(--radius-s);
    color: #6e1712;
    padding: 0.65rem 0.9rem;
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
}
.regrade-warning ul { margin: 0.4rem 0; padding-left: 1.25rem; }
.queue-item .regrade-warning { margin: 0 1rem 0.75rem; }

.error-note,
.report-error {
    color: var(--bad);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ── Week picker ───────────────────────────────────────────────────────── */

.ht-week-selector {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
}
.ht-week-selector label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--lead);
}
.ht-week-selector select { min-width: 5rem; }
.ht-week-layout-badge {
    margin-left: auto;
    align-self: center;
    background: var(--ink-tint);
    color: var(--ink-strong);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-s);
    font-size: 0.875rem;
    font-weight: 500;
}
.sheets-per-pupil { align-items: center; }
.sheets-per-pupil label { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--graphite); }
.sheets-per-pupil input { width: 4.5rem; }
.sheets-per-pupil .format-hint-note { flex: 1 1 20rem; }

/* Year-10 core/options (C/D) picker + the "Options column detected" hint. */
.y10-sheet-picker { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.y10-options-hint {
    background: var(--ok-tint);
    color: var(--ok);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-s);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── Panels ────────────────────────────────────────────────────────────── */

/* Where the user acts: a white sheet with an ink edge. */
.batch-setup,
.generate-bar {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--ink);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem 1.25rem;
    margin: 0 0 1.5rem;
}
.batch-setup h3 { margin: 0 0 0.35rem; }
.batch-hint { margin: 0 0 1rem; font-size: 0.9rem; color: var(--lead); }
.batch-setup .ht-week-selector { margin-bottom: 0.5rem; }
.batch-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.generate-bar { margin-top: 2rem; }
.generate-bar .report-options-grid {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0 0 1rem;
}

/* After a batch is in: which week it's marked against. */
.regrade-panel {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 0 0 1.25rem;
}
.regrade-panel h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.regrade-panel .ht-week-selector { margin-bottom: 0.5rem; }
.regrade-hint { margin: 0; font-size: 0.875rem; color: var(--lead); }

/* Collapsible secondary panels (corrections, extras, history). */
.language-override,
.report-options,
.history-manager,
details.format-hint {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    margin: 0.6rem 0;
    font-size: 0.9375rem;
}
.language-override > summary,
.report-options > summary,
.history-manager > summary,
details.format-hint > summary {
    font-weight: 600;
    color: var(--graphite);
}
.language-override[open] > summary,
.report-options[open] > summary,
.history-manager[open] > summary,
details.format-hint[open] > summary { margin-bottom: 0.6rem; }
.language-override p { margin: 0.6rem 0; }
.language-override ul { margin: 0.4rem 0; font-size: 0.9rem; }
.language-override .error { color: var(--bad); }
.asked-limits-input { width: min(28rem, 100%); }

.answer-key-status {
    margin: 0.75rem 0;
    font-size: 0.875rem;
    color: var(--lead);
}
.answer-key-status.error { color: var(--bad); }
.marking-adjustments {
    background: var(--warn-tint);
    border: 1px solid var(--warn-rule);
    border-radius: var(--radius-s);
    color: var(--warn-text);
    padding: 0.5rem 0.75rem;
}

/* Column-hint box (Print sheets) and generator notes (PowerPoints). */
.format-hint {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.875rem;
}
.format-hint ul { margin-top: 0.3rem; }
.format-hint-note {
    color: var(--lead);
    font-size: 0.875rem;
    line-height: 1.5;
}
.format-hint-note em {
    font-style: normal;
    font-weight: 500;
    color: var(--graphite);
    background: var(--rule-soft);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}

/* ── Scan queue ────────────────────────────────────────────────────────── */

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.queue-item {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}
.queue-item.is-processing { border-color: var(--ink); }
.queue-item-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.7rem 1rem;
}
.queue-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 14rem;
    min-width: 0;
}
.queue-item-layout {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--lead);
}
.queue-item-layout select { font-size: 0.875rem; min-height: 2rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.queue-item-layout-badge { font-size: 0.8125rem; color: var(--lead); }
.queue-item-start { padding: 0.4rem 1.1rem; }
.queue-item-queued { font-size: 0.875rem; color: var(--lead); }

.queue-item-status {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.status-waiting    { background: var(--paper); color: var(--lead); border: 1px solid var(--rule); }
.status-processing { background: var(--ink-tint); color: var(--ink-strong); }
.status-done       { background: var(--ok-tint); color: var(--ok); }
.status-error      { background: var(--bad-tint); color: var(--bad); }

.progress-bar { margin: 0.75rem 0; }
.queue-item .progress-bar { margin: 0; padding: 0 1rem 0.75rem; }
.progress-track {
    height: 6px;
    background: var(--rule-soft);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--ink);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-label {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: var(--lead);
    font-variant-numeric: tabular-nums;
}

/* Per-page results under a queued file. */
.results-table { overflow-x: auto; }
.queue-item .results-table {
    border-top: 1px solid var(--rule-soft);
    max-height: 320px;
    overflow-y: auto;
}
.results-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}
.results-table th, .results-table td {
    padding: 0.45rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--rule-soft);
}
.results-table th {
    background: var(--paper);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--lead);
    position: sticky;
    top: 0;
}
.results-table tr.flagged { background: var(--bad-tint); }
.results-table tr.ok:hover { background: var(--paper); }
.results-table td.missed-hw { color: var(--bad); font-weight: 600; }
.answers-cell {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.04em;
}
.streaming-indicator {
    text-align: center;
    color: var(--ink-strong);
    padding: 0.75rem;
    font-size: 0.875rem;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Review: classes scanned ───────────────────────────────────────────── */

.scan-grid-card {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem 1.25rem;
    margin-bottom: 1.25rem;
}
.scan-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.scan-grid-title { margin: 0 0 0.2rem; font-size: 1.125rem; }
.scan-grid-subtitle {
    margin: 0.2rem 0 0;
    color: var(--lead);
    font-size: 0.875rem;
    max-width: 70ch;
}
.scan-grid-warning {
    margin: 0.5rem 0 0;
    padding: 0.55rem 0.8rem;
    background: var(--warn-tint);
    color: var(--warn-text);
    border: 1px solid var(--warn-rule);
    border-left: 4px solid var(--warn);
    border-radius: var(--radius-s);
    font-size: 0.875rem;
    max-width: 80ch;
}
.scan-grid-unprocessable {
    margin: 0.35rem 0 0;
    padding-left: 1.2rem;
    font-size: 0.875rem;
    color: var(--warn-text);
}
.wipe-btn { white-space: nowrap; }

.scan-grid-legend {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    color: var(--lead);
}
.scan-grid-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    border: 1px solid transparent;
}
.legend-swatch.filled { background: var(--ok-tint); border-color: #b9d8bd; }
.legend-swatch.in-progress { background: var(--ink-tint); border-color: #b3d6d2; }
.legend-swatch.warning { background: var(--bad-tint); border-color: var(--bad-rule); }
.legend-swatch.unmatched { background: var(--warn-tint); border-color: var(--warn-rule); }

.scan-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
}
.scan-grid-empty {
    margin: 0;
    padding: 1rem;
    width: 100%;
    color: var(--lead);
    font-size: 0.9375rem;
    background: var(--paper);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    max-width: none;
}
.scan-grid-col {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 0 0 130px;
    max-width: 130px;
}
.scan-grid-col-header {
    font-family: var(--font-cond);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--graphite);
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--graphite);
}
.scan-cell {
    position: relative;
    aspect-ratio: 1.25;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}
.scan-cell.in-progress { background: var(--ink-tint); border-color: #b3d6d2; color: var(--ink-strong); }
.scan-cell.filled      { background: var(--ok-tint); border-color: #b9d8bd; color: var(--ok); }
.scan-cell.warning     { background: var(--bad-tint); border-color: var(--bad-rule); color: var(--bad); }
.scan-cell.unmatched   { background: var(--warn-tint); border-color: var(--warn-rule); color: var(--warn); }
.scan-cell-label {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: inherit;
}
.scan-cell-score {
    font-family: var(--font-cond);
    font-size: 1.35rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.scan-cell-warning {
    position: absolute;
    top: 4px;
    right: 7px;
    font-size: 0.85rem;
    font-weight: 600;
}
.scan-cell-count {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 0.75rem;
    color: inherit;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

/* ── Reports ───────────────────────────────────────────────────────────── */

.report-options-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
    font-size: 0.9375rem;
}
.report-opt { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.report-opt-inline { margin-right: 0.75rem; }
.report-opt-num { width: 4.5rem; }
.report-opt-text { width: min(28rem, 100%); }
.report-opt-hint { display: block; font-size: 0.8125rem; color: var(--lead); margin-top: 0.2rem; }
.class-lists-file { color: var(--lead); margin-right: 0.5rem; }
.class-lists-ok { color: var(--ok); font-size: 0.875rem; margin: 0; }

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.75rem;
    margin-top: 1rem;
}
.report-generate-row { margin-top: 0; }
.report-generate-btn { font-size: 1rem; padding: 0.65rem 1.5rem; }
.report-generate-row .format-hint-note { flex-basis: 100%; }

.report-results {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}
.report-ready {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
}
/* a pencilled-in bubble: done */
.report-ready::before {
    content: "";
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--graphite);
}
.report-week + .report-week { margin-top: 1.25rem; }
.report-week h3 { margin: 0.25rem 0; }

.report-diagnostics {
    margin: 0.75rem 0;
    padding: 0.65rem 1rem 0.65rem 2rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--lead);
}
.report-diagnostics .diag-warning { color: var(--warn); font-weight: 600; }

.report-open-tab {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink-strong);
}
.report-preview {
    width: 100%;
    height: 78vh;
    margin-top: 0.75rem;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--sheet);
}

.history-hint { font-size: 0.875rem; color: var(--lead); margin: 0.5rem 0; }
.history-import { display: block; margin: 0.5rem 0 0.75rem; font-size: 0.9rem; }
.history-import-error { color: var(--bad); font-size: 0.875rem; }
.history-count { font-size: 0.9rem; font-weight: 600; margin: 0.5rem 0 0.6rem; }
.history-dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 4.5rem;
    padding: 1rem;
    margin: 0 0 0.75rem;
    border: 1.5px dashed var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--graphite);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.history-dropzone:hover { border-color: var(--ink); }
.history-dropzone.dragover { border-color: var(--ink); background: var(--ink-tint); }
.history-dropzone:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.history-file-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.history-dropzone-hint { color: var(--lead); }
.history-empty { color: var(--lead); font-size: 0.9rem; }

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}
.history-table th, .history-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
}
.history-table th { font-size: 0.8125rem; font-weight: 600; color: var(--lead); }
.history-actions { white-space: nowrap; }
.history-actions button {
    font-size: 0.8125rem;
    margin: 0 0.35rem 0.2rem 0;
    padding: 0.25rem 0.7rem;
}

.order-table tr.order-earlier td { background: var(--ok-tint); }
.order-table tr.order-unclear td { background: var(--warn-tint); }
.order-table select { font-size: 0.8125rem; min-height: 1.9rem; padding-top: 0.15rem; padding-bottom: 0.15rem; }
.order-rest { margin-top: 0.6rem; font-size: 0.875rem; }
.week-scores span, .week-scores strong { display: inline-block; margin-right: 0.6rem; white-space: nowrap; }

/* ── Print sheets ──────────────────────────────────────────────────────── */

.pupil-list {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.pupil-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--rule);
}
.pupil-count { font-size: 0.9375rem; font-weight: 600; }
.pupil-clear-btn { font-size: 0.8125rem; padding: 0.25rem 0.75rem; }
.pupil-list-table { max-height: 220px; overflow-y: auto; }
.pupil-list-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}
.pupil-list-table th, .pupil-list-table td {
    padding: 0.3rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--rule-soft);
}
.pupil-list-table th {
    background: var(--paper);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--lead);
    position: sticky;
    top: 0;
}

.sheet-preview {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0 1.5rem;
}
.preview-frame {
    max-height: 520px;
    overflow: auto;
    border: 1px solid var(--rule-soft);
    background: var(--paper);
    margin-bottom: 1rem;
}
.preview-frame svg { display: block; width: 100%; height: auto; background: #fff; }
.sheet-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
}
.pupil-sheet-info { font-size: 0.875rem; color: var(--lead); }
.sheet-actions button { font-size: 0.9375rem; padding: 0.6rem 1.4rem; }
.sheet-actions button:disabled { cursor: wait; }

/* Layout D substitutions review panel. */
.d-subs {
    margin-top: 1.25rem;
    border: 1px solid var(--bad-rule);
    border-radius: var(--radius);
    padding: 1rem;
    background: #fffafa;
}
.d-subs-title { margin: 0 0 0.25rem; font-size: 1rem; color: var(--bad); }
.d-subs-help { margin: 0 0 0.75rem; font-size: 0.875rem; color: var(--lead); }
.d-subs-none { margin: 0; font-size: 0.9rem; color: var(--ok); font-weight: 500; }
.d-subs-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.d-subs-table th, .d-subs-table td {
    text-align: left;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #f0d9d9;
    vertical-align: top;
}
.d-subs-table th { color: var(--lead); font-weight: 600; }
.d-subs-raw { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--lead); }
.d-subs-notes { margin: 0; padding-left: 1.1rem; }
.d-subs-notes li { margin: 0.1rem 0; }
.d-subs-warning { color: var(--bad); font-weight: 600; }
.d-subs-warn-row td { background: var(--bad-tint); }
.d-subs-warning-summary { color: var(--bad); font-weight: 600; margin: 0 0 0.75rem; font-size: 0.9rem; }

.year10-attempted-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: var(--lead);
    cursor: pointer;
    margin-right: 0.5rem;
}

/* ── PowerPoints ───────────────────────────────────────────────────────── */

/* Question-format picker (Scan step + PowerPoints tab) */
.format-picker {
    margin: 0.75rem 0 0.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.5rem;
}
.format-picker-label { font-weight: 600; font-size: 0.9375rem; }
.format-picker-option { display: inline-flex; align-items: baseline; gap: 0.35rem; cursor: pointer; }
.format-picker-option.disabled { opacity: 0.55; cursor: not-allowed; }
.format-picker > .format-hint-note { flex-basis: 100%; margin: 0.15rem 0 0; }
.format-picker-option .format-hint-note { font-size: 0.8125rem; }

.pacing-controls {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin: 0.25rem 0 0.5rem;
}
.pacing-controls label { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; cursor: pointer; }
.pacing-controls .format-hint-note { margin: 0; }
.pacing-slider { transition: opacity 0.15s; }
.pacing-slider.disabled { opacity: 0.45; }
.pacing-slider input[type="range"] { flex: 0 1 12rem; }
.pacing-slider strong { font-variant-numeric: tabular-nums; min-width: 2.5rem; }

.coverage-wrap.stage { border-bottom: none; }
.coverage-wrap > summary.stage-title { display: block; margin: 0; }
.coverage-wrap[open] > summary.stage-title { margin-bottom: 0.5rem; }
.coverage-scroll { overflow-x: auto; margin-top: 0.5rem; }
.coverage-table { border-collapse: collapse; font-size: 0.8125rem; background: var(--sheet); }
.coverage-table th, .coverage-table td {
    border: 1px solid var(--rule-soft);
    padding: 0.25rem 0.55rem;
    text-align: center;
    white-space: nowrap;
}
.coverage-table thead th { background: var(--paper); font-weight: 600; color: var(--lead); }
.coverage-table .cov-subject { text-align: left; font-weight: 600; }
.coverage-table td { color: var(--rule-strong); }
.coverage-table td.covered { color: var(--ok); font-weight: 600; }
.coverage-table .col-selected { background: var(--ink-tint); }
.coverage-table thead th.col-selected { background: var(--ink); color: #fff; }

.deck-actions {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}
.deck-actions .btn-primary { font-size: 0.9375rem; padding: 0.6rem 1.3rem; }

.deck-preview {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.deck-preview h3 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.deck-round, .deck-class {
    margin: 0.4rem 0;
    padding: 0.5rem 0.75rem;
    background: var(--paper);
    border: 1px solid var(--rule-soft);
    border-radius: var(--radius);
}
.deck-class > .deck-round { background: var(--sheet); }
.deck-note { color: var(--lead); font-size: 0.8125rem; margin: 0.3rem 0; }
.deck-columns {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.deck-column { flex: 1 1 0; min-width: 16rem; }
.deck-column h4 { margin: 0.3rem 0; font-size: 0.95rem; }
.deck-questions { padding-left: 1.3rem; margin: 0.3rem 0; }
.deck-questions > li { margin-bottom: 0.6rem; }
.deck-q-text { font-weight: 600; }
.deck-options {
    list-style: none;
    padding-left: 0.6rem;
    margin: 0.15rem 0 0;
    color: var(--lead);
}
.deck-options .deck-correct { color: var(--ok); font-weight: 600; }

/* ── Dialogs, lock screen, footer ──────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(38, 42, 47, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-card {
    background: var(--sheet);
    border-radius: 8px;
    border-top: 4px solid var(--warn);
    padding: 1.5rem 1.75rem;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(38, 42, 47, 0.25);
}
.modal-card h2 { margin: 0 0 0.6rem; font-size: 1.3rem; }
.modal-card p { margin: 0 0 1.25rem; color: var(--lead); font-size: 0.9375rem; }
.modal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.modal-btn.modal-cancel { border-color: transparent; color: var(--lead); }
.modal-btn.modal-cancel:hover { border-color: var(--rule-strong); }

.lock-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--paper);
}
.lock-card {
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 2.25rem 2rem 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.lock-card h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.lock-card p { color: var(--lead); font-size: 0.9375rem; margin: 0 auto 1.5rem; }
.lock-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.lock-card input {
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.15em;
    padding: 0.6rem 0.85rem;
}
.lock-card input.invalid { border-color: var(--bad); }
.lock-card button { font-size: 0.9375rem; padding: 0.65rem 1rem; }
.lock-card .lock-error {
    margin: 0.85rem 0 0;
    color: var(--bad);
    font-size: 0.875rem;
}

.build-status {
    margin-top: 2.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--rule);
    color: var(--lead);
    font-size: 0.75rem;
    text-align: center;
}

/* ── Small screens ─────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .masthead-inner, .omr-app { padding-left: 1rem; padding-right: 1rem; }
    .masthead-sub { display: none; }
    .step-head h2 { font-size: 1.4rem; }
    .stepper-pill { min-width: 0; }
    .stepper-step:not(:last-child)::after {
        left: calc(50% + 1.6rem);
        right: calc(-50% + 1.6rem);
    }
    .ht-week-layout-badge { margin-left: 0; }
    .scan-grid-header { flex-direction: column; }
    .scan-grid-col { flex-basis: calc(50% - 0.4rem); max-width: none; }
    .step-next-row { flex-wrap: wrap; }
    .step-next-note:not(:empty) { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
