:root {
    --indigo: #5b5bd6;
    --indigo-dark: #4a4ac4;
    --indigo-light: #eef0ff;
    --teal: #0d9488;
    --teal-bg: #e6f7f4;
    --green: #16a34a;
    --green-bg: #e8f7ee;
    --amber: #d97706;
    --amber-bg: #fff5e6;
    --red: #dc2626;
    --red-bg: #fdeaea;
    --text: #1a1d29;
    --text-light: #626b7f;
    --text-lighter: #9aa3b5;
    --bg: #f6f7fb;
    --bg-alt: #eef0f6;
    --white: #ffffff;
    --border: #e2e6ef;
    --border-strong: #cdd3e0;
    --sidebar-bg: #171a26;
    --sidebar-text: #a4acc0;
    --sidebar-active: #ffffff;
    --sidebar-border: #262b3b;
    --code-bg: #1e2130;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 20, 35, .05), 0 4px 14px rgba(16, 20, 35, .05);
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

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

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

/* ---------------------------------------------------------------- Sidebar */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 250px;
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.4rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--white);
    font-weight: 700;
    font-size: .98rem;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.brand-icon { color: #8b8bf0; flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.nav-section {
    padding: 1rem 1.25rem .4rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #5e677e;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { color: var(--white); background: rgba(255, 255, 255, .04); }
.nav-item.active {
    color: var(--sidebar-active);
    background: rgba(139, 139, 240, .12);
    border-left-color: #8b8bf0;
}

.sidebar-footer {
    padding: .9rem 1.25rem 1.1rem;
    border-top: 1px solid var(--sidebar-border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    margin-bottom: .6rem;
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #3a3f57;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name {
    color: var(--white);
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { color: #5e677e; font-size: .72rem; text-transform: capitalize; }
.logout-link { color: #5e677e; font-size: .8rem; text-decoration: none; }
.logout-link:hover { color: var(--white); }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: .85rem; left: .85rem;
    z-index: 200;
    background: var(--sidebar-bg);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: .5rem;
    cursor: pointer;
}

/* ------------------------------------------------------------------- Main */
.main {
    margin-left: 250px;
    padding: 2rem 2.25rem 4rem;
    min-height: 100vh;
}

body.no-sidebar .main { margin-left: 0; padding: 0; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.page-head h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.page-head .subtitle { color: var(--text-light); font-size: .95rem; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.breadcrumb {
    font-size: .85rem;
    color: var(--text-light);
    margin-bottom: .35rem;
}
.breadcrumb a { color: var(--text-light); text-decoration: none; }
.breadcrumb a:hover { color: var(--indigo); text-decoration: underline; }

/* ------------------------------------------------------------------ Cards */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem;
    margin-bottom: 1.25rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-head h2 { font-size: 1.05rem; letter-spacing: -.01em; }
.card-head h3 { font-size: .95rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.stat-label { color: var(--text-light); font-size: .82rem; font-weight: 500; }

/* --------------------------------------------------------------- Controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary { background: var(--indigo); color: var(--white); }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-success { background: var(--green); color: var(--white); }
.btn-success:hover { filter: brightness(.93); }
.btn-secondary {
    background: var(--white);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-alt); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; color: var(--text-light); padding: .35rem .5rem; }
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
}

.hint { font-size: .8rem; color: var(--text-light); font-weight: 400; margin-top: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-family: inherit;
    font-size: .92rem;
    color: var(--text);
    background: var(--white);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(91, 91, 214, .12);
}

textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
textarea.code, input.code { font-family: var(--mono); font-size: .84rem; }

.checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 500;
}
.checkbox input { width: auto; }

.form-actions {
    display: flex;
    gap: .6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.inline-form { display: inline; }
.hidden { display: none; }

/* ------------------------------------------------------------------ Flash */
.flash-stack { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: .6rem; }

.flash {
    padding: .7rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.flash-success { background: var(--green-bg); color: #14532d; border-color: #b6e3c8; }
.flash-danger  { background: var(--red-bg);   color: #7f1d1d; border-color: #f3c2c2; }
.flash-warning { background: var(--amber-bg); color: #78350f; border-color: #f3d9ac; }
.flash-info    { background: var(--indigo-light); color: #2e2e73; border-color: #cdd0f7; }

body.no-sidebar .flash-stack {
    max-width: 420px;
    margin: 1.5rem auto -0.5rem;
    padding: 0 1rem;
}

/* ------------------------------------------------------------------ Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .16rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: uppercase;
}
.badge-green  { background: var(--green-bg);  color: #15803d; }
.badge-amber  { background: var(--amber-bg);  color: #b45309; }
.badge-indigo { background: var(--indigo-light); color: #4338ca; }
.badge-teal   { background: var(--teal-bg);   color: #0f766e; }
.badge-gray   { background: var(--bg-alt);    color: var(--text-light); }
.badge-red    { background: var(--red-bg);    color: #b91c1c; }

.code-pill {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .12em;
    background: var(--bg-alt);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    padding: .3rem .7rem;
    display: inline-block;
}

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

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

th {
    text-align: left;
    padding: .6rem .75rem;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td { padding: .7rem .75rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ------------------------------------------------------------- Empty state */
.empty {
    text-align: center;
    padding: 2.75rem 1.5rem;
    color: var(--text-light);
}
.empty svg { color: var(--text-lighter); margin-bottom: .75rem; }
.empty h3 { font-size: 1rem; color: var(--text); margin-bottom: .3rem; }
.empty p { font-size: .9rem; margin-bottom: 1rem; }

/* ---------------------------------------------------------------- Progress */
.progress {
    height: 7px;
    background: var(--bg-alt);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar { height: 100%; background: var(--indigo); border-radius: 999px; }
.progress-bar.done { background: var(--green); }

/* ------------------------------------------------------- Course / outline */
.course-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.course-card h3 { font-size: 1.05rem; letter-spacing: -.01em; }
.course-card .desc { color: var(--text-light); font-size: .88rem; flex: 1; }
.course-meta {
    display: flex;
    gap: 1rem;
    font-size: .8rem;
    color: var(--text-light);
    flex-wrap: wrap;
}

.module {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}

.module-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem 1.1rem;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}
.module-head h3 { font-size: .98rem; flex: 1; }
.module-head .desc { font-size: .82rem; color: var(--text-light); font-weight: 400; }

.lesson-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .75rem 1.1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row:hover { background: var(--bg); }
.lesson-title { flex: 1; font-weight: 500; font-size: .92rem; }
.lesson-sub { font-size: .78rem; color: var(--text-light); font-weight: 400; }

.lesson-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.lesson-icon svg { width: 16px; height: 16px; }
.lesson-row.locked { cursor: not-allowed; }
.lesson-row.locked:hover { background: transparent; }
.lesson-row.locked .lesson-title,
.lesson-row.locked .lesson-sub { color: var(--text-lighter); }

.lesson-icon.locked { background: var(--bg-alt); color: var(--text-lighter); }
.lesson-icon.reading  { background: var(--teal-bg);   color: var(--teal); }
.lesson-icon.exercise { background: var(--indigo-light); color: var(--indigo); }
.lesson-icon.complete { background: var(--green-bg);  color: var(--green); }

.row-actions { display: flex; gap: .25rem; align-items: center; }

/* ----------------------------------------------------------------- Lesson */
.lesson-layout { max-width: 820px; }

.lesson-body { font-size: .97rem; line-height: 1.75; }
.lesson-body h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; letter-spacing: -.015em; }
.lesson-body h3 { font-size: 1.08rem; margin: 1.25rem 0 .4rem; }
.lesson-body h4, .lesson-body h5 { font-size: .98rem; margin: 1rem 0 .3rem; }
.lesson-body p { margin-bottom: .85rem; }
.lesson-body ul, .lesson-body ol { margin: 0 0 .9rem 1.35rem; }
.lesson-body li { margin-bottom: .3rem; }
.lesson-body code {
    font-family: var(--mono);
    font-size: .85em;
    background: var(--bg-alt);
    padding: .1rem .35rem;
    border-radius: 5px;
}
.lesson-body pre.lesson-code {
    background: var(--code-bg);
    color: #e4e7f2;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1rem;
}
.lesson-body pre.lesson-code code {
    background: none;
    padding: 0;
    font-size: .84rem;
    line-height: 1.6;
}

.lesson-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ------------------------------------------------------------ Code editor */
body.editor-page { overflow: hidden; }
body.editor-page .main { padding: 0; height: 100vh; display: flex; flex-direction: column; }
body.editor-page .flash-stack {
    margin: .75rem 1rem 0;
    position: absolute;
    top: 3.5rem; right: 1rem;
    z-index: 50;
    max-width: 380px;
}

.ide-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .7rem 1.1rem;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ide-title { min-width: 0; }
.ide-title h1 {
    font-size: 1rem;
    letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ide-title .crumbs { font-size: .76rem; color: var(--text-light); }
.ide-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.save-state { font-size: .78rem; color: var(--text-lighter); min-width: 70px; }

.ide {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.15fr) minmax(300px, 1.1fr);
    min-height: 0;
}

.ide-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--white);
}
.ide-pane:last-child { border-right: none; }

.pane-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
    flex-shrink: 0;
}
.pane-head .spacer { margin-left: auto; }

.instructions-pane { overflow-y: auto; padding: 0; }
.instructions-body { padding: 1.1rem; }

.tabs { display: flex; gap: .2rem; }
.tab {
    padding: .3rem .7rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-light);
    border-radius: 6px;
    cursor: pointer;
}
.tab:hover { background: rgba(0, 0, 0, .05); }
.tab.active { background: var(--indigo); color: var(--white); }

.editor-stack { flex: 1; position: relative; min-height: 0; background: var(--code-bg); }

.editor-slot { position: absolute; inset: 0; display: none; }
.editor-slot.active { display: block; }

.editor-slot textarea {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background: var(--code-bg);
    color: #e4e7f2;
    font-family: var(--mono);
    font-size: .85rem;
    line-height: 1.65;
    padding: .9rem 1rem;
    resize: none;
    tab-size: 2;
    white-space: pre;
    overflow: auto;
}
.editor-slot textarea:focus { outline: none; box-shadow: none; }

.preview-frame {
    flex: 1;
    border: none;
    background: var(--white);
    min-height: 0;
    width: 100%;
}

.console {
    height: 150px;
    background: var(--code-bg);
    color: #cfd4e4;
    font-family: var(--mono);
    font-size: .78rem;
    line-height: 1.6;
    overflow-y: auto;
    padding: .5rem .8rem;
    flex-shrink: 0;
    border-top: 1px solid #2c3145;
}
.console-line { white-space: pre-wrap; word-break: break-word; padding: .05rem 0; }
.console-line.error { color: #ff8f8f; }
.console-line.warn { color: #f5c26b; }
.console-line.muted { color: #6d7590; }

.test-results { border-top: 1px solid var(--border); flex-shrink: 0; max-height: 190px; overflow-y: auto; }
.test-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .4rem .85rem;
    font-size: .82rem;
    border-bottom: 1px solid var(--border);
}
.test-item:last-child { border-bottom: none; }
.test-item .mark { font-weight: 700; flex-shrink: 0; }
.test-item.pass .mark { color: var(--green); }
.test-item.fail .mark { color: var(--red); }
.test-item.submit-blocked {
    background: var(--amber-bg);
    font-weight: 600;
}
.test-item.submit-blocked .mark { color: var(--amber); }

.karel-cheatsheet {
    margin-top: 1.5rem;
    padding: .9rem 1rem;
    background: var(--bg-alt);
    border-radius: var(--radius);
    font-size: .85rem;
}
.karel-cheatsheet strong { display: block; margin-bottom: .3rem; font-size: .8rem; }
.karel-cheatsheet strong ~ strong { margin-top: .75rem; }
.karel-cheatsheet ul { margin: 0 0 0 1.1rem; }
.karel-cheatsheet li { margin-bottom: .15rem; }
.karel-cheatsheet code { font-size: .82em; }

.lesson-icon.karel { background: #fff1e0; color: #c2731f; }
.lesson-icon.written { background: #efe9f7; color: #6d4aa3; }

.written-response {
    width: 100%;
    min-height: 300px;
    font-family: 'Public Sans', system-ui, sans-serif;
    font-size: .97rem;
    line-height: 1.7;
    padding: 1rem 1.1rem;
}

/* --------------------------------------------------------------- Gradebook */
.gradebook-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.gradebook { font-size: .85rem; }
.gradebook th, .gradebook td { border-right: 1px solid var(--border); }
.gradebook th.rotate {
    height: 130px;
    padding: .35rem;
    width: 42px;
    vertical-align: bottom;
}
.gradebook th.rotate > div {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    max-height: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .72rem;
    text-transform: none;
    letter-spacing: 0;
    margin: 0 auto;
}
.gradebook td.cell { text-align: center; padding: .35rem; }
.gradebook .student-col, .gradebook th.student-col {
    position: sticky;
    left: 0;
    background: var(--white);
    z-index: 2;
    min-width: 180px;
}
.gradebook thead th.student-col { background: var(--bg-alt); z-index: 3; }
.gradebook tbody tr:hover .student-col { background: var(--bg); }

.cell-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: .15rem .35rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: .8rem;
    text-decoration: none;
}
.cell-graded  { background: var(--green-bg);  color: #15803d; }
.cell-partial { background: var(--amber-bg);  color: #b45309; }
.cell-pending { background: var(--indigo-light); color: #4338ca; }
.cell-empty   { color: var(--text-lighter); }
.total-col { font-weight: 700; background: var(--bg-alt); }

/* ------------------------------------------------------------------- Auth */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1000px 500px at 50% -10%, #e8eaff 0%, transparent 60%),
        var(--bg);
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}
.auth-card h1 { font-size: 1.4rem; letter-spacing: -.02em; margin-bottom: .3rem; }
.auth-card .subtitle { color: var(--text-light); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-alt { text-align: center; margin-top: 1.25rem; font-size: .88rem; color: var(--text-light); }

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: var(--indigo);
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 1.25rem;
}

/* ---------------------------------------------------------------- Landing */
.hero {
    padding: 5rem 1.5rem 4rem;
    text-align: center;
    background:
        radial-gradient(900px 450px at 50% -5%, #e8eaff 0%, transparent 65%),
        var(--bg);
}
.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    letter-spacing: -.035em;
    line-height: 1.15;
    max-width: 700px;
    margin: 0 auto 1rem;
}
.hero p {
    color: var(--text-light);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto 1.75rem;
}
.hero-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.landing-section { max-width: 1000px; margin: 0 auto; padding: 3rem 1.5rem 4rem; }
.landing-section h2 { font-size: 1.4rem; letter-spacing: -.02em; margin-bottom: 1.25rem; }

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-lighter);
    font-size: .85rem;
}

/* ------------------------------------------------------------ Error page */
.error-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; }
.error-wrap .code { font-size: 3.5rem; font-weight: 700; color: var(--text-lighter); letter-spacing: -.04em; }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1100px) {
    .ide { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
    .ide-pane.instructions-pane { grid-column: 1 / -1; max-height: 220px; }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main { margin-left: 0; padding: 3.5rem 1rem 3rem; }
    .form-row { grid-template-columns: 1fr; }
    .ide { grid-template-columns: 1fr; grid-template-rows: auto minmax(280px, 1fr) minmax(280px, 1fr); }
    .ide-pane.instructions-pane { max-height: 200px; }
    body.editor-page { overflow: auto; }
    body.editor-page .main { height: auto; }
}

.written-submission {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: .95rem;
    line-height: 1.7;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    max-height: 560px;
    overflow-y: auto;
}

/* Read-only assignment brief, shown above the student's response box. */
.assignment-brief {
    background: var(--indigo-light);
    border: 1px solid #cdd0f7;
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1.1rem;
}
.assignment-brief-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #4338ca;
    margin-bottom: .5rem;
}
.assignment-brief .lesson-body { font-size: .93rem; }
.assignment-brief .lesson-body h2 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.assignment-brief .lesson-body h2:first-child { margin-top: 0; }
.assignment-brief .lesson-body h3 { font-size: .95rem; }
.assignment-brief .lesson-body code { background: rgba(255, 255, 255, .75); }
.assignment-brief .lesson-body pre.lesson-code { font-size: .8rem; }

/* ---------------------------------- Two-column lesson (written assignments) */
.split-layout { max-width: 1280px; }

.split-columns {
    display: grid;
    /* Reading column gets the extra width; the response box needs less. */
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;   /* each column sizes to its own content */
}

.split-col-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-light);
    padding-bottom: .6rem;
    margin-bottom: .9rem;
    border-bottom: 1px solid var(--border);
}

.split-col-read .card,
.split-col-work .card:last-child { margin-bottom: 0; }
.split-col-read .lesson-body { font-size: .95rem; }

/* Stack below laptop width: reading first, then the work. */
@media (max-width: 1050px) {
    .split-columns { grid-template-columns: 1fr; gap: 1.25rem; }
    .split-col-read .card { margin-bottom: 1.25rem; }
}
