/* ============================================================
   BesicEdu — Design System
   Tokens • Base • Components
   Target: primary-school students (7–11) + their teachers
   ============================================================ */

/* ─── Design tokens ─────────────────────────────────────── */
:root, [data-theme="light"] {
    /* Brand palette */
    --bedu-primary: #4F8EF7;
    --bedu-primary-50: #EEF4FF;
    --bedu-primary-100: #DBE7FE;
    --bedu-primary-600: #2F6AD9;
    --bedu-primary-700: #1F50B0;

    --bedu-accent: #FFB454;
    --bedu-accent-50: #FFF6E8;
    --bedu-accent-600: #E6962D;

    --bedu-success: #34D399;
    --bedu-success-50: #E8FBF3;
    --bedu-success-600: #11A972;

    --bedu-warm: #FF7A8B;
    --bedu-warm-50: #FFEEF1;
    --bedu-warm-600: #E2475D;

    --bedu-danger: #EF4444;

    /* Neutral */
    --bedu-bg: #F7F9FC;
    --bedu-surface: #FFFFFF;
    --bedu-surface-muted: #F2F4F8;
    --bedu-border: #E5E9F0;
    --bedu-text: #1F2937;
    --bedu-text-muted: #6B7280;
    --bedu-text-soft: #9CA3AF;

    /* Navbar surface (slightly transparent over bg) */
    --bedu-navbar-bg: rgba(255, 255, 255, 0.85);
    --bedu-overlay: rgba(15, 23, 42, 0.04);

    color-scheme: light;
}

[data-theme="dark"] {
    /* Brand palette — adjusted for dark surfaces (more vibrant) */
    --bedu-primary: #60A5FA;
    --bedu-primary-50: rgba(96, 165, 250, 0.12);
    --bedu-primary-100: rgba(96, 165, 250, 0.20);
    --bedu-primary-600: #3B82F6;
    --bedu-primary-700: #93C5FD;

    --bedu-accent: #FBBF24;
    --bedu-accent-50: rgba(251, 191, 36, 0.12);
    --bedu-accent-600: #FCD34D;

    --bedu-success: #4ADE80;
    --bedu-success-50: rgba(74, 222, 128, 0.12);
    --bedu-success-600: #86EFAC;

    --bedu-warm: #FB7185;
    --bedu-warm-50: rgba(251, 113, 133, 0.12);
    --bedu-warm-600: #FDA4AF;

    --bedu-danger: #F87171;

    /* Neutral — slate dark palette */
    --bedu-bg: #0B1220;
    --bedu-surface: #131D2F;
    --bedu-surface-muted: #1B2638;
    --bedu-border: #2A3550;
    --bedu-text: #E5EAF3;
    --bedu-text-muted: #9AA6BE;
    --bedu-text-soft: #6F7E9C;

    --bedu-navbar-bg: rgba(11, 18, 32, 0.85);
    --bedu-overlay: rgba(0, 0, 0, 0.25);

    /* Shadows: rely on dark colors over dark bg */
    --bedu-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --bedu-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --bedu-shadow: 0 10px 28px -10px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
    --bedu-shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, 0.65), 0 6px 16px rgba(0, 0, 0, 0.35);

    color-scheme: dark;
}

/* Smooth theme transition (skipped on first paint and reduced motion) */
html.bedu-theme-ready body,
html.bedu-theme-ready .bedu-card,
html.bedu-theme-ready .bedu-tile,
html.bedu-theme-ready .bedu-stat,
html.bedu-theme-ready .bedu-chat,
html.bedu-theme-ready .bedu-navbar,
html.bedu-theme-ready .bedu-input,
html.bedu-theme-ready .bedu-btn,
html.bedu-theme-ready .bedu-msg__bubble,
html.bedu-theme-ready .bedu-resource,
html.bedu-theme-ready .bedu-room,
html.bedu-theme-ready .bedu-feed__item {
    transition:
        background-color 240ms var(--bedu-ease),
        border-color 240ms var(--bedu-ease),
        color 240ms var(--bedu-ease);
}

/* Theme-agnostic tokens — apply for both light and dark */
:root, [data-theme="light"], [data-theme="dark"] {
    /* Typography */
    --bedu-font-heading: "Manrope", "Inter", system-ui, -apple-system, sans-serif;
    --bedu-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bedu-text-base: clamp(15px, 0.95vw + 12px, 17px);
    --bedu-line: 1.6;

    /* Spacing scale (4px base) */
    --bedu-space-1: 4px;
    --bedu-space-2: 8px;
    --bedu-space-3: 12px;
    --bedu-space-4: 16px;
    --bedu-space-5: 24px;
    --bedu-space-6: 32px;
    --bedu-space-7: 48px;
    --bedu-space-8: 64px;

    /* Radius */
    --bedu-radius-sm: 8px;
    --bedu-radius: 14px;
    --bedu-radius-lg: 20px;
    --bedu-radius-pill: 999px;

    /* Motion */
    --bedu-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --bedu-dur-fast: 120ms;
    --bedu-dur: 200ms;

    /* Z-index scale */
    --bedu-z-dropdown: 1000;
    --bedu-z-sticky: 1020;
    --bedu-z-modal: 1050;
    --bedu-z-toast: 1080;

    /* Layout */
    --bedu-navbar-h: 72px;
    --bedu-container: 1320px;
}

/* Light shadows (default :root inherits these) */
:root, [data-theme="light"] {
    --bedu-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --bedu-shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
    --bedu-shadow: 0 8px 24px -8px rgba(15, 23, 42, 0.10), 0 2px 6px rgba(15, 23, 42, 0.04);
    --bedu-shadow-lg: 0 18px 50px -16px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.06);
}

