
/* ==================================================================
   URDU
   ------------------------------------------------------------------
   Nafees Nastaleeq is declared with a unicode-range covering the
   Arabic script, so ANY Urdu character anywhere in the application
   picks it up on its own — a subject name, a student's name, a
   question, a remark, a complaint. Nothing has to be tagged, and
   nothing can be missed.

   Latin text is untouched: it never falls into that range.
   ================================================================== */

@font-face {
    font-family: 'Nafees Nastaleeq';
    src: url('../fonts/NafeesNastaleeq.ttf') format('truetype');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+060C, U+061B-061F, U+0600-06FF, U+0750-077F,
                   U+08A0-08FF, U+200C-200F, U+2010-2011,
                   U+FB50-FDFF, U+FE70-FEFF;
}

/* =====================================================================
   STUDY MANAGEMENT SYSTEM — GLASSMORPHIC 3D DESIGN SYSTEM
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    /* brand ramp */
    --brand-1: #6366f1;
    --brand-2: #8b5cf6;
    --brand-3: #d946ef;
    --accent:  #22d3ee;
    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    #3b82f6;

    /* dark surface stack */
    --bg-0: #070b18;
    --bg-1: #0b1124;
    --bg-2: #101a35;

    --glass:        rgba(255, 255, 255, .055);
    --glass-strong: rgba(255, 255, 255, .085);
    --glass-hover:  rgba(255, 255, 255, .11);
    --stroke:       rgba(255, 255, 255, .10);
    --stroke-soft:  rgba(255, 255, 255, .06);
    --stroke-bright:rgba(255, 255, 255, .20);

    --text-1: #eef2ff;
    --text-2: #a9b4d8;
    --text-3: #6f7ba3;

    /* elevation — layered for real depth */
    --sh-1: 0 1px 2px rgba(0,0,0,.30), 0 4px 12px rgba(0,0,0,.22);
    --sh-2: 0 2px 6px rgba(0,0,0,.32), 0 12px 30px rgba(0,0,0,.34);
    --sh-3: 0 4px 12px rgba(0,0,0,.34), 0 26px 60px rgba(0,0,0,.46);
    --sh-4: 0 10px 24px rgba(0,0,0,.38), 0 44px 100px rgba(0,0,0,.58);
    --glow: 0 0 0 1px rgba(139,92,246,.35), 0 12px 40px rgba(99,102,241,.32);

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 999px;

    --sidebar-w: 268px;
    --topbar-h: 74px;

    --ease: cubic-bezier(.22,1,.36,1);
    --ease-soft: cubic-bezier(.4,0,.2,1);

    /* Nastaliq comes first so Urdu characters find it; Latin falls
       straight through, because the face only claims the Arabic range */
    --font: 'Nafees Nastaleeq', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --urdu: 'Nafees Nastaleeq', 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
}

/* light theme */
[data-theme="light"] {
    --bg-0: #eef1f9;
    --bg-1: #f6f8fd;
    --bg-2: #ffffff;

    --glass:        rgba(255, 255, 255, .70);
    --glass-strong: rgba(255, 255, 255, .86);
    --glass-hover:  rgba(255, 255, 255, .95);
    --stroke:       rgba(15, 23, 42, .10);
    --stroke-soft:  rgba(15, 23, 42, .06);
    --stroke-bright:rgba(15, 23, 42, .18);

    --text-1: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;

    --sh-1: 0 1px 2px rgba(15,23,42,.05), 0 4px 12px rgba(15,23,42,.06);
    --sh-2: 0 2px 6px rgba(15,23,42,.07), 0 12px 30px rgba(15,23,42,.09);
    --sh-3: 0 4px 12px rgba(15,23,42,.08), 0 26px 60px rgba(15,23,42,.13);
    --sh-4: 0 10px 24px rgba(15,23,42,.10), 0 44px 100px rgba(15,23,42,.18);
    --glow: 0 0 0 1px rgba(139,92,246,.30), 0 12px 40px rgba(99,102,241,.22);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text-1);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* animated ambient background — the "depth" behind the glass */
body::before {
    content: '';
    position: fixed;
    inset: -20%;
    z-index: -2;
    background:
        radial-gradient(46rem 46rem at 12% 8%,  rgba(99,102,241,.28), transparent 62%),
        radial-gradient(40rem 40rem at 88% 12%, rgba(217,70,239,.20), transparent 60%),
        radial-gradient(50rem 50rem at 60% 92%, rgba(34,211,238,.16), transparent 62%),
        radial-gradient(36rem 36rem at 8% 88%,  rgba(139,92,246,.20), transparent 60%);
    filter: blur(20px);
    animation: drift 26s var(--ease-soft) infinite alternate;
}
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 20%, transparent 80%);
}
[data-theme="light"] body::before { opacity: .55; }
[data-theme="light"] body::after {
    background-image:
        linear-gradient(rgba(15,23,42,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15,23,42,.035) 1px, transparent 1px);
}

@keyframes drift {
    0%   { transform: translate3d(0,0,0) scale(1); }
    50%  { transform: translate3d(2%, -2%, 0) scale(1.06); }
    100% { transform: translate3d(-2%, 2%, 0) scale(1.02); }
}

img, video { display: block; max-width: 100%; }
svg { max-width: 100%; }

/* Inline icons sit on the text baseline instead of forcing their own line.
   Inside flex/grid parents they still centre exactly as before. */
.ic { display: inline-block; vertical-align: -0.16em; flex: 0 0 auto; }
h1 .ic, h2 .ic, h3 .ic, h4 .ic { margin-right: .12em; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { padding-left: 1.15rem; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--brand-1), var(--brand-2));
    border-radius: 99px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(var(--brand-2), var(--brand-3)); background-clip: content-box; }
::selection { background: rgba(139,92,246,.42); color: #fff; }

/* ---------- 3. Typography ---------- */
h1,h2,h3,h4,h5 { line-height: 1.22; font-weight: 700; letter-spacing: -.021em; }
h1 { font-size: clamp(1.55rem, 2.4vw, 2.05rem); }
h2 { font-size: clamp(1.25rem, 1.8vw, 1.55rem); }
h3 { font-size: 1.12rem; }
h4 { font-size: 1rem; }

.display {
    font-size: clamp(2rem, 4.2vw, 3.1rem);
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.06;
}

.grad-text {
    background: linear-gradient(110deg, var(--brand-1), var(--brand-2) 42%, var(--brand-3) 72%, var(--accent));
    background-size: 220% auto;
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    animation: shimmer 7s linear infinite;
}
@keyframes shimmer { to { background-position: 220% center; } }

.muted   { color: var(--text-2); }
.dim     { color: var(--text-3); }
.tiny    { font-size: .76rem; }
.small   { font-size: .855rem; }
.mono    { font-family: var(--mono); }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.truncate{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-3);
}

