/* Study9 - Modern Learning Platform Styles */

/* Offline indicator */
.offline-indicator { position: relative; width: 100%; background: #FFF3CD; color: #856404; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; font-size: 0.85rem; font-weight: 500; font-family: 'DM Sans', sans-serif; max-height: 0; opacity: 0; overflow: hidden; transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease; }
.offline-indicator.visible { max-height: 40px; opacity: 1; padding: 8px 16px; }
.offline-indicator svg { flex-shrink: 0; }

/* Video offline placeholder */
.offline-video svg { opacity: 0.5; margin-bottom: 12px; }
.offline-video p { color: var(--on-surface-variant); font-size: 0.95rem; }

/* Deploy Banner (staging only) */
.deploy-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; background: linear-gradient(135deg, #92400e, #b45309); color: #fef3c7; font-family: 'DM Sans', sans-serif; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
.deploy-banner-content { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; max-width: 1400px; margin: 0 auto; }
.deploy-banner-info { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; }
.deploy-banner-icon { width: 18px; height: 18px; flex-shrink: 0; }
.deploy-banner-actions { display: flex; align-items: center; gap: 12px; }
.deploy-commits-info { font-size: 0.78rem; opacity: 0.85; }
.deploy-btn { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: #fef3c7; padding: 5px 14px; border-radius: 6px; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: 'DM Sans', sans-serif; }
.deploy-btn:hover { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.5); }
.deploy-btn:disabled { opacity: 0.5; cursor: not-allowed; }
body { padding-top: 0; }
body.has-deploy-banner { padding-top: 84px; } /* increased for sync panel */

/* Hidden banner pull tab */
.deploy-banner-tab { position: fixed; top: 0; right: 16px; z-index: 9999; display: flex; align-items: center; justify-content: center; width: 28px; height: 22px; background: linear-gradient(135deg, #92400e, #b45309); color: #fef3c7; border-radius: 0 0 6px 6px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3); transition: var(--transition-fast); opacity: 0.8; }
.deploy-banner-tab:hover { opacity: 1; height: 26px; }

/* Course Sync Panel inside deploy banner */
.deploy-sync-panel { border-top: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); padding: 8px 16px; }
.deploy-sync-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; max-width: 1400px; margin: 0 auto 8px; }
.deploy-sync-title { font-size: 0.8rem; font-weight: 700; color: #fef3c7; }
.deploy-sync-list { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; max-width: 1400px; margin: 0 auto; padding-bottom: 8px; max-height: 150px; overflow-y: auto; }
.deploy-sync-item { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: rgba(255,255,255,0.1); border-radius: 4px; border: 1px solid rgba(255,255,255,0.15); cursor: pointer; transition: var(--transition-fast); font-size: 0.75rem; }
.deploy-sync-item:hover { background: rgba(255,255,255,0.2); }
.deploy-sync-item input[type="checkbox"] { accent-color: #4f7ef7; cursor: pointer; }
.deploy-sync-item .sync-label { display: flex; flex-direction: column; }
.deploy-sync-item .sync-title { font-weight: 500; }
.deploy-sync-item .sync-status { font-size: 0.7rem; opacity: 0.7; }
.deploy-sync-loading { font-size: 0.78rem; opacity: 0.8; margin: 0; }
.deploy-sync-list::-webkit-scrollbar { width: 6px; }
.deploy-sync-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.15); border-radius: 3px; }
.deploy-sync-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.deploy-sync-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
.deploy-btn.secondary { background: rgba(79, 126, 247, 0.3); border-color: rgba(79, 126, 247, 0.5); }
.deploy-btn.secondary:hover { background: rgba(79, 126, 247, 0.45); }

/* Commit History Modal */
.commit-history-list { display: flex; flex-direction: column; gap: var(--space-md); padding: var(--space-lg); max-height: 60vh; overflow-y: auto; }
.commit-history-item { background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-md); padding: var(--space-md); }
.commit-history-hash { font-family: 'Space Mono', monospace; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.commit-history-subject { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); margin-bottom: 6px; }
.commit-history-body { font-size: 0.875rem; color: var(--text-secondary); white-space: pre-wrap; line-height: 1.5; }
.commit-history-empty { padding: var(--space-lg); text-align: center; color: var(--text-muted); font-size: 0.875rem; }

:root {
    --bg-primary: #0f0f12;
    --bg-secondary: #18181c;
    --bg-tertiary: #1f1f25;
    --bg-elevated: #26262e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #6e6e73;
    --accent: #BB86FC;
    --accent-light: #D0A9FF;
    --accent-dark: #9B6FD1;
    --accent-glow: rgba(187, 134, 252, 0.3);
    --success: #34c759;
    --warning: #ff9f0a;
    --error: #ff453a;
    --info: #5ac8fa;
    --voice-accent: #af52de;
    --voice-light: #c77dff;
    --gradient-primary: linear-gradient(135deg, var(--accent) 0%, #D0A9FF 100%);
    --gradient-voice: linear-gradient(135deg, var(--voice-accent) 0%, #bf6fe8 100%);
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Space Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    --primary-color: var(--accent);
    --bg-hover: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.1);
    /* Fixed top nav offset: one line of padding + safe-area (see html.study9-webview for Android shell) */
    --mobile-top-bar-gap: calc(44px + env(safe-area-inset-top, 0px));
}

/* Android WebView: MainActivity already applies system bar insets to the container — avoid double top inset in CSS */
html.study9-webview {
    --mobile-top-bar-gap: 40px;
}
html.study9-webview .catalog-navbar,
html.study9-webview #dashboard-screen > .navbar {
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
}
html.study9-webview .player-navbar {
    padding-top: var(--space-xs);
    padding-bottom: var(--space-xs);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; overflow-x: clip; }
/* clip avoids scroll containment bugs that break position:fixed inside WebViews (e.g. Android) */
body { font-family: var(--font-main); background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: clip; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }
/* Opacity-only: transform on .screen breaks position:fixed descendants (mobile bottom toolbar, drawers). */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Login */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-lg); position: relative; overflow: hidden; }
.login-decoration { position: absolute; inset: 0; pointer-events: none; }
.decoration-circle { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5; }
.decoration-circle.c1 { width: 400px; height: 400px; background: var(--accent); top: -100px; right: -100px; animation: float 8s ease-in-out infinite; }
.decoration-circle.c2 { width: 300px; height: 300px; background: var(--voice-accent); bottom: -50px; left: -50px; animation: float 10s ease-in-out infinite reverse; }
.decoration-circle.c3 { width: 200px; height: 200px; background: var(--info); top: 50%; left: 30%; animation: float 12s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(30px, -30px) scale(1.1); } 66% { transform: translate(-20px, 20px) scale(0.9); } }

.login-card { background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-xl); padding: var(--space-2xl); width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.brand { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-sm); }
.brand-icon { width: 48px; height: 48px; color: var(--accent); }
.brand-icon.small { width: 32px; height: 32px; }
.brand-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand h1 { font-size: 1.75rem; font-weight: 700; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.tagline { color: var(--text-secondary); margin-bottom: var(--space-xl); }

.input-group { margin-bottom: var(--space-md); }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.input-group input, .input-group textarea, .input-group select { width: 100%; padding: var(--space-md); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: 1rem; transition: var(--transition-fast); }
.input-group input:focus, .input-group textarea:focus, .input-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-group input::placeholder { color: var(--text-muted); }
.input-group small { display: block; margin-top: var(--space-xs); color: var(--text-muted); font-size: 0.75rem; }

/* Buttons */
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); width: 100%; padding: var(--space-md) var(--space-lg); background: var(--gradient-primary); color: white; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: var(--transition-fast); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 20px; height: 20px; }
.btn-primary.small { width: auto; padding: var(--space-sm) var(--space-md); font-size: 0.875rem; }

.btn-secondary { display: inline-flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: var(--bg-elevated); color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); font-family: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: var(--transition-fast); }
.btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--accent); }
.btn-secondary svg { width: 16px; height: 16px; }

.btn-ghost { padding: var(--space-sm) var(--space-md); background: transparent; color: var(--text-secondary); border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 0.875rem; cursor: pointer; transition: var(--transition-fast); }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }

.test-accounts { margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid rgba(255, 255, 255, 0.1); }
.test-accounts p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: var(--space-sm); }
.account-tags { display: flex; gap: var(--space-sm); }
.account-tags span { padding: var(--space-xs) var(--space-md); background: var(--bg-tertiary); border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: var(--transition-fast); }
.account-tags span:hover { background: var(--accent); color: white; }

/* Navbar */
.navbar { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) var(--space-xl); background: var(--bg-secondary); border-bottom: 1px solid rgba(255, 255, 255, 0.05); position: sticky; top: 0; z-index: 100; }
.nav-brand { display: flex; align-items: center; gap: var(--space-sm); font-weight: 600; font-size: 1.125rem; cursor: pointer; text-decoration: none; color: inherit; }
.nav-brand .brand-icon { color: var(--accent); }
.nav-user { display: flex; align-items: center; gap: var(--space-md); }
.role-badge { padding: var(--space-xs) var(--space-sm); background: var(--accent-glow); color: var(--accent-light); border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.role-badge.admin { background: rgba(255, 69, 58, 0.2); color: var(--error); }
.role-badge.teacher { background: rgba(175, 82, 222, 0.2); color: var(--voice-light); }

/* Dashboard */
.dashboard-main { padding: var(--space-xl); max-width: 1400px; margin: 0 auto; }
.dashboard-header { margin-bottom: var(--space-xl); }
.dashboard-header h1 { font-size: 2rem; margin-bottom: var(--space-xs); }
.dashboard-header h1 span { color: var(--accent); }
.dashboard-header p { color: var(--text-secondary); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); }
.section-header h2 { font-size: 1.25rem; }

.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-lg); }
.course-card { background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: var(--transition-normal); }
.course-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow-md); }
.course-thumbnail { position: relative; aspect-ratio: 16/9; background: var(--bg-tertiary); overflow: hidden; }
.course-thumbnail img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition-normal); position: relative; z-index: 0; }
.course-card:hover .course-thumbnail img { transform: scale(1.05); }
.course-thumbnail .play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: var(--transition-fast); z-index: 5; }
.course-card:hover .play-overlay { opacity: 1; }
.play-overlay svg { width: 48px; height: 48px; color: white; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3)); }

/* ── Glass bezel + sweeping shine on catalog / cards / detail hero ── */
@keyframes thumbnail-glass-sheen {
    0% {
        opacity: 0;
        transform: translate3d(-62%, -6%, 0) skewX(-19deg);
    }
    8% {
        opacity: 0.92;
    }
    42% {
        opacity: 0.82;
        transform: translate3d(168%, 4%, 0) skewX(-19deg);
    }
    50%,
    100% {
        opacity: 0;
        transform: translate3d(168%, 4%, 0) skewX(-19deg);
    }
}

.thumbnail-glass-frame {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: inherit;
}

.thumbnail-glass-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    z-index: 2;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.36),
        inset 0 -18px 45px rgba(18, 8, 40, 0.22),
        0 0 0 1px rgba(0, 0, 0, 0.22);
    background: linear-gradient(
        168deg,
        rgba(255, 255, 255, 0.16) 0%,
        rgba(200, 190, 255, 0.05) 32%,
        transparent 52%,
        rgba(132, 90, 220, 0.08) 100%
    );
}

.thumbnail-glass-frame::after {
    content: '';
    position: absolute;
    top: -14%;
    left: -62%;
    width: 62%;
    height: 138%;
    z-index: 3;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(
        114deg,
        transparent 14%,
        rgba(255, 255, 255, 0.04) 30%,
        rgba(226, 240, 255, 0.48) 45%,
        rgba(232, 210, 255, 0.38) 50%,
        rgba(255, 255, 255, 0.12) 60%,
        transparent 76%
    );
    mix-blend-mode: overlay;
    filter: saturate(118%);
    opacity: 0;
    animation: thumbnail-glass-sheen var(--glass-sheen-duration, 6.2s) ease-in-out infinite;
    animation-delay: var(--glass-sheen-delay, 0s);
    will-change: transform, opacity;
}

.thumbnail-glass-frame.course-detail-image-wrap::after {
    width: 55%;
}

.thumbnail-glass-frame.skeleton-glass-muted::after {
    animation: none;
    opacity: 0;
}

.course-detail-image-wrap.thumbnail-glass-frame {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.course-detail-image-wrap.thumbnail-glass-frame img {
    position: relative;
    z-index: 0;
}

@media (prefers-reduced-motion: reduce) {
    .thumbnail-glass-frame::after {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
        opacity: 0;
    }
}
.course-card.course-hidden { opacity: 0.55; border-color: rgba(255,255,255,0.08); }
.course-card.course-hidden:hover { opacity: 0.8; }
.course-visibility-btn { position: absolute; top: 8px; right: 8px; z-index: 10; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,0.65); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition-fast); backdrop-filter: blur(4px); }
.course-visibility-btn:hover { background: var(--accent); transform: scale(1.1); }
.course-visibility-badge { position: absolute; top: 8px; left: 8px; z-index: 10; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 8px; border-radius: var(--radius-full); }
.course-visibility-badge.badge-visible { background: rgba(52,199,89,0.85); color: white; }
.course-visibility-badge.badge-hidden { background: rgba(255,59,48,0.85); color: white; }
.course-info { padding: var(--space-md); }
.course-info h3 { font-size: 1rem; margin-bottom: var(--space-xs); line-height: 1.3; }
.course-info p { font-size: 0.875rem; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.course-meta { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid rgba(255, 255, 255, 0.05); font-size: 0.75rem; color: var(--text-muted); }
.course-teacher { display: flex; align-items: center; gap: var(--space-xs); }

/* Admin Section */
.admin-section { margin-top: var(--space-2xl); }
.admin-section h2 { margin-bottom: var(--space-lg); }

/* Admin layout: vertical sidebar + main */
.admin-layout {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xl);
    margin-top: var(--space-lg);
}
.admin-sidebar {
    flex: 0 0 220px;
    position: sticky;
    top: 72px;
    align-self: flex-start;
}
.admin-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.admin-sidebar-nav .admin-tab {
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.admin-sidebar-nav .admin-tab svg {
    flex-shrink: 0;
}
.admin-nav-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    margin-left: auto;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    align-self: flex-end;
}
.admin-nav-close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
}
.admin-main {
    flex: 1;
    min-width: 0;
}

