/* ==========================================================================
   Syncnema 🍿 - Material 3 Expressive Design System
   ========================================================================== */

:root {
    /* M3 Dark Surfaces */
    --md-sys-color-surface: #090C10;
    --md-sys-color-surface-dim: #06090D;
    --md-sys-color-surface-container-lowest: #0C1017;
    --md-sys-color-surface-container-low: #131822;
    --md-sys-color-surface-container: #1A212E;
    --md-sys-color-surface-container-high: #232B3B;
    --md-sys-color-surface-container-highest: #2E374A;

    /* M3 Outlines & Dividers */
    --md-sys-color-outline: rgba(255, 255, 255, 0.12);
    --md-sys-color-outline-variant: rgba(255, 255, 255, 0.06);

    /* M3 Expressive Accents */
    --md-sys-color-primary: #38bdf8;
    --md-sys-color-primary-container: #082f49;
    --md-sys-color-on-primary: #082f49;
    --md-sys-color-on-primary-container: #e0f2fe;

    --md-sys-color-secondary: #f59e0b;
    --md-sys-color-secondary-container: #451a03;
    --md-sys-color-on-secondary-container: #fef3c7;

    --md-sys-color-tertiary: #ef4444;
    --md-sys-color-tertiary-container: #450a0a;
    --md-sys-color-on-tertiary-container: #fee2e2;

    --md-sys-color-on-surface: #f1f5f9;
    --md-sys-color-on-surface-variant: #94a3b8;
}

/* M3 Expressive Surface Containers (Lightweight, No GPU-draining heavy blur) */
.m3-surface-low {
    background-color: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
}
.m3-surface-container {
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.m3-surface-high {
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* M3 Buttons & FABs */
.m3-pill-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    min-height: 48px;
    min-width: 48px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), background-color 0.15s ease, border-color 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.m3-pill-btn:active {
    transform: scale(0.94);
}
.m3-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.25rem;
    min-height: 48px;
    min-width: 48px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.m3-fab:active {
    transform: scale(0.92);
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--md-sys-color-surface, #060911);
    color: #f8fafc;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar - Frost Glass Minimal */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Ambient Background Lights */
.ambient-glow-1 {
    position: fixed;
    top: -10%;
    left: 15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    filter: blur(60px);
}
.ambient-glow-2 {
    position: fixed;
    bottom: -15%;
    right: 10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.07) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
}

/* ==========================================================================
   VisionOS Liquid Glass Core Classes
   ========================================================================== */

/* Floating Island Container - Material 3 Expressive Tonal Surface */
.glass-island {
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.glass-island:hover {
    background-color: var(--md-sys-color-surface-container-high);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
}

/* Cinejoy Style Pill Buttons - M3 Expressive Pill Tokens */
.glass-btn {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--md-sys-color-outline);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    color: #e2e8f0;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}
.glass-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.glass-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.09);
}

/* Accent Pill States (Cinejoy Theme Accents) */
.glass-btn-primary {
    background: rgba(6, 182, 212, 0.18);
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: #38bdf8;
    box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
}
.glass-btn-primary:hover {
    background: rgba(6, 182, 212, 0.3);
    border-color: rgba(56, 189, 248, 0.7);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.35), inset 0 1px 0 0 rgba(255, 255, 255, 0.3);
}

.glass-btn-amber {
    background: rgba(245, 158, 11, 0.16);
    border: 1px solid rgba(245, 158, 11, 0.38);
    color: #fbbf24;
}
.glass-btn-amber:hover {
    background: rgba(245, 158, 11, 0.28);
    border-color: rgba(245, 158, 11, 0.7);
    color: #ffffff;
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.3);
}

.glass-btn-green {
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.38);
    color: #4ade80;
}
.glass-btn-green:hover {
    background: rgba(34, 197, 94, 0.28);
    border-color: rgba(34, 197, 94, 0.7);
    color: #ffffff;
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.3);
}

/* Cinejoy Glass Inputs */
.glass-input, #partner-id-input {
    min-width: 0 !important;
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    transition: all 0.2s ease !important;
}
.glass-input::placeholder, #partner-id-input::placeholder {
    color: rgba(255, 255, 255, 0.45) !important;
}
.glass-input:focus, #partner-id-input:focus {
    background: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(56, 189, 248, 0.55) !important;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    outline: none !important;
}

/* Cinejoy Style Glass Modals */
.modal-overlay {
    background-color: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.modal-content {
    background: rgba(15, 17, 23, 0.86);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 
        0 25px 60px -10px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.18);
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 1.5rem;
}