/* ---------- 4. Layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.028));
    backdrop-filter: blur(26px) saturate(150%);
    -webkit-backdrop-filter: blur(26px) saturate(150%);
    border-right: 1px solid var(--stroke);
    z-index: 60;
    transition: transform .38s var(--ease);
    overflow-y: auto;
    overflow-x: hidden;
}
[data-theme="light"] .sidebar {
    background: linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.65));
}

.brand {
    display: flex; align-items: center; gap: 12px;
    padding: 6px 8px 20px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--stroke-soft);
}
.brand-mark {
    width: 42px; height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));
    box-shadow: 0 8px 22px rgba(99,102,241,.48), inset 0 1px 0 rgba(255,255,255,.42);
    color: #fff;
    transform-style: preserve-3d;
    transition: transform .5s var(--ease);
}
.brand:hover .brand-mark { transform: rotateY(24deg) rotateX(-10deg) translateZ(8px); }
.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 1.03rem; line-height: 1.1; }
.brand-sub  { font-size: .68rem; color: var(--text-3); letter-spacing: .1em; text-transform: uppercase; }

.nav-group { margin-top: 14px; }
.nav-label {
    font-size: .66rem; letter-spacing: .17em; text-transform: uppercase;
    color: var(--text-3); font-weight: 700; padding: 0 12px 8px;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 13px;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-weight: 600;
    font-size: .905rem;
    position: relative;
    transition: all .24s var(--ease);
    border: 1px solid transparent;
}
.nav-item:hover {
    color: var(--text-1);
    background: var(--glass);
    border-color: var(--stroke-soft);
    transform: translateX(4px);
}
.nav-item.active {
    color: #fff;
    background: linear-gradient(100deg, rgba(99,102,241,.30), rgba(139,92,246,.16));
    border-color: rgba(139,92,246,.42);
    box-shadow: 0 6px 20px rgba(99,102,241,.26), inset 0 1px 0 rgba(255,255,255,.14);
}
[data-theme="light"] .nav-item.active { color: var(--brand-1); }
.nav-item.active::before {
    content: '';
    position: absolute; left: -16px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(var(--brand-2), var(--accent));
    box-shadow: 0 0 14px var(--brand-2);
}
.nav-item .ic { flex: 0 0 auto; opacity: .92; }
.nav-count {
    margin-left: auto;
    font-size: .7rem; font-weight: 700;
    padding: 2px 8px; border-radius: var(--r-pill);
    background: var(--glass-strong);
    border: 1px solid var(--stroke-soft);
    color: var(--text-2);
}

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--stroke-soft); }

.main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 14px;
    padding: 0 clamp(16px, 2.4vw, 32px);
    background: rgba(11,17,36,.55);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-bottom: 1px solid var(--stroke);
}
[data-theme="light"] .topbar { background: rgba(255,255,255,.66); }

.content {
    flex: 1 1 auto;
    padding: clamp(20px, 2.6vw, 34px) clamp(16px, 2.4vw, 32px) 60px;
    max-width: 1560px;
    width: 100%;
    margin: 0 auto;
}

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
    margin-bottom: 26px;
}
.page-head .sub { color: var(--text-2); margin-top: 6px; max-width: 62ch; }

/* ---------- 5. Glass surfaces ---------- */
.glass {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--stroke);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
}

.card {
    position: relative;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--stroke);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
    padding: 20px;
    overflow: hidden;
    transition: transform .4s var(--ease), box-shadow .4s var(--ease),
                border-color .3s var(--ease), background .3s var(--ease);
}
.card::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(150deg, rgba(255,255,255,.13), transparent 42%);
    opacity: .8;
}

.card-pad-0 { padding: 0; }

/* 3D tilt (JS adds the CSS vars) */
.tilt {
    transform-style: preserve-3d;
    will-change: transform;
}
.tilt:hover {
    border-color: var(--stroke-bright);
    box-shadow: var(--sh-4), inset 0 1px 0 rgba(255,255,255,.18);
    background: var(--glass-strong);
}
.tilt-inner { transform: translateZ(28px); transform-style: preserve-3d; }

/* moving highlight that follows the cursor */
.tilt::before {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity .35s var(--ease);
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
                rgba(255,255,255,.14), transparent 42%);
    z-index: 1;
}
.tilt:hover::before { opacity: 1; }

.lift { transition: transform .32s var(--ease), box-shadow .32s var(--ease); }
.lift:hover { transform: translateY(-4px); box-shadow: var(--sh-3); }

/* ---------- 6. Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 10px 18px;
    border-radius: var(--r-md);
    border: 1px solid var(--stroke);
    background: var(--glass-strong);
    color: var(--text-1);
    font-weight: 650;
    font-size: .9rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.12);
    transition: transform .2s var(--ease), box-shadow .25s var(--ease),
                background .25s var(--ease), border-color .25s var(--ease), filter .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.18); background: var(--glass-hover); border-color: var(--stroke-bright); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.30), transparent 80%);
    transform: translateX(-130%);
    transition: transform .7s var(--ease);
}
.btn:hover::after { transform: translateX(130%); }

.btn-primary {
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 20px rgba(99,102,241,.42), inset 0 1px 0 rgba(255,255,255,.30);
}
.btn-primary:hover { box-shadow: 0 12px 34px rgba(99,102,241,.55), inset 0 1px 0 rgba(255,255,255,.38); filter: brightness(1.06); }

.btn-accent  { background: linear-gradient(120deg, var(--accent), var(--info)); border-color: transparent; color: #04121a; box-shadow: 0 6px 20px rgba(34,211,238,.36); }
.btn-danger  { background: linear-gradient(120deg, #f43f5e, var(--danger)); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(239,68,68,.38); }
.btn-success { background: linear-gradient(120deg, #34d399, var(--success)); border-color: transparent; color: #04231a; box-shadow: 0 6px 20px rgba(16,185,129,.34); }
.btn-ghost   { background: transparent; box-shadow: none; border-color: var(--stroke-soft); }
.btn-ghost:hover { background: var(--glass); }

.btn-sm  { padding: 7px 13px; font-size: .82rem; border-radius: var(--r-sm); gap: 7px; }
.btn-xs  { padding: 5px 10px; font-size: .75rem; border-radius: 9px; gap: 5px; }
.btn-lg  { padding: 14px 26px; font-size: 1rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }

.icon-btn {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    display: grid; place-items: center;
    border-radius: var(--r-md);
    border: 1px solid var(--stroke);
    background: var(--glass-strong);
    color: var(--text-2);
    cursor: pointer;
    box-shadow: var(--sh-1);
    transition: all .24s var(--ease);
}
.icon-btn:hover { color: var(--text-1); background: var(--glass-hover); transform: translateY(-2px) rotate(-4deg); box-shadow: var(--sh-2); }
.icon-btn.sm { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; }
.icon-btn.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

/* ---------- 7. Forms ---------- */
.field { margin-bottom: 17px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 17px; }