/* Mobile admin nav: FAB + drawer (hidden on desktop) */
.admin-nav-fab,
.admin-nav-backdrop {
    display: none;
}

.admin-nav-fab {
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    background: var(--accent);
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-nav-fab:hover {
    transform: scale(1.06);
    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.16);
}

.admin-nav-fab:active {
    transform: scale(0.97);
}

.admin-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2040;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#admin-section.admin-drawer-open .admin-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
#non-admin-courses.admin-drawer-open .admin-nav-backdrop,
#support-tickets-section.admin-drawer-open .admin-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Admin support tickets workspace */
.admin-tickets-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}
.admin-tickets-layout {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.25fr);
    gap: var(--space-lg);
    align-items: start;
}
@media (max-width: 960px) {
    .admin-tickets-layout { grid-template-columns: 1fr; }
}

/* Admin sidebar stays on the left until mobile; small screens use FAB + drawer */
@media (max-width: 768px) {
    .admin-layout {
        align-items: stretch;
    }

    .admin-nav-fab {
        display: flex;
        position: fixed;
        left: max(16px, env(safe-area-inset-left, 0px));
        right: auto;
        top: auto;
        bottom: max(20px, env(safe-area-inset-bottom, 0px));
        z-index: 2050;
    }

    .admin-nav-backdrop {
        display: block;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(320px, calc(100vw - 40px));
        max-width: 100%;
        flex: none;
        align-self: stretch;
        margin: 0;
        padding-top: env(safe-area-inset-top, 0);
        z-index: 2060;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
        border-radius: 0;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        border-top: none;
        border-bottom: none;
        border-left: none;
        top: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #admin-section.admin-drawer-open .admin-sidebar {
        transform: translateX(0);
    }

    #non-admin-courses.admin-drawer-open .admin-sidebar,
    #support-tickets-section.admin-drawer-open .admin-sidebar {
        transform: translateX(0);
    }

    .admin-sidebar-nav {
        flex-direction: column;
        flex-wrap: nowrap;
        border-radius: 0;
        min-height: 100%;
        max-height: none;
        overflow-y: visible;
        padding: var(--space-md) var(--space-sm);
    }

    .admin-nav-close {
        display: flex;
        margin-bottom: var(--space-sm);
    }

    .admin-sidebar-nav .admin-tab {
        width: 100%;
        flex: none;
        text-align: left;
    }

    .admin-main {
        width: 100%;
    }
}
.admin-tickets-table tbody tr {
    cursor: pointer;
}
.admin-tickets-table tbody tr.admin-ticket-row-selected {
    background: rgba(187, 134, 252, 0.12);
}
.admin-tickets-hint { font-size: 0.8rem; margin-top: var(--space-sm); }
.muted-cell { color: var(--text-muted); text-align: center; padding: var(--space-lg); }
.admin-ticket-detail-panel {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-height: 280px;
}
.admin-ticket-detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.admin-ticket-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.admin-ticket-detail-header code { font-size: 0.95rem; }
.admin-ticket-status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-sm);
}
.admin-ticket-status-row label { flex: 0 0 100%; }
.admin-ticket-status-row select { max-width: 160px; }
.admin-ticket-thread-title {
    font-size: 0.9rem;
    margin: var(--space-lg) 0 var(--space-sm);
    font-weight: 600;
}
.admin-ticket-messages {
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.admin-msg-bubble {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.45;
}
.admin-msg-bubble.user { background: rgba(52, 199, 89, 0.12); align-self: flex-start; }
.admin-msg-bubble.agent { background: rgba(90, 200, 250, 0.12); align-self: flex-end; }
.admin-msg-bubble.system { background: rgba(255, 214, 10, 0.08); align-self: center; max-width: 95%; }
.admin-msg-meta { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 4px; }
.admin-msg-bubble .message-content { word-break: break-word; }
.admin-msg-bubble img.message-image { max-width: 100%; margin-top: 8px; border-radius: var(--radius-sm); }
.admin-ticket-reply { margin-top: var(--space-lg); }
.admin-ticket-reply-textarea { width: 100%; box-sizing: border-box; }
.admin-ticket-reply-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}
.text-secondary { color: var(--text-secondary); }
.badge { font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full); text-transform: capitalize; display: inline-block; }
.badge-open { background: rgba(52, 199, 89, 0.18); color: var(--success); }
.badge-pending { background: rgba(255, 214, 10, 0.15); color: #ffd60a; }
.badge-closed { background: rgba(110, 110, 115, 0.25); color: var(--text-muted); }
.badge-complete { background: rgba(52, 199, 89, 0.18); color: var(--success); }
.badge-failed { background: rgba(255, 59, 48, 0.15); color: #ff7769; }

.support-chat-transcript-box {
    max-height: 240px;
    overflow-y: auto;
    padding: var(--space-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.82rem;
    line-height: 1.45;
}
.support-chat-transcript-line { margin-bottom: var(--space-sm); }
.support-chat-transcript-line:last-child { margin-bottom: 0; }
.support-chat-investigation-box {
    padding: var(--space-md);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}
.support-chat-investigation-text { margin: 0; color: var(--text-primary); }
.support-chat-pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.82rem;
    padding: var(--space-md);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin: 0;
    max-height: 160px;
    overflow-y: auto;
}

.settings-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Settings Cards */
.settings-card { background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.07); border-radius: var(--radius-lg); padding: var(--space-lg); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-lg); }
.settings-card-info { flex: 1; }
.settings-card-info h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: var(--space-xs); }
.settings-card-info p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.settings-card-info .settings-status { display: inline-block; margin-top: var(--space-sm); font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full); }
.settings-card-info .settings-status.on { background: rgba(52,199,89,0.15); color: var(--success); }
.settings-card-info .settings-status.off { background: rgba(110,110,115,0.2); color: var(--text-muted); }
.settings-card-stack { flex-direction: column; align-items: stretch; }
.settings-stack-body { display: flex; flex-direction: column; gap: var(--space-sm); margin-top: var(--space-sm); width: 100%; }
.settings-textarea { width: 100%; min-height: 160px; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.12); background: var(--bg-primary); color: var(--text-primary); font-family: inherit; font-size: 0.82rem; line-height: 1.5; resize: vertical; box-sizing: border-box; }
.settings-textarea:focus { outline: none; border-color: var(--accent); }
.tts-engine-selector { display: flex; gap: 8px; align-self: center; flex-wrap: wrap; }
.tts-option-group { display: flex; align-items: center; gap: 3px; }
.tts-engine-btn { padding: 6px 18px; border-radius: var(--radius-full); border: 1px solid rgba(255,255,255,0.12); background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: var(--transition-fast); }
.tts-engine-btn:hover { border-color: var(--accent); color: var(--accent); }
.tts-engine-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.tts-test-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition-fast); padding: 0; flex-shrink: 0; }
.tts-test-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(187,134,252,0.1); }
.tts-test-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.users-table { background: var(--bg-secondary); border-radius: var(--radius-lg); overflow: hidden; }
.users-table table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: var(--space-md); text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.users-table th { background: var(--bg-tertiary); font-weight: 600; font-size: 0.875rem; color: var(--text-secondary); }
.users-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* Player Layout - Full viewport fit */
.player-navbar { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-sm) var(--space-lg); background: var(--bg-secondary); border-bottom: 1px solid rgba(255, 255, 255, 0.05); flex-shrink: 0; min-height: 50px; }
.player-navbar .nav-user { margin-left: auto; display: flex; align-items: center; gap: var(--space-md); }
.btn-back { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); background: transparent; color: var(--text-secondary); border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 0.8rem; cursor: pointer; transition: var(--transition-fast); }
.btn-back:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.btn-back svg { width: 16px; height: 16px; }
.player-navbar h2 { flex: 1; font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-nav-right { color: var(--text-muted); font-size: 0.8rem; }

.player-layout { display: grid; grid-template-columns: 240px 280px 1fr 280px; height: calc(100vh - 60px); overflow: hidden; }

/* Chat Panels - Left and Right */
.chat-panel { display: flex; flex-direction: column; background: var(--bg-secondary); border-right: 1px solid rgba(255, 255, 255, 0.05); height: 100%; overflow: hidden; }
.right-panel { border-right: none; border-left: 1px solid rgba(255, 255, 255, 0.05); }

/* Middle Column: Playlist + Live Chat */
.middle-panel { display: flex; flex-direction: column; background: var(--bg-secondary); border-right: 1px solid rgba(255, 255, 255, 0.05); height: 100%; overflow: hidden; gap: var(--space-sm); padding: var(--space-sm); }
.middle-panel .playlist-section { flex: 1; min-height: 0; }
.middle-panel .live-chat-section { flex: 1; min-height: 0; }
.panel-header { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-sm); border-bottom: 1px solid rgba(255, 255, 255, 0.05); flex-shrink: 0; }
.panel-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: var(--accent-glow); color: var(--accent); border-radius: var(--radius-sm); flex-shrink: 0; }
.panel-icon.voice { background: rgba(175, 82, 222, 0.2); color: var(--voice-light); }
.panel-icon svg { width: 14px; height: 14px; }
.panel-header h3 { flex: 1; font-size: 0.8rem; font-weight: 600; }
.ai-badge { padding: 2px 6px; background: var(--gradient-primary); color: white; border-radius: var(--radius-full); font-size: 0.6rem; font-weight: 700; text-transform: uppercase; }
.ai-badge.voice { background: var(--gradient-voice); }
.live-badge { padding: 2px 6px; background: rgba(52, 199, 89, 0.2); color: var(--success); border-radius: var(--radius-full); font-size: 0.6rem; font-weight: 600; }

/* Chat Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-sm); display: flex; flex-direction: column; gap: var(--space-sm); min-height: 0; }
.chat-welcome { padding: var(--space-sm); background: var(--bg-tertiary); border-radius: var(--radius-md); font-size: 0.8rem; color: var(--text-secondary); }
.chat-message { display: flex; flex-direction: column; gap: 2px; animation: messageIn 0.3s ease; }
@keyframes messageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chat-message.user { align-items: flex-end; }
.chat-message .message-content { max-width: 90%; padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); border-radius: var(--radius-sm); font-size: 0.8rem; line-height: 1.4; }
.chat-message.user .message-content { background: var(--accent); color: white; border-bottom-right-radius: 2px; }
.chat-message.ai .message-content { border-bottom-left-radius: 2px; }
.chat-message .message-meta { font-size: 0.65rem; color: var(--text-muted); padding: 0 2px; }

.live-chat .chat-message .message-content { background: var(--bg-elevated); }
.live-chat .chat-message.own .message-content { background: var(--accent); color: white; }
.live-chat .message-author { font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1px; }
.live-chat .message-author.teacher { color: var(--voice-light); }

/* Chat Input */
.chat-input-area { display: flex; gap: var(--space-xs); padding: var(--space-sm); border-top: 1px solid rgba(255, 255, 255, 0.05); flex-shrink: 0; }
.chat-input-area input { flex: 1; padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-full); color: var(--text-primary); font-family: inherit; font-size: 0.8rem; min-width: 0; }
.chat-input-area input:focus { outline: none; border-color: var(--accent); }
.btn-send { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--gradient-primary); border: none; border-radius: 50%; color: white; cursor: pointer; transition: var(--transition-fast); flex-shrink: 0; }
.btn-send:hover { transform: scale(1.05); }
.btn-send svg { width: 14px; height: 14px; }

/* Voice Controls */
.voice-messages { flex: 1; overflow-y: auto; padding: var(--space-sm); min-height: 0; }
.voice-controls { padding: var(--space-sm); display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); border-top: 1px solid rgba(255, 255, 255, 0.05); flex-shrink: 0; }
.voice-status { font-size: 0.75rem; color: var(--text-muted); }
.voice-status.listening { color: var(--success); }
.voice-status.speaking { color: var(--voice-light); }
.voice-btn { width: 56px; height: 56px; background: var(--gradient-voice); border: none; border-radius: 50%; cursor: pointer; transition: var(--transition-normal); position: relative; }
.voice-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(175, 82, 222, 0.4); }
.voice-btn.active { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(175, 82, 222, 0.4); } 50% { box-shadow: 0 0 0 15px rgba(175, 82, 222, 0); } }
.voice-btn-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.voice-btn .mic-icon { width: 24px; height: 24px; color: white; }
.voice-btn.active .mic-icon { display: none; }
.voice-waves { display: none; gap: 2px; align-items: center; height: 24px; }
.voice-btn.active .voice-waves { display: flex; }
.voice-waves span { width: 3px; height: 100%; background: white; border-radius: 2px; animation: wave 0.5s ease-in-out infinite; }
.voice-waves span:nth-child(1) { animation-delay: 0s; }
.voice-waves span:nth-child(2) { animation-delay: 0.1s; }
.voice-waves span:nth-child(3) { animation-delay: 0.2s; }
.voice-waves span:nth-child(4) { animation-delay: 0.1s; }
.voice-waves span:nth-child(5) { animation-delay: 0s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.voice-hint { font-size: 0.65rem; color: var(--text-muted); }

/* Video Main Area - Constrained to fit */
.video-main { background: var(--bg-primary); display: flex; flex-direction: column; height: 100%; overflow: hidden; padding: var(--space-sm); }
.video-section { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: var(--space-sm); }
.video-container { flex-shrink: 0; }
.video-player { aspect-ratio: 16/9; background: var(--bg-secondary); border-radius: var(--radius-md); overflow: hidden; position: relative; max-height: 55vh; }
.video-player iframe { width: 100%; height: 100%; border: none; }
.video-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-sm); color: var(--text-muted); }
.video-placeholder svg { width: 48px; height: 48px; opacity: 0.3; }
.video-placeholder p { font-size: 0.85rem; }
.video-controls { display: flex; align-items: center; justify-content: space-between; padding: var(--space-xs) var(--space-sm); background: var(--bg-secondary); border-radius: var(--radius-sm); flex-shrink: 0; }
.video-info h3 { font-size: 0.85rem; margin-bottom: 2px; }
.video-info span { font-size: 0.75rem; color: var(--text-muted); }
.video-nav-buttons { display: flex; gap: var(--space-xs); }
.btn-nav { display: flex; align-items: center; gap: 4px; padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); color: var(--text-primary); border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.75rem; cursor: pointer; transition: var(--transition-fast); }
.btn-nav:hover:not(:disabled) { background: var(--accent); }
.btn-nav:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-nav svg { width: 14px; height: 14px; }