/* ─── Reset / base ──────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--bedu-bg);
    color: var(--bedu-text);
    font-family: var(--bedu-font-body);
    font-size: var(--bedu-text-base);
    line-height: var(--bedu-line);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--bedu-font-heading);
    color: var(--bedu-text);
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 var(--bedu-space-3);
}

h1 { font-size: clamp(1.75rem, 1.2vw + 1.4rem, 2.4rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.4rem, 0.8vw + 1.2rem, 1.8rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin: 0 0 var(--bedu-space-3); }

a {
    color: var(--bedu-primary-600);
    text-decoration: none;
    transition: color var(--bedu-dur) var(--bedu-ease);
}
a:hover { color: var(--bedu-primary-700); }

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

hr {
    border: 0;
    border-top: 1px solid var(--bedu-border);
    margin: var(--bedu-space-5) 0;
}

/* Accessibility helpers */
.bedu-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bedu-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 9999;
    background: var(--bedu-text);
    color: #fff;
    padding: var(--bedu-space-3) var(--bedu-space-4);
    border-radius: 0 0 var(--bedu-radius-sm) 0;
}
.bedu-skip-link:focus { left: 0; color: #fff; }

:focus-visible {
    outline: 3px solid var(--bedu-primary);
    outline-offset: 2px;
    border-radius: var(--bedu-radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ─── Print ──────────────────────────────────────────────── */
@media print {
    .bedu-navbar,
    .bedu-footer,
    .bedu-chat__composer,
    .bedu-toast-host,
    .bedu-skip-link,
    .bedu-msg__actions { display: none !important; }

    body { background: #fff; color: #000; }

    .bedu-card,
    .bedu-tile,
    .bedu-resource,
    .bedu-chat,
    .bedu-msg__bubble {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #000 !important;
        page-break-inside: avoid;
    }

    .bedu-hero,
    .bedu-page-header {
        background: #f5f5f5 !important;
        border: 1px solid #ccc !important;
    }

    .bedu-msg__bubble { color: #000 !important; }
    .bedu-msg--own .bedu-msg__bubble {
        background: #f0f0f0 !important;
        border-color: #ccc !important;
    }

    a { color: #000; text-decoration: underline; }

    .bedu-chat__messages {
        overflow: visible !important;
        height: auto !important;
    }
}

/* ─── Layout primitives ─────────────────────────────────── */
.bedu-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.bedu-main {
    flex: 1 0 auto;
    padding: var(--bedu-space-6) 0;
}
@media (max-width: 575.98px) {
    .bedu-main { padding: var(--bedu-space-4) 0; }
}

.bedu-container {
    width: 100%;
    max-width: var(--bedu-container);
    margin: 0 auto;
    padding: 0 var(--bedu-space-4);
}

.bedu-container--narrow { max-width: 720px; }
.bedu-container--wide { max-width: 1400px; }

/* Stack helper */
.bedu-stack > * + * { margin-top: var(--bedu-space-4); }
.bedu-stack--sm > * + * { margin-top: var(--bedu-space-2); }
.bedu-stack--lg > * + * { margin-top: var(--bedu-space-6); }

/* ─── Card ──────────────────────────────────────────────── */
.bedu-card {
    background: var(--bedu-surface);
    border-radius: var(--bedu-radius);
    box-shadow: var(--bedu-shadow-sm);
    border: 1px solid var(--bedu-border);
    padding: var(--bedu-space-5);
    transition: transform var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease);
}

.bedu-card--hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--bedu-shadow);
}

.bedu-card--flat {
    box-shadow: none;
}

.bedu-card__title {
    margin: 0 0 var(--bedu-space-2);
    font-size: 1.1rem;
}

/* ─── Buttons ───────────────────────────────────────────── */
.bedu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--bedu-space-2);
    padding: 10px 20px;
    font-family: var(--bedu-font-body);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--bedu-radius-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--bedu-dur) var(--bedu-ease),
                color var(--bedu-dur) var(--bedu-ease),
                border-color var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur-fast) var(--bedu-ease);
    user-select: none;
}

.bedu-btn:active:not(:disabled) { transform: translateY(1px); }
.bedu-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bedu-btn--primary {
    background: var(--bedu-primary);
    color: #fff;
}
.bedu-btn--primary:hover:not(:disabled) {
    background: var(--bedu-primary-600);
    color: #fff;
}

.bedu-btn--secondary {
    background: var(--bedu-surface);
    color: var(--bedu-text);
    border-color: var(--bedu-border);
}
.bedu-btn--secondary:hover:not(:disabled) {
    background: var(--bedu-surface-muted);
}

.bedu-btn--ghost {
    background: transparent;
    color: var(--bedu-text);
}
.bedu-btn--ghost:hover:not(:disabled) {
    background: var(--bedu-surface-muted);
}

.bedu-btn--danger {
    background: var(--bedu-danger);
    color: #fff;
}
.bedu-btn--danger:hover:not(:disabled) {
    background: #DC2626;
    color: #fff;
}

.bedu-btn--lg { padding: 14px 28px; font-size: 1rem; }
.bedu-btn--sm { padding: 6px 14px; font-size: 0.85rem; }

.bedu-btn--block { display: flex; width: 100%; }

.bedu-btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
}

/* ─── Forms ─────────────────────────────────────────────── */
.bedu-field { margin-bottom: var(--bedu-space-4); }

.bedu-label {
    display: block;
    margin-bottom: var(--bedu-space-2);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--bedu-text);
}

.bedu-input,
.bedu-select,
.bedu-textarea {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-family: var(--bedu-font-body);
    font-size: 1rem;
    color: var(--bedu-text);
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius-sm);
    transition: border-color var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease);
    appearance: none;
}

.bedu-input:focus,
.bedu-select:focus,
.bedu-textarea:focus {
    border-color: var(--bedu-primary);
    box-shadow: 0 0 0 4px var(--bedu-primary-50);
    outline: none;
}

.bedu-input::placeholder { color: var(--bedu-text-soft); }

.bedu-input--error { border-color: var(--bedu-danger); }
.bedu-input--error:focus { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12); }

.bedu-help {
    margin-top: var(--bedu-space-2);
    font-size: 0.85rem;
    color: var(--bedu-text-muted);
}
.bedu-help--error { color: var(--bedu-danger); }

/* ─── Input group (with trailing action) ────────────────── */
.bedu-input-wrap {
    position: relative;
}
.bedu-input-wrap .bedu-input { padding-right: 48px; }
.bedu-input-action {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--bedu-radius-sm);
    color: var(--bedu-text-muted);
    cursor: pointer;
    transition: background var(--bedu-dur) var(--bedu-ease),
                color var(--bedu-dur) var(--bedu-ease);
}
.bedu-input-action:hover {
    background: var(--bedu-surface-muted);
    color: var(--bedu-text);
}

/* ─── Password strength meter ───────────────────────────── */
.bedu-strength {
    margin-top: var(--bedu-space-2);
    --bedu-strength-color: var(--bedu-border);
}
.bedu-strength--weak       { --bedu-strength-color: var(--bedu-danger); }
.bedu-strength--fair       { --bedu-strength-color: var(--bedu-accent); }
.bedu-strength--good       { --bedu-strength-color: #3B82F6; }
.bedu-strength--strong     { --bedu-strength-color: var(--bedu-success); }

.bedu-strength__track {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}
.bedu-strength__bar {
    flex: 1;
    height: 4px;
    background: var(--bedu-border);
    border-radius: var(--bedu-radius-pill);
    transition: background var(--bedu-dur) var(--bedu-ease);
}
.bedu-strength--weak   .bedu-strength__bar:nth-child(-n+1),
.bedu-strength--fair   .bedu-strength__bar:nth-child(-n+2),
.bedu-strength--good   .bedu-strength__bar:nth-child(-n+3),
.bedu-strength--strong .bedu-strength__bar { background: var(--bedu-strength-color); }
.bedu-strength__label {
    font-size: 0.78rem;
    color: var(--bedu-strength-color);
    font-weight: 600;
}

/* ─── Button loading state ──────────────────────────────── */
.bedu-btn[data-loading="true"] {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.bedu-btn[data-loading="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: bedu-spin 0.7s linear infinite;
}
.bedu-btn--secondary[data-loading="true"]::after,
.bedu-btn--ghost[data-loading="true"]::after {
    border-color: rgba(0, 0, 0, 0.18);
    border-top-color: var(--bedu-text);
}
@keyframes bedu-spin {
    to { transform: rotate(360deg); }
}

/* ─── Avatar ────────────────────────────────────────────── */
.bedu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bedu-primary) 0%, var(--bedu-primary-600) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    overflow: hidden;
    flex-shrink: 0;
    user-select: none;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08);
}

