:root {
    --bg: #09090b;
    --bg-elevated: #111114;
    --surface: #18181b;
    --surface-2: #1f1f23;
    --surface-3: #27272a;
    --border: #2e2e33;
    --border-light: #3f3f46;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --sidebar-width: 280px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Admin page ─────────────────────────────────────────── */

.admin-page {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--primary-glow), transparent),
        var(--bg);
}

.app-shell {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.brand-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: var(--radius-sm);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.125rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.user-pill {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
}

.hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.hero-content h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.hero-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.join-form {
    display: flex;
    gap: 0.625rem;
    flex: 1;
    min-width: 280px;
    max-width: 480px;
}

.join-form input {
    flex: 1;
    margin-top: 0;
}

.content-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
}

.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.panel-toolbar .header-actions-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.toolbar-toggle input {
    accent-color: var(--accent);
}

.panel-toolbar h2 {
    font-size: 1.0625rem;
    font-weight: 600;
}

.panel-desc {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.class-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: border-color 0.2s, transform 0.15s;
}

.class-card:hover {
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.class-card--inactive {
    opacity: 0.72;
    border-style: dashed;
}

.class-card--inactive:hover {
    opacity: 0.9;
}

.class-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.class-card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
}

.class-card .teacher {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.class-card .meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.class-card .actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.inactive-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
    flex-shrink: 0;
}

@keyframes join-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45); }
    50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}

.btn-join-student.join-live-pulse {
    animation: join-pulse 1.5s ease-in-out 3;
}

.class-card .actions .btn-danger-outline {
    margin-left: auto;
}

.loading-state, .empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Buttons & inputs ───────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-3); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-outline { background: transparent; border: 1px solid var(--danger); color: #f87171; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-tool { background: var(--surface-3); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 0.35rem; }
.btn-tool:hover { background: var(--border); }
.btn-tool.is-active {
    background: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #4ade80;
}
.btn-tool-label { font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 0.9375rem; width: 100%; }
.btn-icon { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.btn-icon:hover { color: var(--text); }
.btn-icon-only { padding: 0.4rem 0.6rem; }

input, textarea, select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    margin-top: 0.375rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.label-hint { font-weight: 400; color: var(--text-muted); }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.span-2 { grid-column: span 2; }

/* ── Modal ──────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal.modal-lg { max-width: 560px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.125rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }
.modal-actions.center { justify-content: center; }

.join-confirm-body { text-align: center; }
.confirm-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: 50%;
}
.confirm-lead { font-size: 0.9375rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.confirm-class-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.25rem; }

.enrolled-list {
    list-style: none;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
}

.enrolled-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.enrolled-item:last-child { border-bottom: none; }
.enrolled-empty { padding: 1.25rem; text-align: center; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

.members-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.members-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.members-section-header h4 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.members-hint {
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

.member-count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-secondary);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

.enrolled-item .member-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.enrolled-item .member-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.enrolled-item .member-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.enrolled-item .member-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.lobby-actions {
    display: flex;
    gap: 0.625rem;
    margin-top: 1.25rem;
}

.lobby-actions .btn-lg { width: auto; flex: 1; }
.lobby-password { margin-top: 1rem; text-align: left; }

.search-results {
    list-style: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 160px;
    overflow-y: auto;
    margin-top: 0.25rem;
}

.search-results li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
}

.search-results li:hover { background: var(--surface-2); }

/* ── Room page ──────────────────────────────────────────── */

.room-page { overflow: hidden; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.room-app { height: 100vh; display: flex; flex-direction: column; }

/* HTML [hidden] loses to display:flex on .lobby — must hide explicitly */
.room-app > [hidden],
.lobby[hidden],
.meeting-room[hidden] {
    display: none !important;
}

.lobby {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
}

.lobby-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, var(--primary-glow), transparent),
        var(--bg);
}

.lobby.is-authenticated {
    background: var(--bg);
}

.lobby-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow);
}

.lobby-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}

.lobby-card h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
.room-code-display { margin: 0.75rem 0; font-size: 1rem; color: var(--text-secondary); }
.room-code-display strong { color: var(--text); font-weight: 600; letter-spacing: 0.05em; }
.muted { color: var(--text-muted); font-size: 0.875rem; }
.lobby-form { text-align: left; margin-top: 1.25rem; }
.back-link { display: inline-block; margin-top: 1.25rem; color: var(--text-muted); font-size: 0.8125rem; text-decoration: none; }
.back-link:hover { color: var(--primary); }
.error-msg { color: var(--danger); margin-top: 0.75rem; font-size: 0.8125rem; text-align: center; }

.meeting-room {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg);
}

