:root {
    --bg-0: #f7f8fc;
    --bg-1: #eef2ff;
    --bg-2: #e6f0ff;
    --surface: #ffffff;
    --surface-soft: #f9fbff;
    --text-strong: #111827;
    --text-body: #374151;
    --text-muted: #6b7280;
    --primary: #0D9488;
    --primary-strong: #0B7A6E;
    --accent: #22C55E;
    --danger: #d14343;
    --border: #e3e8f6;
    --shadow: 0 12px 30px rgba(38, 70, 172, 0.12);
    --radius-lg: 20px;
    --radius-md: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Plus Jakarta Sans", "Segoe UI", Tahoma, sans-serif;
    color: var(--text-strong);
    background:
        radial-gradient(1200px 600px at -20% -15%, #ccfbf1 0%, transparent 65%),
        radial-gradient(900px 450px at 115% 20%, #dcfce7 0%, transparent 60%),
        linear-gradient(180deg, var(--bg-0), #ffffff 45%);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.auth-minimal-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.auth-minimal-header {
    height: 76px;
    border-bottom: 1px solid #dfe5f1;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(6px);
}

.auth-minimal-header .role-shell {
    padding-top: 0;
    padding-bottom: 0;
    height: 100%;
    display: flex;
    align-items: center;
}

.brand-logo-text {
    font-size: 34px;
    line-height: 1;
}

.brand-logo-word {
    margin-left: 8px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #0B5E57;
}

.auth-minimal-wrap {
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.auth-minimal-card {
    width: min(440px, 100%);
    background: transparent;
}

.auth-minimal-card h1 {
    margin: 0 0 8px;
    font-size: 40px;
    color: #2b3e91;
    line-height: 1.1;
}

.auth-utility-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0 16px;
    gap: 10px;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #32427d;
}

.check-inline input {
    width: 16px;
    height: 16px;
}

.auth-helper {
    margin-top: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-helper a {
    font-weight: 700;
}

.auth-card {
    width: min(980px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}

.auth-brand {
    padding: 42px;
    background: linear-gradient(155deg, #eff3ff 0%, #f8fbff 62%, #fff3e8 100%);
    border-right: 1px solid var(--border);
}

.brand-kicker {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary-strong);
    background: #e3e9ff;
    border-radius: 999px;
    padding: 6px 10px;
}

.auth-brand h1 {
    margin: 16px 0 12px;
    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.1;
}

.auth-brand p {
    margin: 0;
    color: var(--text-body);
    line-height: 1.65;
}

.feature-list {
    margin-top: 24px;
    display: grid;
    gap: 12px;
}

.feature-chip {
    padding: 10px 12px;
    background: rgba(50, 87, 255, 0.08);
    color: #1f3aa0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
}

.auth-form {
    padding: 42px;
    background: var(--surface);
}

.auth-form h2 {
    margin: 0 0 8px;
    font-size: 28px;
}

.subtle {
    margin: 0 0 24px;
    color: var(--text-muted);
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-body);
}

.field input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text-strong);
    outline: none;
}

.field input:focus {
    border-color: #8aa2ff;
    box-shadow: 0 0 0 3px rgba(50, 87, 255, 0.15);
}

.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text-strong);
    outline: none;
    resize: vertical;
}

.field textarea:focus {
    border-color: #8aa2ff;
    box-shadow: 0 0 0 3px rgba(50, 87, 255, 0.15);
}

.mini-select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-strong);
}

.btn-primary {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #3f7dff);
    cursor: pointer;
}

.btn-primary:hover { background: linear-gradient(135deg, var(--primary-strong), #0D9488); }

.status {
    margin-top: 14px;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    display: none;
}

.status.success { display: block; background: #e7fff8; color: #0d8a70; }
.status.error { display: block; background: #ffecee; color: #b52b3f; }

.role-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 26px 18px 40px;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    color: #1a2d6e;
}

.nav-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pill {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #2c46b2;
    background: #e9eeff;
    border-radius: 999px;
    padding: 6px 10px;
}

.link-btn {
    text-decoration: none;
    color: #3750af;
    font-weight: 700;
    transition: color 0.2s ease;
}

.link-btn:hover {
    color: #243b96;
}

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

.grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 22px rgba(38, 70, 172, 0.08);
    padding: 16px;
}

.card h3 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0; color: var(--text-body); line-height: 1.6; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #1f3aa0;
    background: #e8eeff;
    border-radius: 999px;
    padding: 4px 8px;
}

.pre-box {
    border: 1px solid var(--border);
    background: #fbfcff;
    border-radius: 12px;
    padding: 12px;
    max-height: 60vh;
    overflow: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card { padding: 14px; }
.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}
.stat-value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 800;
    color: #213a9a;
}