.label {
    display: block;
    font-size: .795rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 7px;
    letter-spacing: .015em;
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--stroke);
    background: rgba(0,0,0,.20);
    color: var(--text-1);
    font-size: .92rem;
    transition: border-color .22s, box-shadow .22s, background .22s;
    box-shadow: inset 0 2px 6px rgba(0,0,0,.20);
}
[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea {
    background: rgba(255,255,255,.80);
    box-shadow: inset 0 2px 5px rgba(15,23,42,.05);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(139,92,246,.22), inset 0 2px 6px rgba(0,0,0,.20);
    background: rgba(0,0,0,.28);
}
[data-theme="light"] .input:focus,
[data-theme="light"] .select:focus,
[data-theme="light"] .textarea:focus { background: #fff; }

.textarea { min-height: 118px; resize: vertical; line-height: 1.62; }
.textarea.tall { min-height: 260px; }
.textarea.mono { font-family: var(--mono); font-size: .86rem; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a9b4d8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 38px;
    cursor: pointer;
}
.select option { background: var(--bg-1); color: var(--text-1); }

.hint { font-size: .765rem; color: var(--text-3); margin-top: 6px; }

/* search box */
.searchbox { position: relative; flex: 1 1 300px; max-width: 560px; }
.searchbox .ic {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}
.searchbox .input { padding-left: 44px; border-radius: var(--r-pill); }

/* colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
    width: 32px; height: 32px;
    border-radius: 11px;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.35);
    transition: transform .22s var(--ease), border-color .2s;
    position: relative;
}
.swatch:hover { transform: translateY(-3px) scale(1.1); }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch.on { border-color: #fff; transform: scale(1.14); }
[data-theme="light"] .swatch.on { border-color: var(--text-1); }

/* icon picker */
.icon-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--stroke);
    background: var(--glass);
    color: var(--text-2);
    cursor: pointer;
    transition: all .2s var(--ease);
    position: relative;
}
.icon-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.icon-opt:hover { transform: translateY(-2px); color: var(--text-1); }
.icon-opt.on { background: linear-gradient(130deg, var(--brand-1), var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 5px 16px rgba(99,102,241,.42); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
    width: 44px; height: 25px;
    border-radius: 99px;
    background: rgba(0,0,0,.35);
    border: 1px solid var(--stroke);
    position: relative;
    transition: background .25s var(--ease);
    box-shadow: inset 0 2px 5px rgba(0,0,0,.28);
}
.switch .track::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 19px; height: 19px;
    border-radius: 99px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
    transition: transform .28s var(--ease);
}
.switch input:checked + .track { background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(19px); }

/* dropzone */
.dropzone {
    border: 2px dashed var(--stroke-bright);
    border-radius: var(--r-lg);
    padding: 34px 22px;
    text-align: center;
    cursor: pointer;
    background: rgba(0,0,0,.16);
    transition: all .3s var(--ease);
    position: relative;
}
[data-theme="light"] .dropzone { background: rgba(255,255,255,.5); }
.dropzone:hover, .dropzone.over {
    border-color: var(--brand-2);
    background: rgba(139,92,246,.10);
    transform: scale(1.008);
    box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
.dropzone .dz-icon {
    width: 62px; height: 62px;
    margin: 0 auto 14px;
    border-radius: 19px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--brand-1), var(--brand-2));
    color: #fff;
    box-shadow: 0 10px 28px rgba(99,102,241,.42), inset 0 1px 0 rgba(255,255,255,.35);
    animation: float 3.4s var(--ease-soft) infinite;
}
@keyframes float { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-7px);} }
.dropzone input[type=file] { display: none; }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.file-row {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 13px;
    border-radius: var(--r-sm);
    background: var(--glass-strong);
    border: 1px solid var(--stroke-soft);
    font-size: .85rem;
    animation: slideIn .3s var(--ease);
}
@keyframes slideIn { from { opacity:0; transform: translateY(-6px);} to { opacity:1; transform:none;} }

/* ---------- 8. Grids ---------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); }
/* strict 3-across for YouTube cards on wide screens */
.grid-yt { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
@media (min-width: 1180px) { .grid-yt { grid-template-columns: repeat(3, 1fr); } }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 7px; }
.spread{ display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.spread > * { min-width: 0; }
.ml-auto { margin-left: auto; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 34px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ---------- 9. Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }

.stat {
    position: relative;
    padding: 20px;
    border-radius: var(--r-lg);
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--stroke);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
    overflow: hidden;
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.stat:hover { transform: translateY(-5px) scale(1.014); box-shadow: var(--sh-3); }
.stat::before {
    content: '';
    position: absolute; right: -34px; top: -34px;
    width: 118px; height: 118px;
    border-radius: 50%;
    background: var(--tint, var(--brand-1));
    opacity: .16;
    filter: blur(22px);
}
.stat-ic {
    width: 44px; height: 44px;
    border-radius: 14px;
    display: grid; place-items: center;
    margin-bottom: 14px;
    color: #fff;
    background: linear-gradient(140deg, var(--tint, var(--brand-1)), var(--tint2, var(--brand-2)));
    box-shadow: 0 8px 20px var(--tint-glow, rgba(99,102,241,.40)), inset 0 1px 0 rgba(255,255,255,.35);
}
.stat-val { font-size: 2.05rem; font-weight: 800; letter-spacing: -.032em; line-height: 1; }
.stat-lab { font-size: .79rem; color: var(--text-2); margin-top: 7px; font-weight: 600; }

/* ---------- 10. Category / subject cards ---------- */
.cat-card, .subj-card {
    position: relative;
    display: block;
    border-radius: var(--r-lg);
    padding: 22px;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--stroke);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
    overflow: hidden;
    transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .3s;
}
.cat-card::before, .subj-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(150deg, var(--tint, var(--brand-1)) 0%, transparent 55%);
    opacity: .13;
    transition: opacity .4s var(--ease);
}
.cat-card:hover::before, .subj-card:hover::before { opacity: .24; }

.card-bar {
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(var(--tint, var(--brand-1)), transparent);
}