.room-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
    z-index: 10;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.live-indicator {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
    flex-shrink: 0;
}

.room-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.room-code-small {
    font-size: 0.6875rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.room-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.status-pill {
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
}

.status-pill.online { background: var(--success-bg); color: var(--success); }
.status-pill.offline { background: rgba(239, 68, 68, 0.12); color: #f87171; }

.room-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.video-stage {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
}

.insecure-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 12;
    background: rgba(234, 179, 8, 0.92);
    color: #1c1917;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
    text-align: center;
}

.share-status-bar {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.share-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
}

.share-pill.is-live {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.35);
}

.share-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
}

.share-pill.is-live .share-dot {
    background: #22c55e;
    animation: pulse-dot 1.5s infinite;
}

.main-video-wrap {
    width: 100%;
    height: 100%;
    position: relative;
}

.main-video-wrap video,
.pip-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.pip-video-wrap {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 240px;
    height: 135px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #111;
    z-index: 2;
    box-shadow: var(--shadow);
}

.video-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.5rem 0.625rem 0.35rem;
    color: rgba(255,255,255,0.85);
}

.waiting-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1;
}

.waiting-overlay[hidden] { display: none; }

.waiting-content {
    text-align: center;
    color: var(--text-muted);
}

.waiting-content p { margin-top: 1rem; font-size: 0.875rem; }

/* Instructor wait screen */
.instructor-wait-screen {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0c0c10 0%, #14141a 50%, #0f0f14 100%);
}

.instructor-wait-screen[hidden] { display: none; }

.wait-card {
    text-align: center;
    max-width: 420px;
    padding: 2.5rem 2rem;
}