/* Bottom section: Playlist + Live Chat side by side */
.bottom-section { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); flex: 1; min-height: 0; overflow: hidden; }

/* Playlist */
.playlist-section { background: var(--bg-secondary); border-radius: var(--radius-md); display: flex; flex-direction: column; overflow: hidden; }
.playlist-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}
.playlist-section-head h4 {
    margin: 0;
    padding: 0;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
}
.video-playlist { flex: 1; overflow-y: auto; padding: var(--space-xs); display: flex; flex-direction: column; gap: 4px; }
.playlist-item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition-fast); }
.playlist-item:hover { border-color: var(--accent); background: var(--bg-tertiary); }
.playlist-item.active { border-color: var(--accent); background: var(--accent-glow); }
.playlist-item .item-number { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); border-radius: 4px; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.playlist-item.active .item-number { background: var(--accent); color: white; }
.playlist-item .item-info { flex: 1; min-width: 0; }
.playlist-item .item-title { font-size: 0.75rem; font-weight: 500; margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-item .item-duration { font-size: 0.65rem; color: var(--text-muted); }
.playlist-item .item-status { width: 16px; height: 16px; color: var(--success); opacity: 0; flex-shrink: 0; }
.playlist-item.completed .item-status { opacity: 1; }

/* Live Chat Section */
.live-chat-section { background: var(--bg-secondary); border-radius: var(--radius-md); display: flex; flex-direction: column; overflow: hidden; }
.live-chat-section .panel-header { padding: var(--space-xs) var(--space-sm); }
.live-chat-section .chat-messages { flex: 1; overflow-y: auto; padding: var(--space-xs); min-height: 0; }
.live-chat-section .chat-input-area { padding: var(--space-xs); }

/* Editor Screen */
.editor-layout { display: grid; grid-template-columns: 350px 1fr; min-height: calc(100vh - 60px); }
.editor-sidebar { background: var(--bg-secondary); padding: var(--space-xl); border-right: 1px solid rgba(255, 255, 255, 0.05); }
.editor-sidebar h3 { margin-bottom: var(--space-lg); }

/* Thumbnail Generator */
/* Thumbnail Preview */
.thumbnail-preview { margin-top: var(--space-md); padding: var(--space-md); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); text-align: center; }
.thumbnail-preview img { display: block; margin: 0 auto; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }

/* Thumbnail Upload */
.thumbnail-upload { margin-top: var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid rgba(255, 255, 255, 0.1); }
.thumbnail-upload label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.thumbnail-upload input[type="file"] { width: 100%; padding: var(--space-md); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: 0.875rem; margin-bottom: var(--space-md); transition: var(--transition-fast); cursor: pointer; }
.thumbnail-upload input[type="file"]:hover { border-color: var(--info); }
.thumbnail-upload input[type="file"]:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px rgba(90, 200, 250, 0.3); }
.thumbnail-upload input[type="file"]::file-selector-button { padding: var(--space-sm) var(--space-md); margin-right: var(--space-md); background: var(--bg-elevated); color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.875rem; cursor: pointer; transition: var(--transition-fast); }
.thumbnail-upload input[type="file"]::file-selector-button:hover { background: var(--info); color: white; border-color: var(--info); }
.thumbnail-upload .btn-secondary { width: 100%; justify-content: center; padding: var(--space-md); background: linear-gradient(135deg, var(--info) 0%, #5ac8fa 100%); border: none; color: white; }
.thumbnail-upload .btn-secondary:hover { opacity: 0.9; transform: translateY(-1px); }
.thumbnail-upload .btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.thumbnail-upload .btn-secondary svg { flex-shrink: 0; }

/* Thumbnail Generator */
.thumbnail-generator { margin-top: var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid rgba(255, 255, 255, 0.1); }
.thumbnail-generator label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.thumbnail-generator textarea { width: 100%; padding: var(--space-md); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: 0.875rem; resize: vertical; min-height: 60px; margin-bottom: var(--space-md); transition: var(--transition-fast); }
.thumbnail-generator textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.thumbnail-generator textarea::placeholder { color: var(--text-muted); }
.thumbnail-generator .btn-secondary { width: 100%; justify-content: center; padding: var(--space-md); background: linear-gradient(135deg, var(--voice-accent) 0%, #bf6fe8 100%); border: none; color: white; }
.thumbnail-generator .btn-secondary:hover { opacity: 0.9; transform: translateY(-1px); }
.thumbnail-generator .btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.thumbnail-generator .btn-secondary svg { flex-shrink: 0; }
.thumbnail-generator .spinner, .thumbnail-upload .spinner { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.editor-main { padding: var(--space-xl); }
.editor-playlist { display: flex; flex-direction: column; gap: var(--space-md); }

/* Video Preview in Editor */
.editor-video-preview { margin-bottom: var(--space-xl); padding: var(--space-lg); background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.editor-video-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); }
.editor-video-header h4 { font-size: 1rem; color: var(--text-primary); font-weight: 600; }
.editor-video-player { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius-md); background: #000; margin-bottom: var(--space-md); }
.editor-video-player iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.editor-video-actions { display: flex; align-items: center; gap: var(--space-lg); flex-wrap: wrap; }
.video-link-group { flex: 1; min-width: 200px; }
.video-link-group label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: var(--space-xs); }
.video-link-row { display: flex; gap: var(--space-sm); }
.video-link-row input { flex: 1; padding: var(--space-sm) var(--space-md); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 0.875rem; font-family: var(--font-mono); }
.btn-copy { display: flex; align-items: center; justify-content: center; padding: var(--space-sm); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: var(--transition-fast); }
.btn-copy:hover { background: var(--bg-elevated); border-color: var(--accent); color: var(--accent); }
.btn-copy.copied { background: var(--success); border-color: var(--success); color: white; }
.btn-transcript { display: inline-flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: linear-gradient(135deg, var(--accent) 0%, #5b8def 100%); color: white; border: none; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500; text-decoration: none; transition: var(--transition-fast); }
.btn-transcript:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); }
.btn-transcript .external-icon { opacity: 0.7; }
.btn-icon.small { padding: var(--space-xs); background: transparent; border: none; color: var(--text-muted); cursor: pointer; transition: var(--transition-fast); }
.btn-icon.small:hover { color: var(--text-primary); }
#close-preview-btn { flex-shrink: 0; }
.editor-video-item { display: flex; align-items: center; gap: var(--space-md); padding: var(--space-md); background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-md); transition: var(--transition-fast); }
.editor-video-item .drag-handle { cursor: grab; color: var(--text-muted); padding: var(--space-sm); }
.editor-video-item .drag-handle:active { cursor: grabbing; }
.editor-video-item .video-position { display: flex; align-items: center; gap: var(--space-xs); }
.editor-video-item .video-position label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; min-width: 12px; }
.editor-video-item .position-input { width: 50px; padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.875rem; font-family: var(--font-mono); text-align: center; transition: var(--transition-fast); }
.editor-video-item .position-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.editor-video-item .position-input::-webkit-inner-spin-button, .editor-video-item .position-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.editor-video-item .video-details { flex: 1; }
.editor-video-item .video-details h4 { font-size: 0.9rem; margin-bottom: var(--space-xs); }
.editor-video-item .video-details span { font-size: 0.75rem; color: var(--text-muted); }
.editor-video-item .video-actions { display: flex; gap: var(--space-sm); }
.sortable-ghost { opacity: 0.4; background: var(--bg-tertiary); }
.sortable-drag { opacity: 0.8; transform: rotate(2deg); box-shadow: var(--shadow-lg); }

/* Chapter Groups (Editor) */
.editor-section-controls { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); }
.editor-section-controls .editor-controls { display: flex; gap: var(--space-sm); }
.chapter-group { background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: var(--radius-md); overflow: hidden; transition: var(--transition-fast); margin-bottom: var(--space-sm); }
.chapter-group:hover { border-color: rgba(255, 255, 255, 0.12); }
.chapter-group.sortable-ghost { opacity: 0.4; }
.chapter-header { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-md); background: var(--bg-secondary); cursor: pointer; user-select: none; }
.chapter-drag-handle { cursor: grab; color: var(--text-muted); padding: var(--space-xs); display: flex; align-items: center; }
.chapter-drag-handle:active { cursor: grabbing; }
.chapter-toggle { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: var(--space-xs); font-size: 0.8rem; transition: var(--transition-fast); display: flex; align-items: center; }
.chapter-toggle:hover { color: var(--accent); }
.chapter-toggle .expand-icon { display: inline-block; transition: transform 0.2s; }
.chapter-toggle.expanded .expand-icon { transform: rotate(90deg); }
.chapter-title { flex: 1; font-size: 0.95rem; font-weight: 600; margin: 0; }
.chapter-count { font-size: 0.75rem; color: var(--text-muted); margin-right: var(--space-sm); }
.chapter-actions { display: flex; gap: var(--space-xs); }
.chapter-units { display: none; padding: var(--space-xs); flex-direction: column; gap: var(--space-xs); }
.chapter-units.expanded { display: flex; }

/* Playlist Chapter (Student Player) */
.playlist-chapter { }
.playlist-chapter-header { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); border-radius: var(--radius-sm); margin-bottom: 2px; cursor: pointer; user-select: none; }
.playlist-chapter-header:hover { background: var(--bg-elevated); }
.playlist-chapter-header .expand-icon { display: inline-block; transition: transform 0.2s; color: var(--text-muted); font-size: 0.65rem; }
.playlist-chapter-header.expanded .expand-icon { transform: rotate(90deg); }
.playlist-chapter-title { flex: 1; font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.playlist-chapter-count { font-size: 0.65rem; color: var(--text-muted); }
.playlist-chapter-units { display: none; flex-direction: column; gap: 4px; padding: 2px 0; }
.playlist-chapter-units.expanded { display: flex; }
.btn-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); border: none; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: var(--transition-fast); }
.btn-icon:hover { background: var(--accent); color: white; }
.btn-icon.danger:hover { background: var(--error); }
.btn-icon svg { width: 16px; height: 16px; }

/* Modals */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); z-index: 1000; padding: var(--space-lg); }
.modal.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-content { background: var(--bg-secondary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-lg); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-lg); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.modal-header h3 { font-size: 1.125rem; }
.modal-form-body { padding: var(--space-lg); }
.modal-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: var(--transition-fast); }
.modal-close:hover { color: var(--text-primary); }
.modal-content form { padding: var(--space-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-md); margin-top: var(--space-lg); }
.modal-cancel { padding: var(--space-sm) var(--space-lg) !important; }

/* Toast */
.toast-container { position: fixed; bottom: var(--space-lg); right: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-sm); z-index: 2000; }
.toast { padding: var(--space-md) var(--space-lg); background: var(--bg-elevated); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); color: var(--text-primary); font-size: 0.875rem; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--info); }

/* Loading States */
.loading { display: inline-flex; align-items: center; gap: var(--space-sm); }
.loading::after { content: ''; width: 16px; height: 16px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing-indicator { display: flex; gap: 4px; padding: var(--space-sm) var(--space-md); background: var(--bg-tertiary); border-radius: var(--radius-md); width: fit-content; }
.typing-indicator span { width: 8px; height: 8px; background: var(--text-muted); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.empty-state { text-align: center; padding: var(--space-2xl); color: var(--text-muted); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: var(--space-md); opacity: 0.3; }
.empty-state h3 { margin-bottom: var(--space-sm); color: var(--text-secondary); }

/* Signup Link */
.signup-link { margin-top: var(--space-lg); text-align: center; }
.signup-link p { color: var(--text-muted); font-size: 0.875rem; }
.signup-link a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* Signup Step Wizard */
.signup-steps { margin-bottom: var(--space-lg); }
.step-indicator { display: flex; align-items: center; justify-content: center; gap: 4px; }
.step-dot { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--bg-tertiary); border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); font-size: 0.8rem; font-weight: 600; transition: var(--transition-fast); }
.step-dot.active { background: var(--accent); border-color: var(--accent); color: white; }
.step-dot.completed { background: var(--accent-dark); border-color: var(--accent-dark); color: white; }
.step-line { flex: 1; height: 2px; background: var(--bg-tertiary); border-radius: 1px; max-width: 40px; transition: var(--transition-fast); }
.step-line.active { background: var(--accent); }
.signup-main { display: flex; justify-content: center; align-items: flex-start; padding: var(--space-xl) var(--space-md); min-height: calc(100vh - 64px); }
.signup-step { display: none !important; }
.signup-step.active { display: block !important; animation: fadeIn 0.25s ease; }
.step-buttons { display: flex; gap: var(--space-md); margin-top: var(--space-md); }
.step-buttons .btn-ghost { flex: 1; }
.step-buttons .btn-primary { flex: 2; }
.terms-frame-wrapper { border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md); overflow: hidden; margin-bottom: var(--space-md); height: 200px; }
.terms-frame { width: 100%; height: 100%; border: none; background: var(--bg-primary); }
.terms-checkbox { display: flex; align-items: flex-start; gap: var(--space-sm); font-size: 0.85rem; color: var(--text-secondary); margin-bottom: var(--space-md); cursor: pointer; }
.terms-checkbox input { margin-top: 2px; accent-color: var(--accent); }
.terms-checkbox a { color: var(--accent); }
.signup-link a:hover { text-decoration: underline; }

