/* ═══════════════════════════════════════════════════════
   SCREENCORD — Premium UI with Theming
   ═══════════════════════════════════════════════════════ */

:root {
    /* Layout & Base config */
    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;

    /* Theme: DARK (Default) */
    --bg: #09090b;
    --surface: #18181b;
    --surface-2: #27272a;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text: #ffffff;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    
    --blue: #3b82f6;
    --blue-glow: rgba(59, 130, 246, 0.15);
    --indigo: #818cf8;
    --purple: #a78bfa;
    --green: #34d399;
    --green-glow: rgba(52, 211, 153, 0.15);
    --amber: #fbbf24;
    --red: #f87171;
    --red-glow: rgba(248, 113, 113, 0.15);

    --shadow-sm: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
    
    --bg-mesh: rgba(255,255,255,0.02);
    --btn-ghost-bg: rgba(255,255,255,0.04);
    --btn-ghost-hover: rgba(255,255,255,0.08);
    --nav-bg: rgba(9, 9, 11, 0.8);
    --overlay-bg: rgba(0, 0, 0, 0.75);
    --input-bg: rgba(0, 0, 0, 0.4);
    --preview-bg: #000000;
}

[data-theme="light"] {
    /* Theme: LIGHT */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    
    --blue: #2563eb;
    --blue-glow: rgba(37, 99, 235, 0.12);
    --indigo: #4f46e5;
    --purple: #7c3aed;
    --green: #10b981;
    --green-glow: rgba(16, 185, 129, 0.12);
    --amber: #d97706;
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.12);

    --shadow-sm: 0 4px 12px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.08);

    --bg-mesh: rgba(0,0,0,0.03);
    --btn-ghost-bg: rgba(0,0,0,0.04);
    --btn-ghost-hover: rgba(0,0,0,0.08);
    --nav-bg: rgba(255, 255, 255, 0.8);
    --overlay-bg: rgba(15, 23, 42, 0.6);
    --input-bg: #f8fafc;
    --preview-bg: #e2e8f0;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

/* ─── Animated Background ─── */
.bg-grid {
    position: fixed; inset: 0;
    background-image:
        linear-gradient(var(--bg-mesh) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-mesh) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0; pointer-events: none;
    transition: background-image var(--transition);
}

.bg-glow {
    position: fixed; border-radius: 50%;
    filter: blur(120px); opacity: 0.35;
    z-index: 0; pointer-events: none;
    animation: float 20s ease-in-out infinite;
}
.bg-glow--1 { width: 600px; height: 600px; background: rgba(59,130,246,0.15); top: -200px; left: -100px; }
.bg-glow--2 { width: 500px; height: 500px; background: rgba(139,92,246,0.15); bottom: -100px; right: -100px; animation-delay: -8s; }

[data-theme="light"] .bg-glow { opacity: 0.25; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

/* ─── Navbar ─── */
.navbar {
    position: sticky; top: 0; z-index: 100; padding: 0 24px;
    background: var(--nav-bg);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition), border-color var(--transition);
}
.navbar__inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center; height: 68px;
}

.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; cursor: pointer; transition: transform 0.2s; }
.logo:active { transform: scale(0.96); }
.logo__icon {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue), var(--indigo));
    border-radius: var(--radius-sm); color: white;
    box-shadow: 0 6px 16px rgba(59,130,246,0.3);
}
.logo__text { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }

.nav-group { display: flex; align-items: center; gap: 16px; }
.nav { display: flex; align-items: center; gap: 6px; }

