:root {
    /* Apple Dark Mode Palette */
    --bg-main: #000000;
    --bg-sidebar: rgba(28, 28, 30, 0.6);
    --bg-panel: rgba(44, 44, 46, 0.6);
    --accent: #0A84FF; /* Apple System Blue */
    --accent-hover: #007AFF;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93; /* Apple System Gray */
    --border: rgba(255, 255, 255, 0.1);
    
    /* Chat Bubbles */
    --chat-bubble-own: #0A84FF;
    --chat-bubble-other: rgba(44, 44, 46, 0.8);
    
    /* Apple Effects */
    --glass-blur: blur(50px) saturate(200%);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100dvh;
    overflow: hidden;
    letter-spacing: -0.015em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* Overlays */
.overlay-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: var(--glass-blur);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.prompt-card {
    background: rgba(28, 28, 30, 0.7);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
    backdrop-filter: var(--glass-blur);
}

.prompt-card h1 { 
    margin-bottom: 0.5rem; 
    font-size: 1.8rem; 
    font-weight: 700; 
}
.prompt-card p { 
    color: var(--text-secondary); 
    margin-bottom: 2rem; 
    font-size: 1rem; 
}

.overlay-screen input {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    margin-bottom: 1.2rem;
    outline: none;
    transition: 0.2s ease;
}

.overlay-screen input:focus { 
    border-color: var(--accent);
    background: rgba(255,255,255,0.08);
}

.primary-btn {
    width: 100%;
    padding: 1rem 1.2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    font-size: 1.05rem;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover { 
    background: var(--accent-hover); 
    transform: scale(0.98);
}

.secondary-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-primary);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.secondary-btn:hover { background: rgba(255,255,255,0.15); }

/* Main Layout */
.main-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000000;
    position: relative;
    z-index: 2;
}

.video-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    overflow: hidden;
}

video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-click-shield { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; display: none; }
body:not(.is-admin) .video-click-shield { display: block; }

.guest-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 200;
}

.custom-fs-btn {
    background: rgba(28, 28, 30, 0.6);
    backdrop-filter: var(--glass-blur);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}
.custom-fs-btn:hover { background: rgba(44, 44, 46, 0.8); }

.status-indicator {
    position: absolute;
    top: 24px;
    left: 24px;
    background: rgba(28, 28, 30, 0.6);
    backdrop-filter: var(--glass-blur);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
    opacity: 0;
    z-index: 200;
    transition: opacity 0.3s;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem 0;
    gap: 1.5rem;
}

.tab-btn {
    padding: 1rem 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: 0.2s;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
    font-weight: 600;
}

.sidebar-content {
    display: none;
    flex: 1;
    padding: 1.5rem;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-content.active { display: flex; }

/* Admin Panel */
.admin-controls-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: transparent;
}

.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

.input-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    color: white;
    outline: none;
    font-size: 14px;
    transition: 0.2s;
}

.input-row input:focus { 
    background: rgba(255, 255, 255, 0.08); 
    border-color: rgba(255, 255, 255, 0.2); 
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    width: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.2); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Chat */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 5px;
    margin-bottom: 1rem;
}

.msg {
    padding: 10px 14px;
    background: var(--chat-bubble-other);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 0.95rem;
    max-width: 85%;
    line-height: 1.4;
    align-self: flex-start;
}

.msg.own {
    align-self: flex-end;
    background: var(--chat-bubble-own);
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    color: #FFFFFF;
}

.msg .name {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.msg.own .name { display: none; }

.chat-input-area {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 6px;
    border-radius: 20px;
}

.chat-input-area input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.6rem 0.8rem;
    color: white;
    outline: none;
    font-size: 15px;
}

.chat-input-area .icon-btn {
    border-radius: 16px;
    background: var(--accent);
}
.chat-input-area .icon-btn:hover {
    background: var(--accent-hover);
}

/* Participants */
.participants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.online { background: #34C759; } /* iOS Green */
.status-dot.offline { background: #8E8E93; }

.status-text {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Movies */
.movie-card {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    background: transparent;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.2s;
}
.movie-card:hover {
    background: rgba(255,255,255,0.08);
}
.movie-card img {
    width: 48px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
    background: #1c1c1e;
}
.movie-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.movie-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.movie-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }
.movie-desc { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Invite */
.invite-section {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    background: transparent;
}
.invite-section p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }

/* Visibility Classes */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: block !important; }
.guest-only { display: none !important; }
body:not(.is-admin) .guest-only { display: flex !important; }

/* Фикс для полноэкранного режима на iPhone (fake-fullscreen) */
.video-wrapper.fake-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 9999 !important;
    background: #000 !important;
    aspect-ratio: auto !important;
}

/* Responsive Mobile */
@media (max-width: 900px) {
    .main-layout { flex-direction: column; }
    
    .content-area { 
        height: auto; 
        flex: none; 
        z-index: 10;
        background: #000;
    }
    
    .video-wrapper { 
        width: 100%; 
        aspect-ratio: 16/9; 
    }
    
    .sidebar { 
        width: 100%; 
        flex: 1; 
        height: 0; 
        border-left: none; 
        border-top: 1px solid rgba(255,255,255,0.05);
    }
}