/* Admin Tabs */
.admin-tabs { display: flex; gap: var(--space-sm); margin-bottom: var(--space-lg); border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: var(--space-md); }
.admin-tab { padding: var(--space-sm) var(--space-lg); background: transparent; border: none; color: var(--text-muted); font-family: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer; border-radius: var(--radius-md); transition: var(--transition-fast); }
.admin-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.admin-tab.active { color: var(--accent); background: var(--accent-glow); }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* User Action Buttons in Table */
.users-table .user-actions { display: flex; gap: var(--space-xs); justify-content: flex-end; }
.users-table .btn-action { padding: var(--space-xs) var(--space-sm); background: var(--bg-tertiary); border: none; border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 0.75rem; cursor: pointer; transition: var(--transition-fast); }
.users-table .btn-action:hover { background: var(--accent); color: white; }
.users-table .btn-action.danger:hover { background: var(--error); }

/* Expandable User Rows */
.user-table { width: 100%; border-collapse: collapse; }
.user-table th { text-align: left; padding: var(--space-sm); color: var(--text-muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.user-table td { padding: var(--space-sm); border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
.user-table .col-name { width: 30%; }
.user-table .col-username { width: 25%; }
.user-table .col-expand { width: 40px; text-align: center; }
.user-table .col-actions { width: 35%; text-align: right; }
.user-table .user-name { font-weight: 600; color: var(--text-primary); }
.user-table .user-row { cursor: pointer; transition: var(--transition-fast); }
.user-table .user-row:hover { background: rgba(255, 255, 255, 0.02); }
.user-table .btn-expand { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: var(--space-xs); font-size: 0.8rem; transition: var(--transition-fast); }
.user-table .btn-expand:hover { color: var(--accent); }
.user-table .expand-icon { display: inline-block; transition: transform 0.2s; }

/* User Details Expanded Row */
.user-details-row { display: none; background: var(--bg-tertiary); }
.user-details-row.expanded { display: table-row; }
.user-details { padding: var(--space-md); }
.user-details .detail-section { margin-bottom: var(--space-md); }
.user-details .detail-section h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: var(--space-sm); border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: var(--space-xs); }
.user-details p { font-size: 0.875rem; color: var(--text-secondary); }

/* Toggle Grid in Expanded Row */
.toggle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-md); }
.toggle-item { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) var(--space-md); background: var(--bg-secondary); border-radius: var(--radius-sm); }
.toggle-item label { display: flex; flex-direction: column; gap: 2px; }
.toggle-item .toggle-label { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); }
.toggle-item .toggle-desc { font-size: 0.7rem; color: var(--text-muted); }

/* Browse Courses Modal */
.modal-large { max-width: 900px; }
.available-courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-md); padding: var(--space-lg); max-height: 70vh; overflow-y: auto; }
.available-course-card { background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-md); overflow: hidden; transition: var(--transition-normal); }
.available-course-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.available-course-card .course-thumbnail { aspect-ratio: 16/9; background: var(--bg-secondary); overflow: hidden; }
.available-course-card .course-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.available-course-card .course-info { padding: var(--space-md); }
.available-course-card .course-info h4 { font-size: 0.9rem; margin-bottom: var(--space-xs); }
.available-course-card .course-info p { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: var(--space-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.available-course-card .course-teacher { font-size: 0.75rem; color: var(--text-muted); margin-bottom: var(--space-md); display: flex; align-items: center; gap: var(--space-xs); }
.available-course-card .btn-enroll { width: 100%; padding: var(--space-sm); background: var(--gradient-primary); color: white; border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: var(--transition-fast); }
.available-course-card .btn-enroll:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); }

/* Modal Info Text */
.modal-info { padding: var(--space-md); background: var(--bg-tertiary); border-radius: var(--radius-md); margin-bottom: var(--space-md); color: var(--text-secondary); font-size: 0.875rem; }

/* Video Modal Grid */
.video-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.video-modal-left, .video-modal-right { display: flex; flex-direction: column; gap: var(--space-sm); }
.transcript-header { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.transcript-header label { font-weight: 600; color: var(--text-primary); }
.transcript-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.btn-secondary.small { padding: var(--space-xs) var(--space-sm); font-size: 0.75rem; }
.translation-status { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; padding: var(--space-sm); background: var(--bg-tertiary); border-radius: var(--radius-sm); }
.status-label { font-size: 0.75rem; color: var(--text-muted); }
.lang-badge { padding: 2px 8px; background: var(--success); color: white; border-radius: var(--radius-full); font-size: 0.65rem; font-weight: 600; }
.lang-badge.missing { background: var(--text-muted); }

/* Transcript Section (Center - below video) */
.transcript-section-center { background: var(--bg-secondary); border-radius: var(--radius-md); margin-top: var(--space-sm); display: flex; flex-direction: column; flex: 1; min-height: 150px; }
.transcript-header-bar { display: flex; align-items: center; justify-content: space-between; padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid rgba(255, 255, 255, 0.05); flex-shrink: 0; }
.transcript-title { display: flex; align-items: center; gap: var(--space-xs); font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.transcript-title svg { color: var(--info); }
.language-select { padding: 4px 8px; background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.7rem; cursor: pointer; }
.language-select:focus { outline: none; border-color: var(--accent); }

.transcript-content-center { flex: 1; overflow-y: auto; padding: var(--space-sm); font-size: 0.8rem; line-height: 1.6; color: var(--text-secondary); }
.transcript-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--text-muted); }
.transcript-placeholder p { font-size: 0.8rem; }
.transcript-text { white-space: pre-wrap; word-wrap: break-word; }

/* Responsive for video modal */
@media (max-width: 768px) {
    .video-modal-grid { grid-template-columns: 1fr; }
}

/* ========================================
   MOBILE PANEL OVERLAY & TOOLBAR BASE
   (hidden on desktop, shown via media query)
   ======================================== */
.mobile-bottom-toolbar { display: none; }

.mobile-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 250;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.mobile-panel-overlay.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ========================================
   DESKTOP RESPONSIVE (column width scaling)
   ======================================== */
@media (max-width: 1600px) { .player-layout { grid-template-columns: 220px 260px 1fr 260px; } }
@media (max-width: 1400px) { .player-layout { grid-template-columns: 200px 240px 1fr 240px; } }
@media (max-width: 1200px) { .player-layout { grid-template-columns: 180px 220px 1fr 220px; } }

/* Desktop ≥1024: minimize auxiliary learner panels → floating FAB; video stays full-width center column */
@media (min-width: 1024px) {
    #player-screen .panel-desktop-minimize-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        margin-left: auto;
        padding: 0;
        flex-shrink: 0;
        border: none;
        border-radius: var(--radius-sm);
        background: var(--bg-tertiary);
        color: var(--text-muted);
        cursor: pointer;
        transition: var(--transition-fast);
    }
    #player-screen .panel-desktop-minimize-btn:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--text-primary);
    }
    #player-screen .playlist-section-head .panel-desktop-minimize-btn {
        margin-left: 0;
    }

    #player-screen .player-desktop-fab-dock {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
        position: fixed;
        z-index: 130;
        right: max(12px, var(--space-md));
        bottom: calc(22px + env(safe-area-inset-bottom, 0px));
        pointer-events: none;
        align-items: flex-end;
    }
    #player-screen .fab-restore-panel {
        pointer-events: auto;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.14);
        background: var(--bg-elevated);
        color: var(--text-secondary);
        box-shadow: var(--shadow-lg);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.15s ease, background var(--transition-fast), color var(--transition-fast);
    }
    #player-screen .fab-restore-panel:hover {
        transform: scale(1.06);
        color: var(--text-primary);
    }
    #player-screen .fab-restore-panel svg { width: 22px; height: 22px; flex-shrink: 0; }
    #player-screen .fab-restore-live {
        background: rgba(52, 199, 89, 0.35);
        border-color: rgba(52, 199, 89, 0.55);
        color: #d4fcdc;
    }
    #player-screen .fab-restore-playlist {
        color: var(--accent);
        border-color: rgba(59, 130, 246, 0.35);
    }
    #player-screen .fab-restore-transcript {
        color: var(--info);
        border-color: rgba(90, 200, 250, 0.35);
    }

    /* Middle-column sections (playlist / live chat) collapse vertically; grid width handled in JS until both minimized */
    #player-screen .middle-panel .playlist-section.player-desktop-min-section,
    #player-screen .middle-panel .live-chat-section.player-desktop-min-section {
        flex: 0 0 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        border: none !important;
        pointer-events: none !important;
    }

    #player-screen .transcript-section-center.player-desktop-min-section {
        display: none !important;
    }

    #player-screen .video-main.player-desktop-video-tall .video-player {
        max-height: min(calc(100vh - 120px), 88vh);
    }

    /* Middle grid column collapses entirely when playlist + live are minimized */
    #player-screen .middle-panel.desktop-mid-inert {
        padding: 0;
        gap: 0;
        overflow: hidden;
        pointer-events: none;
    }

    /* FAB only while course player screen is visible (layout shell stays in DOM) */
    #player-screen:not(.active) .player-desktop-fab-dock {
        display: none !important;
    }
}

@media (max-width: 1023px) {
    #player-screen .panel-desktop-minimize-btn { display: none !important; }
    #player-screen .player-desktop-fab-dock { display: none !important; }
}

/* ========================================
   MOBILE LAYOUT — PLAYER SCREEN
   Focus: Video + Playlist inline.
   AI Chat, Transcript, Live Chat, Voice
   become sliding bottom-sheet drawers.
   ======================================== */
