/* public/assets/styles.css
   Visual language: warm editorial paper, rust accent, minimal furniture.
   Information hierarchy lives in the row layout — every signal has its own lane. */

/* ─── Tokens ─────────────────────────────────────────────────────────── */
:root {
    --bg: #faf8f3;
    --paper: #ffffff;
    --paper-dim: #f4f0e7;
    --ink: #1c1a17;
    --ink-dim: #7a766e;
    --ink-faint: #a39e92;
    --muted: #b3aea3;
    --rule: #e3ddcf;
    --rule-strong: #c9c1ad;
    --accent: #b34a2a;
    --accent-soft: #d97152;

    /* Confidence colours: muted, distinct hues, accessible-ish */
    --c1: #d96a5a;   /* 1 — red */
    --c2: #e6925b;   /* 2 — orange */
    --c3: #d9b94a;   /* 3 — yellow */
    --c4: #98b95a;   /* 4 — lime */
    --c5: #5a9468;   /* 5 — green */

    /* Row-tint colours (5–10% strength of the confidence colour) */
    --c1-tint: #fae8e4;
    --c2-tint: #fbeede;
    --c3-tint: #faf3d6;
    --c4-tint: #ecf3da;
    --c5-tint: #e1ecdf;

    --required-bg: #eef5ec;
    --not-required-bg: #f6ecec;
    --notes-bg: #f3efe2;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-underline-offset: 3px;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover {
    text-decoration-color: var(--accent);
}
a:visited {
    color: var(--ink-dim);
    text-decoration-color: color-mix(in srgb, var(--ink-dim) 35%, transparent);
}
a:visited:hover {
    text-decoration-color: var(--ink-dim);
}
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ─── Site furniture ─────────────────────────────────────────────────── */
.site-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}
.site-header__home {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    font-size: 1.1rem;
}
.site-header__sub { color: var(--ink-dim); font-size: 0.9rem; }
.site-header__user {
    margin-left: auto;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.875rem;
}
.site-header__name     { color: var(--ink-dim); }
.site-header__nav-link  { color: var(--ink-dim); text-decoration: none; }
.site-header__nav-link:hover { color: var(--ink); text-decoration: underline; }
.site-header__auth-link { color: var(--accent); text-decoration: none; }
.site-header__auth-link:hover { text-decoration: underline; }

@media (max-width: 620px) {
    .site-header {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    .site-header__sub { display: none; }
}
@media (max-width: 410px) {
    .site-header__user .role-badge { display: none; }
}
.site-header__home-short { display: none; }
@media (max-width: 450px) {
    .site-header__home-full  { display: none; }
    .site-header__home-short { display: inline; }
}

.role-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    line-height: 1;
}
.role-badge--teacher { background: var(--accent); color: #fff; }
.role-badge--pupil   { background: var(--c5);     color: #fff; }
.site-header__user .role-badge {
    font-size: 0.58rem;
    padding: 0.13rem 0.45rem;
}

.container { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

.site-footer {
    text-align: center;
    color: var(--ink-dim);
    padding: 2rem 1rem;
    border-top: 1px solid var(--rule);
    margin-top: 3rem;
}

.breadcrumb {
    color: var(--ink-dim);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--ink-dim); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ─── Component tab bar ─────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--rule);
    margin-bottom: 1.75rem;
}
.tab-bar__tab {
    padding: 0.55rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--ink-dim);
}
.tab-bar__tab:hover { color: var(--ink); }
.tab-bar__tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ─── Spec index ─────────────────────────────────────────────────────── */
.component { margin-bottom: 2.5rem; }
.component h2 {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.3rem;
}
.component .paper {
    font-weight: normal;
    color: var(--ink-dim);
    margin-left: 0.5rem;
    font-size: 0.9rem;
}
.topic { margin: 1.5rem 0 2.5rem; }
.topic h3 { margin: 0; color: var(--ink); }
.topic__header h3 { margin: 0; }
.subtopic-list { list-style: none; padding-left: 0; margin-top: 0; }
.subtopic-list li { padding: 0.3rem 0; }
.subtopic-list a {
    display: inline-flex;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--ink);
}
.subtopic-list a:hover .title { text-decoration: underline; }
.subtopic-list .code {
    font-family: ui-monospace, monospace;
    color: var(--accent);
    min-width: 3rem;
}

/* Pupil-stats variant of a subtopic list item */
.subtopic-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.subtopic-item .subtopic-item__link {
    flex: 1 1 0;
    min-width: 0;
    display: flex; /* override inline-flex so it stretches */
}
.subtopic-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    text-align: center;
}
.stat-pupil-row { display: flex; align-items: center; gap: 0.5rem; }
.stat-pupil-row__name {
    font-size: 0.75rem;
    color: var(--ink-dim);
    flex: 1;
    text-align: right;
    white-space: nowrap;
}

/* Taught count chip (subtopic level) */
.stat-taught {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    line-height: 1.5;
    width: 3rem;
    box-sizing: border-box;
    text-align: center;
    background: var(--paper-dim);
    color: var(--ink-dim);
}

/* Topic-level smooth loading bar */
.topic-bar {
    width: 5rem;
    height: 8px;
    flex-shrink: 0;
    align-self: center;
    margin-top: 5px;
    border-radius: 4px;
    background: var(--paper-dim);
    position: relative;
    overflow: hidden;
}
.topic-bar::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--fill, 0%);
    border-radius: 4px;
}
.topic-bar--c1::after { background: var(--c1); }
.topic-bar--c2::after { background: var(--c2); }
.topic-bar--c3::after { background: var(--c3); }
.topic-bar--c4::after { background: var(--c4); }
.topic-bar--c5::after { background: var(--c5); }