.card-ic {
    width: 50px; height: 50px;
    border-radius: 16px;
    display: grid; place-items: center;
    color: #fff;
    background: linear-gradient(140deg, var(--tint, var(--brand-1)), color-mix(in srgb, var(--tint, var(--brand-1)) 55%, #000));
    box-shadow: 0 9px 24px var(--tint-glow, rgba(99,102,241,.38)), inset 0 1px 0 rgba(255,255,255,.35);
    flex: 0 0 50px;
    transition: transform .45s var(--ease);
}
.tilt:hover .card-ic { transform: rotateY(20deg) rotateX(-8deg) translateZ(14px) scale(1.06); }

.card-title { font-weight: 700; font-size: 1.06rem; letter-spacing: -.015em; }
.card-desc  { color: var(--text-2); font-size: .855rem; margin-top: 7px; min-height: 2.6em; }

.card-meta {
    display: flex; flex-wrap: wrap; gap: 7px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--stroke-soft);
}

.card-actions {
    position: absolute; top: 12px; right: 12px;
    display: flex; gap: 6px;
    opacity: 0;
    transform: translateY(-6px);
    transition: all .28s var(--ease);
    z-index: 4;
}
.cat-card:hover .card-actions, .subj-card:hover .card-actions, .mat-card:hover .card-actions { opacity: 1; transform: none; }

/* ---------- 11. Chips / badges ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: .735rem;
    font-weight: 650;
    background: var(--glass-strong);
    border: 1px solid var(--stroke-soft);
    color: var(--text-2);
    white-space: nowrap;
}
.chip .ic { width: 13px; height: 13px; }
.chip-tint { background: var(--tint-soft, rgba(99,102,241,.16)); border-color: var(--tint-line, rgba(99,102,241,.34)); color: var(--tint-text, #c7d2fe); }
[data-theme="light"] .chip-tint { color: var(--tint, var(--brand-1)); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 8px;
    font-size: .69rem; font-weight: 750;
    text-transform: uppercase; letter-spacing: .06em;
}
.badge-success { background: rgba(16,185,129,.18); color: #6ee7b7; border: 1px solid rgba(16,185,129,.32); }
.badge-warning { background: rgba(245,158,11,.18); color: #fcd34d; border: 1px solid rgba(245,158,11,.32); }
.badge-danger  { background: rgba(239,68,68,.18);  color: #fca5a5; border: 1px solid rgba(239,68,68,.32); }
.badge-info    { background: rgba(59,130,246,.18); color: #93c5fd; border: 1px solid rgba(59,130,246,.32); }
.badge-muted   { background: var(--glass-strong);  color: var(--text-3); border: 1px solid var(--stroke-soft); }
[data-theme="light"] .badge-success { color: #047857; }
[data-theme="light"] .badge-warning { color: #b45309; }
[data-theme="light"] .badge-danger  { color: #b91c1c; }
[data-theme="light"] .badge-info    { color: #1d4ed8; }

/* progress */
.progress {
    height: 6px;
    border-radius: 99px;
    background: rgba(0,0,0,.3);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
[data-theme="light"] .progress { background: rgba(15,23,42,.10); }
.progress .bar {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--tint, var(--brand-1)), var(--accent));
    box-shadow: 0 0 12px var(--tint, var(--brand-1));
    transition: width .8s var(--ease);
}

/* ---------- 12. Tabs ---------- */
.tabs {
    display: flex; gap: 6px;
    padding: 6px;
    border-radius: var(--r-lg);
    background: var(--glass);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.08);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 15px;
    border-radius: var(--r-md);
    font-size: .865rem;
    font-weight: 650;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    background: transparent;
    transition: all .25s var(--ease);
}
.tab:hover { color: var(--text-1); background: var(--glass-strong); }
.tab.active {
    color: #fff;
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
    box-shadow: 0 5px 18px rgba(99,102,241,.40), inset 0 1px 0 rgba(255,255,255,.28);
}
.tab .n {
    font-size: .7rem;
    padding: 1px 7px;
    border-radius: 99px;
    background: rgba(0,0,0,.28);
    font-weight: 700;
}
.tab.active .n { background: rgba(255,255,255,.24); }

.tab-panel { display: none; animation: fadeUp .4s var(--ease); }
.tab-panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- 13. Material cards ---------- */
.mat-card {
    position: relative;
    border-radius: var(--r-lg);
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--stroke);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
    overflow: hidden;
    transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .3s;
    display: flex; flex-direction: column;
}
.mat-card:hover { border-color: var(--stroke-bright); box-shadow: var(--sh-4); }

.mat-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(140deg, rgba(255,255,255,.07), rgba(0,0,0,.25));
    overflow: hidden;
    display: grid; place-items: center;
}
.mat-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .6s var(--ease);
}
.mat-card:hover .mat-thumb img { transform: scale(1.07); }