.bedu-avatar img { width: 100%; height: 100%; object-fit: cover; }

.bedu-avatar--sm { width: 32px; height: 32px; font-size: 0.78rem; }
.bedu-avatar--lg { width: 56px; height: 56px; font-size: 1.15rem; }

/* Avatar palette variants (use with explicit class or by hash in template) */
.bedu-avatar--accent  { background: linear-gradient(135deg, var(--bedu-accent), var(--bedu-accent-600)); }
.bedu-avatar--success { background: linear-gradient(135deg, var(--bedu-success), var(--bedu-success-600)); }
.bedu-avatar--warm    { background: linear-gradient(135deg, var(--bedu-warm), var(--bedu-warm-600)); }

/* ─── Badge ─────────────────────────────────────────────── */
.bedu-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-1);
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--bedu-radius-pill);
    background: var(--bedu-surface-muted);
    color: var(--bedu-text);
}

.bedu-badge--primary { background: var(--bedu-primary-50); color: var(--bedu-primary-700); }
.bedu-badge--success { background: var(--bedu-success-50); color: var(--bedu-success-600); }
.bedu-badge--accent  { background: var(--bedu-accent-50);  color: var(--bedu-accent-600); }
.bedu-badge--warm    { background: var(--bedu-warm-50);    color: var(--bedu-warm-600); }
.bedu-badge--dot {
    padding: 0;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--bedu-success);
}

/* ─── Empty state ───────────────────────────────────────── */
.bedu-empty {
    text-align: center;
    padding: var(--bedu-space-7) var(--bedu-space-4);
    color: var(--bedu-text-muted);
}
.bedu-empty__icon {
    font-size: 3rem;
    margin-bottom: var(--bedu-space-3);
    opacity: 0.5;
}
.bedu-empty__title {
    font-family: var(--bedu-font-heading);
    color: var(--bedu-text);
    font-size: 1.15rem;
    margin-bottom: var(--bedu-space-2);
}

/* ─── Toast ─────────────────────────────────────────────── */
.bedu-toast-host {
    position: fixed;
    top: var(--bedu-space-4);
    right: var(--bedu-space-4);
    z-index: var(--bedu-z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--bedu-space-2);
    pointer-events: none;
    max-width: min(360px, calc(100vw - var(--bedu-space-8)));
}
.bedu-toast {
    pointer-events: auto;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-left: 4px solid var(--bedu-primary);
    border-radius: var(--bedu-radius-sm);
    box-shadow: var(--bedu-shadow-lg);
    padding: var(--bedu-space-3) var(--bedu-space-4);
    font-size: 0.95rem;
    animation: bedu-toast-in 200ms var(--bedu-ease);
}
.bedu-toast--success { border-left-color: var(--bedu-success); }
.bedu-toast--warning { border-left-color: var(--bedu-accent); }
.bedu-toast--error   { border-left-color: var(--bedu-danger); }
@keyframes bedu-toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Navbar ────────────────────────────────────────────── */
.bedu-navbar {
    position: sticky;
    top: 0;
    z-index: var(--bedu-z-sticky);
    background: var(--bedu-navbar-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--bedu-border);
    height: var(--bedu-navbar-h);
}
/* Navbar gets its own slightly-wider container so the row breathes
   without forcing wider page content. */
.bedu-navbar > .bedu-container {
    max-width: min(100%, 1440px);
    padding: 0 var(--bedu-space-5);
    height: 100%;
}

.bedu-navbar__inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--bedu-space-4);
    flex-wrap: nowrap;
    min-width: 0;
}

.bedu-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-2);
    color: var(--bedu-text);
    font-family: var(--bedu-font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
    flex-shrink: 0;
}
.bedu-brand:hover { color: var(--bedu-primary); }
.bedu-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--bedu-primary) 0%, var(--bedu-accent) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 4px 12px -2px rgba(79, 142, 247, 0.4);
}

.bedu-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
    flex-wrap: nowrap;
}

/* Make .bedu-nav__link work as both <a> and <button> */
.bedu-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    color: var(--bedu-text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: var(--bedu-radius-sm);
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;     /* labels must never wrap inside navbar */
    flex-shrink: 0;
    transition: background var(--bedu-dur) var(--bedu-ease),
                color var(--bedu-dur) var(--bedu-ease);
}
.bedu-nav__link > i.bi { font-size: 1em; flex-shrink: 0; }
.bedu-nav__link > span { white-space: nowrap; }
.bedu-nav__link:hover {
    background: var(--bedu-surface-muted);
    color: var(--bedu-text);
}
.bedu-nav__link:focus-visible {
    outline: 2px solid var(--bedu-primary);
    outline-offset: 2px;
}
.bedu-nav__link--active {
    color: var(--bedu-primary);
    background: var(--bedu-primary-50);
}
.bedu-nav__link i.bi-chevron-down {
    font-size: 0.65em;
    margin-left: 2px;
    opacity: 0.7;
    transition: transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-nav__link[aria-expanded="true"] i.bi-chevron-down {
    transform: rotate(180deg);
}

.bedu-navbar__spacer { flex: 1 1 auto; min-width: 0; }

.bedu-navbar__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* User menu pill — avatar + username + chevron, sits at the end of the row. */
.bedu-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-2);
    height: 38px;
    padding: 0 10px 0 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--bedu-radius-pill);
    color: var(--bedu-text);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--bedu-dur-fast) var(--bedu-ease),
                border-color var(--bedu-dur-fast) var(--bedu-ease);
}
.bedu-user-trigger:hover {
    background: var(--bedu-surface-muted);
    border-color: var(--bedu-border);
}
.bedu-user-trigger:focus-visible {
    outline: 2px solid var(--bedu-primary);
    outline-offset: 2px;
}
.bedu-user-trigger[aria-expanded="true"] {
    background: var(--bedu-primary-50);
    border-color: var(--bedu-primary);
}
.bedu-user-trigger .bedu-avatar { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.bedu-user-trigger__label {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-user-trigger i.bi-chevron-down {
    font-size: 0.7em;
    opacity: 0.6;
    transition: transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-user-trigger[aria-expanded="true"] i.bi-chevron-down {
    transform: rotate(180deg);
}

/* Icon-only navbar action button — slightly tighter so the row fits */
.bedu-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--bedu-radius-sm);
    background: transparent;
    border: 0;
    color: var(--bedu-text-muted);
    cursor: pointer;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    transition: background var(--bedu-dur) var(--bedu-ease),
                color var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur-fast) var(--bedu-ease);
}
.bedu-icon-btn:hover {
    background: var(--bedu-surface-muted);
    color: var(--bedu-text);
}
.bedu-icon-btn:active { transform: scale(0.96); }
.bedu-icon-btn:focus-visible {
    outline: 2px solid var(--bedu-primary);
    outline-offset: 2px;
}