.nav__link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; color: var(--text-2); text-decoration: none;
    font-size: 0.85rem; font-weight: 600; border-radius: var(--radius-xs);
    transition: all var(--transition);
}
.nav__link:hover { color: var(--text); background: var(--btn-ghost-bg); }
.nav__link.active { color: var(--blue); background: var(--blue-glow); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
    border: none; border-radius: var(--radius-xs); font-family: var(--font);
    font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.btn:active { transform: scale(0.96); }

.btn--icon { padding: 10px; border-radius: 50%; background: var(--btn-ghost-bg); color: var(--text-2); border: 1px solid var(--border); }
.btn--icon:hover { background: var(--btn-ghost-hover); color: var(--text); }

.btn--primary { background: linear-gradient(135deg, var(--blue), var(--indigo)); color: white; box-shadow: var(--shadow-sm); }
.btn--primary:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.btn--primary:active { transform: translateY(0) scale(0.98); }

.btn--ghost { background: var(--btn-ghost-bg); border: 1px solid var(--border); color: var(--text-2); }
.btn--ghost:hover { background: var(--btn-ghost-hover); color: var(--text); border-color: var(--border-hover); }

.btn--danger { background: var(--red-glow); color: var(--red); border: 1px solid rgba(248,113,113,0.3); }
.btn--danger:hover { background: rgba(248,113,113,0.2); }

.btn--join { background: var(--green-glow); color: var(--green); border: 1px solid rgba(52,211,153,0.25); }
.btn--join:hover { background: rgba(52,211,153,0.18); }

.btn--sm { padding: 8px 14px; font-size: 0.8rem; }

/* Theme Icon transitions */
.theme-icon-light { display: none; }
.theme-icon-dark { display: block; }
[data-theme="light"] .theme-icon-light { display: block; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ─── Main Content ─── */
.main { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 48px 24px 80px; }

.section-header { margin-bottom: 36px; text-align: center; }
.section-header h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.04em; }
.section-desc { color: var(--text-2); font-size: 1rem; margin-top: 8px; line-height: 1.6; }

/* ─── Recorder Card ─── */
.recorder {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-lg); transition: border-color var(--transition);
    margin-bottom: 64px;
}
.recorder:hover { border-color: var(--border-hover); }

.recorder__status {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--btn-ghost-bg);
}

.status-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px 6px 10px; border-radius: 100px;
    background: var(--green-glow); border: 1px solid rgba(52,211,153,0.2);
    font-size: 0.75rem; font-weight: 700; color: var(--green);
    text-transform: uppercase; letter-spacing: 0.08em; transition: all 0.3s;
}
.status-badge.recording { background: var(--red-glow); border-color: rgba(248,113,113,0.3); color: var(--red); }
.status-badge__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); transition: all 0.3s; }
.status-badge.recording .status-badge__dot { background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.timer { display: flex; align-items: center; gap: 2px; font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: var(--text); }
.timer__sep { color: var(--text-3); margin: 0 2px; }

/* Preview */
.preview {
    position: relative; aspect-ratio: 16 / 9; background: #0a0a0a;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}

.preview__placeholder { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; padding: 24px; }
.preview__icon {
    width: 80px; height: 80px; display: flex; align-items: center; justify-content: center;
    border-radius: 24px; background: var(--btn-ghost-bg); border: 1px solid var(--border);
    color: var(--text-3); animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.7; } 50% { transform: scale(1.05); opacity: 1; } }
.preview__placeholder h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.preview__placeholder p { font-size: 0.95rem; color: var(--text-2); max-width: 320px; line-height: 1.5; }

#preview, #live-preview, #watch-preview, #share-playback-video { 
    width: 100%; height: 100%; object-fit: contain; 
    display: none; background: var(--preview-bg);
    position: relative;
    z-index: 1;
}
#preview.active, #live-preview.active, #watch-preview.active { display: block; }
#share-playback-video { display: block; }

.rec-badge {
    position: absolute; top: 16px; left: 16px; display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); border-radius: var(--radius-xs);
    font-size: 0.75rem; font-weight: 800; color: #f87171; letter-spacing: 0.1em; opacity: 0; transform: translateY(-8px); transition: all 0.3s;
}
[data-theme="light"] .rec-badge { color: #ef4444; }
.rec-badge.active { opacity: 1; transform: translateY(0); }
.rec-badge__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); } 50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } }

