/* LMSCursio — application design system.
   Cursio Design System: plum/violet brand spine (#6B3AA0 → #B65C34) on a
   warm-neutral cream base, near-black ink, soft flat borders over heavy
   shadow, Space Grotesk display face for headings/nav, Source Sans 3 body,
   IBM Plex Mono for tabular numbers. */

/* ---- Webfonts (self-hosted; CSP font-src 'self') ---- */
@font-face {
    font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url('fonts/source-sans-3-var-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Source Sans 3'; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url('fonts/source-sans-3-var-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Source Sans 3'; font-style: italic; font-weight: 400; font-display: swap;
    src: url('fonts/source-sans-3-italic-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('fonts/ibm-plex-mono-600-latin.woff2') format('woff2');
}
/* Display face for headings / nav / brand — self-hosted, same CSP-safe pattern. */
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('fonts/space-grotesk-500-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('fonts/space-grotesk-500-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('fonts/space-grotesk-600-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('fonts/space-grotesk-600-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('fonts/space-grotesk-700-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('fonts/space-grotesk-700-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Arabic script — IBM Plex Sans Arabic (SIL OFL, see fonts/IBM-Plex-Sans-Arabic-OFL.txt).
   Scoped by unicode-range so it is only downloaded when Arabic glyphs are on
   the page, and listed after the Latin faces in every stack so Latin text
   keeps its design face while Arabic (UI or course content) falls through. */
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('fonts/ibm-plex-sans-arabic-400-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('fonts/ibm-plex-sans-arabic-500-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 600; font-display: swap;
    src: url('fonts/ibm-plex-sans-arabic-600-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'IBM Plex Sans Arabic'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('fonts/ibm-plex-sans-arabic-700-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
    /* ---- Surfaces / neutrals (warm cream, near-black ink) ---- */
    --bg: #FAF7F1;
    --surface: #ffffff;
    --surface-2: #F2ECE1;
    --text: #221C17;
    --muted: #6E6355;
    --subtle: #A69A88;

    /* ---- Primary (plum / violet) ---- */
    --primary: #6B3AA0;
    --primary-strong: #562F82;
    --primary-active: #402360;
    --primary-soft: #F1E7F8;

    /* ---- Accent (warm terracotta) ---- */
    --accent: #B65C34;
    --accent-strong: #8A4526;
    --accent-soft: #F7E9E0;

    --border: #E8E0D2;
    --border-strong: #D4C7B2;

    /* ---- Semantic ---- */
    --success: #3F7D4A;  --success-soft: #E9F3EA;
    --warning: #B9791F;  --warning-soft: #FBF0DD;
    --danger: #B23B32;   --danger-soft: #FAEBE8;
    --info: #3E6E85;     --info-soft: #E7F0F3;

    /* ---- Status triads (bg / fg / border) ---- */
    --ok-bg: #E9F3EA;        --ok-fg: #2E6B3B;        --ok-bd: #C9E0CC;
    --warn-bg: #FBF0DD;      --warn-fg: #93600E;      --warn-bd: #F0DBB0;
    --bad-bg: #FAEBE8;       --bad-fg: #962E26;       --bad-bd: #F0CFC9;
    --info-bg: #E7F0F3;      --info-fg: #2F5A6E;      --info-bd: #C7DEE6;
    --brand-soft-bg: #F1E7F8; --brand-soft-fg: #562F82; --brand-soft-bd: #DDC5EC;

    /* ---- Brand spine ---- */
    --brand-navy: #6B3AA0;
    --brand-cyan: #B65C34;
    --brand-gradient: linear-gradient(135deg, #6B3AA0 0%, #92497C 52%, #B65C34 100%);

    /* ---- Sidebar / app rail (stays dark in both themes) ---- */
    --rail-bg: #1E1824;
    --sidebar-bg: #1E1824;
    --sidebar-text: #DACFE3;
    --sidebar-text-muted: #8C7F9C;
    --sidebar-item-hover-bg: rgba(255, 255, 255, .06);
    --sidebar-item-active-bg: #6B3AA0;
    --sidebar-border: rgba(255, 255, 255, .08);
    --sidebar-role-bg: rgba(182, 92, 52, .16);
    --sidebar-role-fg: #E8B393;
    --sidebar-role-bd: rgba(182, 92, 52, .32);

    /* ---- Radii (soft, generous) ---- */
    --radius-xs: 6px;
    --radius-sm: 9px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    /* ---- Elevation (flat borders over heavy shadow) ---- */
    --shadow-1: 0 1px 2px rgba(33, 27, 20, .05);
    --shadow-2: 0 6px 20px rgba(33, 27, 20, .08), 0 2px 5px rgba(33, 27, 20, .05);
    --shadow-3: 0 16px 36px rgba(33, 27, 20, .14);
    --shadow-4: 0 22px 50px rgba(33, 27, 20, .2);
    --lift-shadow: 0 8px 20px rgba(33, 27, 20, .07);
    /* legacy aliases consumed across views */
    --shadow-sm: var(--shadow-1);
    --shadow: var(--shadow-2);
    --shadow-pop: var(--shadow-3);

    /* ---- Motion ---- */
    --ease: cubic-bezier(0.2, 0, 0.2, 1);
    --ease-standard: cubic-bezier(0.2, 0, 0.2, 1);
    --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
    --dur-instant: 80ms;
    --dur-fast: 120ms;
    --dur-base: 180ms;
    --dur-slow: 280ms;
    --press-translate: translateY(0.5px);
    --lift-translate: translateY(-2px);

    /* ---- Focus ---- */
    --focus-ring: 0 0 0 3px rgba(107, 58, 160, .35);

    /* ---- Tinted "glow" shadows for primary actions/brand marks (self-adapts
       per theme since it reads the live --primary/--accent custom property) ---- */
    --shadow-primary: 0 3px 10px color-mix(in srgb, var(--primary) 35%, transparent), 0 1px 2px color-mix(in srgb, var(--primary) 25%, transparent);
    --shadow-primary-lg: 0 10px 26px color-mix(in srgb, var(--primary) 32%, transparent);
    --shadow-accent: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent), 0 1px 2px color-mix(in srgb, var(--accent) 25%, transparent);

    /* ---- Type ---- */
    --font: 'Source Sans 3', 'IBM Plex Sans Arabic', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Space Grotesk', 'IBM Plex Sans Arabic', var(--font);
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --sidebar-w: 248px;
    --topbar-h: 60px;

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #191410;
    --surface: #241D18;
    --surface-2: #2D251E;
    --text: #F2EBE1;
    --muted: #BAAD9B;
    --subtle: #7C7061;

    --primary: #9B6FC9;
    --primary-strong: #B794D9;
    --primary-active: #D3B8E8;
    --primary-soft: rgba(155, 111, 201, .16);

    --accent: #D98456;
    --accent-strong: #E8A87D;
    --accent-soft: rgba(217, 132, 86, .16);

    --border: #3D342A;
    --border-strong: #554839;

    --success-soft: rgba(63, 125, 74, .18);
    --warning-soft: rgba(185, 121, 31, .18);
    --danger-soft: rgba(178, 59, 50, .18);
    --info-soft: rgba(62, 110, 133, .18);

    --ok-bg: #24422A;   --ok-fg: #B6DABB;   --ok-bd: #2E6B3B;
    --warn-bg: #5A3B0C; --warn-fg: #F0DBB0; --warn-bd: #93600E;
    --bad-bg: #552420;  --bad-fg: #F0CFC9;  --bad-bd: #962E26;
    --info-bg: #213B47; --info-fg: #C7DEE6; --info-bd: #2F5A6E;
    --brand-soft-bg: rgba(155, 111, 201, .18); --brand-soft-fg: #D3B8E8; --brand-soft-bd: rgba(155, 111, 201, .4);

    --rail-bg: #150F1A;
    --sidebar-bg: #150F1A;
    --sidebar-item-active-bg: #9B6FC9;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
    --shadow-3: 0 18px 40px rgba(0, 0, 0, .6);
    --shadow-4: 0 24px 60px rgba(0, 0, 0, .7);
    --lift-shadow: 0 10px 24px rgba(0, 0, 0, .45);

    --focus-ring: 0 0 0 3px rgba(155, 111, 201, .45);

    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
html::-webkit-scrollbar { width: 10px; height: 10px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
html::-webkit-scrollbar-thumb:hover { background: var(--subtle); }
body {
    margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
    line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--primary); }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.02em; font-family: var(--font-display); font-weight: 600; }
svg { display: block; }

/* Skip link: hidden until keyboard-focused, then floats above the shell so
   assistive-tech users can jump straight past the navigation. */
/* Hidden above the viewport (not off to one side, which would add a
   horizontal scroll in RTL) until keyboard focus brings it into view. */
.skip-link {
    position: absolute; inset-inline-start: 0; top: 0; z-index: 200; transform: translateY(-120%);
    background: var(--primary); color: #fff; padding: .55rem 1rem;
    border-end-end-radius: 8px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { transform: none; }
/* Native form controls follow the brand accent instead of the browser default blue. */
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--primary); }

/* Consistent keyboard focus ring across interactive controls. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* Content links (unclassed) underline on hover; component links opt out via class. */
a:not([class]):hover { text-decoration: underline; text-underline-offset: 2px; }

/* ============================ Typographic utilities ============================ */
/* Eyebrow: small tracked uppercase label above sections / table heads. */
.eyebrow {
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .07em; color: var(--muted);
}
/* Tabular data: GPAs, IDs, credits, amounts, grades. */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
code, kbd, samp { font-family: var(--font-mono); font-size: .9em; }
kbd {
    display: inline-block; padding: .1em .4em; border: 1px solid var(--border-strong);
    border-bottom-width: 2px; border-radius: var(--radius-xs); background: var(--surface-2);
    color: var(--text); font-size: .78em; line-height: 1.4;
}
code:not(pre code) {
    padding: .12em .38em; border-radius: var(--radius-xs);
    background: var(--surface-2); color: var(--primary-strong);
}

/* Respect reduced-motion: neutralize transitions and transforms. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
}

/* ============================ Sidebar shell ============================ */
.shell { display: flex; min-height: 100vh; }
/* Desktop: a light, labelled sidebar grouped under small headings (Notion /
   Linear style). It follows the page theme instead of staying black, and the
   button in its footer shrinks it to an icon rail ([data-sb="collapsed"],
   remembered by app.js). Tablets get a top strip and phones the dark bottom
   tab bar, both further down in the Responsive section. */
:root { --sb-w: var(--sidebar-w); }
.sidebar {
    width: var(--sb-w); flex: none; background: var(--surface); color: var(--muted); border-inline-end: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
    display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem .85rem; min-width: 0;
    font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; color: var(--text); text-decoration: none; line-height: 1.2;
}
.sidebar__brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__logo {
    width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center;
    background: var(--brand-gradient); color: #fff; font-weight: 800; font-size: 1rem;
    box-shadow: var(--shadow-primary);
}
/* Uploaded institution logo in place of the letter mark (any shell). It keeps
   its own shape (tall, square or wide) inside a box of at most
   --logo-w × --logo-h that each shell sizes, instead of being squeezed into
   the 30px letter tile. The white plate keeps dark lettering readable on the
   dark theme; on the light surfaces it blends in. */
.brand-mark--logo {
    --logo-h: 44px; --logo-w: 160px;
    width: auto; height: auto; flex: none; display: inline-flex; align-items: center; justify-content: center;
    background: #fff; box-shadow: none; overflow: hidden; padding: 4px; border-radius: 10px;
}
.brand-mark--logo img {
    display: block; width: auto; height: auto; max-width: var(--logo-w); max-height: var(--logo-h); object-fit: contain;
}
/* Desktop sidebar: the logo sits on its own row above the name, as large as
   the 244px column allows (Canvas / Moodle give the institution logo the top
   of the menu). */
.sidebar__brand--logo { flex-direction: column; justify-content: center; text-align: center; gap: .45rem; padding: 1rem .9rem .8rem; }
.sidebar__brand--logo .brand-mark--logo { --logo-h: 84px; --logo-w: calc(var(--sidebar-w) - 3rem); padding: 6px; border-radius: 12px; }
.sidebar__brand--logo > span:last-child { white-space: normal; font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* Phone top bar logo: hidden until the sidebar brand is (≤720px below). */
.topbar__logo { display: none; }
.topbar__logo.brand-mark--logo { --logo-h: 34px; --logo-w: 96px; padding: 3px; border-radius: 8px; }
.brand-preview .brand-mark--logo { --logo-h: 76px; --logo-w: 200px; box-shadow: 0 0 0 1px var(--border); }
.sidebar__nav { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1px; padding: .25rem .7rem .75rem; overflow-y: auto; scrollbar-width: thin; }
.sidebar__section { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--subtle); padding: .85rem .65rem .3rem; }
.sidebar__section:first-child { padding-top: .25rem; }
.sidebar__link {
    position: relative; display: flex; align-items: center; gap: .7rem;
    padding: .45rem .65rem; border-radius: 9px; width: 100%; background: none; border: 0; cursor: pointer;
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: .93rem; text-align: start;
    /* <button> items (Courses, More) must not fall back to the UA button font. */
    font-family: inherit; line-height: 1.3;
    transition: background .15s, color .15s;
}
.sidebar__link > span:not(.sidebar__badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The "More" tab and its sheet exist for the phone tab bar only. */
.sidebar__more, .navsheet-overlay { display: none; }
.sidebar__link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; stroke-width: 1.8; }
.sidebar__link:hover { background: var(--surface-2); color: var(--text); }
.sidebar__link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.sidebar__link.is-active::before { content: ""; position: absolute; inset-inline-start: -.7rem; top: 7px; bottom: 7px; width: 3px; border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--primary); }
.sidebar__link:focus-visible, .sidebar__user:focus-visible, .sidebar__collapse:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sidebar__badge { margin-inline-start: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--primary); color: #fff; font-size: .66rem; font-weight: 700; display: grid; place-items: center; }
.sidebar__foot { display: flex; align-items: center; gap: .2rem; padding: .6rem .7rem .75rem; border-top: 1px solid var(--border); }
.sidebar__user { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.sidebar__user:hover { background: var(--surface-2); }
.sidebar__user .avatar { width: 32px; height: 32px; font-size: .74rem; }
.sidebar__user-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar__user-text b, .sidebar__user-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-text b { font-size: .86rem; font-weight: 650; }
.sidebar__user-text small { font-size: .74rem; color: var(--muted); }
.sidebar__foot .sidebar__link, .sidebar__collapse {
    flex: none; width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px;
    background: none; border: 0; color: var(--subtle); cursor: pointer; align-items: center;
}
.sidebar__collapse { display: inline-flex; }
.sidebar__collapse svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.sidebar__foot .sidebar__link > span:not(.sidebar__badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sidebar__collapse:hover { background: var(--surface-2); color: var(--text); }

/* Collapsed: an icon rail with a short label under each icon; headings
   become thin dividers. Desktop only — tablets and phones ignore it. */
@media (min-width: 901px) {
    :root[data-sb="collapsed"] { --sb-w: 84px; }
    [data-sb="collapsed"] .sidebar__brand { justify-content: center; padding: 1rem .25rem .75rem; }
    [data-sb="collapsed"] .sidebar__brand > span:last-child { display: none; }
    [data-sb="collapsed"] .sidebar__brand--logo .brand-mark--logo { --logo-h: 56px; --logo-w: 64px; padding: 4px; }
    [data-sb="collapsed"] .sidebar__nav { padding: .25rem .45rem .75rem; scrollbar-width: none; }
    [data-sb="collapsed"] .sidebar__section { font-size: 0; height: 1px; padding: 0; margin: .45rem .5rem; background: var(--border); }
    [data-sb="collapsed"] .sidebar__section:first-child { display: none; }
    [data-sb="collapsed"] .sidebar__nav .sidebar__link { flex-direction: column; justify-content: center; gap: 3px; padding: .5rem .15rem; border-radius: 12px; font-size: .64rem; font-weight: 600; text-align: center; line-height: 1.15; }
    [data-sb="collapsed"] .sidebar__nav .sidebar__link > span:not(.sidebar__badge) { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
    [data-sb="collapsed"] .sidebar__nav .sidebar__link svg { width: 20px; height: 20px; }
    [data-sb="collapsed"] .sidebar__link.is-active::before { display: none; }
    [data-sb="collapsed"] .sidebar__badge { position: absolute; top: .25rem; inset-inline-end: .85rem; min-width: 16px; height: 16px; padding: 0 4px; font-size: .6rem; box-shadow: 0 0 0 2px var(--surface); }
    [data-sb="collapsed"] .sidebar__foot { flex-direction: column; padding: .5rem .4rem .7rem; }
    [data-sb="collapsed"] .sidebar__user { flex: none; padding: .25rem; }
    [data-sb="collapsed"] .sidebar__user-text { display: none; }
    [data-sb="collapsed"] .sidebar__collapse svg { transform: scaleX(-1); }
}

/* Slide-in Courses tray (flyout). */
.tray-overlay { position: fixed; inset: 0; z-index: 90; display: none; background: rgba(15, 23, 42, .35); backdrop-filter: blur(2px); }
.tray-overlay.is-open { display: block; }
.tray { position: absolute; inset-block: 0; inset-inline-start: var(--sb-w); width: 320px; max-width: 80vw; background: var(--surface); border-inline-end: 1px solid var(--border); box-shadow: var(--shadow-pop); padding: 1.1rem 1.25rem; overflow-y: auto; }
.tray__head { display: flex; align-items: center; justify-content: space-between; }
.tray__head h2 { margin: 0; font-size: 1.2rem; }
.tray__close { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.tray__all { display: inline-block; margin: .5rem 0 1rem; font-weight: 600; }
.tray__group { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .35rem; }
.tray__link { display: block; padding: .5rem .6rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.tray__link:hover { background: var(--surface-2); }
.tray__link--muted { color: var(--muted); }
.tray__name { display: block; }
.tray__meta { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.tray__empty { color: var(--muted); margin: 1rem 0; }

.shell__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar__search { flex: 1; max-width: 440px; position: relative; }
.topbar__search svg { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; stroke: var(--muted); }
.topbar__search input {
    width: 100%; padding-block: .55rem; padding-inline: 2.2rem .8rem; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text); font: inherit; font-size: .92rem;
}
.topbar__search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.topbar__actions { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; }
.topbar__page { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.sidebar__logout { margin: 0; }
.shell__content { flex: 1; min-width: 0; }
/* Fluid, left-aligned content that fills the available width on every screen
   (capped on ultra-wide for readability) instead of a fixed centred column. */
.shell__content .page__container { width: 100%; max-width: 1680px; margin: 0; padding: clamp(1rem, 1.6vw, 1.75rem) clamp(1rem, 2.4vw, 2rem) 4rem; }

/* ============================ Public / marketing top bar ============================ */
.appbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.appbar__inner { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; height: 64px; display: flex; align-items: center; gap: 1.25rem; }
.appbar__brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.appbar__logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-gradient); color: #fff; font-weight: 800; }
/* The letter tile's fixed 30px box must not clip an uploaded logo. */
.appbar__logo.brand-mark--logo { width: auto; height: auto; background: #fff; }
.appbar__brand--logo { gap: .7rem; }
.appbar__brand--logo .brand-mark--logo { --logo-h: 48px; --logo-w: 180px; padding: 2px 4px; }
.appbar__nav { display: flex; align-items: center; gap: .25rem; }
.appbar__link { padding: .45rem .7rem; border-radius: 8px; font-size: .92rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.appbar__link:hover { background: var(--surface-2); color: var(--text); }
.appbar__link.is-active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.appbar__actions { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; }

/* ============================ Page header ============================ */
.page { min-height: 60vh; }
.page__container { max-width: 1180px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header__title { margin: 0; font-size: 1.55rem; font-family: var(--font-display); }
.page-header__meta { margin: .35rem 0 0; color: var(--muted); font-size: .95rem; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.page-header__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumb { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.crumb:hover { color: var(--primary); }

/* ============================ Buttons ============================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .6rem 1rem; border-radius: 10px; border: 1px solid transparent;
    font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none;
    font-family: inherit; line-height: 1; white-space: nowrap;
    transition: filter .15s, background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: var(--press-translate); }
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn--primary:hover { background: var(--primary-strong); box-shadow: var(--shadow-primary-lg); }
.btn--accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-accent); }
.btn--accent:hover { filter: brightness(.96); }
.btn--ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn--subtle { background: var(--primary-soft); color: var(--primary); }
.btn--danger { background: var(--surface); border-color: var(--border); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--sm { padding: .45rem .75rem; font-size: .86rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: background .15s, color .15s, border-color .15s; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn__dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-gradient); color: #fff; font-weight: 700; font-size: .82rem; flex: none; }

/* User menu */
.usermenu { position: relative; }
.usermenu__trigger { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; padding: .2rem .5rem .2rem .2rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.usermenu__trigger::-webkit-details-marker { display: none; }
.usermenu__trigger:hover { border-color: var(--border-strong); }
.usermenu__name { font-size: .9rem; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__panel { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: .35rem; display: grid; gap: 2px; z-index: 60; }
.usermenu__item { display: block; width: 100%; text-align: start; padding: .55rem .7rem; border-radius: 8px; font: inherit; font-size: .9rem; color: var(--text); text-decoration: none; background: none; border: 0; cursor: pointer; }
.usermenu__item:hover { background: var(--surface-2); }
.usermenu__item--danger { color: var(--danger); }

/* ============================ Cards ============================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); text-align: start; }
.card h3 { margin: 0 0 .4rem; font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
a.card { display: block; color: inherit; text-decoration: none; transition: border-color .12s var(--ease, ease), box-shadow .18s var(--ease, ease), transform .18s var(--ease, ease); }
a.card:hover { border-color: var(--primary); box-shadow: var(--lift-shadow); transform: translateY(-2px); }
a.card h3 { color: var(--text); }
.card--wide { grid-column: 1 / -1; }

/* ============================ Stats ============================ */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.75rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 1rem; }
.stat__icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat__icon svg { width: 22px; height: 22px; stroke: currentColor; }
.stat__icon--accent { background: var(--accent-soft); color: var(--accent); }
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--info { background: var(--info-soft); color: var(--info); }
.stat__label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-family: var(--font-display); font-variant-numeric: tabular-nums; }

/* ============================ Grid / sections ============================ */
.dashboard { width: 100%; }
.dashboard__header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.dashboard__title { margin: 0 0 .25rem; font-size: 1.55rem; font-family: var(--font-display); }
.dashboard__meta { color: var(--muted); margin: .15rem 0 0; }
.dashboard__meta a { color: var(--muted); text-decoration: none; font-weight: 500; }
.dashboard__meta a:hover { color: var(--primary); }
.dashboard__grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); }
.section-title { margin: 2rem 0 1rem; font-size: 1.15rem; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 1rem; }

/* ============================ Badges ============================ */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; padding: 0; }
.chip, .badge { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.4; background: var(--success-soft); color: var(--success); }
.chip--muted, .badge--muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip--brand { background: var(--primary-soft, var(--surface-2)); color: var(--primary, var(--text)); border: 1px solid transparent; }
.badge--draft, .chip--draft { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
/* Cursio status pills. */
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge--bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge--info { background: var(--info-bg); color: var(--info-fg); }
.badge--brand { background: var(--brand-soft-bg); color: var(--brand-soft-fg); }
/* Small status dot on live-state pills (not on --muted, which isn't a "state"). */
.badge--ok::before, .badge--warn::before, .badge--bad::before, .badge--info::before,
.badge--danger::before, .badge--draft::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}

/* ============================ Tables ============================ */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .8rem 1rem; text-align: start; border-bottom: 1px solid var(--border); font-size: .92rem; }
.table th { background: var(--surface-2); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--primary-soft); }
.table td .mono, .table td.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* Reusable bounded scroll box that keeps a table's header pinned — for long
   data tables (admin lists, rosters). The wrapper owns the border/radius. */
.table-scroll { overflow: auto; max-height: 72vh; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: var(--radius); }
.table-scroll > .table { border: 0; border-radius: 0; }
.table-scroll .table thead th { position: sticky; top: 0; z-index: 2; }

/* ============================ Tabs ============================ */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 0 0 1.5rem; flex-wrap: wrap; }
.tab { padding: .65rem .9rem; border-radius: 8px 8px 0 0; text-decoration: none; font-weight: 600; font-size: .92rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
/* Live-filter (live-filter.js): dim a results region while it refreshes in place. */
.lf-loading { opacity: .45; pointer-events: none; transition: opacity .12s ease; }

/* ===================== In-course vertical navigation ===================== */
/* Two-column course shell: nav rail (col 1, full height) + page content (col 2).
   Keyed off :has() so individual course views need no layout changes. */
.page__container:has(.course-nav) {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    column-gap: 2.25rem;
    row-gap: 0;
    align-items: start;
    /* Keep content rows at their natural height: without this the nav (which
       spans every row) stretches the rows to its full height, opening a large
       gap between the header and the page content. */
    grid-auto-rows: min-content;
}
.page__container:has(.course-nav) > * { grid-column: 2; min-width: 0; }
.page__container:has(.course-nav) > .course-nav { grid-column: 1; grid-row: 1 / -1; }

.course-nav { position: sticky; top: 1.25rem; align-self: start; }
.course-nav__toggle { display: none; }
.course-nav__list { display: flex; flex-direction: column; gap: 1px; }
.course-nav__link {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .7rem; border-radius: 9px;
    text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem;
    border-inline-start: 3px solid transparent; line-height: 1.25;
    transition: background .12s ease, color .12s ease;
}
.course-nav__link:hover { background: var(--surface-2); color: var(--text); }
.course-nav__link.is-active {
    color: var(--primary); background: var(--primary-soft);
    border-inline-start-color: var(--primary);
}
.course-nav__icon { flex: none; width: 1.25rem; text-align: center; font-size: 1rem; opacity: .9; }
.course-nav__link.is-active .course-nav__icon { opacity: 1; }

@media (max-width: 900px) {
    .page__container:has(.course-nav) { display: block; }
    .course-nav { position: static; margin-bottom: 1.25rem; }
    .course-nav__toggle {
        display: flex; align-items: center; justify-content: space-between; width: 100%;
        padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
        background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
    }
    .course-nav__toggle svg { transition: transform .15s ease; }
    .course-nav__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
    .course-nav__list { display: none; margin-top: .4rem; padding: .35rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
    .course-nav.is-open .course-nav__list { display: flex; }
}

/* ============== Reorderable content lists (assignments/pages/quizzes) ===== */
.content-list { display: flex; flex-direction: column; gap: .5rem; }
.content-row {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem .85rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm); transition: border-color .12s ease, box-shadow .12s ease, transform .06s ease;
}
.content-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.content-row.is-unpublished { opacity: .72; }
.content-row.dragging { opacity: .5; box-shadow: 0 0 0 2px var(--primary); }
.content-row__icon {
    flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
    background: var(--primary-soft); font-size: 1.05rem;
}
.content-row__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: inherit; }
.content-row__title { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-row__main:hover .content-row__title { color: var(--primary); }
.content-row__meta { color: var(--muted); font-size: .84rem; }
.content-row .drag-grip { font-size: 1.05rem; }

/* Assignment-group buckets. */
.bucket__settings { gap: .6rem; }
.bucket__field { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
.bucket__field .form__input { margin-top: 0; }
details.module.module--ungrouped { border-style: dashed; background: var(--surface-2); }
details.module.module--ungrouped > summary { background: transparent; }

/* ============================== Gradebook ================================ */
.gb-scroll { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.gb-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
.gb-table th, .gb-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); }
.gb-table th { background: var(--surface-2); position: sticky; top: 0; z-index: 2; text-align: end; font-weight: 700; vertical-align: bottom; }
.gb-table thead th:first-child { text-align: start; }
.gb-num { text-align: end; white-space: nowrap; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.gb-th-title { display: block; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.gb-th-max { font-weight: 500; font-size: .8rem; font-family: var(--font-mono); }
.gb-sticky-col { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); text-align: start !important; min-width: 11rem; box-shadow: 1px 0 0 var(--border); }
.gb-table thead .gb-sticky-col { z-index: 3; background: var(--surface-2); }
.gb-name { font-weight: 600; }
.gb-table tbody tr:hover td { background: var(--primary-soft); }
.gb-table tbody tr:hover .gb-sticky-col { background: var(--primary-soft); }
.gb-empty { background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(127,127,127,.05) 6px, rgba(127,127,127,.05) 12px); }
.gb-total-col { border-inline-start: 2px solid var(--border-strong); font-weight: 700; }
.gb-table tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--surface-2); font-weight: 600; border-top: 2px solid var(--border-strong); }
.gb-table tfoot .gb-sticky-col { z-index: 2; }
/* Grade pills (A–F bands). */
.gb-pill { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-weight: 700; font-size: .82rem; }
.gb-pill--a { background: #dcfce7; color: #166534; }
.gb-pill--b { background: #E7F0F3; color: #2F5A6E; }
.gb-pill--c { background: #fef9c3; color: #854d0e; }
.gb-pill--d { background: #ffedd5; color: #9a3412; }
.gb-pill--f { background: #fee2e2; color: #991b1b; }
.gb-pill--na { background: var(--surface-2); color: var(--muted); }
[data-theme="dark"] .gb-pill--a { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .gb-pill--b { background: #213B47; color: #C7DEE6; }
[data-theme="dark"] .gb-pill--c { background: #713f12; color: #fef08a; }
[data-theme="dark"] .gb-pill--d { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .gb-pill--f { background: #7f1d1d; color: #fecaca; }

/* ================================ People ================================= */
.people-search { margin-bottom: 1.25rem; display: flex; align-items: center; gap: .75rem; }
.people-group { margin-bottom: 1.5rem; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.person { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); transition: border-color .12s ease, box-shadow .12s ease; }
.person:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.person__body { flex: 1 1 auto; min-width: 0; }
.person__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person__email { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar--lg { width: 40px; height: 40px; font-size: .9rem; flex: none; }
.person[hidden] { display: none; }
.person__section { display: flex; align-items: center; gap: .35rem; margin: .45rem 0 0; }
.person__section .form__input { margin: 0; padding: .25rem .4rem; font-size: .8rem; max-width: 150px; }
.person__section .btn { padding: .2rem .5rem; }
.person__meta { margin-top: .4rem; }
.person { position: relative; }
.person-check { flex: none; width: 18px; height: 18px; cursor: pointer; }
.person.is-selected { outline: 2px solid var(--primary); outline-offset: 1px; }
.person__remove { margin: 0; }
.person__remove .btn { padding: .2rem .45rem; }
.bulk-bar { position: sticky; top: .5rem; z-index: 20; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .6rem .85rem; background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.bulk-bar__count { font-size: .9rem; }

/* SpeedGrader: attempt switcher + similarity banner */
/* Quiz builder */
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.builder-side { position: sticky; top: 1rem; }
.qopt { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.qopt input[type="radio"], .qopt input[type="checkbox"] { flex: none; }
@media (max-width: 900px) { .builder-grid { grid-template-columns: 1fr; } .builder-side { position: static; } }

.attempt-pill { display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 .35rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 700; }
.attempt-pill:hover { border-color: var(--border-strong); color: var(--text); }
.attempt-pill.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.sim-banner { display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid var(--border); }
.sim-banner__icon { font-size: 1.2rem; flex: none; }
.sim-banner__body { flex: 1 1 auto; min-width: 0; }
.sim-banner--a { background: #dcfce7; border-color: #86efac; color: #166534; }
.sim-banner--c { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.sim-banner--f { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.sim-banner--na { background: var(--surface-2); }
.sim-banner .muted { color: inherit; opacity: .8; }
[data-theme="dark"] .sim-banner--a { background: #14532d; border-color: #166534; color: #bbf7d0; }
[data-theme="dark"] .sim-banner--c { background: #713f12; border-color: #854d0e; color: #fef08a; }
[data-theme="dark"] .sim-banner--f { background: #7f1d1d; border-color: #991b1b; color: #fecaca; }
.people-import > summary { cursor: pointer; list-style: none; }
.people-import > summary::-webkit-details-marker { display: none; }
.people-import > summary::before { content: "▸ "; color: var(--muted); }
.people-import[open] > summary::before { content: "▾ "; }

/* ============================== Sections ================================ */
.section-list { display: flex; flex-direction: column; gap: .85rem; }
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.15rem; }
.section-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.section-card__title { margin: 0 0 .25rem; font-size: 1.1rem; }
.section-card__meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .85rem; }
.section-card__cap { flex: none; text-align: end; }
.section-card__cap-num { font-size: 1.05rem; }
.cap-bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: .7rem; }
.cap-bar__fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s ease; }
.cap-bar__fill.is-full { background: var(--accent); }
.section-card__actions { display: flex; align-items: flex-start; gap: .5rem; margin-top: .85rem; flex-wrap: wrap; }
.section-edit > summary { list-style: none; display: inline-flex; cursor: pointer; }
.section-edit > summary::-webkit-details-marker { display: none; }
.section-edit[open] { flex: 1 1 100%; }

/* ============================== Discussions ============================== */
.topic-group { margin-bottom: 1.5rem; }
.topic-list { display: flex; flex-direction: column; gap: .5rem; }
.topic {
    display: flex; align-items: center; gap: .85rem; padding: .8rem .95rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.topic:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.topic.is-draft { opacity: .72; }
.topic__icon { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.1rem; }
.topic__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.topic__title { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.topic__preview { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic__meta { color: var(--muted); font-size: .8rem; }
.topic__replies { flex: none; text-align: center; min-width: 4.5rem; padding-inline-start: .5rem; border-inline-start: 1px solid var(--border); }
.topic__replies strong { display: block; font-size: 1.15rem; color: var(--text); line-height: 1.1; }
.topic__replies .muted { font-size: .75rem; }
.topic[hidden] { display: none; }

/* ============================ Files browser ============================== */
.content-row__actions { display: inline-flex; align-items: center; gap: .35rem; flex: none; }
.content-row__actions form { margin: 0; }
.content-row__chev { flex: none; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.content-row--up { background: var(--surface-2); font-weight: 600; }
.content-row[hidden] { display: none; }

/* ========================== Editable course home ======================== */
.course-front { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem 1.4rem; margin-bottom: 1.5rem; }
.course-front__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.course-front__title { margin: 0; font-size: 1.3rem; }
.course-front--empty { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-style: dashed; background: var(--surface-2); margin-bottom: 1.5rem; }

/* ============================ Announcements ============================== */
.ann-group { margin-bottom: 1.5rem; }
.ann-list { display: flex; flex-direction: column; gap: .75rem; }
.ann { display: flex; gap: .85rem; padding: 1rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); border-inline-start: 3px solid transparent; }
.ann.is-unread { border-inline-start-color: var(--primary); }
.ann.is-pinned { background: var(--primary-soft); }
.ann__icon { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.1rem; }
.ann.is-pinned .ann__icon { background: var(--surface); }
.ann__body { flex: 1 1 auto; min-width: 0; }
.ann__head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.ann__title { margin: 0; font-size: 1.05rem; }
.ann__new { background: var(--primary); color: #fff; }
.ann__date { margin-inline-start: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.ann__message { color: var(--text); }
.ann[hidden] { display: none; }

/* ================================ Inbox ================================= */
.inbox { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); }
.inbox-row { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; background: var(--surface); text-decoration: none; color: inherit; transition: background .12s ease; }
.inbox-row:hover { background: var(--surface-2); }
.inbox-row.is-unread { background: var(--primary-soft); border-inline-start: 3px solid var(--primary); padding-inline-start: calc(1rem - 3px); }
.inbox-row__avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-gradient); color: #fff; font-weight: 700; font-size: .85rem; }
.inbox-row__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.inbox-row__top { display: flex; align-items: baseline; gap: .5rem; }
.inbox-row__who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row.is-unread .inbox-row__who { color: var(--text); }
.inbox-row__time { margin-inline-start: auto; flex: none; color: var(--muted); font-size: .78rem; }
.inbox-row__subject { font-size: .9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row:not(.is-unread) .inbox-row__subject { color: var(--muted); }
.inbox-row__snippet { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-row[hidden] { display: none; }

/* ============================== Admin hub =============================== */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .85rem; margin-bottom: 1.75rem; }
.admin-stat { display: flex; align-items: center; gap: .85rem; padding: 1rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.admin-stat__icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.3rem; }
.admin-stat__value { font-size: 1.6rem; font-weight: 700; line-height: 1; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.admin-stat__label { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.admin-stat__sub { color: var(--primary); font-size: .76rem; font-weight: 600; margin-top: .1rem; }
.admin-tool { display: flex; align-items: flex-start; gap: .85rem; }
.admin-tool__icon { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.15rem; }
.admin-tool h3 { margin: 0 0 .15rem; }

/* ============================ Lists / empty ============================ */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list > li { padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.list > li:last-child { border-bottom: 0; }
.empty { text-align: center; padding: 3rem 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--muted); }
.empty__icon { font-size: 2.2rem; opacity: .7; }
.empty h3 { margin: .5rem 0 .25rem; color: var(--text); }

/* ============================ Forms ============================ */
.form { display: flex; flex-direction: column; gap: .35rem; }
.form__label { font-size: .85rem; font-weight: 600; margin-top: .85rem; }
.form__input, textarea.form__input, select.form__input { padding: .7rem .85rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: .95rem; font-family: inherit; width: 100%; transition: border-color .15s, box-shadow .15s; }
.form__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.form__hint { font-size: .82rem; color: var(--muted); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.5rem; }

/* ============================ Alerts ============================ */
.alert { padding: .8rem 1rem; border-radius: 10px; font-size: .92rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert--success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.alert--warn { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert__list { margin: 0; padding-inline-start: 1.1rem; }

.prose { color: var(--text); }
.prose code, .hero__health code, .error code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .15rem .45rem; font-size: .88rem; }

/* ============================ Legal documents ============================ */
.legal { max-width: 760px; margin: 1.5rem auto 3rem; }
.legal__title { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 .35rem; letter-spacing: -.02em; }
.legal__meta { color: var(--muted); font-size: .92rem; margin: 0 0 1.5rem; }
.legal__note { background: var(--info-soft); border: 1px solid var(--info-bd); color: var(--info-fg);
    border-radius: var(--radius); padding: .8rem 1rem; font-size: .9rem; line-height: 1.55; margin: 0 0 2rem; }
.legal__toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.1rem 1.3rem; margin: 0 0 2.2rem; }
.legal__toc h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .6rem; }
.legal__toc ol { margin: 0; padding-inline-start: 1.2rem; columns: 2; column-gap: 2rem; }
.legal__toc li { margin: .2rem 0; }
.legal__toc a { color: var(--primary); text-decoration: none; }
.legal__toc a:hover { text-decoration: underline; }
.legal__section { margin: 0 0 1.8rem; scroll-margin-top: 1rem; }
.legal__section h2 { font-size: 1.2rem; margin: 0 0 .6rem; letter-spacing: -.01em; }
.legal__section h3 { font-size: 1rem; margin: 1.1rem 0 .4rem; }
.legal__section p { color: var(--text); line-height: 1.7; margin: 0 0 .9rem; }
.legal__section ul { margin: 0 0 .9rem; padding-inline-start: 1.3rem; line-height: 1.7; }
.legal__section li { margin: .3rem 0; }
.legal__section a { color: var(--primary); }
.legal__placeholder { color: var(--accent-strong); font-weight: 600; }
@media (max-width: 640px) { .legal__toc ol { columns: 1; } }

/* Public site footer (landing + legal pages) */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 3rem; }
.site-footer__inner { max-width: 1100px; margin: 0 auto; padding: 1.4rem clamp(1rem, 2.4vw, 2rem);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer__copy { color: var(--muted); font-size: .88rem; }
.site-footer__links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.site-footer__links a { color: var(--muted); text-decoration: none; font-size: .88rem; font-weight: 600; }
.site-footer__links a:hover { color: var(--primary); text-decoration: underline; }

/* Legal line under the auth card */
.auth-legal { margin: 1.4rem 0 0; text-align: center; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.auth-legal a { color: var(--primary); text-decoration: none; }
.auth-legal a:hover { text-decoration: underline; }

/* ============================ Hero (landing) ============================ */
.hero { max-width: 820px; margin: 2.5rem auto; text-align: center; }
.hero__badge { display: inline-block; padding: .35rem .8rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: .82rem; letter-spacing: .02em; }
.hero__title { font-size: clamp(2.1rem, 5vw, 3.3rem); margin: 1rem 0 .5rem; }
.hero__subtitle { color: var(--muted); font-size: 1.12rem; max-width: 640px; margin: 0 auto 1rem; }
.hero__phase { font-weight: 600; color: var(--accent); }
.hero__cta { margin: 1.75rem 0 .5rem; display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.hero__grid { display: grid; gap: 1rem; margin: 2.5rem 0; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); text-align: start; }
.hero__health { color: var(--muted); }

/* ============================ Errors ============================ */
.error { text-align: center; max-width: 640px; margin: 4rem auto; }
.error__code { font-size: 5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.error__message { margin: .5rem 0 1rem; }
.error__home { color: var(--primary); text-decoration: none; font-weight: 600; }
.error__trace { margin-top: 1.5rem; text-align: start; overflow: auto; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: .8rem; }

/* ============================ Split auth ============================ */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-split__form { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; margin-bottom: 1.5rem; }
.auth-brand .appbar__logo { width: 30px; height: 30px; }
/* Sign-in: the institution logo is the first thing on the card, big enough
   to recognise at a glance, with the name underneath. */
.auth-brand--logo { flex-direction: column; align-items: flex-start; gap: .6rem; font-size: 1.05rem; }
.auth-brand--logo .appbar__logo.brand-mark--logo { --logo-h: 112px; --logo-w: 248px; padding: 6px; border-radius: 14px; }
.auth-brand .appbar__logo.brand-mark--logo { width: auto; height: auto; background: #fff; }
.auth-title { font-size: 1.7rem; margin: 0 0 .25rem; }
.auth-subtitle { color: var(--muted); margin: 0 0 1.5rem; font-size: .95rem; }
.auth-sso { display: flex; gap: .6rem; margin-top: 1.1rem; }
.auth-sso .btn { flex: 1; }
.auth-divider { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .82rem; margin: 1.4rem 0 .2rem; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.auth-links { margin-top: 1.5rem; font-size: .9rem; text-align: center; color: var(--muted); }
.auth-links a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-card .btn--primary, .auth-card .btn--accent { width: 100%; margin-top: 1.4rem; }

.auth-aside { position: relative; overflow: hidden; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 3rem; background: linear-gradient(150deg, var(--primary) 0%, var(--accent) 130%); }
.auth-aside::after { content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%; background: rgba(255,255,255,.12); top: -120px; inset-inline-end: -120px; }
.auth-aside__inner { position: relative; z-index: 1; max-width: 420px; }
.auth-aside__title { font-size: 2.1rem; line-height: 1.2; margin: 0 0 1rem; }
.auth-aside__text { opacity: .92; font-size: 1.05rem; }
.auth-aside__stat { margin-top: 2rem; display: inline-flex; align-items: center; gap: 1rem; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); padding: 1rem 1.4rem; border-radius: var(--radius); backdrop-filter: blur(4px); }
.auth-aside__stat-num { font-size: 1.8rem; font-weight: 800; }
.auth-aside__stat-ico { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; }
.auth-aside__stat-ico svg { width: 24px; height: 24px; stroke: #fff; }

/* ============================ MFA ============================ */
.mfa-qr { width: 180px; height: 180px; margin: 0 auto 1rem; border: 1px dashed var(--border-strong); border-radius: 10px; display: grid; place-items: center; background: #fff; padding: 8px; }
.mfa-qr svg { width: 100%; height: 100%; display: block; }
.mfa-secret { text-align: center; font-size: .9rem; color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
[dir="rtl"] .card, [dir="rtl"] .table th, [dir="rtl"] .table td { text-align: start; }

/* ============================ Form layout ============================ */
.card-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.6rem; }
.form-grid { display: grid; gap: 0 1.1rem; grid-template-columns: 1fr 1fr; }
.form-grid .col-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.policy-edit-row { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr auto; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.weekrow { display: grid; grid-template-columns: 110px minmax(140px, 1.4fr) 2fr auto; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.weekrow--head { margin-bottom: .35rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.weekrow--head span { padding-inline-start: .2rem; }
@media (max-width: 640px) { .policy-edit-row, .weekrow { grid-template-columns: 1fr; } .weekrow--head { display: none; } }

/* Password show/hide toggle (enhanced by app.js) */
.pwd-wrap { position: relative; display: block; }
.pwd-wrap .form__input { padding-inline-end: 2.5rem; }
.pwd-toggle { position: absolute; inset-inline-end: .55rem; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; color: var(--muted); padding: .3rem; display: grid; place-items: center; border-radius: 6px; }
.pwd-toggle:hover { color: var(--text); }
.pwd-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }

/* ============================ Accordion modules ============================ */
details.module { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: .85rem; overflow: hidden; }
details.module > summary { list-style: none; cursor: pointer; padding: .85rem 1.1rem; display: flex; align-items: center; gap: .8rem; font-weight: 700; background: var(--surface-2); border-bottom: 1px solid transparent; }
details.module[open] > summary { border-bottom-color: var(--border); }
details.module > summary::-webkit-details-marker { display: none; }
.module__chevron { color: var(--muted); transition: transform .2s ease; flex: none; }
details.module[open] .module__chevron { transform: rotate(90deg); }
.module__count { margin-inline-start: auto; color: var(--muted); font-weight: 500; font-size: .85rem; }
.module__body { padding: .25rem 1.1rem 1rem; }
.module__lessons { list-style: none; margin: 0; padding: 0; }
.module__lessons li { display: flex; align-items: center; gap: .65rem; padding: .6rem .5rem; margin: 0 -.5rem; border-radius: 8px; border-top: 1px solid var(--border); font-size: .94rem; }
.module__lessons li:first-child { border-top: 0; }
.module__lessons li:hover { background: var(--surface-2); }
.module__type { flex: none; width: 22px; text-align: center; font-size: 1rem; }
/* Canvas-style module items: indentation, linked title, per-item publish. */
.module__lessons li.module__item { padding-inline-start: calc(.5rem + var(--indent, 0) * 1.6rem); }
.module__link { color: var(--primary); text-decoration: none; font-weight: 600; }
.module__link:hover { text-decoration: underline; }
.module__kind { margin-inline-start: auto; }
.module__item-actions { display: inline-flex; align-items: center; gap: .25rem; margin-inline-start: .5rem; }
.module__item-actions form { margin: 0; }
.module__item-actions .btn { padding: .15rem .4rem; line-height: 1; }
.module__pub { color: var(--muted); }
.module__pub.is-published { color: var(--success, #3F7D4A); }
.module__item.is-unpublished { opacity: .62; }
.module__item--header { background: var(--surface-2); border-radius: 6px; }
.module__item--header .module__header-text { text-transform: uppercase; letter-spacing: .04em; font-size: .82rem; color: var(--muted); }
.module__add { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .5rem; margin-top: .9rem; }
.module__add-existing > summary { list-style: none; display: inline-flex; cursor: pointer; }
.module__add-existing > summary::-webkit-details-marker { display: none; }
.module__add-existing[open] { flex: 1 1 100%; }
/* Drag-and-drop reordering. */
.drag-grip { flex: none; cursor: grab; color: var(--muted); font-size: 1rem; line-height: 1; user-select: none; padding: 0 .15rem; opacity: .55; }
.drag-grip:hover { opacity: 1; }
.drag-grip:active { cursor: grabbing; }
details.module > summary .drag-grip { margin-inline-end: .1rem; }
.module__item.dragging, details.module.dragging { opacity: .5; }
[data-reorder] .module__item.dragging { background: var(--primary-soft); }
details.module.dragging { box-shadow: 0 0 0 2px var(--primary); }
/* Item lists are drop targets, including empty modules. */
.module__lessons--droppable { min-height: .5rem; border-radius: 8px; transition: box-shadow .12s ease, background .12s ease; }
.module__lessons.is-drop-target { box-shadow: inset 0 0 0 2px var(--primary); background: var(--primary-soft); }
.module__drop-hint { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .8rem; margin: .25rem 0; color: var(--muted); font-size: .85rem; border: 1px dashed var(--border-strong); border-radius: 8px; }
.module__lessons:has(.module__item) .module__drop-hint { display: none; }
/* A module emptied by dragging keeps a visible drop zone. */
.module__lessons--droppable.is-empty { min-height: 2.75rem; display: flex; align-items: center; justify-content: center; }
/* The label comes from the (translated) data-empty-label attribute on the list. */
.module__lessons--droppable.is-empty::after { content: attr(data-empty-label); color: var(--muted); font-size: .85rem; }
.module__lessons--droppable.is-empty .module__drop-hint { display: none; }

/* ============================ Reports / verify ============================ */
.icon-tile { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: .9rem; }
.icon-tile svg { width: 21px; height: 21px; stroke: currentColor; fill: none; }
.verify-card { max-width: 520px; margin: 1rem auto; text-align: center; }
.verify-badge { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1.1rem; font-size: 2rem; }
.verify-badge--ok { background: var(--success-soft); color: var(--success); }
.verify-badge--bad { background: var(--danger-soft); color: var(--danger); }

/* ============================ Threads (discussions) ============================ */
.post { display: flex; gap: .85rem; padding: 1.1rem 0; border-top: 1px solid var(--border); }
.post:first-child { border-top: 0; }
.post__body { flex: 1; min-width: 0; }
.post__head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .25rem; flex-wrap: wrap; }
.post__author { font-weight: 600; }
.post__time { color: var(--muted); font-size: .82rem; }
.post__text { white-space: pre-wrap; word-break: break-word; }
.composer { margin-top: 1.25rem; }
.composer textarea { min-height: 96px; }

/* ============================ Inbox thread ============================ */
.thread-wrap { max-width: 780px; }
.thread { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.25rem; }
.thread-day { text-align: center; margin: .75rem 0 .35rem; }
.thread-day span { display: inline-block; padding: .15rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: .74rem; font-weight: 600; }
.thread-row { display: flex; align-items: flex-end; gap: .55rem; }
.thread-row.is-me { flex-direction: row-reverse; }
.thread-row.is-grouped { margin-top: -.2rem; }
.thread-row__avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-gradient); color: #fff; font-weight: 700; font-size: .72rem; }
.thread-row__spacer { flex: none; width: 32px; }
.msg { max-width: 76%; padding: .55rem .9rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.msg__author { font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; }
.msg__text { white-space: pre-wrap; word-break: break-word; }
.msg__meta { font-size: .72rem; color: var(--muted); margin-top: .25rem; text-align: end; }
.thread-row.is-them .msg { border-end-start-radius: 5px; }
.thread-row.is-me .msg { border-end-end-radius: 5px; background: var(--primary); border-color: var(--primary); color: #fff; }
.thread-row.is-me .msg__author { display: none; }
.thread-row.is-me .msg__meta { color: rgba(255,255,255,.82); }
/* Back-compat for any old markup. */
.msg--me { margin-inline-start: auto; background: var(--primary); border-color: var(--primary); color: #fff; }
.msg--me .msg__meta { color: rgba(255,255,255,.82); }

/* List meta helpers */
.list__main { min-width: 0; }
.list__meta { color: var(--muted); font-size: .85rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.list__title { font-weight: 600; }
.list__title a { color: var(--text); text-decoration: none; }
.list__title a:hover { color: var(--primary); }

/* ============================ Quiz runner ============================ */
.quiz-bar { position: sticky; top: calc(var(--topbar-h) + 0px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm); }
.quiz-timer { font-weight: 700; font-variant-numeric: tabular-nums; padding: .4rem .85rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.quiz-timer.is-low { background: var(--danger-soft); color: var(--danger); }
.qcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem 1.4rem; margin-bottom: 1rem; }
.qcard__head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.qcard__num { font-weight: 700; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.qcard__points { color: var(--muted); font-size: .82rem; }
.qcard__prompt { font-weight: 600; margin-bottom: .9rem; white-space: pre-wrap; }
.opt { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .5rem; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt input { accent-color: var(--primary); width: 17px; height: 17px; }
.quiz-score { font-size: 3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.quiz-ring { width: 120px; height: 120px; }

/* ============================ Calendar ============================ */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-head__nav { display: flex; align-items: center; gap: .5rem; }
.cal-head__title { margin: 0; font-size: 1.2rem; min-width: 8.5rem; text-align: center; }
.cal-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.cal-legend__item { display: inline-flex; align-items: center; gap: .35rem; }
.cal-dot { width: .65rem; height: .65rem; border-radius: 50%; }
.cal-dot--event { background: var(--primary); }
.cal-dot--due { background: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal__dow { background: var(--surface-2); padding: .5rem; text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal__day { background: var(--surface); min-height: 108px; padding: .45rem; font-size: .8rem; display: flex; flex-direction: column; gap: .2rem; }
.cal__day.is-out { background: var(--surface-2); }
.cal__day.is-today { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.cal__num { font-weight: 600; font-size: .78rem; color: var(--muted); align-self: flex-start; }
.cal__day.is-today .cal__num { background: var(--primary); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-grid; place-items: center; }
.cal__ev { display: block; padding: .18rem .42rem; border-radius: 6px; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; border-inline-start: 3px solid transparent; }
.cal__ev--event { background: var(--primary-soft); color: var(--primary); border-inline-start-color: var(--primary); }
.cal__ev--due { background: var(--accent-soft); color: var(--accent); border-inline-start-color: var(--accent); }
a.cal__ev:hover { filter: brightness(.96); text-decoration: underline; }
.cal__ev b { font-weight: 700; }
.cal__more { font-size: .72rem; }
.cal__more > summary { cursor: pointer; color: var(--muted); font-weight: 600; list-style: none; padding: .1rem .2rem; }
.cal__more > summary::-webkit-details-marker { display: none; }
.cal__more > summary:hover { color: var(--text); }
.cal__more-list { display: flex; flex-direction: column; gap: .2rem; margin-top: .2rem; }
@media (max-width: 640px) { .cal__day { min-height: 72px; } .cal__ev { font-size: .65rem; } }

/* ============================ Canvas-style dashboard ============================ */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 340px); gap: clamp(1.25rem, 2vw, 2rem); align-items: start; }
.dash__rail { display: flex; flex-direction: column; gap: 1rem; }
/* Course cards flow into as many columns as fit and stretch to fill the row, so
   the dashboard uses the full width on any screen. auto-fill keeps a lone card
   card-sized rather than stretching it across the whole row. */
.ccards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(248px, 100%), 1fr)); gap: 1.25rem; }
.ccard { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; transition: box-shadow .15s ease, transform .15s ease; }
.ccard:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.ccard__head { height: 116px; position: relative; background-blend-mode: multiply; }
.ccard__head::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(0, 0, 0, .12)); pointer-events: none; }
.ccard__pub { z-index: 1; }
.ccard__pub { position: absolute; top: .6rem; inset-inline-start: .6rem; }
.ccard__pub .btn { background: rgba(255, 255, 255, .92); color: #1f2937; border: 0; }
.ccard__body { padding: .85rem 1rem .4rem; flex: 1; }
.ccard__title { font-weight: 700; text-decoration: none; display: block; line-height: 1.3; }
.ccard__title:hover { text-decoration: underline; }
.ccard__meta { color: var(--muted); font-size: .82rem; margin: .25rem 0 0; }
/* The sections the viewer teaches / sits in, under the course meta line. */
.ccard__sections { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: .45rem 0 0; font-size: .78rem; color: var(--muted); }
.ccard__sections .chip { font-size: .74rem; padding: .15rem .5rem; text-decoration: none; }
.ccard__sections a.chip:hover { color: var(--text); border-color: var(--primary, var(--border)); }
.ccard__actions { display: flex; gap: .35rem; padding: .5rem .8rem .7rem; }
.ccard__actions a { color: var(--muted); display: inline-flex; padding: .35rem; border-radius: 8px; transition: background .12s ease, color .12s ease; }
.ccard__actions a:hover { background: var(--surface-2); color: var(--text); }
/* Rail sections are panels now (surface + border) for a more finished look. */
.dash-rail__section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.dash-rail__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .6rem; }
.dash-rail__head span { font-weight: 700; font-size: .98rem; }
.dash-rail__link { font-size: .82rem; }
.dash-rail__section .muted { font-size: .86rem; }
.dash-rail__btn { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .7rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; transition: background .12s ease, border-color .12s ease; }
.dash-rail__btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.dash-rail__btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.dash-rail__btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

/* Dashboard "To do" / "Recent feedback" agenda lists */
.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.agenda__item { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.agenda__item:last-child { border-bottom: 0; padding-bottom: 0; }
.agenda__item:first-child { padding-top: 0; }
.agenda__body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.agenda__type { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); }
.agenda__type--quiz { color: var(--primary); }
.agenda__title { font-size: .88rem; font-weight: 600; color: var(--text); text-decoration: none; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.agenda__title:hover { color: var(--primary); text-decoration: underline; }
.agenda__meta { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda__due { flex: none; font-size: .76rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; text-align: end; padding-top: .1rem; }
.agenda__item--overdue .agenda__due { color: var(--danger, #B23B32); }
.agenda__grade { flex: none; font-size: .85rem; font-weight: 700; white-space: nowrap; text-align: end; padding-top: .1rem; }
.agenda__grade.score-a { color: var(--success); }
.agenda__grade.score-b { color: var(--info); }
.agenda__grade.score-c { color: var(--warning); }
.agenda__grade.score-d { color: var(--danger); }

@media (max-width: 900px) { .dash { grid-template-columns: minmax(0, 1fr); } .dash__rail { order: -1; } }

/* ============================ Canvas-style syllabus ============================ */
.syllabus__main { max-width: 880px; }
.syllabus__summary th:last-child, .syllabus__summary td:last-child { text-align: end; }
.syllabus__icon { margin-inline-end: .4rem; }

/* ============================ Canvas-style course home ============================ */
.course-home { display: block; }
.course-home--rail { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.75rem; align-items: start; }
.course-home__rail { display: flex; flex-direction: column; gap: .5rem; position: sticky; top: 1rem; }
.rail-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .35rem; }
.rail-btn { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: .9rem; transition: background .12s ease, border-color .12s ease; }
.rail-btn span { width: 18px; text-align: center; color: var(--muted); }
.rail-btn:hover { background: var(--surface-2); border-color: var(--primary); }
@media (max-width: 900px) { .course-home--rail { grid-template-columns: 1fr; } .course-home__rail { position: static; flex-direction: row; flex-wrap: wrap; } .course-home__rail .rail-title { display: none; } }

/* ============================ Command palette (⌘K) ============================ */
.cmdk-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 100; }
.cmdk-overlay.is-open { display: flex; }
.cmdk { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); overflow: hidden; }
.cmdk__input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 1rem 1.15rem; font: inherit; font-size: 1.05rem; background: transparent; color: var(--text); outline: none; }
.cmdk__results { max-height: 52vh; overflow-y: auto; padding: .4rem; }
.cmdk__item { display: flex; align-items: baseline; gap: .6rem; padding: .65rem .75rem; border-radius: 9px; text-decoration: none; color: var(--text); cursor: pointer; }
.cmdk__item.is-active, .cmdk__item:hover { background: var(--surface-2); }
.cmdk__item small { color: var(--muted); }
.cmdk__empty { padding: 1.6rem; text-align: center; color: var(--muted); }
.cmdk__hint { padding: .55rem .9rem; border-top: 1px solid var(--border); font-size: .74rem; color: var(--muted); display: flex; gap: 1.1rem; }

/* ============================ Responsive ============================ */
@media (max-width: 960px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    /* Tablets: the rail becomes a top strip that WRAPS, so every entry stays
       on screen (no sideways scrolling with an invisible scrollbar). */
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; border-inline-end: 0; border-bottom: 1px solid var(--border); }
    .sidebar__brand { padding: .8rem 1rem; white-space: nowrap; }
    .sidebar__brand--logo { flex-direction: row; text-align: start; gap: .6rem; }
    .sidebar__brand--logo .brand-mark--logo { --logo-h: 52px; --logo-w: 160px; padding: 3px; border-radius: 9px; }
    .sidebar__brand--logo > span:last-child { white-space: nowrap; font-size: 1rem; display: block; }
    .sidebar__nav { flex-direction: row; flex-wrap: wrap; padding: .4rem .5rem; }
    .sidebar__section, .sidebar__foot { display: none; }
    .sidebar__link { white-space: nowrap; width: auto; min-width: 64px; }
    .sidebar__link.is-active::before { display: none; }
    .tray { inset-inline-start: 0; }
}
/* Phones (and the installed app): a fixed bottom tab bar like the course
   shell's — four primary items plus "More", which opens a sheet with the
   rest and Sign out. Thumb-reachable, never wider than the screen, and the
   install banner / toasts sit above it. */
@media (max-width: 720px) {
    /* The bar is exactly --bottom-nav-h tall (border included) so the content
       padding, the Courses tray, the install banner and toasts can clear it. */
    :root { --bottom-nav-h: 58px; }
    .shell { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
    .sidebar {
        position: fixed; top: auto; bottom: 0; inset-inline: 0; z-index: 60; width: 100%; box-sizing: border-box;
        height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
        flex-direction: row; align-items: stretch; border-bottom: 0; border-top: 1px solid rgba(255, 255, 255, .08);
        padding-bottom: env(safe-area-inset-bottom, 0px); overflow: visible;
    }
    /* The tab bar keeps its dark plum look (only desktop went light). */
    .sidebar { background: var(--rail-bg, #1E1824); color: rgba(255, 255, 255, .82); }
    .sidebar__link { flex-direction: column; gap: 4px; color: rgba(255, 255, 255, .78); font-weight: 600; text-align: center; line-height: 1.2; }
    .sidebar__link svg { width: 22px; height: 22px; stroke-width: 1.75; }
    .sidebar__link:hover { background: var(--sidebar-item-hover-bg); color: #fff; }
    .sidebar__link.is-active { background: var(--sidebar-item-active-bg); color: #fff; font-weight: 600; }
    .sidebar__badge { position: absolute; min-width: 16px; height: 16px; padding: 0 4px; background: #e8590c; font-size: .6rem; }
    .sidebar__brand { display: none; }
    .sidebar__nav { width: 100%; height: calc(var(--bottom-nav-h) - 1px); flex-direction: row; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 0 2px; overflow: visible; }
    .sidebar__link { display: none; }
    .sidebar__link[data-nav-primary], .sidebar__more {
        display: flex; flex: 1 1 0; min-width: 0; width: auto; min-height: 0;
        justify-content: center; padding: 4px 2px; border-radius: 10px; margin: 2px 1px; font-size: .62rem;
    }
    /* Pop-over panels opened from page-header buttons (e.g. Calendar's
       "+ Personal event") anchor to the button's end edge; on a phone that
       pushed them off the start edge of the screen. */
    .page-header__actions .usermenu__panel { inset-inline-end: auto !important; inset-inline-start: 0; width: min(320px, calc(100vw - 2rem)) !important; max-width: calc(100vw - 2rem); }
    .sidebar__link > span:not(.sidebar__badge) { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidebar__badge { top: 2px; inset-inline-end: auto; inset-inline-start: calc(50% + 4px); }
    .sidebar__link.is-active { box-shadow: none; }
    /* Courses tray: full width above the tab bar. */
    .tray { inset-inline-start: 0; width: 100%; max-width: none; bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
    /* Install banner and toasts clear the tab bar (the course shell does the same in lms.css). */
    .shell ~ .pwa-install { bottom: calc(var(--bottom-nav-h) + 10px + env(safe-area-inset-bottom, 0px)); max-height: min(64vh, 520px); }
    body:has(.shell) .app-toast { bottom: calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom, 0px)); }
    html.has-install-banner body:has(.shell) .app-toast { bottom: calc(var(--pwa-install-h, 0px) + var(--bottom-nav-h) + 24px + env(safe-area-inset-bottom, 0px)); }
    /* "More" sheet. */
    .navsheet-overlay { position: fixed; inset: 0; z-index: 95; background: rgba(15, 23, 42, .35); backdrop-filter: blur(2px); }
    .navsheet-overlay.is-open { display: block; }
    .navsheet {
        position: absolute; inset-inline: 0; bottom: 0; max-height: 80vh; overflow-y: auto; overscroll-behavior: contain;
        background: var(--surface); color: var(--text); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-pop);
        padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .navsheet__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px; }
    .navsheet__head h2 { margin: 0; font-size: 1.05rem; }
    .navsheet__close { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); min-width: 44px; min-height: 44px; }
    .navsheet__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .navsheet__list form { margin: 0; display: contents; }
    .navsheet__link {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 68px; padding: 8px 4px;
        border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none;
        font: inherit; font-size: .74rem; font-weight: 600; text-align: center; cursor: pointer; width: 100%;
    }
    .navsheet__link > span:not(.sidebar__badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .navsheet__link svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.75; }
    .navsheet__link.is-active { background: var(--primary); color: #fff; }
    .navsheet__link .sidebar__badge { position: static; display: inline-grid; margin-top: -2px; }
    .navsheet__link:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
    .navsheet { transform: translateY(16px); animation: navsheet-in .18s ease forwards; }
    @keyframes navsheet-in { to { transform: none; } }
}
@media (max-width: 720px) {
    .topbar__search { max-width: none; }
    .topbar__page { display: none; }
    .usermenu__name { display: none; }
    .topbar__logo { display: inline-flex; }
    .page-header { align-items: flex-start; }
}
/* Small phones: tighten the topbar so search + actions fit 320px wide. The
   language button keeps its accessible name (aria-label) when the label hides. */
@media (max-width: 480px) {
    .topbar { gap: .5rem; padding: 0 .75rem; }
    .topbar__actions { gap: .35rem; }
    .locale-switch__btn { padding: 0 .55rem; min-width: 38px; justify-content: center; }
    .locale-switch__btn span { display: none; }
}

/* ============================ E-signature module ============================ */
.esign-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.esign-list { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.esign-list__row {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.esign-list__main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.esign-list__main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.esign-list__main .muted { font-size: .82rem; }
.esign-list__actions { display: flex; align-items: center; gap: .4rem; flex: none; }
.esign-list__actions form { margin: 0; }
.esign-recip__order {
    flex: none; width: 24px; height: 24px; border-radius: var(--radius-full); display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--border-strong); font-size: .8rem; font-weight: 600;
}
.esign-recip__dot { flex: none; width: 12px; height: 12px; border-radius: var(--radius-full); box-shadow: 0 0 0 2px var(--surface); }
.esign-recip__fields { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr auto; }
@media (max-width: 640px) { .esign-recip__fields { grid-template-columns: 1fr; } }
.radio-row { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; padding: .4rem 0; }
.radio-row input { margin-top: .2rem; flex: none; }

/* ---- E-signature field editor ---- */
.esign-editor__toolbar { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.esign-tool__group { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.esign-tool__label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.esign-tool__select { width: auto; min-width: 150px; padding: .4rem .6rem; }
.esign-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.esign-chip::before { content: ""; width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--chip, var(--primary)); flex: none; }
.esign-chip.is-active { border-color: var(--chip, var(--primary)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--chip, var(--primary)) 30%, transparent); }
.esign-editor__pages { margin-top: 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.esign-doc__title { margin: 0 0 .5rem; font-size: .95rem; }
.esign-page { position: relative; margin: 0 auto 1rem; max-width: 820px; border: 1px solid var(--border); box-shadow: var(--shadow-1); background: var(--surface); }
.esign-page__canvas { display: block; width: 100%; }
.esign-page__overlay { position: absolute; inset: 0; cursor: crosshair; }
.esign-field { position: absolute; box-sizing: border-box; border: 1.5px dashed var(--field, var(--primary)); background: color-mix(in srgb, var(--field, var(--primary)) 12%, transparent); border-radius: 3px; cursor: move; min-width: 24px; min-height: 16px; touch-action: none; }
.esign-field__label { position: absolute; inset-inline-start: 2px; top: 1px; font-size: .62rem; font-weight: 700; color: var(--field, var(--primary)); text-transform: uppercase; letter-spacing: .03em; pointer-events: none; white-space: nowrap; }
.esign-field__del { position: absolute; inset-inline-end: -9px; top: -9px; width: 18px; height: 18px; border-radius: var(--radius-full); border: 0; background: var(--danger); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.esign-field__resize { position: absolute; inset-inline-end: -4px; bottom: -4px; width: 12px; height: 12px; background: var(--field, var(--primary)); border: 2px solid var(--surface); border-radius: 2px; cursor: nwse-resize; touch-action: none; }

/* ---- E-signature signing ceremony (public) ---- */
.sign-body { background: var(--bg); }
.sign-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.sign-topbar__brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; }
.sign-topbar__powered { font-size: .8rem; }
.sign-main { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.sign-consent { max-width: 640px; margin: 1.5rem auto; }
.sign-consent__agree { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.sign-wrap { max-width: 640px; margin: 1rem auto; }
.sign-done__tick { width: 56px; height: 56px; margin: 0 auto; border-radius: var(--radius-full); background: var(--ok-bg); color: var(--ok-fg); display: grid; place-items: center; }
.sign-done__tick svg { width: 30px; height: 30px; }

.sign-ceremony__bar { position: sticky; top: 56px; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .6rem .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-1); margin-bottom: 1rem; }
.sign-ceremony__actions { display: flex; align-items: center; gap: .6rem; }
.sign-ceremony__pages { display: flex; flex-direction: column; gap: 1.5rem; }

.sign-field { position: absolute; box-sizing: border-box; border: 1.5px solid var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); border-radius: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sign-field.is-required { border-style: solid; box-shadow: 0 0 0 2px color-mix(in srgb, var(--warning) 40%, transparent); }
.sign-field.is-filled { border-color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); box-shadow: none; }
.sign-field--click { cursor: pointer; font-size: .7rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.sign-field__input { width: 100%; height: 100%; border: 0; background: transparent; font: inherit; font-size: .8rem; padding: 0 .3rem; color: var(--text); }
.sign-field__input:focus { outline: none; }
.sign-field__check { width: 18px; height: 18px; }
.sign-field__sig { max-width: 100%; max-height: 100%; object-fit: contain; }
.sign-field__typed { font-family: var(--font-serif, Georgia, serif); font-size: 1rem; font-style: italic; color: var(--text); white-space: nowrap; }

.sign-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(20, 26, 34, .45); padding: 1rem; }
.sign-modal[hidden] { display: none; }
.sign-modal__card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); padding: 1.5rem; width: 100%; max-width: 480px; }
.sign-pad { width: 100%; height: 150px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); touch-action: none; cursor: crosshair; }
.sign-typed { font-family: var(--font-serif, Georgia, serif); font-size: 1.2rem; font-style: italic; }

/* ---- E-signature void disclosure ---- */
.esign-void { position: relative; }
.esign-void > summary { list-style: none; cursor: pointer; }
.esign-void > summary::-webkit-details-marker { display: none; }
.esign-void__form { position: absolute; inset-inline-end: 0; margin-top: .4rem; z-index: 20; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-3); padding: .85rem; }

/* ---- E-signature audit timeline ---- */
.esign-timeline { list-style: none; margin: 1rem 0 0; padding: 0; position: relative; }
.esign-timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.esign-timeline__item { position: relative; display: flex; gap: .85rem; padding: 0 0 1rem 0; }
.esign-timeline__item:last-child { padding-bottom: 0; }
.esign-timeline__dot { position: relative; z-index: 1; flex: none; width: 14px; height: 14px; margin-top: 2px; border-radius: var(--radius-full); background: var(--primary); box-shadow: 0 0 0 3px var(--surface); }

/* ---- E-signature dashboard progress ---- */
.esign-progress { display: inline-flex; align-items: center; gap: .5rem; }
.esign-progress__bar { width: 72px; height: 6px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.esign-progress__bar > span { display: block; height: 100%; background: var(--success); border-radius: inherit; }

/* =========================================================================
   Localization & right-to-left (both shells)
   Layout uses logical properties (margin-inline-*, inset-inline-*, text-align:
   start) so it mirrors automatically under dir="rtl"; the rules below cover
   what logical properties cannot express. Nothing here applies to LTR.
   ========================================================================= */

/* Language switcher — a compact pill showing the other language in its own script. */
.locale-switch { display: inline-flex; margin: 0; }
.locale-switch__btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted, var(--muted)); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.locale-switch__btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.locale-switch__btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.locale-switch__btn svg { flex: none; }
.lms-shell .locale-switch__btn { min-height: 34px; border-radius: var(--radius-sm); border-color: var(--c-border); background: var(--c-surface); color: var(--c-muted); }
.auth-card__locale { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.sign-topbar .locale-switch { margin-inline-start: auto; }

/* Direction-dependent glyphs (lms_icon marks them .lms-icon--dir) and the
   text arrows used in prev/next controls flip; neutral icons never do. */
[dir="rtl"] .lms-icon--dir,
[dir="rtl"] .breadcrumb-sep svg,
[dir="rtl"] [data-sg-nav],
[dir="rtl"] .icon-flip-rtl { transform: scaleX(-1); }

/* Arabic is cursive: any letter-spacing breaks the joins between letters and
   uppercase transforms are meaningless — neutralise both for Arabic UI. */
html[lang="ar"] body, html[lang="ar"] body * { letter-spacing: normal !important; }
html[lang="ar"] body { line-height: 1.65; }
/* Space Grotesk's flagged "1" reads as Arabic-Indic "١" beside Arabic text, so
   Arabic pages take Latin glyphs (digits, codes) for headings from Source Sans. */
html[lang="ar"] { --font-display: 'IBM Plex Sans Arabic', 'Source Sans 3', var(--font); }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 { line-height: 1.4; }

/* User-generated content keeps its own direction: an English course title or
   paragraph inside the Arabic UI (or Arabic content in the English UI) is laid
   out by its first strong character, so "Welcome!" never renders "!Welcome". */
.cursio-content :where(p, li, h1, h2, h3, h4, h5, h6, blockquote, td, th, dd, dt, figcaption, div),
:where(.item-title, .ccard__title, .cs-meta-title, .module-title, .agenda__title, .tray__name, .tray__meta, .person-name, .thread-row .msg) { unicode-bidi: plaintext; }
.cursio-content :where(p, li, h1, h2, h3, h4, h5, h6, blockquote, dd, dt, figcaption) { text-align: start; }
/* Code, maths and identifiers always read left-to-right. */
.cursio-content :where(pre, code, kbd, samp), .mono, .td-mono, input[type="email"], input[type="url"], input[type="tel"], .mjx-container { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .cursio-content pre, [dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"] { text-align: left; }

/* Sticky first column's divider sits on the inline-end side. */
[dir="rtl"] .gb-sticky-col { box-shadow: -1px 0 0 var(--border); }
/* Document canvases (PDF pages with placed e-sign fields, SpeedGrader
   annotations) use physical page coordinates — never mirror them. */
.esign-page, .pdf-annot__layer, .pdf-annot { direction: ltr; }

/* Server-side validation feedback (partials/form-feedback.php + app.js). */
.form-error-summary ul { margin: .35rem 0 0; padding-inline-start: 1.1rem; }
.form-error-summary:focus { outline: 2px solid var(--danger, #B23B32); outline-offset: 2px; }
.field-error { margin: .3rem 0 0; font-size: .82rem; font-weight: 600; color: var(--danger, #B23B32); }
[aria-invalid="true"] { border-color: var(--danger, #B23B32) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger, #B23B32) 18%, transparent); }
.lms-shell .form-error-summary { flex-direction: column; gap: 4px; }
.alert--info { background: var(--primary-soft); color: var(--text); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }

/* PWA notices (app.js) — sit above the phone bottom bar and safe area. */
.app-toast { position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 200; margin-inline: auto; max-width: 520px; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 16px; border-radius: 12px; background: #221C17; color: #fff; font-size: .92rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); transform: translateY(150%); opacity: 0; transition: transform .2s ease, opacity .2s ease; pointer-events: none; }
.app-toast.is-visible { transform: none; opacity: 1; pointer-events: auto; }
.app-toast__btn { flex: none; min-height: 36px; padding: 0 14px; border-radius: 8px; border: 0; background: #fff; color: #221C17; font: inherit; font-weight: 700; cursor: pointer; }
@media (max-width: 640px) { .lms-shell ~ .app-toast, body:has(.lms-shell) .app-toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .app-toast { transition: none; } }

/* Phones: wide data tables scroll inside themselves, never the whole page. */
@media (max-width: 720px) {
    .table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ===================== Install the app (PWA banner + /install) =====================
   Banner: partials/install-prompt.php, driven by the PWA block of app.js. A
   non-modal card pinned to the bottom (above the safe area; above the phone
   tab bar in the course shell — see lms.css), never covering the page's last
   actions: while it is open, html.has-install-banner reserves its height
   (--pwa-install-h) under the content. Help page: install/index.php. */
.pwa-install[hidden], .pwa-install [hidden], .install-help [hidden] { display: none !important; }
.pwa-install {
    position: fixed; z-index: 50;
    left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-height: min(72vh, 560px); overflow-y: auto; overscroll-behavior: contain;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
    font-size: .88rem; line-height: 1.4;
}
@media (min-width: 720px) {
    .pwa-install { left: auto; right: auto; inset-inline-end: 20px; width: min(440px, calc(100vw - 40px)); }
}
@media (prefers-reduced-motion: no-preference) {
    .pwa-install { transform: translateY(12px); opacity: 0; transition: transform .22s ease, opacity .22s ease; }
    .pwa-install.is-visible { transform: none; opacity: 1; }
}
.pwa-install:focus { outline: none; }
.pwa-install:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; box-shadow: var(--shadow-pop); }
.pwa-install__head { display: flex; align-items: flex-start; gap: 10px; }
.pwa-install__icon { flex: none; width: 40px; height: 40px; border-radius: 10px; }
.pwa-install__text { min-width: 0; }
.pwa-install__title { margin: 0; font-size: .95rem; font-weight: 700; line-height: 1.3; }
.pwa-install__benefits { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--muted); font-size: .8rem; }
.pwa-install__benefits li { position: relative; padding-inline-start: 1.05em; }
.pwa-install__benefits li::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--primary); font-weight: 700; }
.pwa-install__how { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.pwa-install__how-title { margin: 0 0 2px; font-weight: 600; }
.pwa-steps { margin: 0; padding-inline-start: 1.4em; display: grid; gap: 2px; }
.pwa-steps--plain { padding-inline-start: 1.1em; }
.pwa-note { margin: 0; }
.pwa-glyph { display: inline-block; vertical-align: -3px; margin-inline: 1px; color: var(--primary); }
.pwa-install__actions, .install-help__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pwa-install__btn {
    flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.pwa-install__btn:hover { background: var(--surface-2); }
.pwa-install__btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.pwa-install__btn--primary:hover { background: var(--primary-strong, var(--primary)); }
.pwa-install__btn--quiet { border-color: transparent; background: transparent; color: var(--muted); }
.pwa-install__btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; box-shadow: none; }
.install-help .pwa-install__btn { flex: 0 1 auto; }
/* Keep the page's last actions reachable, and lift toasts above the banner. */
html.has-install-banner body { padding-bottom: calc(var(--pwa-install-h, 0px) + 24px); }
html.has-install-banner .app-toast { bottom: calc(var(--pwa-install-h, 0px) + 24px + env(safe-area-inset-bottom, 0px)); }
/* Already running as the installed app: no install entry points. */
.is-standalone [data-pwa-open], .is-standalone [data-pwa-open-row] { display: none !important; }
.lms-shell .cs-footer-install { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 4px; color: var(--c-primary); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.lms-shell .cs-footer-install:hover { text-decoration: underline; }

/* /install help page. */
.install-help { max-width: 980px; display: grid; gap: 1.1rem; }
.install-help__hero { display: flex; align-items: center; gap: 1rem; }
.install-help__icon { flex: none; width: 64px; height: 64px; border-radius: 16px; }
.install-help__title { margin: 0; font-size: clamp(1.4rem, 3.6vw, 1.9rem); }
.install-help__lead { margin: .3rem 0 0; color: var(--muted); }
.install-help__status { display: grid; gap: .4rem; }
.install-help__status p { margin: 0; }
.install-help__actions { margin-top: 0; }
.install-help__done { color: var(--success, #2E7D4F); font-weight: 600; }
.install-help__grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.install-help__card { min-width: 0; padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.install-help__platform { scroll-margin-top: 1rem; }
.install-help__platform.is-detected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.install-help__h2 { margin: 0 0 .6rem; font-size: 1.08rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.install-help__h3 { margin: .9rem 0 .35rem; font-size: .95rem; }
.install-help__h3.is-detected { color: var(--primary); }
.install-help__you { display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .76rem; font-weight: 700; }
.install-help__list { margin: 0; padding: 0; list-style: none; display: grid; gap: .3rem; }
.install-help__list--check li { position: relative; padding-inline-start: 1.3em; }
.install-help__list--check li::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--primary); font-weight: 700; }
.install-help__fine { margin: .6rem 0 0; color: var(--muted); font-size: .9rem; }
/* Installation check (/install): one row per requirement, coloured by the
   browser's report; the verdict line repeats the colour for the summary. */
.install-diag__list { margin: .8rem 0 0; display: grid; gap: .45rem; }
.install-diag__row { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: .25rem .9rem; align-items: start; padding: .5rem; padding-inline-start: 1.6rem; position: relative; border-radius: var(--radius-sm, 8px); background: var(--surface-2, rgba(0,0,0,.03)); }
.install-diag__row::before { content: ""; position: absolute; inset-inline-start: .55rem; top: .95rem; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.install-diag__row[data-status="ok"]::before, .install-diag__summary[data-status="ok"] { --diag: var(--success, #2E7D4F); }
.install-diag__row[data-status="warn"]::before, .install-diag__summary[data-status="warn"] { --diag: var(--warning, #B26A00); }
.install-diag__row[data-status="fail"]::before, .install-diag__summary[data-status="fail"] { --diag: var(--danger, #B3261E); }
.install-diag__row[data-status="info"]::before, .install-diag__summary[data-status="info"] { --diag: var(--primary); }
.install-diag__row[data-status]:not([data-status="pending"])::before { background: var(--diag); }
.install-diag__row[data-status="pending"]::before { animation: install-diag-pulse 1.2s ease-in-out infinite; }
@keyframes install-diag-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .install-diag__row[data-status="pending"]::before { animation: none; } }
.install-diag__label { margin: 0; font-weight: 600; font-size: .92rem; }
.install-diag__hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.install-diag__value { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.install-diag__summary { margin: .9rem 0 0; padding: .7rem .9rem; border-radius: var(--radius-sm, 8px); border: 1px solid var(--diag, var(--border)); color: var(--diag, inherit); font-weight: 600; background: var(--surface); }
@media (max-width: 480px) { .install-diag__row { grid-template-columns: 1fr; } }
.install-help .pwa-steps { font-size: .95rem; }
/* ===================== end Install the app ===================== */

/* ===================== Sign-in page (institutional login) =====================
   Login form tweaks for resources/views/auth/login.php: label row with the
   "Forgot password?" link, a 44px show/hide toggle, provider buttons that
   wrap on narrow phones. Logical properties only (RTL/LTR). */
.auth-login__hint { margin: .3rem 0 0; }
.auth-login__email { text-align: start; }
[dir="rtl"] .auth-login__email { text-align: end; }
.auth-login__label-row { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.auth-login__label-row .form__label { margin-bottom: 0; }
.auth-login__forgot { color: var(--primary); font-size: .88rem; font-weight: 600; text-decoration: none; padding-block: .35rem; }
.auth-login__forgot:hover, .auth-login__forgot:focus-visible { text-decoration: underline; }
.auth-login .pwd-wrap { margin-top: .4rem; }
.auth-login__toggle { min-width: 44px; min-height: 44px; inset-inline-end: .1rem; }
.auth-login__toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -4px; }
.auth-login__toggle[aria-pressed="true"] { color: var(--primary); }
.auth-login__toggle svg[hidden] { display: none; }
.auth-sso { flex-wrap: wrap; }
.auth-sso__btn { flex: 1 1 140px; display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 44px; }
.auth-sso__btn svg { flex: none; }
.auth-sso__note { margin: .8rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; text-align: center; }
@media (max-width: 420px) {
    .auth-split__form { padding: 1.5rem 1rem; }
    .auth-title { font-size: 1.45rem; }
}
/* ===================== end Sign-in page ===================== */

/* ---- Admin two-column form pages (course create/edit, terms, departments) ----
   Main column + a side column (live student preview, or the add form). The
   classes were referenced by the views but never defined, so the preview fell
   below the form as unstyled text. */
.bp-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 1.5rem; align-items: start; }
.bp-form-grid > * { min-width: 0; }
@media (max-width: 1100px) { .bp-form-grid { grid-template-columns: minmax(0, 1fr); } }
.bp-stepper { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bp-stepper .btn { min-width: 2.5rem; justify-content: center; }
.bp-preview { position: sticky; top: calc(var(--topbar-h, 64px) + 1rem); display: grid; gap: .6rem; }
@media (max-width: 1100px) { .bp-preview { position: static; } }
.bp-preview__label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.bp-preview__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1); }
.bp-preview__thumb { aspect-ratio: 16 / 7; background: var(--surface-2); display: grid; place-items: center; font-size: 2.2rem; overflow: hidden; }
.bp-preview__body { padding: .9rem 1rem 1rem; display: grid; gap: .3rem; }
.bp-preview__code { font-size: .78rem; font-weight: 700; color: var(--muted); }
.bp-preview__title { font-weight: 700; font-size: 1.05rem; line-height: 1.3; unicode-bidi: plaintext; overflow-wrap: anywhere; }
.bp-preview__meta, .bp-preview__sections { font-size: .85rem; color: var(--muted); }
.bp-preview__summary { font-size: .9rem; unicode-bidi: plaintext; overflow-wrap: anywhere; }

/* ===================== Admin · section roster (People) ===================== */
.section-card__foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.section-card__foot > span:first-child { margin-inline-end: auto; }
.sec-people__add { margin-bottom: 1.5rem; }
.sec-people__h { font-size: 1.05rem; margin: 0 0 .8rem; }
.sec-people__row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.sec-people__row > .form__input, .sec-people__row > div { flex: 1 1 14rem; }
.sec-people__results { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .3rem; max-height: 18rem; overflow: auto; }
.sec-people__results:empty { display: none; }
.sec-people__pick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.sec-people__pick:has(input:disabled) { opacity: .65; cursor: default; }
.sec-people__pick > span:nth-of-type(1) { flex: 1 1 12rem; overflow-wrap: anywhere; }
.sec-people__picked { margin-top: .8rem; }
.sec-people__unpick { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0 0 .3rem; }
.sec-people__paste { margin-top: .9rem; }
.sec-people__paste > summary { cursor: pointer; font-weight: 600; }
.sec-people__paste[open] > summary { margin-bottom: .5rem; }
.sec-people__submit { margin-top: .9rem; }
.sec-people__submit > div { flex: 0 1 14rem; }
.sec-people__check { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; flex: 1 1 14rem; }
.sec-people__hint { font-size: .85rem; margin: .6rem 0 0; }
.sec-people__errors { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
.sec-people__bulk { margin-top: .8rem; }
.sec-people__bulk .form__input { width: auto; min-width: 10rem; }
.sec-people__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sec-people__search [hidden] { display: none; }

/* ── Floating AI assistant (partials/ai-fab.php, js/ai-assistant.js) ─────────
   One round button in the end corner of every signed-in page, in both shells.
   Desktop: bottom corner, panel opens above it. Phones: the button sits above
   the bottom tab bar (app shell ≤720px, course shell ≤640px) and the panel
   becomes a sheet between the top of the screen and the tab bar, so it never
   covers the navigation. It also rises above the install banner. */
.ai-fab { --ai-fab-gap: 20px; --ai-fab-bottom: calc(var(--ai-fab-gap) + env(safe-area-inset-bottom, 0px)); }
.ai-fab__btn {
    position: fixed; inset-inline-end: calc(var(--ai-fab-gap) + env(safe-area-inset-right, 0px)); bottom: var(--ai-fab-bottom); z-index: 80;
    width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
    background: var(--primary); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .12);
    transition: transform .15s ease, box-shadow .15s ease;
}
.ai-fab__btn svg { width: 24px; height: 24px; stroke: currentColor; }
.ai-fab__btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, .26); }
.ai-fab__btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.ai-fab__btn[aria-expanded="true"] { transform: scale(.92); }
.ai-panel {
    position: fixed; inset-inline-end: calc(var(--ai-fab-gap) + env(safe-area-inset-right, 0px)); bottom: calc(var(--ai-fab-bottom) + 68px); z-index: 85;
    width: min(400px, calc(100vw - 2 * var(--ai-fab-gap))); height: min(600px, calc(100vh - var(--ai-fab-gap) * 2 - 88px)); height: min(600px, calc(100dvh - var(--ai-fab-gap) * 2 - 88px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.ai-panel[hidden] { display: none; }
.ai-panel__head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--border); }
.ai-panel__mark { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.ai-panel__mark svg { width: 18px; height: 18px; stroke: currentColor; }
.ai-panel__titles { flex: 1 1 auto; min-width: 0; }
.ai-panel__title { margin: 0; font-size: 1rem; line-height: 1.2; }
.ai-panel__sub { margin: 0; font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-panel__icon { flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.ai-panel__icon:hover { background: var(--surface-2); color: var(--text); }
.ai-panel__icon svg { width: 18px; height: 18px; stroke: currentColor; }
.ai-panel__notice { padding: 14px; overflow-y: auto; font-size: .88rem; line-height: 1.5; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ai-panel__notice h3 { margin: 0 0 .4rem; font-size: .95rem; }
.ai-panel__notice ul { margin: 0 0 .75rem; padding-inline-start: 1.1rem; }
.ai-panel__log { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-panel__empty { margin: auto 0; text-align: center; color: var(--muted); font-size: .88rem; padding: 0 12px; }
.ai-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .9rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg--me { align-self: flex-end; background: var(--primary); color: #fff; border-end-end-radius: 4px; }
.ai-msg--ai { align-self: flex-start; background: var(--surface-2); color: var(--text); border-end-start-radius: 4px; }
.ai-msg--pending { color: var(--muted); font-style: italic; }
.ai-panel__error { margin: 0 14px 8px; padding: 8px 10px; border-radius: 10px; font-size: .84rem; background: var(--bad-bg); color: var(--bad-fg); border: 1px solid var(--bad-bd); }
.ai-panel__error[hidden] { display: none; }
.ai-panel__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 4px; border-top: 1px solid var(--border); }
.ai-panel__input { flex: 1 1 auto; min-height: 44px; max-height: 140px; resize: none; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; }
.ai-panel__input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.ai-panel__send { flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; }
.ai-panel__send:disabled { opacity: .5; cursor: default; }
.ai-panel__send svg { width: 18px; height: 18px; stroke: currentColor; }
.ai-panel__foot { margin: 0; padding: 2px 14px 10px; font-size: .7rem; color: var(--muted); text-align: center; }
.ai-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Leave room at the end of the page so the button never hides the last control. */
body:has(.ai-fab) .shell__content { padding-bottom: 88px; }
body:has(.ai-fab) .lms-shell .main-content:not(.flush) { padding-bottom: 88px; }
/* The install banner (when opened from a menu) sits in the same corner. */
html.has-install-banner .ai-fab { --ai-fab-bottom: calc(var(--pwa-install-h, 0px) + var(--ai-fab-gap) + 12px + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) { .ai-fab__btn { transition: none; } }
/* App shell phones: above the bottom tab bar. */
@media (max-width: 720px) {
    .shell ~ .ai-fab { --ai-fab-gap: 14px; --ai-fab-bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom, 0px)); }
    html.has-install-banner .shell ~ .ai-fab { --ai-fab-bottom: calc(var(--pwa-install-h, 0px) + var(--bottom-nav-h) + 26px + env(safe-area-inset-bottom, 0px)); }
}
/* Course shell phones: its rail becomes a 56px bottom bar at ≤640px (lms.css). */
@media (max-width: 640px) {
    .lms-shell ~ .ai-fab { --ai-fab-gap: 14px; --ai-fab-bottom: calc(56px + 14px + env(safe-area-inset-bottom, 0px)); }
    html.has-install-banner .lms-shell ~ .ai-fab { --ai-fab-bottom: calc(var(--pwa-install-h, 0px) + 56px + 26px + env(safe-area-inset-bottom, 0px)); }
}
/* Phones: the panel is a sheet from below the status bar down to the tab bar. */
@media (max-width: 720px) {
    .ai-fab__btn { width: 52px; height: 52px; }
    .shell ~ .ai-fab .ai-panel, .lms-shell ~ .ai-fab .ai-panel {
        inset-inline: 8px; width: auto; top: calc(8px + env(safe-area-inset-top, 0px)); height: auto;
    }
    .ai-fab:has(.ai-panel:not([hidden])) .ai-fab__btn { display: none; }
}
@media (max-width: 720px) {
    .shell ~ .ai-fab .ai-panel { bottom: calc(var(--bottom-nav-h) + 8px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 640px) {
    .lms-shell ~ .ai-fab .ai-panel { bottom: calc(56px + 8px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 641px) and (max-width: 720px) {
    .lms-shell ~ .ai-fab .ai-panel { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
@media print { .ai-fab { display: none !important; } }
.tz-warn { display: inline-block; margin-top: 4px; color: #93600E; font-weight: 600; }

/* Profile pictures in avatar bubbles (lms_avatar with a user id, topbar). */
.avatar--photo, .avatar.has-photo { padding: 0; overflow: hidden; background: var(--surface-2, #eee); }
.avatar--photo img, .avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
