/* ============================================================
   BuckNET WatchParty - Premium Dark UI
   Single theme: BuckNET Purple (Emby-style aesthetic)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Design Tokens */
:root {
    --accent:         #a855f7;
    --accent-dim:     #7c3aed;
    --accent-light:   #c084fc;
    --accent-glow:    rgba(168, 85, 247, 0.35);
    --bg-0:           #0d0d0f;
    --bg-1:           #141416;
    --bg-2:           #1c1c1f;
    --bg-3:           #242428;
    --border-subtle:  rgba(255,255,255,0.07);
    --border-accent:  rgba(168, 85, 247, 0.35);
    --text-1:         #f1f1f1;
    --text-2:         #9b9ba8;
    --text-3:         #5c5c6e;
    --danger:         #ef4444;
    --danger-dim:     rgba(239,68,68,0.18);
    --gold:           #fbbf24;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.5);
    --shadow-md:      0 4px 12px rgba(0,0,0,0.6);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.7);
    --shadow-glow:    0 0 18px rgba(168,85,247,0.4);
    --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      14px;
    /* Legacy compatibility aliases */
    --cyber-primary:  #a855f7;
    --cyber-secondary:#7c3aed;
    --cyber-accent:   #c084fc;
    --cyber-gold:     #fbbf24;
    --cyber-red:      #ef4444;
    --bg-primary:     #0d0d0f;
    --bg-secondary:   #141416;
    --bg-tertiary:    #1c1c1f;
    --text-primary:   #f1f1f1;
    --text-secondary: #9b9ba8;
    --text-dim:       #5c5c6e;
}

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

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

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.4); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.55rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    white-space: nowrap;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); box-shadow: var(--shadow-glow); transform: translateY(-1px); }

.btn-small {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    background: var(--bg-3);
    color: var(--text-1);
}
.btn-small:hover { background: var(--bg-2); border-color: var(--border-accent); color: var(--accent-light); }

.btn-danger {
    background: var(--danger-dim) !important;
    color: #f87171 !important;
    border-color: rgba(239,68,68,0.3) !important;
}
.btn-danger:hover {
    background: rgba(239,68,68,0.28) !important;
    box-shadow: 0 0 12px rgba(239,68,68,0.3);
    color: #fff !important;
}

/* Login Page */
.login-page-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(168,85,247,0.18) 0%, transparent 70%), var(--bg-0);
    padding: 2rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.login-brand { text-align: center; }

.login-brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.5rem;
}

.login-brand-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 20px rgba(168,85,247,0.5);
}

.login-brand-name {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-brand-sub { font-size: 0.85rem; color: var(--text-2); }

.login-card {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(168,85,247,0.08);
}

.login-card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group { margin-bottom: 1.2rem; }

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168,85,247,0.15); }
.form-group input::placeholder { color: var(--text-3); }

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.login-btn:hover { background: var(--accent-light); box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error-message {
    color: #f87171;
    background: var(--danger-dim);
    border: 1px solid rgba(239,68,68,0.3);
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    display: none;
}

/* Party Page Layout */
.party-page { background: var(--bg-0); color: var(--text-1); }
.party-container { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* Top Navbar */
.party-header {
    height: 48px;
    min-height: 48px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-brand-icon {
    width: 26px;
    height: 26px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.navbar-brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.navbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-subtle);
    flex-shrink: 0;
}

.party-code {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-2);
    flex-shrink: 0;
}

.party-code-label { color: var(--text-3); }

.party-code-badge {
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-light);
    background: rgba(168,85,247,0.12);
    border: 1px solid rgba(168,85,247,0.25);
    padding: 1px 8px;
    border-radius: 4px;
    letter-spacing: 1.5px;
}

.navbar-spacer { flex: 1; }