@media (max-width: 1023px) {

    /* Course player & editor: fixed top bar (position:sticky is unreliable in WebViews) */
    .player-navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        z-index: 150;
        flex-wrap: nowrap;
        min-width: 0;
        overflow-x: hidden;
        gap: var(--space-xs);
        padding: calc(env(safe-area-inset-top, 0px) + var(--space-xs)) var(--space-sm) var(--space-xs);
    }

    #player-screen .player-layout,
    #editor-screen .editor-layout {
        margin-top: var(--mobile-top-bar-gap);
    }

    /* Catalog & dashboard: fixed top bar (sticky breaks in WebViews; works through tablet widths) */
    /* overflow: visible so .mobile-nav-menu (position:absolute; top:100%) is not clipped */
    .catalog-navbar,
    #dashboard-screen > .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        z-index: 150;
        overflow-x: visible;
        overflow-y: visible;
        gap: var(--space-xs);
        align-items: center;
    }

    .catalog-navbar {
        padding: calc(env(safe-area-inset-top, 0px) + var(--space-xs)) var(--space-xl) var(--space-xs);
    }

    #dashboard-screen > .navbar {
        padding: calc(env(safe-area-inset-top, 0px) + var(--space-xs)) var(--space-xl) var(--space-xs);
        min-width: 0;
    }

    #dashboard-screen > .navbar .nav-brand {
        min-width: 0;
        flex: 0 1 auto;
    }

    #dashboard-screen > .navbar .nav-brand > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #dashboard-screen > .navbar .nav-center {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        justify-content: center;
    }

    #dashboard-screen > .navbar .nav-user {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        gap: var(--space-sm);
    }

    #dashboard-screen > .navbar #user-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: min(160px, 28vw);
    }

    .screen > .catalog-navbar ~ main {
        padding-top: calc(var(--mobile-top-bar-gap) + var(--space-md));
    }

    #dashboard-screen > .dashboard-main {
        padding: calc(var(--mobile-top-bar-gap) + var(--space-xl)) var(--space-xl) var(--space-xl);
    }

    .catalog-navbar .nav-brand {
        min-width: 0;
        flex: 0 1 auto;
    }

    .catalog-navbar .nav-brand > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-btn {
        flex-shrink: 0;
        margin-left: auto;
    }

    /* Player layout: scrollable column, padded for the fixed toolbar */
    .player-layout {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: calc(100vh - var(--mobile-top-bar-gap) - 72px);
        padding-bottom: 68px; /* toolbar height + breathing room */
        -webkit-overflow-scrolling: touch;
    }

    /* Video column first */
    .video-main {
        order: 1;
        height: auto;
        flex-shrink: 0;
        overflow: visible;
        padding: var(--space-xs);
    }

    .video-section {
        height: auto;
        gap: var(--space-xs);
        flex: none;
    }

    .video-container { flex-shrink: 0; }

    .video-player {
        max-height: none;
        /* Natural 16:9 via aspect-ratio */
    }

    /* Transcript hides from inline flow — becomes drawer */
    .transcript-section-center {
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        height: 68vh;
        max-height: 68vh;
        max-height: 68dvh;
        border-radius: 16px 16px 0 0;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-bottom: none;
        z-index: 300;
        transform: translateY(102%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        margin-top: 0;
        flex: none;
        background: var(--bg-secondary);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
        display: flex;
        flex-direction: column;
    }
    .transcript-section-center.mobile-open {
        transform: translateY(0);
    }

    /* Playlist column: show inline below video */
    .middle-panel {
        order: 2;
        height: auto;
        border: none;
        border-right: none;
        background: transparent;
        padding: 0 var(--space-xs) var(--space-xs);
        gap: 0;
        flex-shrink: 0;
        overflow: visible;
    }

    .middle-panel .playlist-section {
        flex: none;
        height: auto;
        max-height: none;
        border-radius: var(--radius-md);
        overflow: visible;
    }

    /* Playlist items flow naturally (no fixed height parent) */
    .middle-panel .playlist-section .video-playlist {
        flex: none;
        overflow-y: visible;
        max-height: none;
    }

    /* Live chat: hidden from inline flow — becomes drawer */
    .middle-panel .live-chat-section {
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        height: 68vh;
        max-height: 68vh;
        max-height: 68dvh;
        border-radius: 16px 16px 0 0;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-bottom: none;
        z-index: 300;
        transform: translateY(102%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        background: var(--bg-secondary);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
        display: flex;
        flex-direction: column;
    }
    .middle-panel .live-chat-section.mobile-open {
        transform: translateY(0);
    }

    /* AI Chat panel: becomes bottom drawer */
    .chat-panel.left-panel {
        display: flex;
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        height: 68vh;
        max-height: 68vh;
        max-height: 68dvh;
        border-radius: 16px 16px 0 0;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-bottom: none;
        z-index: 300;
        transform: translateY(102%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
    }
    .chat-panel.left-panel.mobile-open {
        transform: translateY(0);
    }

    /* Voice panel: becomes bottom drawer */
    .chat-panel.right-panel {
        display: flex;
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        height: 68vh;
        max-height: 68vh;
        max-height: 68dvh;
        border-radius: 16px 16px 0 0;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-bottom: none;
        z-index: 300;
        transform: translateY(102%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
        overflow-x: hidden;
        min-width: 0;
    }
    .chat-panel.right-panel.mobile-open {
        transform: translateY(0);
    }

    /* Voice drawer: header + controls inside narrow screens / WebView */
    .chat-panel.right-panel .panel-header h3 {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .chat-panel.right-panel .voice-controls {
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
        box-sizing: border-box;
    }

    /* Drag-handle pill at top of every drawer */
    .chat-panel.left-panel::before,
    .chat-panel.right-panel::before,
    .middle-panel .live-chat-section::before,
    .transcript-section-center::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 10px auto 4px;
        flex-shrink: 0;
    }

    /* ── Mobile Bottom Toolbar ── */
    .mobile-bottom-toolbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100vw;
        height: 60px;
        background: var(--bg-secondary);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 400;
        align-items: stretch;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    }

    .mobile-tool-btn {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        flex: 1;
        min-width: 0;
        padding: 6px var(--space-xs) 4px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-family: inherit;
        font-size: 0.58rem;
        font-weight: 500;
        cursor: pointer;
        border-radius: 0;
        transition: color var(--transition-fast), background var(--transition-fast);
        letter-spacing: 0.01em;
    }

    .mobile-tool-btn svg {
        flex-shrink: 0;
        transition: transform var(--transition-fast);
    }

    .mobile-tool-btn:active svg {
        transform: scale(0.9);
    }

    .mobile-tool-btn.active {
        color: var(--accent);
        background: rgba(37, 99, 235, 0.08);
    }

    .mobile-tool-btn.active-voice {
        color: var(--voice-light);
        background: rgba(175, 82, 222, 0.1);
    }

    /* Unread dot badge */
    .mobile-tool-btn .mob-badge {
        position: absolute;
        top: 8px;
        right: calc(50% - 16px);
        width: 7px;
        height: 7px;
        background: var(--accent);
        border-radius: 50%;
        border: 1px solid var(--bg-secondary);
        display: none;
    }
    .mobile-tool-btn.has-unread .mob-badge { display: block; }

    .mobile-tool-btn > span:not(.mob-badge) {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Player / editor navbar: avoid horizontal run-off (logout, title, etc.) */
    .player-navbar h2,
    #editor-course-title {
        font-size: 0.75rem;
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #player-user-name,
    #player-user-role,
    #editor-user-name,
    #editor-user-role {
        display: none !important;
    }
    .player-navbar .nav-user {
        gap: var(--space-xs);
        flex-shrink: 0;
    }
    .player-nav-right {
        flex-shrink: 1;
        min-width: 0;
        font-size: 0.62rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #player-logout-btn,
    #editor-logout-btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.72rem;
        white-space: nowrap;
    }
    #save-course-btn {
        flex-shrink: 0;
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.68rem;
    }

    /* Editor */
    .editor-layout { grid-template-columns: 1fr; }
    .editor-sidebar { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
}

/* Mobile Menu */
.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-xs);
    margin-left: auto;
}
.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   GENERAL MOBILE (dashboard, catalog, etc.)
   ======================================== */
@media (max-width: 768px) {
    /* Compact header: hide wide nav clusters (hamburger holds actions) */
    .catalog-navbar .nav-actions,
    .catalog-navbar .nav-center,
    .navbar .nav-center,
    .navbar .nav-user {
        display: none !important;
    }

    /* Tighter horizontal padding on small phones */
    .catalog-navbar {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }

    #dashboard-screen > .navbar {
        padding-left: var(--space-sm);
        padding-right: var(--space-sm);
    }

    .screen > .catalog-navbar ~ main {
        padding-top: calc(var(--mobile-top-bar-gap) + var(--space-sm));
    }

    #dashboard-screen > .dashboard-main {
        padding: calc(var(--mobile-top-bar-gap) + var(--space-sm)) var(--space-sm) var(--space-sm);
    }

    .mobile-cat-toggle {
        flex-shrink: 1;
        min-width: 0;
    }

    .mobile-cat-toggle > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .section-header-actions { flex-wrap: wrap; }
    .my-courses-search input { width: 180px; }
    .my-courses-search input:focus { width: 200px; }
    .catalog-header { margin-bottom: var(--space-md); }

    .catalog-mode-btn {
        min-height: 44px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .courses-grid { grid-template-columns: 1fr; }

    .player-navbar h2 {
        order: 0;
        width: auto;
        margin-top: 0;
    }
}



::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-tertiary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Toggle Switch */
.toggle-cell { text-align: center; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-tertiary); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-full); transition: var(--transition-fast); }
.toggle-slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; bottom: 2px; background: var(--text-secondary); border-radius: 50%; transition: var(--transition-fast); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); background: white; }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 0 3px var(--accent-glow); }

/* Catalog Screen (Public Homepage) */
.catalog-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.catalog-navbar > .nav-brand + .nav-actions {
    margin-left: var(--space-md);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-actions .user-greeting {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: var(--space-lg);
}

.nav-actions .user-greeting strong {
    color: var(--text-primary);
}
.mobile-nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 200;
    padding: var(--space-sm);
    margin-top: 4px;
}
.mobile-nav-menu.active {
    display: block;
    animation: fadeIn 0.15s ease;
}
.mobile-nav-menu .mobile-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    background: transparent;
    border: none;
    font-family: inherit;
    text-align: left;
}
.mobile-nav-menu .mobile-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.mobile-nav-menu .mobile-nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.mobile-nav-menu .mobile-nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: var(--space-xs) var(--space-md);
}
.mobile-nav-menu .mobile-user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.mobile-nav-menu .mobile-user-info span:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.catalog-header {
    text-align: center;
    margin-bottom: var(--space-lg);
    padding-top: var(--space-sm);
}

.catalog-search-row {
    max-width: 640px;
    margin: 0 auto var(--space-sm);
}

.catalog-search-modes {
    display: inline-flex;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: var(--space-md);
}

.catalog-mode-btn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.catalog-mode-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.catalog-mode-btn.active {
    background: var(--accent);
    color: #fff;
}

.catalog-search-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: var(--space-sm);
}

.catalog-search-wrap .catalog-search {
    flex: 1 1 220px;
    min-width: 0;
}

.catalog-ai-submit {
    flex: 0 0 auto;
    align-self: center;
    padding: 0 16px;
    min-height: 44px;
    font-size: 0.875rem;
    white-space: nowrap;
    border-radius: var(--radius-full);
}

/* Catalog Search Box */
.catalog-search {
    position: relative;
    max-width: none;
    margin: 0;
}

.catalog-search .search-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.catalog-search input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) calc(var(--space-md) + 28px);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-fast);
}

.catalog-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.catalog-search input::placeholder {
    color: var(--text-muted);
}

/* Browse Modal Search Box */
.browse-search {
    position: relative;
    padding: 0 var(--space-lg) var(--space-md);
}