/* Mean confidence chip */
.stat-conf {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    line-height: 1.5;
    width: 2.8rem;
    box-sizing: border-box;
    text-align: center;
}
.stat-conf--none { background: var(--paper-dim); color: var(--ink-faint); }
.stat-conf--1 { background: var(--c1-tint); color: var(--c1); }
.stat-conf--2 { background: var(--c2-tint); color: var(--c2); }
.stat-conf--3 { background: var(--c3-tint); color: var(--c3); }
.stat-conf--4 { background: var(--c4-tint); color: var(--c4); }
.stat-conf--5 { background: var(--c5-tint); color: var(--c5); }


/* ─── Spec index: topic header ───────────────────────────────────────── */
.topic__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}
.topic__header h3 { margin: 0; line-height: 1; }

/* ─── Spec index: subtopic column headers ────────────────────────────── */
/* Rendered as the first <li> inside .subtopic-list using the same
   .subtopic-item / .subtopic-stats structure as data rows — guarantees alignment. */
.subtopic-col-headers { pointer-events: none; }
.subtopic-col-headers,
.subtopic-col-headers .subtopic-stats {
    font-size: 0.65rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
/* Fixed widths must match stat-taught / stat-conf / stat-quiz exactly */
.col-taught { width: 3rem;   box-sizing: border-box; padding: 0.1rem 0.4rem; }
.col-conf   { width: 2.8rem; box-sizing: border-box; padding: 0.1rem 0.4rem; }
.col-quiz   { width: 3rem;   box-sizing: border-box; padding: 0.1rem 0.4rem; }

/* On very narrow screens, stack teacher stats below the subtopic link */
@media (max-width: 560px) {
    .subtopic-col-headers--teacher,
    .subtopic-col-headers--pupil { display: none; }
    .subtopic-item { flex-wrap: wrap; }
    .subtopic-item .subtopic-stats { flex-basis: 100%; flex-direction: column; align-items: stretch; }
    .stat-class-row { display: flex; align-items: center; gap: 0.5rem; }
    .subtopic-stats .stat-class-row__name {
        display: block;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.75rem;
        color: var(--ink-dim);
        text-decoration: none;
        text-align: right;
    }
    .subtopic-stats .stat-class-row__name:hover { text-decoration: underline; }
    .stat-taught-class { flex-shrink: 0; width: auto; }
    .topic__header { margin-bottom: 0.75rem; }
}

/* Teacher per-class taught column header — width matches stat-taught-class chip */
.subtopic-col-headers a {
    color: inherit;
    text-decoration: none;
}
.subtopic-col-headers a:hover .col-taught-class {
    text-decoration: underline;
}
.col-taught-class {
    width: 5rem;
    box-sizing: border-box;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-dim);
    text-align: center;
    overflow-wrap: break-word;
    pointer-events: auto;
}

/* Wide-screen: wrapper is transparent so chips flow directly in .subtopic-stats */
@media (min-width: 561px) {
    .stat-class-row { display: contents; }
    .subtopic-stats .stat-class-row__name { display: none; }
    .stat-pupil-row { display: contents; }
    .stat-pupil-row__name { display: none; }
}

/* Teacher per-class taught chip */
.stat-taught-class {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    line-height: 1.5;
    width: 5rem;
    box-sizing: border-box;
    text-align: center;
    background: var(--paper-dim);
    color: var(--ink-dim);
}
.stat-taught-class--c1 { background: var(--c1-tint); color: var(--c1); }
.stat-taught-class--c2 { background: var(--c2-tint); color: var(--c2); }
.stat-taught-class--c3 { background: var(--c3-tint); color: var(--c3); }
.stat-taught-class--c4 { background: var(--c4-tint); color: var(--c4); }
.stat-taught-class--c5 { background: var(--c5-tint); color: var(--c5); }

/* ─── Spec index: quiz score chip ────────────────────────────────────── */
.stat-quiz {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    line-height: 1.5;
    width: 3rem;
    box-sizing: border-box;
    text-align: center;
    background: var(--paper-dim);
    color: var(--ink);
}
.stat-quiz--none  { color: var(--ink-faint); }
.stat-quiz--empty { visibility: hidden; }

/* ─── Subtopic header ────────────────────────────────────────────────── */
.subtopic-header h1 { margin: 0.5rem 0 0.25rem; }
.subtopic-header .code {
    font-family: ui-monospace, monospace;
    color: var(--accent);
}

/* ─── Statements list ────────────────────────────────────────────────── */
.statements { margin: 1.5rem 0 2rem; }

/* Group wrapper */
.group { margin: 1rem 0 0.75rem; }
.group__title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-dim);
    margin: 0 0 0.4rem;
    padding-left: 0.25rem;
}