.user-info { display: flex; align-items: center; gap: 8px; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px 2px 6px;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: 99px;
    color: var(--text-2);
    font-size: 0.78rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    user-select: none;
    white-space: nowrap;
}
.user-chip:hover {
    background: var(--bg-2);
    border-color: var(--border-accent);
    color: var(--accent-light);
}
.user-avatar {
    width: 18px;
    height: 18px;
    background: var(--accent-dim);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
}
#currentUserName {
    color: var(--text-1);
    font-weight: 600;
}

.user-count-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: 99px;
    padding: 2px 10px;
    white-space: nowrap;
}

.user-count-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(74,222,128,0.7);
}

#showLibraryBtn {
    background: rgba(168,85,247,0.15);
    color: var(--accent-light);
    border-color: rgba(168,85,247,0.3);
}
#showLibraryBtn:hover { background: rgba(168,85,247,0.25); color: #fff; }

#userCount { color: var(--text-1); font-weight: 700; }

/* Party Content */
.party-content { flex: 1; display: flex; overflow: hidden; }

/* Library Sidebar */
.library-sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-1);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s;
}
.library-sidebar.hidden {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}
.library-sidebar.hidden .sidebar-header,
.library-sidebar.hidden .search-container,
.library-sidebar.hidden .library-nav,
.library-sidebar.hidden .library-content {
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.sidebar-header h2 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-2);
}

.search-container {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.83rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(168,85,247,0.15); }
.search-input::placeholder { color: var(--text-3); }

.clear-search-btn {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.clear-search-btn:hover { color: var(--text-1); }

.library-nav {
    display: flex;
    padding: 0.4rem 0.6rem;
    gap: 0.3rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.nav-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--bg-3); color: var(--text-1); }
.nav-btn.active { background: rgba(168,85,247,0.15); color: var(--accent-light); font-weight: 600; }

.library-content { flex: 1; overflow-y: auto; padding: 0.5rem; background: var(--bg-0); }

.library-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.library-item:hover { background: var(--bg-2); border-color: var(--border-accent); }

.library-item img {
    width: 42px;
    height: 63px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--bg-3);
}

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

.library-item-title {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.library-item-meta {
    font-size: 0.75rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Video Area */
.video-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    background: var(--bg-0);
    min-width: 0;
}

.no-video-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.placeholder {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.placeholder-icon { font-size: 3.5rem; opacity: 0.3; }
.placeholder h2 { font-size: 1rem; font-weight: 600; color: var(--text-2); }
.placeholder p { font-size: 0.83rem; color: var(--text-3); max-width: 280px; }

/* Video Player */
.video-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
    min-width: 0;
    position: relative;
    background: #000;
}
.video-wrapper {
    position: relative;
    width: 100%;
    max-height: 72vh;
    background: #000;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}
.cast-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    color: #fff;
    font-family: var(--font);
}
.cast-overlay-content {
    text-align: center;
}
.cast-overlay-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    animation: pulse-cast 2s infinite ease-in-out;
}
@keyframes pulse-cast {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

#videoElement {
    width: 100%;
    max-height: 72vh;
    background: #000;
    display: block;
    flex-shrink: 0;
}

video:fullscreen, video:-webkit-full-screen, #videoElement:fullscreen, #videoElement:-webkit-full-screen {
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    max-height: 100vh !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
}
video::backdrop, #videoElement::backdrop { background: #000; }

