/* ROLLOVERS: every :hover style sits inside @media (hover: hover), so that it applies only where there is a pointer to
   move off again. On a touch screen (phone or tablet) it would stay on after a tap. Do the same for new ones. */

/* =========================================================================
   Design tokens, shared with the other OET interactive pages
   (see oet-design-system.css). Same custom-property names, same colours,
   same radii/shadow, same button behaviour, so this teacher/student portal
   reads as the same product as the practice-test pages. Dark mode follows
   the visitor's OS preference by default; the toggle in Nav.php overrides
   it by setting data-theme="light"/"dark" on <html>, which always wins.
   ========================================================================= */
:root {
    --bg:            #f4f6f8;
    --panel:         #ffffff;
    --ink:           #1c2530;
    --muted:         #5b6675;
    --border:        #d8dee5;

    --accent:        #0f71f0;   /* MEUK blue */
    --accent-ink:    #ffffff;

    --correct:       #1c7c3f;
    --correct-bg:    #e6f6ea;
    --incorrect:     #b3261e;
    --tl-red:        #d93025;   /* the three traffic lights: the same in light and dark mode */
    --tl-amber:      #f5a300;
    --tl-green:      #2e9e4f;
    --incorrect-bg:  #fdeceb;
    --warn:          #92400e;
    --warn-bg:       #fef3c7;

    --hl:            #fff2a8;
    --hl-border:     #e0b800;
    --blue:            #8ec5ff;
    --blue-bg:         #17407a;

    --btn-disabled:  #aab3bb;

    /* Review-page fields: editable ones are plainly different from read-only ones */
    --edit-bg:       #ffffff;
    --edit-ink:      #1c2530;
    --edit-border:   #8794a3;
    --ro-bg:         #eceff3;
    --ro-ink:        #5b6675;
    --st-approve:    #0b6e63;   /* "Approve changes" (teal) */
    --st-pending:    #1a8f80;   /* "Edited but not approved" (lighter teal) */
    --st-done:       #0f71f0;   /* "Edited and approved" */

    --shadow: 0 2px 10px rgba(20, 30, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #12171c;
        --panel:         #1a2127;
        --ink:           #e8edf1;
        --muted:         #9aa7b2;
        --border:        #2c3641;

        --accent:        #3fc2ae;   /* MEUK teal */
        --accent-ink:    #08201c;

        --correct:       #59d98a;
        --correct-bg:    #123322;
        --incorrect:     #ff8a80;
        --incorrect-bg:  #3a1616;
        --warn:          #e8b944;
        --warn-bg:       #3a2e0a;

        --hl:            #5a4a00;
        --hl-border:     #c7a300;
        --blue:            #8ec5ff;
        --blue-bg:         #17407a;

        --btn-disabled:  #3a4652;

        --edit-bg:       #0c1014;
        --edit-ink:      #f4f7fa;
        --edit-border:   #54626f;
        --ro-bg:         #232c34;
        --ro-ink:        #9aa7b2;
        --st-approve:    #f5d84a;
        --st-pending:    #f0a030;
        --st-done:       #3fc2ae;

        --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
    }
}

:root[data-theme="dark"] {
    --bg:            #12171c;
    --panel:         #1a2127;
    --ink:           #e8edf1;
    --muted:         #9aa7b2;
    --border:        #2c3641;

    --accent:        #3fc2ae;   /* MEUK teal */
    --accent-ink:    #08201c;

    --correct:       #59d98a;
    --correct-bg:    #123322;
    --incorrect:     #ff8a80;
    --incorrect-bg:  #3a1616;
    --warn:          #e8b944;
    --warn-bg:       #3a2e0a;

    --hl:            #5a4a00;
    --hl-border:     #c7a300;
    --blue:            #8ec5ff;
    --blue-bg:         #17407a;

    --btn-disabled:  #3a4652;

    --edit-bg:       #0c1014;
    --edit-ink:      #f4f7fa;
    --edit-border:   #54626f;
    --ro-bg:         #232c34;
    --ro-ink:        #9aa7b2;
    --st-approve:    #f5d84a;
    --st-pending:    #f0a030;
    --st-done:       #3fc2ae;

    --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

/* Browsers don't give <button> the inherited body font by default the
   way <a> gets it automatically, without this, button-styled links
   and actual <button> elements render at different heights/weights
   even with identical padding. */
button {
    font: inherit;
}

/* Tick boxes and radio buttons take the same colour as the buttons */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
}

/* Base link colour so a plain <a> with no class (a back-navigation link,
   an inline "create one" prompt) is theme-aware, without this it falls
   back to the browser's default link blue, which is illegible/wrong
   against the dark background in dark mode. More specific rules
   (nav a, .button-link, etc.) override this as usual. */
