/* --- Theme palette ---
   "Slate frame": a slate page background, with each page sitting on an off-white panel (never
   pure white - both tiers are tinted toward the logo's blues). --navy and --sky are sampled
   straight from assets/jerry-logo-full.png. --yellow is the old brand-bar tagline yellow, kept as
   the accent - only ever used on dark backgrounds (nav, overlay) or as a fill behind dark text,
   since yellow text on the off-white panels would be unreadable.
   Tune the overall darkness here: --page-bg for the frame, --panel/--surface for the content. */
:root {
    --page-bg: #7d8ba1;       /* slate frame around the panel */
    --panel: #e9edf3;         /* the page itself */
    --surface: #f5f7fa;       /* raised things on the panel: tables, inputs, cards, chat bubbles */
    --surface-2: #dde3ec;     /* recessed/header things: table headers, chat box, inline code */
    --zebra: #edf1f6;
    --row-hover: #dce7f7;
    --border: #c9d1dc;
    --border-strong: #b3bdcb;
    --text: #1c2533;
    --muted: #5a6577;
    --navy: #013b95;
    --navy-dark: #0a1f44;
    --sky: #008cfe;
    --link: #0b4fb3;
    --yellow: #ffd873;
}

html {
    background: var(--page-bg);
    min-height: 100%;
}

/* The body IS the panel - so login pages and print views (which build their own <body> or skip
   the nav) get the frame for free, no wrapper element needed. border-box + 1344px max = the same
   1280px content width as before. */
body {
    font-family: system-ui, sans-serif;
    box-sizing: border-box;
    max-width: 1344px;
    width: calc(100% - 1.5rem);
    margin: 1.5rem auto;
    padding: 1.5rem 2rem 0.5rem;
    background: var(--panel);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(10, 25, 50, 0.3);
    color: var(--text);
    line-height: 1.5;
}

/* Landing + login pages: a small centered card instead of the full-width app panel. */
body.narrow {
    max-width: 720px;
    margin-top: 3rem;
}

a {
    color: var(--link);
}

/* Rendered assignment / chat markdown keeps a readable line length (~the old page width)
   even though the container is now wide - long prose paragraphs at 1280px are hard to track. */
.markdown-body {
    max-width: 90ch;
}

/* --- Brand bar --- */
/* Sits flush across the top of the panel (negative margins cancel the body padding). The logo is
   navy-on-transparent, so this strip has to stay light - it can't go back to a dark gradient. */
.brand-bar {
    margin: -1.5rem -2rem 0;
    padding: 0.85rem 2rem 0.7rem;
    display: flex;
    align-items: center;
}

.brand-logo {
    display: block;
    height: 64px;
    width: auto;
}