/* Chat Sidebar - Translucent Floating Frosted Glass Window */
#chat-sidebar {
    position: absolute;
    right: 4.75rem;
    top: 4.75rem;
    bottom: 5.5rem;
    width: 330px;
    max-width: calc(100vw - 5.5rem);
    background: rgba(10, 15, 26, 0.32);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 1.5rem;
    box-shadow: 
        0 20px 50px -10px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.22);
    transform: translateX(0);
    opacity: 1;
    z-index: 40;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, transparent 0px, rgba(0, 0, 0, 0.3) 12px, rgba(0, 0, 0, 0.85) 28px, black 40px, black 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0px, rgba(0, 0, 0, 0.3) 12px, rgba(0, 0, 0, 0.85) 28px, black 40px, black 100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, mask-image 0.45s ease, -webkit-mask-image 0.45s ease;
    pointer-events: auto;
}
#chat-sidebar.scrolled-history {
    mask-image: linear-gradient(to bottom, black 0%, black 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 100%);
}
.sidebar-closed {
    transform: translateX(calc(100% + 5rem)) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Scrollbar killer for no-scrollbar elements */
.no-scrollbar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
.no-scrollbar {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

/* Legacy button labels hiding */
#sync-toggle-btn span,
#sync-btn-label {
    display: none !important;
}
#user-profile-btn span,
#spectators-trigger-btn span {
    display: inline-flex !important;
}

@media (max-width: 768px), (max-height: 500px) {
    /* Ultra-Compact Top Bar on Mobile */
    #top-bar {
        top: 0.3rem !important;
        padding-left: 0.3rem !important;
        padding-right: 0.3rem !important;
        gap: 0.2rem !important;
    }
    #top-bar .glass-island {
        padding: 0.15rem 0.35rem !important;
        height: 1.875rem !important;
        gap: 0.25rem !important;
    }
    #tutorial-btn {
        padding: 0.15rem !important;
    }
    #tutorial-btn svg {
        width: 0.95rem !important;
        height: 0.95rem !important;
    }
    #status-container {
        padding: 0.15rem 0.35rem !important;
        height: 1.5rem !important;
    }
    #status-text {
        display: none !important;
        font-size: 0.65rem !important;
        white-space: nowrap !important;
    }
    #status-container.show-status #status-text {
        display: inline !important;
    }
    #video-modal-trigger,
    #sub-modal-trigger,
    #sync-toggle-btn,
    #share-room-btn,
    #donate-trigger-btn-mobile {
        width: 1.625rem !important;
        height: 1.625rem !important;
        padding: 0 !important;
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 9999px !important;
        flex-shrink: 0 !important;
    }
    #video-modal-trigger svg,
    #sub-modal-trigger svg,
    #sync-toggle-btn svg,
    #share-room-btn svg,
    #donate-trigger-btn-mobile svg {
        width: 0.85rem !important;
        height: 0.85rem !important;
    }
    #my-id {
        font-size: 0.65rem !important;
        max-width: 38px !important;
    }
    #partner-id-input {
        width: 2.75rem !important;
        height: 1.5rem !important;
        font-size: 0.65rem !important;
        padding: 0 0.2rem !important;
    }
    #connect-btn,
    #disconnect-btn {
        width: 1.625rem !important;
        height: 1.625rem !important;
        padding: 0 !important;
        min-width: 0 !important;
    }
    #connect-btn svg,
    #disconnect-btn svg {
        width: 0.75rem !important;
        height: 0.75rem !important;
    }

    /* Floating Side Dock Buttons on Mobile */
    #toggle-chat-btn,
    #custom-fs-btn,
    #reaction-toggle-btn {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }
    #toggle-chat-btn svg,
    #custom-fs-btn svg,
    #reaction-toggle-btn svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    .absolute.top-20.right-4,
    #right-floating-controls {
        top: 2.5rem !important;
        right: 0.35rem !important;
        gap: 0.3rem !important;
    }
    .absolute.left-4.top-20,
    #left-floating-controls {
        top: 2.5rem !important;
        left: 0.35rem !important;
    }

    /* Modern Responsive Drawer on Mobile */
    #chat-sidebar {
        right: 0.6rem !important;
        left: 0.6rem !important;
        top: 3.5rem !important;
        bottom: 0.75rem !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: calc(100dvh - 4.25rem) !important;
        border-radius: 1.25rem !important;
        mask-image: none !important;
        -webkit-mask-image: none !important;
        background: rgba(10, 15, 26, 0.92) !important;
        box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.9) !important;
    }
    #chat-sidebar.scrolled-history {
        mask-image: none !important;
        -webkit-mask-image: none !important;
    }
    #chat-sidebar > div:first-child {
        padding: 0.5rem 0.75rem !important;
    }
    #close-sidebar-btn {
        width: 1.75rem !important;
        height: 1.75rem !important;
        font-size: 1.1rem !important;
    }
    #chat-messages {
        padding: 0.6rem 0.75rem !important;
        gap: 0.5rem !important;
    }
    #chat-messages > div {
        padding: 0.45rem 0.75rem !important;
        font-size: 0.8rem !important;
        line-height: 1.25rem !important;
        margin-bottom: 0.35rem !important;
        border-radius: 0.75rem !important;
    }
    #chat-input {
        height: 2.25rem !important;
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    #emoji-btn {
        width: 2.25rem !important;
        height: 2.25rem !important;
    }
    #emoji-btn svg {
        width: 1.1rem !important;
        height: 1.1rem !important;
    }
    #chat-send {
        height: 2.25rem !important;
        padding: 0.35rem 0.85rem !important;
        font-size: 0.75rem !important;
    }
    #chat-send svg {
        width: 0.65rem !important;
        height: 0.65rem !important;
    }

    /* Modals on Mobile */
    .modal-content {
        padding: 1rem !important;
        max-width: 92vw !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        border-radius: 1rem !important;
    }
}