.browse-search .search-icon {
    position: absolute;
    left: calc(var(--space-lg) + var(--space-sm));
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.browse-search input {
    width: 100%;
    padding: var(--space-sm) var(--space-md) var(--space-sm) calc(var(--space-md) + 24px);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.browse-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.browse-search input::placeholder {
    color: var(--text-muted);
}

/* My Courses Search Box */
.section-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.my-courses-search {
    position: relative;
}

.my-courses-search .search-icon {
    position: absolute;
    left: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.my-courses-search input {
    width: 220px;
    padding: var(--space-sm) var(--space-sm) var(--space-sm) calc(var(--space-sm) + 22px);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.my-courses-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    width: 280px;
}

.my-courses-search input::placeholder {
    color: var(--text-muted);
}


/* Catalog course cards with enroll button */
.catalog-card .btn-enroll-catalog {
    width: 100%;
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.catalog-card .btn-enroll-catalog:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.catalog-card .btn-unenroll-catalog {
    width: 100%;
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.catalog-card .btn-unenroll-catalog:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
    transform: translateY(-2px);
}

.catalog-card:hover {
    cursor: default;
}

.catalog-card .course-thumbnail {
    cursor: pointer;
}

.catalog-card .course-info h3 {
    cursor: pointer;
}

.catalog-card .course-info h3:hover {
    color: var(--accent);
}

/* Catalog Skeleton Loading */
.skeleton-card { animation: skeleton-fade-in 0.3s ease; }
.skeleton-shimmer { background: linear-gradient(110deg, var(--bg-tertiary) 30%, var(--bg-elevated) 50%, var(--bg-tertiary) 70%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: var(--radius-sm); }
.skeleton-line { height: 14px; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes skeleton-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-appear { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.course-card.catalog-card { animation: card-appear 0.35s ease both; }

/* Load More Button */
.catalog-load-more-wrap { display: flex; justify-content: center; padding: var(--space-2xl) 0; }
.btn-load-more { display: inline-flex; align-items: center; gap: var(--space-sm); padding: var(--space-md) var(--space-xl); background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: var(--transition-fast); }
.btn-load-more:hover { background: var(--bg-elevated); border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.btn-load-more:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-load-more svg { animation: none; }
.btn-load-more:disabled svg { animation: spin 1s linear infinite; }

.lazy-img { opacity: 0; transition: opacity 0.3s ease; }
.lazy-img[src]:not([data-src]) { opacity: 1; }

/* Login Modal */
.login-modal-content {
    max-width: 420px;
    padding: 0;
    background: transparent;
    border: none;
}

.login-modal-content .login-card {
    position: relative;
}

.login-modal-content .modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.login-modal-content .modal-close:hover {
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

/* Nav Center for Home button */
.nav-center {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-center .btn-ghost {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.nav-center .btn-ghost svg {
    width: 16px;
    height: 16px;
}


/* ========================
   DOWNLOAD PAGE
   ======================== */

.download-main {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: var(--space-xl) var(--space-md);
    min-height: calc(100vh - 64px);
}

.download-card {
    max-width: 520px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.download-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto var(--space-lg);
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.download-card h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.download-card > p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: var(--space-lg);
}

.download-meta {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.download-badge {
    background: var(--surface-light);
    color: var(--text-secondary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
}

.download-size {
    background: var(--success-bg);
    color: var(--success);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-xl);
}

.download-admin {
    border-top: 1px solid var(--surface-light);
    padding-top: var(--space-lg);
    margin-bottom: var(--space-lg);
    text-align: left;
}

.download-admin h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.download-admin form {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.download-admin input[type="file"] {
    flex: 1;
    min-width: 200px;
    padding: var(--space-xs);
    background: var(--surface-light);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.download-instructions {
    border-top: 1px solid var(--surface-light);
    padding-top: var(--space-lg);
    text-align: left;
}

.download-instructions h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.download-instructions ol {
    padding-left: var(--space-lg);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.download-instructions li {
    margin-bottom: var(--space-xs);
}

/* Mobile download page */
@media (max-width: 640px) {
    .download-main,
    .signup-main {
        padding: var(--space-md);
    }
    .download-card {
        padding: var(--space-lg);
    }
    .download-card h1 {
        font-size: 1.4rem;
    }
}

/* ========================
   ADMIN LOGS
   ======================== */

.logs-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    background: var(--surface-light);
    border-radius: var(--radius-md);
}

.logs-filters .input-small {
    padding: var(--space-xs) var(--space-sm);
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 140px;
}

.logs-table-container {
    overflow-x: auto;
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-md);
    max-height: 60vh;
    overflow-y: auto;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.logs-table th {
    position: sticky;
    top: 0;
    background: var(--surface-light);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--surface-light);
    white-space: nowrap;
}

.logs-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: top;
}

.logs-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.log-level-error { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.log-level-warn { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.log-level-info { background: rgba(187, 134, 252, 0.15); color: #BB86FC; }
.log-level-debug { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }

.log-time { white-space: nowrap; color: var(--text-muted); font-size: 0.8rem; }
.log-component { white-space: nowrap; color: var(--text-secondary); font-family: 'Space Mono', monospace; font-size: 0.8rem; }
.log-message { color: var(--text-primary); line-height: 1.4; }
.log-user { white-space: nowrap; color: var(--text-secondary); font-size: 0.8rem; }
.log-ip { white-space: nowrap; color: var(--text-muted); font-size: 0.8rem; font-family: 'Space Mono', monospace; }

.log-details {
    margin-top: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow-x: auto;
    max-width: 400px;
}

.logs-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
    padding: var(--space-sm);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}


/* ===== Blog & Pages Editor ===== */
.modal-xlarge {
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.editor-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.editor-meta-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

@media (max-width: 768px) {
    .editor-meta-row {
        grid-template-columns: 1fr;
    }
}

.textarea-small {
    min-height: 60px;
    resize: vertical;
}

.editor-toolbar-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-md);
    background: var(--bg-secondary);
}

.editor-quill {
    min-height: 300px;
    background: var(--bg-primary);
}

.editor-quill .ql-editor {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.7;
}

.editor-quill .ql-editor.ql-blank::before {
    color: var(--text-muted);
}

/* Quill toolbar dark theme */
.ql-toolbar {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color) !important;
    border: none !important;
}

.ql-toolbar .ql-stroke {
    stroke: var(--text-secondary);
}

.ql-toolbar .ql-fill {
    fill: var(--text-secondary);
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar .ql-picker-label:hover .ql-stroke {
    stroke: var(--accent);
}

.ql-toolbar button:hover .ql-fill,
.ql-toolbar .ql-picker-label:hover .ql-fill {
    fill: var(--accent);
}

.ql-toolbar .ql-picker-label {
    color: var(--text-secondary);
}

.ql-toolbar .ql-picker-options {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.ql-toolbar .ql-picker-item {
    color: var(--text-secondary);
}

.ql-toolbar .ql-picker-item:hover {
    color: var(--accent);
}

.ql-snow .ql-tooltip {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.ql-snow .ql-tooltip input[type=text] {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.ql-snow .ql-tooltip a.ql-preview {
    color: var(--accent);
}

/* Editor title at top */
.editor-title-group {
    margin-bottom: var(--space-md);
}
.editor-title-group .input-lg {
    font-size: 1.25rem;
    font-weight: 600;
    padding: var(--space-md) var(--space-lg);
}

/* Custom Quill toolbar buttons */
.ql-toolbar .ql-youtube {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 3px;
}
.ql-toolbar .ql-youtube svg {
    fill: var(--text-secondary);
    stroke: none;
}
.ql-toolbar .ql-youtube:hover svg {
    fill: var(--accent);
}

/* Featured image upload */
.featured-image-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}
.featured-image-upload:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.featured-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
}
.featured-image-placeholder svg {
    stroke: var(--text-muted);
}
.featured-image-preview {
    max-height: 120px;
    max-width: 100%;
    border-radius: var(--radius-sm);
    object-fit: cover;
}
.featured-image-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--error);
    color: white;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.featured-image-upload.has-image .featured-image-remove {
    display: flex;
}
.featured-image-upload.has-image .featured-image-placeholder {
    display: none;
}
.featured-image-upload.has-image {
    border-style: solid;
    border-color: var(--border-color);
    background: var(--bg-primary);
}

/* YouTube embed in rendered content */
.ql-editor .ql-video-wrapper,
.blog-post-article .ql-video-wrapper,
.page-content .ql-video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 1rem 0;
    border-radius: var(--radius-md);
}
.ql-editor .ql-video-wrapper iframe,
.blog-post-article .ql-video-wrapper iframe,
.page-content .ql-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Table container for admin lists */
.table-container {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.data-table .status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.published {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-badge.draft {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

.data-table .actions {
    display: flex;
    gap: var(--space-xs);
    white-space: nowrap;
}

.data-table .actions .btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-weight: 500;
}

.data-table .actions .btn-edit {
    background: rgba(187, 134, 252, 0.15);
    color: var(--accent);
}

.data-table .actions .btn-edit:hover {
    background: rgba(187, 134, 252, 0.25);
}

.data-table .actions .btn-delete {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.data-table .actions .btn-delete:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ===== Public Blog & Pages ===== */
.blog-list-main,
.blog-post-main,
.page-main {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

.blog-hero {
    text-align: center;
    margin-bottom: var(--space-xl);
    padding: var(--space-xl) 0;
}

.blog-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.blog-hero-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.blog-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.blog-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.blog-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.blog-card-body {
    padding: var(--space-md);
}

.blog-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}

.blog-card-excerpt {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: var(--space-sm);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.blog-post-article,
.page-article {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.blog-post-article .post-header,
.page-article .page-header {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.blog-post-article .post-title,
.page-article .page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
    line-height: 1.3;
}

.blog-post-article .post-meta,
.page-article .page-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.blog-post-article .post-featured-image,
.page-article .page-featured-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    background: var(--bg-tertiary);
}

.blog-post-article .post-content,
.page-article .page-content {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1.05rem;
}

.blog-post-article .post-content h1,
.blog-post-article .post-content h2,
.blog-post-article .post-content h3,
.page-article .page-content h1,
.page-article .page-content h2,
.page-article .page-content h3 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.blog-post-article .post-content p,
.page-article .page-content p {
    margin-bottom: var(--space-md);
}

.blog-post-article .post-content img,
.page-article .page-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
}

.blog-post-article .post-content blockquote,
.page-article .page-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: var(--space-md);
    margin: var(--space-md) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.blog-post-article .post-content pre,
.page-article .page-content pre {
    background: var(--bg-tertiary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-md) 0;
}

.blog-post-article .post-content code,
.page-article .page-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
}

.blog-post-article .post-content ul,
.blog-post-article .post-content ol,
.page-article .page-content ul,
.page-article .page-content ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-lg);
}

.blog-post-article .post-content li,
.page-article .page-content li {
    margin-bottom: var(--space-xs);
}

.blog-post-article .post-content a,
.page-article .page-content a {
    color: var(--accent);
    text-decoration: underline;
}

.blog-post-article .post-content a:hover,
.page-article .page-content a:hover {
    color: var(--accent-light);
}

.blog-post-article .post-content iframe,
.page-article .page-content iframe {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: var(--space-md) 0;
}

.page-article {
    max-width: 900px;
    margin: 0 auto;
}

/* Back button for blog/post pages */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
    transition: color 0.2s ease;
}

.back-btn:hover {
    color: var(--accent);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .blog-hero h1 {
        font-size: 1.8rem;
    }

    .blog-posts-grid {
        grid-template-columns: 1fr;
    }

    .blog-post-article,
    .page-article {
        padding: var(--space-lg);
    }

    .blog-post-article .post-title,
    .page-article .page-title {
        font-size: 1.5rem;
    }
}

/* Course Detail / Product Page */
.course-detail-main { padding: var(--space-xl); max-width: 1200px; margin: 0 auto; }

.course-detail-breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: var(--space-lg); display: flex; align-items: center; gap: var(--space-xs); flex-wrap: wrap; }
.course-detail-breadcrumb a { color: var(--accent); text-decoration: none; transition: var(--transition-fast); }
.course-detail-breadcrumb a:hover { color: var(--accent-light); }
.breadcrumb-sep { color: var(--text-muted); opacity: 0.5; }

.course-detail-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2xl); margin-bottom: var(--space-2xl); }

.course-detail-image-col { position: relative; }
.course-detail-image-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-tertiary); border: 1px solid rgba(255,255,255,0.08); }
.course-detail-image-wrap img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.course-detail-image-upload-overlay { position: absolute; bottom: 0; left: 0; right: 0; z-index: 8; padding: var(--space-md); background: linear-gradient(transparent, rgba(0,0,0,0.7)); }
.detail-upload-label { display: inline-flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); border-radius: var(--radius-md); color: white; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: var(--transition-fast); backdrop-filter: blur(4px); }
.detail-upload-label:hover { background: rgba(255,255,255,0.25); }

.course-detail-summary-col { display: flex; flex-direction: column; gap: var(--space-lg); }
.detail-title { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 0; }
.detail-sales-summary { font-size: 1rem; color: var(--text-secondary); line-height: 1.7; }
.detail-sales-summary:empty::after { content: 'No summary available. Ask admin to add a sales summary.'; color: var(--text-muted); font-style: italic; }

.detail-price-action { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }
.btn-buy-now { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: var(--space-md) var(--space-xl); background: linear-gradient(135deg, #059669, #10b981); color: white; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1.125rem; font-weight: 700; cursor: pointer; text-decoration: none; transition: var(--transition-fast); box-shadow: 0 4px 14px rgba(16,185,129,0.35); }
.btn-buy-now:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.45); color: white; }
.btn-buy-now svg { width: 20px; height: 20px; }

.btn-enroll-detail { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); padding: var(--space-md) var(--space-xl); background: var(--gradient-primary); color: white; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1.125rem; font-weight: 700; cursor: pointer; transition: var(--transition-fast); box-shadow: var(--shadow-glow); }
.btn-enroll-detail:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(187,134,252,0.45); }

.detail-meta-info { display: flex; gap: var(--space-lg); flex-wrap: wrap; padding-top: var(--space-md); border-top: 1px solid rgba(255,255,255,0.08); }
.detail-meta-item { display: flex; align-items: center; gap: var(--space-xs); color: var(--text-secondary); font-size: 0.9rem; }
.detail-meta-item svg { color: var(--accent); flex-shrink: 0; }

.detail-admin-section { margin-top: var(--space-lg); padding: var(--space-lg); background: var(--bg-tertiary); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-md); }
.detail-admin-section h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: var(--space-md); color: var(--accent); }

.course-detail-curriculum { margin-top: var(--space-2xl); }
.curriculum-heading { font-size: 1.5rem; font-weight: 700; margin-bottom: var(--space-lg); padding-bottom: var(--space-md); border-bottom: 2px solid var(--accent); display: inline-block; }

.curriculum-accordion { display: flex; flex-direction: column; gap: var(--space-sm); }
.curriculum-chapter { background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-md); overflow: hidden; }
.curriculum-chapter-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) var(--space-lg); cursor: pointer; transition: var(--transition-fast); user-select: none; }
.curriculum-chapter-header:hover { background: var(--bg-tertiary); }
.curriculum-chapter-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: var(--space-sm); }
.curriculum-chapter-title .chapter-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--accent-glow); color: var(--accent-light); border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.curriculum-chapter-count { font-size: 0.8rem; color: var(--text-muted); }
.curriculum-chapter-chevron { width: 20px; height: 20px; color: var(--text-muted); transition: transform var(--transition-fast); flex-shrink: 0; }
.curriculum-chapter.open .curriculum-chapter-chevron { transform: rotate(180deg); }

.curriculum-chapter-body { display: none; padding: 0 var(--space-lg) var(--space-md); }
.curriculum-chapter.open .curriculum-chapter-body { display: block; }
.curriculum-chapter-description { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: var(--space-md); padding: var(--space-sm) var(--space-md); background: var(--bg-tertiary); border-radius: var(--radius-sm); border-left: 3px solid var(--accent); }
.curriculum-lesson { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-sm); transition: var(--transition-fast); }
.curriculum-lesson:hover { background: rgba(255,255,255,0.03); }
.curriculum-lesson-icon { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.curriculum-lesson-title { font-size: 0.9rem; color: var(--text-primary); flex: 1; }
.curriculum-lesson-duration { font-size: 0.8rem; color: var(--text-muted); }

@media (max-width: 768px) {
    .course-detail-layout { grid-template-columns: 1fr; gap: var(--space-lg); }
    .detail-title { font-size: 1.5rem; }
    .course-detail-main { padding: var(--space-md); }
    .detail-price-action { flex-direction: column; align-items: stretch; }
    .btn-buy-now, .btn-enroll-detail { width: 100%; justify-content: center; }
    .detail-meta-info { flex-direction: column; gap: var(--space-sm); }
}

.generating-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Category Sidebar */
.catalog-main {
    display: flex;
    gap: 24px;
    padding: 0 24px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.catalog-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: sticky;
    top: 88px;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.category-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cat-parent {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    transition: background 0.15s;
}

.cat-parent:hover {
    background: var(--bg-hover);
}

.cat-parent.active {
    background: var(--primary-color);
    color: white;
}

.cat-parent .cat-count {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.6;
}

.cat-parent .cat-arrow {
    transition: transform 0.2s;
    font-size: 10px;
    opacity: 0.5;
}

.cat-parent.expanded .cat-arrow {
    transform: rotate(90deg);
}

.cat-children {
    display: none;
    padding-left: 12px;
    flex-direction: column;
    gap: 1px;
}

.cat-children.expanded {
    display: flex;
}

.cat-child {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}

.cat-child:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.cat-child.active {
    background: var(--primary-color);
    color: white;
}

.cat-child .cat-count {
    font-size: 11px;
    opacity: 0.6;
    margin-left: 4px;
}

.active-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.active-category-badge .clear-cat {
    cursor: pointer;
    opacity: 0.7;
    font-size: 16px;
    line-height: 1;
}

.active-category-badge .clear-cat:hover {
    opacity: 1;
}

.category-filter-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.catalog-content {
    flex: 1;
    min-width: 0;
}

.cat-all-btn {
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cat-all-btn:hover {
    background: var(--bg-hover);
}

.cat-all-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Mobile category menu inside hamburger */
.category-menu {
    max-height: 60vh;
    overflow-y: auto;
}

.category-menu .cat-parent {
    font-size: 14px;
    padding: 10px 12px;
}

.category-menu .cat-child {
    font-size: 13px;
    padding: 8px 12px;
}

/* Mobile category sidebar drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 98;
}
.sidebar-backdrop.open {
    display: block;
}

.mobile-cat-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}
.mobile-cat-toggle:hover {
    background: var(--bg-hover);
}
.mobile-cat-toggle svg {
    width: 18px;
    height: 18px;
}

/* Responsive - sidebar becomes left drawer on mobile */
@media (max-width: 768px) {
    .catalog-sidebar {
        display: block;
        position: fixed;
        top: var(--mobile-top-bar-gap);
        left: -280px;
        width: 280px;
        height: calc(100vh - var(--mobile-top-bar-gap));
        height: calc(100dvh - var(--mobile-top-bar-gap));
        z-index: 99;
        border-radius: 0 12px 12px 0;
        max-height: none;
        transition: left 0.25s ease;
        box-shadow: none;
    }
    .catalog-sidebar.open {
        left: 0;
        box-shadow: 4px 0 16px rgba(0,0,0,0.3);
    }
    .catalog-main {
        flex-direction: column;
    }
    .mobile-cat-toggle {
        display: flex;
    }
}

/* Biometric Login Banner */
.biometric-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, rgba(10,132,255,0.15), rgba(48,209,88,0.1));
    border: 1px solid rgba(10,132,255,0.25);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.biometric-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.biometric-banner-content svg {
    flex-shrink: 0;
    color: var(--accent);
}
.biometric-banner-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}
.biometric-banner-actions .btn-ghost.small,
.biometric-banner-actions .btn-primary.small {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
}

/* Settings Card */
.settings-card {
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}
.settings-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}
.settings-card-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* Icon-only button */
.btn-ghost.icon-only {
    padding: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .biometric-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Notifications Admin */
.notif-badge {
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-glow);
    color: var(--accent-light);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}
