/* ── CSS VARIABLES ─────────────────────────────────────────────────────── */
:root {
    --navy: #1B3A6B;
    --blue: #2E6DB4;
    --blue-bg: #E6F1FB;
    --gold: #C8960C;
    --gold-light: #F5E6B8;
    --bg: #F4F6FA;
    --surface: #FFFFFF;
    --surface2: #EEF1F8;
    --surface3: #E4E8F2;
    --border: #DDE1EE;
    --text: #18192A;
    --text2: #52576E;
    --text3: #8A90A8;
    --green: #1A6B3A;
    --green-bg: #E8F5EE;
    --green-border: #B8DFC8;
    --amber: #7A4800;
    --amber-bg: #FEF3E2;
    --amber-border: #F5D99A;
    --red: #8B1A1A;
    --red-bg: #FCEAEA;
    --red-border: #F0B8B8;
    --purple: #3C3489;
    --purple-bg: #EEEDFE;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(27,58,107,.08);
    --shadow-lg: 0 8px 32px rgba(27,58,107,.14);
}

/* ── Dark theme ──────────────────────────────────────────────────────────────
   Charcoal background, deepened navy header (themes itself via --navy), brighter
   accents so they read on dark, status colors kept legible, shadows softened.
   Applied via [data-theme="dark"] (explicit toggle) OR prefers-color-scheme when
   the user hasn't chosen (data-theme unset). */
:root[data-theme="dark"] {
    --navy: #11233f;          /* deepened so the header reads dark */
    --blue: #5B9BE0;          /* brighter so it pops on charcoal */
    --blue-bg: #1C2A3D;       /* dark "info" surface */
    --gold: #E0B84A;
    --gold-light: #4A3E1C;
    --bg: #16181D;            /* balanced charcoal, not pure black */
    --surface: #1E2128;       /* cards sit slightly above the bg */
    --surface2: #262A33;      /* hover / secondary surface */
    --surface3: #303541;
    --border: #333845;
    --text: #E8EAF0;
    --text2: #AEB4C4;
    --text3: #767D90;
    --green: #5FC98A;
    --green-bg: #16291F;
    --green-border: #2C5A3E;
    --amber: #E0A94A;
    --amber-bg: #2C2310;
    --amber-border: #5A471C;
    --red: #E07070;
    --red-bg: #2C1717;
    --red-border: #5A2C2C;
    --purple: #9189E0;
    --purple-bg: #211E3A;
    --shadow: 0 2px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

/* Auto dark when the user hasn't explicitly chosen a theme */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --navy: #11233f;
        --blue: #5B9BE0;
        --blue-bg: #1C2A3D;
        --gold: #E0B84A;
        --gold-light: #4A3E1C;
        --bg: #16181D;
        --surface: #1E2128;
        --surface2: #262A33;
        --surface3: #303541;
        --border: #333845;
        --text: #E8EAF0;
        --text2: #AEB4C4;
        --text3: #767D90;
        --green: #5FC98A;
        --green-bg: #16291F;
        --green-border: #2C5A3E;
        --amber: #E0A94A;
        --amber-bg: #2C2310;
        --amber-border: #5A471C;
        --red: #E07070;
        --red-bg: #2C1717;
        --red-border: #5A2C2C;
        --purple: #9189E0;
        --purple-bg: #211E3A;
        --shadow: 0 2px 12px rgba(0,0,0,.35);
        --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── APP SHELL ─────────────────────────────────────────────────────────── */
.app-root { min-height: 100vh; }
.app-main { min-height: calc(100vh - 58px); }
.auth-main { min-height: 100vh; }

.app-header {
    background: linear-gradient(135deg, var(--navy) 0%, #1E4A8A 100%);
    color: #fff;
    height: 58px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 12px rgba(27,58,107,.3);
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
    width: 36px; height: 36px;
    background: rgba(255,255,255,.15);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 20px;
}
.header-title-block {}
.header-title { font-size: 15px; font-weight: 700; }
.header-sub { font-size: 11px; opacity: .7; }

.header-nav { display: flex; gap: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,.75);
    transition: all .15s;
    text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.2); color: #fff; }

.header-right { display: flex; align-items: center; gap: 16px; }
.view-toggle {
    display: flex; align-items: center; gap: 2px;
    background: rgba(0,0,0,.18); border-radius: 20px; padding: 3px;
}
.view-toggle-btn {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 500; font-family: inherit;
    padding: 5px 12px; border: none; border-radius: 16px;
    background: transparent; color: rgba(255,255,255,.7);
    cursor: pointer; transition: all .15s; white-space: nowrap;
}
.view-toggle-btn:hover { color: #fff; }
.view-toggle-btn.active { background: rgba(255,255,255,.95); color: var(--navy); }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
}
.user-name { font-size: 13px; color: rgba(255,255,255,.85); }
.btn-icon {
    width: 32px; height: 32px; border-radius: 7px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.8);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.2); color: #fff; }