/* Floating controls smooth transition */
#left-floating-controls,
#right-floating-controls {
    transition: top 0.3s cubic-bezier(0.16, 1, 0.3, 1), right 0.3s ease, left 0.3s ease;
}

/* Fullscreen stick-to-top controls */
:fullscreen #right-floating-controls,
.is-fullscreen #right-floating-controls {
    top: 1.25rem !important;
    right: 1.25rem !important;
}

:fullscreen #left-floating-controls,
.is-fullscreen #left-floating-controls {
    top: 1.25rem !important;
    left: 1.25rem !important;
}

:fullscreen #chat-sidebar,
.is-fullscreen #chat-sidebar {
    position: absolute;
    right: 4.75rem;
    top: 4.75rem;
    bottom: 5.5rem;
    z-index: 60;
}

:fullscreen #catch-up-btn,
.is-fullscreen #catch-up-btn {
    bottom: 5.5rem !important;
    z-index: 60 !important;
}

@media (max-width: 768px), (max-height: 500px) {
    :fullscreen #right-floating-controls,
    .is-fullscreen #right-floating-controls {
        top: 0.4rem !important;
        right: 0.4rem !important;
    }

    :fullscreen #left-floating-controls,
    .is-fullscreen #left-floating-controls {
        top: 0.4rem !important;
        left: 0.4rem !important;
    }

    :fullscreen #chat-sidebar,
    .is-fullscreen #chat-sidebar {
        right: 2.35rem !important;
        bottom: 4.5rem !important;
        top: auto !important;
        width: 235px !important;
        max-width: calc(100vw - 2.85rem) !important;
        height: 275px !important;
        max-height: min(65vh, calc(100vh - 5.5rem)) !important;
    }
}

/* Chat Header and Messages inside Translucent Sidebar */
#chat-sidebar > div:first-child {
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#chat-messages {
    display: flex;
    flex-direction: column;
    mask-image: none;
    -webkit-mask-image: none;
}
#chat-messages > :first-child {
    margin-top: auto !important;
}
#chat-top-fade {
    display: none;
}

/* Toast Notifications */
@keyframes fadeInSlide {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast-msg {
    animation: fadeInSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    background: rgba(15, 23, 42, 0.75) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
}

/* Floating Status Badges */
.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.st-red {
    background-color: #f87171;
    box-shadow: 0 0 8px #f87171;
}
.st-yellow {
    background-color: #fbbf24;
    box-shadow: 0 0 8px #fbbf24;
    animation: pulse 1s infinite;
}
.st-green {
    background-color: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}
.st-blue {
    background-color: #38bdf8;
    box-shadow: 0 0 10px #38bdf8;
}
@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

/* Video Subtitles */
video::cue {
    font-family: 'Vazirmatn', sans-serif;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    font-size: 1.15em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    border-radius: 6px;
    padding: 2px 8px;
}

/* Interactive Timestamps in Chat */
.timestamp-chip {
    display: inline-block;
    direction: ltr;
    unicode-bidi: embed;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 9999px;
    padding: 1px 7px;
    margin: 0 2px;
    font-family: monospace;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}
.timestamp-chip:hover {
    background: rgba(56, 189, 248, 0.35);
    color: #ffffff;
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
    transform: scale(1.04);
}

/* Floating Smart Attributed Reactions Animation */
@keyframes floatSmartPill {
    0% {
        transform: translateY(15px) scale(0.6);
        opacity: 0;
    }
    15% {
        transform: translateY(-20px) scale(1.08);
        opacity: 1;
    }
    30% {
        transform: translateY(-45px) scale(1);
        opacity: 0.95;
    }
    75% {
        transform: translateY(-130px) scale(0.96);
        opacity: 0.85;
    }
    100% {
        transform: translateY(-210px) scale(0.7);
        opacity: 0;
    }
}

.reaction-pill-anim {
    position: absolute;
    animation: floatSmartPill 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
    z-index: 45;
}

.reaction-pill-content {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.6rem 0.25rem 0.35rem;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9999px;
    box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.65), 0 0 15px rgba(255, 255, 255, 0.05);
}