.mat-thumb .ph {
    width: 56px; height: 56px;
    border-radius: 18px;
    display: grid; place-items: center;
    color: #fff;
    background: linear-gradient(140deg, var(--tint, var(--brand-1)), color-mix(in srgb, var(--tint, var(--brand-1)) 50%, #000));
    box-shadow: 0 10px 26px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.30);
}

.play-badge {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    background: linear-gradient(to top, rgba(0,0,0,.62), rgba(0,0,0,.06));
    opacity: 0;
    transition: opacity .3s var(--ease);
}
.mat-card:hover .play-badge { opacity: 1; }
.play-badge span {
    width: 56px; height: 56px;
    border-radius: 99px;
    display: grid; place-items: center;
    background: rgba(255,0,51,.94);
    color: #fff;
    box-shadow: 0 10px 30px rgba(255,0,51,.5);
    transform: scale(.75);
    transition: transform .35s var(--ease);
    padding-left: 3px;
}
.mat-card:hover .play-badge span { transform: scale(1); }

.mat-dur {
    position: absolute; right: 9px; bottom: 9px;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(0,0,0,.82);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    font-family: var(--mono);
}
.mat-type-tag {
    position: absolute; left: 9px; top: 9px;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 8px;
    background: rgba(0,0,0,.66);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: .67rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.mat-body { padding: 15px 16px 16px; flex: 1 1 auto; display: flex; flex-direction: column; }
.mat-title { font-weight: 700; font-size: .95rem; line-height: 1.36; }
.mat-sub { font-size: .78rem; color: var(--text-3); margin-top: 6px; }
.mat-foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: auto; padding-top: 13px;
    border-top: 1px solid var(--stroke-soft);
    font-size: .74rem; color: var(--text-3);
}

/* list-style material row */
.mat-row {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 16px;
    border-radius: var(--r-md);
    background: var(--glass);
    border: 1px solid var(--stroke-soft);
    transition: all .28s var(--ease);
}
.mat-row:hover { background: var(--glass-strong); border-color: var(--stroke-bright); transform: translateX(5px); box-shadow: var(--sh-2); }
.mat-row .mr-ic {
    width: 42px; height: 42px; flex: 0 0 42px;
    border-radius: 13px;
    display: grid; place-items: center;
    color: #fff;
    background: linear-gradient(140deg, var(--tint, var(--brand-1)), color-mix(in srgb, var(--tint, var(--brand-1)) 50%, #000));
    box-shadow: 0 6px 16px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.3);
}

/* note card */
.note-card {
    position: relative;
    border-radius: var(--r-lg);
    padding: 20px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--stroke);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.10);
    transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.note-card:hover { transform: translateY(-3px); box-shadow: var(--sh-3); }
.note-card::before {
    content: '';
    position: absolute; left: 0; top: 16px; bottom: 16px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: linear-gradient(var(--accent), var(--brand-2));
}
.note-body {
    color: var(--text-2);
    font-size: .89rem;
    line-height: 1.72;
    max-height: 240px;
    overflow: hidden;
    position: relative;
}
.note-body.open { max-height: none; }
.note-body h2, .note-body h3, .note-body h4 { color: var(--text-1); margin: 14px 0 7px; }
.note-body ul { margin: 8px 0; }
.note-body code { font-family: var(--mono); font-size: .84em; background: rgba(0,0,0,.32); padding: 2px 6px; border-radius: 5px; color: var(--accent); }
.note-body pre { background: rgba(0,0,0,.34); padding: 13px; border-radius: var(--r-sm); overflow-x: auto; margin: 10px 0; border: 1px solid var(--stroke-soft); }
.note-body pre code { background: none; padding: 0; color: var(--text-2); }
.note-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="light"] .note-body code { background: rgba(15,23,42,.06); color: #0e7490; }
[data-theme="light"] .note-body pre  { background: rgba(15,23,42,.05); }

/* ---------- 14. Topic cards ---------- */
.topic-card {
    position: relative;
    display: block;
    padding: 18px 20px;
    border-radius: var(--r-md);
    background: var(--glass);
    border: 1px solid var(--stroke);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.08);
    transition: all .32s var(--ease);
    overflow: hidden;
}
.topic-card:hover {
    background: var(--glass-strong);
    border-color: var(--stroke-bright);
    transform: translateY(-3px);
    box-shadow: var(--sh-3);
}
.topic-num {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 11px;
    display: grid; place-items: center;
    font-weight: 800; font-size: .82rem;
    background: linear-gradient(140deg, var(--tint, var(--accent)), color-mix(in srgb, var(--tint, var(--accent)) 45%, #000));
    color: #fff;
    box-shadow: 0 5px 14px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.32);
}

/* ---------- 15. Modal ---------- */
.modal {
    position: fixed; inset: 0;
    z-index: 200;
    display: none;
    align-items: flex-start; justify-content: center;
    padding: 28px 16px;
    overflow-y: auto;
    background: rgba(4,7,18,.68);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}
.modal.open { display: flex; animation: fadeIn .25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    width: 100%;
    max-width: 640px;
    margin: auto;
    border-radius: var(--r-xl);
    background: linear-gradient(150deg, rgba(255,255,255,.11), rgba(255,255,255,.045));
    backdrop-filter: blur(34px) saturate(160%);
    -webkit-backdrop-filter: blur(34px) saturate(160%);
    border: 1px solid var(--stroke-bright);
    box-shadow: var(--sh-4), inset 0 1px 0 rgba(255,255,255,.20);
    animation: popIn .42s var(--ease);
    overflow: hidden;
}
[data-theme="light"] .modal-box { background: linear-gradient(150deg, rgba(255,255,255,.96), rgba(255,255,255,.90)); }
.modal-box.wide { max-width: 880px; }
@keyframes popIn {
    from { opacity: 0; transform: translateY(28px) scale(.95) rotateX(6deg); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    display: flex; align-items: center; gap: 13px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--stroke-soft);
}
.modal-head h3 { flex: 1 1 auto; }
.modal-body { padding: 24px; max-height: min(72vh, 760px); overflow-y: auto; }

/* Long forms (add material, edit subject): let the whole overlay scroll instead
   of trapping the submit button inside an inner scroll area. */
.modal-box.wide .modal-body { max-height: none; overflow: visible; }
.modal-box.wide .modal-head {
    position: sticky; top: 0; z-index: 3;
    background: rgba(11,17,36,.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
[data-theme="light"] .modal-box.wide .modal-head { background: rgba(255,255,255,.94); }
.modal-foot {
    display: flex; gap: 11px; justify-content: flex-end;
    padding: 18px 24px;
    border-top: 1px solid var(--stroke-soft);
    background: rgba(0,0,0,.14);
}
[data-theme="light"] .modal-foot { background: rgba(15,23,42,.03); }

/* lightbox */
.lightbox {
    position: fixed; inset: 0; z-index: 300;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(2,4,12,.94);
    backdrop-filter: blur(11px);
    -webkit-backdrop-filter: blur(11px);
    padding: 24px;
}
.lightbox.open { display: flex; animation: fadeIn .2s; }
.lightbox img, .lightbox iframe, .lightbox video {
    max-width: min(1240px, 94vw);
    max-height: 90vh;
    border-radius: var(--r-lg);
    box-shadow: var(--sh-4);
    background: #000;
}
.lightbox iframe { width: min(1240px, 94vw); aspect-ratio: 16/9; height: auto; border: 0; }
.lightbox .lb-close {
    position: absolute; top: 22px; right: 22px;
    width: 46px; height: 46px;
    border-radius: 99px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.22);
    color: #fff; cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all .25s var(--ease);
}
.lightbox .lb-close:hover { background: var(--danger); transform: rotate(90deg) scale(1.08); }

/* ---------- 16. Toast / flash ---------- */
.toasts {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 400;
    display: flex; flex-direction: column; gap: 11px;
    max-width: 380px;
}
.toast {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 17px;
    border-radius: var(--r-md);
    background: rgba(16,26,53,.92);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid var(--stroke-bright);
    box-shadow: var(--sh-3);
    font-size: .875rem;
    animation: toastIn .45s var(--ease);
    position: relative;
    overflow: hidden;
}
[data-theme="light"] .toast { background: rgba(255,255,255,.96); }
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-2); }
.toast.success::before { background: var(--success); }
.toast.error::before   { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast .t-ic { flex: 0 0 auto; margin-top: 1px; }
.toast.success .t-ic { color: var(--success); }
.toast.error .t-ic   { color: var(--danger); }
.toast.warning .t-ic { color: var(--warning); }
.toast.info .t-ic    { color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(90px) scale(.9);} to { opacity:1; transform: none;} }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(90px) scale(.9); } }

/* ---------- 17. Empty state ---------- */
.empty {
    text-align: center;
    padding: 66px 24px;
    border-radius: var(--r-xl);
    background: var(--glass);
    border: 1px dashed var(--stroke-bright);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.empty .e-ic {
    width: 82px; height: 82px;
    margin: 0 auto 20px;
    border-radius: 26px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, rgba(99,102,241,.30), rgba(139,92,246,.16));
    border: 1px solid var(--stroke-bright);
    color: var(--brand-2);
    box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.20);
    animation: float 4s var(--ease-soft) infinite;
}
.empty h3 { margin-bottom: 9px; }
.empty p  { color: var(--text-2); max-width: 46ch; margin: 0 auto 22px; }