/* ─── The statement row ──────────────────────────────────────────────── */
/*
   Three-column grid:
     1. 6px lit-status stripe
     2. The body (marker + text + meta), flexible
     3. The confidence cluster, auto-width
*/
.row {
    display: grid;
    grid-template-columns: var(--row-cols, 6px 1fr auto);
    align-items: stretch;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.row:hover,
.row:focus-within {
    border-color: var(--rule-strong);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    outline: none;
}
.row--static {
    cursor: default;
}
.row--static:hover {
    border-color: var(--rule);
    box-shadow: none;
}

/* Lit indicator strip */
.row__lit { background: transparent; border-radius: 8px 0 0 8px; }
.row.is-taught .row__lit { background: var(--c5); }

/* Untaught: dim the whole row */
.row.is-untaught {
    background: var(--paper-dim);
    border-color: var(--rule);
}
.row.is-untaught .row__body,
.row.is-untaught .row__aside { opacity: 0.45; }

/* Confidence tints (taught rows only — untaught + confidence is a edge case) */
.row.is-conf-1 { background: var(--c1-tint); }
.row.is-conf-2 { background: var(--c2-tint); }
.row.is-conf-3 { background: var(--c3-tint); }
.row.is-conf-4 { background: var(--c4-tint); }
.row.is-conf-5 { background: var(--c5-tint); }

/* ─── Row body ───────────────────────────────────────────────────────── */
.row__body {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    min-width: 0;
}
.row__marker {
    flex: 0 0 1.6rem;
    width: 1.6rem;
    height: 1.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    background: var(--paper);
    line-height: 1;
}
.row.is-taught .row__marker {
    background: var(--c5);
    color: var(--paper);
    border-color: var(--c5);
}
@media (max-width: 400px) {
    .row__marker { display: none; }
}
.row__text {
    flex: 1 1 auto;
    min-width: 0;
}

/* ─── Right-hand aside: pips (row 1) + meta indicators (row 2) ──────── */
.row__aside {
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border-left: 1px dashed var(--rule);
    min-width: 4.5rem;
}

/* ─── Meta row: pencil icon + quiz score ─────────────────────────────── */
.row__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    color: var(--ink-dim);
    font-size: 0.8rem;
    font-feature-settings: "tnum";
    min-height: 1rem;
    cursor: pointer;
}
.meta-icon {
    width: 0.95rem;
    height: 0.95rem;
    color: var(--ink-faint);
    flex: 0 0 auto;
}
.meta-icon.meta-notes { color: #ccc; }
.meta-notes.is-active { color: var(--accent); }
.meta-quiz--empty { visibility: hidden; }
.meta-quiz {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
    min-width: 4rem;
}
.meta-quiz strong {
    color: var(--ink);
    font-weight: 600;
}

/* ─── Confidence pips ────────────────────────────────────────────────── */
.conf-pips {
    display: inline-flex;
    gap: 0.3rem;
    padding: 0.25rem 0.4rem;
    border-radius: 999px;
    /* Pips fade in on hover/focus */
    opacity: 0.25;
    transition: opacity 0.15s ease;
}
.row:hover .conf-pips,
.row:focus-within .conf-pips,
.row.is-engaged .conf-pips { opacity: 1; }
@media (hover: none) {
    /* No-hover devices (touch): pips always visible */
    .conf-pips { opacity: 1; }
}

.pip {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    border: 1.5px solid var(--rule-strong);
    background: var(--paper);
    padding: 0;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.pip:hover { transform: scale(1.15); }
.conf-pips[data-rating="1"] .pip:nth-child(-n+1) { border-color: var(--c1); background: var(--c1); }
.conf-pips[data-rating="2"] .pip:nth-child(-n+2) { border-color: var(--c2); background: var(--c2); }
.conf-pips[data-rating="3"] .pip:nth-child(-n+3) { border-color: var(--c3); background: var(--c3); }
.conf-pips[data-rating="4"] .pip:nth-child(-n+4) { border-color: var(--c4); background: var(--c4); }
.conf-pips[data-rating="5"] .pip:nth-child(-n+5) { border-color: var(--c5); background: var(--c5); }

/* ─── Required / Not-required / Notes panels ─────────────────────────── */
.guidance {
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}
.guidance h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.guidance--required     { background: var(--required-bg); }
.guidance--not-required { background: var(--not-required-bg); }
.notes { background: var(--notes-bg); padding: 1rem 1.25rem; border-radius: 6px; }
.notes h2 { margin: 0 0 0.5rem; font-size: 1rem; }

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28,26,23,0.4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
.modal {
    background: var(--paper);
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal__header {
    padding: 1.1rem 1.25rem 0.8rem;
    border-bottom: 1px solid var(--rule);
    display: flex;
    transition: background 0.2s;
    align-items: flex-start;
    gap: 1rem;
}
.modal__title {
    margin: 0;
    flex: 1;
    font-size: 1.05rem;
    line-height: 1.4;
    font-weight: 600;
}
.modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--ink-dim);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    flex: 0 0 auto;
}
.modal__close:hover { color: var(--ink); }
.modal__header.is-conf-1 { background: var(--c1-tint); }
.modal__header.is-conf-2 { background: var(--c2-tint); }
.modal__header.is-conf-3 { background: var(--c3-tint); }
.modal__header.is-conf-4 { background: var(--c4-tint); }
.modal__header.is-conf-5 { background: var(--c5-tint); }
.modal__body { padding: 0.25rem 1.25rem 1.25rem; }

.modal__section { padding: 0.85rem 0; }
.modal__section + .modal__section { border-top: 1px dashed var(--rule); }
.modal__section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 600;
}
.modal__section--meta {
    color: var(--ink-dim);
    font-size: 0.85rem;
}
.modal__section--meta h3 {
    color: var(--ink-faint);
    font-size: 0.7rem;
}
.modal .conf-pips { opacity: 1; padding-left: 0; }

.modal__conf-label {
    color: var(--ink-dim);
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}
.modal__conf-label strong { color: var(--ink); }

.modal__notes-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.modal__notes-header h3 { margin: 0; }
.modal__notes-status {
    font-size: 0.75rem;
    color: var(--ink-faint);
    font-style: italic;
}
.modal__notes textarea {
    width: 100%;
    min-height: 5rem;
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0.6rem;
    resize: vertical;
}

.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.4rem 0.9rem;
    font: inherit;
    font-size: 0.85rem;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
}
.btn:visited { color: white; }
.btn:hover { background: var(--accent-soft); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn--outline:visited { color: var(--accent); }
.btn--outline:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }

.modal__quiz {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
}
.modal__quiz-stats {
    color: var(--ink-dim);
    font-size: 0.9rem;
}
.modal__quiz-stats strong { color: var(--ink); }
.modal__quiz a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}
.modal__quiz a:hover { text-decoration: underline; }

