/* =========================================================================
   Focus-Learning — styles matched to the Capstone 1 wireframes
   ========================================================================= */
:root {
    --blue: #1d4ed8;
    --blue-600: #2563eb;
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --bg: #eef2f7;
    --card: #ffffff;
    --line: #e3e8f0;
    --line-soft: #eef1f6;
    --text: #1e293b;
    --muted: #64748b;
    --faint: #94a3b8;
    --green: #16a34a;
    --green-50: #dcfce7;
    --yellow: #b45309;
    --yellow-50: #fef3c7;
    --red: #dc2626;
    --red-50: #fee2e2;
    --purple: #7c3aed;
    --purple-50: #ede9fe;
    --pink-50: #fce7f3;
    --orange: #ea580c;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .04);
    --heading: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    --body: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    --c: #2563eb;
    --c2: #60a5fa;
    --surface: #ffffff;
    --soft: #f8fafc;
    --soft-2: #f1f5f9;
    --hover: #f4f7fb;
    --zebra: #fbfcfe;
    --line-strong: #cbd5e1;
    --text-2: #475569;
    --nav-text: #3b4658;
    --nav-label: #7b8698;
    --mix: #ffffff;           /* what subject colours are tinted towards */
    --blue-ink: #1d4ed8;      /* blue used for text; --blue stays the top bar and button colour */
    --green-fill: #16a34a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--heading); margin: 0; line-height: 1.2; }
.text-purple { color: #4f46e5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 28px; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ----------------------------------------------------------------- Top bar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: 68px; display: flex; align-items: center; gap: 14px; padding: 0 22px;
    background: var(--blue); color: #fff; box-shadow: 0 2px 0 rgba(96, 165, 250, .55);
}
.role-student .topbar { background: linear-gradient(90deg, #4f46e5, #7c3aed 55%, #9333ea); }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-logo {
    width: 44px; height: 44px; border-radius: 10px; background: #fff; color: var(--blue);
    display: grid; place-items: center; font: 900 15px var(--heading);
}
.role-student .brand-logo { background: rgba(255, 255, 255, .18); color: #fff; border: 2px solid rgba(255, 255, 255, .45); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font: 900 19px var(--heading); letter-spacing: -.2px; }
.brand-text span { font-size: 12.5px; opacity: .9; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
    position: relative; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .16); font-size: 19px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .26); }
.count-bubble {
    position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    background: #ef4444; color: #fff; font: 800 11px/20px var(--heading); text-align: center; border: 2px solid #fff;
}
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; text-align: left; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
    background: var(--blue-100); color: var(--blue-ink); font: 900 15px var(--heading);
}
.topbar .avatar { background: #e0ecff; border: 2px solid rgba(255, 255, 255, .7); }
.role-student .topbar .avatar { background: linear-gradient(135deg, #fde68a, #fdba74); color: #7c3aed; }
.avatar-md { width: 46px; height: 46px; }
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-xl { width: 96px; height: 96px; font-size: 34px; border: 5px solid var(--surface); box-shadow: var(--shadow); background: var(--surface); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font: 800 15px var(--heading); }
.user-meta small { font-size: 12px; opacity: .9; }
.caret { font-size: 11px; opacity: .8; }
.dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; padding: 6px;
    background: var(--surface); color: var(--text); border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 12px 30px rgba(15, 23, 42, .15);
}
[data-dropdown].open .dropdown { display: block; }
.dropdown a, .dropdown button {
    display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; border: 0; background: none; cursor: pointer; font-size: 14px;
}
.dropdown a:hover, .dropdown button:hover { background: var(--blue-50); }
.menu-toggle { display: none; background: rgba(255, 255, 255, .16); border: 0; color: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 20px; cursor: pointer; }

/* ----------------------------------------------------------------- Shell & sidebar */
.shell { display: grid; grid-template-columns: 262px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar {
    position: sticky; top: 68px; height: calc(100vh - 68px); overflow-y: auto;
    display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-profile { display: flex; align-items: center; gap: 12px; padding: 18px 18px; border-bottom: 1px solid var(--line-soft); }
.role-student .sidebar-profile { background: linear-gradient(135deg, #f5f3ff, #fdf2f8); }
.role-student .sidebar-profile .avatar { background: linear-gradient(135deg, #c084fc, #f472b6); color: #fff; }
.sidebar-profile strong { display: block; font: 800 15.5px var(--heading); }
.role-student .sidebar-profile strong { color: #4338ca; }
.sidebar-profile small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.role-student .sidebar-profile small { color: #6d28d9; font-weight: 600; }
.nav { padding: 6px 10px 12px; }
.nav-label { padding: 16px 10px 6px; font: 800 12px var(--heading); letter-spacing: .8px; color: var(--nav-label); }
.role-student .nav-label { color: #a855f7; }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; margin: 2px 0;
    border: 0; border-radius: 10px; background: none; color: var(--nav-text); font-size: 15px; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--blue-50); color: var(--blue-ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--blue); }
.nav-item.tinted.active { background: color-mix(in srgb, var(--c) 12%, var(--mix)); color: var(--c); box-shadow: inset 3px 0 0 var(--c); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; flex: none; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--blue-100); color: var(--blue-ink); font: 800 12px/22px var(--heading); text-align: center; }
.nav-item.active .nav-badge { background: var(--blue); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 12.5px; }
.sidebar-foot strong { color: var(--blue-ink); font-weight: 700; }
.role-student .sidebar-foot strong { color: #7c3aed; }
.sidebar-scrim { display: none; }
.main { padding: 28px 30px 48px; min-width: 0; }

/* ----------------------------------------------------------------- Flash */
.flash { position: relative; padding: 12px 44px 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; border: 1px solid; }
.flash-success { background: #ecfdf3; color: #166534; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.flash-info { background: var(--blue-50); color: #1e40af; border-color: var(--blue-100); }
.flash-close { position: absolute; right: 10px; top: 8px; background: none; border: 0; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }

/* ----------------------------------------------------------------- Page head */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 27px; font-weight: 900; letter-spacing: -.3px; }
.page-sub { color: var(--muted); margin-top: 6px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 18px; }
.crumbs a { color: var(--blue-ink); }
.crumbs span:last-child { font-weight: 600; }
.crumbs .sep { color: var(--faint); }
.section-title { display: flex; align-items: baseline; gap: 10px; font-size: 18px; font-weight: 800; margin: 28px 0 14px; }
.section-title small { font: 500 14px var(--body); color: var(--muted); }

/* ----------------------------------------------------------------- Icons
   Solar icons, Bold Duotone style (assets/icons/*.svg, inserted by icon() in includes/helpers.php).
   They are drawn in currentColor, so each icon takes the colour of the element around it.
   Icons by 480 Design, CC BY 4.0. */
.ic { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.22em; }
.btn .ic, .pill .ic, .chip .ic, .flash .ic, .dropdown .ic { width: 1.15em; height: 1.15em; }
.card-title .ic, .section-title .ic { color: var(--blue-600); }
.role-student .card-title .ic, .role-student .section-title .ic { color: var(--purple); }
.section-title .ic { align-self: center; }
.dropdown .ic { margin-right: 8px; }
.chip-icon, .file-icon { color: var(--c); }
.attention { color: var(--red); }
.legend .dot { display: inline-block; margin: 0 4px 0 0; vertical-align: middle; }
.legend .dot-good { background: var(--green); }
.legend .dot-mid { background: #f59e0b; }
.legend .dot-low { background: var(--red); }

/* ----------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 10px;
    border: 1px solid transparent; font: 800 15px var(--heading); cursor: pointer; white-space: nowrap; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green-fill); color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-light { background: var(--soft); color: var(--text); border-color: var(--line); }
.btn-white { background: #fff; color: var(--c); }
.btn-outline { background: var(--surface); color: var(--blue-ink); border-color: #bfd3fb; font-family: var(--body); font-weight: 600; }
.btn-subject { background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 80%, black)); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--c) 30%, transparent); }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn-xs { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-link { background: none; border: 0; color: var(--blue-ink); font-weight: 700; cursor: pointer; padding: 0; }
.btn-edit { background: var(--blue-50); color: var(--blue-ink); border-color: var(--blue-100); }
.btn-del { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn-on { background: #ecfdf3; color: var(--green); border-color: #bbf7d0; }

/* ----------------------------------------------------------------- Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .card-title { margin: 0; }
.card-head a { color: var(--blue-ink); font-weight: 600; font-size: 14.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2-wide { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 20px; }

/* ----------------------------------------------------------------- Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { display: flex; align-items: center; gap: 16px; padding: 22px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; flex: none; }
.stat-num { font: 900 27px/1 var(--heading); }
.stat-label { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.bg-blue { background: var(--blue-50); } .c-blue { color: var(--blue-ink); }
.bg-purple { background: var(--purple-50); } .c-purple { color: var(--purple); }
.bg-yellow { background: var(--yellow-50); } .c-yellow { color: #c2410c; }
.bg-red { background: var(--red-50); } .c-red { color: var(--red); }
.bg-green { background: var(--green-50); } .c-green { color: var(--green); }
.bg-pink { background: var(--pink-50); } .c-pink { color: #be185d; }
.stat-icon.bg-blue { color: var(--blue-ink); }
.stat-icon.bg-purple { color: var(--purple); }
.stat-icon.bg-yellow { color: #c2410c; }
.stat-icon.bg-red { color: var(--red); }
.stat-icon.bg-green { color: var(--green); }
.stat-icon.bg-pink { color: #be185d; }

/* ----------------------------------------------------------------- Teacher-style subject cards */
.subject-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.subject-card { display: flex; flex-direction: column; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 35%, var(--mix)); border-radius: var(--radius); overflow: hidden; transition: transform .12s, box-shadow .12s; }
a.subject-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px color-mix(in srgb, var(--c) 18%, transparent); }
.subject-card-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px; min-height: 88px; color: #fff; background: linear-gradient(120deg, var(--c), var(--c2)); }
.subject-icon { font-size: 30px; line-height: 1; flex: none; }
.subject-card-head strong { display: block; font: 900 18px/1.15 var(--heading); }
.subject-card-head span { font-size: 13px; opacity: .92; }
.subject-card-head .subject-icon { font-size: 30px; opacity: 1; }
.subject-card-body { padding: 16px 18px 18px; margin-top: auto; }
.meta-row { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.meta-row b { color: var(--c); font: 800 14.5px var(--heading); }
.progress { height: 7px; border-radius: 99px; background: color-mix(in srgb, var(--c) 14%, var(--mix)); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.link-arrow { display: inline-block; margin-top: 12px; color: var(--c); font: 800 15px var(--heading); }

/* ----------------------------------------------------------------- Activity feed, notices, quick actions */
.feed-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.feed-item:first-child { padding-top: 2px; }
.feed-item:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--blue-600); }
.dot-quiz, .dot-submission { background: var(--green); }
.dot-lesson { background: var(--red); }
.dot-grade, .dot-feedback { background: #c2410c; }
.dot-message, .dot-account { background: var(--blue-600); }
.dot-material { background: var(--purple); }
.feed-title { font-weight: 600; }
.feed-title span { font-weight: 400; color: var(--muted); }
.feed-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.feed-time { color: var(--faint); font-size: 13px; margin-top: 4px; }
.notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 13px 16px; border-radius: 10px; border-left: 4px solid; margin-bottom: 10px; }
.notice:last-child { margin-bottom: 0; }
.notice-red { background: var(--red-50); border-color: #ef4444; }
.notice-yellow { background: #fefce8; border-color: #f59e0b; }
.notice-blue { background: var(--blue-50); border-color: var(--blue-600); }
.notice small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.notice form { flex: none; }
.notice .x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.quick-item { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; font-weight: 600; background: var(--surface); width: 100%; cursor: pointer; text-align: left; }
.quick-item:last-child { margin-bottom: 0; }
.quick-item:hover { background: var(--soft); border-color: var(--line-strong); }
.quick-item .arrow { margin-left: auto; color: var(--faint); }
.quick-item .qi { font-size: 19px; display: grid; place-items: center; color: var(--c); }

/* ----------------------------------------------------------------- Subject hero */
.hero {
    display: flex; align-items: center; gap: 22px; padding: 30px 30px; border-radius: 20px; color: #fff; margin-bottom: 24px;
    background: linear-gradient(120deg, var(--c), color-mix(in srgb, var(--c) 82%, var(--c2)));
}
.role-student .hero { background: linear-gradient(110deg, var(--c), var(--c2)); box-shadow: 0 10px 24px color-mix(in srgb, var(--c) 25%, transparent); }
.hero-icon { width: 76px; height: 76px; border-radius: 18px; display: grid; place-items: center; font-size: 38px; background: rgba(255, 255, 255, .2); flex: none; }
.hero h1 { font-size: 27px; font-weight: 900; }
.hero p { margin: 6px 0 0; opacity: .92; }
.hero-right { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.hero-stat { text-align: right; }
.hero-stat strong { display: block; font: 900 34px/1 var(--heading); }
.hero-stat span { font-size: 14px; opacity: .92; }
.hero-bar { width: 150px; height: 6px; border-radius: 9px; background: rgba(255, 255, 255, .35); margin-top: 10px; overflow: hidden; }
.hero-bar span { display: block; height: 100%; background: #fff; border-radius: inherit; }
.hero-box { min-width: 100px; padding: 14px 18px; border-radius: 16px; background: rgba(255, 255, 255, .2); text-align: center; }
.hero-box strong { display: block; font: 900 30px/1 var(--heading); }
.hero-box span { font-size: 14px; opacity: .92; }

/* ----------------------------------------------------------------- Tabs */
.tabs { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.tab { flex: 1; padding: 17px 12px; text-align: center; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.tab + .tab { border-left: 1px solid var(--line-soft); }
.tab.active { background: color-mix(in srgb, var(--c) 10%, var(--mix)); color: var(--c); font-weight: 800; font-family: var(--heading); border-bottom-color: var(--c); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ----------------------------------------------------------------- List rows (lessons, quizzes, students) */
.row-card {
    display: flex; align-items: center; gap: 18px; padding: 20px 22px; margin-bottom: 14px; width: 100%;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: left; color: inherit;
}
a.row-card:hover { box-shadow: 0 6px 16px rgba(15, 23, 42, .07); }
.row-card.lesson { border-left: 5px solid var(--c); }
.row-card.lesson.is-current { border-left-color: #f59e0b; border-color: color-mix(in srgb, var(--c) 45%, var(--mix)); border-left-color: #f59e0b; }
.row-card.lesson.is-upcoming { border-left-color: var(--line); opacity: .65; }
.row-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; flex: none; background: var(--soft-2); }
.row-icon { color: var(--c); }
.row-icon.done { background: var(--green-50); color: var(--green); }
.row-icon.current { background: #fef9c3; color: #b45309; }
.row-icon.wait { background: var(--yellow-50); color: #c2410c; }
.row-main { flex: 1; min-width: 0; }
.row-kicker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 3px; }
.row-title { font-size: 18px; font-weight: 600; }
.row-desc { color: var(--muted); margin-top: 3px; }
.row-side { display: flex; align-items: center; gap: 12px; flex: none; }
.chev { color: var(--faint); font-size: 20px; }
.dashed-add {
    display: block; width: 100%; padding: 20px; margin-bottom: 14px; border: 2px dashed var(--line-strong); border-radius: 14px;
    background: var(--soft); color: var(--muted); font-size: 17px; text-align: center; cursor: pointer;
}
.dashed-add:hover { border-color: var(--c); color: var(--c); }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ----------------------------------------------------------------- Pills & tags */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.pill-grey { background: var(--soft-2); color: var(--muted); font-weight: 500; }
.pill-green { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.pill-yellow { background: #fefce8; color: #b45309; border-color: #fde68a; }
.pill-red { background: var(--red-50); color: #b91c1c; border-color: #fecaca; }
.pill-blue { background: var(--blue-50); color: var(--blue-ink); border-color: var(--blue-100); }
.pill-purple { background: var(--purple-50); color: var(--purple); border-color: #ddd6fe; }
.pill-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill-current { background: #fffbeb; color: #b45309; border-color: #fcd34d; font: 900 12px var(--heading); letter-spacing: .3px; }
.tag { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 13px; font-weight: 700; background: color-mix(in srgb, var(--c) 12%, var(--mix)); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--mix)); }
.tag-plain { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 13px; color: var(--muted); background: var(--soft-2); }
.role-pill { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 700; }
.role-Teacher { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.role-Student { background: var(--purple-50); color: #6d28d9; border: 1px solid #ddd6fe; }
.role-Parent { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.role-Admin { background: var(--red-50); color: #b91c1c; border: 1px solid #fecaca; }

/* ----------------------------------------------------------------- Scores */
.score { display: inline-block; min-width: 64px; padding: 5px 10px; border-radius: 99px; font: 800 14.5px var(--heading); text-align: center; }
.score-good { background: #dcfce7; color: #15803d; }
.score-mid { background: #fefce8; color: #c2410c; }
.score-low { background: var(--red-50); color: #dc2626; }
.score-none { color: var(--faint); background: none; }
.score-wait { background: #fff7ed; color: #c2410c; font-size: 12.5px; }
.trophy { font: 900 19px var(--heading); color: var(--green); white-space: nowrap; }

/* ----------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table th { font: 800 14.5px var(--heading); color: var(--text-2); background: var(--soft); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:nth-child(even) { background: var(--zebra); }
.table td.center, .table th.center { text-align: center; }
.table .who { display: flex; align-items: center; gap: 12px; font-weight: 600; white-space: nowrap; }
.table .code { color: var(--muted); white-space: nowrap; }
.table .actions { display: flex; gap: 8px; }
.letter { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--blue-50); color: var(--blue-ink); font: 900 15px var(--heading); }
.grid-score th { font-size: 14px; }
.grid-score th span { margin-right: 4px; }

/* ----------------------------------------------------------------- Toolbars, search, chips */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px 20px; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.search { flex: 1 1 260px; position: relative; }
.search input { width: 100%; padding: 12px 14px 12px 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.search::before {
    content: ''; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
    background: var(--muted); -webkit-mask: url(../icons/magnifier.svg) center / contain no-repeat; mask: url(../icons/magnifier.svg) center / contain no-repeat;
}
.toolbar select { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 170px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14.5px; }
.chip.active { background: var(--blue-50); border-color: var(--blue-600); color: var(--blue-ink); font-weight: 800; font-family: var(--heading); }
.seg { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.seg a, .seg button { padding: 10px 18px; border-radius: 10px; border: 0; background: var(--soft-2); color: var(--text-2); font: 700 15px var(--heading); cursor: pointer; }
.seg .active { background: var(--blue); color: #fff; }
.role-student .seg .active { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

/* ----------------------------------------------------------------- Student list rows */
.person-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
a.person-row:hover { box-shadow: 0 6px 16px rgba(15, 23, 42, .07); }
.person-row .letter { width: 46px; height: 46px; font-size: 17px; }
.person-name { font-size: 17px; font-weight: 700; }
.person-sub { color: var(--faint); font-size: 13.5px; }
.person-side { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--faint); font-size: 14.5px; text-align: right; }

/* ----------------------------------------------------------------- Uploads & files */
.dropzone {
    position: relative; display: grid; place-items: center; gap: 4px; min-height: 86px; padding: 18px; margin: 4px 0 14px;
    border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--soft); color: var(--faint); text-align: center; cursor: pointer;
    font-weight: 600; letter-spacing: .2px;
}
.dropzone.big { min-height: 124px; }
.dropzone.dragover, .dropzone:hover { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 5%, var(--mix)); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .chosen { color: var(--text); font-weight: 700; }
.dropzone .chosen::before {
    content: ''; display: inline-block; width: 1.15em; height: 1.15em; margin-right: 6px; vertical-align: -0.22em;
    background: currentColor; -webkit-mask: url(../icons/paperclip.svg) center / contain no-repeat; mask: url(../icons/paperclip.svg) center / contain no-repeat;
}
.dropzone small { font-weight: 400; font-size: 12.5px; }
.file-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; margin-top: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.file-icon { font-size: 24px; flex: none; }
.file-name { font-weight: 600; }
.file-meta { color: var(--faint); font-size: 13.5px; }
.file-row .file-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.file-row .file-actions a { color: var(--blue-ink); font-weight: 600; }
.media-img { display: block; max-height: 460px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0 12px; }
.media-audio { width: 100%; margin: 8px 0 12px; }
.media-video { width: 100%; max-height: 480px; border-radius: 12px; background: #000; margin: 6px 0 12px; }
.media-pdf { width: 100%; height: 540px; border: 1px solid var(--line); border-radius: 12px; margin: 6px 0 10px; }
.prose { white-space: pre-line; line-height: 1.65; font-size: 16px; }

/* ----------------------------------------------------------------- Modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .5); overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 525px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 32px 34px; background: var(--surface); border-radius: 18px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28); }
.modal-lg { max-width: 760px; }
.modal h3 { font-size: 22px; font-weight: 900; }
.modal-sub { color: var(--muted); margin: 8px 0 20px; }
.modal-center { max-width: 450px; text-align: center; }
.modal-emoji { font-size: 50px; margin-bottom: 10px; color: var(--red); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }
.modal-actions-split { display: grid; grid-template-columns: 1fr 1fr; }
.modal-actions-split .btn { padding: 14px; }
.field { margin-bottom: 16px; }
.field label, .label { display: block; margin-bottom: 7px; font-weight: 600; font-size: 14.5px; }
.field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--c, var(--blue-600)); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #2563eb) 15%, transparent); }
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { color: var(--faint); font-size: 12.5px; margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; }

/* ----------------------------------------------------------------- Messages */
.chat { display: grid; grid-template-columns: 325px minmax(0, 1fr); height: calc(100vh - 230px); min-height: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list .search { flex: none; margin: 16px; }
.chat-items { overflow-y: auto; }
.chat-item { position: relative; display: flex; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.chat-item:hover { background: var(--soft); }
.chat-item.active { background: var(--blue-50); box-shadow: inset 3px 0 0 var(--blue); }
.chat-item .letter { width: 44px; height: 44px; font-size: 17px; }
.chat-item .unread { position: absolute; left: 46px; top: 12px; min-width: 20px; height: 20px; border-radius: 10px; background: #ef4444; color: #fff; font: 800 11px/20px var(--heading); text-align: center; border: 2px solid var(--surface); }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item-top strong { font-size: 15.5px; }
.chat-item-top time { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.chat-item-role { color: var(--faint); font-size: 13px; }
.chat-item-preview { color: var(--text-2); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.chat-head strong { display: block; font-size: 17px; }
.chat-head small { color: var(--muted); }
.chat-thread { flex: 1; overflow-y: auto; padding: 22px; background: var(--soft); display: flex; flex-direction: column; gap: 16px; }
.bubble { max-width: 66%; padding: 14px 18px; border-radius: 14px; line-height: 1.5; white-space: pre-line; }
.bubble time { display: block; text-align: right; font-size: 12px; margin-top: 6px; opacity: .75; }
.bubble.mine { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-compose { display: flex; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--line); }
.chat-compose textarea { flex: 1; resize: none; height: 50px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }

/* ----------------------------------------------------------------- Profile */
.profile-card { padding: 0; overflow: hidden; }
.profile-banner { height: 112px; background: linear-gradient(110deg, #1d4ed8, #3b82f6); }
.role-student .profile-banner { background: linear-gradient(110deg, #4f46e5, #a855f7); }
.profile-main { display: flex; align-items: flex-end; gap: 20px; padding: 0 30px; margin-top: -48px; }
.profile-main h2 { font-size: 25px; font-weight: 900; margin-top: 54px; }
.profile-main p { margin: 4px 0 0; color: var(--muted); }
.profile-main .btn { margin-left: auto; margin-bottom: 4px; }
.profile-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 26px 30px 30px; }
.field-box { padding: 14px 18px; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 12px; }
.field-box small { display: block; color: var(--muted); font-size: 13px; }
.field-box strong { display: block; font-size: 17px; font-weight: 600; margin-top: 4px; word-break: break-word; }
.sys-strip { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 24px; padding: 20px 22px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--soft); }
.sys-strip small { display: block; color: var(--muted); font-size: 13px; }
.sys-strip strong { font-weight: 600; }

/* ----------------------------------------------------------------- Info list (system information) */
.info-list .info-row { display: flex; justify-content: space-between; gap: 16px; padding: 13px 14px; margin-bottom: 10px; background: var(--soft); border-radius: 10px; }
.info-list .info-row span { color: var(--text-2); }
.info-list .info-row strong { font-weight: 600; text-align: right; }
.bar-row { margin-bottom: 18px; }
.bar-row .meta-row { color: var(--text); font-weight: 600; margin-bottom: 8px; }
.stat-line { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; margin-bottom: 10px; background: var(--soft); border-radius: 10px; color: var(--text-2); }
.stat-line strong { font: 900 19px var(--heading); }

/* ----------------------------------------------------------------- Empty state */
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 46px; height: 46px; color: var(--faint); }
.empty p { margin: 8px 0 0; }

/* ----------------------------------------------------------------- Student portal */
.greet {
    position: relative; overflow: hidden; display: flex; align-items: center; gap: 20px; padding: 38px 36px; margin-bottom: 24px;
    border-radius: 24px; color: #fff; background: linear-gradient(110deg, #4f46e5, #7c3aed 60%, #a855f7);
    box-shadow: 0 12px 28px rgba(99, 102, 241, .28);
}
.greet::before, .greet::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09); }
.greet::before { width: 220px; height: 220px; right: 120px; top: -110px; }
.greet::after { width: 260px; height: 260px; right: -60px; bottom: -140px; }
.greet h1 { font-size: 31px; font-weight: 900; }
.greet p { margin: 8px 0 20px; opacity: .9; font-size: 17px; }
.greet-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.greet-actions .btn { padding: 13px 22px; font-size: 16px; }
.btn-glass { background: rgba(255, 255, 255, .18); color: #fff; border: 1px solid rgba(255, 255, 255, .4); }
.btn-whiteblue { background: #fff; color: #4338ca; }
.mascot { position: relative; z-index: 1; margin-left: auto; font-size: 88px; line-height: 1; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .18)); }
.kid-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; }
.kid-card { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 35%, var(--mix)); border-radius: 22px; transition: transform .12s, box-shadow .12s; }
.kid-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px color-mix(in srgb, var(--c) 20%, transparent); }
.kid-card-top { position: relative; padding: 24px 20px 20px; min-height: 142px; color: #fff; background: linear-gradient(120deg, var(--c), var(--c2)); display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; }
.kid-card-top .subject-icon { font-size: 38px; }
.kid-card-top strong { font: 900 19px var(--heading); }
.stars-pill { position: absolute; top: 14px; right: 14px; padding: 3px 9px; border-radius: 99px; background: rgba(255, 255, 255, .25); font-size: 13px; letter-spacing: -2px; min-height: 24px; }
.kid-card-body { padding: 16px 20px 18px; }
.kid-card-body .link-arrow { display: block; text-align: right; }
.panel-kid { padding: 26px; border: 1.5px solid color-mix(in srgb, var(--c) 30%, var(--mix)); border-radius: 22px; background: var(--surface); margin-bottom: 24px; }
.panel-kid .card-title .ti { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--c) 12%, var(--mix)); font-size: 18px; }
.panel-kid .card-title .ti .ic { color: var(--c); }
.lesson-item { display: flex; align-items: center; gap: 18px; padding: 18px 20px; margin-bottom: 14px; background: var(--soft); border: 1.5px solid color-mix(in srgb, var(--c) 30%, var(--mix)); border-radius: 14px; }
.lesson-num { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff; font: 900 18px var(--heading); background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, var(--c2))); }
.lesson-item .row-title { font-weight: 700; font-family: var(--heading); }
.lesson-item .uploaded { color: var(--faint); font-size: 13.5px; margin-top: 4px; }
.lesson-item .btn { margin-left: auto; }
.viewed { color: var(--green); font-size: 13px; font-weight: 700; }
.act-item { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 14px; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 14px; }
.act-item.is-pending { background: #fffbeb; border-color: #fde68a; }
.act-item.is-overdue { background: #fef2f2; border-color: #fecaca; }
.act-item .row-title { font-family: var(--heading); font-weight: 800; }
.act-item .sub-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; flex: none; background: color-mix(in srgb, var(--c) 12%, var(--mix)); color: var(--c); }
.act-side { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.result-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; }
.result-card { background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 30%, var(--mix)); border-radius: 20px; overflow: hidden; }
.result-card-head { display: flex; align-items: center; gap: 10px; padding: 22px 20px; color: #fff; background: linear-gradient(120deg, var(--c), var(--c2)); }
.result-card-head strong { font: 900 18px var(--heading); }
.result-card-head .count { margin-left: auto; font: 800 14px var(--heading); opacity: .95; white-space: nowrap; }
.result-card-body { padding: 16px; }
.result-tile { padding: 14px 16px; margin-bottom: 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 30%, var(--mix)); background: color-mix(in srgb, var(--c) 9%, var(--mix)); }
.result-tile:last-child { margin-bottom: 0; }
.result-tile .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.result-tile .top b { color: var(--c); font: 900 16px var(--heading); white-space: nowrap; }
.result-tile .mid { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.result-tile .mid .progress { flex: 1; background: rgba(255, 255, 255, .8); }
.result-tile .when { color: var(--faint); font-size: 13px; }
.quiz-q { padding: 22px 24px; margin-bottom: 18px; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 25%, var(--mix)); border-radius: 18px; }
.quiz-q h3 { font: 800 18px var(--heading); margin-bottom: 14px; display: flex; gap: 10px; }
.quiz-q h3 .qn { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 15px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--soft); font-size: 16px; }
.option:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--mix)); }
.option input { width: 20px; height: 20px; accent-color: var(--c); flex: none; }
.option:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--mix)); font-weight: 700; }
.option .letter-badge { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); font: 800 13px var(--heading); flex: none; }
.option.correct { border-color: #22c55e; background: #f0fdf4; }
.option.wrong { border-color: #f87171; background: #fef2f2; }
.option .mark { margin-left: auto; font-weight: 800; font-size: 13px; }
.score-banner { display: flex; align-items: center; gap: 22px; padding: 26px 28px; margin-bottom: 22px; border-radius: 20px; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 30%, var(--mix)); }
.score-banner .big { font: 900 44px/1 var(--heading); color: var(--c); }
.score-banner .stars { font-size: 28px; letter-spacing: -2px; }
.feedback-box { padding: 16px 18px; border-radius: 14px; background: #f0f9ff; border: 1px solid #bae6fd; margin-top: 12px; }
.feedback-box small { color: var(--muted); display: block; margin-top: 6px; }
.feedback-box strong { display: block; margin-bottom: 4px; }

/* ----------------------------------------------------------------- Teacher quiz builder */
.q-row { padding: 18px 20px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.q-row-top { display: flex; gap: 12px; align-items: flex-start; }
.q-row-top .qn { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue-ink); font: 900 14px var(--heading); }
.q-row-top .q-text { flex: 1; font-weight: 600; }
.q-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 10px 0 0 42px; color: var(--text-2); font-size: 14.5px; }
.q-opts .ok { color: var(--green); font-weight: 700; }
.kv { display: flex; flex-wrap: wrap; gap: 10px 28px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }

/* ----------------------------------------------------------------- Login */
.login-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.login-top { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; background: var(--blue); color: #fff; box-shadow: 0 3px 0 rgba(96, 165, 250, .55); }
.login-top .school { padding: 7px 16px; border-radius: 99px; background: #fff; color: var(--blue); font: 800 13px var(--heading); letter-spacing: .3px; }
.login-center { flex: 1; display: grid; place-items: center; padding: 40px 20px; }
.login-card { display: grid; grid-template-columns: 1.1fr 1fr; width: 100%; max-width: 1125px; min-height: 605px; overflow: hidden; background: var(--surface); border-radius: 20px; box-shadow: 0 20px 50px rgba(15, 23, 42, .1); }
.login-info { display: flex; flex-direction: column; justify-content: center; padding: 56px 50px; background: #1d55db; color: #fff; }
.login-logo { width: 80px; height: 80px; border-radius: 18px; display: grid; place-items: center; font-size: 38px; background: rgba(255, 255, 255, .14); margin-bottom: 44px; }
.login-info h1 { font-size: 33px; font-weight: 900; line-height: 1.25; margin-bottom: 56px; }
.login-info ul { list-style: none; margin: 0; padding: 0; }
.login-info li { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; font-size: 16px; opacity: .95; }
.login-form { padding: 64px 46px; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { font-size: 27px; font-weight: 900; }
.login-form > p { color: var(--muted); margin: 8px 0 30px; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; margin-bottom: 30px; border-radius: 12px; background: var(--soft-2); }
.role-btn { padding: 12px 10px; border: 0; border-radius: 9px; background: none; color: var(--text-2); font: 800 15.5px var(--heading); cursor: pointer; }
.role-btn.active { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(29, 78, 216, .3); }
.role-btn .ic { color: var(--rc); }
.role-btn.active .ic { color: #fff; }
.login-form .field input { padding: 14px 16px; }
.login-btn { width: 100%; padding: 16px; margin-top: 8px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font: 900 17px var(--heading); cursor: pointer; }
.login-btn:hover { filter: brightness(1.06); }
.login-error { padding: 12px 14px; margin-bottom: 18px; border-radius: 10px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }

/* ----------------------------------------------------------------- Responsive */
@media (max-width: 1280px) {
    .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kid-grid, .result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
    .chat { grid-template-columns: 270px minmax(0, 1fr); }
    .user-meta { display: none; }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .menu-toggle { display: grid; place-items: center; }
    .sidebar { position: fixed; z-index: 50; top: 0; left: 0; width: 280px; height: 100vh; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 40px rgba(15, 23, 42, .25); }
    .sidebar.open { transform: none; }
    .sidebar-scrim.open { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(15, 23, 42, .4); }
    .main { padding: 22px 16px 40px; }
    .hero { flex-wrap: wrap; padding: 24px; }
    .hero-right { margin-left: 0; width: 100%; justify-content: space-between; }
    .hero-stat { text-align: left; }
    .login-card { grid-template-columns: 1fr; }
    .login-info { display: none; }
    .login-form { padding: 40px 26px; }
    .chat { grid-template-columns: 1fr; height: auto; }
    .chat-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 280px; }
    .chat-main { min-height: 480px; }
    .options, .q-opts { grid-template-columns: 1fr; }
    .profile-fields { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .subject-grid, .kid-grid, .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat { padding: 16px; gap: 12px; }
    .stat-icon { width: 44px; height: 44px; font-size: 21px; }
    .stat-num { font-size: 23px; }
    .brand-text span { display: none; }
    .brand-text strong { font-size: 16px; white-space: nowrap; }
    .brand-logo { width: 38px; height: 38px; }
    .topbar { padding: 0 12px; gap: 10px; }
    .greet { padding: 26px 22px; }
    .mascot { display: none; }
    .row-card, .lesson-item, .act-item, .person-row { flex-wrap: wrap; }
    .row-side, .act-side, .person-side { margin-left: 0; width: 100%; justify-content: flex-start; }
    .lesson-item .btn { margin-left: 0; }
    .field-row, .add-row { grid-template-columns: 1fr; }
    .modal { padding: 24px 20px; }
    .bubble { max-width: 88%; }
    .profile-main { flex-wrap: wrap; }
    .profile-main .btn { margin-left: 0; }
}
@media (max-width: 420px) {
    .subject-grid, .kid-grid, .result-grid { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------- Print (batch upload credentials) */
@media print {
    .topbar, .sidebar, .page-actions, .no-print, .flash { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    body { background: #fff; }
    .card, .table-wrap { box-shadow: none; }
}

/* ----------------------------------------------------------------- Dark mode
   One click on the moon / sun button in the top bar switches it (assets/js/app.js). The choice is saved in
   this browser and put on <html data-theme="dark"> by theme_head() before the page is drawn.
   Light mode uses the colours in :root above; dark mode swaps those colours and fixes the few fixed ones. */
.theme-btn { border: 0; color: inherit; cursor: pointer; }
.theme-btn .ic-sun, [data-theme="dark"] .theme-btn .ic-moon { display: none; }
[data-theme="dark"] .theme-btn .ic-sun { display: inline; }
.login-top-right { display: flex; align-items: center; gap: 12px; }
.theme-btn { flex: none; }
.table th.th-subject { color: var(--c); }
/* Phones: room for the extra button in the top bars */
@media (max-width: 640px) {
    .login-top { padding: 0 14px; gap: 10px; }
    .login-top-right { gap: 8px; }
    .login-top .school { padding: 5px 10px; font-size: 10.5px; line-height: 1.25; text-align: center; }
    .topbar-right { gap: 8px; flex: none; }
    .user-menu-btn .caret { display: none; }
    .brand, .brand-text { min-width: 0; }
    .brand-text strong { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) {
    .topbar .brand-text { display: none; }
}

@media screen {
    [data-theme="dark"] {
        color-scheme: dark;
        --bg: #0f172a;
        --card: #1e293b;
        --surface: #1e293b;
        --soft: #263347;
        --soft-2: #334155;
        --hover: #273449;
        --zebra: #213044;
        --line: #334155;
        --line-soft: #2a3649;
        --line-strong: #475569;
        --text: #e2e8f0;
        --text-2: #cbd5e1;
        --muted: #94a3b8;
        --faint: #8391a7;
        --nav-text: #cbd5e1;
        --nav-label: #8391a7;
        --mix: #1e293b;
        --blue-ink: #93c5fd;
        --blue-600: #60a5fa;
        --blue-50: rgba(96, 165, 250, .14);
        --blue-100: rgba(96, 165, 250, .28);
        --green: #4ade80;
        --green-50: rgba(74, 222, 128, .14);
        --yellow: #fbbf24;
        --yellow-50: rgba(251, 191, 36, .14);
        --red: #f87171;
        --red-50: rgba(248, 113, 113, .14);
        --purple: #c4b5fd;
        --purple-50: rgba(167, 139, 250, .16);
        --pink-50: rgba(244, 114, 182, .14);
        --orange: #fb923c;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .22);
    }

    /* Subject and icon colours are made lighter so they stay readable on dark cards */
    [data-theme="dark"] .chip-icon, [data-theme="dark"] .file-icon, [data-theme="dark"] .meta-row b, [data-theme="dark"] .link-arrow,
    [data-theme="dark"] .quick-item .qi, [data-theme="dark"] .tab.active, [data-theme="dark"] .row-icon:not(.done):not(.current):not(.wait),
    [data-theme="dark"] .tag, [data-theme="dark"] .nav-item.tinted.active, [data-theme="dark"] .panel-kid .card-title .ti .ic,
    [data-theme="dark"] .act-item .sub-icon, [data-theme="dark"] .result-tile .top b, [data-theme="dark"] .score-banner .big,
    [data-theme="dark"] .dashed-add:hover, [data-theme="dark"] .dropzone.dragover, [data-theme="dark"] .dropzone:hover,
    [data-theme="dark"] .table th.th-subject { color: color-mix(in srgb, var(--c) 60%, white); }
    [data-theme="dark"] .nav-icon .ic { color: color-mix(in srgb, currentColor 65%, white); }
    [data-theme="dark"] .role-btn:not(.active) .ic { color: color-mix(in srgb, var(--rc) 65%, white); }
    [data-theme="dark"] .text-purple { color: #a5b4fc; }
    [data-theme="dark"] .c-yellow, [data-theme="dark"] .stat-icon.bg-yellow, [data-theme="dark"] .row-icon.wait { color: #fdba74; }
    [data-theme="dark"] .c-pink, [data-theme="dark"] .stat-icon.bg-pink { color: #f9a8d4; }
    [data-theme="dark"] body:not(.role-student) .topbar .avatar { color: #1d4ed8; }
    [data-theme="dark"] .btn-outline { border-color: var(--blue-100); }
    [data-theme="dark"] .nav-item.active, [data-theme="dark"] .chat-item.active { box-shadow: inset 3px 0 0 var(--blue-600); }

    /* Messages, pills and scores */
    [data-theme="dark"] .flash-success, [data-theme="dark"] .btn-on { background: rgba(34, 197, 94, .14); color: #86efac; border-color: rgba(34, 197, 94, .35); }
    [data-theme="dark"] .flash-error, [data-theme="dark"] .btn-del, [data-theme="dark"] .login-error { background: rgba(239, 68, 68, .14); color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
    [data-theme="dark"] .flash-info { color: #bfdbfe; }
    [data-theme="dark"] .notice-yellow { background: rgba(245, 158, 11, .12); }
    [data-theme="dark"] .row-icon.current { background: rgba(250, 204, 21, .14); color: #fcd34d; }
    [data-theme="dark"] .pill-green, [data-theme="dark"] .score-good { background: rgba(34, 197, 94, .15); color: #86efac; border-color: rgba(34, 197, 94, .3); }
    [data-theme="dark"] .pill-yellow, [data-theme="dark"] .pill-current, [data-theme="dark"] .role-Parent, [data-theme="dark"] .score-mid { background: rgba(245, 158, 11, .14); color: #fcd34d; border-color: rgba(245, 158, 11, .35); }
    [data-theme="dark"] .pill-red, [data-theme="dark"] .role-Admin { color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
    [data-theme="dark"] .score-low { color: #fca5a5; }
    [data-theme="dark"] .pill-purple, [data-theme="dark"] .role-Student { color: #c4b5fd; border-color: rgba(167, 139, 250, .35); }
    [data-theme="dark"] .pill-orange, [data-theme="dark"] .score-wait { background: rgba(249, 115, 22, .14); color: #fdba74; border-color: rgba(249, 115, 22, .35); }
    [data-theme="dark"] .role-Teacher { background: rgba(16, 185, 129, .14); color: #6ee7b7; border-color: rgba(16, 185, 129, .35); }

    /* Student portal */
    [data-theme="dark"] .role-student .sidebar-profile { background: linear-gradient(135deg, rgba(139, 92, 246, .2), rgba(236, 72, 153, .12)); }
    [data-theme="dark"] .role-student .sidebar-profile strong { color: #c7d2fe; }
    [data-theme="dark"] .role-student .sidebar-profile small { color: #d8b4fe; }
    [data-theme="dark"] .role-student .nav-label { color: #c084fc; }
    [data-theme="dark"] .role-student .sidebar-foot strong { color: #c4b5fd; }
    [data-theme="dark"] .act-item.is-pending { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .35); }
    [data-theme="dark"] .act-item.is-overdue { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .35); }
    [data-theme="dark"] .option.correct { background: rgba(34, 197, 94, .12); }
    [data-theme="dark"] .option.wrong { background: rgba(239, 68, 68, .12); }
    [data-theme="dark"] .result-tile .mid .progress { background: rgba(255, 255, 255, .12); }
    [data-theme="dark"] .feedback-box { background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .3); }

    /* Shadows and overlays */
    [data-theme="dark"] .dropdown { box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
    [data-theme="dark"] .modal { box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
    [data-theme="dark"] .modal-backdrop { background: rgba(2, 6, 23, .7); }
    [data-theme="dark"] .login-card { box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
}