/* Controls */
.controls, .live-controls {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-top: 1px solid var(--border); background: var(--btn-ghost-bg);
}
.live-controls { justify-content: center; padding: 16px 24px; }
.controls__left, .controls__right { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.controls__right { justify-content: flex-end; }
.controls__center { display: flex; align-items: center; gap: 12px; }

/* Toggle buttons */
.toggle-btn {
    display: flex; align-items: center; gap: 6px; padding: 8px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--btn-ghost-bg); color: var(--text-2); cursor: pointer;
    transition: all var(--transition); font-family: var(--font); font-size: 0.85rem; font-weight: 600;
}
.toggle-btn:hover { border-color: var(--border-hover); background: var(--btn-ghost-hover); color: var(--text); }
.toggle-btn.active { background: var(--blue-glow); border-color: rgba(59,130,246,0.3); color: var(--blue); }
.toggle-btn__icon-off { display: none; }
.toggle-btn.active .toggle-btn__icon-on { display: block; }
.toggle-btn.active .toggle-btn__icon-off { display: none; }
.toggle-btn:not(.active) .toggle-btn__icon-on { display: none; }
.toggle-btn:not(.active) .toggle-btn__icon-off { display: block; }

/* Record Button */
.record-btn {
    display: flex; align-items: center; gap: 10px; padding: 14px 32px;
    background: linear-gradient(135deg, var(--blue), var(--indigo)); border: none; border-radius: var(--radius-sm);
    color: white; font-family: var(--font); font-size: 0.95rem; font-weight: 700;
    cursor: pointer; transition: all 0.3s;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.2);
}
.record-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.record-btn:active { transform: translateY(0) scale(0.96); }
.record-btn__circle { width: 12px; height: 12px; background: white; border-radius: 50%; box-shadow: 0 0 8px rgba(255,255,255,0.5); }

.stop-btn {
    display: none; align-items: center; gap: 10px; padding: 14px 32px;
    background: var(--red-glow); border: 1px solid rgba(248,113,113,0.3);
    border-radius: var(--radius-sm); color: var(--red); font-family: var(--font); font-size: 0.95rem;
    font-weight: 700; cursor: pointer; transition: all var(--transition);
}
.stop-btn:hover { background: rgba(248,113,113,0.25); border-color: var(--red); }
.stop-btn:active { transform: scale(0.96); }
.stop-btn__square { width: 12px; height: 12px; background: var(--red); border-radius: 3px; }

.quality-chip {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--border);
}
.quality-chip__label { font-size: 0.75rem; font-weight: 800; color: var(--text); }
.quality-chip__value { font-size: 0.75rem; color: var(--text-2); }

/* ─── Features ─── */
.features { text-align: center; }
.features__header { margin-bottom: 48px; }
.features__badge {
    display: inline-block; padding: 6px 16px; border-radius: 100px;
    background: var(--blue-glow); border: 1px solid rgba(59,130,246,0.2);
    color: var(--blue); font-size: 0.8rem; font-weight: 700; margin-bottom: 16px; letter-spacing: 0.04em; text-transform: uppercase;
}
.features__title { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.2; }

.features__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.feature-card {
    text-align: left; padding: 28px 24px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}
.feature-card:hover { border-color: var(--border-hover); transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-card__icon {
    width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); margin-bottom: 20px;
}
.feature-card__icon--blue { background: var(--blue-glow); color: var(--blue); }
.feature-card__icon--purple { background: rgba(139,92,246,0.15); color: var(--purple); }
.feature-card__icon--green { background: var(--green-glow); color: var(--green); }
.feature-card__icon--amber { background: rgba(251,191,36,0.15); color: var(--amber); }

.feature-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: var(--text-2); line-height: 1.6; }

/* ─── Recordings Grid ─── */
.recordings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.recording-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; transition: all 0.3s; cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.recording-card:hover { border-color: var(--blue); transform: translateY(-4px); box-shadow: var(--shadow-md); }