.modal__taught { font-size: 0.85rem; margin: 0; }

.modal__log {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}
.modal__log li {
    padding: 0.15rem 0;
    display: flex;
    gap: 0.6rem;
}
.modal__log time {
    flex: 0 0 6rem;
    color: var(--ink-faint);
}

/* ─── Auth forms ─────────────────────────────────────────────────────── */
.auth-card {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 2rem;
}
.auth-card h1 {
    margin: 0 0 1.5rem;
    font-size: 1.4rem;
}
.form-group {
    margin-bottom: 1.1rem;
}
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
    display: block;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    background: var(--bg);
    color: var(--ink);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.4;
    appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237a766e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 2rem;
}
.form-group input:focus,
.form-group select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
.form-hint {
    font-weight: 400;
    color: var(--ink-dim);
    font-size: 0.8rem;
}
.form-error {
    background: #fdf0ee;
    border-left: 3px solid var(--accent);
    color: var(--accent);
    padding: 0.6rem 0.8rem;
    margin-bottom: 1.25rem;
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
}
.form-success {
    background: #eef5ec;
    border-left: 3px solid var(--c5);
    color: #2d6b3a;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1.25rem;
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
}
.form-fieldset {
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1rem 1rem 0.25rem;
    margin-bottom: 1.25rem;
}
.form-fieldset legend {
    padding: 0 0.4rem;
    font-size: 0.875rem;
    color: var(--ink-dim);
}
.btn-primary {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 1.5rem;
}
.btn-primary:hover { background: var(--accent-soft); }
.auth-footer {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--ink-dim);
    text-align: center;
}
.auth-footer a { color: var(--accent); }

/* ─── Page header (title + inline action) ───────────────────────────── */
.page-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; }
.btn-primary--inline {
    display: inline-block;
    width: auto;
    padding: 0.35rem 0.9rem;
    font-size: 0.875rem;
    margin-top: 0;
    text-decoration: none;
}

/* ─── Class list ─────────────────────────────────────────────────────── */
.class-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.class-card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.class-card__main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex: 1 1 auto;
}
.class-card__name { font-weight: 600; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.class-card__name:hover { text-decoration: underline; }
.class-card__year { color: var(--ink-dim); font-size: 0.875rem; }
.class-card__meta { color: var(--ink-dim); font-size: 0.875rem; }
.class-card__code-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}
.class-card__code-label { color: var(--ink-dim); }
.enrolment-code {
    font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: var(--paper-dim);
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    color: var(--accent);
}
.empty-state { color: var(--ink-dim); }
.class-card__active {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--c5);
    white-space: nowrap;
}
.class-card__activate {
    font-size: 0.875rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}
.class-card__activate:hover { text-decoration: underline; }

/* ─── Current class panel (join page) ───────────────────────────────── */
.current-class {
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}
.current-class__label { margin: 0 0 0.2rem; font-size: 0.8rem; color: var(--ink-dim); }
.current-class__name  { margin: 0; font-weight: 600; font-size: 1.05rem; }
.current-class__year  { font-weight: 400; color: var(--ink-dim); font-size: 0.9rem; }

/* ─── Teacher multi-class columns ────────────────────────────────────── */
.class-header {
    display: grid;
    margin-bottom: 0.25rem;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg);
}
.class-header__cell {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-dim);
    padding: 0.25rem 0.5rem;
    border-left: 1px dashed var(--rule);
    min-width: 3.5rem;
    overflow-wrap: break-word;
}
.class-header__cell a {
    color: inherit;
    text-decoration: none;
}
.class-header__cell a:hover { text-decoration: underline; }
.row__class-col {
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px dashed var(--rule);
    min-width: 3.5rem;
}
.row__class-col input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--c5);
    cursor: pointer;
}

/* Pips are interactive for pupils */
.conf-pips .pip { cursor: pointer; }

/* ─── Admin nav link ─────────────────────────────────────────────────── */
.site-header__nav-link--admin {
    color: var(--accent) !important;
    font-weight: 600;
}

/* ─── Info panel ─────────────────────────────────────────────────────── */
.info-panel {
    background: var(--paper);
    border-left: 3px solid var(--ink-dim);
    border-radius: 5px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}
.info-panel p { margin: 0 0 0.5rem; }
.info-panel p:last-child { margin-bottom: 0; }