.role-badge { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 20px; }
.role-badge.admin { background: rgba(200,150,12,.35); color: #F5E6B8; }
.role-badge.instructor { background: rgba(46,109,180,.35); color: #B8D4F8; }
.role-badge.student { background: rgba(26,107,58,.35); color: #B8DFC8; }

/* ── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-body { max-width: 820px; margin: 0 auto; padding: 1.5rem; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ── LOGIN ──────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2.25rem; width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, var(--navy), var(--blue));
    border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem; font-size: 28px; color: #fff;
    box-shadow: 0 4px 16px rgba(27,58,107,.3);
}
.login-title { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text2); margin-bottom: 2rem; }

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.form-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.form-input {
    width: 100%; padding: 10px 13px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; background: var(--surface); color: var(--text);
    outline: none; transition: border .15s, box-shadow .15s;
    font-family: inherit;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(46,109,180,.15); }
.form-input-sm { font-size: 13px; padding: 7px 10px; }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.color-pick { width: 40px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; padding: 2px; }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all .15s; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--navy), var(--blue)); border-color: var(--navy); color: #fff; }
.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #14294d, #235a94); /* darker navy→blue */
    border-color: #14294d;
    color: #fff;
}
.btn-ghost { border-color: transparent; background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); border-color: var(--border); }
.btn-warning { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }
.btn-warning:hover { background: var(--amber); color: #fff; }
.btn-danger { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--text3); }
.btn-danger-ghost:hover { color: var(--red); background: var(--red-bg); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.back-btn {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 13px; color: var(--text2); cursor: pointer;
    background: none; border: none; padding: 0; margin-bottom: 1rem;
    font-family: inherit; transition: color .15s;
}
.back-btn:hover { color: var(--navy); }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: .875rem; display: flex; align-items: center; gap: 6px; }
.card-progress-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.alert-card { border-left: 3px solid; }
.alert-card.amber { border-left-color: var(--gold); background: var(--amber-bg); }
.alert-card.amber .card-title { color: var(--amber); }

/* ── STATS ──────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .875rem 1rem; box-shadow: var(--shadow); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--blue); }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; font-weight: 500; }

/* ── PROGRESS BARS ──────────────────────────────────────────────────────── */
.progress-bar-wrap { background: var(--surface2); border-radius: 20px; height: 8px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--navy), var(--blue)); transition: width .5s cubic-bezier(.4,0,.2,1); }
.progress-bar-fill.gold { background: linear-gradient(90deg, var(--gold), #E5A800); }

/* ── TAGS ───────────────────────────────────────────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.tag.success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.tag.warning { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.tag.danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.tag.blue { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(46,109,180,.25); }
.tag.navy { background: rgba(27,58,107,.1); color: var(--navy); border: 1px solid rgba(27,58,107,.2); }
.tag.gray { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.tag.purple { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(60,52,137,.2); }
.tag.amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; font-size: 10px; font-weight: 700; padding: 0 4px; }
.badge.amber { background: var(--gold); color: #fff; }

/* ── PHASE BLOCKS ───────────────────────────────────────────────────────── */
.phase-block { margin-bottom: 10px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.phase-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; cursor: pointer; user-select: none; transition: filter .15s; }
.phase-header:hover { filter: brightness(.97); }
.phase-title { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.phase-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.phase-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: 10px; }
.phase-count { font-size: 12px; color: var(--text2); white-space: nowrap; font-weight: 500; }
.phase-pb { width: 70px; }
.phase-body { background: var(--surface); padding: 4px 12px 12px; border-top: 1px solid var(--border); }

/* ── ITEMS ──────────────────────────────────────────────────────────────── */
.week-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .07em; padding: 10px 6px 4px; }
.section-cat { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; padding: 6px 6px 2px; }
.item-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); transition: background .1s; }
.item-row:hover { background: var(--surface2); }
.item-row.done .item-text { color: var(--text3); text-decoration: line-through; }
.item-row.flagged { background: var(--amber-bg); }
.item-row.flagged .item-text { color: var(--amber); }
.item-row input[type=checkbox] { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; accent-color: var(--navy); cursor: pointer; }
.item-content { flex: 1; min-width: 0; }
.item-text { font-size: 13px; color: var(--text); line-height: 1.5; display: block; }
.item-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.item-link { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--blue); padding: 2px 7px; border-radius: 20px; background: rgba(46,109,180,.1); border: 1px solid rgba(46,109,180,.2); transition: all .15s; text-decoration: none; }
.item-link:hover { background: rgba(46,109,180,.2); text-decoration: none; }
.quiz-required-note { font-size: 11px; color: var(--blue); font-weight: 600; margin-left: 4px; }
.quiz-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; border: 1.5px solid var(--blue); background: rgba(46,109,180,.1); color: var(--blue); cursor: pointer; transition: all .15s; font-family: inherit; }
.quiz-btn:hover { background: var(--blue); color: #fff; }
.quiz-btn.passed { border-color: var(--green); background: var(--green-bg); color: var(--green); cursor: default; }
.quiz-btn.passed:hover { background: var(--green-bg); color: var(--green); }
.quiz-attempt-info { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text3); }
.flag-btn { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 2px 7px; border-radius: 20px; border: 1px solid var(--border); background: none; cursor: pointer; color: var(--text3); transition: all .15s; font-family: inherit; }
.flag-btn:hover { border-color: var(--amber-border); color: var(--amber); background: var(--amber-bg); }
.flag-btn.active { border-color: var(--amber-border); color: var(--amber); background: var(--amber-bg); }

