:root {
    --primary: #ff003c;
    --primary-glow: rgba(255, 0, 60, 0.35);
    --primary-dim: rgba(255, 0, 60, 0.12);
    --accent: #ff3366;
    --bg-deep: #040406;
    --bg-pane: #0c0c10;
    --bg-card: #131318;
    --bg-input: #18181f;
    --bg-hover: #1e1e28;
    --text: #ffffff;
    --text-sub: #aaaabc;
    --text-muted: #666677;
    --border: rgba(255, 255, 255, 0.07);
    --border-soft: rgba(255, 255, 255, 0.04);
    --glass: rgba(255, 255, 255, 0.025);
    --radius-xl: 28px;
    --radius-l: 18px;
    --radius-m: 12px;
    --radius-s: 8px;
    --shadow-deep: 0 40px 80px rgba(0, 0, 0, 0.95);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

html,
body {
    min-height: 100vh;
    background: var(--bg-deep);
    color: var(--text);
    overflow-x: hidden;
}

/* ===== ANIMATED BACKGROUND ===== */
.mesh-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 70% 50% at 15% 10%, rgba(255, 0, 60, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 85% 85%, rgba(120, 0, 255, 0.04) 0%, transparent 55%);
    animation: meshShift 18s ease-in-out infinite alternate;
}

@keyframes meshShift {
    from {
        opacity: 0.8;
    }

    to {
        opacity: 1;
    }
}

.particle-field {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle-field span {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 0, 60, 0.5);
    border-radius: 50%;
    animation: particleDrift linear infinite;
}

@keyframes particleDrift {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translateY(-10vh) scale(1.5);
        opacity: 0;
    }
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-deep);
}

.login-card {
    width: 90%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 56px 44px;
    box-shadow: var(--shadow-deep), 0 0 0 1px rgba(255, 255, 255, 0.03);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.6s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 120px;
    background: var(--primary);
    filter: blur(90px);
    opacity: 0.18;
    pointer-events: none;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.18;
    }

    50% {
        opacity: 0.28;
    }
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-card h1 {
    text-align: center;
    font-size: 3.2rem;
    font-weight: 900;
    letter-spacing: -3px;
    line-height: 1;
    background: linear-gradient(135deg, #fff 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 48px;
    letter-spacing: 0.4px;
}

.login-hint {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 12px;
}

.login-hint strong {
    color: rgba(255, 0, 60, 0.7);
}

.input-group {
    margin-bottom: 22px;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-sub);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-field {
    width: 100%;
    padding: 16px 48px 16px 48px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    color: var(--text);
    font-size: 1rem;
    transition: var(--transition);
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.pwd-toggle {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 4px;
    transition: var(--transition);
}

.pwd-toggle:hover {
    color: var(--text);
}

.pwd-toggle svg {
    width: 18px;
    height: 18px;
}

.action-btn {
    width: 100%;
    margin-top: 10px;
    padding: 18px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-m);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 12px 32px var(--primary-glow);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

.action-btn:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 18px 40px var(--primary-glow);
}

.action-btn:active {
    transform: translateY(0);
}

#error-msg {
    text-align: center;
    margin-top: 14px;
    font-size: 0.82rem;
    color: var(--primary);
    min-height: 20px;
}

/* ===== MAIN APP LAYOUT ===== */
#player-screen {
    height: 100vh;
    overflow: hidden;
}

#player-screen.hidden {
    display: none;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ===== THEATER STAGE ===== */
.theater-stage {
    flex: 0 0 auto;
    height: 55vw;
    max-height: 50vh;
    background: #000;
    position: relative;
    z-index: 10;
    overflow: hidden;
}

/* ===== TOP BAR ===== */
.stage-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
    backdrop-filter: blur(4px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    white-space: nowrap;
    color: white;
    opacity: 0.85;
}