/* ─── Flash messages ─────────────────────────────────────────────────── */
.flash {
    padding: 0.6rem 0.9rem;
    border-radius: 5px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.flash--error   { background: #fdf0ee; border-left: 3px solid var(--accent); color: var(--accent); }
.flash--success { background: var(--c5-tint); border-left: 3px solid var(--c5); color: var(--c5); }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn--danger { background: #c0392b; }
.btn--danger:hover { background: #a93226; }

/* Inline text-style action links */
.btn-text {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.875rem;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
}
.btn-text:hover { text-decoration: underline; }
.btn-text:disabled { opacity: 0.35; cursor: default; }
.btn-text--danger { color: #c0392b; }

/* ─── Manage class page ──────────────────────────────────────────────── */
.manage-section {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.manage-section__title {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-dim);
    font-weight: 600;
}
.manage-rename {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.manage-rename input[type="text"] {
    flex: 1;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    font: inherit;
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--ink);
    max-width: 28rem;
}
.manage-rename input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.teacher-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.teacher-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}
.teacher-row:last-child { border-bottom: none; }
.teacher-row__name { font-weight: 500; min-width: 10rem; }
.teacher-row__you  { font-weight: 400; color: var(--ink-faint); font-size: 0.8rem; }
.teacher-row__email { flex: 1; color: var(--ink-dim); font-size: 0.85rem; }

.manage-add-teacher { margin-top: 0.75rem; }
.manage-add-teacher__label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}
.manage-add-teacher__row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.manage-add-teacher input[type="email"] {
    flex: 1;
    max-width: 22rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--ink);
}
.manage-add-teacher input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}

.danger-zone { border-color: #f5c6c0; }
.danger-zone .manage-section__title { color: #c0392b; }
.danger-zone__actions { display: flex; flex-direction: column; gap: 1rem; }
.danger-zone__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.danger-zone__desc { flex: 1; }
.danger-zone__desc strong { display: block; margin-bottom: 0.2rem; }
.danger-zone__desc p { margin: 0; font-size: 0.85rem; color: var(--ink-dim); }

/* ─── Admin section headings ─────────────────────────────────────────── */
.admin-section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-dim);
    margin: 1.75rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--rule);
}
.admin-section-heading:first-of-type { margin-top: 0; }
.admin-section-heading--deleted { color: #c0392b; border-color: #f5c6c0; }

/* ─── Admin table ────────────────────────────────────────────────────── */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
}
.admin-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--paper-dim);
    border-bottom: 1px solid var(--rule);
    font-weight: 600;
    color: var(--ink-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.admin-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table__row--deleted td { color: var(--ink-faint); }
.admin-table__row--deleted .admin-table__name { text-decoration: line-through; }
.admin-table__name a { color: var(--ink); text-decoration: none; }
.admin-table__name a:hover { color: var(--accent); text-decoration: underline; }
.admin-table__actions { display: flex; gap: 0.75rem; align-items: center; white-space: nowrap; }

/* Badge */
.badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
}
.badge--active  { background: var(--c5-tint); color: var(--c5); }
.badge--deleted { background: #fdf0ee; color: #c0392b; }

/* Smaller enrolment code variant for tables */
.enrolment-code--sm {
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
    letter-spacing: 0.05em;
}

/* ─── Teacher class list: dashboard link ─────────────────────────────── */
.class-card__actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.class-card__dashboard,
.class-card__manage {
    font-size: 0.875rem;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}
.class-card__dashboard:hover,
.class-card__manage:hover { text-decoration: underline; }
.class-card__manage { color: var(--ink-dim); }
.class-card__shared {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--c5);
    background: var(--c5-tint);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}

/* ─── Teacher dashboard: heatmap ─────────────────────────────────────── */
.dash-year { font-weight: 400; color: var(--ink-dim); font-size: 0.85em; }

.dash-view {
    font-size: 0.875rem;
    color: var(--ink-dim);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.dash-view__link {
    color: var(--ink-dim);
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.dash-view__link:hover { color: var(--ink); background: var(--paper-dim); }
.dash-view__link.is-active { color: var(--accent); font-weight: 600; background: var(--paper-dim); }

.heatmap-wrap { overflow-x: auto; margin-bottom: 2rem; }
.heatmap {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
}
.heatmap th {
    background: var(--paper-dim);
    color: var(--ink-dim);
    font-weight: 600;
    padding: 0.45rem 0.6rem;
    text-align: center;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}
.heatmap__name-col { text-align: left; min-width: 8rem; }
.heatmap__topic-col { min-width: 2.8rem; font-size: 0.78rem; }
.heatmap__total-col  { min-width: 4rem; }

.heatmap td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); text-align: center; }
.heatmap tbody tr:last-child td { border-bottom: none; }
.heatmap tbody tr:hover td { background: var(--paper-dim); }

.heatmap__name { text-align: left; }
.heatmap__name a { color: var(--ink); text-decoration: none; }
.heatmap__name a:hover { color: var(--accent); text-decoration: underline; }

.heatmap__cell { font-feature-settings: "tnum"; font-size: 0.8rem; }
.heatmap__cell.is-conf-1, .heatmap__total.is-conf-1 { background: var(--c1-tint); color: var(--c1); }
.heatmap__cell.is-conf-2, .heatmap__total.is-conf-2 { background: var(--c2-tint); color: var(--c2); }
.heatmap__cell.is-conf-3, .heatmap__total.is-conf-3 { background: var(--c3-tint); color: var(--c3); }
.heatmap__cell.is-conf-4, .heatmap__total.is-conf-4 { background: var(--c4-tint); color: var(--c4); }
.heatmap__cell.is-conf-5, .heatmap__total.is-conf-5 { background: var(--c5-tint); color: var(--c5); }

.heatmap__total { font-weight: 600; color: var(--ink); font-size: 0.82rem; font-feature-settings: "tnum"; }

.heatmap th[data-sort-type] { cursor: pointer; user-select: none; }
.heatmap th[data-sort-type].is-sorted-asc::after  { content: '▴'; }
.heatmap th[data-sort-type].is-sorted-desc::after { content: '▾'; }

/* ─── Teacher dashboard: pupil detail ────────────────────────────────── */
.dash-component { margin-bottom: 2.5rem; }
.dash-component__title {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.3rem;
    margin-bottom: 0.75rem;
}
.dash-topic { margin: 1.25rem 0 0.5rem; }
.dash-topic__title { margin: 0 0 0.5rem; font-size: 1rem; color: var(--ink); }
.dash-subtopic { margin: 0.75rem 0 0.75rem 0.5rem; }
.dash-subtopic__title {
    font-size: 0.85rem;
    margin: 0 0 0.4rem;
    color: var(--ink-dim);
}
.dash-subtopic__title .code {
    font-family: ui-monospace, monospace;
    color: var(--accent);
}
.dash-group { margin: 0.5rem 0 0.5rem 0.5rem; }
.dash-group__title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    margin: 0.35rem 0 0.3rem;
}