/* ---------- 18. Breadcrumb ---------- */
.crumbs {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
    font-size: .83rem;
    color: var(--text-3);
    margin-bottom: 16px;
}
.crumbs a { color: var(--text-2); font-weight: 600; transition: color .2s; }
.crumbs a:hover { color: var(--brand-2); }
.crumbs .ic { opacity: .5; }

/* ---------- 19. Hero panel ---------- */
.hero {
    position: relative;
    padding: clamp(24px, 3.4vw, 40px);
    border-radius: var(--r-xl);
    background: linear-gradient(135deg, rgba(99,102,241,.24), rgba(139,92,246,.13) 46%, rgba(34,211,238,.10));
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    border: 1px solid var(--stroke-bright);
    box-shadow: var(--sh-3), inset 0 1px 0 rgba(255,255,255,.18);
    overflow: hidden;
    margin-bottom: 26px;
}
.hero::before {
    content: '';
    position: absolute; right: -80px; top: -80px;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139,92,246,.42), transparent 70%);
    filter: blur(30px);
    animation: pulse 8s var(--ease-soft) infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.16); opacity: 1; } }
.hero-inner { position: relative; z-index: 2; }

/* ---------- 20. Voice recorder ---------- */
.recorder {
    display: flex; align-items: center; gap: 16px;
    padding: 20px;
    border-radius: var(--r-lg);
    background: rgba(0,0,0,.22);
    border: 1px solid var(--stroke);
}
[data-theme="light"] .recorder { background: rgba(255,255,255,.6); }
.rec-btn {
    width: 66px; height: 66px; flex: 0 0 66px;
    border-radius: 99px;
    border: none;
    display: grid; place-items: center;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(140deg, #f43f5e, var(--danger));
    box-shadow: 0 10px 28px rgba(239,68,68,.45), inset 0 1px 0 rgba(255,255,255,.3);
    transition: all .3s var(--ease);
}
.rec-btn:hover { transform: scale(1.06); }
.rec-btn.recording { animation: recPulse 1.5s ease-in-out infinite; }
@keyframes recPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6), 0 10px 28px rgba(239,68,68,.45); }
    50%     { box-shadow: 0 0 0 18px rgba(239,68,68,0), 0 10px 28px rgba(239,68,68,.45); }
}
.rec-time { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.rec-wave { display: flex; align-items: center; gap: 3px; height: 34px; }
.rec-wave i {
    width: 3px; height: 8px;
    border-radius: 99px;
    background: linear-gradient(var(--brand-2), var(--accent));
    animation: wave 1.1s ease-in-out infinite;
}
.rec-wave i:nth-child(2n) { animation-delay: .12s; }
.rec-wave i:nth-child(3n) { animation-delay: .26s; }
.rec-wave i:nth-child(4n) { animation-delay: .4s; }
.rec-wave i:nth-child(5n) { animation-delay: .18s; }
@keyframes wave { 0%,100% { height: 8px; opacity: .5; } 50% { height: 30px; opacity: 1; } }

audio { width: 100%; height: 40px; border-radius: var(--r-pill); }

/* ---------- 21. Filter panel ---------- */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 13px;
    padding: 18px;
    border-radius: var(--r-lg);
    background: var(--glass);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--sh-1), inset 0 1px 0 rgba(255,255,255,.08);
    margin-bottom: 22px;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.fchip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px;
    border-radius: var(--r-pill);
    font-size: .81rem; font-weight: 650;
    background: var(--glass);
    border: 1px solid var(--stroke);
    color: var(--text-2);
    cursor: pointer;
    transition: all .25s var(--ease);
}
.fchip:hover { color: var(--text-1); background: var(--glass-hover); transform: translateY(-2px); }
.fchip.on {
    color: #fff;
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
    border-color: transparent;
    box-shadow: 0 5px 16px rgba(99,102,241,.4);
}

/* ---------- 22. Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--stroke); background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.tbl th {
    text-align: left;
    padding: 13px 16px;
    font-size: .72rem; font-weight: 750;
    text-transform: uppercase; letter-spacing: .09em;
    color: var(--text-3);
    border-bottom: 1px solid var(--stroke);
    white-space: nowrap;
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--stroke-soft); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .2s; }
table.tbl tbody tr:hover { background: var(--glass-strong); }

/* ---------- 23. Timeline ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute; left: 8px; top: 6px; bottom: 6px;
    width: 2px;
    background: linear-gradient(var(--brand-2), transparent);
}
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before {
    content: '';
    position: absolute; left: -24px; top: 6px;
    width: 10px; height: 10px;
    border-radius: 99px;
    background: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(139,92,246,.20), 0 0 12px var(--brand-2);
}

/* ---------- 24. Auth page ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 28px 18px;
}
.auth-card {
    width: 100%; max-width: 430px;
    padding: 38px 34px;
    border-radius: var(--r-xl);
    background: linear-gradient(155deg, rgba(255,255,255,.12), rgba(255,255,255,.05));
    backdrop-filter: blur(34px) saturate(160%);
    -webkit-backdrop-filter: blur(34px) saturate(160%);
    border: 1px solid var(--stroke-bright);
    box-shadow: var(--sh-4), inset 0 1px 0 rgba(255,255,255,.22);
    animation: popIn .6s var(--ease);
    position: relative;
    overflow: hidden;
}
[data-theme="light"] .auth-card { background: linear-gradient(155deg, rgba(255,255,255,.95), rgba(255,255,255,.85)); }
.auth-logo {
    width: 68px; height: 68px;
    margin: 0 auto 20px;
    border-radius: 21px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--brand-1), var(--brand-2) 50%, var(--brand-3));
    color: #fff;
    box-shadow: 0 14px 38px rgba(99,102,241,.5), inset 0 1px 0 rgba(255,255,255,.4);
    animation: float 4.4s var(--ease-soft) infinite;
}

/* ---------- 25. Utilities & animations ---------- */
.fade-up { animation: fadeUp .55s var(--ease) both; }
.d1 { animation-delay: .05s; } .d2 { animation-delay: .1s; } .d3 { animation-delay: .15s; }
.d4 { animation-delay: .2s; }  .d5 { animation-delay: .25s; } .d6 { animation-delay: .3s; }

.skeleton {
    background: linear-gradient(90deg, var(--glass) 25%, var(--glass-hover) 50%, var(--glass) 75%);
    background-size: 200% 100%;
    animation: shine 1.5s linear infinite;
    border-radius: var(--r-sm);
}
@keyframes shine { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--stroke-soft); margin: 22px 0; border: 0; }