.wait-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.wait-org {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.wait-title {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.wait-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.wait-class {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.wait-teacher {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.wait-spinner { display: flex; justify-content: center; }

/* ── Participants sidebar ───────────────────────────────── */

.participants-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.sidebar-count {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    min-width: 1.5rem;
    text-align: center;
}

.sidebar-section {
    padding: 0.625rem 0;
    flex-shrink: 0;
    max-height: 28%;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.25rem 1rem 0.375rem;
}

.participant-list {
    list-style: none;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    transition: background 0.12s;
}

.participant-item:hover { background: var(--surface-2); }
.participant-item.is-self { background: rgba(99, 102, 241, 0.08); }

.participant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.participant-avatar.host {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
}

.participant-avatar.viewer {
    background: var(--surface-3);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.participant-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--surface-3);
}

.sidebar-chat {
    margin-top: auto;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    padding-bottom: 0.5rem;
}

.chat-messages {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    min-height: 120px;
    max-height: 220px;
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    align-items: flex-start;
}

.chat-message.is-self { flex-direction: row-reverse; }
.chat-message.is-self .chat-bubble { background: rgba(99, 102, 241, 0.2); }

.chat-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-bubble {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.55rem;
    max-width: 85%;
    font-size: 0.75rem;
}

.chat-author {
    display: block;
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-bottom: 0.1rem;
}

.chat-text { word-break: break-word; }

.chat-form {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem 0;
    border-top: 1px solid var(--border);
}

.chat-form input {
    margin-top: 0;
    flex: 1;
    font-size: 0.8125rem;
    padding: 0.45rem 0.6rem;
}

.chat-form .btn { flex-shrink: 0; }

.participant-info {
    flex: 1;
    min-width: 0;
}

.participant-name {
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.participant-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--primary-glow);
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.sidebar-empty[hidden] { display: none; }

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

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .hero-panel { flex-direction: column; align-items: stretch; }
    .join-form { max-width: none; flex-direction: column; }

    .participants-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -8px 0 32px rgba(0,0,0,0.5);
    }

    .participants-sidebar.is-open { transform: translateX(0); }

    .mobile-sidebar-toggle { display: inline-flex; }

    .pip-video-wrap {
        width: 140px;
        height: 79px;
        bottom: 0.5rem;
        right: 0.5rem;
    }

    .room-actions .btn-tool span,
    .room-actions .btn-tool { font-size: 0.75rem; padding: 0.4rem 0.6rem; }
}

@media (max-width: 480px) {
    .room-actions .btn-tool svg + * { display: none; }
}
.participant-media-permissions{display:flex;gap:4px;flex-wrap:wrap;margin-left:auto}.btn-media-permission{font-size:10px!important;padding:3px 6px!important;min-height:26px!important}.btn-media-permission.is-active{background:#d1fae5!important;color:#047857!important;border-color:#6ee7b7!important}
.class-files-list{display:grid;gap:12px;margin-top:16px}.class-file-item{display:flex;gap:16px;align-items:center;justify-content:space-between;padding:14px;border:1px solid var(--border);border-radius:10px}.class-file-item video{width:min(360px,50%);max-height:210px;background:#000;border-radius:8px}
.class-recording-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.class-recording-actions video{width:360px;max-width:100%}
.whiteboard-overlay{position:fixed;inset:0;z-index:1000;background:rgba(3,10,24,.82);padding:20px}.whiteboard-panel{height:100%;display:flex;flex-direction:column;background:#fff;border-radius:14px;overflow:hidden}.whiteboard-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:10px 14px;border-bottom:1px solid #dbe3ee;color:#172033}.whiteboard-toolbar label{display:flex;align-items:center;gap:6px;font-size:12px}.whiteboard-panel canvas{width:100%;flex:1;min-height:0;touch-action:none;cursor:crosshair;background:#fff}.recording-live{background:#b42318!important;color:#fff!important;animation:pulse 1.4s infinite}

/* Standalone deployment pages */
.auth-page{min-height:100vh;margin:0;background:var(--bg,#f4f7fb);color:var(--text,#0f172a);display:grid;place-items:center;padding:24px;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
.auth-shell{width:min(100%,460px)}
.auth-card{background:var(--surface,#fff);border:1px solid var(--border,#e2e8f0);border-radius:20px;box-shadow:0 20px 60px rgba(15,23,42,.12);padding:32px}
.auth-brand{margin-bottom:28px}.auth-card h2{margin:0 0 20px}.auth-form{display:grid;gap:16px}.auth-form label{display:grid;gap:7px;font-size:14px;font-weight:600}.auth-form input{width:100%}
.auth-error,.notice{border-radius:12px;padding:12px 14px;margin:0 0 18px;font-size:14px}.auth-error,.notice.error{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}.notice.success{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0}
.standalone-grid-form{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;align-items:end}.standalone-grid-form label,.filter-bar label{display:grid;gap:7px;font-size:13px;font-weight:600}.form-action{display:flex;gap:8px;align-items:end;flex-wrap:wrap}
.table-wrap{overflow:auto}.standalone-table{width:100%;border-collapse:collapse;min-width:900px}.standalone-table th,.standalone-table td{padding:12px 14px;border-bottom:1px solid var(--border,#e2e8f0);vertical-align:top;text-align:left;font-size:13px}.standalone-table th{font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted,#64748b);background:var(--surface-soft,#f8fafc)}
.inline-user-form{display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:7px;min-width:520px}.password-reset-form{display:flex;gap:6px;min-width:220px}.password-reset-form input{min-width:140px}.filter-bar{display:flex;align-items:end;gap:12px;flex-wrap:wrap}.filter-bar label{min-width:160px}.stats-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.stat-card{background:var(--surface,#fff);border:1px solid var(--border,#e2e8f0);border-radius:16px;padding:18px;display:grid;gap:7px}.stat-card span{color:var(--text-muted,#64748b);font-size:13px}.stat-card strong{font-size:24px}
@media(max-width:900px){.standalone-grid-form{grid-template-columns:1fr 1fr}.stats-grid{grid-template-columns:1fr}.auth-card{padding:24px}}
@media(max-width:560px){.standalone-grid-form{grid-template-columns:1fr}}
@media(prefers-color-scheme:dark){.auth-page{background:#020617;color:#e2e8f0}.auth-card,.stat-card{background:#0f172a;border-color:#334155}.standalone-table th{background:#111827}.auth-error,.notice.error{background:#450a0a;color:#fecaca;border-color:#7f1d1d}.notice.success{background:#052e16;color:#bbf7d0;border-color:#166534}}

/* Main-site class synchronization */
.source-chip{display:inline-flex;align-items:center;gap:.25rem;padding:.2rem .5rem;border:1px solid var(--border);border-radius:999px;font-size:.72rem;font-weight:700;background:var(--surface-2);color:var(--text-muted);white-space:nowrap}.source-chip--local{opacity:.78}.class-card-header{gap:.45rem;flex-wrap:wrap}.sync-notice{margin:.75rem 0;padding:.8rem 1rem;border:1px solid var(--border);border-radius:12px;background:var(--surface-2);color:var(--text-muted);font-size:.88rem;line-height:1.65}.quick-student-form{margin-top:1rem;padding:1rem;border:1px solid var(--border);border-radius:14px;background:var(--surface-2)}.quick-student-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:.75rem 0}.quick-student-grid .span-2{grid-column:1/-1}@media(max-width:700px){.quick-student-grid{grid-template-columns:1fr}.quick-student-grid .span-2{grid-column:auto}}