/* ── VIDEO EMBED ────────────────────────────────────────────────────────── */
.video-embed-toggle { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; margin-top: 6px; }
.video-thumb { width: 48px; height: 36px; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-title-small { font-size: 12px; font-weight: 500; flex: 1; min-width: 0; }
.video-embed-wrap { margin-top: 6px; }
.video-iframe { width: 100%; aspect-ratio: 16/9; border: none; border-radius: var(--radius-sm); }

/* ── STUDENT LIST ───────────────────────────────────────────────────────── */
.student-row { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .1s; border: 1px solid transparent; }
.student-row:hover { background: var(--surface2); border-color: var(--border); }
.student-row.archived { opacity: .6; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.student-info { flex: 1; min-width: 0; }
.student-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.student-name { font-size: 14px; font-weight: 700; }
.student-course { font-size: 12px; color: var(--text2); margin-top: 2px; }
.student-meta-small { font-size: 12px; color: var(--text2); }
.student-last-active { font-size: 11px; color: var(--text3); margin-top: 2px; }
.progress-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.progress-text { font-size: 12px; color: var(--text2); font-weight: 500; }
.attention-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--amber-border); font-size: 13px; cursor: pointer; }

/* ── STUDENT DETAIL ─────────────────────────────────────────────────────── */
.student-detail-header .student-header-content { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.student-header-info { flex: 1; min-width: 0; }
.student-header-info h2 { font-size: 18px; font-weight: 700; }
.student-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.student-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.checkride-date { font-size: 13px; color: var(--text2); margin-top: 4px; display: flex; align-items: center; gap: 4px; }

.detail-tabs { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid var(--border); }
.detail-tab { flex: 1; text-align: center; padding: 8px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text2); background: none; border: none; transition: all .15s; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 5px; }
.detail-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; font-size: 10px; font-weight: 700; background: var(--blue); color: #fff; padding: 0 4px; }