.scroll-x { overflow-x: auto; scrollbar-width: thin; }

.embed-16x9 { position: relative; aspect-ratio: 16/9; border-radius: var(--r-md); overflow: hidden; background: #000; box-shadow: var(--sh-2); }
.embed-16x9 iframe, .embed-16x9 video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.pdf-frame { width: 100%; height: min(80vh, 900px); border: 1px solid var(--stroke); border-radius: var(--r-md); background: #1e1e1e; }

/* ---------- 26. Mobile ---------- */
.menu-toggle { display: none; }
.sb-backdrop {
    position: fixed; inset: 0;
    background: rgba(2,4,12,.6);
    backdrop-filter: blur(4px);
    z-index: 55;
    display: none;
}
.sb-backdrop.show { display: block; animation: fadeIn .25s; }

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
        box-shadow: var(--sh-4);
    }
    .sidebar.open { transform: none; }
    .menu-toggle { display: grid; }
}

@media (max-width: 720px) {
    body { font-size: 14.5px; }
    .content { padding: 18px 14px 48px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .stat { padding: 16px; }
    .stat-val { font-size: 1.65rem; }
    .grid { gap: 14px; }
    .grid-3, .grid-4, .grid-yt { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .page-head { margin-bottom: 20px; }
    .modal { padding: 12px; }
    .modal-body { padding: 18px; max-height: 72vh; }
    .modal-head, .modal-foot { padding: 16px 18px; }
    .hide-sm { display: none !important; }
    .toasts { left: 12px; right: 12px; max-width: none; }

    /* hero: never let the action column sit on top of the title */
    .hero .spread > * { flex: 1 1 100% !important; }
    .hero .stack { flex-direction: row; flex-wrap: wrap; }
    .hero .stack > .btn { flex: 1 1 140px; }
    .hero h1 { font-size: 1.5rem; }
    .card-ic { width: 44px; height: 44px; flex-basis: 44px; border-radius: 14px; }
}

@media (max-width: 480px) {
    .grid-3, .grid-4, .grid-yt, .grid-2 { grid-template-columns: 1fr; }
    .btn { padding: 9px 15px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    body::before { animation: none; }
}

@media print {
    .sidebar, .topbar, .card-actions, .btn, .tabs { display: none !important; }
    body::before, body::after { display: none; }
    body { background: #fff; color: #000; }
}

/* ---------- answer rows (used by the exam, practice feedback, learning
   mode and the result page — defined here so every page gets them) ---------- */
.opt-row { display: flex; align-items: center; gap: 13px; padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--stroke-soft); background: var(--glass); font-size: .94rem; }
.opt-row .opt-l { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: .82rem; background: var(--glass-strong);
  border: 1px solid var(--stroke); color: var(--text-2); }
.opt-row.right { border-color: rgba(16,185,129,.55); background: rgba(16,185,129,.12); }
.opt-row.right .opt-l { background: var(--success); border-color: transparent; color: #042a20; }
.opt-row.wrong { border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.10); }
.opt-row.wrong .opt-l { background: var(--danger); border-color: transparent; color: #fff; }


/* hidden a little earlier than .hide-sm — for chrome that crowds a busy
   top bar long before the phone breakpoint */
@media (max-width: 1080px) {
    .hide-md { display: none !important; }
}


/* the way into the administrator's own study space */
.to-study {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, .42);
    background: rgba(251, 191, 36, .12);
    white-space: nowrap;
}
.to-study:hover {
    color: #fde68a;
    border-color: #fbbf24;
    background: rgba(251, 191, 36, .22);
}


/* ==================================================================
   URDU — direction and spacing
   ------------------------------------------------------------------
   Nastaliq hangs a long way below the baseline and needs more room
   than a Latin face. `.ur` is put on by the script that finds Urdu
   text, so these rules reach it wherever it turns up.
   ================================================================== */

.ur {
    font-family: var(--urdu);
    line-height: 2.05;
    font-size: 1.12em;
    letter-spacing: 0;
}

/* a block that is wholly Urdu reads from the right */
.ur-block {
    direction: rtl;
    text-align: right;
    unicode-bidi: isolate;
}

/* a cell or a heading that is Urdu, inside a left-to-right table */
td.ur, th.ur, li.ur, p.ur, span.ur, strong.ur, h1.ur, h2.ur, h3.ur, h4.ur, a.ur {
    unicode-bidi: isolate;
}

/* typing Urdu: the box turns round as soon as the first letter lands,
   which is what dir="auto" is for */
.input[dir="auto"], .select[dir="auto"], textarea[dir="auto"] { text-align: start; }

.input.ur, textarea.ur {
    font-family: var(--urdu);
    font-size: 1.1em;
    line-height: 2;
    padding-top: .5em;
    padding-bottom: .5em;
}

/* Urdu inside a note or an explanation */
.note-body .ur, .msg-text.ur, .question-text.ur { line-height: 2.1 }

/* a hint that the app understands Urdu, shown beside fields that often hold it */
.ur-hint {
    font-family: var(--urdu);
    font-size: .95rem;
    color: var(--text-3);
    direction: rtl;
}

/* ---------- 24. Messenger ---------- */
.msgr{display:grid;grid-template-columns:320px minmax(0,1fr);gap:0;
  height:calc(100vh - var(--topbar-h) - 40px);min-height:520px;
  border:1px solid var(--stroke);border-radius:var(--r-lg);overflow:hidden;background:var(--glass)}

.msgr-list{display:flex;flex-direction:column;min-width:0;border-right:1px solid var(--stroke);
  background:var(--bg-1)}
.msgr-list-head{display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:14px 15px;border-bottom:1px solid var(--stroke-soft)}
.msgr-list-head h2{margin:0;font-size:1rem;display:flex;align-items:center;gap:8px}
.msgr-search{padding:10px 12px;border-bottom:1px solid var(--stroke-soft)}
.msgr-search .input{padding:8px 11px;font-size:.85rem}
.msgr-threads{flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain}

.msgr-thread{display:flex;gap:11px;padding:11px 13px;border-bottom:1px solid var(--stroke-soft);
  transition:background .16s var(--ease);align-items:flex-start}
.msgr-thread:hover{background:var(--glass)}
.msgr-thread.on{background:var(--glass-strong);
  box-shadow:inset 3px 0 0 var(--brand-1)}
.msgr-thread-body{min-width:0;flex:1 1 auto;display:flex;flex-direction:column;gap:2px}
.msgr-thread strong{font-size:.88rem;font-weight:650}
.msgr-preview{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:190px}
.msgr-unread{flex:0 0 auto;min-width:19px;height:19px;padding:0 5px;border-radius:99px;
  background:var(--brand-1);color:#fff;font-size:.68rem;font-weight:700;
  display:grid;place-items:center}
.msgr-unread.hide{display:none}

.msgr-chat{display:flex;flex-direction:column;min-width:0;background:var(--bg-0)}
.msgr-head{display:flex;align-items:center;gap:12px;padding:12px 16px;
  border-bottom:1px solid var(--stroke);background:var(--bg-1)}
.msgr-head strong{display:block;font-size:.95rem}
.msgr-back{display:none}
.msgr-live{margin-left:auto;display:flex;align-items:center;gap:6px}
.msgr-live .dot{width:7px;height:7px;border-radius:99px;background:var(--success);
  animation:msgrPulse 2.4s var(--ease) infinite}
.msgr-live.stale .dot{background:var(--warning);animation:none}
@keyframes msgrPulse{0%,100%{opacity:1}50%{opacity:.25}}

.msgr-body{flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;padding:16px;
  display:flex;flex-direction:column;gap:9px}
.msgr-disclosure{color:var(--text-3);text-align:center;padding:6px 12px;margin:0 auto 6px;
  background:var(--glass);border:1px solid var(--stroke-soft);border-radius:99px;
  display:inline-flex;align-items:center;gap:6px;align-self:center}
.msgr-day{text-align:center;margin:8px 0 4px}
.msgr-day span{font-size:.72rem;color:var(--text-3);background:var(--glass);
  border:1px solid var(--stroke-soft);border-radius:99px;padding:3px 11px}

.msgr-msg{display:flex;gap:8px;align-items:flex-end;max-width:76%}
.msgr-msg.mine{margin-left:auto;flex-direction:row-reverse}
.msgr-bubble{position:relative;padding:9px 12px 18px;border-radius:14px;
  background:var(--glass-strong);border:1px solid var(--stroke-soft);min-width:0}
.msgr-msg.mine .msgr-bubble{background:linear-gradient(135deg,var(--brand-1),var(--brand-2));
  border-color:transparent;color:#fff}
.msgr-bubble p{margin:0;font-size:.9rem;line-height:1.5;word-break:break-word;white-space:pre-wrap}
.msgr-when{position:absolute;right:10px;bottom:5px;font-size:.66rem;opacity:.62}

.msgr-voice{display:flex;align-items:center;gap:9px;flex-wrap:wrap;max-width:100%}
.msgr-voice audio{height:34px;width:230px;max-width:100%}
/* the length sits under the player rather than fighting it for the row */
.msgr-voice > .tiny{flex:0 0 auto}

/* Inside my own bubble the ground is a saturated gradient, so the muted text
   tokens — chosen against a dark surface — all but disappear. Everything in
   there is white, at the opacity that carries the same hierarchy. */
.msgr-msg.mine .msgr-bubble,
.msgr-msg.mine .msgr-bubble p,
.msgr-msg.mine .msgr-bubble strong,
.msgr-msg.mine .msgr-bubble a{color:#fff}
.msgr-msg.mine .msgr-bubble .dim,
.msgr-msg.mine .msgr-bubble .tiny{color:rgba(255,255,255,.82)}
.msgr-msg.mine .msgr-when{color:rgba(255,255,255,.78)}
.msgr-image img{max-width:260px;max-height:280px;border-radius:10px;display:block}
.msgr-file{display:flex;align-items:center;gap:9px;padding:7px 10px;border-radius:10px;
  background:var(--glass);border:1px solid var(--stroke-soft);margin-bottom:4px}
.msgr-msg.mine .msgr-file{background:rgba(255,255,255,.16);border-color:rgba(255,255,255,.24);color:#fff}
.msgr-file strong{display:block;font-size:.82rem}

.msgr-composer{border-top:1px solid var(--stroke);padding:11px 14px;background:var(--bg-1)}
.msgr-row{display:flex;align-items:flex-end;gap:8px}
.msgr-text{flex:1 1 auto;resize:none;max-height:150px;padding:9px 12px;font-size:.9rem;
  line-height:1.45;min-height:40px}
.msgr-send{flex:0 0 auto;padding:9px 14px}
.msgr-mic.on{color:var(--danger);background:color-mix(in srgb,var(--danger) 16%,transparent);
  animation:msgrPulse 1.4s var(--ease) infinite}
.msgr-attached{display:flex;flex-wrap:wrap;gap:6px;padding-bottom:9px}
.msgr-chip{font-size:.76rem;padding:4px 9px;border-radius:8px;background:var(--glass);
  border:1px solid var(--stroke-soft)}
.msgr-chip-clear{font-size:.72rem;color:var(--danger);background:none;border:none;cursor:pointer}
.msgr-recording{display:flex;align-items:center;gap:11px;padding-top:10px}
.rec-dot{width:10px;height:10px;border-radius:99px;background:var(--danger);
  animation:msgrPulse 1.1s var(--ease) infinite}

.msgr-observer{border-top:1px solid var(--stroke);padding:14px 16px;background:var(--bg-1);
  display:flex;align-items:center;gap:10px;color:var(--text-3)}
.msgr-blank{flex:1 1 auto;display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:10px;color:var(--text-3)}

.msgr-picker{position:fixed;inset:0;z-index:120;background:rgba(3,6,18,.66);
  backdrop-filter:blur(6px);display:grid;place-items:center;padding:20px}
.msgr-picker-box{width:min(520px,100%);max-height:78vh;overflow-y:auto;padding:20px;
  background:var(--bg-1);border:1px solid var(--stroke);border-radius:var(--r-lg);
  box-shadow:0 30px 80px rgba(0,0,0,.5)}
.msgr-people{display:flex;flex-direction:column;gap:2px}
.msgr-people-head{font-size:.68rem;letter-spacing:.08em;text-transform:uppercase;
  color:var(--text-3);padding:11px 4px 5px}
.msgr-person{display:flex;align-items:center;gap:11px;padding:8px 10px;border-radius:10px}
.msgr-person:hover{background:var(--glass)}
.msgr-person strong{display:block;font-size:.88rem}

@media (max-width:900px){
  .msgr{grid-template-columns:1fr;height:calc(100vh - var(--topbar-h) - 20px)}
  .msgr-list{display:none}
  .msgr-back{display:inline-flex}
  body.msgr-listing .msgr-list{display:flex}
  body.msgr-listing .msgr-chat{display:none}
  .msgr-msg{max-width:88%}
}

/* An explicit `display` beats the `hidden` attribute, so any component with
   one — the picker, the attachment tray, the recording bar — stayed on screen
   however hidden it claimed to be. This is the standard remedy and belongs
   near the top rather than beside any one component. */
[hidden] { display: none !important; }

/* a badge with nothing to say gets out of the way entirely */
.hide { display: none !important; }