/* Pupil detail statement row */
.dash-stmt-wrap { margin-bottom: 0.35rem; }
.dash-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    transition: background 0.15s;
}
.dash-row.is-taught   { border-left: 3px solid var(--accent); }
.dash-row.is-untaught { background: var(--paper-dim); }
.dash-row.is-untaught .conf-pips,
.dash-row.is-untaught .dash-row__text { opacity: 0.55; }

.dash-row.is-conf-1 { background: var(--c1-tint); }
.dash-row.is-conf-2 { background: var(--c2-tint); }
.dash-row.is-conf-3 { background: var(--c3-tint); }
.dash-row.is-conf-4 { background: var(--c4-tint); }
.dash-row.is-conf-5 { background: var(--c5-tint); }

/* Read-only pips in dash rows */
.dash-row .conf-pips { opacity: 1; flex: 0 0 auto; }
.dash-row .conf-pips .pip { cursor: default; }

.dash-row__text { flex: 1 1 auto; font-size: 0.9rem; min-width: 0; }

.dash-row__note-btn {
    background: none;
    border: none;
    padding: 0.1rem 0.2rem;
    cursor: pointer;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    color: var(--accent);
}
.dash-row__note-btn:hover { opacity: 0.75; }

/* Note expansion below the row */
.dash-note-body {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--ink-dim);
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-top: none;
    border-radius: 0 0 6px 6px;
    white-space: pre-wrap;
    margin-top: -0.35rem;
}
.dash-note-body[hidden] { display: none; }

/* ─── Teacher dashboard: taught management ───────────────────────────── */
.tm-component { margin-bottom: 2rem; }
.tm-comp-heading {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--rule);
}

.tm-topic { border-bottom: 1px solid var(--rule); }
.tm-topic__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    color: var(--ink);
}
.tm-topic__header:hover .tm-topic__title { color: var(--accent); }
.tm-topic__arrow {
    font-size: 0.6rem;
    color: var(--ink-faint);
    flex-shrink: 0;
    transition: transform 0.15s;
}
.tm-topic.is-open .tm-topic__arrow { transform: rotate(90deg); }
.tm-topic__title { flex: 1; font-weight: 600; font-size: 0.9rem; }
.tm-topic__count {
    font-size: 0.78rem;
    color: var(--ink-dim);
    background: var(--paper-dim);
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    flex-shrink: 0;
    font-feature-settings: "tnum";
}
.tm-topic__count.is-complete { background: var(--c5-tint); color: var(--c5); font-weight: 600; }
.tm-topic__check-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--ink-dim);
    font-weight: 400;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.tm-topic__body { display: none; padding: 0.25rem 0 0.5rem 0.75rem; }
.tm-topic.is-open .tm-topic__body { display: block; }

.tm-subtopic { margin: 0.3rem 0; }
.tm-subtopic__header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.6rem;
    background: var(--paper-dim);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}
.tm-subtopic__check { flex-shrink: 0; cursor: pointer; }
.tm-subtopic__title { flex: 1; }
.tm-subtopic__count {
    font-size: 0.78rem;
    color: var(--ink-dim);
    flex-shrink: 0;
    font-feature-settings: "tnum";
}
.tm-markall {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--ink-dim);
    font-weight: 400;
    flex-shrink: 0;
}
.tm-markall[hidden] { display: none; }

.tm-stmts { list-style: none; margin: 0; padding: 0; }
.tm-stmt {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--rule);
    font-size: 0.875rem;
    transition: background 0.1s;
}
.tm-stmt:last-child { border-bottom: none; }
.tm-stmt.is-taught { background: var(--c5-tint); }
.tm-stmt.is-selected { background: var(--c3-tint); }
.tm-stmt.is-taught.is-selected { background: var(--c3-tint); }
.tm-stmt__check { flex-shrink: 0; margin-top: 0.2rem; cursor: pointer; }
.tm-stmt__text { flex: 1; color: var(--ink); line-height: 1.45; }

/* ─── Quiz: take page ─────────────────────────────────────────────────── */

.quiz-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.quiz-header h1 { flex: 1 1 auto; margin: 0; font-size: 1.3rem; }
.quiz-header__right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 0 0 auto;
}
.quiz-tally { font-size: 1rem; color: var(--ink-dim); }
.quiz-tally__score { font-weight: 700; color: var(--ink); margin-right: 0.2rem; }
.quiz-tally__pct { color: var(--ink-dim); font-size: 0.9rem; }
.quiz-tally--empty { font-size: 0.9rem; color: var(--ink-faint); }
.quiz-end {
    font-size: 0.9rem;
    color: var(--ink-dim);
    text-decoration: none;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    white-space: nowrap;
}
.quiz-end:hover { background: var(--paper-dim); }

.quiz-card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* Question state */
.quiz-question__context {
    font-size: 0.85rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0 0 0.5rem;
}
.quiz-question__stem {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1.25rem;
    line-height: 1.4;
}
.quiz-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.5rem 0;
}
.quiz-code {
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin: 0.6rem 0;
    font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
    font-size: 0.875rem;
    font-weight: normal;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
}
.quiz-options {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.quiz-option-btn {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
    transition: background 0.1s, border-color 0.1s;
}
.quiz-option-btn:hover { background: var(--paper-dim); border-color: var(--accent); }
.quiz-option-letter {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--rule);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-dim);
}

/* Feedback state */
.quiz-feedback { border-left: 4px solid var(--rule-strong); }
.quiz-feedback--correct { border-left-color: var(--c5); }
.quiz-feedback--wrong   { border-left-color: var(--c1); }
.quiz-feedback__result {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.quiz-feedback--correct .quiz-feedback__result { color: var(--c5); }
.quiz-feedback--wrong   .quiz-feedback__result { color: var(--c1); }
.quiz-feedback__stem { font-size: 1rem; color: var(--ink-dim); margin: 0 0 1rem; }
.quiz-feedback__explanation {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: var(--paper-dim);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--ink-dim);
}