/* Skip Intro */
.skip-intro-button {
    position: absolute;
    bottom: 200px;
    right: 80px;
    padding: 10px 22px;
    background: rgba(168,85,247,0.15);
    color: var(--accent-light);
    border: 1px solid rgba(168,85,247,0.5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 100;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
    letter-spacing: 0.5px;
}
.skip-intro-button:hover { background: var(--accent); color: #fff; box-shadow: var(--shadow-glow); transform: scale(1.04); }

/* Video Meta Bar */
.collapse-footer-btn {
    width: 100%;
    padding: 3px;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 0.7rem;
    cursor: pointer;
    text-align: center;
    transition: color 0.2s;
}
.collapse-footer-btn:hover { color: var(--text-1); }
.collapse-footer-btn.collapsed { transform: rotate(180deg); }

.video-meta {
    padding: 0.7rem 1rem;
    background: var(--bg-1);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.video-meta.collapsed { display: none; }

.video-meta-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    width: 100%;
}

.video-info { flex: 1; min-width: 0; }
.video-info h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.video-info p {
    color: var(--text-2);
    font-size: 0.78rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.stream-controls {
    display: flex;
    flex-direction: row;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.stream-control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 110px;
    max-width: 200px;
    flex: 1;
}
.stop-button-group { flex: 0 0 auto; min-width: auto; }
.autoplay-toggle-group { min-width: 80px; max-width: 100px; }

.stream-control-group label {
    color: var(--text-3);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stream-select {
    padding: 0.35rem 0.6rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.2s;
}
.stream-select:hover, .stream-select:focus { outline: none; border-color: var(--accent); }
.stream-select option { background: var(--bg-3); color: var(--text-1); }

.autoplay-toggle {
    padding: 0.35rem 0.7rem;
    background: rgba(168,85,247,0.12);
    border: 1px solid rgba(168,85,247,0.3);
    color: var(--accent-light);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}
.autoplay-toggle:hover { background: rgba(168,85,247,0.22); }
.autoplay-toggle[data-enabled="false"] { background: var(--bg-3); border-color: var(--border-subtle); color: var(--text-2); }
.autoplay-toggle[data-enabled="false"]:hover { border-color: var(--border-accent); color: var(--text-1); }

/* Cast Button */
.cast-btn {
    padding: 0.35rem 0.7rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    color: var(--text-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    align-self: flex-end;
}
.cast-btn:hover { background: var(--bg-2); border-color: var(--border-accent); color: var(--accent-light); }
.cast-btn.casting { background: rgba(168,85,247,0.15); border-color: rgba(168,85,247,0.4); color: var(--accent-light); box-shadow: 0 0 10px rgba(168,85,247,0.2); }
.cast-btn svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

/* Chat Panel */
.chat-container {
    width: 300px;
    min-width: 220px;
    max-width: 500px;
    background: var(--bg-1);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}
.chat-container.collapsed { display: none; }

.chat-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s;
}
.chat-resize-handle:hover, .chat-resize-handle.dragging { background: rgba(168,85,247,0.2); }
.chat-resize-handle::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}
.chat-resize-handle:hover::after, .chat-resize-handle.dragging::after { opacity: 0.5; }

.chat-header {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-header h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-2);
}

.participant-section { border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-2);
    font-weight: 600;
    transition: background 0.15s;
}
.participant-header:hover { background: rgba(255,255,255,0.03); }
.participant-chevron { font-size: 0.65rem; transition: transform 0.2s; }
.participant-chevron.collapsed { transform: rotate(-90deg); }
.participant-items { list-style: none; max-height: 120px; overflow-y: auto; }
.participant-items.hidden { display: none; }
.participant-items li { padding: 0.25rem 0.85rem; font-size: 0.8rem; color: var(--text-2); }
.participant-self { color: var(--accent-light) !important; font-weight: 600; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--bg-0);
}

.chat-message { display: flex; width: 100%; }
.chat-message-other { justify-content: flex-start; }
.chat-message-mine { justify-content: flex-end; }

.chat-message-bubble {
    max-width: 78%;
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    position: relative;
}
.chat-message-other .chat-message-bubble { background: var(--bg-2); border: 1px solid var(--border-subtle); border-bottom-left-radius: 3px; }
.chat-message-mine .chat-message-bubble { background: rgba(168,85,247,0.18); border: 1px solid rgba(168,85,247,0.3); border-bottom-right-radius: 3px; }

.chat-message-username { font-weight: 600; font-size: 0.72rem; display: block; margin-bottom: 2px; opacity: 0.75; }
.chat-message-other .chat-message-username { color: var(--gold); }
.chat-message-mine .chat-message-username { color: var(--accent-light); }

.chat-message-text { color: var(--text-1); font-size: 0.83rem; line-height: 1.4; word-wrap: break-word; display: block; }