.bars { display: grid; gap: 8px; margin-top: 10px; }
.bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    gap: 10px;
    align-items: center;
}
.bar-label { font-size: 12px; color: var(--text-muted); }
.bar-wrap {
    background: #edf1ff;
    border-radius: 999px;
    overflow: hidden;
    height: 10px;
}
.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3f61ff, #f97316);
}
.bar-progress {
    width: 100%;
    height: 12px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: #edf1ff;
}

.bar-progress::-webkit-progress-bar {
    background: #edf1ff;
    border-radius: 999px;
}

.bar-progress::-webkit-progress-value {
    background: linear-gradient(90deg, #3f61ff, #f97316);
    border-radius: 999px;
}

.bar-progress::-moz-progress-bar {
    background: linear-gradient(90deg, #3f61ff, #f97316);
    border-radius: 999px;
}
.bar-value {
    text-align: right;
    font-size: 12px;
    color: var(--text-body);
    font-weight: 700;
}

.simple-list {
    margin: 10px 0 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
}

.section-stack {
    display: grid;
    gap: 16px;
}

.section-gap {
    margin-top: 16px;
}

.task-summary {
    background: linear-gradient(145deg, #f6f9ff 0%, #fcfffe 100%);
    border: 1px solid #dde5ff;
}

.muted-note {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.btn-row {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-row .btn-primary {
    width: auto;
}

.grid-2 {
    display: grid;
    gap: 16px;
    grid-template-columns: 1.25fr 1fr;
}

.editor-shell {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.mini-btn {
    border: 1px solid var(--border);
    background: #f6f8ff;
    color: #30439b;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: 700;
}

.mini-btn:hover {
    background: #edf2ff;
}

.editor {
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    line-height: 1.6;
}

.workspace-split {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.role-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.48fr);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 22px;
}

.welcome-card {
    background: linear-gradient(115deg, #f5fbff 0%, #eef5ff 55%, #fff3e8 100%);
    border: 1px solid #d8e6fb;
}

.welcome-card h2 {
    margin: 0;
    font-size: 38px;
    line-height: 1.16;
    color: #253c93;
}

.welcome-card h2 .lead {
    color: #f97316;
}

.usage-card {
    background: linear-gradient(135deg, #22C55E 0%, #16A34A 50%, #0D9488 100%);
    color: #fff;
    border: 0;
}

.usage-card h3 {
    margin: 0 0 4px;
    color: #fff;
    font-size: 30px;
}

.usage-subline {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    opacity: 0.95;
}

.usage-progress-track {
    margin-top: 12px;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.30);
    overflow: hidden;
}

.usage-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: #ffffff;
}

.usage-progress {
    margin-top: 12px;
    width: 100%;
    height: 8px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.30);
}

.usage-progress::-webkit-progress-bar {
    background: rgba(255, 255, 255, 0.30);
    border-radius: 999px;
}

.usage-progress::-webkit-progress-value {
    background: #ffffff;
    border-radius: 999px;
}

.usage-progress::-moz-progress-bar {
    background: #ffffff;
    border-radius: 999px;
}

.classes-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.classes-head h3 {
    margin: 0;
    font-size: 30px;
    color: #243b97;
}

.classes-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4a5fa5;
    font-weight: 700;
    font-size: 14px;
}

.search-input {
    min-width: 240px;
    border: 1px solid #d6e0f8;
    border-radius: 12px;
    background: #f8fbff;
    padding: 10px 12px;
    font-size: 14px;
}

.class-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.class-card {
    min-height: 250px;
    box-shadow:
        0 4px 6px rgba(38, 70, 172, 0.07),
        0 12px 32px rgba(38, 70, 172, 0.14),
        0 24px 64px rgba(38, 70, 172, 0.10);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.class-card:hover {
    box-shadow:
        0 6px 12px rgba(38, 70, 172, 0.10),
        0 20px 48px rgba(38, 70, 172, 0.20),
        0 40px 80px rgba(38, 70, 172, 0.13);
    transform: translateY(-4px);
}

.class-meta {
    margin-top: 10px;
    display: grid;
    gap: 6px;
    color: #3f5090;
    font-size: 14px;
}

.class-meta .state {
    color: #0e9f5f;
    font-weight: 800;
}

.class-stats {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: #f4f7ff;
    border: 1px solid #e0e8ff;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}

.class-stats .label {
    font-size: 12px;
    color: #6374ad;
    font-weight: 700;
}

.class-stats .value {
    margin-top: 4px;
    font-size: 28px;
    font-weight: 800;
    color: #2c3f93;
}

.class-links {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.create-class-card {
    display: grid;
    place-items: center;
    text-align: center;
    background: #f7f9ff;
    border: 1px dashed #cad6fa;
}

.create-class-card .plus {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 40px;
    color: #2f4397;
    background: #eef2ff;
}

.create-class-card p {
    margin-top: 14px;
    font-size: 20px;
    color: #2f4397;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
}

.action-list {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
}

.action-list a {
    display: inline-block;
}

.dashboard-actions {
    margin-top: 10px;
}

.empty-state {
    padding: 14px;
    border-radius: 12px;
    background: #f7f9ff;
    border: 1px dashed #d6def7;
    color: var(--text-muted);
}

.is-hidden {
    display: none !important;
}

@media (max-width: 980px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .bar-row { grid-template-columns: 90px 1fr 34px; }
    .workspace-split,
    .grid-2,
    .role-hero,
    .class-grid { grid-template-columns: 1fr; }
    .classes-head {
        flex-direction: column;
        align-items: flex-start;
    }
    .search-input {
        min-width: 0;
        width: 100%;
    }
    .auth-minimal-card h1 {
        font-size: 32px;
    }
}

@media (max-width: 980px) {
    .auth-card { grid-template-columns: 1fr; }
    .auth-brand { border-right: 0; border-bottom: 1px solid var(--border); }
    .grid { grid-template-columns: 1fr; }
    .grid-two { grid-template-columns: 1fr; }
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 24, 64, 0.52);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    z-index: 900;
    padding: 18px;
}

.modal-overlay.is-hidden {
    display: none !important;
}

.modal-box {
    width: min(480px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(20, 40, 120, 0.20);
    padding: 30px 28px 24px;
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f2f4fb;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    color: #4a5fa0;
    font-size: 18px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    line-height: 1;
}

.modal-close:hover { background: #eaeeff; }

.modal-box h2 {
    margin: 0 0 6px;
    font-size: 26px;
    color: #253c93;
}

.modal-status {
    margin-top: 10px;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    display: none;
}

.modal-status.success { display: block; background: #e7fff8; color: #0d8a70; }
.modal-status.error   { display: block; background: #ffecee; color: #b52b3f; }

/* ── Image upload widget ─────────────────────────────────────── */
.img-upload-wrap {
    position: relative;
    border: 2px dashed #d0d9f7;
    border-radius: 14px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s;
}
.img-upload-wrap:hover { border-color: #f97316; }
.img-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.img-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}
.img-upload-icon { font-size: 28px; }
.img-preview {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

/* ── Class card link ─────────────────────────────────────────── */
.class-card-link {
    text-decoration: none;
    color: inherit;
}
.class-card-link h3 {
    margin: 0 0 0;
    color: #1a2d6e;
    transition: color 0.2s;
}
.class-card-link:hover h3 { color: #f97316; }

/* ── Class detail page ───────────────────────────────────────── */
.class-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.class-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.class-detail-title {
    margin: 0;
    font-size: clamp(26px, 4vw, 40px);
    color: #1a2d6e;
    font-weight: 900;
    line-height: 1.1;
}

.class-code-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #eef2ff;
    color: #2c46b2;
    border: 1px solid #d0d9f7;
    border-radius: 999px;
    padding: 5px 14px;
}

.class-detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.btn-manage-students {
    display: inline-block;
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    background: #f97316;
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn-manage-students:hover { background: #ea580c; color: #fff; }

.btn-forum {
    display: inline-block;
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    background: #1a2d6e;
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn-forum:hover { background: #253c93; color: #fff; }

.class-task-section { margin-top: 0; }

.task-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.task-toolbar h3 {
    margin: 0;
    font-size: 22px;
    color: #1a2d6e;
}

.task-toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-create-task {
    padding: 9px 18px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    background: #f97316;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn-create-task:hover { background: #ea580c; }

.btn-shared-tasks {
    padding: 9px 18px;
    border-radius: 12px;
    border: 1.5px solid #d0d9f7;
    font-size: 14px;
    font-weight: 700;
    background: #f7f9ff;
    color: #2c46b2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}
.btn-shared-tasks:hover { background: #eef2ff; border-color: #b0bef7; }

.task-action-btns {
    display: flex;
    gap: 10px;
}

.class-empty-state {
    padding: 36px 20px;
    text-align: center;
    background: #f7f9ff;
    border: 1px dashed #d0d9f7;
    border-radius: 14px;
    color: var(--text-muted);
}

.class-empty-state .class-empty-icon {
    font-size: 42px;
    margin-bottom: 10px;
}

.class-empty-state p {
    margin: 6px 0 0;
    font-size: 15px;
    font-weight: 600;
}

@media (max-width: 780px) {
    .class-detail-header { flex-direction: column; }
    .task-toolbar { flex-direction: column; align-items: flex-start; }
    .task-toolbar-actions { width: 100%; }
    .search-input { width: 100%; min-width: 0; }
}

/* ── Student dashboard hero ─────────────────────────────────── */
.student-hero {
    margin-bottom: 22px;
}

.student-welcome-card {
    background: linear-gradient(115deg, #f5fbff 0%, #eef5ff 60%, #fff3e8 100%);
    border: 1px solid #d8e6fb;
}

.student-welcome-card h2 {
    margin: 0 0 8px;
    font-size: 28px;
    color: #253c93;
    line-height: 1.2;
}

.student-welcome-card h2 .lead { color: #f97316; }

.phase-progress-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 14px;
}

.phase-stat {
    background: #f7f9ff;
    border: 1px solid #dde5ff;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.phase-stat .phase-label {
    font-size: 11px;
    font-weight: 700;
    color: #6374ad;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.phase-stat .phase-value {
    margin-top: 6px;
    font-size: 14px;
    font-weight: 800;
    color: #2c3f93;
}

.phase-stat.phase-done .phase-value   { color: #0e9f5f; }
.phase-stat.phase-pending .phase-value { color: #e07d00; }
.phase-stat.phase-locked .phase-value  { color: var(--text-muted); }

/* ── Admin dashboard hero ────────────────────────────────────── */
.admin-welcome-card {
    background: linear-gradient(115deg, #f5f0ff 0%, #f0f5ff 60%, #eaf8ff 100%);
    border: 1px solid #d8d0fb;
    margin-bottom: 22px;
}

.admin-welcome-card h2 {
    margin: 0 0 6px;
    font-size: 28px;
    color: #3c2893;
}

.admin-welcome-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
}

@media (max-width: 700px) {
    .phase-progress-grid { grid-template-columns: 1fr; }
    .modal-box { padding: 22px 16px 18px; }
}

/* ══════════════════════════════════════════════════════════════
   TASK LIST – updated columns (no Status column)
══════════════════════════════════════════════════════════════ */
.task-total-label {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 10px;
    font-weight: 600;
}

.task-name-icon { margin-right: 6px; }

.due-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    padding: 2px 10px;
}
.due-upcoming { background: #fff3e0; color: #c05600; }
.due-overdue  { background: #ffecee; color: #b52b3f; }

.btn-view-submissions {
    background: #1e3a8a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn-view-submissions:hover { background: #1e40af; }

.btn-task-menu {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #4a5fa0;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
}
.btn-task-menu:hover { background: #eaeeff; }

.task-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: #fff;
    border: 1px solid #dde4f7;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(30,58,138,0.13);
    min-width: 110px;
    z-index: 200;
}
.task-dropdown a,
.task-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 16px;
    font-size: 13px;
    color: #253c93;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.task-dropdown a:hover,
.task-dropdown button:hover { background: #f0f4ff; }
.task-dropdown button.task-menu-danger { color: #dc2626; }
.task-dropdown button.task-menu-danger:hover { background: #fff5f5; }
.task-action-btns { display: flex; align-items: center; gap: 6px; position: relative; }

/* ── Task prompt body (student pages) ──────────────── */
.task-prompt-body {
    background: var(--bg-1);
    border-left: 4px solid var(--primary);
    border-radius: 0 10px 10px 0;
    padding: 14px 18px;
    margin-top: 10px;
    line-height: 1.7;
}
.task-prompt-body p {
    margin: 0 0 6px;
    color: var(--text-body);
    line-height: 1.7;
}
.task-prompt-body p:last-child { margin-bottom: 0; }
.task-prompt-body p:empty { display: none; }
.task-prompt-body strong,
.task-prompt-body b {
    color: var(--primary-strong);
}
.task-prompt-body em,
.task-prompt-body i {
    color: var(--text-body);
    font-style: italic;
}

/* ── Task prompt image placeholder (student pages) ──────────────── */
.task-prompt-img-placeholder {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    margin: 12px 0;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 14px;
    background: #f8fafc;
}
.task-prompt-img-placeholder i { font-size: 22px; flex-shrink: 0; }
/* Teacher task-image badge */
.task-img-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #0D9488;
    background: #eef1ff;
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════════
   3-STEP WIZARD MODAL
══════════════════════════════════════════════════════════════ */
.modal-box--wide {
    width: min(620px, 100%);
}

/* Progress bar */
.wizard-progress-wrap {
    position: relative;
    background: #e5e9f7;
    border-radius: 20px;
    height: 12px;
    margin-bottom: 22px;
    overflow: hidden;
}
.wizard-progress-bar {
    height: 100%;
    background: #1e3a8a;
    border-radius: 20px;
    transition: width 0.35s ease;
}
.wizard-progress-pct {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 800;
    color: #4a5fa0;
    line-height: 1;
}

/* Step visibility */
.wizard-step { padding: 0; }
.wizard-step.is-hidden { display: none !important; }

/* Field helpers */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.optional-lbl {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}
.req { color: #d14343; }
.char-counter {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 3px;
}

/* Quill overrides */
.quill-editor-wrap {
    border-radius: 10px;
    overflow: hidden;
}
.ql-toolbar.ql-snow { border-radius: 10px 10px 0 0; border-color: #d0d9f7; }
.ql-container.ql-snow { border-radius: 0 0 10px 10px; border-color: #d0d9f7; min-height: 140px; }

/* Navigation row */
.wizard-nav {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}
.wizard-nav--split {
    justify-content: space-between;
    gap: 12px;
}
.wizard-nav--split .btn-secondary,
.wizard-nav--split .btn-primary {
    flex: 1;
    width: auto;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
}
.btn-secondary {
    background: #f3f4f8;
    border: 1px solid #d0d9f7;
    border-radius: 10px;
    padding: 10px 26px;
    font-size: 15px;
    font-weight: 600;
    color: #4a5fa0;
    cursor: pointer;
}
.btn-secondary:hover { background: #e8ecf7; }

/* Wizard status message */
.wizard-status {
    margin-top: 8px;
    font-size: 13px;
    min-height: 18px;
}
.wizard-status.error   { color: #b52b3f; }
.wizard-status.success { color: #0d8a70; }

/* AI tools grid */
.ai-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.ai-tool-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f9ff;
    border: 1px solid #dde5ff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #253c93;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-tool-card:hover { background: #eef2ff; }
.ai-tool-card input[type="checkbox"] {
    accent-color: #1e3a8a;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* AI Writing Assistant Setup (Item 4) */
.ai-setup-section {
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}
.ai-setup-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #1e3a8a;
    margin-bottom: 8px;
}
.ai-other-input {
    margin-top: 8px;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #dde5ff;
    border-radius: 8px;
    font-size: 13px;
    color: #334155;
    background: #fff;
    box-sizing: border-box;
}
.ai-other-input:focus { outline: none; border-color: #0D9488; box-shadow: 0 0 0 3px rgba(13,148,136,.12); }

/* Upload row */
.upload-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.btn-upload-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1.5px solid #d0d9f7;
    border-radius: 10px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #253c93;
    cursor: pointer;
    white-space: nowrap;
}
.btn-upload-file:hover { background: #eef2ff; }
.upload-hint { font-size: 12px; color: var(--text-muted); }
.upload-status-msg { font-size: 13px; margin-top: 6px; }
.upload-status-msg.info    { color: #1e3a8a; }
.upload-status-msg.success { color: #0d8a70; }
.upload-status-msg.error   { color: #b52b3f; }

@media (max-width: 640px) {
    .field-row { grid-template-columns: 1fr; }
    .ai-tools-grid { grid-template-columns: 1fr; }
    .modal-box--wide { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════
   RICH EDITOR TOOLBAR GROUPS (Forethought / Performance)
══════════════════════════════════════════════════════════════ */
.editor-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    background: #f6f8ff;
}
.toolbar-group {
    display: flex;
    gap: 3px;
    border-right: 1px solid #dde5ff;
    padding-right: 6px;
    margin-right: 2px;
}
.toolbar-group:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.toolbar-btn {
    border: 1px solid #d0d9f7;
    background: #fff;
    color: #30439b;
    border-radius: 7px;
    padding: 5px 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.toolbar-btn:hover { background: #edf2ff; border-color: #a0b0f0; }
.toolbar-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.rich-editor {
    min-height: 220px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    background: #fff;
    line-height: 1.7;
    font-size: 15px;
    outline: none;
    color: var(--text-strong);
}
.rich-editor:focus { border-color: #8aa2ff; box-shadow: 0 0 0 3px rgba(50,87,255,0.12); }
.rich-editor[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #aab4d0;
    font-style: italic;
}

.editor-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 12px;
    background: #f6f8ff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    font-size: 12px;
    color: var(--text-muted);
}
.editor-footer .wc-stat { font-weight: 700; color: #3750af; }

/* ══════════════════════════════════════════════════════════════
   CHECKLIST (Forethought)
══════════════════════════════════════════════════════════════ */
.checklist-wrap { display: grid; gap: 8px; }
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f7f9ff;
    border: 1px solid #dde5ff;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.checklist-item:hover { background: #eef2ff; }
.checklist-item.done { background: #f0fff7; border-color: #b0e8cf; }
.checklist-item.done .checklist-text { text-decoration: line-through; color: var(--text-muted); }
.checklist-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #8aa2ff;
    border-radius: 5px;
    flex-shrink: 0;
    position: relative;
    background: #fff;
    transition: all 0.15s;
}
.checklist-item.done .checklist-checkbox {
    background: #22c55e;
    border-color: #22c55e;
}
.checklist-item.done .checklist-checkbox::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 3px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}
.checklist-text { flex: 1; font-size: 14px; font-weight: 600; color: #2c3f93; }

/* ══════════════════════════════════════════════════════════════
   PROGRESS BAR (Forethought)
══════════════════════════════════════════════════════════════ */
.plan-progress-wrap {
    background: #edf1ff;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}
.plan-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0D9488, #22C55E);
    border-radius: 999px;
    transition: width 0.4s ease;
}
.plan-progress-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: right;
}

/* ══════════════════════════════════════════════════════════════
   PERFORMANCE LAYOUT (timer + editor + sidebar)
══════════════════════════════════════════════════════════════ */
.perf-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: start;
}
.perf-sidebar { display: grid; gap: 14px; }
.perf-editor-wrap { display: grid; gap: 0; }

.timer-card { text-align: center; }
.timer-display {
    font-size: 36px;
    font-weight: 900;
    color: #1a2d6e;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    margin: 4px 0 8px;
}
.timer-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.timer-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f6f8ff;
    color: #30439b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.timer-btn:hover { background: #edf2ff; }
.timer-btn.active-start { background: #22c55e; color: #fff; border-color: #22c55e; }
.timer-btn.active-pause { background: #f97316; color: #fff; border-color: #f97316; }

.sidebar-stat-card .stat-rows { display: grid; gap: 6px; margin-top: 4px; }
.sidebar-stat-card .srow {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.sidebar-stat-card .srow span:first-child { color: var(--text-muted); }
.sidebar-stat-card .srow span:last-child { font-weight: 700; color: #1a2d6e; }

.ai-tools-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-side-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    background: #f7f9ff;
    border: 1px solid #dde5ff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    color: #2c3f93;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.ai-side-btn:hover { background: #eef2ff; }
.ai-side-btn .ai-icon { font-size: 20px; }

/* Dual panel / preview toggle */
.panel-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
}
.panel-tab {
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.panel-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.panel-pane { display: none; }
.panel-pane.active { display: block; }

.preview-box {
    min-height: 300px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfcff;
    line-height: 1.8;
    font-size: 15px;
    color: var(--text-body);
}

@media (max-width: 900px) {
    .perf-layout { grid-template-columns: 1fr; }
    .perf-sidebar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .perf-sidebar { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   SYNONYM HOVER POPUP
══════════════════════════════════════════════════════════════ */
.synonym-popup {
    position: fixed;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(30,58,138,0.18);
    padding: 14px 16px;
    min-width: 240px;
    max-width: 320px;
}
.synonym-popup.is-hidden { display: none; }
.synonym-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}
.synonym-header strong { color: var(--primary); }
.synonym-list { display: grid; gap: 6px; }
.synonym-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f6f8ff;
    border: 1px solid #dde5ff;
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.synonym-item:hover { background: #eef2ff; }
.synonym-word { font-size: 14px; font-weight: 700; color: #1e3a8a; }
.synonym-arabic { font-size: 13px; color: var(--text-muted); direction: rtl; }
.synonym-loading { text-align: center; color: var(--text-muted); font-size: 13px; padding: 8px 0; }
.synonym-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

/* ══════════════════════════════════════════════════════════════
   CHAT WIDGET
══════════════════════════════════════════════════════════════ */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
}
.chat-toggle-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #3f7dff);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(50,87,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.chat-toggle-btn:hover { transform: scale(1.08); }
.chat-window {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 16px 45px rgba(30,58,138,0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.chat-window.is-hidden { display: none; }
.chat-header {
    background: linear-gradient(135deg, var(--primary), #3f7dff);
    color: #fff;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-header-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    height: 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f9fbff;
}
.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}
.chat-msg.bot {
    background: #eef2ff;
    color: #1e3a8a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
}
.chat-msg.user {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: #fff;
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    background: #f6f8ff;
}
.chat-input:focus { border-color: #8aa2ff; }
.chat-send-btn {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-strong); }

/* ── Chat Modal Overlay ──────────────────────────────────────── */
.chat-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.chat-modal-overlay.is-hidden { display: none; }
.chat-modal-box {
    width: min(640px, calc(100vw - 40px));
    height: min(580px, calc(100vh - 80px));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(30,58,138,0.22);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.chat-modal-box .chat-messages {
    height: auto;
    flex: 1;
}

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(30,58,138,0.14);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 240px;
}
.toast.success { border-left: 4px solid #22c55e; color: #0d8a70; }
.toast.error { border-left: 4px solid var(--danger); color: #b52b3f; }
.toast.info { border-left: 4px solid var(--primary); color: #1e3a8a; }
@keyframes toastIn {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ══════════════════════════════════════════════════════════════
   REFLECTION PHASE – prompt-based editors
══════════════════════════════════════════════════════════════ */
.reflection-prompt-wrap {
    border: 1px solid #dde5ff;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 16px;
}
.reflection-prompt-label {
    background: linear-gradient(90deg, #f0f4ff, #f7f9ff);
    border-bottom: 1px solid #dde5ff;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    color: #2c3f93;
}
.reflection-editor {
    min-height: 120px;
    padding: 12px 14px;
    border: none;
    outline: none;
    background: #fff;
    line-height: 1.7;
    font-size: 14px;
    color: var(--text-strong);
    width: 100%;
    display: block;
}
.reflection-editor[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #aab4d0;
    font-style: italic;
}
.reflection-footer {
    display: flex;
    justify-content: flex-end;
    padding: 5px 12px;
    background: #f7f9ff;
    border-top: 1px solid #eef1fb;
    font-size: 12px;
    color: var(--text-muted);
}
.reflection-footer .wc { font-weight: 700; color: #3750af; }

.analytics-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.analytics-item {
    background: #f7f9ff;
    border: 1px solid #dde5ff;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}
.analytics-item .a-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.analytics-item .a-value {
    font-size: 22px;
    font-weight: 900;
    color: #1a2d6e;
    margin-top: 4px;
}

.grade-display-card {
    background: linear-gradient(135deg, #f5f9ff, #fff3e8);
    border: 1px solid #dde5ff;
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}
.grade-badge {
    font-size: 48px;
    font-weight: 900;
    color: #1e3a8a;
    line-height: 1;
    min-width: 80px;
    text-align: center;
}
.grade-meta .grade-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}
.grade-meta .grade-feedback {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-body);
    line-height: 1.55;
}

/* ══════════════════════════════════════════════════════════════
   RUBRIC SCORING (Teacher Review)
══════════════════════════════════════════════════════════════ */
.rubric-section { display: grid; gap: 14px; margin-bottom: 16px; }
.rubric-criterion {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.rubric-criterion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f6f8ff;
    border-bottom: 1px solid var(--border);
}
.criterion-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a8a;
}
.criterion-weight {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}
.rubric-score-row {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    flex-wrap: wrap;
}
.score-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #f7f9ff;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    color: #3750af;
    transition: all 0.15s;
}
.score-btn:hover { border-color: #8aa2ff; background: #eef2ff; }
.score-btn.selected-1 { background: #ff5252; border-color: #ff5252; color: #fff; }
.score-btn.selected-2 { background: #ff9800; border-color: #ff9800; color: #fff; }
.score-btn.selected-3 { background: #ffc107; border-color: #ffc107; color: #fff; }
.score-btn.selected-4 { background: #8bc34a; border-color: #8bc34a; color: #fff; }
.score-btn.selected-5 { background: #2196f3; border-color: #2196f3; color: #fff; }
.score-descriptor {
    padding: 0 14px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    height: 0;
    overflow: hidden;
    transition: height 0.2s;
}
.score-descriptor.active {
    padding-bottom: 10px;
    height: auto;
}

.rubric-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #eef2ff;
    border: 1px solid #d0d9f7;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 700;
}
.rubric-total .label { color: #1e3a8a; font-size: 14px; }
.rubric-total .score { font-size: 24px; color: #1e3a8a; }

.ai-assess-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1.5px solid #d0d9f7;
    border-radius: 10px;
    background: #f7f9ff;
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.ai-assess-btn:hover { background: #eef2ff; }

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS  (max-width: 768px and below)
══════════════════════════════════════════════════════════════ */

/* ── Core layout ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .role-shell {
        padding: 16px 12px 32px;
    }

    /* Nav: allow items to wrap gracefully */
    .top-nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    .brand-title {
        font-size: 16px;
    }
    .nav-meta {
        flex-wrap: wrap;
        gap: 6px;
    }
    .nav-meta .link-btn {
        font-size: 13px;
    }
    /* Hide the tour help button on mobile to save space */
    #tourHelpBtn {
        display: none;
    }

    /* Welcome / hero cards */
    .welcome-card h2,
    .student-welcome-card h2,
    .admin-welcome-card h2 {
        font-size: 22px;
    }
    .classes-head h3 {
        font-size: 22px;
    }

    /* Stat values */
    .stat-value {
        font-size: 22px;
    }
    .class-stats .value {
        font-size: 20px;
    }

    /* Stats grid → 2 cols at 768, 1 col at 480 */
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Bar chart labels: shorter col */
    .bar-row {
        grid-template-columns: 80px 1fr 30px;
        gap: 6px;
    }
    .bar-label { font-size: 11px; }

    /* Tables: make horizontally scrollable */
    .data-table {
        min-width: 560px;
    }
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Wrap any naked data-table not already in .table-wrap */
    .card > .data-table,
    .section-stack > .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Buttons: comfortable touch targets */
    .btn-primary,
    .btn-secondary,
    .btn-create-task,
    .btn-manage-students,
    .btn-forum {
        padding: 11px 14px;
        font-size: 14px;
    }

    /* Toolbar buttons: slightly smaller */
    .toolbar-btn {
        padding: 4px 7px;
        font-size: 12px;
        min-width: 26px;
    }

    /* Auth card: single column already at 980px — just reduce padding */
    .auth-form,
    .auth-brand {
        padding: 24px 20px;
    }
    .auth-minimal-card h1 {
        font-size: 26px;
    }

    /* Wizard modal */
    .field-row {
        grid-template-columns: 1fr;
    }

    /* Class grid */
    .class-grid {
        grid-template-columns: 1fr;
    }

    /* Grade display card on small screens */
    .grade-display-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .grade-badge {
        font-size: 36px;
        min-width: auto;
    }

    /* Rubric score buttons: tighter grid */
    .rubric-score-row {
        gap: 4px;
    }
    .score-btn {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    /* Toast: full-width on tiny screens */
    .toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
    }
    .toast {
        min-width: 0;
        width: 100%;
    }

    /* Chat widget: bottom-left on mobile to avoid overlap with nav */
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }
    .chat-window {
        width: calc(100vw - 32px);
        right: 0;
    }

    /* Pre-box: shorter on mobile */
    .pre-box {
        max-height: 40vh;
    }

    /* Timer: smaller display */
    .timer-display {
        font-size: 28px;
    }

    /* Reflection analytics bar */
    .analytics-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Extra small screens (≤ 480px) ──────────────────────────── */
@media (max-width: 480px) {
    .role-shell {
        padding: 12px 10px 24px;
    }

    /* Nav: stack vertically, brand on top */
    .top-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .nav-meta {
        width: 100%;
        gap: 6px;
    }

    /* Hero welcome text */
    .welcome-card h2,
    .student-welcome-card h2 {
        font-size: 18px;
    }

    /* Stats: 1 column */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .phase-progress-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Section headings */
    .classes-head h3 {
        font-size: 18px;
    }

    /* Auth brand padding */
    .auth-brand,
    .auth-form {
        padding: 20px 16px;
    }

    /* Wizard nav buttons */
    .wizard-nav--split .btn-secondary,
    .wizard-nav--split .btn-primary {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* AI tools grid → 1 col */
    .ai-tools-grid,
    .ai-tools-sidebar {
        grid-template-columns: 1fr;
    }

    /* Class stats: 2 col instead of 3 */
    .class-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Modal: full-screen edge */
    .modal-box {
        padding: 18px 14px 16px;
    }
    .modal-box--wide {
        width: 100%;
    }

    /* Reflection analytics bar */
    .analytics-bar {
        grid-template-columns: 1fr;
    }

    /* Rubric total */
    .rubric-total {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .rubric-total .score {
        font-size: 20px;
    }

    /* Chat window: full width */
    .chat-window {
        width: calc(100vw - 32px);
        min-width: 0;
    }
}

/* ── Landscape small devices ─────────────────────────────────── */
@media (max-height: 500px) and (max-width: 900px) {
    .auth-wrap {
        padding: 12px 16px;
        align-items: flex-start;
    }
    .modal-box {
        max-height: calc(100vh - 20px);
    }
}