.quiz-options--review {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.quiz-options--review .quiz-option {
    padding: 0.6rem 1rem;
    border: 1px solid var(--rule);
    border-radius: 6px;
    font-size: 0.95rem;
    color: var(--ink-dim);
}
.quiz-options--review .quiz-option--correct {
    background: var(--c5-tint);
    border-color: var(--c5);
    color: var(--ink);
    font-weight: 600;
}
.quiz-options--review .quiz-option--chosen {
    background: var(--c1-tint);
    border-color: var(--c1);
    color: var(--ink);
}

.quiz-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.quiz-next { flex: 0 0 auto; }

.preview-banner {
    font-size: 0.85rem;
    color: var(--ink-dim);
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 0.4rem 0.75rem;
    margin: 0 0 1.25rem;
}

/* Subtopic page: teacher quiz management link */

/* Subtopic page: take-quiz CTA button below header */
.quiz-cta {
    margin: 0 0 1.25rem;
}
.quiz-cta .btn {
    display: inline-flex;
    align-items: baseline;
    gap: 0.6rem;
    font-size: 0.95rem;
    padding: 0.5rem 1.1rem;
    text-decoration: none;
}
.quiz-cta__meta {
    font-size: 0.8rem;
    opacity: 0.85;
}


/* Teacher quiz form */
.quiz-form { max-width: 640px; }
.quiz-form .form-group { margin-bottom: 1.25rem; }
.quiz-form label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.4rem; }
.quiz-form select,
.quiz-form textarea,
.quiz-form input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--paper);
    color: var(--ink);
}
.quiz-form select:focus,
.quiz-form textarea:focus,
.quiz-form input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }
.stem-builder {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.stem-block {
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    overflow: hidden;
}
.stem-block__controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding: 0.35rem 0.6rem;
    background: var(--paper-dim);
    border-bottom: 1px solid var(--rule);
}
.stem-block__type {
    width: auto;
    font-size: 0.85rem;
    padding: 0.15rem 0.3rem;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: var(--paper);
    cursor: pointer;
}
.stem-block__value {
    display: block;
    border: none;
    border-radius: 0;
    resize: vertical;
}
.stem-block__value[hidden],
.stem-block__image-wrap[hidden] { display: none; }
.stem-block__value[data-type="code"] {
    font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
    font-size: 0.875rem;
    background: var(--paper-dim);
}
.stem-block__value:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: transparent; }
.stem-block__image-wrap { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.5rem 0; }
.stem-block__thumb { max-width: 240px; max-height: 180px; object-fit: contain; border-radius: 4px; border: 1px solid var(--rule); }
.stem-block__current-file { font-size: 0.8rem; color: var(--ink-dim); margin: 0; }
.stem-builder__add { margin-top: 0.1rem; }
.quiz-form__options {
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}
.quiz-form__options legend {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0 0.4rem;
}
.quiz-form__legend-hint { font-weight: 400; color: var(--ink-faint); font-size: 0.8rem; }
.quiz-form__option-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.quiz-form__option-row:last-child { margin-bottom: 0; }
.quiz-form__radio-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    font-weight: 600;
    min-width: 2.5rem;
}
.quiz-form__option-input { flex: 1 1 auto; }
.form-label-hint { font-weight: 400; color: var(--ink-faint); font-size: 0.8rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }

/* Teacher quiz question table */
.quiz-table .quiz-table__stmt { color: var(--ink-dim); font-size: 0.85rem; max-width: 200px; }

/* ─── Question flagging (pupil) ──────────────────────────────────────── */
.quiz-flag { margin-top: 0.75rem; }
.quiz-flag__toggle {
    font-size: 0.85rem;
    color: var(--ink-dim);
    cursor: pointer;
    user-select: none;
}
.quiz-flag__toggle:hover { color: var(--ink); }
.quiz-flag[open] .quiz-flag__toggle { color: var(--ink); }
.quiz-flag form {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 480px;
}
.quiz-flag__reason {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--paper);
    color: var(--ink);
    resize: vertical;
    min-height: 3rem;
}
.quiz-flag__reason:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Flag count badge on teacher quiz question list */
.flag-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.45rem;
    background: #fff3e0;
    border: 1px solid #f0a830;
    border-radius: 3px;
    font-size: 0.75rem;
    color: #8a5500;
    font-weight: 600;
    text-decoration: none;
    vertical-align: middle;
}
a.flag-badge:hover { background: #ffe0b2; text-decoration: none; }

/* ─── Flags review table (teacher) ──────────────────────────────────── */
.flags-table .flags-table__subtopic { color: var(--ink-dim); font-size: 0.85rem; white-space: nowrap; }
.flags-table .flags-table__stmt     { color: var(--ink-dim); font-size: 0.85rem; max-width: 180px; }
.flags-table .flags-table__reason   { font-size: 0.9rem; max-width: 220px; }
.flags-table__no-reason             { color: var(--ink-faint); font-style: italic; }

/* Dismiss-flag checkbox in the edit form */
.quiz-form__flag-dismiss {
    padding: 0.75rem 1rem;
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 6px;
    margin-bottom: 1.25rem;
}
.quiz-form__flag-dismiss label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
}