.topbar-input-row {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.url-input {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 40px;
    color: white;
    font-size: 0.85rem;
    transition: var(--transition);
}

.url-input:focus {
    border-color: rgba(255, 0, 60, 0.5);
    background: rgba(255, 255, 255, 0.09);
}

.url-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.topbar-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-btn svg {
    width: 16px;
    height: 16px;
}

.topbar-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.topbar-btn.accent {
    background: var(--primary);
    border-color: transparent;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.topbar-btn.accent:hover {
    background: var(--accent);
}

.status-pill {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 5px 10px;
    border-radius: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid transparent;
    white-space: nowrap;
}

.status-pill.connected {
    color: #00ffaa;
    border-color: rgba(0, 255, 170, 0.3);
}

.status-pill.syncing {
    color: #ffcc00;
    border-color: rgba(255, 204, 0, 0.3);
}

.status-pill.offline {
    color: var(--text-muted);
    border-color: var(--border);
}

/* ===== VIDEO AREA ===== */
.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

#main-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.video-placeholder.hidden {
    display: none;
}

.video-placeholder svg {
    width: 80px;
    height: 80px;
    opacity: 0.6;
}

.video-placeholder p {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    max-width: 220px;
}

/* ===== HUD ===== */
.hud {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 45%);
    opacity: 0;
    transition: opacity var(--transition);
    z-index: 20;
}

.video-wrapper:hover .hud,
.video-wrapper.hud-visible .hud {
    opacity: 1;
}

.hud-time {
    display: none;
    /* Only shown on very small layouts if needed */
}

/* SEEK BAR */
.seek-container {
    padding: 0 16px 8px;
    cursor: pointer;
}

.seek-track {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    transition: height var(--transition);
}

.seek-container:hover .seek-track {
    height: 6px;
}

.seek-buffer,
.seek-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 4px;
}

.seek-buffer {
    background: rgba(255, 255, 255, 0.18);
    width: 0%;
}

.seek-fill {
    background: var(--primary);
    width: 0%;
    box-shadow: 0 0 8px rgba(255, 0, 60, 0.7);
}

.seek-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    border: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.seek-container:hover .seek-thumb {
    opacity: 1;
}

/* ─── NEW TMDB UI EXTENSIONS ─── */
.embed-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
}

/* Hide obsolete HUD */
.hud {
    display: none !important;
}

/* Server selector */
.server-selector-overlay {
    margin: 15px 0;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sel-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.srv-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.srv-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.srv-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* HUD CONTROLS ROW */
.hud-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 14px;
    gap: 8px;
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
}

.hud-btn svg {
    width: 22px;
    height: 22px;
}

.hud-btn:hover {
    color: var(--primary);
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

.volume-cluster {
    display: flex;
    align-items: center;
    gap: 4px;
}

.volume-range {
    -webkit-appearance: none;
    appearance: none;
    width: 72px;
    height: 3px;
    background: linear-gradient(to right, var(--primary) var(--vol, 100%), rgba(255, 255, 255, 0.2) var(--vol, 100%));
    border-radius: 3px;
    cursor: pointer;
    outline: none;
}

.volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.hud-time-inline {
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    padding: 0 4px;
    font-variant-numeric: tabular-nums;
}

/* ===== UPLOAD OVERLAY ===== */
#upload-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 4, 6, 0.82);
    backdrop-filter: blur(16px);
}

#upload-overlay.hidden {
    display: none;
}

.upload-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 48px;
    box-shadow: var(--shadow-deep);
    animation: fadeUp 0.3s ease forwards;
}

.upload-ring {
    width: 120px;
    height: 120px;
    position: relative;
}

.upload-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 5;
}

.ring-bar {
    fill: none;
    stroke: var(--primary);
    stroke-width: 5;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
    filter: drop-shadow(0 0 6px var(--primary));
}

.upload-pct {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 900;
    color: white;
}

.upload-filename {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.upload-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.upload-cancel-btn {
    margin-top: 8px;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--text-sub);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.upload-cancel-btn:hover {
    background: rgba(255, 0, 60, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== PiP ===== */
#pip-layer {
    position: absolute;
    top: 60px;
    right: 14px;
    width: 150px;
    aspect-ratio: 16/9;
    border-radius: 12px;
    border: 2px solid var(--primary);
    background: #000;
    overflow: hidden;
    z-index: 25;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.8);
}

#pip-layer.hidden {
    display: none;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#local-video {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 42px;
    height: 32px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    object-fit: cover;
}