.notifications-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-xl);
    align-items: start;
}
.notif-composer {
    min-width: 0;
}
.notif-composer-header,
.notif-preview-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.notif-composer-header svg,
.notif-preview-header svg {
    color: var(--accent);
}
.notif-preview-panel {
    position: sticky;
    top: var(--space-lg);
}
.notif-phone-mockup {
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    border: 2px solid rgba(255,255,255,0.08);
}
.notif-phone-screen {
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.notif-phone-status {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
}
.notif-phone-body {
    padding: var(--space-lg) var(--space-md);
    min-height: 200px;
}
.notif-preview-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    animation: slideIn 0.4s ease;
}
.notif-preview-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.notif-preview-icon img {
    width: 24px;
    height: 24px;
}
.notif-preview-content {
    flex: 1;
    min-width: 0;
}
.notif-preview-content strong {
    display: block;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-preview-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-preview-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
#notif-status {
    margin-top: var(--space-md);
    font-size: 0.875rem;
    min-height: 1.5rem;
    transition: color 0.2s ease;
}
#notif-status.sending {
    color: var(--accent);
}
#notif-status.success {
    color: var(--success);
}
#notif-status.error {
    color: var(--error);
}

@media (max-width: 768px) {
    .notifications-layout {
        grid-template-columns: 1fr;
    }
    .notif-preview-panel {
        position: static;
    }
}

/* ============================================================
   LIVE SESSION — overlay layout
   ============================================================ */
/* Only show live session layout when the screen is active */
.live-session-layout.active,
#live-session-container.active {
    display: flex;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg-secondary);
}
/* Safety net: ensure flex overrides .screen.active { display: block } */
#live-session-container.screen.active {
    display: flex !important;
}
.live-session-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.live-session-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.live-session-header h3 {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-status-badge {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.session-status-badge.live {
    background: #dc2626;
    color: #fff;
}
.session-status-badge.scheduled {
    background: #2563eb;
    color: #fff;
}
.session-status-badge.ended {
    background: var(--text-muted);
    color: #fff;
}
.session-participant-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* broadcast area */
.live-session-broadcast {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    position: relative;
    overflow: hidden;
    min-height: 0;
}
.broadcast-fs-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.broadcast-fs-btn:hover {
    background: rgba(0,0,0,0.85);
}
.fs-chat-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 20;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.fs-chat-toggle:hover {
    background: rgba(0,0,0,0.85);
}
.live-session-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
}
.live-session-placeholder p {
    font-size: 0.95rem;
}
.live-session-broadcast video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* controls bar */
.live-session-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ============================================================
   Q&A SIDEBAR
   ============================================================ */
.live-session-qa {
    width: 360px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: transform 0.25s ease;
}
/* Fullscreen mode: sidebar becomes fixed sliding panel */
.live-session-layout.fullscreen .live-session-qa {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}
.live-session-layout.fullscreen .live-session-qa.qa-open {
    transform: translateX(0);
}
.live-session-layout.fullscreen .broadcast-fs-btn,
.live-session-layout.fullscreen .fs-chat-toggle {
    display: flex !important;
}
.live-session-layout.fullscreen .fs-chat-toggle {
    bottom: 80px;
}
.qa-header {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.qa-header h4 {
    margin: 0;
    font-size: 0.95rem;
}
#qa-question-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.qa-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}
.qa-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px 0;
}

.qa-item {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}
.qa-item .question {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
    line-height: 1.4;
}
.qa-item .qa-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}
.qa-item .ai-answer {
    font-size: 0.84rem;
    padding: 6px 8px;
    background: rgba(59,130,246,0.12);
    border-left: 3px solid #3b82f6;
    border-radius: 0 4px 4px 0;
    margin-bottom: 4px;
    line-height: 1.4;
}
.qa-item .ai-answer .ai-label {
    font-size: 0.7rem;
    color: #60a5fa;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
.qa-item .teacher-answer {
    font-size: 0.84rem;
    padding: 6px 8px;
    background: rgba(34,197,94,0.12);
    border-left: 3px solid #22c55e;
    border-radius: 0 4px 4px 0;
    margin-top: 4px;
    line-height: 1.4;
}
.qa-item .teacher-answer .teacher-label {
    font-size: 0.7rem;
    color: #4ade80;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
.qa-item .qa-pending {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 0;
}

.audio-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.audio-volume-control svg {
    flex-shrink: 0;
    opacity: 0.7;
    color: var(--text-primary);
}
.audio-volume-control input[type="range"] {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.qa-input {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.qa-input textarea {
    flex: 1 1 auto;
    min-width: 0;
    resize: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.4;
}
.qa-input textarea::placeholder {
    color: var(--text-muted);
}
.qa-input .btn-primary {
    width: auto;
    padding: 8px 14px;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ============================================================
   SESSION CARDS (in dashboard)
   ============================================================ */
/* ════════ CHAT & CALLS — Web UI ════════ */
.chat-ui-container {
    display: flex;
    height: calc(100vh - 130px);
    height: calc(100dvh - 130px);
    min-height: 300px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.chat-ui-sidebar {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
}
.chat-ui-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chat-ui-sidebar-header h3 {
    margin: 0;
    font-size: 0.95rem;
}
.chat-ui-room-list {
    flex: 1;
    overflow-y: auto;
}
.chat-ui-room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.chat-ui-room-item:hover { background: rgba(255,255,255,0.04); }
.chat-ui-room-item.active { background: rgba(99,102,241,0.15); }
.chat-ui-room-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.chat-ui-room-info { flex: 1; min-width: 0; }
.chat-ui-room-name {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-ui-room-lastmsg {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-ui-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.chat-ui-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    min-height: 0;
}
.chat-ui-messages {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.chat-ui-msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.chat-ui-msg-header h4 {
    margin: 0;
    font-size: 0.9rem;
}
.chat-ui-msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chat-ui-msg { max-width: 80%; }
.chat-ui-msg.mine { align-self: flex-end; }
.chat-ui-msg.other { align-self: flex-start; }
.chat-ui-msg-sender {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    padding-left: 2px;
}
.chat-ui-msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    word-break: break-word;
}
.chat-ui-msg.mine .chat-ui-msg-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-ui-msg.other .chat-ui-msg-bubble {
    background: var(--bg-tertiary);
    border-bottom-left-radius: 4px;
}
.chat-ui-msg-time {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 2px;
    padding: 0 2px;
}
.chat-ui-msg-input {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.chat-ui-msg-input input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    min-width: 0;
}
.chat-ui-msg-input input:focus { outline: none; border-color: var(--accent); }
.chat-ui-msg-input button { flex-shrink: 0; border-radius: 20px; }

/* Media in messages */
.chat-ui-msg-image { padding: 4px; background: transparent !important; }
.chat-ui-msg-image img { max-width: 240px; max-height: 240px; border-radius: 8px; cursor: pointer; }
.chat-ui-msg-image .chat-ui-img-fallback { padding: 12px; color: var(--text-muted); font-size: 0.78rem; }
.chat-ui-download-link { color: var(--accent); text-decoration: none; font-size: 0.82rem; }
.chat-ui-download-link:hover { text-decoration: underline; }
.chat-ui-video-fallback { padding: 12px 0; }

/* ─── Call overlay (unused - calls handled by native Android app) ─── */
/* kept for potential future web calling feature */

/* Mobile chat UI */
@media (max-width: 768px) {
    .chat-ui-sidebar { width: 100%; }
    .chat-ui-container { flex-direction: column; }
    .chat-ui-main { display: none; }
    .chat-ui-container.show-chat .chat-ui-sidebar { display: none; }
    .chat-ui-container.show-chat .chat-ui-main { display: flex; }
}

.live-sessions-list {
    padding: 16px;
}
.session-card {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}
.session-card:hover {
    background: var(--hover-bg);
}
.session-card .session-info {
    flex: 1;
    min-width: 0;
}
.session-card .session-info h4 {
    margin: 0 0 2px;
    font-size: 0.9rem;
}
.session-card .session-info .session-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.session-card .session-actions button {
    white-space: nowrap;
}

.session-status-tag {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
}
.session-status-tag.live {
    background: rgba(220,38,38,0.15);
    color: #f87171;
}
.session-status-tag.scheduled {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
}
.session-status-tag.ended {
    background: rgba(107,114,128,0.15);
    color: #9ca3af;
}

/* ============================================================
   CREATE SESSION FORM
   ============================================================ */
.create-session-form {
    max-width: 520px;
    margin: 24px auto;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.create-session-form h3 {
    margin: 0 0 16px;
    font-size: 1.05rem;
}
.create-session-form label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}
.create-session-form input,
.create-session-form textarea,
.create-session-form select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.create-session-form select {
    appearance: auto;
    -webkit-appearance: menulist;
}
.create-session-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .live-session-layout.active,
    #live-session-container.active {
        flex-direction: column;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
    }
    .live-session-main {
        flex: 1 1 55%;
        min-height: 0;
        overflow: hidden;
    }
    .live-session-broadcast {
        min-height: 0;
    }
    .live-session-qa {
        width: 100%;
        flex: 1 1 45%;
        min-height: 0;
        max-height: 45%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        overflow: hidden;
    }
    .qa-list {
        min-height: 0;
    }
    .live-session-controls {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px;
    }
    .live-session-header {
        padding: 6px 10px;
        gap: 6px;
    }
    .live-session-header h3 {
        font-size: 0.88rem;
    }
    .create-session-form {
        margin: 12px;
        padding: 14px;
    }
}

/* ============================================================
   EXAM & CERTIFICATION
   ============================================================ */

/* Editor tabs */
.editor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
    flex-shrink: 0;
}
.editor-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.editor-tab:hover { color: var(--text-primary); }
.editor-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.editor-tab-panel { display: none; }
.editor-tab-panel.active { display: block; }

/* Exam builder */
.exam-builder { padding: 0; }
.exam-settings-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.exam-settings-form h3 {
    margin: 0 0 16px;
    font-size: 1.05rem;
}
.exam-settings-row {
    display: flex;
    gap: 16px;
}
.exam-settings-row .input-group { flex: 1; }
.exam-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-danger:hover { background: #b91c1c; }

.exam-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.exam-empty-state p { margin-bottom: 16px; }

.exam-questions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.exam-questions-header h3 { margin: 0; }

.exam-questions-list { display: flex; flex-direction: column; gap: 8px; }
.exam-question-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.exam-question-card .eq-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.exam-question-card .eq-text {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}
.exam-question-card .eq-options {
    margin-top: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    font-size: 0.82rem;
}
.exam-question-card .eq-option { color: var(--text-secondary); }
.exam-question-card .eq-option.correct { color: #22c55e; font-weight: 600; }
.exam-question-card .eq-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.eq-actions button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.eq-actions button:hover { border-color: var(--accent); color: var(--accent); }
.eq-actions button.eq-delete:hover { border-color: #dc2626; color: #dc2626; }

/* Student exam panel (inside player) */
.exam-panel {
    display: none;
    flex-direction: column;
}
.exam-panel.active { display: flex; }
.exam-student-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.exam-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}
.exam-info-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}
.exam-info-card h4 { margin: 0 0 8px; font-size: 1rem; }
.exam-info-card p { margin: 4px 0; font-size: 0.85rem; color: var(--text-secondary); }

.exam-timer {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 10px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--accent);
}
.exam-timer.urgent { color: #dc2626; }

.exam-question-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
}
.exam-question-item .eqi-number {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.exam-question-item .eqi-text {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 10px;
}
.exam-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.84rem;
}
.exam-option:hover { background: rgba(255,255,255,0.05); }
.exam-option input[type="radio"] { accent-color: var(--accent); }
.exam-option.selected { background: rgba(99,102,241,0.15); }

#submit-exam-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    font-size: 0.95rem;
}

.exam-result-card {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}
.exam-result-card.passed {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.3);
}
.exam-result-card.failed {
    background: rgba(220,38,38,0.1);
    border: 1px solid rgba(220,38,38,0.3);
}
.exam-result-card h3 { margin: 0 0 8px; }
.exam-result-card .score { font-size: 2rem; font-weight: 700; }
.exam-result-card.passed .score { color: #22c55e; }
.exam-result-card.failed .score { color: #dc2626; }

.attempt-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
}
.attempt-history-item:last-child { border-bottom: none; }
.attempt-pass { color: #22c55e; font-weight: 600; }
.attempt-fail { color: #dc2626; font-weight: 600; }

/* Certificate info in exam panel */
.cert-info-card {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.3);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    text-align: center;
}
.cert-info-card h4 { color: #22c55e; margin: 0 0 8px; }
.cert-info-card p { font-size: 0.82rem; color: var(--text-secondary); margin: 4px 0; }

/* Certificates grid (student dashboard) */
.certificates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 0 16px 16px;
}
.cert-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.cert-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.cert-card h4 {
    margin: 0 0 8px;
    font-size: 1rem;
}
.cert-card .cert-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.cert-card .cert-number {
    font-size: 0.75rem;
    color: var(--accent);
    font-family: monospace;
    margin-bottom: 12px;
}
.cert-card .cert-actions {
    display: flex;
    gap: 8px;
}
.cert-card .cert-actions button {
    flex: 1;
    padding: 8px;
    font-size: 0.82rem;
}

/* Verify screen */
.verify-main {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    padding: 20px;
}
.verify-container {
    max-width: 500px;
    width: 100%;
    text-align: center;
}
.verify-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px;
}
.verify-card .verify-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.verify-badge.valid {
    background: rgba(34,197,94,0.15);
    color: #22c55e;
}
.verify-card h2 { margin: 0 0 16px; }
.verify-card .verify-detail {
    font-size: 0.9rem;
    margin: 6px 0;
    color: var(--text-secondary);
}
.verify-card .verify-detail strong { color: var(--text-primary); }

/* Exam panel visibility control */
@media (max-width: 768px) {
    .exam-panel { display: none !important; }
    .exam-panel.mobile-active { display: flex !important; }
    .exam-settings-row { flex-direction: column; gap: 8px; }
}

/* ============================================================
   EXAM TAKING SCREEN (standalone, from dashboard)
   ============================================================ */

.exam-take-main {
    display: flex;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 24px 16px;
    background: var(--bg-primary);
}
.exam-take-container {
    max-width: 720px;
    width: 100%;
}
.exam-take-hero {
    text-align: center;
    margin-bottom: 28px;
}
.exam-take-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}
.exam-take-hero h2 {
    margin: 0 0 6px;
    font-size: 1.4rem;
}
.exam-take-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.exam-take-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.exam-take-info-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}
.exam-take-info-item .info-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.exam-take-info-item .info-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.exam-take-start {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
    margin-top: 16px;
}
.exam-take-history {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.exam-take-history h4 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.exam-take-submit-area {
    text-align: center;
    padding: 20px 0;
}
.exam-take-submit {
    padding: 14px 48px;
    font-size: 1.05rem;
}
.exam-timer-nav {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--accent);
    padding: 6px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}
.exam-result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* Student exams list */
.student-exams-section h2 {
    padding: 16px;
    margin: 0;
}
.student-exams-list {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.student-exam-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: border-color 0.15s;
}
.student-exam-card:hover {
    border-color: var(--accent);
}
.student-exam-info h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}
.student-exam-course {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 6px;
}
.student-exam-meta {
    display: flex;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.student-exam-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.student-exam-btns {
    display: flex;
    gap: 8px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}
.exam-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.exam-status-badge.passed {
    background: rgba(34,197,94,0.15);
    color: #22c55e;
}
.exam-status-badge.attempted {
    background: rgba(234,179,8,0.15);
    color: #eab308;
}
.exam-status-badge.new {
    background: rgba(99,102,241,0.1);
    color: var(--accent);
}

@media (max-width: 768px) {
    .student-exam-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .student-exam-actions {
        align-items: flex-start;
        width: 100%;
    }
    .exam-take-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Dynamic student tab containers — fill admin-main flex child */
.student-exams-section,
.student-certificates-section {
    width: 100%;
    box-sizing: border-box;
}
.student-certificates-section h2,
.student-exams-section h2 {
    margin: 0;
    padding: 20px 16px 12px;
    font-size: 1.2rem;
}

/* Course editor — AI thumbnail: explicit workflow (not vague placeholders). */
.thumbnail-generator-intro {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 var(--space-md) 0;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent);
}
.thumbnail-generator-intro strong {
    color: var(--text-primary);
    font-weight: 600;
}
.thumbnail-generator-intro ol {
    margin: var(--space-sm) 0 0 var(--space-lg);
    padding: 0;
}
.thumbnail-generator-intro li + li {
    margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   GAMIFICATION & ENGAGEMENT FEATURES
   ══════════════════════════════════════════════════════════════════ */

/* ── Stats Bar (Dashboard) ─────────────────────────────────────── */
.gamification-stats-bar {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    overflow-x: auto;
    padding-bottom: var(--space-xs);
    -webkit-overflow-scrolling: touch;
}
.gamification-stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: var(--transition-fast);
}
.gamification-stat-card:hover {
    border-color: rgba(187, 134, 252, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.gamification-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.gamification-stat-icon.xp {
    background: rgba(187, 134, 252, 0.15);
    color: var(--accent);
}
.gamification-stat-icon.streak {
    background: rgba(255, 159, 10, 0.15);
    color: var(--warning);
}
.gamification-stat-icon.badges {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}
.gamification-stat-icon.engagement {
    background: rgba(90, 200, 250, 0.15);
    color: var(--info);
}
.gamification-stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gamification-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.gamification-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── XP Bar ────────────────────────────────────────────────────── */
.xp-bar-container {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
}
.xp-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow) ease-out;
}
.xp-bar-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Level Badge ───────────────────────────────────────────────── */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, rgba(187, 134, 252, 0.2), rgba(187, 134, 252, 0.08));
    border: 1px solid rgba(187, 134, 252, 0.3);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
}
.level-badge .level-icon {
    font-size: 0.8rem;
}