/* Flags nav link when there are open flags */
.site-header__nav-link--flagged { color: #8a5500; font-weight: 600; }

/* ─── User dropdown ───────────────────────────────────────────────────── */
.site-header__dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.site-header__dropdown-trigger {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: inherit;
}
.site-header__dropdown-trigger:hover .site-header__name,
.site-header__dropdown.is-open .site-header__dropdown-trigger .site-header__name { color: var(--ink); }
.site-header__chevron {
    font-size: 0.65rem;
    color: var(--ink-faint);
    transition: transform 0.15s ease, color 0.15s ease;
    align-self: center;
    line-height: 1;
}
.site-header__dropdown-trigger:hover .site-header__chevron { color: var(--ink-dim); }
.site-header__dropdown.is-open .site-header__chevron {
    transform: rotate(180deg);
    color: var(--ink-dim);
}
.site-header__dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 0.5rem;
    background: transparent;
    z-index: 100;
    min-width: 140px;
}
.site-header__dropdown-menu::before {
    content: '';
    position: absolute;
    top: 0.5rem;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: -1;
}
.site-header__dropdown.is-open .site-header__dropdown-menu { display: block; }
@media (hover: hover) {
    .site-header__dropdown:hover .site-header__dropdown-menu { display: block; }
}
.site-header__dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--ink-dim);
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
}
.site-header__dropdown-item:hover { color: var(--ink); background: var(--paper-dim); }
.site-header__dropdown-item--admin { color: var(--accent) !important; font-weight: 600; }
.site-header__dropdown-item--admin:hover { background: var(--paper-dim); }
.site-header__dropdown-divider { border: none; border-top: 1px solid var(--rule); margin: 0.25rem 0; }

/* ─── Spec badge (GCSE / A-level chip on class cards & admin table) ──── */
.spec-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--paper-dim);
    color: var(--ink-dim);
    border: 1px solid var(--rule);
    vertical-align: middle;
    margin-left: 0.3rem;
}

/* ─── Spec switcher (tab bar above spec index for multi-spec users) ──── */
.spec-switcher {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--rule);
    padding-bottom: 0;
}
.spec-switcher__tab {
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 4px 4px 0 0;
    transition: color 0.1s;
}
.spec-switcher__tab:hover { color: var(--ink); }
.spec-switcher__tab.is-active {
    color: var(--accent);
    font-weight: 700;
    border-bottom-color: var(--accent);
}
.spec-switcher__default {
    margin-left: auto;
    display: flex;
    align-items: center;
}
.spec-switcher__default-label {
    font-size: 0.8rem;
    color: var(--ink-faint);
}
.spec-switcher__set-default {
    font-size: 0.8rem;
    color: var(--ink-dim);
}
.spec-switcher__set-default:hover { color: var(--accent); }

/* ─── Spec picker (multi-spec pupils with no preference set) ─────────── */
.spec-picker {
    max-width: 480px;
    margin: 3rem auto;
    text-align: center;
}
.spec-picker__prompt {
    font-size: 1rem;
    color: var(--ink-dim);
    margin-bottom: 1.5rem;
}
.spec-picker__cards {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.spec-picker__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.5rem 2rem;
    background: var(--paper);
    border: 2px solid var(--rule);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    min-width: 160px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.spec-picker__card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.spec-picker__code {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    font-family: ui-monospace, monospace;
}
.spec-picker__title {
    font-size: 0.85rem;
    color: var(--ink-dim);
    text-align: center;
    line-height: 1.3;
}
.spec-picker__level {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
}
.spec-picker-empty {
    text-align: center;
    margin: 3rem auto;
}
.spec-picker-empty__msg {
    font-size: 1rem;
    color: var(--ink-dim);
    margin-bottom: 1.25rem;
}

/* ─── Info panel variant: warning ────────────────────────────────────── */
.info-panel--warn {
    border-left-color: #d97152;
    background: #fdf3ee;
}

/* ─── Content clarification info button + popover ────────────────────── */
.info-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1.5px solid var(--ink-dim);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--ink-dim);
    width: 1.15rem;
    height: 1.15rem;
    padding: 0;
    line-height: 1;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
    pointer-events: auto;
    vertical-align: middle;
}
.info-btn:hover,
.info-btn:focus-visible {
    color: var(--ink);
    border-color: var(--ink);
    background: var(--paper-dim);
    outline: none;
}

#info-popover {
    position: fixed;
    z-index: 300;
    background: var(--ink);
    color: var(--bg);
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.55;
    box-shadow: 0 4px 20px rgba(0,0,0,0.28);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    top: 0;
    left: -9999px;
    max-width: 320px;
}
#info-popover.is-visible {
    opacity: 1;
}

/* ─── CSS tooltip (data-tooltip attribute) ───────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    right: calc(100% + 8px);
    transform: translateY(-50%);
    background: var(--ink);
    color: var(--bg);
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.4;
    width: max-content;
    max-width: 260px;
    white-space: pre-wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── My classes page (pupil) ────────────────────────────────────────── */
.my-classes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.my-classes-list__item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 0.9rem;
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}
.my-classes-list__info { flex: 1 1 auto; }
.my-classes-list__name { font-weight: 600; }
.my-classes-list--empty { color: var(--ink-dim); margin: 0; }
.my-classes-divider { border: none; border-top: 1px solid var(--rule); margin: 1.25rem 0; }

/* ─── Pupil management list (teacher dashboard) ───────────────────────── */
.pupil-mgmt-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.pupil-mgmt-list__item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
    background: var(--paper-dim);
    border: 1px solid var(--rule);
    border-radius: 6px;
    margin-bottom: 0.4rem;
}
.pupil-mgmt-list__info { flex: 1 1 auto; min-width: 0; }
.pupil-mgmt-list__name { font-weight: 600; display: block; }
.pupil-mgmt-list__username { font-size: 0.82rem; color: var(--ink-dim); }
.pupil-mgmt-list__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.my-classes-subtitle { font-size: 1rem; font-weight: 600; margin: 0 0 0.4rem; }