.chat-message-system {
    color: var(--text-2);
    font-size: 0.73rem;
    font-style: italic;
    text-align: center;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    padding: 3px 8px;
    align-self: center;
    max-width: 90%;
    border: 1px solid var(--border-subtle);
}

.chat-input {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-1);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.chat-input input {
    flex: 1;
    padding: 0.45rem 0.65rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.83rem;
    transition: border-color 0.2s;
}
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input input::placeholder { color: var(--text-3); }

.expand-chat-btn {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 0.6rem 0.25rem;
    background: var(--bg-1);
    border: none;
    border-left: 1px solid var(--border-subtle);
    color: var(--text-3);
    font-family: var(--font);
    font-size: 0.7rem;
    cursor: pointer;
    letter-spacing: 1px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.expand-chat-btn:hover { background: var(--bg-2); color: var(--text-1); }

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: var(--bg-2);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(168,85,247,0.12);
}
.modal-content h2 { font-size: 1.2rem; font-weight: 700; color: var(--text-1); margin-bottom: 0.75rem; }
.modal-content p { color: var(--text-2); font-size: 0.85rem; margin-bottom: 1rem; }
.modal-content input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: var(--font);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}
.modal-content input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(168,85,247,0.15); }

/* Autoplay Countdown */
.autoplay-countdown {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.countdown-content {
    text-align: center;
    padding: 2.5rem;
    background: var(--bg-2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(168,85,247,0.2);
    max-width: 420px;
    width: 90%;
}
.countdown-content h3 { font-size: 1.3rem; font-weight: 700; color: var(--accent-light); margin-bottom: 0.5rem; }
.countdown-content p { color: var(--text-2); font-size: 0.95rem; margin-bottom: 1.5rem; }
.countdown-timer { margin: 1.5rem 0; }
.countdown-timer span {
    font-size: 4.5rem;
    font-weight: 700;
    color: var(--accent);
    display: inline-block;
    animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: 0.85; } }
#cancelAutoplayBtn { margin-top: 0.5rem; padding: 0.6rem 1.8rem; font-size: 0.9rem; font-weight: 700; }

/* Landing / index page */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem; }
header { text-align: center; margin-bottom: 2rem; padding: 2.5rem 0 1.5rem; }
header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}
header p { color: var(--text-2); font-size: 1rem; }

.action-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.card {
    background: var(--bg-2);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow); transform: translateY(-3px); }
.card h2 { color: var(--accent-light); margin-bottom: 0.75rem; font-size: 1.4rem; }
.card p { color: var(--text-2); margin-bottom: 1.2rem; font-size: 0.9rem; }
.card input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-1);
    font-family: var(--font);
    transition: border-color 0.2s;
}
.card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(168,85,247,0.15); }
.card input::placeholder { color: var(--text-3); }

/* Version watermark */
.version-watermark { font-size: 0.68rem; color: var(--text-3); text-decoration: none; transition: color 0.2s; }
.version-watermark:hover { color: var(--text-2); }

/* Collapsed footer expands video */
.video-player:has(.video-meta.collapsed) #videoElement { max-height: 90vh; }

/* Responsive */
@media (max-width: 1024px) {
    .video-area { flex-direction: column; }
    .video-meta-row { flex-direction: column; gap: 0.75rem; }
    .stream-controls { flex-wrap: wrap; }
    .stream-control-group { flex: 1; min-width: 130px; }
    .chat-container { width: 100% !important; min-width: 100%; max-width: 100%; height: 220px; border-left: none; border-top: 1px solid var(--border-subtle); }
    .chat-resize-handle { display: none; }
    #videoElement { max-height: 45vh; }
}
@media (max-width: 768px) {
    .library-sidebar { position: absolute; height: calc(100% - 48px); z-index: 100; }
    .library-sidebar.hidden { transform: translateX(-100%); width: 320px; min-width: 320px; opacity: 0; }
    .party-header { padding: 0 0.6rem; gap: 0.5rem; }
    .navbar-brand-name { display: none; }
}