/* Title-bar Class picker (teacher pages, lib/layout.php, 2026-11-13). */
.class-picker {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
}
.class-picker select {
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

/* Landing + login pages have no nav - the logo stands on its own, centered, a bit larger. */
.login-logo {
    text-align: center;
    margin: 0.5rem 0 1rem;
}

.login-logo img {
    height: 110px;
    width: auto;
}

/* --- Navigation --- */
/* Full-width logo-navy band under the brand bar; yellow marks the current page. */
.site-nav {
    display: flex;
    gap: 1.5rem;
    margin: 0 -2rem 1.75rem;
    padding: 0 2rem;
    background: var(--navy);
}

.site-nav a {
    color: #d3def0;
    text-decoration: none;
    font-weight: 600;
    padding: 0.7rem 0 0.6rem;
}

.site-nav a:hover {
    color: #fff;
}

.site-nav a.active {
    color: var(--yellow);
    box-shadow: inset 0 -3px 0 var(--yellow);
}

/* Course Setup sub-tabs (Classes | Roster | Units), lib/layout.php 2026-11-13. Sits directly under
   the navy bar, which then drops its own bottom margin. */
.site-nav.has-subnav { margin-bottom: 0; }
.sub-nav {
    display: flex;
    gap: 0.25rem;
    margin: 0 -2rem 1.75rem;
    padding: 0.4rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.sub-nav a {
    color: var(--navy);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
}
.sub-nav a:hover { background: var(--row-hover); }
.sub-nav a.active { background: var(--navy); color: #fff; }

/* --- Form controls --- */
/* Forms in this app are narrow input stacks (login, roster paste, dashboard filters).
   Cap them so they don't stretch across the now-wide page container. */
form {
    max-width: 640px;
}

/* The student submit form is the exception - it holds the assignment instructions preview and
   the code-paste box. Let it fill the page like the tables on the other pages do (drop the cap
   the generic `form` rule sets). */
.submit-form {
    max-width: none;
}
.submit-form .assignment-detail-box {
    max-width: 100%;
}

textarea {
    width: 100%;
    height: 100px;
    margin-bottom: 1rem;
    padding: 0.5rem;
    font-family: inherit;
    box-sizing: border-box;
}

/* Text inputs/selects default to browser pure white - pull them onto the off-white surface. */
textarea,
select,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]) {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

textarea:focus,
select:focus,
input:focus {
    outline: 2px solid var(--sky);
    outline-offset: 0;
}

button {
    padding: 0.5rem 1rem;
    cursor: pointer;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
}

button:hover:not(:disabled) {
    filter: brightness(1.15);
}

button:disabled {
    background: #b7c0cc;
    color: #eef1f6;
    cursor: default;
}

#approveBtn {
    background: #28a745;
    display: none;
}

/* --- Chat box & messages --- */
.chat-box {
    border: 1px solid var(--border);
    padding: 1rem;
    height: 420px;
    overflow-y: auto;
    margin-bottom: 1rem;
    background: var(--surface-2);
    border-radius: 6px;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

.message .label {
    display: block;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
    color: var(--muted);
}

.message.system {
    color: var(--muted);
    font-style: italic;
    background: transparent;
    padding: 0 0 0.5rem 0;
}

.message.teacher {
    background: #d4e3f9;
}

.message.agent {
    background: var(--surface);
    border: 1px solid var(--border);
}

.message.error {
    background: #fdecea;
    border: 1px solid #f5c2c0;
    color: #9c2a20;
}

/* --- Agent 4 (reviewer) on Brainstorm --- */
#reviewBtn {
    background: #6f42c1;
    display: none;
}

.message.reviewer {
    background: #f1ecfa;
    border: 1px solid #d6c8ee;
}

.review-issue {
    padding: 0.5rem 0;
    border-top: 1px solid #eee6f8;
}

.review-issue .loc {
    font-weight: 600;
}

.review-issue p {
    margin: 0.25rem 0 0;
}

.sev {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    margin-right: 0.4rem;
}

.sev.high   { background: #fdecea; color: #9c2a20; }
.sev.medium { background: #fff4d6; color: #6b5200; }
.sev.low    { background: #eef1f4; color: #4a5560; }

.review-note {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.5rem 0 0;
}

/* --- Rendered Markdown content --- */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin: 0.9em 0 0.4em;
    line-height: 1.25;
}

.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }

.markdown-body p {
    margin: 0.5em 0;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.4em;
    margin: 0.5em 0;
}

.markdown-body li {
    margin: 0.25em 0;
}

@media print {
    /* Print views (teacher/print_assignment.php) hide their own
       "Print this page" button in the actual printed output. */
    .no-print {
        display: none !important;
    }
    /* Drop the slate frame/panel on paper. */
    html {
        background: none;
    }
    body {
        margin: 0;
        max-width: none;
        width: auto;
        padding: 0;
        background: none;
        box-shadow: none;
        border-radius: 0;
    }
}

.markdown-body code {
    background: var(--surface-2);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: ui-monospace, Consolas, monospace;
}

/* Feedback code spans get a more distinct color than the default grey - it read too close to
   the row-hover blue right next to it. Reuses the same yellow already established for
   cohort-badge, for a consistent palette instead of a new one-off color. Text is darkened well
   past cohort-badge's #8a6d00 (only ~4.4:1 contrast on this background, under WCAG AA's 4.5:1
   minimum) to ~7:1 - students flagged the text as too low-contrast to read comfortably. Higher
   specificity than .markdown-body code (which still supplies padding/radius/font) so it wins
   regardless of source order. */
ul.feedback-list code {
    background: #fff3cd;
    color: #4a3800;
}

.markdown-body pre {
    background: #1e1e1e;
    color: #e6e6e6;
    padding: 0.85em 1em;
    border-radius: 6px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-body blockquote {
    border-left: 3px solid var(--border-strong);
    margin: 0.6em 0;
    padding: 0.2em 0 0.2em 1em;
    color: var(--muted);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1em 0;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
    font-size: 0.92rem;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 0.4em 0.6em;
    text-align: left;
}

.markdown-body th {
    background: var(--surface-2);
}

.markdown-body strong {
    font-weight: 700;
}

/* --- Grading dashboard --- */
.result-box {
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    white-space: pre-wrap;
}

.result-box.success {
    background: #eaf7ec;
    border: 1px solid #b7e0bb;
}

.result-box.error {
    background: #fdecea;
    border: 1px solid #f5c2c0;
}

/* Grading in-progress lock (teacher/grading.php) - a real full-page backdrop, not just a
   banner, so nothing underneath (delete buttons, score badges, the assignment dropdown) can be
   clicked while a grade call is in flight or about to reload. The Stop button lives INSIDE
   .grading-overlay-box (not out in the page) specifically so it stays reachable during
   "Grade All" even though everything else is locked out. */
.grading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
}

.grading-overlay-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--navy-dark);
    color: #fff;
    padding: 0.7rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-weight: 600;
    font-size: 0.95rem;
}