/* ─── Responsive tightening (Phase 12 polish) ───────────────────
   At narrower widths the labels are the first thing to drop —
   keep icons, then collapse the search pill, then the whole nav. */
@media (max-width: 1280px) {
    .bedu-navbar__inner { gap: var(--bedu-space-3); }
    .bedu-nav { gap: 0; }
    .bedu-nav__link { padding: 8px 9px; font-size: 0.88rem; }
}
@media (max-width: 1100px) {
    /* Hide text labels on the static nav links so the row keeps fitting,
       but keep the dropdown labels (those have their own chevrons). */
    .bedu-nav > a.bedu-nav__link > span:not(.bedu-only-icon-hide) {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .bedu-nav > a.bedu-nav__link {
        padding: 8px;
        width: 38px; height: 38px;
        justify-content: center;
    }
    .bedu-nav > a.bedu-nav__link > i.bi { font-size: 1.15rem; }
}
/* At tablet widths the dropdown triggers also lose their text so the
   row keeps fitting alongside the search pill and action icons. */
@media (max-width: 960px) {
    .bedu-nav .dropdown > .bedu-nav__link > span {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .bedu-nav .dropdown > .bedu-nav__link {
        padding: 8px;
        width: 38px; height: 38px;
        justify-content: center;
    }
    .bedu-nav .dropdown > .bedu-nav__link > i.bi-chevron-down { display: none; }
}

/* Dropdown menu — themed */
.bedu-navbar .dropdown-menu {
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    box-shadow: var(--bedu-shadow);
    padding: 6px;
    min-width: 220px;
    margin-top: 4px; /* close enough that hover doesn't drop between trigger and menu */
}
/* Invisible bridge so the cursor can travel from trigger to menu
   without firing a mouseleave between them. */
.bedu-navbar .dropdown-menu::before {
    content: "";
    position: absolute;
    inset: -8px 0 auto 0;
    height: 8px;
    background: transparent;
}

/* Megamenu: wider dropdown with side-by-side grade columns.
   CRITICAL: do NOT set `display: grid` on the base selector — that
   overrides Bootstrap's `display: none` and the menu stays open
   on page load. Apply grid layout only when Bootstrap marks the
   menu as `.show`. */
.bedu-navbar .dropdown-menu--mega {
    min-width: 280px;
    max-width: min(96vw, 760px);
    padding: var(--bedu-space-3);
    max-height: 70vh;
    overflow-y: auto;
}
.bedu-navbar .dropdown-menu--mega.show {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--bedu-space-2) var(--bedu-space-3);
}
@media (min-width: 480px) {
    .bedu-navbar .dropdown-menu--mega.show {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}
@media (min-width: 720px) {
    .bedu-navbar .dropdown-menu--mega.show {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
}

.bedu-megamenu-group {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.bedu-megamenu-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bedu-space-2);
    padding: 6px 10px 6px;
    margin-bottom: 2px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bedu-text-soft);
    border-bottom: 1px solid var(--bedu-border);
}
.bedu-megamenu-group__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: var(--bedu-radius-pill);
    background: var(--bedu-primary-50);
    color: var(--bedu-primary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}
/* Subject items inside a column — keep slim */
.bedu-megamenu-group .dropdown-item {
    padding: 7px 10px;
    font-size: 0.9rem;
    white-space: normal;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 8px;
}
.bedu-megamenu-group .dropdown-item i {
    flex-shrink: 0;
    color: var(--bedu-primary);
}
.bedu-navbar .dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-2);
    border-radius: var(--bedu-radius-sm);
    padding: 8px 12px;
    font-size: 0.92rem;
    color: var(--bedu-text);
    transition: background var(--bedu-dur-fast) var(--bedu-ease),
                color var(--bedu-dur-fast) var(--bedu-ease);
}
.bedu-navbar .dropdown-item > i.bi {
    width: 18px;
    text-align: center;
    color: var(--bedu-text-muted);
    flex-shrink: 0;
}
.bedu-navbar .dropdown-item:hover,
.bedu-navbar .dropdown-item:focus {
    background: var(--bedu-primary-50);
    color: var(--bedu-primary);
}
.bedu-navbar .dropdown-item:hover > i.bi,
.bedu-navbar .dropdown-item:focus > i.bi { color: var(--bedu-primary); }
.bedu-navbar .dropdown-divider {
    border-color: var(--bedu-border);
}

.bedu-mobile-toggle {
    display: none;
}

/* ─── Mobile drawer (≤ 860px) ───────────────────────────────────
   The drawer slides down from under the navbar and contains:
       • full-text nav links (no icon-only collapse)
       • a horizontal row of action icons (search, theme, bell, user)
       • a backdrop that closes the drawer on tap outside
   The drawer is scrollable so even very tall menus fit on small phones. */