a {
    color: var(--accent);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

main {
    padding: 2rem;
}

.auth-box {
    max-width: 320px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.auth-box input {
    padding: 0.5rem;
    margin-bottom: 1rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
}

.auth-box button {
    padding: 0.6rem;
    border-radius: 10px;
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    .auth-box button:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.error {
    color: var(--incorrect);
}

.required-mark {
    color: var(--incorrect);
}

.required-key {
    color: var(--muted);
    font-size: 0.85rem;
}

nav a,
nav .nav-current {
    margin-left: 1rem;
    font-size: 0.95rem;
}

nav a {
    color: var(--accent);
    text-decoration: none;
}

@media (hover: hover) {
    nav a:hover {
        text-decoration: underline;
    }
}

nav .nav-current {
    color: var(--muted);
    cursor: pointer;
}

/* Colour-only change (no added text/width) so new review-queue work
   doesn't shift the rest of the nav, see Nav::render(). */
nav a.nav-attention {
    color: var(--warn);
}

/* The tab you are on keeps its quiet colour even when it is the Review Queue with work waiting. */
nav a.nav-current {
    color: var(--muted);
}

/* Theme toggle, same outline/fill-on-hover button system as everywhere
   else, pill-shaped, with the sun/moon emoji + text label swapped in by
   Nav.php's script. A status/utility control, so it sits in the nav
   alongside the page links rather than needing its own chrome. */
#themeToggle {
    margin-left: 1rem;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

/* Rollover only where there is a pointer to roll off again: on a touch screen it would stay filled after a tap. */
@media (hover: hover) {
    #themeToggle:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

/* Both labels share one cell, so the button is as wide as the longer one in either mode. The label shown is the
   mode a click switches to: "Dark mode" while the page is light, "Light mode" while it is dark. */
#themeToggle { display: inline-grid; white-space: nowrap; padding-left: calc(0.9rem - 2px); }   /* 2 px off the left side: it was 2 px wider than the old light-mode button */
#themeToggle > span { grid-area: 1 / 1; text-align: center; }
#themeToggle > span[data-label="light"],
#themeToggle[data-theme="dark"] > span[data-label="dark"] { visibility: hidden; }
#themeToggle[data-theme="dark"] > span[data-label="light"] { visibility: visible; }

.task-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
}

.task-table th,
.task-table td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

.filter-bar {
    margin-bottom: 1.5rem;
}

.filter-bar select {
    padding: 0.4rem;
    background: var(--bg);
    color: var(--ink);
    border-radius: 8px;
    border: 1.5px solid var(--border);
}

.template-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.template-card .meta {
    color: var(--muted);
    margin-top: -0.5rem;
}

/* ---------------------------------------------------------------------
   Unified button system, every clickable control (nav links styled as
   buttons, form submits, row actions) shares one look and interaction:
   transparent fill with an accent outline at rest, solid accent fill on
   hover with text recoloured to stay legible, grey/disabled when
   inactive. Sizing varies per button; colour and interaction don't.
   --------------------------------------------------------------------- */
.template-card button,
.button-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 9px;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

@media (hover: hover) {
    .template-card button:hover,
    .button-link:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.task-form {
    display: flex;
    flex-direction: column;
    max-width: 640px;
    gap: 0.25rem;
}

.task-form input,
.task-form select,
.task-form textarea {
    padding: 0.5rem;
    margin-bottom: 1rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
}

.task-form input:focus,
.task-form select:focus,
.task-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.task-form button {
    align-self: flex-start;
    padding: 0.6rem 1.2rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 9px;
    color: var(--accent);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    .task-form button:hover:not(:disabled) {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.checkbox-label {
    display: block;
    font-weight: normal;
    margin-bottom: 0.4rem;
}

.checkbox-label input {
    margin-right: 0.4rem;
    width: auto;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 1rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.inline-form label {
    font-size: 0.9rem;
}

.inline-form input {
    padding: 0.5rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
}

.inline-form button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 9px;
    color: var(--accent);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    .inline-form button:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.actions {
    display: flex;
    gap: 0.5rem;
}

form.inline {
    display: inline;
}

.actions button,
.button-link.small {
    padding: 0.35rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-size: 0.9rem;
}

.button-link.small {
    color: var(--accent);
    border-color: var(--accent);
}

@media (hover: hover) {
    .button-link.small:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

button.danger {
    border: 1.5px solid var(--incorrect);
    color: var(--incorrect);
    background: transparent;
    padding: 0.5rem 1rem;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    button.danger:hover {
        background: var(--incorrect);
        color: var(--accent-ink);
    }
}

.reading-instruction {
    color: var(--muted);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--ink);
}

.badge.original {
    background: color-mix(in srgb, var(--accent) 15%, var(--bg));
    border-color: var(--accent);
    color: var(--accent);
}

.badge.draft {
    background: var(--warn-bg);
    border-color: var(--warn);
    color: var(--warn);
}

.badge.other {
    background: var(--blue-bg);
    border-color: var(--blue);
    color: var(--blue);
}

.badge.published {
    background: var(--hl);
    border-color: var(--hl-border);
    color: var(--hl-border);
}

.template-card button.green,
.button-link.green {
    border-color: var(--accent);
    color: var(--accent);
}

@media (hover: hover) {
    .template-card button.green:hover,
    .button-link.green:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.button-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.button-row form.inline {
    display: inline-flex;
}

.field-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.field-with-button input {
    flex: 1;
}

/* Shared box model for the app's two standard action-button variants,
   independent of whatever container they're in, .task-form button
   (above) sets its own padding for bare/unclassed buttons, which used
   to leave button.primary without any padding at all outside a
   .task-form, producing a visibly shorter button next to .secondary. */
button.primary,
button.secondary {
    padding: 0.6rem 1.2rem;
    border-radius: 9px;
    font-size: 1rem;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

button.secondary {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--muted);
}

@media (hover: hover) {
    button.secondary:hover:not(:disabled) {
        border-color: var(--ink);
        color: var(--ink);
    }
}

button.secondary:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

button.primary {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}

@media (hover: hover) {
    button.primary:hover:not(:disabled) {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

button.primary:disabled {
    color: var(--btn-disabled);
    border-color: var(--btn-disabled);
    cursor: not-allowed;
}

/* Bare .task-form buttons (no .primary/.secondary - e.g. "Save as
   Draft", task-edit.php's "Update") get the same disabled treatment as
   button.primary above; .primary/.secondary keep their own rules. */
.task-form button:not(.primary):not(.secondary):disabled {
    color: var(--btn-disabled);
    border-color: var(--btn-disabled);
    cursor: not-allowed;
}

.button-link.secondary-link {
    background: transparent;
    color: var(--muted);
    border: 1.5px solid var(--border);
}

@media (hover: hover) {
    .button-link.secondary-link:hover {
        background: var(--bg);
        color: var(--ink);
        border-color: var(--ink);
    }
}

.clickable-summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
}

.speak-teacher {
    color: var(--accent);
    font-weight: 600;
}

@media (hover: hover) {
    .clickable-summary:hover {
        text-decoration: underline;
    }
}

.add-panel {
    margin-top: 1.5rem;
}

.add-panel > .task-form {
    margin-top: 1rem;
}

.locked-field {
    color: var(--muted);
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.dashboard-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.dashboard-panel h2 {
    margin-top: 0;
}

.account-info {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.5rem;
    margin: 0;
}

.account-info dt {
    font-weight: 600;
    color: var(--muted);
}

.account-info dd {
    margin: 0;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg);
}

.stat-tile.highlight {
    background: var(--warn-bg);
}

/* "Awaiting your review": the same yellow as the "Published by" badge in the Task Library, in light and dark mode */
.stat-tile.stat-tile-link.highlight {
    background: var(--hl);
    border: 1px solid var(--hl-border);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.completion-row {
    display: grid;
    grid-template-columns: 280px 1fr 3rem;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.completion-label {
    display: flex;
    flex-direction: column;
}

/* Progress bar: side-by-side segments, one per stage a student's work has
   reached - green (returned), amber (marked), red (submitted) - then the
   grey track for everyone yet to submit. The track is a plain pale grey
   with an outline so the coloured fills always stand out from it. */
.completion-bar {
    display: flex;
    background: #e9edf1;
    border: 1px solid #8b96a3;
    border-radius: 5px;
    height: 1.1rem;
    overflow: hidden;
}

.completion-task .completion-row + .completion-row .completion-bar { height: 0.55rem; }

.completion-bar-fill {
    height: 100%;
    flex: none;
}

.completion-bar-fill.stage-submitted { background: #d93025; }
.completion-bar-fill.stage-marked    { background: #f5a300; }
.completion-bar-fill.stage-returned  { background: var(--correct); }

.completion-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.8rem;
    font-size: 0.85rem;
}

.completion-stages .stage::before {
    content: "";
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    margin-right: 0.3rem;
}

.completion-stages .stage-submitted::before { background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 20 20%22%3E%3Cpath fill=%22%23d93025%22 fill-rule=%22evenodd%22 d=%22M0 10a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0z%22/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.completion-stages .stage-marked::before    { background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 20 20%22%3E%3Cpath fill=%22%23f5a300%22 fill-rule=%22evenodd%22 d=%22M0 10a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM7 10a3 3 0 1 0 6 0a3 3 0 1 0-6 0z%22/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
.completion-stages .stage-returned::before  { background: var(--correct); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .completion-bar { background: #2c3641; border-color: #6b7886; }
}
:root[data-theme="dark"] .completion-bar { background: #2c3641; border-color: #6b7886; }

/* Phones: label on its own line, bar and percentage underneath. */
@media (max-width: 640px) {
    .completion-row {
        grid-template-columns: 1fr 3rem;
        gap: 0.35rem 0.75rem;
    }
    .completion-label {
        grid-column: 1 / -1;
    }
}

.completion-percent {
    text-align: right;
    font-size: 0.9rem;
    color: var(--muted);
}

/* ------------------------------------------------------------
   Student-facing pages
   ------------------------------------------------------------ */

.student-main {
    max-width: 760px;
    margin: 0 auto;
}

.task-brief {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.task-brief h2 {
    margin-top: 0;
}

.case-notes {
    white-space: pre-wrap;
    font-family: inherit;
    background: var(--bg);
    border-radius: 6px;
    padding: 1rem;
    margin: 0;
}

/* Borderless table for generated "Label: value" case-note rows (see
   TextFormat::notes()), lines up every value in a block regardless of
   label length, the way the real exam paper does, without needing a
   monospace font or manual padding. */
.notes-table {
    border-collapse: collapse;
    margin: 0.15em 0 0.6em;
}

.notes-table td {
    padding: 0 0 0.15em;
    vertical-align: top;
}

.notes-table td.notes-table-label {
    padding-right: 1.5em;
    white-space: nowrap;
}

.task-table .status-cell {
    text-align: center;
}

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--ink);
}

.status-pill.status-progress {
    background: color-mix(in srgb, var(--accent) 15%, var(--bg));
    border-color: var(--accent);
    color: var(--accent);
}

.status-pill.status-waiting {
    background: var(--warn-bg);
    border-color: var(--warn);
    color: var(--warn);
}

.status-pill.status-expired,
.status-pill.status-error {
    background: var(--incorrect-bg);
    border-color: var(--incorrect);
    color: var(--incorrect);
}

.status-pill.status-ready {
    background: var(--correct-bg);
    border-color: var(--correct);
    color: var(--correct);
}

.feedback-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.feedback-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
}

.feedback-card.feedback-green {
    border-left-color: var(--tl-green);
}

.feedback-card.feedback-amber {
    border-left-color: var(--tl-amber);
}

.feedback-card.feedback-red {
    border-left-color: var(--tl-red);
}

.feedback-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.traffic-light {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.traffic-light.traffic-green {
    background: var(--tl-green);
}

/* The three lights also differ in shape, so they can be told apart without colour: green is solid, amber is a
   ring with a small hole, red is a thinner ring with a large hole. Used at every size (see .rating-dot below). */
.traffic-light.traffic-amber,
.rating-dot-amber::before {
    background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 20 20%22%3E%3Cpath fill=%22%23f5a300%22 fill-rule=%22evenodd%22 d=%22M0 10a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM7 10a3 3 0 1 0 6 0a3 3 0 1 0-6 0z%22/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

.traffic-light.traffic-red,
.rating-dot-red::before {
    background: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 20 20%22%3E%3Cpath fill=%22%23d93025%22 fill-rule=%22evenodd%22 d=%22M0 10a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0z%22/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

.exercise-list {
    padding-left: 1.2rem;
}

.exercise-list li {
    margin-bottom: 0.4rem;
}

.exercise-answer-form {
    margin-top: 1rem;
}

.exercise-answer {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

/* Selection (Content) and reorder (Organisation and Layout) practice
   exercises, a list of items the student checks or numbers, rather
   than a free-text answer box. */
.exercise-option-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-option-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
}

.exercise-option-item label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
}

.exercise-reorder-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Numbered sentences move up the list; the browser must not scroll to keep up with them. */
.exercise-reorder-list { overflow-anchor: none; }

.exercise-reorder-select {
    flex: 0 0 auto;
    width: 3.2rem;
    padding: 0.3rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}

/* Linking-words (Organisation and Layout follow-up) practice exercise:
   the sentences read top to bottom in their already-correct order,
   each one (after the first) preceded by a dropdown for the
   signposting word that joins it to the sentence before it. */
.exercise-linking-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-linking-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* An answer judged correct is no longer a field: it is text, bold in the MEUK colour. */
.exercise-filled { color: var(--accent); font-weight: 700; }

.exercise-linking-select {
    flex: 0 0 auto;
    padding: 0.3rem 0.4rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}

/* Writing page: pinned to the viewport (no page scroll), case notes
   and instructions on the left, the letter on the right, each
   scrolling independently. Scoped to body.write-mode so every other
   page keeps its normal document scrolling. */

body.write-mode {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.write-mode header {
    flex: 0 0 auto;
}

.write-main {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem;
}

.task-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 1rem;
    flex: 0 0 auto;
}

.write-layout {
    flex: 1 1 auto;
    display: flex;
    gap: 1.5rem;
    width: 100%;
    min-height: 0;
}

.write-column {
    flex: 1 1 50%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.write-column h2 {
    flex: 0 0 auto;
    margin: 0 0 0.5rem;
}

.write-meta {
    flex: 0 0 auto;
}

body.writing-page .write-meta { font-size: 1.1rem; }   /* the due date: the same size as the task title above it */

.case-notes-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg);
    border-radius: 6px;
    padding: 1rem;
}

.instructions-block {
    flex: 0 0 auto;
    max-height: 45%;
    margin-top: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
}

.instructions-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.instructions-header h2 {
    margin: 0;
    font-size: 1rem;
}

.instructions-toggle {
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 7px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--accent);
    flex-shrink: 0;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    .instructions-toggle:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

.instructions-body {
    padding: 0.75rem 0.9rem;
    overflow-y: auto;
    min-height: 0;
}

.instructions-body.hidden {
    display: none;
}

.write-letter-column h2 {
    margin: 0 0 0.5rem;
}

.write-letter-form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.write-letter-form textarea {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: inherit;
}

.write-letter-form .meta,
.write-letter-form .button-row {
    flex: 0 0 auto;
}

/* ------------------------------------------------------------
   Teacher review / approve-and-send page, and the same pattern
   reused on the student's feedback view. Both live inside
   body.write-mode (see above) for the fixed-viewport, no-page-scroll
   behaviour, toggling between a "Reference" pane (reusing
   .write-layout etc. verbatim, read-only) and a "Feedback" pane:
   only one visible at a time so whichever is active fills the screen.
   ------------------------------------------------------------ */

.stat-tile-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.view-toggle {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    z-index: 1;
    display: flex;
    gap: 0.4rem;
}

.view-toggle-btn {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--muted);
    padding: 0.35rem 0.9rem;
    border-radius: 7px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

@media (hover: hover) {
    .view-toggle-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }
}

.view-toggle-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.feedback-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.feedback-view.hidden,
.write-layout.hidden {
    display: none;
}

.overall-block {
    flex: 0 0 auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}

/* A <p>/<ol>/<h2> brings its own browser margin; without this the first and last
   one add extra space inside the box on top of the padding above, same as a feedback-card
   would if its first child were a <p> instead of the zero-margin header div. */
.overall-block > *:first-child {
    margin-top: 0;
}

.overall-block > *:last-child {
    margin-bottom: 0;
}

.overall-block h2 {
    margin: 0 0 0.4rem;
}

.ai-draft-note {
    max-height: 4.2em;
    overflow-y: auto;
    margin: 0 0 0.4rem;
    color: var(--muted);
}

.review-summary,
.review-comment {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
}

/* Shown on a button while its click triggers a Claude API call the
   teacher has to wait on (generate task, mark now) - a plain disabled
   state alone looked identical to "nothing happened", so this spins
   for the duration of the page's own submit-to-reload wait. */
.btn-spinner {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.15em;
    animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Lets the comment box fill whatever height its card actually grew to
   (the 6-column grid stretches every card to match the tallest one) -
   without this it stayed at its rows="10" height regardless, so a
   longer comment (Content, typically more quoted examples) scrolled
   internally even when the card around it had unused space. */
.review-comment {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.review-summary:focus,
.review-comment:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.feedback-view .feedback-grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: repeat(6, 1fr);
    overflow-y: auto;
    margin-bottom: 0;
}

.review-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem 0.9rem;
    min-height: 0;
}

.rating-options {
    display: flex;
    gap: 0.9rem;
    padding: 0.3rem;
}

/* A fixed-size light; the chosen one gets a ring drawn outside it with a
   thin gap, so the light's own colour is never covered. */
.rating-dot {
    position: relative;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    cursor: pointer;
    border: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

.rating-dot input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.rating-dot:has(input:checked) {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
}

/* The same three colours in light and dark mode (the review page's lights) */
/* The coloured shape is drawn inside (so the selection outline on the button itself is never masked away). */
.rating-dot::before { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.rating-dot-green::before { background: var(--tl-green); }
.rating-dot-amber::before, .rating-dot-red::before { /* shape and colour: see .traffic-light above */ }

.approved-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--st-approve);
}

.approved-label[hidden] {
    display: none;
}

.feedback-view .overall-block,
.feedback-view .exercises-block {
    flex: 0 0 auto;
    margin-bottom: 0.75rem;
}

.feedback-view .exercises-block {
    max-height: 15%;
    overflow-y: auto;
}

/* Logo top-left of every page's header, and the shared footer. The
   header keeps its old look (title left, nav/link right) - the logo
   just leads it, and whatever comes last is pushed to the right edge. */
header {
    justify-content: flex-start;
    gap: 1rem;
}

header > :last-child:not(.site-logo):not(h1) {
    margin-left: auto;
}

.site-logo {
    flex: 0 0 auto;
    display: inline-flex;
    line-height: 0;
}

.site-logo img {
    height: 44px;
    width: auto;
}

.site-logo-standalone {
    padding: 1rem 2rem 0;
}

.site-footer {
    padding: 1.25rem 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.site-footer a {
    color: var(--muted);
}

/* The company name is a link to the homepage, in the interface colour: blue in light mode, teal in dark mode. */
.site-footer a {
    color: var(--accent);
    text-decoration: none;
}

@media (hover: hover) {
    .site-footer a:hover {
        text-decoration: underline;
    }
}

body.write-mode .site-footer {
    flex: 0 0 auto;
    padding-block: 0.5rem;
}

/* Menu fills the space beside the logo/title and right-aligns its
   items, including when it wraps onto a second line. */
header nav {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    row-gap: 0.4rem;
}

/* Footer stays fixed to the bottom of the window rather than scrolling
   with the page; the body gets matching bottom padding so the last of
   the content is never hidden behind it. */
body {
    padding-bottom: 2.75rem;
}

body.write-mode {
    box-sizing: border-box;
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    padding: 0.6rem 2rem;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

body.write-mode .site-footer {
    padding-block: 0.6rem;
}

/* Create Task: fit the window instead of scrolling. The case notes box
   takes whatever height is left after everything else (never less than
   6rem), so the page only scrolls if the window is genuinely too small. */
body.fit-page {
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

body.fit-page header {
    flex: 0 0 auto;
}

body.fit-page main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-block: 1rem;
}

body.fit-page .task-form {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

body.fit-page .task-form #source_notes {
    flex: 1 1 auto;
    min-height: 6rem;
    resize: none;
}

/* Keep the page title on one line so the menu wraps beside it rather than
   stacking the header tall. */
header h1 {
    flex: 0 0 auto;
    white-space: nowrap;
}

body.fit-page .task-form > * {
    flex-shrink: 0;
}

body.fit-page .task-form > #source_notes {
    flex-shrink: 1;
}

body.fit-page .task-form #instructions {
    min-height: 5rem;
}

body.fit-page .task-form input,
body.fit-page .task-form select,
body.fit-page .task-form textarea {
    margin-bottom: 0.5rem;
}

body.fit-page .task-form #instructions {
    min-height: 4rem;
}

body.fit-page .task-form #source_notes {
    min-height: 5rem;
}

body.fit-page main {
    padding-block: 2rem 0.5rem;   /* the same space under the menu bar as every other page with tabs */
}

body.fit-page .task-form > #instructions {
    flex: 1 1 4rem;
    min-height: 3rem;
    resize: none;
}

body.fit-page .task-form > #source_notes {
    flex: 2 1 auto;
}

body.fit-page main > p,
body.fit-page main > .button-row {
    margin-block: 0.25rem;
}

/* Practice links now sit at the foot of the feedback card they relate to. */
.feedback-card .card-exercises {
    margin: 0.6rem 0 0;
    padding: 0.5rem 0 0;
    list-style: none;
    border-top: 1px solid var(--border);
}

.feedback-card .card-exercises li {
    margin: 0.2rem 0;
}

/* Practice exercises: instructions are italic so they read as guidance,
   and the text the student actually works on sits in its own quoted block. */
.exercise-instruction {
    font-style: italic;
    margin: 0.6rem 0;
}

/* The points that finish an instruction, and the list of points that could go either way. */
.exercise-points { padding-left: 1.4rem; }
.exercise-points li { margin: 0.3rem 0; }

.exercise-target-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 1rem 0 0.3rem;
}

/* The text to work on is plain text on the card with only a thin accent line down its left side, no box, so it cannot be mistaken for the answer field
   (as on the teacher's edit-feedback page, where read-only text sits flat on the panel). */
.exercise-target {
    font-style: normal;
    background: none;
    border: 0;
    border-left: 2px solid var(--accent);
    border-radius: 0;
    padding: 0 0 0 0.9rem;
    margin: 0 0 1rem;
}

/* Live word count under a free-text answer box. */
.exercise-wordcount {
    font-size: 0.9rem;
    color: var(--muted);
    margin: 0 0 0.8rem;
}

.exercise-wordcount-over {
    color: #c0392b;
    font-weight: 600;
}

/* Attempt history beside a practice link: a small traffic light per try. */
.attempt-history .traffic-light {
    margin-left: 0.2rem;
    vertical-align: middle;
}

/* Case notes and task instructions can't be selected or copied. */
.no-copy {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* The attempt count and lights sit on their own line under the practice link. */
.feedback-card .card-exercises .attempt-history {
    display: block;
    margin-top: 0.1rem;
}

/* Task Library card: the prompt on the left, each time it was set for
   students (classes, then assigned-due dates; newest first) on the right.
   On narrow screens the list drops underneath. */
.template-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1.5rem;
}

.template-card > * {
    grid-column: 1;
}

.template-card > .template-instances {
    grid-column: 2;
    grid-row: 1 / span 4;
    align-self: start;
}

.template-instances {
    list-style: none;
    margin: 0.2rem 0 0;
    padding: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.template-instances li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.2rem 1.6rem;
    padding: 0.35rem 0;
}

/* One assignment: its classes, then "Practice or Exam - Due date" underneath; the Extend control sits on the right. */
.template-instances .instance-info { display: flex; flex-direction: column; min-width: 0; font-size: 1rem; } /* same size as the "Medicine - Referral Letter" line */
.template-instances .instance-classes { color: var(--ink); font-weight: 600; }
.template-instances .instance-dates { white-space: nowrap; }

@media (max-width: 720px) {
    .template-card {
        grid-template-columns: minmax(0, 1fr);
    }
    .template-card > .template-instances {
        grid-column: 1;
        grid-row: auto;
        margin-top: 0.8rem;
        padding-top: 0.2rem;
        border-top: 1px solid var(--border);
    }
    /* Each assignment: class names full width, then Practice/Exam and the due date, then Extend deadline */
    .template-instances li { grid-template-columns: minmax(0, 1fr); gap: 0.8rem; padding: 0.6rem 0; }
    .template-instances li + li { border-top: 1px solid var(--border); }
    .template-instances .instance-dates { white-space: normal; }
    .template-instances .instance-extend { width: 100%; }
    .template-instances .instance-extend select { flex: 1 1 auto; min-width: 0; }
    .template-instances .instance-extend button.secondary { flex: 0 0 auto; }
}

.template-instances .instance-extend { display: flex; align-items: center; gap: 0.4rem; }
.template-instances .instance-extend { align-items: stretch; }
.template-instances .instance-extend button.secondary,
.template-instances .instance-extend select {
    padding: 0.1rem 0.7rem; font-size: 0.85rem; line-height: 1.2; margin: 0; box-sizing: border-box;
}
/* The Extend drop-down: small, and in the interface colours like the other drop-downs */
.template-instances .instance-extend select {
    width: auto; min-height: 0; padding: 0.1rem 0.4rem;
    background: var(--bg); color: var(--ink);
    border: 1.5px solid var(--border); border-radius: 8px;
    font-family: inherit; cursor: pointer;
}
.template-instances .instance-extend select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Assignments whose due date has passed. */
.template-instances .instance-overdue {
    color: var(--incorrect);
}

/* Task Library: "Assigned tasks" and "Unassigned tasks" sections. */
.library-section {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 1.8rem 0 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border);
}

.library-section:first-of-type {
    margin-top: 0.5rem;
}

.library-section-assigned {
    border-bottom-color: var(--accent);
}

.library-section-count {
    font: inherit;
    color: var(--muted);
}

/* Exam / Practice timers, the "show relevant points" highlights and the model letter */
.notes-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.notes-heading h2 {
    margin: 0;
}

.task-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--ink);
    background: var(--panel);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 0.25rem 0.75rem;
}

.task-timer.timer-ok {
    color: var(--correct);
    border-color: var(--correct);
    background: var(--correct-bg);
}

.task-timer.timer-amber {
    color: var(--warn);
    border-color: var(--warn);
    background: var(--warn-bg);
}

.task-timer.timer-warning {
    color: var(--incorrect);
    border-color: var(--incorrect);
    background: var(--incorrect-bg);
}

mark.relevant {
    background: transparent;
    color: inherit;
}

.show-relevant mark.relevant {
    background: var(--hl);
    border-radius: 3px;
    box-shadow: 0 0 0 2px var(--hl);
}

.model-letter {
    background: var(--bg);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    line-height: 1.5;
    max-width: 48rem;
}

.review-timing {
    /* No top margin: the toolbar above already has one, and the two collapse in a normal
       page but add up in the fixed Role-play layout, which made the line jump between tabs. */
    margin: 0 0 0.75rem;
}

/* Writing / Speaking tabs on Create Task and the Task Library */
.kind-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin: 0 0 1rem;
}

.kind-tab {
    padding: 0.5rem 1.25rem;
    border: 2px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: -2px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

@media (hover: hover) {
    a.kind-tab:hover,
    button.kind-tab:hover {
        color: var(--accent);
    }
}

/* The same tabs as buttons (the Writing page's Feedback / Task / Letter on a phone) */
button.kind-tab { font: inherit; font-weight: 600; background: transparent; cursor: pointer; }
button.kind-tab.active { background: var(--panel); }

.kind-tab.active {
    color: var(--accent);
    background: var(--panel);
    border-color: var(--border);
    border-bottom: 2px solid var(--panel);
}

.kind-tab-count {
    font-weight: inherit;
    color: inherit;
    margin-left: 0.25rem;
}

/* The sent feedback pages (Writing and Speaking): the tabs sit directly under the task title. */
.sent-tabs { flex: 0 0 auto; }

/* Student Speaking role-play */
.sp-main { max-width: 52rem; margin: 0 auto; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.sp-choice { border: 0; padding: 0; margin: 1rem 0; display: grid; gap: 0.6rem; }

.sp-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--panel);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.sp-option:has(input:checked) { border-color: var(--accent); }
/* The box or dot itself keeps the browser's arrow unless told otherwise, so the pointer changed only around it. */
.sp-option input { cursor: pointer; }
.sp-option input:disabled { cursor: default; }

.sp-privacy { margin: 1rem 0; }

.sp-dialog {
    max-width: 34rem;
    padding: 1.5rem;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sp-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

/* The two answers in the pop-up look identical, so neither is pushed. */
.sp-equal button { flex: 1 1 0; }

.sp-check { display: grid; gap: 0.75rem; margin: 1rem 0; }
.sp-check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.sp-check h3 { margin: 0.5rem 0 0; }
.sp-intro h3 { margin: 1.1rem 0 0.3rem; }
.sp-intro h3:first-child { margin-top: 0.5rem; }
.sp-intro ul { margin: 0.3rem 0 0; padding-left: 1.3rem; }
.sp-intro li { margin: 0.3rem 0; }
/* A note directly under a tick box sits close to it (the grid's gap and the paragraph's own margin would add up). */
.sp-check .sp-option + .meta { margin: -0.45rem 0 0 0.25rem; }
/* The microphone box is ticked by the page itself, so it doesn't look clickable. */
.sp-auto { cursor: default; }
.sp-option:has(input:disabled:not(:checked)) { opacity: 0.6; cursor: default; }

/* A reminder or warning on the preparation screen */
.sp-nudge {
    margin: 0.75rem 0;
    padding: 0.6rem 1rem;
    background: var(--warn-bg);
    color: var(--warn);
    border: 1.5px solid var(--warn);
    border-radius: 8px;
    font-weight: 600;
}

.sp-meter {
    width: 10rem;
    height: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.sp-meter-bar { height: 100%; width: 0; background: var(--correct); transition: width 0.08s linear; }

.sp-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.sp-bar h2 { margin: 0; }
/* The task's name and due date, sized as on the Writing page (below 900 px: both small, the date grey). */
.sp-task-head .task-subtitle { margin: 0 0 1rem; }
.sp-task-head .sp-due { font-size: 1.1rem; margin: 0 0 1rem; }
/* On a computer, as on the Writing page: the due date heads the left column, and the heading and clock sit beside it. */
@media (min-width: 901px) {
    .sp-screen-wide:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1.5rem; }
    .sp-screen-wide .sp-task-head { display: contents; }
    .sp-screen-wide .sp-task-head .task-subtitle, .sp-screen-wide .sp-split { grid-column: 1 / -1; }
    .sp-screen-wide .sp-task-head .sp-due { grid-column: 1; align-self: center; margin: 0 0 0.5rem; }
    .sp-screen-wide .sp-bar { grid-column: 2; align-self: center; }
}
@media (max-width: 900px) {
    .sp-task-head { margin-bottom: 0.5rem; line-height: 1.3125; }
    .sp-task-head .task-subtitle { margin: 0; font-size: 1rem; }
    .sp-task-head .sp-due { margin: 0; font-size: 1rem; font-weight: 600; color: var(--muted); }
}

.sp-status { font-size: 1.15rem; font-weight: 600; margin: 0.75rem 0; }

.sp-card {
    background: var(--bg);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}

.case-notes-scroll .sp-card { margin: 0; padding: 0; background: none; }
/* The prep and role-play screens are wider so the card sits beside the controls, as on the Writing page. */
.sp-main:has(.sp-screen-wide:not([hidden])) { max-width: 72rem; }
.sp-split { display: flex; gap: 1.5rem; align-items: flex-start; }
.sp-split .sp-card-panel { flex: 1 1 50%; }
.sp-split .sp-controls { flex: 1 1 50%; min-width: 0; }
/* The role card is a lozenge like the feedback cards, with the interface colour in place of the traffic light.
   Its heading sits level with the first line of the instructions beside it. */
.sp-card-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    padding: 0.9rem 1.2rem 1rem;
    box-shadow: var(--shadow);
}
.sp-card-panel h2 { margin: 0 0 0.4rem; display: flex; align-items: center; gap: 0.5rem; }
.sp-card-panel h2::before {
    content: '';
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}
.sp-card-panel .case-notes-scroll { background: none; padding: 0; }
/* The teacher's Review page: the cards stacked as lozenges in the left-hand column, which scrolls. */
/* Under the Transcript heading: the timing line, the recording note and the transcript sit close together. */
.sp-transcript-column > .meta, .sp-transcript-column > .sp-player { margin: 0 0 0.4rem; }
.sp-transcript-column > .review-timing { margin-bottom: 0.25rem; }
.overall-block .overall-timing { margin-top: 0.6rem; }
/* Times in the Speaking timing lines: bold, in the interface colour. */
.time-fig { color: var(--accent); font-weight: 700; }
.sp-review-cards { background: none; padding: 0 0.25rem 0 0; }
.sp-review-cards .sp-card-panel { margin-bottom: 0.75rem; }
.sp-review-cards .sp-card-panel .sp-card { margin: 0; padding: 0; background: none; }
@media (max-width: 800px) { .sp-split { flex-direction: column; } .sp-split > * { width: 100%; } }
.sp-card-details { margin-top: 1rem; }

.sp-help {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}

.sp-help-answer { margin: 0.75rem 0; white-space: pre-wrap; }
.sp-help-log { margin: 0.75rem 0; max-height: 14rem; overflow-y: auto; }
/* Everything said in Help, the student's questions and the assistant's answers alike. */
.sp-turn-help { font-style: italic; opacity: 0.85; }
.sp-help-line { margin: 0.4rem 0; padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--bg); }
.sp-help-teacher { border-left: 4px solid var(--accent); }
.sp-help-you { color: var(--muted); }

/* Resume draws the eye once the teacher has finished an answer. */
@keyframes sp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } 50% { box-shadow: 0 0 0 5px var(--accent-soft, rgba(80, 120, 200, 0.35)); } }
#help-resume.sp-pulse { animation: sp-pulse 1.6s ease-in-out infinite; }
#help-resume:disabled { opacity: 0.5; cursor: not-allowed; }
.sp-typed { margin-top: 1rem; }

.sp-debug {
    margin-top: 1.5rem;
    max-height: 16rem;
    overflow: auto;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: pre-wrap;
}

/* The Speaking Lab's table of moods */
.lab-mood-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.lab-mood-table th, .lab-mood-table td { text-align: left; padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--border); }
.lab-mood-table th { color: var(--muted); font-weight: 600; }

/* Teacher review of a Speaking role-play: recording player and transcript */
.sp-player { margin-bottom: 0.75rem; }
.sp-player audio { width: 100%; }
.sp-player .button-row { flex-wrap: wrap; }
#sp-play-note { flex: 1 1 100%; margin: 0; }
.sp-transcript { display: flex; flex-direction: column; gap: 0.5rem; }
.sp-turn { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.5rem 0.7rem; border-radius: 6px; }
.sp-turn { color: var(--ink); }
.sp-turn-candidate { background: color-mix(in srgb, var(--accent, #2e7d32) 14%, var(--panel, #fff)); border-left: 4px solid var(--accent, #2e7d32); }
.sp-turn-patient { background: color-mix(in srgb, var(--muted, #888) 12%, var(--panel, #fff)); border-left: 4px solid var(--muted, #bbb); color: var(--muted); }
.sp-turn.sp-playing { outline: 2px solid var(--accent, #2e7d32); }
.sp-who { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; min-width: 4.5rem; flex: 0 0 auto; }
.sp-text { flex: 1 1 auto; }
.sp-scores { font-size: 0.8rem; color: #777; }
.sp-pause { text-align: center; font-size: 0.85rem; color: #a05a00; }
.sp-play { padding: 0.15rem 0.5rem; flex: 0 0 auto; min-width: 2.2rem; }
.sp-turn-candidate { position: relative; }
/* A thin bar along the bottom of the turn that is playing: how far through the turn and the reply, and click to move. */
.sp-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: pointer; }
.sp-progress[hidden] { display: none; }
.sp-progress { --split: 100%; }
/* The track: the candidate's part in a faint accent, the patient's reply in faint grey, with a
   2px gap between them. The two fills below stop at the same gap. */
.sp-progress::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    background: linear-gradient(to right,
        color-mix(in srgb, var(--accent) 25%, transparent) calc(var(--split) - 1px),
        transparent calc(var(--split) - 1px), transparent calc(var(--split) + 1px),
        color-mix(in srgb, var(--muted) 25%, transparent) calc(var(--split) + 1px)); }
.sp-progress-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; max-width: calc(var(--split) - 1px); background: var(--accent); }
.sp-progress-reply { background: var(--muted); margin-left: 1px; max-width: calc(100% - var(--split) - 1px); }

/* Teacher review page: the page scrolls and every feedback box grows to
   show all of its text, so nothing inside a box needs scrolling. */
body.review-scroll {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    display: block;
}
body.review-scroll .write-main { display: block; }
body.review-scroll .feedback-view { display: block; }
body.review-scroll .feedback-view .feedback-grid {
    overflow: visible;
    margin-bottom: 1rem;
    align-items: stretch;
}
body.review-scroll .criteria-group-title { margin: 1.25rem 0 0.5rem; }
body.review-scroll .review-comment {
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
}
body.review-scroll .ai-draft-note { max-height: none; overflow: visible; }
body.review-scroll .write-layout { height: calc(100vh - 11rem); min-height: 30rem; margin-top: 2.5rem; }
body.review-scroll .write-layout.hidden { display: none; }
body.review-scroll .view-toggle { position: static; justify-content: flex-end; margin-bottom: 0.5rem; }
body.review-scroll .feedback-view.hidden { display: none; }
body.review-scroll .review-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
body.review-scroll .review-task-title { margin: 0; font-size: 1.1rem; }
body.review-scroll .review-toolbar .view-toggle { margin-bottom: 0; margin-left: auto; flex: 0 0 auto; }
body.review-scroll .write-layout { margin-top: 0; }
/* While the Role-play / Letter view is open the page itself stays still: the
   window is divided between the header, the toolbar and the two panes, and only
   the panes scroll. */
body.review-scroll.ref-open { height: 100vh; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
body.review-scroll.ref-open .write-main { display: flex; flex: 1 1 auto; min-height: 0; }
body.review-scroll.ref-open .write-layout { height: auto; min-height: 0; flex: 1 1 auto; }
body.review-scroll .overall-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
body.review-scroll .overall-columns .ai-draft-note { margin: 0; }
body.review-scroll .overall-edit { display: flex; flex-direction: column; gap: 0.4rem; }
@media (max-width: 800px) { body.review-scroll .overall-columns { grid-template-columns: 1fr; } }

/* What will be sent: saved is not the same as approved */
.approval-state { margin: 0.2rem 0 0; font-size: 0.85rem; font-weight: 600; }
.approval-none { color: var(--muted); font-weight: 400; }
.approval-pending { color: var(--st-pending); }
.approval-yes { color: var(--st-done); }
.save-status { margin: 0; line-height: 1.4; }
.send-row { gap: 1rem; margin-top: 1rem; }

/* Comment editors that show bold instead of ** markers */
.rich-wrap { display: flex; flex-direction: column; flex: 1 1 auto; gap: 0.3rem; min-width: 0; }
.rich-bar { display: flex; align-items: center; gap: 0.6rem; }
.rich-bold { padding: 0.1rem 0.6rem; border: 1.5px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--ink); cursor: pointer; }
@media (hover: hover) {
    .rich-bold:hover { border-color: var(--accent); color: var(--accent); }
}
.rich-edit {
    flex: 1 1 auto;
    min-height: 3rem;
    padding: 0.5rem;
    background: var(--edit-bg);
    color: var(--edit-ink);
    border: 1.5px solid var(--edit-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.rich-edit:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Follow-on exercises on the teacher review page */
.exercises-panel { margin: 0 0 1rem; }
.exercises-panel > .meta { margin: 0 0 0.75rem; }
.review-exercises { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; box-shadow: var(--shadow); }
.exercise-criterion { margin: 0 0 0.4rem; font-size: 1rem; }
.exercise-item { margin: 0.5rem 0; padding: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.exercise-type { margin: 0 0 0.5rem; font-weight: 700; }
.exercise-fields { display: grid; gap: 0.6rem; }
.exercise-field { display: block; font-size: 0.85rem; color: var(--muted); }
.exercise-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
/* Editable boxes: the same look as the feedback editors, sized to their text */
.exercise-item textarea {
    display: block;
    width: 100%;
    margin-top: 0.2rem;
    padding: 0.5rem;
    box-sizing: border-box;
    background: var(--edit-bg);
    color: var(--edit-ink);
    border: 1.5px solid var(--edit-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
}
.exercise-item textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.exercise-item .approved-label, .exercise-item .approval-state { margin-top: 0.5rem; }
.exercise-item .button-row { margin-top: 0.5rem; }

/* Read-only text (the AI's draft) is quieter than anything editable */
body.review-scroll .ai-draft-note {
    background: var(--ro-bg);
    color: var(--ro-ink);
    border-radius: 8px;
    padding: 0.5rem;
}
.review-summary,
.review-comment {
    background: var(--edit-bg);
    color: var(--edit-ink);
    border-color: var(--edit-border);
}

/* Bulleted advice in the overall summary */
.feedback-bullets, .rich-edit ul { margin: 0.3rem 0; padding-left: 1.3rem; }
.feedback-bullets li, .rich-edit li { margin: 0.2rem 0; }

/* Admin lists: a heading row per teacher. */
.task-table tr.group-row th {
    background: var(--bg-soft, rgba(127, 127, 127, 0.12));
    text-align: left;
    font-weight: 700;
}

/* Task editors: Publish / Return to Tasks while saved, Save draft / Revert once something is changed. */
.edit-actions [hidden] { display: none !important; }
.edit-actions .edit-clean, .edit-actions .edit-dirty { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* A button that reads as a link, for small secondary actions inside a sentence. */
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.relevant-points { margin: 0 0 1rem 1.2rem; padding: 0; }
.relevant-points li { margin: 0.2rem 0; }
.task-form input[readonly], .task-form textarea[readonly], .task-form select:disabled { opacity: 0.75; cursor: not-allowed; }

/* A grey (secondary) button inside a form keeps the grey look on hover. Without this the general
   .task-form button:hover rule filled it blue while leaving its text dark. */
@media (hover: hover) {
    .task-form button.secondary:hover:not(:disabled) {
        background: transparent;
        border-color: var(--ink);
        color: var(--ink);
    }
}

/* Task editors: a wider form, and text boxes that can also be dragged taller. */
.task-form[data-edit-form] { max-width: 960px; }
.task-form[data-edit-form] textarea { resize: vertical; line-height: 1.5; }

/* Bold button above the case notes and writing task boxes. */
.task-form .bold-bar { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; }
.task-form .bold-bar .bold-button {
    align-self: auto;
    padding: 0.1rem 0.7rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
@media (hover: hover) {
    .task-form .bold-bar .bold-button:hover { background: var(--accent); color: var(--accent-ink); }
}
.task-form .bold-bar .meta { margin: 0; }

/* "Claude is thinking" overlay: see assets/js/claude-waiting.js */
.claude-waiting {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(28, 37, 48, .55);
}
.claude-waiting-card {
    width: min(420px, 100%);
    padding: 28px 28px 24px;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    text-align: center;
}
.claude-waiting-lines {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin: 0 0 20px;
    text-align: left;
}
.claude-waiting-line {
    display: block;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--border) 0%, var(--accent) 45%, var(--border) 90%);
    background-size: 220% 100%;
    animation: claude-stream 1.6s linear infinite;
}
.claude-waiting-line:nth-child(1) { width: 92%; }
.claude-waiting-line:nth-child(2) { width: 78%; animation-delay: -.3s; }
.claude-waiting-line:nth-child(3) { width: 96%; animation-delay: -.6s; }
.claude-waiting-line:nth-child(4) { width: 64%; animation-delay: -.9s; }
.claude-waiting-line:nth-child(5) { width: 84%; animation-delay: -1.2s; }
.claude-waiting-title {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 600;
}
.claude-waiting-dots { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.claude-waiting-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: claude-pulse 1.2s ease-in-out infinite;
}
.claude-waiting-dots i:nth-child(2) { animation-delay: .2s; }
.claude-waiting-dots i:nth-child(3) { animation-delay: .4s; }
.claude-waiting-detail { margin: 0; color: var(--muted); font-size: .9rem; }
.claude-waiting-progress { margin: 0 0 .5rem; font-size: 1.15rem; font-weight: 700; color: var(--accent); }
.claude-waiting-progress[hidden] { display: none; }
@keyframes claude-stream {
    from { background-position: 220% 0; }
    to   { background-position: -120% 0; }
}
@keyframes claude-pulse {
    0%, 80%, 100% { opacity: .25; transform: scale(.8); }
    40%           { opacity: 1;   transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
    .claude-waiting-line, .claude-waiting-dots i { animation: none; }
    .claude-waiting-line { background: var(--accent); opacity: .35; }
}

/* API Usage page: the traffic-light green = the call worked, red = it failed */
.api-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    color: #ffffff;
}
.api-status.ok   { background: var(--tl-green); }
.api-status.fail { background: var(--tl-red); }
.api-text-fail { color: var(--tl-red); font-weight: 700; }
.task-table tr.api-row-ok   td:first-child { box-shadow: inset 4px 0 0 var(--tl-green); }
.task-table tr.api-row-fail td { background: var(--incorrect-bg); }
.task-table tr.api-row-fail td:first-child { box-shadow: inset 4px 0 0 var(--tl-red); }
.stat-tile.api-ok   .stat-number { color: var(--tl-green); }
.stat-tile.api-fail { background: var(--incorrect-bg); }
.stat-tile.api-fail .stat-number { color: var(--tl-red); }
.task-table tfoot th { border-top: 2px solid var(--border); text-align: left; }

/* Estimated-cost tile on the API Usage page: same colour as the default (primary) button */
.stat-tile.cost {
    background: transparent;
    border: 1.5px solid var(--accent);
}
.stat-tile.cost .stat-number { color: var(--accent); }

/* API Usage page: voice-service calls use the "Approve changes" label colour (teal in light mode, yellow in dark) */
.api-voice {
    display: inline-block;
    padding: 1px 8px;
    border: 1.5px solid var(--st-approve);
    border-radius: 999px;
    color: var(--st-approve);
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.api-details { margin-top: 4px; font-size: .85rem; }
.api-details summary { cursor: pointer; color: var(--accent); }
.api-details p { margin: 4px 0 0; max-width: 28rem; overflow-wrap: anywhere; }

/* In-page confirmation box (assets/js/portal-confirm.js): takes the portal's own light/dark colours */
.portal-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(28, 37, 48, .55);
}
.portal-modal-card {
    width: min(440px, 100%);
    padding: 22px 24px 18px;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.portal-modal-title { margin: 0 0 10px; font-size: 1.1rem; font-weight: 600; }
.portal-modal-text { margin: 0 0 10px; color: var(--muted); }
.portal-modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* Live word count under the model letter on the task edit page */
.letter-count { margin-top: 6px; }
.letter-count.letter-count-out { color: var(--tl-red); font-weight: 600; }

/* Relevant points on the task edit page: a tick list, and a collapsed list of other lines to add */
.relevant-points.relevant-points-edit { list-style: none; margin-left: 0; }
/* Student dashboard: dates and their heading stay on one line */
.task-table .nowrap-cell { white-space: nowrap; min-width: 7.5rem; }
/* Student dashboard buttons: one width, centred text, never split at the hyphen in role-play */
.task-table td .button-link.small { min-width: 10.5rem; text-align: center; white-space: nowrap; box-sizing: border-box; }
/* A back link in a header that also holds the light/dark button stays on the right, next to it */
header > a:not(.site-logo) { margin-left: auto; }
/* With no back link, the button itself goes to the far right */
header > h1 + #themeToggle { margin-left: auto; }
.task-table .shrink-cell { width: 1%; white-space: nowrap; }
.task-ref { font-weight: 700; color: var(--accent); margin-right: 0.25rem; }
#rewrite-row[hidden] { display: none !important; }
.more-points { margin: 0 0 1rem; }
.more-points summary { cursor: pointer; color: var(--accent); margin-bottom: 0.4rem; }

/* Steps shown above the feedback when the student is asked to edit and resubmit */
.feedback-steps ol { margin: 0.5rem 0 0.75rem 1.25rem; padding: 0; }
.feedback-steps li { margin-bottom: 0.35rem; }

.resubmit-form {
    flex: 0 0 auto;
    margin-top: 0.75rem;
}

/* "Your letter" / "Model letter": one right-hand column, only one pane shown at a time */
.letter-pane {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.letter-pane.hidden {
    display: none;
}

/* Student feedback tab: the whole tab scrolls together, from the steps intro down through the
   criteria, rather than only the criteria grid scrolling inside a fixed header. */
.feedback-view-scroll {
    overflow-y: auto;
}

.feedback-view-scroll .feedback-grid {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
}

/* A disabled checkbox (a completed selection exercise, read-only) gets drawn by the OS as a washed-out
   grey tick on grey, unreadable in both themes. Once disabled it's drawn by hand instead, in the same
   green as a correct traffic light, so a ticked item is still clearly visible. */
.exercise-option-item input[type="checkbox"]:disabled,
.sp-option input[type="checkbox"]:disabled {
    appearance: none;
    -webkit-appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    flex: 0 0 auto;
    margin-top: 0.1rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--panel);
}

.exercise-option-item input[type="checkbox"]:disabled:checked,
.sp-option input[type="checkbox"]:disabled:checked {
    background-color: var(--tl-green);
    border-color: var(--tl-green);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3.2L13 5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 75% 75%;
}

/* Second attempt: switching between "Your feedback" and "Original task" beside the letter.
   A plain in-flow row of buttons, not the page-level .view-toggle (which is absolutely
   positioned for the top-right corner and would otherwise jump out of this column). */
.attempt-pane-toggle {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
}

.attempt-pane.hidden {
    display: none;
}

/* The second attempt's instruction line: above the page on a laptop, inside the Feedback tab on a phone. */
.attempt-note-pane { display: none; }
.attempt-note-pane { margin: 0 0 0.75rem; }

/* Theme button on the pages that have no header (login, password and eBook pages) */
.page-theme-toggle { position: fixed; top: 1rem; right: 1rem; z-index: 10; }

/* Dashboard: each task and its Reset row form one block; blocks alternate in shade so tasks stand apart */
.completion-task { padding: 0.6rem 0.75rem; border-radius: 6px; }
.completion-task .completion-row { margin-bottom: 0; }
.completion-task .completion-row + .completion-row { margin-top: 0.3rem; }
.completion-class .completion-task:nth-child(odd) { background: var(--bg); }
.completion-class .completion-task:nth-child(even) { background: color-mix(in srgb, var(--bg) 70%, var(--border)); }


/* Writing: the first screen ("How it works"), the lozenges for the case notes and the writing task,
   and the note that stands in for the letter box during an exam's preparation time. */
/* The writing page itself never scrolls (body.write-mode), so on a short screen this one has to, or the button that
   starts the task is out of reach. */
/* The right padding keeps the scrollbar off the text. */
.start-screen { box-sizing: border-box; width: 100%; max-width: 52rem; margin: 0 auto; padding-right: 0.75rem; flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.start-screen[hidden] { display: none; }
.start-screen .sp-intro ul { margin-top: 0.3rem; }
.write-letter-form[hidden], .reading-note[hidden] { display: none; }
.reading-note {
    margin: 0;
    padding: 0.9rem 1.2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* The Writing left column: two lozenges like the Speaking card. The case notes take the spare height and
   scroll; the writing task sits below and can be hidden. */
.write-card { display: flex; flex-direction: column; min-height: 0; margin-bottom: 0.75rem; }
.write-card-notes { flex: 1 1 auto; }
.write-card .notes-heading, .write-card .instructions-header { flex: 0 0 auto; border: 0; padding: 0; margin: 0 0 0.4rem; }
.write-card .notes-heading h2, .write-card .instructions-header h2 { margin: 0; font-size: 1.5rem; }
.write-card-notes .notes-heading { flex-wrap: wrap; }   /* on the narrowest phones "Show relevant points" goes below the heading */
.write-card .case-notes-scroll, .write-card .instructions-body { background: none; padding: 0; }
.instructions-block.write-card { flex: 0 0 auto; max-height: 45%; margin-top: 0; border-radius: 12px; }
.write-card h2::before { content: ''; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* The Speaking editor's locked cards: a plain wrapper, greyed while locked. */
fieldset.locked-fields { border: 0; padding: 0; margin: 0; min-width: 0; display: contents; }
fieldset.locked-fields:disabled :is(input, textarea, select, button) { opacity: 0.7; }

/* The model dialogue: one turn to a line, the speaker in bold. */
.model-turn { margin: 0 0 0.6rem; }
.model-turn:last-child { margin-bottom: 0; }


/* ===== Writing on tablets and phones =====================================================================
   Wide screens keep the two columns. Below 900 px the case notes and the letter are shown one at a time
   (tabs switch them), the header is slimmed down, and the page is sized to the space above the on-screen
   keyboard (--vvh is set from the browser's visual viewport; 100dvh is the fallback). */
.write-tabs { display: none; }
.tab-timer { display: none; }
.phone-notice { display: none; }

@media (max-width: 900px) {
    body.writing-edit { height: var(--vvh, 100dvh); }
    body.writing-edit header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
    body.writing-edit.kbd-open .site-footer { display: none; }
    body.writing-edit.kbd-open { padding-bottom: 0; }
    /* While the keyboard is open: no Save draft / Submit (autosave covers saving; they return when it closes) and
       the word count loses its explanation. */
    body.writing-edit.kbd-open .write-letter-form .button-row,
    body.writing-edit.kbd-open .wc-note { display: none; }
    body.writing-edit .write-main { padding: 0.5rem 0.75rem 0.75rem; }
    body.writing-edit .task-subtitle { margin: 0 0 0.5rem; font-size: 1rem; }
    body.writing-edit .write-letter-form textarea { font-size: 16px; }   /* below 16px an iPhone zooms in when the box is tapped */
    body.writing-edit .write-letter-form .button-row button { flex: 1 1 0; min-height: 44px; }
    body.writing-edit.kbd-open header,
    body.writing-edit.kbd-open .task-subtitle { display: none; }

    .write-tabs { display: flex; gap: 0.25rem; align-items: flex-end; margin: 0 0 0.75rem; flex: 0 0 auto; }
    .write-tabs.hidden { display: none; }
    .write-tab { flex: 1 1 0; min-height: 44px; text-align: center; padding-inline: 0.2rem; white-space: nowrap; }
    .write-tabs .write-tab { font-size: 0.9rem; }
    .tab-timer { display: inline-flex; align-items: center; justify-content: center; min-width: 4.2rem; align-self: center; margin-bottom: 2px; }
    .write-tab.attention { animation: write-tab-pulse 1.6s ease-in-out 3; }
    /* The tab bar already says where you are and shows the clock, and the due date sits under the task
       title on both tabs (so nothing moves between them), so these lines are not repeated (Exam keeps its heading,
       which names the phase). */
    /* The title block is always two lines tall so the tabs and buttons never move between the tabs:
       Case notes and task shows the full title (up to two lines); Your letter shows the short name
       (e.g. "W2 Referral") with the due date under it. */
    /* Whole-pixel lines (21px at 16px), so that one line of title and two lines of title and due date give a block
       of exactly the same height, and the tabs and clock below do not shift. */
    body.writing-edit .task-subtitle { line-height: 1.3125; min-height: 2.625em; }
    body.writing-edit .task-subtitle .subtitle-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    body.writing-edit:has(.write-layout[data-pane="letter"]) .task-subtitle .subtitle-title { display: none; }
    body.writing-edit:has(.write-layout[data-pane="letter"]) .task-subtitle .subtitle-short { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    body.writing-edit:has(.write-layout[data-pane="letter"]) .task-subtitle .subtitle-due { display: block; color: var(--muted); }
    .write-notes-column .write-meta { display: none; }
    .write-letter-column .notes-heading:has(#task-timer[data-mode="practice"]) { display: none; }
    .write-layout[data-pane="task"] .write-letter-column,
    .write-layout[data-pane="feedback"] .write-letter-column { display: none; }
    .write-layout[data-pane="letter"] .write-notes-column { display: none; }

    /* The second attempt's feedback and task are separate tabs here, so the inner Your feedback / Original task
       buttons go, and the tab decides which of the two is shown. */
    .attempt-pane-toggle { display: none; }
    .attempt-note-top { display: none; }
    .attempt-note-pane { display: block; }
    .write-layout[data-pane="feedback"] #earlier-feedback { display: block !important; }
    .write-layout[data-pane="feedback"] #original-task { display: none !important; }
    .write-layout[data-pane="task"] #earlier-feedback { display: none !important; }
    .write-layout[data-pane="task"] #original-task { display: flex !important; flex-direction: column; flex: 0 0 auto; }

    /* The page scrolls, so the task is always shown in full (nothing to hide) and the Feedback and Task tabs
       scroll as one piece instead of each panel scrolling on its own. */
    .write-notes-column { overflow-y: auto; }
    .write-notes-column .attempt-pane, .write-notes-column .write-card { min-width: 0; max-width: 100%; }
    .write-notes-column .case-notes-scroll { min-width: 0; overflow-wrap: anywhere; }
    .write-notes-column .case-notes-scroll { flex: 0 0 auto; overflow: visible; max-height: none; }
    .write-notes-column .write-card-notes { flex: 0 0 auto; }
    .write-notes-column .instructions-block { max-height: none; }
    .write-notes-column .instructions-block .instructions-toggle { display: none; }
    .write-notes-column .instructions-body.hidden { display: block; }
}

/* The due date beside the task title is only used on a phone's Your letter tab (see below). */
.subtitle-due, .subtitle-short { display: none; }

@keyframes write-tab-pulse { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 5px var(--accent); } }

/* A phone: the "far better on a larger screen" notice on the first screen. */
@media (max-width: 700px) {
    .phone-notice {
        display: block;
        margin: 1rem 0;
        padding: 0.75rem 1rem;
        background: var(--warn-bg);
        color: var(--warn);
        border: 1.5px solid var(--warn);
        border-radius: 8px;
    }
}


/* ===== Speaking on a phone ================================================================================
   The role-play is the part that suits a phone: headphones, a good microphone and one thing to do. Only two
   things are ever pinned (the clock at the top and the status, level bar and Help and End buttons at the
   bottom), both kept slim so the card keeps the screen; the card scrolls with the page. */
@media (max-width: 700px) {
    main.sp-main { padding: 0.75rem; }
    body:has(main.sp-main) header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
    .sp-screen h2 { font-size: 1.3rem; }
    .sp-screen button { min-height: 44px; }
    .sp-check-row { flex-direction: column; align-items: stretch; }
    .sp-check-row .sp-meter { width: 100%; }
    .sp-screen .button-row { flex-wrap: wrap; }
    .sp-screen .button-row button { flex: 1 1 auto; }
    .sp-dialog { max-width: calc(100vw - 2rem); }

    /* Preparation and role-play: the footer steps aside, and the clock stays at the top */
    body:has(#screen-prep:not([hidden])) .site-footer,
    body:has(#screen-roleplay:not([hidden])) .site-footer { display: none; }
    body:has(#screen-prep:not([hidden])),
    body:has(#screen-roleplay:not([hidden])) { padding-bottom: 0; }
    .sp-screen-wide .sp-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); justify-content: flex-end; padding: 0.4rem 0; margin-bottom: 0.4rem; }
    .sp-screen-wide .sp-bar h2 { display: none; }
    .sp-split { gap: 0.75rem; align-items: stretch; }
    .sp-split .sp-card-panel, .sp-split .sp-controls { flex: 0 0 auto; }

    /* Preparation: the instructions, then the card, then a Start button pinned at the bottom */
    #screen-prep .sp-controls { display: contents; }
    #screen-prep .sp-controls > p { order: 0; margin: 0; }
    #screen-prep .sp-card-panel { order: 1; }
    #screen-prep .sp-controls .button-row { order: 2; position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 0.5rem 0; margin: 0; width: 100%; box-sizing: border-box; }
    #screen-prep .sp-controls .button-row button { width: 100%; }

    /* Role-play: status, level bar and the two buttons pinned at the bottom (a few lines tall) */
    #screen-roleplay .sp-controls { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 0.4rem 0 0.6rem; border-top: 1px solid var(--border); }
    #screen-roleplay .sp-controls > p.meta { display: none; }
    #screen-roleplay .sp-controls .sp-status { margin: 0.1rem 0; font-size: 1rem; }
    #screen-roleplay .sp-controls .sp-meter { width: 100%; height: 0.5rem; margin: 0.3rem 0; }
    #screen-roleplay .sp-controls .button-row { margin-top: 0.3rem; flex-wrap: nowrap; }
    #screen-roleplay .sp-controls .button-row button { flex: 1 1 0; }
    /* Help: kept compact (about a third of the screen at most) so the card stays readable above it */
    #screen-roleplay .sp-help { max-height: 32dvh; overflow-y: auto; margin: 0.3rem 0; padding: 0.5rem 0.75rem; }
    #screen-roleplay .sp-help > h3, #screen-roleplay .sp-help > .meta { display: none; }
    #screen-roleplay .sp-help .sp-help-log { max-height: 14dvh; margin: 0.3rem 0; }
    #screen-roleplay .sp-help .field-with-button input { font-size: 16px; min-height: 44px; }
}

/* ===== Student dashboard and every header on a phone ======================================================
   The header (logo, title, light/dark button) must fit inside the screen, so the title may wrap and the
   button stays compact. The dashboard's task table becomes one card per task instead of a wide table. */
@media (max-width: 700px) {
    /* The bar is one fixed height whatever the title: a one-line title (Task Library) and a two-line one (My Classes
       and Students) fill the same bar. The title's own top and bottom margins are dropped so two lines fit inside it. */
    header { flex-wrap: wrap; padding: 0.6rem 0.75rem; gap: 0.5rem; box-sizing: border-box; min-height: 75px; }
    header h1 { white-space: normal; flex: 1 1 0; min-width: 0; font-size: 1.3rem; margin: 0; }
    header #themeToggle, header > h1 + #themeToggle { margin-left: 0; flex: 0 0 auto; padding: 0.3rem 0.7rem 0.3rem calc(0.7rem - 2px); font-size: 0.8rem; }
    /* On a phone the light / dark button is just its icon, on every page. */
    #themeToggle .theme-text { display: none; }
    header #themeToggle, header > h1 + #themeToggle, .page-theme-toggle { padding: 0.3rem 0.55rem; font-size: 1rem; }
    .site-logo img { height: 36px; }
    main.student-main { padding: 1rem 0.75rem; }

    .student-main .task-table, .student-main .task-table tbody,
    .student-main .task-table tr, .student-main .task-table td { display: block; width: auto; }
    .student-main .task-table { background: transparent; }
    .student-main .task-table thead { display: none; }
    .student-main .task-table tr {
        margin: 0 0 0.75rem; padding: 0.7rem 0.85rem;
        background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
    }
    .student-main .task-table td { border: 0; padding: 0.15rem 0; }
    .student-main .task-table td.shrink-cell { display: inline-block; margin-right: 0.6rem; font-weight: 600; }
    .student-main .task-table td.nowrap-cell { min-width: 0; }
    .student-main .task-table td.nowrap-cell::before { content: "Due: "; color: var(--muted); }
    .student-main .task-table td.status-cell { text-align: left; padding: 0.35rem 0; }
    .student-main .task-table td .button-link.small { display: block; width: 100%; min-width: 0; margin-top: 0.4rem; min-height: 44px; line-height: 44px; padding-block: 0; }
}

/* A phone held sideways on the Writing page: the page is made for upright use, so ask for it to be turned. */
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
    .rotate-notice {
        display: flex; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center;
        padding: 1rem; text-align: center; font-size: 1.2rem; font-weight: 600;
        background: var(--bg); color: var(--ink);
    }
}

/* ===== Review Queue: tick feedback to release as it is ======================================================== */
.queue-table td.queue-check, .queue-table th:first-child { width: 2rem; }
.queue-table input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); cursor: pointer; }
.queue-lights { white-space: nowrap; }
.queue-lights .traffic-light { width: 20px; height: 20px; margin-right: 4px; vertical-align: middle; }   /* 20 px: the shapes are drawn to stay crisp at this size */
.queue-release-row { margin-top: 1rem; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.notice-ok { padding: 0.6rem 0.9rem; border: 1.5px solid var(--tl-green); border-radius: 8px; }

@media (max-width: 700px) {
    .queue-table, .queue-table tbody, .queue-table tr, .queue-table td { display: block; width: auto; }
    .queue-table { background: transparent; }
    .queue-table thead { display: none; }
    .queue-table tr {
        position: relative; margin: 0 0 0.75rem; padding: 0.7rem 0.85rem 0.7rem 2.9rem;
        background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
    }
    .queue-table td { border: 0; padding: 0.15rem 0; }
    .queue-table td.queue-check { position: absolute; left: 0.85rem; top: 0.75rem; width: auto; }
    .queue-table input[type="checkbox"] { width: 1.5rem; height: 1.5rem; }
    .queue-table td.queue-student { font-weight: 600; display: inline-block; margin-right: 0.6rem; }
    .queue-table td.queue-type { display: inline-block; color: var(--muted); }
    .queue-table td.queue-lights { padding: 0.35rem 0; }
    .queue-table td.queue-marked { color: var(--muted); font-size: 0.9rem; }
    .queue-table td.queue-marked::before { content: "Marked: "; }
    .queue-table tr:last-child { margin-bottom: 0; }
    .queue-table td.queue-review { padding-top: 0.4rem; }
    .queue-table td.queue-review .button-link { display: block; text-align: center; min-height: 44px; line-height: 44px; padding-block: 0; }
    .queue-release-row { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 0.75rem 0 0; margin-top: 0; }
    .queue-release-row button { width: 100%; min-height: 48px; }
    .queue-release-row .meta { display: none; }
}

/* ===== My Classes and Students, class and student edit pages, on a phone ====================================
   The class and student tables become one card each; the forms stay one column with finger-sized controls. */
@media (max-width: 700px) {
    /* One gutter size on a phone (0.75rem): beside the cards, between them, under the header and above the footer */
    main { padding: 0.75rem; }
    body { padding-bottom: 2.5rem; }
    .dashboard-panel { padding: 1rem; margin-bottom: 0.75rem; }
    .stat-row { gap: 0.75rem; }
    .stat-tile { flex: 1 1 8rem; min-width: 0; }
    .template-card { padding: 0.7rem 1rem; margin-bottom: 0.75rem; }
    .template-instances li:last-child { padding-bottom: 0; }
    body .btn-long { display: none; }
    body .btn-short { display: inline; }

    .people-table, .people-table tbody, .people-table tr, .people-table td { display: block; width: auto; }
    .people-table { background: transparent; }
    .people-table thead { display: none; }
    .people-table tr {
        margin: 0 0 0.75rem; padding: 0.7rem 0.85rem;
        background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
    }
    .people-table tr.group-row { background: transparent; border: 0; box-shadow: none; padding: 0.4rem 0 0; margin-bottom: 0.25rem; }
    .people-table tr.group-row th { display: block; text-align: left; }
    .people-table td { border: 0; padding: 0.15rem 0; overflow-wrap: anywhere; }
    .people-table td.pc-title { font-weight: 600; font-size: 1.05rem; }
    .people-table td[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--muted); }
    .people-table td.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.5rem; }
    .people-table td.actions:empty { display: none; }
    .people-table td.actions .button-link.small { flex: 1 1 8rem; text-align: center; min-height: 44px; line-height: 44px; padding-block: 0; }

    /* Forms: 16px text so a phone does not zoom in when a box is tapped; buttons big enough for a thumb */
    .task-form input, .task-form select, .task-form textarea { font-size: 16px; min-height: 44px; box-sizing: border-box; width: 100%; }
    .task-form input[type="checkbox"], .task-form input[type="radio"] { min-height: 0; width: auto; }
    .task-form .button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .task-form .button-row button, .task-form .button-row .button-link { flex: 1 1 auto; min-height: 44px; text-align: center; box-sizing: border-box; }
    .checkbox-label { padding: 0.25rem 0; }
    form.inline button, main > .button-row button { min-height: 44px; }
}

.btn-short { display: none; }

/* ===== Teacher menu and desktop-only pages ================================================================
   Above 700px the nav is the usual row of links. On a phone the links fold into a menu under a Menu button,
   and pages that are not suitable for a small screen are greyed and blocked (see public/assets/js/desktop-only.js
   and Nav::DESKTOP_ONLY_PAGES). */
.nav-toggle, .desktop-only-notice, .desktop-only-toast { display: none; }
.teacher-nav { display: flex; align-items: center; flex-wrap: wrap; }
.nav-links { display: contents; }

@media (max-width: 700px) {
    .teacher-nav { position: relative; flex: 0 0 auto; margin-left: auto; flex-wrap: nowrap; gap: 0.5rem; }
    .nav-toggle {
        display: inline-block; padding: 0.3rem 0.8rem; border-radius: 999px; background: transparent;
        border: 1.5px solid var(--accent); color: var(--accent); font-size: 0.85rem; cursor: pointer;
        transition: background-color .15s ease, color .15s ease;
    }
    .nav-toggle.nav-attention { border-color: var(--warn); color: var(--warn); }
    .nav-toggle { position: relative; z-index: 61; }
    .nav-open .nav-toggle { background: var(--accent); color: var(--accent-ink); }
    .nav-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.5); display: none; }
    body.nav-menu-open .nav-backdrop { display: block; }
    body.nav-menu-open { overflow: hidden; }
    /* The header is sticky with its own z-index, so the menu inside it sat under the backdrop; lift the header while the menu is open */
    body.nav-menu-open > header { z-index: 55; }
    .nav-links {
        display: none; position: absolute; top: calc(100% + 0.4rem); right: 0; z-index: 60; min-width: 15rem;
        flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
        box-shadow: var(--shadow); padding: 0.3rem 0;
    }
    .nav-open .nav-links { display: flex; }
    .nav-links a, .nav-links .nav-current { margin: 0; padding: 0.75rem 1rem; font-size: 1rem; min-height: 44px; box-sizing: border-box; }
    .nav-links > * + * { border-top: 1px solid var(--border); }
    @media (hover: hover) {
        .nav-links a:hover { text-decoration: none; background: var(--bg); }
    }
    .nav-links .nav-current { color: var(--ink); font-weight: 600; }
    .nav-links a.desktop-only-link { color: var(--btn-disabled); }
    .nav-links a.desktop-only-link::after { content: " (desktop only)"; font-size: 0.8rem; }
    a.desktop-only-link:not(.button-link) { cursor: not-allowed; }
    a.desktop-only-link.add-link { color: var(--btn-disabled); }
    a.desktop-only-link.add-link::after { content: " (desktop only)"; font-size: 0.8rem; }
    /* A blocked button looks disabled (same grey as other disabled buttons) but can still be tapped for the message */
    .button-link.desktop-only-link, .button-link.desktop-only-link:hover {
        background: transparent; color: var(--btn-disabled); border-color: var(--btn-disabled); cursor: not-allowed;
    }

    .desktop-only-toast {
        display: block; position: fixed; left: 0.75rem; right: 0.75rem; bottom: 1rem; z-index: 1000; padding: 0.85rem 1rem;
        background: var(--warn-bg); color: var(--warn); border: 1.5px solid var(--warn); border-radius: 10px; box-shadow: var(--shadow);
    }
    .desktop-only-toast[hidden] { display: none; }

    body.desktop-only-page .desktop-only-notice {
        display: block; margin: 1rem 0.75rem; padding: 1rem; background: var(--warn-bg); color: var(--warn);
        border: 1.5px solid var(--warn); border-radius: 10px;
    }
    body.desktop-only-page .desktop-only-notice .button-link { display: inline-block; margin-top: 0.5rem; }
    body.desktop-only-page > *:not(header):not(.desktop-only-notice):not(.site-footer):not(script) { display: none !important; }
}

/* ===== Analyse performance (student and class charts) ========================================================== */
.perf-toggle { margin: 0 0 1rem; }
.perf-scroll { overflow-x: auto; max-width: 100%; padding-bottom: 0.25rem; }
.perf-table { border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.perf-table th, .perf-table td { padding: 6px 0.6rem; text-align: center; vertical-align: middle; height: 40px; box-sizing: border-box; }
.perf-table th.perf-col { font-size: 0.85rem; color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--border); }
.perf-table th.perf-crit { text-align: left; font-weight: 600; font-size: 0.9rem; white-space: normal; width: 112px; min-width: 112px; max-width: 112px; line-height: 17px; padding-top: 3px; padding-bottom: 3px; position: sticky; left: 0; background: var(--panel); z-index: 1; padding-right: 1rem; }
.perf-table .traffic-light { width: 20px; height: 20px; display: block; margin: 0 auto; }   /* whole-pixel size: the ring and hole shapes are drawn on a 20 px grid, so they stay crisp */
/* Speaking criteria names are long: a wider first column on tablets and computers keeps each to two lines */
@media (min-width: 701px) {
    .perf-table.perf-speaking th.perf-crit { width: 270px; min-width: 270px; max-width: 270px; }
}
/* Advice popup for amber and red lights (assets/js/perf-popup.js) */
.perf-has-advice { cursor: help; }
.perf-has-advice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 50%; }
.perf-popup { position: fixed; z-index: 2000; max-width: min(24rem, calc(100vw - 1.5rem)); padding: 0.6rem 0.8rem; background: var(--panel); color: var(--ink); border: 1.5px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); font-size: 0.9rem; line-height: 1.35; pointer-events: none; }
.perf-popup[hidden] { display: none; }
.perf-popup strong { display: block; margin-bottom: 0.25rem; }
.perf-table .perf-resub { background: color-mix(in srgb, var(--muted) 14%, var(--panel)); }
.perf-sym { font-weight: 700; font-size: 1.1rem; line-height: 1; display: inline-block; padding-bottom: 2px; }
.perf-bar { display: flex; width: 3.4rem; height: 1.1rem; border-radius: 3px; overflow: hidden; margin: 0 auto; }
.perf-bar i, .perf-key-bar { display: block; height: 100%; }
.perf-green { background: var(--tl-green); }
.perf-amber { background: var(--tl-amber); }
.perf-red { background: var(--tl-red); }
.perf-key { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.2rem; margin: 1rem 0 0.5rem; font-size: 0.9rem; }
.perf-key-bar { display: inline-block; width: 1.4rem; height: 0.8rem; border-radius: 2px; vertical-align: middle; }
.perf-tasks { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.9rem; }
.perf-tasks li { margin-bottom: 0.25rem; }
.class-reuse-note { margin: 0.4rem 0 1rem; }

@media (max-width: 700px) {
    .perf-table th.perf-crit { width: 96px; min-width: 96px; max-width: 96px; font-size: 0.78rem; line-height: 15px; padding: 5px 0.4rem; }
    .perf-table td, .perf-table th.perf-col { padding-left: 0.35rem; padding-right: 0.35rem; }
}

/* Student feedback page on a phone: the Feedback / Your letter / Model letter buttons sit in a row under the title
   instead of floating over it, and the criteria boxes stack one above the other at full width. */
.back-row { margin: 0 0 0.75rem; flex: 0 0 auto; }
@media (max-width: 700px) {
    .write-main > .view-toggle { position: static; width: 100%; margin: 0 0 0.6rem; flex: 0 0 auto; }
    .write-main > .view-toggle .view-toggle-btn { flex: 1 1 0; min-width: 0; padding: 0.4rem 0.3rem; font-size: 0.85rem; min-height: 44px; }
    /* The student Writing and Speaking pages keep their title in the menu bar on a phone: logo, title (no name), the way back
       to the dashboard and the icon-only theme button. */
    body.writing-page header h1, body.speaking-page header h1 { font-size: 1.05rem; }   /* one line beside the Dashboard link, e.g. Speaking Feedback */
    /* ...and the title and tabs sit exactly where they do on the Writing edit page (same padding, margins and text size). */
    body.student-sent .write-main { padding: 0.5rem 0.75rem 0.75rem; }
    body.student-sent .task-subtitle { margin: 0 0 0.5rem; min-height: 2.6em; }
    body.student-sent .sent-tabs { margin-bottom: 0.75rem; }
    /* The sent feedback pages' tabs (Feedback / Role-play or Your letter / Model): three equal tabs across a phone. */
    .sent-tabs .kind-tab { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0.5rem 0.2rem; font-size: 0.9rem; text-align: center; white-space: nowrap; }
    .write-main .task-subtitle { margin: 0 0 0.6rem; font-size: 1rem; }
    .write-main { padding: 0.75rem; }
    .feedback-view .feedback-grid, .feedback-view-scroll .feedback-grid { grid-template-columns: 1fr !important; }
}

/* Student feedback page on a phone, "Your letter" / "Model letter" / "Role-play" tabs: the two columns stack, the left
   column (case notes and task, or the role card) first and the letter or model answer below it, and the two
   scroll together beneath the fixed header, buttons and title, exactly as the Feedback tab does. */
@media (max-width: 700px) {
    body.write-mode.ref-open .write-layout { flex-direction: column; flex: 1 1 auto; height: auto; min-height: 0; overflow-y: auto; gap: 1rem; margin-top: 0; }
    body.write-mode.ref-open .write-layout .write-column { flex: 0 0 auto; width: 100%; }
    body.write-mode.ref-open .write-layout .letter-pane,
    body.write-mode.ref-open .write-layout .case-notes-scroll { flex: 0 0 auto; overflow: visible; max-height: none; }
    body.write-mode.ref-open .write-layout .instructions-block { max-height: none; }
    /* The writing task is always shown here, so there is nothing for Hide / Show to do. */
    body.write-mode.ref-open .write-layout .instructions-toggle { display: none; }
}

/* Praise on a completed practice exercise, in the "Approve changes" colour of the Review page (golden in dark mode). */
.exercise-praise { color: var(--st-approve); font-weight: 600; font-size: 1.05rem; margin: 0.8rem 0 0.4rem; display: flex; align-items: center; }
.praise-medal { flex: 0 0 auto; margin-right: 10px; }
/* The words take the medal's colour: deeper shades on a light background, paler ones in dark mode (where gold is the
   Approve changes colour itself). */
.exercise-praise.praise-gold { color: #8f6c00; }
.exercise-praise.praise-silver { color: #3d6593; }
.exercise-praise.praise-bronze { color: #942f14; }   /* a reddish bronze, to stay clearly apart from the gold on a light background */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .exercise-praise.praise-gold { color: var(--st-approve); }
    :root:not([data-theme="light"]) .exercise-praise.praise-silver { color: #a6c4e4; }
    :root:not([data-theme="light"]) .exercise-praise.praise-bronze { color: #dd9257; }
}
:root[data-theme="dark"] .exercise-praise.praise-gold { color: var(--st-approve); }
:root[data-theme="dark"] .exercise-praise.praise-silver { color: #a6c4e4; }
:root[data-theme="dark"] .exercise-praise.praise-bronze { color: #dd9257; }

/* The foot of a practice exercise: Back to feedback, then the Check or Practise button (wrapping only where the screen
   is too narrow). */
.exercise-foot { flex-wrap: wrap; margin-top: 1rem; }
/* The link and the button beside it are one height (tall enough to tap) and one shape. */
.exercise-foot > a.button-link,
.exercise-foot > button.button-link,
.exercise-foot > button.primary {
    display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
    min-height: 44px; margin: 0; padding: 0.3rem 0.9rem; font-size: 0.95rem; line-height: 1.2; border-radius: 9px;
}

/* Practice exercise on a phone: the header stays put and only the exercise scrolls, as on the feedback page. */
@media (max-width: 700px) {
    body.exercise-page { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
    body.exercise-page header { flex: 0 0 auto; }
    body.exercise-page .site-footer { position: static; flex: 0 0 auto; padding-block: 0.5rem; }
    body.exercise-page main.student-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}

/* Whole-pixel column widths, so each light sits on the pixel grid and its edges stay crisp. */
.perf-table th.perf-col { width: 72px; min-width: 72px; }
.perf-key .traffic-light { width: 20px; height: 20px; vertical-align: middle; }

/* Class and student forms: a class only takes students of its own profession. */
.class-pick[hidden], #class-pick-hint[hidden], .warn-note[hidden] { display: none; }
.no-class { color: var(--warn); font-weight: 600; }
.warn-note { margin: 0.5rem 0 1rem; padding: 0.6rem 0.85rem; border: 1.5px solid var(--warn); border-radius: 8px; background: var(--warn-bg); color: var(--warn); }

/* My classes and students: New class / New student / Batch add sit together under the tabs. */
.add-actions { margin: 0 0 1.25rem; }
.add-actions .add-panel { margin-top: 0.6rem; }
.add-actions .add-panel > summary { padding: 0.15rem 0; }
.add-actions .add-link-row { margin: 0.6rem 0 0; }
.add-link { text-decoration: none; display: inline-block; padding: 0.15rem 0; }
.add-link::before { content: "\25B8"; display: inline-block; width: 1.05em; font-size: 0.95em; }

/* New class / New student / Batch add: one row of links above the tabs, the open form below the row. */
.add-actions { margin: 0 0 1rem; }
.add-actions .add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; margin: 0; }
.add-toggle { background: none; border: 0; padding: 0.15rem 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; }
@media (hover: hover) {
    .add-toggle:hover { text-decoration: underline; }
}
.add-toggle::before { content: "\25B8"; display: inline-block; width: 1.05em; font-size: 0.95em; }
.add-toggle[aria-expanded="true"]::before { content: "\25BE"; }
.add-actions .add-panel { margin-top: 0.75rem; }
.add-actions .add-panel[hidden] { display: none; }

/* Batch tab: the lozenge on the tab and heading, the lists under it, and the inline "place in a class" form. */
.tab-lozenge { display: inline-block; min-width: 1.35em; padding: 0 0.4em; margin-left: 0.25em; border-radius: 999px; background: var(--hl); border: 1px solid var(--hl-border); color: var(--ink); font-size: 0.8em; font-weight: 700; line-height: 1.5; text-align: center; vertical-align: 0.05em; }
.batch-heading { margin: 1.25rem 0 0.5rem; font-size: 1.15rem; }
.batch-subheading { margin: 1rem 0 0.4rem; font-size: 1rem; }
.batch-card { margin: 0 0 0.75rem; }
.batch-card > summary { cursor: pointer; padding: 0.4rem 0; }
.batch-card > summary .meta { margin-left: 0.4rem; }
.place-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.place-form select, .place-form input[type="text"] { flex: 1 1 11rem; min-width: 0; }
@media (max-width: 700px) {
    .place-form { flex-direction: column; align-items: stretch; }
    .place-form button { width: 100%; min-height: 44px; }
}

.archived-classes { margin-top: 1.25rem; }
.archived-classes .tab-lozenge { margin-left: 0.4em; }

/* Batch add: column names in the notes under the intro */
.batch-fields strong { color: var(--accent); }

/* File upload "Choose file" button: same look as the outlined buttons, not the browser's own */
input[type="file"]::file-selector-button {
    font: inherit;
    font-weight: 600;
    padding: 0.5rem 1rem;
    margin-right: 0.75rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: 9px;
    color: var(--accent);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    input[type="file"]::file-selector-button:hover {
        background: var(--accent);
        color: var(--accent-ink);
    }
}

/* Batch add preview: class reference beside the class name */
.class-ref { color: var(--accent); font-weight: 700; }

/* Batch add preview: profession dropdown, same look as the form fields */
select.profession-fix,
select.class-pick-select {
    padding: 0.4rem 0.5rem;
    background: var(--bg);
    color: var(--ink);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: inherit;
    max-width: 100%;
    cursor: pointer;
}

select.profession-fix:focus,
select.class-pick-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Batch add preview: spacing of the class options and buttons under the table */
#batch-import-form { margin-top: 1.5rem; }
#batch-import-form > label:not(.checkbox-label) { margin-top: 0.5rem; margin-bottom: 0.5rem; }
#batch-import-form input[type="radio"],
#batch-import-form input[type="checkbox"] { margin: 0 0.4rem 0 0; padding: 0; }
#batch-import-form .button-row { margin-top: 1rem; }

/* Batch add preview: class code green when the class suits the student's profession, red (and the class highlighted) when not */
.class-ok .class-ref { color: var(--correct); }
.class-wrong { background: var(--incorrect-bg); border-radius: 5px; padding: 0.1rem 0.3rem; }
.class-wrong .class-ref { color: var(--incorrect); }

/* Batch add preview: "Delete class" appears over an unsuitable class when you point at it */
.class-item { position: relative; }
.class-delete {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 5;
    white-space: nowrap;
    padding: 0.2rem 0.6rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--incorrect);
    color: var(--bg);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}
.class-wrong:hover .class-delete,
.class-wrong:focus-within .class-delete { display: block; }

/* A red warning under a form field (same look as the Batch add status) */
.field-warning { margin: -0.5rem 0 1rem; }

select.class-pick-select { max-width: 18rem; text-overflow: ellipsis; }

/* Dashboard Overview: the numbers in MEUK blue (light) / MEUK teal (dark), i.e. the interface accent colour */
.dashboard-overview .stat-number { color: var(--accent); }

/* Task Library cards: no extra space above the title (the card padding is enough) */
.template-card > h2 { margin-top: 0; }

/* Speaking "choose the best response" exercise: one boxed group of responses per situation */
.exercise-choice { margin: 0 0 1rem; padding: 0.8rem 1rem; border: 1.5px solid var(--border); border-radius: 12px; background: var(--panel); min-width: 0; }
.exercise-choice-note { margin: 0.5rem 0 0; font-size: 0.95rem; font-style: italic; }
.exercise-choice-note .choice-label-1 { color: var(--tl-green); }
.exercise-choice-note .choice-label-2 { color: var(--tl-amber); }
.exercise-choice-note .choice-label-3 { color: var(--tl-red); }
.exercise-choice-situation { margin: 0 0 0.6rem; font-weight: 600; }
.exercise-choice .exercise-choice-number { color: var(--accent); margin-right: 0.3rem; }
.exercise-choice .exercise-option-list { margin: 0.4rem 0 0; }

/* Choose the best response: the chosen response is outlined in the accent colour, then green (strongest) or red (weaker) after a check */
.exercise-choice input[type="radio"] { accent-color: var(--accent); margin-top: 0.2rem; }
.exercise-choice .exercise-option-item:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.exercise-choice .exercise-option-item.choice-correct:has(input) { border-color: var(--correct); background: var(--correct-bg); }
.exercise-choice .exercise-option-item.choice-wrong:has(input) { border-color: var(--incorrect); background: var(--incorrect-bg); }
.exercise-choice .exercise-option-item.choice-correct input[type="radio"] { accent-color: var(--correct); }
.exercise-choice .exercise-option-item.choice-wrong input[type="radio"] { accent-color: var(--incorrect); }
/* A situation answered correctly is locked: keep its green, not the greyed look of a disabled control */
.exercise-choice .exercise-option-item.choice-correct input:disabled { opacity: 1; }
.exercise-choice .exercise-option-item:has(input:disabled) label { cursor: default; }
/* Choose the best response: the ranking in colour. Strongest, Weaker and Weakest use the traffic-light colours. */
.exercise-choice .exercise-option-item.choice-weaker:has(input) { border-color: var(--tl-amber); background: var(--warn-bg); }
.exercise-choice .exercise-option-item.choice-weaker input[type="radio"] { accent-color: var(--tl-amber); }
.rank-Strongest { color: var(--tl-green); }
.rank-Weaker { color: var(--tl-amber); }
.rank-Weakest { color: var(--tl-red); }

/* Review Queue: feedback whose Send was pressed; the student's exercises are being built (Releasing). */
.queue-table tr.queue-sending { opacity: 0.55; }
.queue-table tr.queue-sending .queue-sending-label { font-style: italic; }

/* Admin Failures page */
.failures-table td { vertical-align: top; }
.failures-table td:last-child { overflow-wrap: anywhere; }
.queue-table tr.queue-sent .queue-sending-label { color: var(--ok, #2e7d32); font-weight: 600; }
.notice-warn { padding: 0.6rem 0.9rem; border: 2px solid var(--tl-amber, #e0a000); border-radius: 8px; background: var(--hl, #fff3c4); color: inherit; }

/* Second attempt, "Original task": the same Case Notes and Writing Task panels as the first attempt */
.original-task-pane:not(.hidden) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }


/* ===== Locked menu bar and tabs ==============================================================================
   The menu bar stays at the top of the screen while the page scrolls underneath it, and tabs stay locked just
   below it (the way the Writing feedback page has always behaved). --header-h is the menu bar's height, kept up to
   date by sticky-frame.js (these are only the starting values). A page whose own box does the scrolling (Create Task)
   already keeps its menu bar still, so there the tabs lock to the top of that box instead. */
:root { --header-h: 119px; }
@media (max-width: 700px) { :root { --header-h: 75px; } }

header { position: sticky; top: 0; z-index: 30; }

.kind-tabs {
    position: sticky;
    top: var(--header-h);
    z-index: 20;
    background: var(--bg);
    box-shadow: 0 1rem 0 0 var(--bg);   /* the gap under the tabs is covered too, so nothing shows through it */
}
body.fit-page .kind-tabs { top: -2rem; }   /* the box has 2rem of padding above its content; the tabs lock flush under the menu bar */

/* The student feedback pages (Writing and Speaking): the task title is locked under the menu bar and the tabs under
   the title, so the same things stay put whichever page it is. The title's gap below is padding, not margin, so its
   background covers it. --title-h is measured by sticky-frame.js. */
body.student-sent .write-main { padding-top: 1rem; }
body.student-sent .task-subtitle {
    position: sticky; top: var(--header-h); z-index: 20; background: var(--bg);
    margin: 0; padding: 0.5rem 0 1rem;
}
body.student-sent .sent-tabs { top: calc(var(--header-h) + var(--title-h, 0px)); }
@media (max-width: 700px) {
    body.student-sent .write-main { padding-top: 0; }
    body.student-sent .task-subtitle { padding: 0.5rem 0 0.5rem; }
}
.perf-table th.perf-col .task-ref { margin-right: 0; }

/* Matching exercise (Appropriateness of Language): a sentence with its medical term in bold, and a drop-down of everyday phrases */
/* Exercises with a recording: the play button sits alone in the first column and the sentence in the second, so the button is in
   the same place and the text always starts at the same left edge, however long the sentence is. A drop-down or a note goes under
   the sentence in the second column. */
.exercise-matching-item,
.exercise-dictation-item { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 0.75rem; row-gap: 0.5rem; align-items: start; }
.exercise-matching-item .exercise-audio-play,
.exercise-dictation-item .exercise-audio-play { grid-column: 1; grid-row: 1; margin: 0; align-self: start; }
.exercise-matching-sentence,
.exercise-dictation-sentence { grid-column: 2; grid-row: 1; line-height: 1.5; padding-top: 10px; overflow-wrap: anywhere; }
.exercise-matching-item .exercise-linking-select { grid-column: 2; grid-row: 2; width: 100%; max-width: 100%; min-height: 44px; font-size: 16px; }
.exercise-matching-sentence strong { color: var(--accent); }
.exercise-audio-play { min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-size: 16px; cursor: pointer; margin-right: 0.4rem; vertical-align: middle; }
.gapfill-input { font: inherit; padding: 0.3rem 0.5rem; border: 1px solid var(--border, #bbb); border-radius: 6px; min-width: 9ch; max-width: 100%; background: var(--bg); color: inherit; }
/* The gap's field sits inside the line of text, shorter than the line, so every line of a sentence is the same distance apart. */
/* EVERY TYPE-IN GAPFILL uses these three classes: gapfill-item on its card, gapfill-sentence on the text and gapfill-input on
   the field. Whole pixels throughout: with fractions, each field is rounded differently on screen and some come out a pixel short. */
.gapfill-sentence { line-height: 30px; padding-top: 7px; }
.exercise-linking-item.gapfill-item { padding-block: 10px; }
/* 28px leaves room above the typing cursor, and below for trailing letters, inside the borders. */
.gapfill-sentence .gapfill-input { box-sizing: border-box; height: 28px; line-height: 22px; padding-block: 1px 3px; margin: 0; vertical-align: baseline; }
.exercise-matching-item select.is-wrong { border-color: var(--incorrect); background: var(--incorrect-bg); }
.exercise-dictation-note { grid-column: 2; grid-row: 2; margin: 0; color: var(--incorrect); }
.gapfill-input.is-wrong { border-color: var(--incorrect); background: var(--incorrect-bg); }
.exercise-linking-select.is-wrong { border-color: var(--incorrect); background: var(--incorrect-bg); }
.exercise-matching-item .exercise-matched { grid-column: 2; grid-row: 2; }
.exercise-explanation { line-height: 1.5; }
.exercise-dictation-sentence strong { color: var(--accent); }

/* Keyboard and cursor focus: one MEUK look everywhere, never the browser default ring. Text fields, drop-downs and text areas get
   an accent border and a soft glow; buttons, links, tick boxes, radio buttons and summaries get an accent outline. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="button"]):not([type="submit"]):focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible,
input[type="file"]:focus-visible,
input[type="submit"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Practice exercises, fields the student types or chooses in: on the darkest background in dark mode (var(--bg)) and the lightest in
   light mode (var(--panel), white). So in light mode the cards and boxes around them, and the instructions, sit on the light grey.
   :where() keeps these rules weak so the red and green marking colours still win. */
@media (prefers-color-scheme: light) {
    :where(:root:not([data-theme="dark"]) body.exercise-page) .task-brief,
    :where(:root:not([data-theme="dark"]) body.exercise-page) .exercise-linking-item,
    :where(:root:not([data-theme="dark"]) body.exercise-page) .exercise-reorder-item { background: var(--bg); }
    :where(:root:not([data-theme="dark"]) body.exercise-page) .exercise-answer,
    :where(:root:not([data-theme="dark"]) body.exercise-page) .exercise-linking-select,
    :where(:root:not([data-theme="dark"]) body.exercise-page) .exercise-reorder-select,
    :where(:root:not([data-theme="dark"]) body.exercise-page) .gapfill-input { background: var(--panel); }
}
:where(:root[data-theme="light"] body.exercise-page) .task-brief,
:where(:root[data-theme="light"] body.exercise-page) .exercise-linking-item,
:where(:root[data-theme="light"] body.exercise-page) .exercise-reorder-item { background: var(--bg); }
:where(:root[data-theme="light"] body.exercise-page) .exercise-answer,
:where(:root[data-theme="light"] body.exercise-page) .exercise-linking-select,
:where(:root[data-theme="light"] body.exercise-page) .exercise-reorder-select,
:where(:root[data-theme="light"] body.exercise-page) .gapfill-input { background: var(--panel); }

/* Student pages: the Log out button in the menu bar (before the light/dark button), and the warning before logging out
   for inactivity. */
header > a.student-logout { margin-left: auto; padding: 0.3rem 0.9rem; border: 1.5px solid var(--accent); border-radius: 999px; font-size: 0.9rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
header > a:not(.site-logo) ~ a.student-logout { margin-left: 0; }
header > a.student-logout + #themeToggle { margin-left: 0; }
/* On a phone the title, the way back, Log out and the light/dark button share one line. */
@media (max-width: 700px) {
    body.writing-page header, body.speaking-page header { gap: 0.35rem; }
    body.writing-page header h1, body.speaking-page header h1 { min-width: min-content; }
    body.writing-page header > a:not(.site-logo), body.speaking-page header > a:not(.site-logo) { font-size: 0.8rem; white-space: nowrap; }
    header > a.student-logout { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}
@media (max-width: 359px) {
    body.writing-page header, body.speaking-page header { gap: 0.25rem; padding-inline: 0.4rem; }
    body.writing-page .site-logo img, body.speaking-page .site-logo img { height: 28px; width: auto; }
    body.writing-page header h1, body.speaking-page header h1 { font-size: 0.9rem; }
    body.writing-page header > a:not(.site-logo), body.speaking-page header > a:not(.site-logo) { font-size: 0.7rem; }
    body.writing-page header > a.student-logout, body.speaking-page header > a.student-logout { padding-inline: 0.4rem; }
    body.student-sent .sent-tabs .kind-tab { font-size: 0.78rem; padding-inline: 0.15rem; }   /* so that Model dialogue fits */
}
.session-warning { position: fixed; inset: 0; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(0, 0, 0, 0.55); }
.session-warning-panel { max-width: 26rem; padding: 1.25rem 1.5rem; border-radius: 10px; text-align: center; background: var(--panel); color: var(--ink); border: 1px solid var(--accent); }

/* Practice exercises: headings of the feedback and explanations, in the MEUK colour. */
.exercise-heading, body.exercise-page .feedback-card-header strong { color: var(--accent); }
/* A finished content exercise: a ticked point that could go either way is amber, not green. */
.exercise-option-item.selection-could input[type="checkbox"]:disabled:checked { background-color: var(--tl-amber); border-color: var(--tl-amber); }
/* A drop-down marked red: only the closed box is red, not the list that opens from it. */
.exercise-linking-select option { background: var(--panel); color: var(--ink); }
.exercise-linking-select option:disabled { color: var(--muted); }
/* A word given to the student after the last try. */
.exercise-dictation-sentence strong.gapfill-revealed { color: var(--tl-amber); }
.exercise-hint { margin: 0.6rem 0; }
.exercise-hint summary { display: inline-block; cursor: pointer; }
.exercise-hint[open] summary { margin-bottom: 0.6rem; }

/* Practice exercises: the tick or cross on an answer (a solid circle, the symbol in the background colour). */
.result-mark { width: 20px; height: 20px; flex: 0 0 auto; }
.exercise-choice .exercise-option-item { position: relative; }
.exercise-choice .exercise-option-item .result-mark { margin-top: 0.15rem; }
/* The mark stands where the radio button was. */
.exercise-choice .exercise-option-item.choice-correct input[type="radio"],
.exercise-choice .exercise-option-item.choice-wrong input[type="radio"],
.exercise-choice .exercise-option-item.choice-weaker input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.exercise-matching-item .result-mark,
.exercise-dictation-item .result-mark { grid-column: 1; grid-row: 2; justify-self: center; align-self: center; }
.exercise-note-reminder { margin: 0.6rem 0; font-weight: 600; }
/* Record yourself, on a finished exercise. */
.record-self { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.record-self:empty { display: none; }
.record-self button { min-height: 44px; }
.record-self button[hidden] { display: none; }
.record-self button.is-recording { border-color: var(--incorrect); color: var(--incorrect); }
.record-message { flex: 1 0 100%; margin: 0; color: var(--incorrect); }
.record-message:empty { display: none; }

/* Reorder: from the third unsuccessful check, a sentence that needs moving. */
.exercise-reorder-item.is-misplaced { border-color: var(--incorrect); background: var(--incorrect-bg); }

/* Analyse performance, practice exercises: the medal tables and the buttons that choose what they show. */
.pick-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0 0.8rem; }
.pick-row a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }
.medal-heading { margin: 1.2rem 0 0.4rem; }
.medal-table { width: 100%; max-width: 52rem; border-collapse: collapse; table-layout: fixed; background: var(--panel); font-size: 0.9rem; }
.medal-table th, .medal-table td { padding: 0.45rem 0.15rem; text-align: center; vertical-align: middle; border-bottom: 1px solid var(--border); }
.medal-table thead th { vertical-align: bottom; font-size: 0.75rem; }
.medal-table th:first-child { width: 34%; text-align: left; padding-left: 0.5rem; font-weight: 600; overflow-wrap: anywhere; }
.medal-table td.zero { color: var(--muted); }
.medal-key { position: relative; display: inline-flex; flex-direction: column; align-items: center; cursor: help; }
.medal-tip { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: 13rem; max-width: 70vw; padding: 0.5rem 0.7rem; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-size: 0.85rem; font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; visibility: hidden; z-index: 40; }
.medal-key:hover .medal-tip, .medal-key:focus .medal-tip { visibility: visible; }
.medal-table th:nth-last-child(-n+2) .medal-tip { left: auto; right: 0; transform: none; }
/* So that the column headings do not run into each other on narrower screens. */
@media (max-width: 600px) { .medal-table th:first-child { width: 30%; } .medal-table thead th { font-size: 0.66rem; } }
@media (max-width: 420px) { .medal-table { font-size: 0.8rem; } .medal-table th:first-child { width: 28%; } .medal-table thead th { font-size: 0.55rem; padding-inline: 0; } }

/* Writing add-ons. The student's message, and the line that stays if they carry on. */
.addon-dialog { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1100; display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; background: rgba(0, 0, 0, 0.6); }
.addon-panel { max-width: 36rem; width: 100%; margin: auto; padding: 1rem 1.25rem; border: 2px solid var(--tl-amber); border-radius: 10px; background: var(--panel); color: var(--ink); text-align: left; }
.addon-panel p { margin: 0.4rem 0; }
.addon-panel ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.addon-panel li { margin: 0.25rem 0; }
.addon-title, .addon-heading { font-weight: 700; }
.addon-browser { color: var(--accent); font-weight: 700; }
.addon-bar { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; padding: 0.4rem 0.7rem; border: 1.5px solid var(--tl-amber); border-radius: 8px; background: var(--warn-bg); font-weight: 600; }
/* The teacher's warnings: at the top of the Review page, and the label in the Review Queue with its details. */
.addon-warning { margin: 0 0 1rem; padding: 0.8rem 1rem; border: 2px solid var(--tl-amber); border-radius: 10px; background: var(--warn-bg); }
.addon-warning p { margin: 0.3rem 0; }
.addon-flag { position: relative; display: inline-block; margin-top: 0.2rem; padding: 0.1rem 0.7rem; border: 1px solid var(--tl-amber); border-radius: 999px; color: var(--tl-amber); font-size: 0.8rem; font-weight: 700; cursor: help; }
.addon-flag-tip { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 17rem; max-width: 75vw; padding: 0.5rem 0.7rem; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-size: 0.85rem; font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; visibility: hidden; }
.addon-flag:hover .addon-flag-tip, .addon-flag:focus .addon-flag-tip { visibility: visible; }

/* Log-in screen: the title sits beside the logo. The right-hand space keeps it clear of the light/dark button. */
.login-brand { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 4.5rem 0 2rem; }
.login-brand .site-logo-standalone { padding: 0; }
.login-brand-title { font-size: 2rem; font-weight: 700; color: var(--ink); }   /* as the title in every page header */
@media (max-width: 700px) { .login-brand { padding-left: 1rem; } .login-brand-title { font-size: 1.3rem; } }