.recording-card__thumb {
    aspect-ratio: 16 / 9; background: var(--preview-bg); position: relative;
    display: flex; align-items: center; justify-content: center;
}
.recording-card__thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.recording-card__play {
    position: absolute; width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    border-radius: 50%; color: white; opacity: 0; transform: scale(0.8); transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
}
.recording-card:hover .recording-card__play { opacity: 1; transform: scale(1); }

.recording-card__info { padding: 16px 20px; }
.recording-card__name { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recording-card__meta { display: flex; align-items: center; gap: 12px; font-size: 0.8rem; color: var(--text-3); }

.recording-card__actions { padding: 0 20px 20px; display: flex; gap: 8px; }

/* Empty state */
.empty-state {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 80px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-state__icon { color: var(--text-3); opacity: 0.5; margin-bottom: 8px; }
.empty-state h3 { font-size: 1.25rem; font-weight: 800; }
.empty-state p { color: var(--text-2); font-size: 0.95rem; margin-bottom: 16px; }

/* ─── Live Panel ─── */
.live-panel {
    display: grid; 
    grid-template-columns: 1fr 14px 360px; 
    gap: 0;
    min-height: 540px;
    transition: none !important;
}
.live-panel__video-area { 
    display: flex; flex-direction: column; gap: 16px; 
}

/* ─── Whiteboard Surface ─── */
.whiteboard-surface {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #fdfdfd;
    background-image: 
        radial-gradient(#e5e7eb 1px, transparent 1px),
        radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.preview.is-whiteboard .whiteboard-surface {
    display: block;
    opacity: 1;
}
.preview.is-whiteboard video {
    opacity: 0 !important;
    pointer-events: none;
}

.live-panel__resizer {
    width: 14px;
    height: 100%;
    cursor: col-resize;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.02);
}
.live-panel__resizer::after {
    content: '';
    width: 4px;
    height: 48px;
    background: var(--border);
    border-radius: 4px;
    transition: all 0.2s;
}
.live-panel__resizer:hover::after,
.live-panel__resizer.is-dragging::after {
    background: var(--blue);
    height: 64px;
    box-shadow: 0 0 10px var(--blue-glow);
}
.live-panel__resizer:hover {
    background: rgba(59,130,246,0.05);
}

/* ─── Live Canvas (Annotations) ─── */
.live-canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none; /* raw canvas element — Fabric manages this internally */
}

/* Fabric wraps the canvas in .canvas-container — pointer-events off by default */
.canvas-container {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 20;
    pointer-events: none;
    cursor: default;
}

/* Drawing tools (pen, rect, arrow, text) */
.canvas-container.is-drawing {
    pointer-events: auto !important;
    cursor: crosshair !important;
}

.canvas-container.is-drawing canvas {
    pointer-events: auto !important;
    cursor: crosshair !important;
}

/* Select tool */
.canvas-container.is-selecting {
    pointer-events: auto !important;
    cursor: default !important;
}

.canvas-container.is-selecting canvas {
    pointer-events: auto !important;
    cursor: default !important;
}

/* ─── Side-Anchored Annotation Flyout ─── */
.annotation-toolbar {
    position: fixed;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: row-reverse; /* Tools fly out to the LEFT of the trigger */
    align-items: center;
    gap: 16px;
    z-index: 1000;
}

/* Vertical Tool Pill (The Flyout) */
.annotation-toolbar__tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 40px;
    padding: 10px;
    gap: 8px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6);
    animation: flyInLeft 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flyInLeft {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Trigger Button (Always visible on the right) */
.annotation-toolbar__toggle {
    width: 48px;
    height: 48px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.annotation-toolbar__toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
}

.annotation-toolbar__toggle.active {
    background: var(--blue-dark);
}

/* Tool Buttons in the Flyout */
.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    transition: all 0.2s;
}
.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}
.tool-btn.active {
    background: var(--blue);
    color: white;
}

.tool-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

#tool-color {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
    overflow: hidden;
}
#tool-color::-webkit-color-swatch-wrapper { padding: 0; }
#tool-color::-webkit-color-swatch { border: none; border-radius: 50%; }

