:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f3f6;
    --bg-card: #ffffff;
    --border: #d0d7de;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-muted: #6e7781;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --success: #1a7f37;
    --warning: #9a6700;
    --error: #cf222e;
    --shadow: 0 2px 8px rgba(140,149,159,0.2);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]),
    :root[data-theme="adaptive"] {
        color-scheme: light;
        --bg-primary: #f6f8fa;
        --bg-secondary: #ffffff;
        --bg-tertiary: #f0f3f6;
        --bg-card: #ffffff;
        --border: #d0d7de;
        --text-primary: #24292f;
        --text-secondary: #57606a;
        --text-muted: #6e7781;
        --accent: #0969da;
        --accent-hover: #0550ae;
        --success: #1a7f37;
        --warning: #9a6700;
        --error: #cf222e;
        --shadow: 0 2px 8px rgba(140,149,159,0.2);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.hidden { display: none !important; }

/* Auth Page */
.auth-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.theme-toggle {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Account button — same round shape as the theme toggle but logs the
   user out on click, so it picks up the danger palette on hover. */
.user-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    transition: all 0.2s;
}

#user-display:hover {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-secondary);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.text-success {
    color: var(--success);
    font-weight: 500;
}

.text-error {
    color: var(--error);
    font-weight: 500;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

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

.link-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.25rem 1.5rem;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-brand {
    font-size: 1.05rem;
    font-weight: bold;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 0 0 auto;
}

/* Layout */
.container {
    display: flex;
    min-height: 100vh;
}

.container:has(.grade-fs-page:not(.hidden)) {
    height: 100vh;
    min-height: 0;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1rem 0 0.5rem;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
    /* Pin to the viewport so the bottom toggle stays reachable on long pages. */
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
}

.sidebar.collapsed {
    width: 56px;
}

.nav-menu {
    list-style: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-bottom {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.5rem;
    border-top: 1px solid var(--border);
}

.grading-layout-controls {
    display: none;
    grid-template-columns: 1fr;
    gap: 0.3rem;
}

body.show-grading-layout-controls .grading-layout-controls {
    display: grid;
}

.submission-feedback {
    margin: 0.5rem 0;
}

.submission-feedback ul {
    margin: 0.35rem 0 0 1.25rem;
    padding: 0;
}

.submission-feedback li {
    margin: 0.25rem 0;
}

.sidebar-tool {
    width: 100%;
    min-height: 2rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    text-align: left;
}

.sidebar-tool:hover,
.sidebar-tool.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-tool-icon {
    flex: 0 0 1.1rem;
    text-align: center;
}

.sidebar-session-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
}

.nav-icon {
    flex: 0 0 auto;
    width: 1.25rem;
    text-align: center;
}

.nav-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .nav-item {
    padding: 0.75rem 0.5rem;
    justify-content: center;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .sidebar-tool {
    justify-content: center;
    padding: 0.35rem 0.25rem;
}

.sidebar.collapsed .sidebar-tool-label {
    display: none;
}

.sidebar.collapsed .sidebar-session-controls {
    flex-direction: column;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.nav-group {
    list-style: none;
}

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

.nav-subitem {
    padding: 0.4rem 1rem 0.4rem 2.6rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-subitem:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-subitem.active {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.sidebar.collapsed .nav-submenu {
    display: block;
    padding: 0.2rem 0 0.45rem;
}

.sidebar.collapsed .nav-subitem {
    padding: 0.35rem 0;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0;
}

.sidebar.collapsed .nav-subitem.active {
    border-left: 3px solid var(--accent);
}

.sidebar-toggle {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.content {
    flex: 1;
    min-width: 0;
    padding: 2rem;
    overflow-y: auto;
}

/* When the full-screen grading page is active, drop content padding and
   suppress its outer scroll so the source/PDF panes own the scroll. */
.content:has(> .grade-fs-page:not(.hidden)) {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--accent);
}

.card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.card-score {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    background: rgba(63,185,80,0.2);
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 600;
    vertical-align: middle;
}

.card-score-muted {
    background: rgba(125,133,144,0.2);
    color: var(--text-muted);
}

#assignments-calendar {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: 10px;
}

.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.cal-nav {
    display: flex;
    gap: 0.25rem;
}

.cal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cal-legend {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.cal-dow {
    background: rgba(125,133,144,0.15);
    text-align: center;
    padding: 0.4rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cal-cell {
    background: var(--bg-card);
    min-height: 88px;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cal-cell-blank {
    background: rgba(125,133,144,0.05);
}

.cal-cell-today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-day {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.cal-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-event {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event-release { background: rgba(63,185,80,0.25); color: var(--success); }
.cal-event-due { background: rgba(88,166,255,0.25); color: var(--accent); }
.cal-event-late { background: rgba(210,153,34,0.25); color: var(--warning); }
.cal-event-grade { background: rgba(187,128,255,0.25); color: #c08bff; }

.submission-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.submission-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    background: rgba(125,133,144,0.1);
    border-bottom: 1px solid var(--border);
}

.submission-group-header h4 {
    margin: 0;
    color: var(--text-primary);
    flex: 1 1 auto;
    min-width: 0;
}

.batch-progress {
    height: 8px;
    background: rgba(125,133,144,0.2);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.batch-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease;
}

.submission-group-note {
    padding: 0.4rem 0.9rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.submission-group-rows .submission-item {
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
}

.submission-group-rows .submission-item:last-child {
    border-bottom: none;
}

.cal-target-flash {
    animation: cal-flash 1.5s ease-out;
}

@keyframes cal-flash {
    0%, 100% { box-shadow: none; }
    20% { box-shadow: 0 0 0 3px var(--accent); }
}

.card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.assignment-meta {
    justify-content: flex-start;
    align-items: center;
}

.deadline-lines {
    display: inline-grid;
    grid-template-columns: max-content 1fr;
    column-gap: 0.35rem;
    row-gap: 0;
    line-height: 1.15;
}

.deadline-lines span {
    display: contents;
}

.deadline-lines strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.problem-link {
    text-decoration: none;
    color: var(--text-primary);
}

.problem-link:hover {
    color: var(--accent);
}

.instructor-notes {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border, #c8c8c8);
    border-radius: 6px;
    background: var(--surface-muted, rgba(0, 0, 0, 0.03));
    font-size: 0.85rem;
}

.instructor-notes > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
}

.instructor-notes ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.instructor-notes li + li {
    margin-top: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: rgba(63,185,80,0.2); color: var(--success); }
.badge-warning { background: rgba(210,153,34,0.2); color: var(--warning); }
.badge-error { background: rgba(248,81,73,0.2); color: var(--error); }
.badge-info { background: rgba(88,166,255,0.2); color: var(--accent); }

.badge-button {
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.badge-button:hover {
    filter: brightness(1.15);
    text-decoration: line-through;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.homework-filter-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 5.8rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.homework-filter-switch:hover,
.homework-filter-switch[data-mode="current"] {
    border-color: var(--accent);
    color: var(--accent);
}

.homework-filter-switch[data-mode="all"] {
    color: var(--text-secondary);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.submissions-page-header {
    gap: 1rem;
}

.assignment-submissions-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0.75rem;
}

.page-subtitle {
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.filter-select {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

/* Table */
.table-container {
    overflow-x: auto;
}

.assignment-submissions-table table {
    min-width: 980px;
}

.assignment-subquestions-panel {
    margin: 0.75rem 0 1rem;
}

.assignment-subquestions-table table {
    min-width: 1100px;
}

.assignment-subquestions-table th,
.assignment-subquestions-table td {
    white-space: nowrap;
}

.subquestion-max {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.2;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

tr:hover {
    background: var(--bg-tertiary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal.modal-wide {
    max-width: 1200px;
}

/* Full-viewport modal — for side-by-side document comparison, where a
   centred dialog wastes most of the screen. */
.modal.modal-fullscreen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.modal-fullscreen .modal-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    /* The dialog's roomy padding is wasted space once it fills the screen. */
    padding: 0.75rem 1rem 1rem;
    display: flex;
}

.modal.modal-fullscreen .modal-body > * {
    flex: 1;
    min-height: 0;
}

.modal.modal-fullscreen .pdf-review {
    height: 100%;
}

.modal.modal-fullscreen .pdf-review-frame,
.modal.modal-fullscreen .pdf-review-markdown,
.modal.modal-fullscreen .pdf-review-rendered {
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 1;
}

/* Grading preview view switch: student's upload vs typeset transcription. */
.grade-fs-pdf-views {
    display: inline-flex;
    gap: 0.25rem;
}

.grade-fs-pdf-views .btn.is-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* PDF → Markdown transcription review: the rendered PDF on the left, the
   Markdown that will actually be graded on the right. */
.pdf-review {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
}

.pdf-review-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pdf-review-pane h4 {
    margin: 0 0 0.5rem;
}

.pdf-review-frame {
    width: 100%;
    height: 60vh;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
}

.pdf-review-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.pdf-review-tab {
    padding: 0.35rem 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
}

.pdf-review-tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Rendered transcription — the pandoc-typeset PDF the student compares
   against their own upload. */
.pdf-review-rendered {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 44vh;
}

.pdf-review-rendered .pdf-review-frame {
    flex: 1;
    min-height: 44vh;
}

#pdf-review-render-note:empty {
    display: none;
}

.pdf-review-markdown {
    width: 100%;
    flex: 1;
    min-height: 44vh;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
}

.pdf-review-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

@media (max-width: 900px) {
    .pdf-review {
        grid-template-columns: 1fr;
    }

    .pdf-review-frame {
        height: 45vh;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.submit-method-tabs,
.signature-mode-tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
}

.submit-method-tab,
.signature-mode-tab {
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    padding: 0.55rem 0.85rem;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
}

.submit-method-tab.is-active,
.signature-mode-tab.is-active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.generated-declaration-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.declaration-generated-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.declaration-generated-grid input[readonly] {
    color: var(--text-secondary);
}

.signature-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.signature-canvas-wrap {
    width: 100%;
    aspect-ratio: 18 / 5;
    min-height: 150px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    overflow: hidden;
}

.signature-canvas-wrap canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: crosshair;
}

.signature-legal,
.legal-confirmation {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.legal-confirmation {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.typed-signature-preview {
    min-height: 4.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    font-family: "Brush Script MT", "Segoe Script", "Snell Roundhand", cursive;
    font-style: normal;
    font-weight: 400;
    font-size: 2rem;
    line-height: 1.35;
    color: var(--text-primary);
}

@media (max-width: 700px) {
    .declaration-generated-grid {
        grid-template-columns: 1fr;
    }

    .submit-method-tabs,
    .signature-mode-tabs {
        width: 100%;
    }

    .submit-method-tab,
    .signature-mode-tab {
        flex: 1;
    }
}

.grade-context {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.grade-context p {
    margin: 0.25rem 0;
}

/* Full-screen grading page */
.page-content.grade-fs-page {
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.grade-fs-header {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.grade-fs-splitter {
    display: none;
    background: var(--border);
    z-index: 3;
}

.grade-fs-splitter:hover {
    background: var(--accent);
}

.is-resizing-grade {
    cursor: col-resize;
    user-select: none;
}

.grade-fs-header-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.grade-fs-meta {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.grade-fs-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.grade-fs-score-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

.grade-fs-score-inline input[type="number"] {
    width: 4.5rem;
    padding: 0.4rem 0.5rem;
}

.grade-fs-meta strong {
    color: var(--text-primary);
}

.grade-fs-meta-line {
    line-height: 1.3;
}

.grade-fs-meta-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.grade-fs-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.grade-fs-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    width: 100%;
}

.grade-fs-field-grow {
    flex: 1 1 320px;
    min-width: 168px;
}

.grade-fs-field-label {
    font-weight: 500;
}

.grade-fs-field input[type="number"] {
    width: 90px;
}

.grade-fs-field textarea {
    width: 100%;
    min-height: 38px;
    resize: vertical;
    max-width: 100%;
}

.grade-fs-subquestions {
    flex: 1 1 100%;
    min-width: 196px;
    width: 100%;
}

.grade-fs-subquestion-editor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    align-items: start;
}

.grade-fs-subquestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    gap: 0.35rem;
    align-items: end;
}

.grade-fs-subquestion-field {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.76rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.grade-fs-subquestion-field.is-active {
    border-color: var(--accent);
    background: rgba(37, 99, 235, 0.12);
    color: var(--text-primary);
}

.grade-fs-subquestion-field span {
    white-space: nowrap;
}

.grade-fs-subquestion-field input[type="number"] {
    width: 2.8rem;
    padding: 0.25rem;
}

.grade-fs-subquestion-feedback {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.grade-fs-subquestion-feedback textarea {
    width: 100%;
    min-height: 42px;
    resize: vertical;
    max-width: 100%;
}

.grade-fs-out-of {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.grade-fs-body {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
}

.grade-layout-single .grade-fs-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "source pdf";
}

.grade-layout-single .grade-fs-preview-splitter {
    display: none;
}

.page-content.grade-fs-page.grade-layout-split,
.page-content.grade-fs-page.grade-layout-pdf-right {
    display: grid;
    grid-template-columns: minmax(0, var(--grade-main-split, 50%)) 6px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas:
        "controls main-split previews";
    overflow: hidden;
}

.page-content.grade-fs-page.grade-layout-split.grade-layout-mirror {
    grid-template-columns: minmax(0, 1fr) 6px minmax(0, var(--grade-main-split, 50%));
    grid-template-areas:
        "previews main-split controls";
}

.page-content.grade-fs-page.grade-layout-pdf-right {
    grid-template-rows: minmax(7rem, var(--grade-preview-split, 50%)) 6px minmax(7rem, 1fr);
    grid-template-areas:
        "controls main-split pdf"
        "preview-split main-split pdf"
        "source main-split pdf";
}

.page-content.grade-fs-page.grade-layout-pdf-right.grade-layout-mirror {
    grid-template-columns: minmax(0, 1fr) 6px minmax(0, var(--grade-main-split, 50%));
    grid-template-areas:
        "pdf main-split controls"
        "pdf main-split preview-split"
        "pdf main-split source";
}

.grade-layout-split .grade-fs-header,
.grade-layout-pdf-right .grade-fs-header {
    grid-area: controls;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid var(--border);
}

.grade-layout-split.grade-layout-mirror .grade-fs-header,
.grade-layout-pdf-right.grade-layout-mirror .grade-fs-header {
    border-right: none;
    border-left: 1px solid var(--border);
}

.grade-layout-split .grade-fs-form,
.grade-layout-pdf-right .grade-fs-form {
    flex: 1 1 auto;
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.grade-layout-split .grade-fs-actions,
.grade-layout-pdf-right .grade-fs-actions {
    flex: 0 0 100%;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin-left: 0;
    white-space: nowrap;
}

.grade-layout-split .grade-fs-header-row,
.grade-layout-pdf-right .grade-fs-header-row {
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.grade-layout-split .grade-fs-meta,
.grade-layout-pdf-right .grade-fs-meta {
    flex: 1 1 auto;
    min-width: 4rem;
}

.grade-layout-split .grade-fs-actions .btn,
.grade-layout-pdf-right .grade-fs-actions .btn {
    padding-inline: 0.55rem;
}

.grade-layout-split .grade-fs-score-inline,
.grade-layout-pdf-right .grade-fs-score-inline {
    gap: 0.2rem;
}

.grade-layout-split .grade-fs-score-inline input[type="number"],
.grade-layout-pdf-right .grade-fs-score-inline input[type="number"] {
    width: 3.4rem;
    padding-inline: 0.35rem;
}

.grade-layout-split .grade-fs-body {
    grid-area: previews;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(7rem, var(--grade-preview-split, 50%)) 6px minmax(7rem, 1fr);
    grid-template-areas:
        "source"
        "preview-split"
        "pdf";
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.grade-layout-pdf-right .grade-fs-body {
    display: contents;
}

.grade-layout-split .grade-fs-subquestions,
.grade-layout-pdf-right .grade-fs-subquestions {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.grade-layout-split .grade-fs-subquestion-editor,
.grade-layout-pdf-right .grade-fs-subquestion-editor {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.grade-layout-split .grade-fs-subquestion-grid,
.grade-layout-pdf-right .grade-fs-subquestion-grid {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(auto-fit, minmax(min(6rem, 100%), 1fr));
}

.grade-layout-split .grade-fs-subquestion-feedback,
.grade-layout-pdf-right .grade-fs-subquestion-feedback,
.grade-layout-split .grade-fs-field-grow,
.grade-layout-pdf-right .grade-fs-field-grow {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.grade-layout-split .grade-fs-field,
.grade-layout-pdf-right .grade-fs-field {
    min-height: 0;
}

.grade-layout-split .grade-fs-field textarea,
.grade-layout-pdf-right .grade-fs-field textarea,
.grade-layout-split .grade-fs-subquestion-feedback textarea,
.grade-layout-pdf-right .grade-fs-subquestion-feedback textarea {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.grade-layout-single .grade-fs-source-pane {
    grid-area: source;
}

.grade-layout-single .grade-fs-pdf-pane {
    grid-area: pdf;
}

.grade-layout-single.grade-layout-mirror .grade-fs-body {
    grid-template-areas: "pdf source";
}

.grade-layout-split .grade-fs-source-pane,
.grade-layout-pdf-right .grade-fs-source-pane {
    grid-area: source;
}

.grade-layout-split .grade-fs-preview-splitter,
.grade-layout-pdf-right .grade-fs-preview-splitter {
    grid-area: preview-split;
}

.grade-layout-split .grade-fs-pdf-pane,
.grade-layout-pdf-right .grade-fs-pdf-pane {
    grid-area: pdf;
}

.grade-layout-split .grade-fs-main-splitter,
.grade-layout-pdf-right .grade-fs-main-splitter {
    display: block;
    grid-area: main-split;
    cursor: col-resize;
}

.grade-layout-split .grade-fs-preview-splitter,
.grade-layout-pdf-right .grade-fs-preview-splitter {
    display: block;
    cursor: row-resize;
}

.grade-layout-split .grade-fs-source-pane,
.grade-layout-pdf-right .grade-fs-source-pane,
.grade-layout-split .grade-fs-pdf-pane,
.grade-layout-pdf-right .grade-fs-pdf-pane {
    border-right: none;
}

.grade-layout-split .grade-fs-source-pane,
.grade-layout-pdf-right .grade-fs-source-pane {
    border-bottom: none;
}

.grade-fs-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-card);
}

.grade-fs-pane:last-child {
    border-right: none;
}

.grade-layout-single .grade-fs-source-pane {
    border-right: 1px solid var(--border);
}

.grade-layout-single.grade-layout-mirror .grade-fs-source-pane {
    border-right: none;
}

.grade-layout-single.grade-layout-mirror .grade-fs-pdf-pane {
    border-right: 1px solid var(--border);
}

.grade-fs-pane-head {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.grade-fs-pane-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: var(--bg-card);
}

.grade-fs-source {
    margin: 0;
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.grade-fs-source.is-empty {
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
}

iframe.grade-fs-pane-body {
    border: 0;
    width: 100%;
    height: 100%;
}

@media (max-width: 900px) {
    .grade-layout-split .grade-fs-header,
    .grade-layout-pdf-right .grade-fs-header,
    .grade-layout-split .grade-fs-body {
        resize: none;
    }
    .grade-layout-single .grade-fs-body {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(0, 1fr);
    }
    .grade-layout-single .grade-fs-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .grade-layout-single .grade-fs-pane:last-child {
        border-bottom: none;
    }
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    color: #fff;
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Submission Item */
.submission-item {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submission-info h4 {
    margin-bottom: 0.25rem;
}

.submission-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.submission-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
    color: var(--text-primary);
}

.ai-feedback-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    line-height: 1.5;
    white-space: normal;
}

.ai-rubric-scores ul {
    margin-left: 1.25rem;
}

/* Recent Section */
.recent-section {
    margin-top: 2rem;
}

.recent-section h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Course Materials */
.course-info {
    background: var(--bg-card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.course-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* Rich materials view used by courses that ship a hand-authored block of
 * HTML (see COURSE_MATERIALS_HTML_BY_CODE in app.js). Visual identity ports
 * the original STOTCC/index.html look — section-as-card, accent-colored
 * heading rules, pill tags, schedule table — onto the SPA's theme tokens so
 * dark/light mode keep working. Spans the full grid width. */
.materials-rich {
    grid-column: 1 / -1;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Header banner sits flush across the top of the materials grid. Uses the
 * accent gradient already used elsewhere in the app for visual cohesion. */
.materials-rich-header {
    margin: 0 0 1rem;
    padding: 1.5rem 1.25rem 1.25rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
}
.materials-rich-header h2 { margin: 0 0 .35rem; font-size: 1.6rem; line-height: 1.25; color: #fff; }
.materials-rich-header p { margin: .2rem 0; color: rgba(255, 255, 255, 0.92); }
.materials-rich-header .tag { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* Each <section> renders as its own card so the long page reads like a
 * stack of boxes rather than a wall of text. The h3 gets an accent-coloured
 * left bar matching the original index.html design. */
.materials-rich section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem 1.15rem;
    margin: 0 0 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}
.materials-rich section h3 {
    margin: 0 0 .75rem;
    font-size: 1.15rem;
    line-height: 1.3;
    border-left: 4px solid var(--accent);
    padding-left: .55rem;
    color: var(--text-primary);
}
.materials-rich section p { margin: .35rem 0; }
.materials-rich section ul,
.materials-rich section ol { padding-left: 1.25rem; margin: .5rem 0; }
.materials-rich section li { margin: .15rem 0; }

.materials-rich .tag {
    display: inline-block;
    padding: .2rem .55rem;
    margin: .15rem .35rem .15rem 0;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .3px;
}
.materials-rich .materials-tags { margin-top: .6rem; }

.materials-rich .dl-list { list-style: none; padding-left: 0; }
.materials-rich .dl-list li { margin: .35rem 0; }
.materials-rich .dl-list a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.materials-rich .dl-list a:hover { text-decoration: underline; }

.materials-rich .materials-note {
    margin-top: .6rem;
    color: var(--text-muted);
    font-size: .85rem;
}
.materials-rich .materials-alert {
    margin: .75rem 0 0;
    padding: .55rem .75rem;
    background: rgba(238, 178, 64, 0.12);
    border: 1px solid rgba(238, 178, 64, 0.45);
    border-radius: 6px;
    font-size: .9rem;
    color: var(--text-primary);
}

.materials-rich .materials-schedule {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
    margin-top: .5rem;
}
.materials-rich .materials-schedule th,
.materials-rich .materials-schedule td {
    border: 1px solid var(--border);
    padding: .4rem .55rem;
    text-align: left;
    vertical-align: top;
}
.materials-rich .materials-schedule th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
}

.materials-rich-footer {
    margin: 1rem 0 0;
    padding-top: .75rem;
    color: var(--text-muted);
    font-size: .8rem;
    text-align: center;
}

@media (max-width: 700px) {
    .materials-rich-header h2 { font-size: 1.3rem; }
    .materials-rich .materials-schedule { font-size: .82rem; }
}

.materials-homework-section {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 0.5rem;
}

.section-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.section-heading-row h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.materials-homework-detail {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    width: 100%;
}

.materials-homework-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.materials-homework-copy p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.material-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.material-card:hover {
    border-color: var(--accent);
}

.material-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.material-card p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.link-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.link-list li {
    margin: 0;
}

.link-list a {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    color: #fff;
    text-decoration: none;
    font-size: 0.8rem;
    transition: opacity 0.2s;
}

.link-list a:hover {
    opacity: 0.85;
}

.slides-link {
    background: var(--accent);
}

.notes-link {
    background: var(--success);
}

/* Homework Instructions */
.hw-instructions {
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    /* Stack the sidebar on top at full width regardless of any persisted
       collapsed state from desktop. */
    .sidebar,
    .sidebar.collapsed {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        position: static;
        top: auto;
        height: auto;
        align-self: stretch;
    }

    /* Re-show labels even if .collapsed lingers from a prior desktop
       session, but keep the homework sub-list hidden — the sidebar is
       a horizontal top bar at this width and the sublist would wrap
       awkwardly. */
    .sidebar.collapsed .nav-label {
        display: inline;
    }
    .sidebar.collapsed .sidebar-tool-label {
        display: inline;
    }
    .sidebar.collapsed .nav-item {
        padding: 0.75rem 1rem;
        justify-content: flex-start;
    }
    .sidebar.collapsed .nav-submenu,
    .nav-submenu {
        display: none;
    }

    .sidebar-toggle {
        display: none;
    }

    .sidebar-bottom {
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    body.show-grading-layout-controls .grading-layout-controls {
        display: flex;
        flex: 1 1 auto;
    }

    .sidebar-session-controls,
    .sidebar.collapsed .sidebar-session-controls {
        flex-direction: row;
        flex: 0 0 auto;
    }

    .nav-menu {
        display: flex;
        overflow-x: auto;
    }

    .nav-item {
        white-space: nowrap;
        padding: 0.75rem 1rem;
    }

    .nav-item.active {
        border-left: none;
        border-bottom: 3px solid var(--accent);
    }

    .materials-homework-detail {
        align-items: flex-start;
        flex-direction: column;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}