@media (max-width: 860px) {
    /* Hide desktop-only chrome */
    .bedu-nav { display: none; }
    .bedu-navbar__spacer { display: none; }
    /* Search trigger stays in the navbar (still tappable as an icon) */

    .bedu-mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: var(--bedu-radius-sm);
        background: transparent;
        border: 0;
        color: var(--bedu-text);
        font-size: 1.35rem;
        cursor: pointer;
        transition: background var(--bedu-dur-fast) var(--bedu-ease);
    }
    .bedu-mobile-toggle:hover { background: var(--bedu-surface-muted); }
    .bedu-navbar.is-open .bedu-mobile-toggle {
        background: var(--bedu-primary-50);
        color: var(--bedu-primary);
    }

    /* Backdrop dims the page behind the drawer. Created on demand by
       the existing _navbar.html toggle script (works even without JS
       change because the .is-open class on the navbar is enough). */
    .bedu-navbar.is-open::before {
        content: "";
        position: fixed;
        inset: var(--bedu-navbar-h) 0 0 0;
        background: rgba(15, 23, 42, 0.32);
        backdrop-filter: blur(2px);
        z-index: -1;
        animation: bedu-fade-in var(--bedu-dur) var(--bedu-ease);
    }

    .bedu-navbar.is-open .bedu-nav {
        display: flex;
        position: absolute;
        top: var(--bedu-navbar-h);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        background: var(--bedu-surface);
        padding: var(--bedu-space-3);
        border-bottom: 1px solid var(--bedu-border);
        box-shadow: var(--bedu-shadow-lg);
        max-height: calc(100dvh - var(--bedu-navbar-h));
        overflow-y: auto;
        animation: bedu-slide-down var(--bedu-dur) var(--bedu-ease);
    }
    .bedu-navbar.is-open .bedu-nav__link {
        width: 100%;
        justify-content: flex-start;
        padding: 12px var(--bedu-space-3);
        font-size: 1rem;
        height: auto;
    }
    .bedu-navbar.is-open .bedu-nav__link > i.bi {
        font-size: 1.15rem;
        width: 22px;
        text-align: center;
    }
    /* Bootstrap dropdowns inside the mobile drawer — go full-width,
       drop the floating positioning so they live in the flow. */
    .bedu-navbar.is-open .bedu-nav .dropdown { width: 100%; }
    .bedu-navbar.is-open .bedu-nav .dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100%;
        margin: 4px 0 8px 8px;
        box-shadow: none;
        border: 0;
        background: var(--bedu-surface-muted);
        padding: 4px;
    }
    .bedu-navbar.is-open .bedu-nav .dropdown-menu::before { display: none; }
    .bedu-navbar.is-open .bedu-nav .dropdown-menu--mega.show {
        grid-template-columns: 1fr !important;
    }

    /* Shrink the in-navbar action cluster so it stays single-line. */
    .bedu-navbar__actions { gap: 2px; }
    .bedu-icon-btn { width: 40px; height: 40px; }
    .bedu-user-trigger { padding: 0 4px; height: 40px; }
    .bedu-user-trigger__label { display: none !important; }
    .bedu-user-trigger i.bi-chevron-down { display: none; }
}

/* Even tighter on small phones */
@media (max-width: 480px) {
    :root { --bedu-navbar-h: 64px; }
    .bedu-navbar > .bedu-container { padding: 0 var(--bedu-space-3); }
    .bedu-navbar__inner { gap: var(--bedu-space-2); }
    .bedu-brand__mark { width: 32px; height: 32px; border-radius: 8px; }
    .bedu-brand { font-size: 1rem; }
    .bedu-icon-btn { width: 38px; height: 38px; font-size: 1rem; }
    /* Hide the search trigger entirely on small phones; users can still
       access search after opening the drawer via the dropdown shortcut */
    .bedu-search-trigger { display: none; }
}

@keyframes bedu-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes bedu-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ─── Footer ────────────────────────────────────────────── */
.bedu-footer {
    flex-shrink: 0;
    padding: var(--bedu-space-6) 0;
    text-align: center;
    color: var(--bedu-text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--bedu-border);
    background: var(--bedu-surface);
}

/* ─── Hero (dashboard greeting) ─────────────────────────── */
.bedu-hero {
    position: relative;
    background:
        radial-gradient(circle at 88% -20%, color-mix(in srgb, var(--bedu-primary) 25%, transparent) 0%, transparent 50%),
        radial-gradient(circle at -5% 120%, color-mix(in srgb, var(--bedu-accent) 22%, transparent) 0%, transparent 50%),
        linear-gradient(135deg, var(--bedu-primary-50) 0%, var(--bedu-accent-50) 100%);
    border-radius: var(--bedu-radius-lg);
    padding: clamp(var(--bedu-space-5), 4vw, var(--bedu-space-7)) clamp(var(--bedu-space-5), 4vw, var(--bedu-space-7));
    overflow: hidden;
    border: 1px solid var(--bedu-border);
    isolation: isolate;
}
/* Subtle dot pattern overlay */
.bedu-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--bedu-text-soft) 0.8px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.08;
    pointer-events: none;
    z-index: -1;
}
.bedu-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-2);
    padding: 5px 12px;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bedu-text-muted);
    margin-bottom: var(--bedu-space-3);
    backdrop-filter: blur(8px);
}
.bedu-hero__title {
    font-size: clamp(1.6rem, 1vw + 1.3rem, 2.2rem);
    margin: 0 0 var(--bedu-space-2);
    color: var(--bedu-text);
}
.bedu-hero__lead {
    color: var(--bedu-text-muted);
    max-width: 60ch;
    margin: 0;
    font-size: 1.05rem;
}

/* ─── Stat card (KPI tile) ──────────────────────────────── */
.bedu-stat {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-4);
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    overflow: hidden;
    transition: transform var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease),
                border-color var(--bedu-dur) var(--bedu-ease);
}
.bedu-stat::after {
    content: "";
    position: absolute;
    inset: auto auto 0 0;
    width: 100%;
    height: 3px;
    background: currentColor;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: opacity var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--bedu-shadow);
}
.bedu-stat:hover::after { opacity: 0.7; transform: scaleX(1); }

.bedu-stat__icon {
    width: 48px; height: 48px;
    border-radius: var(--bedu-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    transition: transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-stat:hover .bedu-stat__icon { transform: scale(1.08) rotate(-3deg); }
.bedu-stat__icon--primary { background: var(--bedu-primary-50); color: var(--bedu-primary); }
.bedu-stat__icon--accent  { background: var(--bedu-accent-50);  color: var(--bedu-accent-600); }
.bedu-stat__icon--success { background: var(--bedu-success-50); color: var(--bedu-success-600); }
.bedu-stat__icon--warm    { background: var(--bedu-warm-50);    color: var(--bedu-warm-600); }

.bedu-stat--primary { color: var(--bedu-primary); }
.bedu-stat--accent  { color: var(--bedu-accent-600); }
.bedu-stat--success { color: var(--bedu-success-600); }
.bedu-stat--warm    { color: var(--bedu-warm-600); }
.bedu-stat__value {
    font-family: var(--bedu-font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--bedu-text);
}
.bedu-stat__label {
    color: var(--bedu-text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ─── Section header ────────────────────────────────────── */
.bedu-section {
    margin: 0;
}
.bedu-section__header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: var(--bedu-space-3);
    margin-bottom: var(--bedu-space-4);
}
.bedu-section__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-2);
}
/* Decorative accent dot before title */
.bedu-section__title::before {
    content: "";
    width: 6px; height: 22px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--bedu-primary), var(--bedu-accent));
    display: inline-block;
}
.bedu-section__link {
    font-size: 0.9rem;
    color: var(--bedu-primary);
    font-weight: 600;
}
.bedu-section__link:hover { color: var(--bedu-primary-600); }

/* ─── Subject tile (with palette tones) ─────────────────── */
.bedu-tile {
    display: block;
    position: relative;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    padding: var(--bedu-space-4);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    isolation: isolate;
    transition: transform var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease),
                border-color var(--bedu-dur) var(--bedu-ease);
    height: 100%;
}
/* Soft accent glow on hover */
.bedu-tile::before {
    content: "";
    position: absolute;
    inset: -50% -30% auto auto;
    width: 200px; height: 200px;
    background: radial-gradient(circle, currentColor 0%, transparent 65%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur) var(--bedu-ease);
    pointer-events: none;
    z-index: -1;
}
.bedu-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--bedu-shadow);
    color: inherit;
}
.bedu-tile:hover::before {
    opacity: 0.08;
    transform: scale(1);
}
.bedu-tile--primary { color: var(--bedu-primary); }
.bedu-tile--accent  { color: var(--bedu-accent-600); }
.bedu-tile--success { color: var(--bedu-success-600); }
.bedu-tile--warm    { color: var(--bedu-warm-600); }