/* ── Streak Display ────────────────────────────────────────────── */
.streak-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.streak-flame {
    font-size: 1.1rem;
}

/* ── Leaderboard ───────────────────────────────────────────────── */
.leaderboard-section {
    padding: var(--space-md) 0;
}
.leaderboard-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}
.leaderboard-item:hover {
    border-color: rgba(187, 134, 252, 0.2);
    background: var(--bg-tertiary);
}
.leaderboard-item.current-user {
    border-color: rgba(187, 134, 252, 0.4);
    background: rgba(187, 134, 252, 0.05);
}
.leaderboard-rank {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}
.leaderboard-rank.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #1a1a1a;
}
.leaderboard-rank.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a1a;
}
.leaderboard-rank.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b06820);
    color: #1a1a1a;
}
.leaderboard-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}
.leaderboard-score {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-light);
}

/* ── Badges Grid ───────────────────────────────────────────────── */
.badges-section {
    padding: var(--space-md) 0;
}
.badges-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}
.badge-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.badge-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.badge-card.earned {
    border-color: rgba(52, 199, 89, 0.3);
}
.badge-card.locked {
    opacity: 0.5;
    filter: grayscale(0.6);
}
.badge-card-emoji {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
    display: block;
}
.badge-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}
.badge-card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.badge-card-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}
.badge-earned-check {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
}

/* ── Skills Self-Assessment ────────────────────────────────────── */
.skills-section {
    padding: var(--space-md) 0;
}
.skills-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}
.skills-category {
    margin-bottom: var(--space-xl);
}
.skills-category-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-color);
}
.skill-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}
.skill-item:hover {
    background: var(--bg-secondary);
}
.skill-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}
.skill-stars {
    display: flex;
    gap: 4px;
}
.skill-star {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    background: transparent;
    border: none;
    color: var(--text-muted);
}
.skill-star:hover {
    transform: scale(1.15);
}
.skill-star.filled {
    color: var(--accent);
}
.skill-star.filled:hover {
    color: var(--accent-light);
}

/* ── Recommendations ───────────────────────────────────────────── */
.recommendations-section {
    padding: var(--space-md) 0;
}
.recommendations-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}
.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-md);
}
.recommendation-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    display: block;
}
.recommendation-card:hover {
    border-color: rgba(187, 134, 252, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.recommendation-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}
.recommendation-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}
.recommendation-reason {
    font-size: 0.72rem;
    color: var(--accent-light);
    font-style: italic;
}

/* ── Learner Record ────────────────────────────────────────────── */
.learner-record-section {
    padding: var(--space-md) 0;
}
.learner-record-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}
.learner-record-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.learner-record-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--space-md);
    border-left: 4px solid var(--accent);
    transition: var(--transition-fast);
}
.learner-record-item:hover {
    border-color: var(--border-color);
    border-left-color: var(--accent);
}
.learner-record-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.learner-record-icon.certificate {
    background: rgba(255, 215, 0, 0.15);
}
.learner-record-icon.course_completion {
    background: rgba(52, 199, 89, 0.15);
}
.learner-record-icon.exam_score {
    background: rgba(90, 200, 250, 0.15);
}
.learner-record-icon.badge {
    background: rgba(187, 134, 252, 0.15);
}
.learner-record-body {
    flex: 1;
    min-width: 0;
}
.learner-record-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.learner-record-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.learner-record-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: right;
}

/* ── Engagement Score Ring ─────────────────────────────────────── */
.engagement-ring-container {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}
.engagement-ring {
    width: 80px;
    height: 80px;
    position: relative;
}
.engagement-ring svg {
    transform: rotate(-90deg);
}
.engagement-ring-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 6;
}
.engagement-ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--transition-slow) ease-out;
}
.engagement-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.engagement-breakdown {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.engagement-breakdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.8rem;
}
.engagement-breakdown-label {
    flex: 1;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.engagement-breakdown-count {
    color: var(--text-primary);
    font-weight: 600;
}

/* ── Chatroom Summary Panel ────────────────────────────────────── */
.chatroom-summary-panel {
    background: var(--bg-secondary);
    border: 1px solid rgba(187, 134, 252, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}
.chatroom-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}
.chatroom-summary-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}
.chatroom-summary-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.chatroom-summary-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ── AI Quiz Generator ─────────────────────────────────────────── */
.ai-quiz-section {
    padding: var(--space-md) 0;
}
.ai-quiz-section h2 {
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
}
.ai-quiz-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}
.ai-quiz-preview {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.ai-quiz-question-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}
.ai-quiz-question-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}
.ai-quiz-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.ai-quiz-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.ai-quiz-option-letter {
    font-weight: 700;
    color: var(--accent);
    min-width: 20px;
}
.ai-quiz-explanation {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: rgba(52, 199, 89, 0.08);
    border-left: 3px solid var(--success);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ── Empty States ──────────────────────────────────────────────── */
.gamification-empty {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}
.gamification-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}
.gamification-empty-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ── XP History ────────────────────────────────────────────────── */
.xp-history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}
.xp-history-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}
.xp-history-amount {
    font-weight: 700;
    color: var(--accent-light);
    min-width: 50px;
}
.xp-history-reason {
    flex: 1;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.xp-history-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Search Match Snippets ─────────────────────────────────────── */
.search-matches {
    margin-top: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.search-match {
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s ease;
}
.search-match:hover {
    background: rgba(255,255,255,0.08);
}
.search-match-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 2px;
}
.search-match-text {
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .gamification-stats-bar {
        flex-wrap: nowrap;
    }
    .gamification-stat-card {
        min-width: 120px;
        padding: var(--space-sm) var(--space-md);
    }
    .badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    .recommendations-grid {
        grid-template-columns: 1fr;
    }
    .engagement-ring-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Removed Ideas MVPs ─────────────────────────────────────────── */
.leaderboard-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-lg);
}
.leaderboard-period-filters {
    display: flex;
    gap: var(--space-sm);
}
.leaderboard-period-btn.active {
    background: var(--accent);
    color: #fff;
}
.exam-questions-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.editor-tools-bar {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-lg);
}
.editor-microlearning-preview,
.microlearning-player-panel,
.video-checkpoints-panel {
    margin-top: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}
.microlearning-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.microlearning-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}
.microlearning-card-head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.microlearning-read-time {
    color: var(--text-muted);
    font-size: 0.8125rem;
}
.microlearning-summary {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}
.video-checkpoints-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.video-checkpoint-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}
.video-checkpoint-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.checkpoint-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.compliance-list,
.compliance-admin-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.compliance-item,
.compliance-admin-item {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}
.compliance-item.overdue {
    border-color: rgba(239, 68, 68, 0.35);
}
.compliance-item.completed {
    border-color: rgba(34, 197, 94, 0.35);
}
.compliance-status-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.compliance-admin-form {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    max-width: 560px;
}
.compliance-admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.badge-card-visual {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-sm);
}
.learning-path-step.done {
    opacity: 0.65;
}
.learning-path-step.current .learning-path-step-title {
    color: var(--accent);
    font-weight: 600;
}
.learning-path-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}
.learning-path-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.learning-path-steps {
    list-style: none;
    padding: 0;
    margin: var(--space-md) 0 0;
}
.learning-path-step {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.marketplace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
}
.marketplace-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.marketplace-card-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}
.marketplace-match {
    color: var(--accent);
    font-weight: 600;
}
.marketplace-skills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}
.marketplace-skill-tag {
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}
.marketplace-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: var(--space-sm);
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.marketplace-admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

/* Generate Video — animated progress while job runs */
#gv-progress-bar {
    transition: none;
}

#gv-progress-track.gv-progress-active #gv-progress-bar {
    background: linear-gradient(
        90deg,
        var(--primary) 0%,
        #ff6b35 45%,
        #ffb347 50%,
        #ff6b35 55%,
        var(--primary) 100%
    );
    background-size: 200% 100%;
    animation: gv-progress-shimmer 1.2s linear infinite;
}

#gv-progress-track.gv-progress-active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 5px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

@keyframes gv-progress-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