.grading-overlay .spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: grading-spin 0.8s linear infinite;
}

@keyframes grading-spin {
    to { transform: rotate(360deg); }
}

.result-box.info {
    background: #eef4fb;
    border: 1px solid #cfe2f3;
}

table.data-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 1rem;
    background: var(--surface);
}

table.data-table th, table.data-table td {
    border: 1px solid var(--border);
    padding: 0.5em 0.7em;
    text-align: left;
    vertical-align: top;
    font-size: 0.9rem;
}

table.data-table th {
    background: var(--surface-2);
}

/* Grading table: locked column widths (via <colgroup>) so opening a feedback panel never
   reflows the table - the Feedback column stays the same width whether it's a row of score
   chips or a full expanded comment. */
table.grading-table {
    table-layout: fixed;
    width: 100%;
}

table.grading-table td {
    overflow-wrap: anywhere;
}

/* Zebra striping + row hover - the grading/gradebook rows are tall, this keeps them easy to trace across. */
table.data-table tbody tr:nth-child(even) {
    background: var(--zebra);
}

table.data-table tbody tr:hover {
    background: var(--row-hover);
}

/* Students found the row-hover blue too close to the code-span styling inside feedback text -
   while reading a row's feedback, hovering made it look like part of the feedback itself was
   being highlighted. Disable just the hover here (My Grades) - zebra striping stays, other
   tables (gradebook, grading, roster) keep the hover since nobody's raised it there. */
table.data-table.no-row-hover tbody tr:hover {
    background: transparent;
}

table.data-table.no-row-hover tbody tr:nth-child(even):hover {
    background: var(--zebra);
}

/* Gradebook: pin the Student column while the grade columns scroll horizontally under it. */
.gradebook-table th:first-child,
.gradebook-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    border-right: 2px solid var(--border-strong);
}

/* Also pin the header row while scrolling down, so a column's assignment title/date stays
   visible no matter how far down the roster you've scrolled. */
.gradebook-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Assignment titles used to wrap to 2-3 lines, plus a separate badge line and a separate
   assigned/due-date line, blowing up the sticky header to 5-6 lines tall and leaving only a
   handful of student rows visible before scrolling. Two lines now: title on its own line
   (truncated with an ellipsis - full title + full date via the title="" hover tooltip), then
   type/format badges + a short date together on a second line. */
.gradebook-col-title {
    display: block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gradebook-col-line {
    margin-top: 0.25rem;
}

.gradebook-col-date {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--muted);
}