.bedu-tile__icon {
    width: 56px; height: 56px;
    border-radius: var(--bedu-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: var(--bedu-space-3);
    transition: transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-tile:hover .bedu-tile__icon { transform: scale(1.08) rotate(-4deg); }
.bedu-tile__icon--primary { background: var(--bedu-primary-50); color: var(--bedu-primary); }
.bedu-tile__icon--accent  { background: var(--bedu-accent-50);  color: var(--bedu-accent-600); }
.bedu-tile__icon--success { background: var(--bedu-success-50); color: var(--bedu-success-600); }
.bedu-tile__icon--warm    { background: var(--bedu-warm-50);    color: var(--bedu-warm-600); }
.bedu-tile__eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--bedu-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--bedu-space-1);
}
.bedu-tile__title {
    font-family: var(--bedu-font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 var(--bedu-space-3);
    color: var(--bedu-text);
}
.bedu-tile__meta {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-2);
    font-size: 0.85rem;
    color: var(--bedu-text-muted);
}
.bedu-tile__meta-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--bedu-text-soft);
}

/* ─── Activity feed (recent messages) ───────────────────── */
.bedu-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}
.bedu-feed > li + li {
    border-top: 1px solid var(--bedu-border);
}
.bedu-feed__item {
    display: flex;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-3);
    border-radius: var(--bedu-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: background var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur) var(--bedu-ease);
}
.bedu-feed__item:hover {
    background: var(--bedu-surface-muted);
    color: inherit;
    transform: translateX(2px);
}
.bedu-feed__body { flex: 1; min-width: 0; }
.bedu-feed__top {
    display: flex;
    align-items: baseline;
    gap: var(--bedu-space-2);
    margin-bottom: 2px;
}
.bedu-feed__where {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--bedu-primary-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bedu-feed__time {
    font-size: 0.78rem;
    color: var(--bedu-text-soft);
    margin-left: auto;
}
.bedu-feed__text {
    color: var(--bedu-text);
    font-size: 0.95rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.bedu-feed__sender {
    font-weight: 600;
    color: var(--bedu-text);
    margin-right: 4px;
}

/* ─── Book card (file thumbnail) ────────────────────────── */
.bedu-book {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-3);
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    text-decoration: none;
    color: inherit;
    transition: transform var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease);
    height: 100%;
}
.bedu-book:hover { transform: translateY(-2px); box-shadow: var(--bedu-shadow-sm); color: inherit; }
.bedu-book__cover {
    width: 48px; height: 56px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--bedu-warm-50), var(--bedu-accent-50));
    border-radius: var(--bedu-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bedu-warm-600);
    font-size: 1.4rem;
    box-shadow: inset 3px 0 0 var(--bedu-warm);
}
.bedu-book__body { flex: 1; min-width: 0; }
.bedu-book__title {
    font-weight: 600;
    color: var(--bedu-text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-book__meta {
    font-size: 0.78rem;
    color: var(--bedu-text-muted);
    margin-top: 2px;
}

/* ─── Dashboard 2-column layout (desktop) ───────────────── */
@media (min-width: 992px) {
    .bedu-dash {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
        gap: var(--bedu-space-6);
        align-items: start;
    }
}

/* ─── Page header (subject/methodology hero) ───────────── */
.bedu-page-header {
    background: linear-gradient(135deg, var(--bedu-primary-50) 0%, var(--bedu-accent-50) 100%);
    border-radius: var(--bedu-radius-lg);
    padding: var(--bedu-space-5);
    border: 1px solid var(--bedu-border);
    margin-bottom: var(--bedu-space-5);
}
.bedu-page-header__crumbs {
    font-size: 0.85rem;
    color: var(--bedu-text-muted);
    margin-bottom: var(--bedu-space-3);
}
.bedu-page-header__crumbs a { color: var(--bedu-text-muted); }
.bedu-page-header__crumbs a:hover { color: var(--bedu-primary-700); }
.bedu-page-header__title {
    font-size: clamp(1.5rem, 1vw + 1.2rem, 2rem);
    margin: 0 0 var(--bedu-space-2);
}
.bedu-page-header__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--bedu-space-3);
    color: var(--bedu-text-muted);
    font-size: 0.95rem;
}
.bedu-page-header__meta-item {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-2);
}

/* ─── Books list (sidebar) ──────────────────────────────── */
.bedu-resource-list { list-style: none; padding: 0; margin: 0; }
.bedu-resource-list li + li { margin-top: var(--bedu-space-2); }
.bedu-resource {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-3);
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: background var(--bedu-dur) var(--bedu-ease),
                border-color var(--bedu-dur) var(--bedu-ease);
}
.bedu-resource:hover {
    color: inherit;
    background: var(--bedu-surface-muted);
    border-color: var(--bedu-primary-100);
}
.bedu-resource__icon {
    width: 36px; height: 36px;
    border-radius: var(--bedu-radius-sm);
    background: var(--bedu-warm-50);
    color: var(--bedu-warm-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.bedu-resource__body { flex: 1; min-width: 0; }
.bedu-resource__title {
    font-weight: 600;
    color: var(--bedu-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-resource__meta {
    font-size: 0.78rem;
    color: var(--bedu-text-muted);
    margin-top: 2px;
}

/* ─── Chat (messenger) ──────────────────────────────────── */
.bedu-chat {
    display: flex;
    flex-direction: column;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    overflow: hidden;
    height: 100%;
    /* Viewport-aware on mobile so the composer is always reachable.
       On desktop, parent grid sets sticky position and natural height. */
    min-height: clamp(520px, calc(100dvh - 200px), 80vh);
}
@media (max-width: 991.98px) {
    .bedu-chat {
        min-height: calc(100dvh - var(--bedu-navbar-h) - var(--bedu-space-7));
        border-radius: var(--bedu-radius);
    }
}

.bedu-chat__header {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-4);
    border-bottom: 1px solid var(--bedu-border);
    background: var(--bedu-surface);
}
.bedu-chat__avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bedu-primary) 0%, var(--bedu-accent) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.bedu-chat__title {
    flex: 1;
    min-width: 0;
}
.bedu-chat__name {
    font-family: var(--bedu-font-heading);
    font-weight: 700;
    color: var(--bedu-text);
    line-height: 1.2;
}
.bedu-chat__status {
    display: inline-flex;
    align-items: center;
    gap: var(--bedu-space-1);
    font-size: 0.8rem;
    color: var(--bedu-text-muted);
    margin-top: 2px;
}
.bedu-chat__status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--bedu-text-soft);
    transition: background var(--bedu-dur) var(--bedu-ease);
}
.bedu-chat__status[data-connection="online"] .bedu-chat__status-dot {
    background: var(--bedu-success);
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
}
.bedu-chat__status[data-connection="reconnecting"] .bedu-chat__status-dot {
    background: var(--bedu-accent);
}