.reaction-pill-avatar {
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: 1.5px solid;
    background: rgba(255, 255, 255, 0.05);
}

.reaction-pill-name {
    font-size: 0.75rem;
    font-weight: 700;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reaction-pill-emoji {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

.reaction-emoji-only {
    font-size: 2.75rem;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
}

.reaction-anim {
    position: absolute;
    animation: floatSmartPill 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none;
    font-size: 3rem;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
    z-index: 45;
}

emoji-picker {
    position: absolute;
    bottom: 75px;
    left: 10px;
    z-index: 60;
    --emoji-font-family: 'Vazirmatn';
    height: 320px;
    width: calc(100% - 20px);
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Landscape Mode Prompt */
#landscape-warning { display: none; }
@media only screen and (max-width: 768px) and (orientation: portrait) {
    #landscape-warning { display: flex; }
    #landscape-warning.hidden-force { display: none !important; }
}
@keyframes rotate-phone {
    0%, 10% { transform: rotate(0deg); }
    40%, 60% { transform: rotate(90deg); }
    90%, 100% { transform: rotate(0deg); }
}
.phone-icon {
    font-size: 4rem;
    animation: rotate-phone 3s infinite ease-in-out;
}

/* ==========================================================================
   Mobile M3 Bottom Bar & Safe-Area Adjustments
   ========================================================================== */
#m3-bottom-bar {
    position: fixed;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    right: 0.75rem;
    height: 60px;
    z-index: 35;
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 9999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s ease;
}

#m3-bottom-bar .m3-pill-btn,
#m3-bottom-bar .m3-fab {
    min-height: 48px;
    min-width: 48px;
}

@media (min-width: 768px) {
    #m3-bottom-bar,
    #m3-top-chip,
    #m3-emoji-ribbon {
        display: none !important;
    }
}

/* 1-Tap Emoji Ribbon */
#m3-emoji-ribbon {
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s ease;
}

.m3-quick-emoji {
    border: none;
    outline: none;
    cursor: pointer;
    background: transparent;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.m3-quick-emoji:active {
    transform: scale(1.35);
}

/* ==========================================================================
   Floating Live Chat Stream Overlay
   ========================================================================== */
#chat-stream-overlay {
    z-index: 25;
}

@keyframes streamSlideIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes streamFadeOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-8px) scale(0.92);
    }
}

.chat-stream-msg {
    animation: streamSlideIn 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background-color 0.15s ease;
    max-width: 100%;
}

.chat-stream-msg.fading-out {
    animation: streamFadeOut 0.4s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.chat-stream-msg:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Material 3 Modal Bottom Sheet System (< 768px)
   ========================================================================== */
.m3-drag-handle {
    width: 44px;
    height: 4px;
    background-color: var(--md-sys-color-outline);
    border-radius: 9999px;
    margin: 0 auto 1.25rem auto;
    display: none;
}

@keyframes sheet-open {
    0% {
        transform: translateY(100%);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal-content.m3-bottom-sheet {
        width: 100% !important;
        max-width: 100% !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 32px !important;
        border-top-right-radius: 32px !important;
        max-height: 85dvh !important;
        overflow-y: auto !important;
        animation: sheet-open 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)) !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        background-color: var(--md-sys-color-surface-container) !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8) !important;
    }

    .m3-drag-handle {
        display: block;
    }
}

/* ==========================================================================
   Landscape Cinema Mode Auto-Fullscreen & Auto-Hide Rules
   ========================================================================== */
@media (orientation: landscape) and (max-height: 500px) {
    #top-bar,
    #m3-bottom-bar,
    #m3-top-chip {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    body.show-controls #top-bar,
    body:hover #top-bar,
    body.show-controls #m3-bottom-bar,
    body.show-controls #m3-top-chip {
        opacity: 1;
        pointer-events: auto;
    }

    #m3-emoji-ribbon {
        bottom: 0.75rem !important;
        left: 0.75rem !important;
        right: auto !important;
        transform: scale(0.9);
        transform-origin: bottom left;
    }

    #chat-stream-overlay {
        bottom: 1rem !important;
        right: 1rem !important;
    }
}