/* The Student header cell is sticky on BOTH axes at once (stays pinned top-left as a corner) -
   needs the highest z-index so it stacks above the plain top-sticky header row and the plain
   left-sticky student column as they scroll underneath it. */
.gradebook-table thead th:first-child {
    z-index: 3;
}

/* A sticky cell overlaps the scrolling columns, so it needs its own opaque background - the
   row's <tr> background does not show through a sticky <td>. Mirror the header shade, the
   zebra striping, and the hover colour so the pinned column matches its row. */
.gradebook-table thead th:first-child {
    background: var(--surface-2);
}

.gradebook-table tbody td:first-child {
    background: var(--surface);
}

.gradebook-table tbody tr:nth-child(even) td:first-child {
    background: var(--zebra);
}

.gradebook-table tbody tr:hover td:first-child {
    background: var(--row-hover);
}

.score-badge {
    display: inline-block;
    background: #eaf7ec;
    border: 1px solid #b7e0bb;
    color: #1e7a2e;
    font-weight: 700;
    padding: 0.15em 0.6em;
    border-radius: 12px;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.feedback-list {
    margin: 0.3rem 0 0;
    padding-left: 1.2em;
}

.feedback-list li {
    margin: 0.25em 0;
    font-size: 0.88rem;
}

/* --- Grading: per-attempt score strip + collapsible feedback panels --- */
.attempt-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

/* The score chips double as buttons - override the global blue <button> styling. */
button.score-badge {
    background: #eaf7ec;
    border: 1px solid #b7e0bb;
    color: #1e7a2e;
    font-weight: 700;
    padding: 0.15em 0.6em;
    border-radius: 12px;
    font-size: 0.9rem;
    margin: 0;
    cursor: pointer;
    line-height: 1.4;
}

button.score-badge:hover {
    background: #d8f0dc;
}

button.score-badge.active {
    background: #1e7a2e;
    border-color: #1e7a2e;
    color: #fff;
}

button.score-badge.pending {
    background: #f0f0f0;
    border-color: #d6d6d6;
    color: #777;
}

button.score-badge.pending:hover {
    background: #e6e6e6;
}

button.score-badge.pending.active {
    background: #666;
    border-color: #666;
    color: #fff;
}

/* A lab attempt signed off as Fail (Grade Submissions, 2026-11-13): red, not the default green. */
button.score-badge.failed {
    background: #fbeceb;
    border-color: #f0c2bc;
    color: #9c2a20;
}
button.score-badge.failed:hover { background: #f8e1de; }
button.score-badge.failed.active {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

.attempt-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

/* Lab sign-off on Grade Submissions (2026-11-13): Status pill + a Pass|Fail segmented toggle. The
   side that's already chosen is "on" (and disabled - clicking it again would change nothing). */
tr:target > td { background: #fffbea; }
.lab-state {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}
.lab-state.awaiting { background: #fff3cd; color: #7a5b00; }
.lab-state.passed { background: #d4edda; color: #1e6b34; }
.lab-state.failed { background: #f8d7da; color: #9c2a20; }
.lab-toggle { display: inline-flex; margin: 0 0.6rem 0.35rem 0; vertical-align: middle; }
.lab-toggle .seg {
    padding: 0.35rem 0.95rem;
    font-size: 0.9rem;
    font-weight: 700;
    background: #fff;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 0;
    cursor: pointer;
}
.lab-toggle .seg.pass { border-radius: 6px 0 0 6px; }
.lab-toggle .seg.fail { border-radius: 0 6px 6px 0; border-left: none; }
.lab-toggle .seg.pass:hover:not(:disabled) { background: #e3f4e8; color: #1e6b34; }
.lab-toggle .seg.fail:hover:not(:disabled) { background: #f8e1de; color: #9c2a20; }
.lab-toggle .seg.pass.on { background: #1e6b34; color: #fff; border-color: #1e6b34; cursor: default; }
.lab-toggle .seg.fail.on { background: #c0392b; color: #fff; border-color: #c0392b; cursor: default; }
.lab-ticks { font-size: 0.82rem; color: var(--muted); }

.attempt-panel {
    margin-top: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.attempt-panel[hidden] {
    display: none;
}

.attempt-panel-meta {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.attempt-panel .feedback-list {
    margin-top: 0;
}

button.attempt-delete-btn {
    margin-top: 0.5rem;
    background: #c0392b;
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
}

.assignment-detail-box {
    background: #f8f5e9;
    border: 1px solid #e6dcae;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    max-height: 700px;
    overflow-y: auto;
}

/* --- Student submit: "your previous attempts" (copy-from-a-past-submission) --- */
.prior-attempt {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    margin-bottom: 0.5rem;
}

.prior-attempt > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.prior-attempt-text {
    width: 100%;
    margin: 0.6rem 0 0;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    background: var(--panel);
    box-sizing: border-box;
}

button.prior-attempt-use {
    margin-top: 0.5rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

/* --- Student submit: outstanding-assignments ("to-do") card --- */
.todo-card {
    max-width: none;
    border: 1px solid #c3d6ee;
    background: #dfe9f6;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    margin: 1rem 0 1.5rem;
}

.todo-card-head {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.todo-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.todo-list li {
    margin: 0.3rem 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
}

button.todo-link {
    background: none;
    border: none;
    color: var(--link);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.15rem 0;
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
}

button.todo-link:hover {
    color: var(--navy);
}

.todo-tag {
    background: var(--yellow);
    color: #3d2f00;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
}

/* --- Assignment type badge (Assignment vs Assessment) --- */
.type-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
    background: #eef1f4;
    color: #555;
}

.type-badge.assignment {
    background: #e3f0fc;
    color: #0b5394;
}

.type-badge.assessment {
    background: #f3e8ff;
    color: #6b21a8;
}

.format-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
    background: #e0f2f1;
    color: #00695c;
}

.cohort-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
    background: #fff3cd;
    color: #8a6d00;
}

.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 0 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.site-footer a {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--border-strong);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.site-footer a:hover {
    color: var(--text);
    border-bottom-color: var(--muted);
}

/* --- Manage Assignments (teacher/assignments.php): filter bar, one-line table with
   Edit / View panels under each row, Units panel. Each assignment is its own <tbody> (row +
   its two hidden panels), so striping goes by tbody instead of the generic tr:nth-child zebra. --- */
.muted { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
form.inline { display: inline; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
button.secondary { background: var(--muted); }
button.danger { background: #c0392b; }

.asg-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0.75rem 0 0;
}
.asg-toolbar label { font-weight: 600; font-size: 0.9rem; }
.asg-toolbar select { padding: 0.3rem; margin-left: 0.25rem; }

table.asg-table tbody tr.asg-row { background: var(--surface); }
table.asg-table tbody:nth-of-type(even) tr.asg-row { background: var(--zebra); }
table.asg-table tbody tr.asg-row:hover { background: var(--row-hover); }
table.asg-table tbody.unpublished tr.asg-row { color: var(--muted); }
table.asg-table tbody.focused tr.asg-row { box-shadow: inset 4px 0 0 var(--yellow); }
table.asg-table tbody tr.asg-panel,
table.asg-table tbody tr.asg-panel:nth-child(even) { background: #fff; }
table.asg-table td { vertical-align: middle; }
table.asg-table tbody tr.asg-panel > td { padding: 0.75rem 1rem 1rem; }

.status-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #f8e1de;
    color: #9c2a20;
    margin-left: 0.3rem;
}

/* Edit panel: a highlighted card - heading, full-width Title on its own line, then Type / Date /
   Status / Unit side by side, then Save / Cancel. */
table.asg-table tbody tr.asg-panel[data-panel="edit"] > td {
    background: #fffbea;
    border-left: 4px solid var(--yellow);
}
.asg-edit { display: flex; gap: 0.9rem 1rem; align-items: flex-end; flex-wrap: wrap; }
.asg-edit-heading { flex-basis: 100%; font-weight: 700; font-size: 1rem; }
.asg-edit label { display: flex; flex-direction: column; font-weight: 600; font-size: 0.85rem; gap: 0.3rem; }
.asg-edit label.full { flex-basis: 100%; }
.asg-edit label.grow { flex: 1; min-width: 240px; }
.asg-edit label.grow input { width: 100%; box-sizing: border-box; }
.asg-edit input, .asg-edit select { padding: 0.45rem; font-size: 0.95rem; }
.asg-edit label.full input { width: 100%; box-sizing: border-box; font-weight: 600; }
.asg-edit-buttons { display: flex; gap: 0.5rem; margin-left: auto; }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: nowrap; }

/* Manage Assignments (2026-11-13): one-click Live/Unpublished toggle per row, and a ⋯ menu that
   holds the less-used actions (Print, Chat history, Delete). */
.pub-toggle {
    min-width: 6.5rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
}
.pub-toggle.live { background: #e3f4e8; color: #1e6b3a; border-color: #b7e0c2; }
.pub-toggle.unpub { background: #f8e1de; color: #9c2a20; border-color: #f0c2bc; }
.pub-toggle:hover { filter: brightness(0.95); }

.row-menu { position: relative; display: inline-block; }
.row-menu > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.2rem 0.55rem;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    user-select: none;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--row-hover); }
.row-menu-items {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 11rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    padding: 0.3rem 0;
}
.row-menu-items a,
.row-menu-items button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
    color: inherit;
    background: none;
    border: none;
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
}
.row-menu-items a:hover,
.row-menu-items button:hover { background: var(--row-hover); }
.row-menu-items form { margin: 0; border-top: 1px solid var(--border); }
.row-menu-items button.menu-danger { color: #c0392b; font-weight: 600; }

.units-panel {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    background: var(--surface);
}
.units-panel > summary { cursor: pointer; font-weight: 700; }
table.units-table { margin: 0.5rem 0; }
table.units-table td { vertical-align: middle; }
table.units-table input[type="text"] { width: 100%; padding: 0.35rem; box-sizing: border-box; }
table.units-table input[type="number"] { width: 4.5rem; padding: 0.35rem; }

/* --- Unit notes: the note editor on teacher/units.php and the student Notes tab. --- */
textarea.note-body {
    width: 100%;
    box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 400;
    padding: 0.5rem;
}
details.note-item {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0;
}
details.note-item > summary { cursor: pointer; font-weight: 600; }
details.note-item .note-md { margin-top: 0.75rem; }
/* Notes are pasted plain text: indented lines render as code boxes, so wrap long lines inside
   them instead of a sideways scrollbar. */
.note-md pre,
.note-md pre code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* --- Agent 6 on the unit page: topic outline proposal + the Write Note panel. --- */
.status-pill.ai { background: #fff3cd; color: #8a6100; }
/* Each proposed topic is a numbered card: title + Remove on one line, the summary wrapped
   full-width under it, then its section of the notes. */
#proposalRows { counter-reset: proposal; }
.proposal-row {
    counter-increment: proposal;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
.proposal-row::before { content: counter(proposal) "."; font-weight: 700; color: var(--muted); min-width: 1.5rem; }
.proposal-row input[name="topic_title[]"] { flex: 1; min-width: 200px; padding: 0.4rem; font-weight: 700; font-size: 1rem; }
.proposal-row textarea[name="topic_summary[]"] {
    flex-basis: 100%;
    padding: 0.4rem;
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
    box-sizing: border-box;
}
.write-label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.85rem; }
.review-box {
    margin: 1rem 0 0.75rem;
    padding: 0.5rem 0.9rem;
    background: #fffbea;
    border-left: 4px solid var(--yellow);
    border-radius: 4px;
    font-size: 0.9rem;
}
.review-box ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.write-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.write-preview {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.9rem;
    max-height: 32rem;
    overflow-y: auto;
    background: var(--surface);
}
@media (max-width: 900px) {
    .write-columns { grid-template-columns: 1fr; }
}
.proposal-source { flex-basis: 100%; font-size: 0.85rem; }
.proposal-source > summary { cursor: pointer; color: var(--muted); }
.proposal-source textarea { margin-top: 0.3rem; }