.bedu-chat__messages {
    flex: 1;
    padding: var(--bedu-space-4);
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bedu-bg);
    display: flex;
    flex-direction: column;
    gap: var(--bedu-space-3);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--bedu-border) transparent;
}
.bedu-chat__messages::-webkit-scrollbar { width: 8px; }
.bedu-chat__messages::-webkit-scrollbar-thumb { background: var(--bedu-border); border-radius: 4px; }

/* Date separator (optional) */
.bedu-chat__day {
    align-self: center;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius-pill);
    padding: 4px 12px;
    font-size: 0.78rem;
    color: var(--bedu-text-muted);
    margin: var(--bedu-space-2) 0;
}

/* Message bubble */
.bedu-msg {
    display: flex;
    align-items: flex-end;
    gap: var(--bedu-space-2);
    max-width: 100%;
    animation: bedu-msg-in 160ms var(--bedu-ease);
}
@keyframes bedu-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.bedu-msg--own { align-self: flex-end; flex-direction: row-reverse; }
.bedu-msg--scroll-highlight .bedu-msg__bubble {
    animation: bedu-msg-pulse 1.6s var(--bedu-ease);
}
@keyframes bedu-msg-pulse {
    0%   { box-shadow: 0 0 0 0 var(--bedu-accent); }
    50%  { box-shadow: 0 0 0 6px rgba(255, 180, 84, 0.22); }
    100% { box-shadow: 0 0 0 0 rgba(255, 180, 84, 0); }
}

.bedu-msg__avatar {
    width: 32px; height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bedu-primary-100);
    color: var(--bedu-primary-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}
.bedu-msg--own .bedu-msg__avatar { display: none; }

.bedu-msg__body {
    display: flex;
    flex-direction: column;
    max-width: min(75%, 520px);
    min-width: 0;
}
.bedu-msg--own .bedu-msg__body { align-items: flex-end; }

.bedu-msg__meta {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-2);
    font-size: 0.78rem;
    color: var(--bedu-text-muted);
    margin-bottom: 2px;
    padding: 0 var(--bedu-space-2);
}
.bedu-msg--own .bedu-msg__meta { flex-direction: row-reverse; }
.bedu-msg__sender {
    font-weight: 600;
    color: var(--bedu-text);
}
.bedu-msg__sender--mod {
    color: var(--bedu-accent-600);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.bedu-msg__sender--mod::before {
    content: "👑";
    font-size: 0.85em;
}

.bedu-msg__bubble {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    background: var(--bedu-surface);
    color: var(--bedu-text);
    border: 1px solid var(--bedu-border);
    position: relative;
    transition: box-shadow var(--bedu-dur) var(--bedu-ease);
}
.bedu-msg--own .bedu-msg__bubble {
    background: var(--bedu-primary);
    color: #fff;
    border-color: transparent;
    border-bottom-right-radius: 4px;
}
.bedu-msg:not(.bedu-msg--own) .bedu-msg__bubble {
    border-bottom-left-radius: 4px;
}

/* Reply preview inside bubble */
.bedu-msg__reply {
    display: block;
    margin: -4px -8px 8px;
    padding: 8px 10px;
    border-left: 3px solid var(--bedu-accent);
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    font-size: 0.85rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.bedu-msg--own .bedu-msg__reply {
    background: rgba(255, 255, 255, 0.18);
    border-left-color: rgba(255, 255, 255, 0.6);
}
.bedu-msg__reply-sender {
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}
.bedu-msg__reply-text {
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Image */
.bedu-msg__media {
    margin-top: 6px;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    max-width: 280px;
}
.bedu-msg__media img { display: block; width: 100%; height: auto; }

/* Hover actions */
.bedu-msg__actions {
    align-self: center;
    opacity: 0;
    transition: opacity var(--bedu-dur) var(--bedu-ease);
}
.bedu-msg:hover .bedu-msg__actions,
.bedu-msg:focus-within .bedu-msg__actions { opacity: 1; }
.bedu-msg__action-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    color: var(--bedu-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0;
}
.bedu-msg__action-btn:hover { background: var(--bedu-surface-muted); color: var(--bedu-text); }

/* Composer */
.bedu-chat__composer {
    background: var(--bedu-surface);
    border-top: 1px solid var(--bedu-border);
    padding: var(--bedu-space-3) var(--bedu-space-4);
}
.bedu-chat__reply-preview {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-2);
    padding: var(--bedu-space-2) var(--bedu-space-3);
    background: var(--bedu-primary-50);
    border-left: 3px solid var(--bedu-primary);
    border-radius: var(--bedu-radius-sm);
    margin-bottom: var(--bedu-space-2);
    font-size: 0.85rem;
}
.bedu-chat__reply-preview.is-hidden { display: none; }
.bedu-chat__reply-preview-body { flex: 1; min-width: 0; }
.bedu-chat__reply-preview-sender { font-weight: 700; color: var(--bedu-primary-700); }
.bedu-chat__reply-preview-text {
    color: var(--bedu-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bedu-chat__form {
    display: flex;
    align-items: end;
    gap: var(--bedu-space-2);
}
.bedu-chat__image-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--bedu-surface-muted);
    border: 1px solid var(--bedu-border);
    color: var(--bedu-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: background var(--bedu-dur) var(--bedu-ease),
                color var(--bedu-dur) var(--bedu-ease);
}
.bedu-chat__image-btn:hover { background: var(--bedu-primary-50); color: var(--bedu-primary-700); }
.bedu-chat__image-btn.has-file {
    background: var(--bedu-primary-50);
    color: var(--bedu-primary-700);
    border-color: var(--bedu-primary);
}
.bedu-chat__text {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    padding: 11px 16px;
    font: inherit;
    font-size: 1rem;
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius-pill);
    resize: none;
    transition: border-color var(--bedu-dur) var(--bedu-ease),
                box-shadow var(--bedu-dur) var(--bedu-ease);
}
.bedu-chat__text:focus {
    outline: none;
    border-color: var(--bedu-primary);
    box-shadow: 0 0 0 4px var(--bedu-primary-50);
}
.bedu-chat__send {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--bedu-primary);
    color: #fff;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: background var(--bedu-dur) var(--bedu-ease),
                transform var(--bedu-dur-fast) var(--bedu-ease);
}
.bedu-chat__send:hover { background: var(--bedu-primary-600); }
.bedu-chat__send:active { transform: scale(0.95); }
.bedu-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Offline hint: subtle warning tint on composer */
.bedu-chat--offline .bedu-chat__composer {
    background: linear-gradient(180deg, var(--bedu-accent-50) 0%, var(--bedu-surface) 60%);
}
.bedu-chat--offline .bedu-chat__composer::before {
    content: "⚠ Aloqa uzildi. Qayta ulanmoqda…";
    display: block;
    font-size: 0.8rem;
    color: var(--bedu-accent-600);
    font-weight: 600;
    margin-bottom: var(--bedu-space-2);
    text-align: center;
}

.bedu-chat__banned {
    margin: var(--bedu-space-3) var(--bedu-space-4);
    padding: var(--bedu-space-3);
    background: var(--bedu-warm-50);
    border: 1px solid var(--bedu-warm);
    border-radius: var(--bedu-radius-sm);
    color: var(--bedu-warm-600);
    text-align: center;
    font-weight: 600;
}

/* Image preview thumbnail above input */
.bedu-chat__image-preview {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-2);
    padding: var(--bedu-space-2) var(--bedu-space-3);
    background: var(--bedu-primary-50);
    border-radius: var(--bedu-radius-sm);
    margin-bottom: var(--bedu-space-2);
    font-size: 0.85rem;
}
.bedu-chat__image-preview.is-hidden { display: none; }
.bedu-chat__image-preview img {
    width: 40px; height: 40px;
    border-radius: var(--bedu-radius-sm);
    object-fit: cover;
}