/* ─── Resource Push Popup ─── */
.push-popup {
    position: fixed;
    top: 40px;
    right: 40px;
    background: var(--surface);
    border: 1px solid var(--blue);
    border-radius: var(--radius);
    padding: 24px;
    width: 320px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--blue-glow);
    z-index: 2000;
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.push-popup__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.push-popup__badge {
    background: var(--blue-glow);
    color: var(--blue);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 100px;
    letter-spacing: 0.05em;
}
.push-popup__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-3);
    cursor: pointer;
    line-height: 1;
}
.push-popup__title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text);
}
.push-popup__url {
    font-size: 0.85rem;
    color: var(--text-3);
    margin-bottom: 20px;
    word-break: break-all;
}
.push-popup__btn {
    width: 100%;
    justify-content: center;
}

@keyframes slideUp {
    from { transform: translate(-50%, 40px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes slideInRight {
    from { transform: translateX(60px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


.room-info {
    display: none; flex-direction: column; gap: 12px;
    padding: 20px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.room-info__label { font-size: 0.8rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.room-info__code {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: var(--input-bg); border-radius: var(--radius-xs); border: 1px solid var(--border);
}
.room-info__code span { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; letter-spacing: 0.15em; color: var(--blue); }
.room-info__viewers { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }

/* ─── Global Sidebar ─── */
.sidebar-panel {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
    height: 100%;
}

.sidebar-tabs {
    display: flex; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.sidebar-tab {
    flex: 1; padding: 14px 0; background: none; border: none; font-size: 0.9rem; font-weight: 700;
    color: var(--text-3); font-family: var(--font); cursor: pointer; transition: all var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border-bottom: 2px solid transparent;
}
.sidebar-tab:hover { color: var(--text); background: var(--btn-ghost-bg); }
.sidebar-tab.active { color: var(--blue); border-bottom-color: var(--blue); background: var(--surface); }

.sidebar-pane { display: none; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-pane.active { display: flex; }

/* ─── Chat Pane ─── */
.chat-panel__header {
    display: flex; align-items: center; gap: 10px; padding: 16px 20px;
    font-size: 0.95rem; font-weight: 800; color: var(--text); background: var(--surface-2);
}
.chat-panel__count {
    padding: 2px 10px; border-radius: 100px; background: var(--blue-glow);
    color: var(--blue); font-size: 0.75rem; font-weight: 700;
}
.chat-panel__messages {
    flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px;
    min-height: 400px;
}
.chat-panel__input {
    position: relative; display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.chat-panel__input input {
    flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--input-bg); color: var(--text); font-family: var(--font); font-size: 0.9rem;
    outline: none; transition: all var(--transition);
}
.chat-panel__input input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.chat-panel__input input:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-emoji-picker {
    display: flex; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border);
    gap: 8px; overflow-x: auto;
}
.emoji-btn {
    background: none; border: none; font-size: 1.4rem; padding: 6px; cursor: pointer;
    border-radius: var(--radius-xs); transition: all 0.2s;
}
.emoji-btn:hover { background: var(--btn-ghost-hover); transform: scale(1.1); }

.chat-msg { display: flex; flex-direction: column; gap: 4px; }
.chat-msg__header { display: flex; align-items: center; gap: 8px; }
.chat-msg__name { font-size: 0.8rem; font-weight: 700; color: var(--blue); }
.chat-msg__time { font-size: 0.7rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chat-msg__text { font-size: 0.95rem; color: var(--text); line-height: 1.5; word-break: break-word; background: var(--surface-2); padding: 10px 14px; border-radius: 0 12px 12px 12px; display: inline-block; border: 1px solid var(--border); }
.chat-msg--self .chat-msg__header { flex-direction: row-reverse; }
.chat-msg--self .chat-msg__name { color: var(--green); }
.chat-msg--self .chat-msg__text { border-radius: 12px 0 12px 12px; background: var(--green-glow); border-color: rgba(52,211,153,0.2); margin-left: auto; color: var(--text); }
.chat-msg--self { display: flex; flex-direction: column; align-items: flex-end; }

.chat-system-msg {
    text-align: center; font-size: 0.8rem; color: var(--text-3); font-weight: 500;
    padding: 10px 16px; background: var(--btn-ghost-bg); border-radius: var(--radius-sm);
    margin: 8px auto; display: inline-block;
}

/* ─── Polls & Resources ─── */
.chat-poll {
    background: var(--surface-2); border: 1px solid var(--blue); border-radius: var(--radius-sm);
    padding: 16px; display: flex; flex-direction: column; gap: 12px; width: 100%; box-shadow: 0 4px 12px var(--blue-glow); margin-left: auto; margin-right: auto;
}
.chat-poll__q { font-size: 0.95rem; font-weight: 800; color: var(--text); }
.chat-poll__opt {
    display: flex; flex-direction: column; padding: 10px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xs);
    cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden;
}
.chat-poll__opt:hover { border-color: var(--blue); background: var(--btn-ghost-bg); transform: translateX(4px); }
.chat-poll__opt-text { position: relative; z-index: 1; font-size: 0.9rem; font-weight: 600; }
.chat-poll__bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue-glow); width: 0%; transition: width 0.4s ease-out; z-index: 0; }

.resource-card {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: all 0.2s; text-decoration: none; color: inherit;
}
.resource-card:hover { border-color: var(--green); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.resource-card__icon { color: var(--green); display: flex; align-items: center; justify-content: center; padding: 8px; background: var(--green-glow); border-radius: var(--radius-xs); flex-shrink: 0; }
.resource-card__info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.resource-card__title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.resource-card__url { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ─── Modals ─── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--overlay-bg); backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn { from { opacity: 0; backdrop-filter: blur(0); } }

.modal {
    width: 100%; max-width: 500px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(30px) scale(0.98); opacity: 0; } }

.modal__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 24px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.modal__header h2 { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.modal__close {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border: none; background: var(--btn-ghost-bg); border-radius: var(--radius-xs);
    color: var(--text-3); font-size: 1.25rem; cursor: pointer; transition: all var(--transition);
}
.modal__close:hover { background: var(--btn-ghost-hover); color: var(--text); transform: rotate(90deg); }

.modal__body { padding: 24px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 12px; padding: 20px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* Form elements */
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.form-input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--input-bg); color: var(--text); font-family: var(--font); font-size: 0.95rem;
    outline: none; transition: all var(--transition);
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.form-input--code { font-family: var(--mono); font-size: 1.6rem; font-weight: 800; text-align: center; letter-spacing: 0.15em; text-transform: uppercase; padding: 16px; }
.form-hint { font-size: 0.85rem; color: var(--text-3); margin-top: 12px; line-height: 1.5; }

.save-preview { margin-top: 20px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--preview-bg); }
.save-preview video { width: 100%; display: block; }

.share-status { margin-top: 20px; font-size: 0.9rem; color: var(--text-3); font-weight: 500; }

/* ─── Toast ─── */
.toast-container { position: fixed; bottom: 32px; right: 32px; z-index: 2000; display: flex; flex-direction: column; gap: 12px; }
.toast {
    padding: 16px 24px; border-radius: var(--radius-xs);
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); font-size: 0.9rem; font-weight: 600;
    box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 12px;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.removing { opacity: 0; transform: translateX(30px) scale(0.95); margin-top: -60px; pointer-events: none; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } }
.toast--success { border-left: 4px solid var(--green); }
.toast--error { border-left: 4px solid var(--red); }
.toast--info { border-left: 4px solid var(--blue); }

/* ─── Footer ─── */
.footer { position: relative; z-index: 1; border-top: 1px solid var(--border); padding: 0 24px; background: var(--surface); transition: background var(--transition); }
.footer__inner { max-width: 1200px; margin: 0 auto; padding: 32px 0; display: flex; justify-content: space-between; align-items: center; }
.footer__copy { font-size: 0.85rem; color: var(--text-3); font-weight: 500; }

/* ─── Responsive ─── */
@media (max-width: 960px) {
    .live-panel { grid-template-columns: 1fr; }
    .features__grid { grid-template-columns: repeat(2, 1fr); }
    .chat-panel { max-height: 400px; }
}

@media (max-width: 640px) {
    .main { padding: 24px 16px 80px; }
    .section-header h1 { font-size: 1.8rem; }
    .recorder { border-radius: var(--radius-sm); margin-bottom: 40px; }
    .controls { flex-direction: column; gap: 16px; padding: 16px; }
    .controls__left, .controls__right { min-width: auto; justify-content: center; }
    .features__title { font-size: 1.6rem; }
    .features__grid { grid-template-columns: 1fr; }
    .nav__link span { display: none; }
    .toggle-btn__label { display: none; }
    .footer__inner { flex-direction: column; gap: 16px; text-align: center; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; border: 1px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ═══════════════════════════════════════════════════════
   AUTH GATE
   ═══════════════════════════════════════════════════════ */
.auth-gate {
    position: fixed; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.auth-card {
    width: 100%; max-width: 420px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card__header {
    padding: 36px 32px 24px; text-align: center;
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(139,92,246,0.08));
    border-bottom: 1px solid var(--border);
}

.auth-card__subtitle {
    color: var(--text-2); font-size: 0.9rem; margin-top: 12px; line-height: 1.5;
}

.auth-card__body {
    padding: 28px 32px 32px;
}

.auth-card__body .form-label {
    margin-top: 16px;
}
.auth-card__body .form-label:first-of-type {
    margin-top: 0;
}

.auth-error {
    padding: 12px 16px; border-radius: var(--radius-xs);
    background: var(--red-glow); border: 1px solid rgba(248,113,113,0.3);
    color: var(--red); font-size: 0.85rem; font-weight: 600;
    margin-bottom: 16px; animation: fadeIn 0.2s;
}

.auth-success {
    padding: 12px 16px; border-radius: var(--radius-xs);
    background: var(--green-glow); border: 1px solid rgba(52,211,153,0.3);
    color: var(--green); font-size: 0.85rem; font-weight: 600;
    margin-bottom: 16px; animation: fadeIn 0.2s;
}

.auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0 16px;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-divider span {
    font-size: 0.8rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em;
}

.auth-toggle {
    text-align: center; margin-top: 20px;
    font-size: 0.85rem; color: var(--text-3);
}

.auth-toggle a {
    color: var(--blue); text-decoration: none; font-weight: 600;
    transition: color 0.2s;
}
.auth-toggle a:hover { color: var(--indigo); }

/* ═══════════════════════════════════════════════════════
   USER MENU (Navbar)
   ═══════════════════════════════════════════════════════ */
.user-menu {
    position: relative;
}

.user-menu__trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 6px;
    background: var(--btn-ghost-bg); border: 1px solid var(--border);
    border-radius: 100px; cursor: pointer;
    font-family: var(--font); font-size: 0.85rem; font-weight: 600;
    color: var(--text); transition: all var(--transition);
}
.user-menu__trigger:hover {
    background: var(--btn-ghost-hover); border-color: var(--border-hover);
}

.user-avatar {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue), var(--indigo));
    border-radius: 50%; color: white;
    font-size: 0.75rem; font-weight: 800;
}

.user-menu__name {
    max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 240px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    z-index: 200;
    opacity: 0; visibility: hidden; transform: translateY(-8px) scale(0.97);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.user-dropdown.active {
    opacity: 1; visibility: visible; transform: translateY(0) scale(1);
}

.user-dropdown__info {
    padding: 14px 16px;
}
.user-dropdown__email {
    font-size: 0.8rem; color: var(--text-3); word-break: break-all;
}
.user-dropdown__divider {
    height: 1px; background: var(--border); margin: 0 8px;
}
.user-dropdown__item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 12px 16px;
    background: none; border: none;
    font-family: var(--font); font-size: 0.85rem; font-weight: 600;
    color: var(--text-2); cursor: pointer;
    transition: all var(--transition);
}
.user-dropdown__item:hover {
    background: var(--btn-ghost-bg); color: var(--red);
}

/* ═══════════════════════════════════════════════════════
   ADMIN DASHBOARD
   ═══════════════════════════════════════════════════════ */
.admin-stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
    margin-bottom: 24px;
}

.admin-stats-grid--secondary {
    margin-bottom: 40px;
}

.admin-stat-card {
    display: flex; align-items: center; gap: 16px;
    padding: 24px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}
.admin-stat-card:hover {
    border-color: var(--border-hover); transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.admin-stat-card__icon {
    width: 48px; height: 48px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}

.admin-stat-card__info {
    display: flex; flex-direction: column; gap: 4px;
}

.admin-stat-card__value {
    font-size: 1.8rem; font-weight: 900; letter-spacing: -0.03em;
    color: var(--text); line-height: 1;
}

.admin-stat-card__label {
    font-size: 0.8rem; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.04em;
}

.admin-stat-mini {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}

.admin-stat-mini__label {
    font-size: 0.85rem; font-weight: 600; color: var(--text-2);
}

.admin-stat-mini__value {
    font-size: 1.1rem; font-weight: 800; color: var(--text);
    font-family: var(--mono);
}

.admin-section {
    margin-bottom: 32px;
}

.admin-section__header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}

.admin-section__title {
    font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em;
}

.admin-table-wrapper {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table thead {
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}

.admin-table th {
    padding: 14px 16px; text-align: left;
    font-size: 0.75rem; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.06em;
}

.admin-table td {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    color: var(--text);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: var(--btn-ghost-bg);
}

.admin-badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 100px;
    font-size: 0.7rem; font-weight: 800; letter-spacing: 0.05em;
    text-transform: uppercase;
}

.admin-badge--live {
    background: var(--red-glow); color: var(--red); border: 1px solid rgba(248,113,113,0.3);
}
.admin-badge--playback {
    background: rgba(139,92,246,0.12); color: var(--purple); border: 1px solid rgba(139,92,246,0.25);
}
.admin-badge--active {
    background: var(--green-glow); color: var(--green); border: 1px solid rgba(52,211,153,0.25);
}
.admin-badge--ended {
    background: var(--btn-ghost-bg); color: var(--text-3); border: 1px solid var(--border);
}
.admin-badge--admin {
    background: rgba(251,191,36,0.12); color: var(--amber); border: 1px solid rgba(251,191,36,0.25);
}
.admin-badge--user {
    background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(59,130,246,0.2);
}

.admin-code {
    font-family: var(--mono); font-size: 0.8rem; font-weight: 700;
    padding: 4px 8px; border-radius: 4px;
    background: var(--surface-2); color: var(--blue);
    letter-spacing: 0.08em;
}

.admin-user-cell {
    display: flex; align-items: center; gap: 12px;
}

.admin-user-avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--blue), var(--indigo));
    border-radius: 50%; color: white;
    font-size: 0.75rem; font-weight: 800;
}

.admin-user-name {
    font-weight: 700; font-size: 0.88rem;
}

.admin-user-email {
    font-size: 0.75rem; color: var(--text-3);
}

.admin-action-btn {
    padding: 5px 12px !important; font-size: 0.75rem !important;
}

/* Admin Responsive */
@media (max-width: 960px) {
    .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-table { font-size: 0.8rem; }
    .admin-table th, .admin-table td { padding: 10px 12px; }
}

@media (max-width: 640px) {
    .admin-stats-grid { grid-template-columns: 1fr; }
    .admin-table-wrapper { overflow-x: auto; }
    .auth-card__body { padding: 20px 24px 24px; }
    .auth-card__header { padding: 28px 24px 20px; }
    .user-menu__name { display: none; }
}