.detail-phase { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
.detail-phase-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; cursor: pointer; transition: background .1s; }
.detail-phase-header:hover { background: var(--surface2); }
.detail-phase-body { padding: 8px 14px 12px; border-top: 1px solid var(--border); }
.detail-week-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .07em; padding: 8px 0 2px; }
.detail-cat { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; padding: 4px 0 2px; }
.detail-item { display: flex; align-items: flex-start; gap: 9px; padding: 4px 0; }
.detail-item-icon { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; font-size: 10px; }
.detail-item-icon.done { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.detail-item-icon.todo { background: var(--surface2); color: var(--text3); border: 1px solid var(--border); }
.detail-item-icon.flagged { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.detail-item-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.detail-item-text.done { color: var(--text3); }
.flagged-item { padding: 5px 0; border-bottom: 1px solid var(--amber-border); font-size: 13px; display: flex; align-items: center; gap: 6px; }

/* ── FLIGHT NOTES ───────────────────────────────────────────────────────── */
.note-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; overflow: hidden; }
.note-header { display: flex; align-items: center; gap: 10px; padding: .75rem 1rem; cursor: pointer; transition: background .15s; user-select: none; }
.note-header:hover { background: var(--surface3); }
.note-title { font-size: 13px; font-weight: 700; color: var(--text); }
.note-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text3); margin-top: 3px; }
.note-body { padding: .5rem 1rem 1rem; font-size: 13px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.note-form { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1rem; }
.ti-chevron-down { transition: transform .2s; }
.ti-chevron-down.open { transform: rotate(180deg); display: inline-block; }

/* ── QUIZ HISTORY ───────────────────────────────────────────────────────── */
.quiz-history-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.quiz-history-row:last-child { border-bottom: none; }
.quiz-history-title { font-size: 13px; font-weight: 600; }
.quiz-history-meta { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── QUIZ MODAL ─────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-box { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 1.25rem; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.quiz-header { background: linear-gradient(135deg, var(--navy), var(--blue)); color: #fff; padding: 1.25rem 1.5rem; border-radius: var(--radius) var(--radius) 0 0; }
.quiz-header-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.quiz-progress-bar { height: 4px; background: rgba(255,255,255,.25); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.quiz-progress-bar div { height: 100%; background: #fff; border-radius: 2px; transition: width .3s; }
.quiz-body { padding: 1.5rem; }
.quiz-q-num { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.quiz-q-text { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.5; margin-bottom: 1.25rem; }
.quiz-option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; transition: all .15s; }
.quiz-option:hover { border-color: var(--blue); background: rgba(46,109,180,.05); }
.quiz-option.selected { border-color: var(--blue); background: rgba(46,109,180,.1); }
.quiz-option.correct { border-color: var(--green); background: var(--green-bg); cursor: default; }
.quiz-option.incorrect { border-color: var(--red); background: var(--red-bg); cursor: default; }
.quiz-option.faded { opacity: .5; cursor: default; }
.quiz-option-letter { width: 24px; height: 24px; border-radius: 50%; background: var(--surface2); border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; color: var(--text2); }
.quiz-option.selected .quiz-option-letter { background: var(--blue); border-color: var(--blue); color: #fff; }
.quiz-option.correct .quiz-option-letter { background: var(--green); border-color: var(--green); color: #fff; }
.quiz-option.incorrect .quiz-option-letter { background: var(--red); border-color: var(--red); color: #fff; }
.quiz-option-text { font-size: 14px; color: var(--text); line-height: 1.4; padding-top: 2px; }
.quiz-explanation { background: var(--gold-light); border: 1px solid rgba(200,150,12,.3); border-radius: var(--radius-sm); padding: .875rem 1rem; margin-top: 1rem; font-size: 13px; color: var(--amber); line-height: 1.6; display: none; }
.quiz-explanation.show { display: block; }
.quiz-footer { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-top: 1px solid var(--border); gap: 10px; }
.quiz-score-screen { padding: 2rem 1.5rem; text-align: center; }
.quiz-score-circle { width: 100px; height: 100px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 1rem; border: 4px solid; }
.quiz-score-circle.pass { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.quiz-score-circle.fail { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.score-pct { font-size: 28px; font-weight: 800; }
.score-fraction { font-size: 12px; font-weight: 500; }
.quiz-result-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.quiz-result-msg { font-size: 13px; color: var(--text2); max-width: 380px; margin: 0 auto; line-height: 1.6; }
.xp-earned { display: inline-flex; align-items: center; gap: 6px; background: var(--gold-light); border: 1px solid rgba(200,150,12,.3); border-radius: 20px; padding: 5px 14px; font-size: 14px; font-weight: 700; color: var(--amber); margin-bottom: 12px; }

/* ── GAMIFICATION ───────────────────────────────────────────────────────── */
.xp-row { display: flex; align-items: center; gap: 12px; margin-bottom: 1rem; flex-wrap: wrap; }
.streak-badge { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(135deg, #FF6B2B, #FF9A3C); color: #fff; border-radius: 20px; padding: 5px 12px; font-size: 13px; font-weight: 700; box-shadow: 0 2px 8px rgba(255,107,43,.3); }
.xp-block { flex: 1; min-width: 180px; }
.xp-meta { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--text2); }
.level-name { font-size: 12px; color: var(--text3); }
.xp-to-next { font-size: 11px; color: var(--text3); margin-top: 3px; }
.milestone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: .75rem; }
.milestone { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .625rem .75rem; display: flex; align-items: center; gap: 8px; }
.milestone.earned { background: var(--gold-light); border-color: rgba(200,150,12,.35); }
.milestone-icon { font-size: 20px; flex-shrink: 0; filter: grayscale(1); opacity: .4; }
.milestone.earned .milestone-icon { filter: none; opacity: 1; }
.milestone-name { font-size: 12px; font-weight: 600; color: var(--text2); }
.milestone.earned .milestone-name { color: var(--amber); }
.milestone-desc { font-size: 10px; color: var(--text3); margin-top: 1px; }

/* ── COURSE CARDS ───────────────────────────────────────────────────────── */
.course-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: .75rem; cursor: pointer; transition: all .15s; box-shadow: var(--shadow); }
.course-card:hover { border-color: var(--blue); box-shadow: var(--shadow-lg); }
.course-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.course-title { font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.course-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.course-description { font-size: 13px; color: var(--text2); margin-top: 8px; }
.course-tabs { display: flex; gap: 4px; margin-bottom: 1rem; }
.course-tab { flex: 1; padding: 8px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text2); background: var(--surface); border: 1px solid var(--border); transition: all .15s; font-family: inherit; }
.course-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.course-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.course-row:last-child { border-bottom: none; }

/* ── CURRICULUM EDITOR ──────────────────────────────────────────────────── */
.curriculum-editor {}
.editor-phase { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden; box-shadow: var(--shadow); }
.editor-phase-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface2); }
.editor-phase-title { font-size: 14px; font-weight: 700; }
.editor-week { margin: 8px 16px; background: var(--surface2); border-radius: var(--radius-sm); overflow: hidden; }
.editor-week-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.week-label-edit { font-size: 13px; font-weight: 600; }
.editor-section { margin: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.editor-section-header { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; background: var(--surface2); }
.section-cat-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.section-cat-badge.reading { background: var(--blue-bg); color: var(--blue); }
.section-cat-badge.video { background: var(--red-bg); color: var(--red); }
.section-cat-badge.practice { background: var(--green-bg); color: var(--green); }
.section-cat-badge.document { background: var(--purple-bg); color: var(--purple); }
.editor-item { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.editor-item:last-child { border-bottom: none; }
.item-display { display: flex; align-items: center; gap: 8px; }
.item-type-icon { font-size: 14px; flex-shrink: 0; }
.item-title { font-size: 13px; flex: 1; min-width: 0; }
.item-edit-form { padding: 8px 0; }
.editor-actions { display: flex; align-items: center; gap: 6px; }
.editor-actions-sm { display: flex; align-items: center; gap: 4px; }
.add-week-btn, .add-section-btn { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--blue); background: none; border: 1px dashed rgba(46,109,180,.3); border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer; width: 100%; margin: 6px 16px; width: calc(100% - 32px); font-family: inherit; transition: all .15s; }
.add-week-btn:hover, .add-section-btn:hover { background: rgba(46,109,180,.05); border-color: var(--blue); }
.add-phase-form, .add-week-form, .add-section-form { padding: 12px 16px; background: var(--surface2); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit { font-size: 14px; font-weight: 700; border: 1px solid var(--blue); border-radius: 5px; padding: 4px 8px; background: var(--surface); color: var(--text); font-family: inherit; flex: 1; }
.course-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.course-title-input { font-size: 20px; font-weight: 700; border: none; border-bottom: 2px solid var(--border); background: transparent; color: var(--text); font-family: inherit; padding: 4px 0; outline: none; width: 100%; }
.course-title-input:focus { border-bottom-color: var(--blue); }
.editor-actions { display: flex; gap: 8px; flex-shrink: 0; }
.settings-panel { background: var(--surface2); }

/* ── QUIZ EDITOR ────────────────────────────────────────────────────────── */
.quiz-question-editor { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1rem; }
.quiz-q-num-editor { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); margin-bottom: 8px; }
.option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.option-row input[type=radio] { flex-shrink: 0; accent-color: var(--green); }

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 1rem; }
.alert-danger { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.info-box { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .875rem 1rem; font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ── LOADING ────────────────────────────────────────────────────────────── */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 1rem; color: var(--text2); font-size: 14px; }
.loading-state { display: flex; justify-content: center; padding: 3rem; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ARCHIVED ───────────────────────────────────────────────────────────── */
.archived-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.archived-section summary { font-size: 13px; color: var(--text2); cursor: pointer; font-weight: 500; }

/* ── EMPTY STATES ───────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2rem; color: var(--text2); font-size: 13px; }
.empty-state i { font-size: 32px; color: var(--text3); display: block; margin-bottom: .5rem; }
.empty-state-large { text-align: center; padding: 4rem 2rem; }
.empty-state-large i { font-size: 48px; color: var(--text3); display: block; margin-bottom: 1rem; }
.empty-state-large h2 { font-size: 20px; font-weight: 700; margin-bottom: .5rem; }
.empty-state-large p { color: var(--text2); margin-bottom: 1.5rem; }
.not-found { text-align: center; padding: 4rem; }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-num { font-size: 20px; }
    .app-body { padding: 1rem; }
    .app-header { padding: 0 1rem; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .header-nav { display: none; }
    .view-toggle { display: none; }
    .modal-box { margin: .5rem; }
}

/* ── Note acknowledgment ─────────────────────────────────────────────────── */
.note-ack-row { display: flex; align-items: center; padding: 8px 14px 12px; border-top: 0.5px solid var(--border); margin-top: 4px; }
.note-ack-done { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--green); font-weight: 500; }
.note-ack-done .ti { font-size: 14px; }

/* ── Notification bell + panel ───────────────────────────────────────────── */
.notif-wrap { position: relative; }
.notif-bell { position: relative; }
.notif-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
    width: 340px; max-height: 420px; overflow-y: auto;
    background: var(--surface); color: var(--text);
    border: 0.5px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.notif-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 0.5px solid var(--border);
    font-weight: 600; font-size: 14px; position: sticky; top: 0; background: var(--surface);
}
.notif-mark-all { background: none; border: none; color: var(--blue); font-size: 12px; cursor: pointer; font-family: inherit; }
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { display: flex; flex-direction: column; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--text3); font-size: 13px; }
.notif-item { padding: 10px 14px; border-bottom: 0.5px solid var(--border); cursor: pointer; transition: background .12s; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--blue-bg); }
.notif-item.unread:hover { background: rgba(46,109,180,.14); }
.notif-item-title { font-size: 13px; font-weight: 500; color: var(--text); }
.notif-item-body { font-size: 12px; color: var(--text2); margin-top: 2px; }
.notif-item-time { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ── Nav badge (Notes tab) ───────────────────────────────────────────────── */
.nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
    border-radius: 9px; background: var(--gold, #C8920F); color: #1B3A6B;
    font-size: 11px; font-weight: 700; line-height: 18px;
}

/* ── Dashboard notes nudge ───────────────────────────────────────────────── */
.notes-nudge {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.notes-nudge:hover { border-color: var(--blue); box-shadow: var(--shadow-lg); }
.notes-nudge-left { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.notes-nudge-link { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; color: var(--blue); white-space: nowrap; }

/* ── Notes master-detail layout ──────────────────────────────────────────── */
.notes-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.notes-list {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius); overflow: hidden; max-height: 70vh; overflow-y: auto;
}
.notes-list-item {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 12px 14px; border-bottom: 0.5px solid var(--border);
    cursor: pointer; transition: background .12s;
}
.notes-list-item:last-child { border-bottom: none; }
.notes-list-item:hover { background: var(--surface2); }
.notes-list-item.active { background: var(--blue-bg); }
.notes-list-dot { width: 10px; flex: 0 0 10px; padding-top: 5px; }
.notes-list-dot .dot { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold, #C8920F); }
.notes-list-main { min-width: 0; }
.notes-list-title { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-list-item.unacked .notes-list-title { font-weight: 600; }
.notes-list-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.notes-reader {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius); padding: 20px; min-height: 240px;
}
.notes-reader-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text3); min-height: 200px; }
.notes-reader-back { display: none; margin-bottom: 12px; }
.notes-reader-head h2 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.notes-reader-body { margin-top: 16px; font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* Responsive: collapse to single column, list-then-reader */
@media (max-width: 720px) {
    .notes-layout { grid-template-columns: 1fr; }
    .notes-layout.reading .notes-list { display: none; }
    .notes-layout:not(.reading) .notes-reader { display: none; }
    .notes-reader-back { display: inline-flex; }
    .notes-list { max-height: none; }
}

/* ── Theme transition & toggle ───────────────────────────────────────────── */
body, .card, .app-header, .login-box, .notes-list, .notes-reader,
.notif-panel, .stat, .student-row, .modal-box {
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.theme-toggle .ti { font-size: 18px; }

/* Dark-mode foreground fixes: a few elements use --navy as a text/accent color,
   which is intentionally dark for the header but unreadable on dark surfaces.
   Override just those to a readable tone in dark mode. */
:root[data-theme="dark"] .back-btn:hover { color: var(--blue); }
:root[data-theme="dark"] .tag.navy {
    background: rgba(91,155,224,.14); color: var(--blue); border-color: rgba(91,155,224,.3);
}
:root[data-theme="dark"] .item-row input[type=checkbox] { accent-color: var(--blue); }
:root[data-theme="dark"] .spinner { border-top-color: var(--blue); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) .back-btn:hover { color: var(--blue); }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .tag.navy {
        background: rgba(91,155,224,.14); color: var(--blue); border-color: rgba(91,155,224,.3);
    }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .item-row input[type=checkbox] { accent-color: var(--blue); }
    :root:not([data-theme="light"]):not([data-theme="dark"]) .spinner { border-top-color: var(--blue); }
}

/* ── Segmented toggle (invite vs manual, etc.) ───────────────────────────── */
.seg-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface2); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-size: 13px; font-weight: 500; background: transparent; border: none; color: var(--text2); cursor: pointer; transition: background .15s, color .15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--blue); color: #fff; }
.seg-btn:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Document lists (course resources) ───────────────────────────────────── */
.doc-list { display: flex; flex-direction: column; gap: 6px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.doc-row-btn { width: 100%; text-align: left; cursor: pointer; transition: background .15s; font: inherit; color: inherit; }
.doc-row-btn:hover { background: var(--surface3); }
.doc-icon { font-size: 22px; color: var(--blue); flex-shrink: 0; }
.doc-meta { flex: 1; min-width: 0; }
.doc-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }

/* ── Problem report cards ────────────────────────────────────────────────── */
.report-card.resolved { opacity: .6; }
.report-card.resolved:hover { opacity: 1; }