/* ─── Subject/methodology page layout ───────────────────── */
@media (min-width: 992px) {
    .bedu-subject {
        display: grid;
        grid-template-columns: 320px minmax(0, 1fr);
        gap: var(--bedu-space-5);
        align-items: start;
    }
    .bedu-subject__sidebar {
        position: sticky;
        top: calc(var(--bedu-navbar-h) + var(--bedu-space-4));
    }
}

/* ─── Admin chat dashboard (room list + detail) ─────────── */
.bedu-rooms {
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    overflow: hidden;
}
.bedu-room {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-3) var(--bedu-space-4);
    text-decoration: none;
    color: inherit;
    transition: background var(--bedu-dur) var(--bedu-ease);
}
.bedu-room + .bedu-room { border-top: 1px solid var(--bedu-border); }
.bedu-room:hover { background: var(--bedu-surface-muted); color: inherit; }
.bedu-room__avatar {
    width: 44px; height: 44px;
    flex-shrink: 0;
}
.bedu-room__body { flex: 1; min-width: 0; }
.bedu-room__head {
    display: flex;
    align-items: baseline;
    gap: var(--bedu-space-2);
}
.bedu-room__title {
    font-weight: 700;
    color: var(--bedu-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-room__time {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--bedu-text-muted);
    flex-shrink: 0;
}
.bedu-room__preview {
    color: var(--bedu-text-muted);
    font-size: 0.9rem;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-room__unread {
    flex-shrink: 0;
    min-width: 22px;
    height: 22px;
    border-radius: var(--bedu-radius-pill);
    background: var(--bedu-warm);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 7px;
}

/* ─── Manage dashboard ──────────────────────────────────── */
.bedu-manage-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--bedu-space-5);
}
@media (min-width: 992px) {
    .bedu-manage-grid { grid-template-columns: 1fr 1fr; }
    .bedu-manage-grid > .bedu-manage-section--wide { grid-column: 1 / -1; }
}

.bedu-manage-section {
    background: var(--bedu-surface);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
    overflow: hidden;
}
.bedu-manage-section__head {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: var(--bedu-space-4);
    border-bottom: 1px solid var(--bedu-border);
}
.bedu-manage-section__icon {
    width: 36px; height: 36px;
    border-radius: var(--bedu-radius-sm);
    background: var(--bedu-primary-50);
    color: var(--bedu-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.bedu-manage-section__icon--accent  { background: var(--bedu-accent-50);  color: var(--bedu-accent-600); }
.bedu-manage-section__icon--success { background: var(--bedu-success-50); color: var(--bedu-success-600); }
.bedu-manage-section__icon--warm    { background: var(--bedu-warm-50);    color: var(--bedu-warm-600); }
.bedu-manage-section__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    flex: 1;
}
.bedu-manage-section__count {
    color: var(--bedu-text-muted);
    font-size: 0.85rem;
}
.bedu-manage-section__body { padding: var(--bedu-space-2); }

.bedu-manage-row {
    display: flex;
    align-items: center;
    gap: var(--bedu-space-3);
    padding: 10px 12px;
    border-radius: var(--bedu-radius-sm);
}
.bedu-manage-row + .bedu-manage-row {
    border-top: 1px solid var(--bedu-border);
    border-radius: 0;
}
.bedu-manage-row:hover { background: var(--bedu-surface-muted); }
.bedu-manage-row__title {
    flex: 1;
    min-width: 0;
    color: var(--bedu-text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bedu-manage-row__meta {
    color: var(--bedu-text-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}
.bedu-manage-row__actions {
    display: flex;
    gap: 6px;
}

/* Themed Bootstrap modal */
.bedu-navbar ~ .modal .modal-dialog,
.modal .modal-dialog { /* fallback */ }
.modal .modal-content {
    background: var(--bedu-surface);
    color: var(--bedu-text);
    border: 1px solid var(--bedu-border);
    border-radius: var(--bedu-radius);
}
.modal .modal-header {
    border-bottom: 1px solid var(--bedu-border);
    padding: var(--bedu-space-4);
}
.modal .modal-title {
    font-family: var(--bedu-font-heading);
    font-weight: 700;
}
.modal .modal-body { padding: var(--bedu-space-4); }
.modal .modal-footer {
    border-top: 1px solid var(--bedu-border);
    padding: var(--bedu-space-3) var(--bedu-space-4);
}
.modal .btn-close {
    filter: var(--bedu-modal-close-filter, none);
}
[data-theme="dark"] .modal .btn-close { filter: invert(1); }

/* ─── Auth surface (login/register) ─────────────────────── */
.bedu-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--bedu-space-5) var(--bedu-space-4);
    background:
        radial-gradient(circle at 0% 0%, var(--bedu-primary-50) 0, transparent 40%),
        radial-gradient(circle at 100% 100%, var(--bedu-accent-50) 0, transparent 40%),
        var(--bedu-bg);
}
.bedu-auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--bedu-surface);
    border-radius: var(--bedu-radius-lg);
    box-shadow: var(--bedu-shadow-lg);
    padding: var(--bedu-space-6);
}
.bedu-auth__brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--bedu-space-4);
}
.bedu-auth__title {
    text-align: center;
    margin-bottom: var(--bedu-space-2);
}
.bedu-auth__lead {
    text-align: center;
    color: var(--bedu-text-muted);
    margin-bottom: var(--bedu-space-5);
}
.bedu-auth__alt {
    text-align: center;
    margin-top: var(--bedu-space-4);
    font-size: 0.9rem;
    color: var(--bedu-text-muted);
}