/* ===== SIDEBAR ===== */
.sidebar {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-pane);
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--text-sub);
    text-transform: uppercase;
}

.online-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00ffaa;
    box-shadow: 0 0 6px rgba(0, 255, 170, 0.6);
    animation: dotBlink 2s ease-in-out infinite;
}

@keyframes dotBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* PARTICIPANTS */
.participants-row {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.participants-row::-webkit-scrollbar {
    display: none;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-sub);
}

.user-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.user-pill.me {
    border-color: var(--primary);
    color: var(--primary);
}

.user-pill.me::before {
    background: var(--primary);
}

/* CHAT */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-window::-webkit-scrollbar {
    width: 3px;
}

.chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-row {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.chat-row.row-me {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-row.row-them {
    align-self: flex-start;
    align-items: flex-start;
}

.sender-name {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    padding: 0 6px;
}

.bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.row-them .bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.row-me .bubble {
    background: var(--primary);
    border-bottom-right-radius: 4px;
    box-shadow: 0 6px 18px rgba(255, 0, 60, 0.25);
}

.sys-msg {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 4px 0;
    font-style: italic;
}

/* EMOJI ROW */
.emoji-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.emoji-btn {
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid transparent;
    user-select: none;
}

.emoji-btn:hover {
    transform: scale(1.35) rotate(8deg);
    border-color: var(--border);
    background: var(--bg-card);
}

/* CALL BAR */
.call-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.call-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.call-btn svg {
    width: 18px;
    height: 18px;
}

.call-btn:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.call-btn.active {
    background: var(--primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.call-btn.muted {
    background: rgba(255, 0, 60, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* CHAT INPUT */
.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 16px 20px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 12px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: white;
    font-size: 0.9rem;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}

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

.send-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.send-btn:hover {
    background: var(--accent);
    transform: scale(1.06);
}

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 900px) {
    #app-container {
        flex-direction: row;
    }

    .theater-stage {
        flex: 1;
        height: 100vh;
        max-height: 100vh;
    }

    .sidebar {
        width: 360px;
        border-top: none;
        border-left: 1px solid var(--border);
    }

    #pip-layer {
        width: 220px;
        top: 80px;
        right: 380px;
    }

    .stage-topbar {
        padding: 18px 24px;
        gap: 16px;
    }

    .topbar-brand {
        font-size: 0.9rem;
    }

    .url-input {
        font-size: 0.9rem;
    }

    .topbar-btn {
        width: 42px;
        height: 42px;
    }

    .topbar-btn svg {
        width: 18px;
        height: 18px;
    }

    .hud-controls {
        padding: 12px 20px 20px;
    }

    .seek-container {
        padding: 0 20px 10px;
    }

    .volume-range {
        width: 90px;
    }
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 12px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    box-shadow: var(--shadow-deep);
    animation: toastIn 0.3s ease forwards;
    white-space: nowrap;
}

.toast.hidden {
    display: none;
}

.toast.error {
    border-color: rgba(255, 0, 60, 0.4);
    color: var(--primary);
}

.toast.success {
    border-color: rgba(0, 255, 170, 0.3);
    color: #00ffaa;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== BLOOM EMOJI ===== */
.bloom-emoji {
    position: fixed;
    bottom: -80px;
    font-size: 5rem;
    pointer-events: none;
    z-index: 2000;
    animation: bloom 3.5s cubic-bezier(0.1, 0, 0.2, 1) forwards;
}

@keyframes bloom {
    0% {
        transform: translateY(0) scale(0.3);
        opacity: 0;
        filter: blur(8px);
    }

    20% {
        opacity: 1;
        filter: blur(0);
        transform: translateY(-28vh) scale(1.3);
    }

    80% {
        opacity: 0.5;
    }

    100% {
        transform: translateY(-105vh) scale(0.6);
        opacity: 0;
    }
}

/* ===== SIDEBAR TABS ===== */
.sidebar-head {
    flex-shrink: 0;
    padding: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-tabs {
    display: flex;
    flex: 1;
}

.stab {
    flex: 1;
    padding: 14px 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    letter-spacing: 0.3px;
}

.stab:hover {
    color: var(--text);
}

.stab.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

#panel-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

#panel-browse {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

#panel-browse.hidden {
    display: none;
}

/* ===== BROWSE PANEL ===== */
.browse-cats {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.browse-cats::-webkit-scrollbar {
    display: none;
}

.cat-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--text-sub);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

.browse-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.browse-search-input {
    flex: 1;
    padding: 9px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: white;
    font-size: 0.82rem;
    transition: var(--transition);
}

.browse-search-input:focus {
    border-color: var(--primary);
}

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

.browse-search-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.browse-search-btn svg {
    width: 16px;
    height: 16px;
}

.browse-search-btn:hover {
    background: var(--accent);
}

/* MOVIE GRID */
.movie-grid {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-content: start;
}

.movie-grid::-webkit-scrollbar {
    width: 3px;
}

.movie-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.browse-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.spin-ring {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.movie-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.movie-card:hover {
    border-color: rgba(255, 0, 60, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.movie-card:active {
    transform: translateY(0);
}

.movie-thumb {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
    background: var(--bg-pane);
}

.movie-thumb-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #1a1a24, #0d0d14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.movie-info {
    padding: 8px;
}

.movie-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-meta {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.movie-year {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.movie-badge {
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    background: var(--primary);
    color: white;
}

.movie-badge.cam {
    background: #ff8800;
}

.movie-badge.type-series {
    background: #6c55ff;
}

.movie-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.movie-card:hover .movie-play-overlay {
    opacity: 1;
}

.movie-play-overlay svg {
    width: 36px;
    height: 36px;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

.browse-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.browse-footer {
    padding: 10px;
    text-align: center;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.load-more-btn {
    padding: 10px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--text-sub);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.load-more-btn:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Movie detail loading spinner in video */
.movie-detail-loading {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.movie-detail-loading .spin-ring {
    width: 44px;
    height: 44px;
    border-width: 4px;
}

.movie-detail-loading p {
    color: var(--text-sub);
    font-size: 0.85rem;
}

/* ===== SERVER / AUDIO SELECTOR OVERLAY ===== */
.server-selector-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(12px);
    padding: 20px;
}

.sel-card {
    background: linear-gradient(145deg, #1a1a2e, #12121f);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    gap: 0;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
    position: relative;
}

.sel-thumb {
    width: 120px;
    flex-shrink: 0;
    object-fit: cover;
    display: block;
}

.sel-thumb-placeholder {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: #1a1a28;
}

.sel-info {
    flex: 1;
    padding: 18px 16px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sel-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.3;
}

.sel-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sel-btns {
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 200px;
    overflow-y: auto;
}

.srv-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}

.srv-btn:hover {
    background: var(--primary);
    border-color: transparent;
}

.srv-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}

.srv-tag {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.55);
    margin-left: auto;
    white-space: nowrap;
}

.srv-btn:hover .srv-tag {
    color: rgba(255, 255, 255, 0.85);
}

.sel-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sel-close:hover {
    background: var(--primary);
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;

}

/* =========================================================================
   YOUTUBE-STYLE REDESIGN OVERRIDES
   ========================================================================= */

body {
    background-color: #0f0f0f !important;
    color: #f1f1f1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Hide old elements */
.mesh-bg,
.particle-field,
#login-screen,
.sidebar,
#app-container>.theater-stage {
    display: none !important;
}

/* NAVBAR */
.yt-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #0f0f0f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 2000;
    box-sizing: border-box;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.nav-left {
    display: flex;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1.2rem;
    color: #fff;
    letter-spacing: -0.5px;
}

.search-box {
    display: flex;
    align-items: center;
    background: #121212;
    border: 1px solid #303030;
    border-radius: 40px;
    padding: 0;
    height: 40px;
    width: 100%;
    max-width: 500px;
    margin: 0 20px;
    overflow: hidden;
}

.search-box input {
    background: transparent;
    border: none;
    color: #fff;
    padding: 0 16px;
    height: 100%;
    flex: 1;
    outline: none;
    font-size: 1rem;
}

.search-box button {
    background: #222;
    border: none;
    border-left: 1px solid #303030;
    padding: 0 20px;
    height: 100%;
    color: #aaa;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-box button:hover {
    background: #303030;
    color: #fff;
}

/* CATEGORIES ROW */
.yt-categories {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    background-color: #0f0f0f;
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    z-index: 1000;
    box-sizing: border-box;
    border-bottom: 1px solid #272727;
}

.yt-categories::-webkit-scrollbar {
    display: none;
}

.cat-pill {
    background: #272727;
    color: #f1f1f1;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.2s;
}

.cat-pill:hover {
    background: #3f3f3f;
}

.cat-pill.active {
    background: #f1f1f1;
    color: #0f0f0f;
    font-weight: 500;
}

/* MAIN LAYOUT */
.yt-layout {
    margin-top: 120px;
    padding: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
}

#app-container {
    background: transparent;
    padding: 0;
}

/* PLAYER COLUMN */
.yt-player-column {
    flex: 2;
    min-width: 320px;
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-details {
    margin-top: 16px;
    padding-bottom: 24px;
}

.playing-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #fff;
}

.playing-meta {
    font-size: 0.85rem;
    color: #aaa;
    display: flex;
    gap: 12px;
    align-items: center;
}

.playing-desc {
    margin-top: 16px;
    background: #272727;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #f1f1f1;
    line-height: 1.5;
}

/* GRID COLUMN */
.yt-grid-column {
    flex: 1;
    min-width: 300px;
}

/* RE-STYLE MOVIE GRID for YouTube layout */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px 12px;
    padding: 0;
}

/* RE-STYLE MOVIE CARDS */
.movie-card {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    cursor: pointer;
    box-shadow: none;
    transition: none;
    padding: 0;
}

.movie-card:hover {
    transform: none;
    box-shadow: none;
}

.movie-thumb-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #222;
}

.movie-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.movie-card:hover .movie-thumb-wrap img {
    transform: scale(1.05);
}

.movie-info {
    padding: 12px 0 0 0;
    display: flex;
    flex-direction: column;
}

.movie-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.movie-meta {
    font-size: 0.85rem;
    color: #aaa;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.movie-badge {
    padding: 2px 6px;
    border-radius: 4px;
    background: #272727;
    color: #aaa;
    font-size: 0.75rem;
    font-weight: 600;
}

/* RESPONSIVE Adjustments */
@media (min-width: 1001px) {
    .yt-grid-column .movie-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .yt-grid-column .movie-card {
        display: flex;
        gap: 12px;
        align-items: flex-start;
    }

    .yt-grid-column .movie-thumb-wrap {
        width: 160px;
        flex-shrink: 0;
        aspect-ratio: 16 / 9;
    }

    .yt-grid-column .movie-info {
        padding: 0;
        padding-top: 4px;
        flex: 1;
    }
}

@media (max-width: 1000px) {
    .yt-layout {
        flex-direction: column;
    }

    .yt-player-column,
    .yt-grid-column {
        flex: 1 1 100%;
        min-width: 0;
    }
}

@media (max-width: 600px) {
    .yt-navbar {
        padding: 0 12px;
    }

    .search-box {
        margin: 0 10px;
        max-width: none;
    }

    .nav-logo span {
        display: none;
    }

    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px 8px;
    }

    .video-wrapper {
        border-radius: 0;
    }

    .yt-layout {
        padding: 0;
        width: 100%;
        margin-top: 110px;
    }

    .video-details,
    .yt-grid-column {
        padding: 0 16px;
        margin-top: 12px;
    }

    .yt-categories {
        top: 60px;
    }
}