/* ═══════════════════════════════════════════════════════════════════
   style.css — Watch Party | Premium Cinema + Cinnamoroll Theme
   ═══════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ════════════════════════════════════════════════════════════
   DESIGN TOKENS — Default (Cinema Dark)
   ════════════════════════════════════════════════════════════ */
:root {
    /* Backgrounds */
    --bg-primary:       #08080f;
    --bg-secondary:     #0e0e1a;
    --bg-card:          rgba(255, 255, 255, 0.03);
    --bg-card-hover:    rgba(255, 255, 255, 0.06);
    --bg-elevated:      rgba(20, 20, 35, 0.95);
    --bg-input:         rgba(255, 255, 255, 0.04);
    --bg-input-focus:   rgba(255, 255, 255, 0.07);

    /* Borders */
    --border-subtle:    rgba(255, 255, 255, 0.06);
    --border-default:   rgba(255, 255, 255, 0.08);
    --border-strong:    rgba(255, 255, 255, 0.14);
    --border-focus:     rgba(168, 85, 247, 0.5);

    /* Brand */
    --brand-primary:    #a855f7;
    --brand-secondary:  #6366f1;
    --brand-gradient:   linear-gradient(135deg, #a855f7 0%, #6366f1 50%, #8b5cf6 100%);
    --brand-glow:       rgba(168, 85, 247, 0.25);
    --brand-glow-lg:    rgba(168, 85, 247, 0.12);

    /* Accent */
    --accent:           #38bdf8;
    --accent-secondary: #22d3ee;
    --success:          #34d399;
    --warning:          #fbbf24;
    --error:            #f87171;

    /* Text */
    --text-primary:     #f8fafc;
    --text-secondary:   #94a3b8;
    --text-muted:       #64748b;
    --text-inverse:     #0f172a;

    /* Radii */
    --radius-sm:        8px;
    --radius-md:        12px;
    --radius-lg:        16px;
    --radius-xl:        20px;
    --radius-2xl:       24px;
    --radius-full:      9999px;

    /* Shadows */
    --shadow-sm:        0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg:        0 8px 32px rgba(0,0,0,0.4);
    --shadow-xl:        0 16px 48px rgba(0,0,0,0.5);
    --shadow-glow:      0 0 40px var(--brand-glow);

    /* Transitions */
    --ease-smooth:      cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce:      cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast:    150ms;
    --duration-normal:  250ms;
    --duration-slow:    400ms;

    /* Theme-specific */
    --logo-emoji:       '🎬';
    --logo-filter:      drop-shadow(0 0 24px rgba(168, 85, 247, 0.5));
    --btn-text-shadow:  0 1px 2px rgba(0,0,0,0.3);
    --scrollbar-thumb:  rgba(255,255,255,0.08);
    --scrollbar-hover:  rgba(255,255,255,0.14);

    /* Video Subtitles */
    --sub-size:         1.2rem;
    --sub-bg:           rgba(0, 0, 0, 0.75);
    --sub-color:        #ffffff;
}

/* ════════════════════════════════════════════════════════════
   CINNAMOROLL THEME 🩵
   ════════════════════════════════════════════════════════════ */
body.theme-cinnamoroll {
    --bg-primary:       #e8f4fc;
    --bg-secondary:     #f0f7ff;
    --bg-card:          rgba(255, 255, 255, 0.85);
    --bg-card-hover:    rgba(255, 255, 255, 0.95);
    --bg-elevated:      rgba(255, 255, 255, 0.96);
    --bg-input:         rgba(255, 255, 255, 0.7);
    --bg-input-focus:   rgba(255, 255, 255, 0.9);

    --border-subtle:    rgba(135, 206, 250, 0.2);
    --border-default:   rgba(135, 206, 250, 0.3);
    --border-strong:    rgba(135, 206, 250, 0.4);
    --border-focus:     rgba(135, 206, 250, 0.7);

    --brand-primary:    #7cc8f0;
    --brand-secondary:  #f8a4c8;
    --brand-gradient:   linear-gradient(135deg, #7cc8f0 0%, #b8d4f0 30%, #f8a4c8 70%, #f5c6d0 100%);
    --brand-glow:       rgba(124, 200, 240, 0.3);
    --brand-glow-lg:    rgba(124, 200, 240, 0.15);

    --accent:           #f8a4c8;
    --accent-secondary: #c8e6f0;
    --success:          #86efac;
    --warning:          #fde68a;
    --error:            #fca5a5;

    --text-primary:     #2c3e50;
    --text-secondary:   #607d8b;
    --text-muted:       #90a4ae;
    --text-inverse:     #ffffff;

    --shadow-sm:        0 1px 3px rgba(124, 200, 240, 0.1);
    --shadow-md:        0 4px 12px rgba(124, 200, 240, 0.12);
    --shadow-lg:        0 8px 32px rgba(124, 200, 240, 0.15);
    --shadow-xl:        0 16px 48px rgba(124, 200, 240, 0.18);
    --shadow-glow:      0 0 40px rgba(124, 200, 240, 0.2);

    --logo-filter:      drop-shadow(0 0 20px rgba(124, 200, 240, 0.4));
    --btn-text-shadow:  none;
    --scrollbar-thumb:  rgba(124, 200, 240, 0.2);
    --scrollbar-hover:  rgba(124, 200, 240, 0.35);
}

/* ════════════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

/* ════════════════════════════════════════════════════════════
   VIDEO CUE & OVERLAYS
   ════════════════════════════════════════════════════════════ */
video::cue {
    background-color: var(--sub-bg);
    color: var(--sub-color);
    font-family: 'Inter', sans-serif;
    font-size: var(--sub-size);
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    border-radius: 4px;
    padding: 0.2em 0.5em;
}

body {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    transition: background var(--duration-slow) var(--ease-smooth),
                color var(--duration-slow) var(--ease-smooth);
}

/* Cinema ambient background */
body:not(.theme-cinnamoroll) {
    background-image:
        radial-gradient(ellipse 80% 60% at 80% 5%, rgba(99, 102, 241, 0.12), transparent),
        radial-gradient(ellipse 60% 50% at 15% 90%, rgba(168, 85, 247, 0.1), transparent),
        radial-gradient(ellipse 40% 30% at 50% 50%, rgba(56, 189, 248, 0.03), transparent);
}

/* Cinnamoroll ambient background */
body.theme-cinnamoroll {
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 200, 240, 0.2), transparent),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(248, 164, 200, 0.15), transparent),
        radial-gradient(ellipse 50% 40% at 50% 50%, rgba(200, 230, 240, 0.1), transparent);
}

/* Cinnamoroll floating decorations */
body.theme-cinnamoroll::before {
    content: '☁️  ⭐  ☁️  🩵  ☁️  ⭐  ☁️';
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    letter-spacing: 12px;
    opacity: 0.35;
    z-index: 9998;
    pointer-events: none;
    animation: floatClouds 8s ease-in-out infinite;
}

/* Cinnamoroll mascot character */
.cinnamoroll-mascot {
    display: none;
}

body.theme-cinnamoroll .cinnamoroll-mascot {
    display: block;
    position: fixed;
    bottom: 16px;
    left: 16px;
    width: 100px;
    height: 100px;
    z-index: 9997;
    pointer-events: none;
    animation: floatMascot 4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(124, 200, 240, 0.3));
    opacity: 0.9;
    border-radius: 50%;
    object-fit: cover;
}

@keyframes floatMascot {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

@keyframes floatClouds {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ════════════════════════════════════════════════════════════ */
h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    font-weight: 800;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}

h2 {
    font-size: clamp(1.3rem, 3vw, 1.7rem);
    font-weight: 700;
}

h3 {
    font-size: 1rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
    margin-bottom: 2.5rem;
    text-align: center;
    line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════
   THEME TOGGLE SWITCH
   ════════════════════════════════════════════════════════════ */
.theme-toggle-wrapper {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: 6px 14px 6px 12px;
    box-shadow: var(--shadow-md);
    transition: all var(--duration-normal) var(--ease-smooth);
    cursor: pointer;
    user-select: none;
}

.theme-toggle-wrapper:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.theme-toggle-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color var(--duration-normal);
}

.theme-toggle-track {
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-full);
    position: relative;
    transition: background var(--duration-normal) var(--ease-smooth);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

body.theme-cinnamoroll .theme-toggle-track {
    background: linear-gradient(135deg, #7cc8f0, #f8a4c8);
    border-color: rgba(124, 200, 240, 0.3);
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform var(--duration-normal) var(--ease-bounce);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
}

.theme-toggle-thumb::after {
    content: '🎬';
    font-size: 0.6rem;
}

body.theme-cinnamoroll .theme-toggle-thumb {
    transform: translateX(20px);
}

body.theme-cinnamoroll .theme-toggle-thumb::after {
    content: '🐕';
}

/* ════════════════════════════════════════════════════════════
   HOST SETUP PAGE
   ════════════════════════════════════════════════════════════ */
.host-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4rem 1.5rem 5rem;
    animation: pageIn 0.6s var(--ease-smooth) both;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.host-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 1rem;
    filter: var(--logo-filter);
    animation: floatLogo 5s ease-in-out infinite;
}

@keyframes floatLogo {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.02); }
}

/* ── Glass Panel ── */
.main-card {
    width: 100%;
    max-width: 640px;
}

.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-2xl);
    padding: 2rem 2.25rem;
    box-shadow: var(--shadow-xl);
    animation: panelIn 0.5s var(--ease-smooth) both;
    transition: border-color var(--duration-normal),
                background var(--duration-slow);
}

body.theme-cinnamoroll .glass-panel {
    box-shadow: var(--shadow-lg), 0 0 60px rgba(124, 200, 240, 0.08);
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Sections ── */
.section-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.section-label .badge {
    width: 22px;
    height: 22px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.field-group {
    margin-bottom: 1.75rem;
}

/* ── File Input ── */
.file-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all var(--duration-normal) var(--ease-smooth);
    cursor: pointer;
}

.file-input:hover { border-color: var(--border-strong); }
.file-input:focus { border-color: var(--border-focus); outline: none; }

/* ── Drop Zone ── */
.drop-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drop-zone .dz-icon { font-size: 2rem; }
.drop-zone .dz-text { font-weight: 500; font-size: 0.95rem; }
.drop-zone .dz-hint { font-size: 0.8rem; opacity: 0.6; }

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--brand-primary);
    background: rgba(168, 85, 247, 0.04);
    color: var(--text-primary);
    transform: scale(1.01);
}

body.theme-cinnamoroll .drop-zone:hover,
body.theme-cinnamoroll .drop-zone.dragover {
    border-color: var(--brand-primary);
    background: rgba(124, 200, 240, 0.08);
}

.drop-zone.file-selected {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.04);
    color: var(--success);
    border-style: solid;
}

/* ── Preview Zone ── */
.preview-zone {
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 2rem;
    border: 1px solid var(--border-default);
    background: #0a0a14;
    animation: panelIn 0.4s var(--ease-smooth) both;
}

body.theme-cinnamoroll .preview-zone {
    background: #f0f4f8;
}

.preview-zone video {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    display: block;
}

.preview-info { padding: 1rem 1.25rem; }

.preview-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.preview-meta-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.preview-badge {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

/* ── Subtitles ── */
.sub-entry {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    animation: panelIn 0.3s var(--ease-smooth) both;
}

.sub-lang-input,
.sub-file-input {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: border-color var(--duration-fast);
}

.sub-lang-input { flex: 0 0 130px; }
.sub-file-input { flex: 1; min-width: 0; color: var(--text-secondary); cursor: pointer; }
.sub-lang-input:focus, .sub-file-input:focus { border-color: var(--border-focus); outline: none; }

.sub-remove-btn {
    width: 40px;
    border-radius: var(--radius-md);
    background: rgba(248, 113, 113, 0.08);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.2);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--duration-fast);
}
.sub-remove-btn:hover { background: rgba(248, 113, 113, 0.15); }

.add-sub-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px dashed var(--border-strong);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--duration-normal);
}
.add-sub-btn:hover {
    background: var(--bg-input-focus);
    color: var(--text-primary);
    border-color: var(--brand-primary);
}

/* ════════════════════════════════════════════════════════════
   BUTTONS (Global)
   ════════════════════════════════════════════════════════════ */
button {
    background: var(--brand-gradient);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px var(--brand-glow);
    text-shadow: var(--btn-text-shadow);
    transition: all var(--duration-normal) var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    border-radius: inherit;
    pointer-events: none;
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none !important;
}

button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--brand-glow);
    filter: brightness(1.05);
}

button:not(:disabled):active {
    transform: translateY(0) scale(0.98);
}

body.theme-cinnamoroll button {
    color: #fff;
}

#start-btn, #launch-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

/* ════════════════════════════════════════════════════════════
   SHARE ZONE
   ════════════════════════════════════════════════════════════ */
.link-box {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

#share-link {
    flex: 1;
    padding: 13px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    transition: border-color var(--duration-fast);
}

#share-link:focus { border-color: var(--border-focus); outline: none; }
#copy-btn { padding: 13px 22px; border-radius: var(--radius-md); }

/* ── Guest Panel ── */
.guest-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    transition: all var(--duration-normal);
}

.guest-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.guest-count-badge {
    background: var(--brand-gradient);
    color: #fff;
    padding: 3px 14px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
}

.guest-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guest-list-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    padding: 0.5rem;
}

.guest-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast);
}

.guest-chip:hover {
    border-color: var(--border-default);
    background: var(--bg-card-hover);
}

.guest-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.guest-chip-name {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ── Status Pill ── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: 8px 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    transition: all var(--duration-normal);
}

.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--duration-normal);
}

.status-pill.connected .dot {
    background: var(--success);
    animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

/* ════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ════════════════════════════════════════════════════════════ */
.dashboard-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
    animation: pageIn 0.5s var(--ease-smooth) both;
}

/* ── MAIN VIDEO AREA ── */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: #000;
}

body.theme-cinnamoroll .dashboard-main {
    background: #e0eaf2;
}

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

body.theme-cinnamoroll .video-wrapper {
    background: #d8e8f4;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ── Controls Bar ── */
.controls-bar {
    flex: 0 0 auto;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 50;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

body.theme-cinnamoroll .controls-bar {
    background: rgba(255, 255, 255, 0.92);
    border-top-color: var(--border-default);
}

/* Progress bar */
.progress-area {
    height: 18px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
    position: relative;
    transition: height var(--duration-fast) var(--ease-smooth);
}

body.theme-cinnamoroll .progress-track {
    background: rgba(0,0,0,0.08);
}

.progress-area:hover .progress-track { height: 7px; }

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    pointer-events: none;
    transition: width 0.15s linear;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--duration-fast) var(--ease-bounce);
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.progress-area:hover .progress-fill::after {
    transform: translateY(-50%) scale(1);
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.time-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ── Control Buttons ── */
.ctrl-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: #fff;
    min-height: 40px;
    min-width: 40px;
    cursor: pointer;
    box-shadow: none;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-smooth);
    text-shadow: none;
}

.ctrl-btn::before { display: none; }

.ctrl-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    transform: none;
    box-shadow: none;
    filter: none;
}

body.theme-cinnamoroll .ctrl-btn {
    background: rgba(124, 200, 240, 0.12);
    border-color: rgba(124, 200, 240, 0.2);
    color: var(--text-primary);
}

body.theme-cinnamoroll .ctrl-btn:hover:not(:disabled) {
    background: rgba(124, 200, 240, 0.2);
}

body.theme-cinnamoroll .ctrl-btn svg { fill: var(--text-primary); }

/* ── Volume slider ── */
.volume-slider {
    width: 80px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-full);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: background var(--duration-fast);
}

body.theme-cinnamoroll .volume-slider {
    background: rgba(0,0,0,0.1);
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}

body.theme-cinnamoroll .volume-slider::-webkit-slider-thumb {
    background: var(--brand-primary);
}

/* ── Subtitle selector ── */
.sub-selector {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    min-height: 40px;
    cursor: pointer;
    transition: all var(--duration-fast);
}

body.theme-cinnamoroll .sub-selector {
    background: rgba(124, 200, 240, 0.1);
    border-color: rgba(124, 200, 240, 0.2);
    color: var(--text-primary);
}

.sub-selector option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.dashboard-sidebar {
    width: 360px;
    flex: 0 0 360px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    z-index: 60;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

body.theme-cinnamoroll .dashboard-sidebar {
    background: rgba(255, 255, 255, 0.94);
    border-left-color: var(--border-default);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Transfers ── */
.transfer-section {
    flex: 0 0 auto;
    max-height: 220px;
    overflow-y: auto;
}

.transfer-speed-value {
    color: var(--accent);
    font-family: 'SF Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
}

.transfer-list {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transfer-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
}

.transfer-name {
    flex: 0 0 70px;
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.transfer-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.transfer-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s linear;
}

.transfer-pct {
    flex: 0 0 36px;
    text-align: right;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: 'SF Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ── Next Episode ── */
.next-episode-section {
    flex: 0 0 auto;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
}

.next-episode-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    box-shadow: none;
    transition: all var(--duration-fast);
}

.next-episode-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.next-episode-btn::before {
    display: none;
}

.next-episode-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* ── Chat ── */
.chat-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-bottom: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-msg {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: baseline;
    animation: msgIn 0.25s var(--ease-smooth) both;
    border: 1px solid transparent;
    transition: border-color var(--duration-fast);
}

.chat-msg:hover {
    border-color: var(--border-subtle);
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.chat-system {
    background: transparent;
    justify-content: center;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.75rem;
    border: none;
}

.chat-author {
    font-weight: 700;
    font-size: 0.8rem;
}

.chat-text {
    font-size: 0.85rem;
    flex: 1;
    word-break: break-word;
    color: var(--text-primary);
}

.chat-time {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.chat-input-area {
    padding: 14px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: all var(--duration-fast) var(--ease-smooth);
}

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

.chat-input:focus {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.08);
}

body.theme-cinnamoroll .chat-input:focus {
    box-shadow: 0 0 0 3px rgba(124, 200, 240, 0.15);
}

.chat-send-btn {
    width: 44px;
    min-height: 44px;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
}

/* ── Reactions ── */
.reaction-section {
    flex: 0 0 auto;
    padding: 14px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
}

.reaction-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.reaction-btn {
    width: 42px;
    min-height: 42px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    font-size: 1.15rem;
    box-shadow: none;
    padding: 0;
    text-shadow: none;
    transition: all var(--duration-fast) var(--ease-bounce);
}

.reaction-btn::before { display: none; }

.reaction-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
    transform: scale(1.2) !important;
    box-shadow: none;
    filter: none;
}

/* Floating Emoji */
.reaction-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.floating-emoji {
    position: absolute;
    font-size: 2.5rem;
    animation: floatEmoji 2.5s ease-out forwards;
    bottom: 0;
}

@keyframes floatEmoji {
    0% { transform: translateY(0) scale(0.5) rotate(0deg); opacity: 1; }
    20% { transform: translateY(-60px) scale(1.2) rotate(-5deg); opacity: 1; }
    100% { transform: translateY(-280px) scale(0.7) rotate(10deg); opacity: 0; }
}

/* ════════════════════════════════════════════════════════════
   OVERLAYS (Sync, Loading)
   ════════════════════════════════════════════════════════════ */
.sync-overlay, .loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(8, 8, 15, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 20;
    animation: overlayIn 0.3s var(--ease-smooth) both;
}

.sync-overlay > *, .loading-overlay > * {
    max-width: 380px;
    width: 90%;
    text-align: center;
}

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

body.theme-cinnamoroll .sync-overlay,
body.theme-cinnamoroll .loading-overlay {
    background: rgba(232, 244, 252, 0.94);
}

.sync-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-default);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin: 0 auto 1rem;
}

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

.sync-overlay h3 { margin-bottom: 0.5rem; }
.sync-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.compat-badge {
    display: inline-block;
    background: var(--brand-gradient);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.compat-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Progress bar overlay */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s linear;
}

/* ── Seek Indicator ── */
.seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    font-weight: 700;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    z-index: 25;
    pointer-events: none;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
}

body.theme-cinnamoroll .seek-indicator {
    background: rgba(255,255,255,0.85);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* ── Reconnect Banner ── */
.reconnect-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--warning);
    color: #000;
    text-align: center;
    z-index: 10000;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.reconnect-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ════════════════════════════════════════════════════════════
   WELCOME SCREEN (Guest)
   ════════════════════════════════════════════════════════════ */
.welcome-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

body.theme-cinnamoroll .welcome-screen {
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 200, 240, 0.2), transparent),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(248, 164, 200, 0.15), transparent);
}

.welcome-logo {
    font-size: 4rem;
    filter: var(--logo-filter);
    animation: floatLogo 5s ease-in-out infinite;
}

.welcome-title {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
}

.welcome-title span {
    -webkit-text-fill-color: var(--brand-primary);
}

.pulse-btn {
    padding: 18px 48px;
    font-size: 1.1rem;
    border-radius: var(--radius-full);
    position: relative;
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 16px var(--brand-glow); }
    50% { box-shadow: 0 4px 32px var(--brand-glow), 0 0 60px var(--brand-glow-lg); }
}

.welcome-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 1.5em;
}

.welcome-status.error { color: var(--error); }
.welcome-status.connecting { color: var(--accent); }

/* ════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {
    .theme-toggle-wrapper {
        top: 8px;
        right: 8px;
        padding: 5px 10px 5px 10px;
    }
    
    .theme-toggle-label { display: none; }

    .host-wrapper {
        padding: 3rem 1rem 3rem;
    }

    .glass-panel {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius-xl);
    }

    .dashboard-layout {
        flex-direction: column;
        height: auto;
        min-height: 100dvh;
    }

    .dashboard-main {
        flex: none;
        width: 100%;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    }

    .video-wrapper {
        width: 100%;
        aspect-ratio: 16 / 9;
    }

    .controls-bar {
        padding: 8px 12px;
    }

    .ctrl-btn {
        min-width: 36px;
        min-height: 36px;
        padding: 6px 10px;
    }

    .volume-slider, #mute-btn { display: none; }

    .dashboard-sidebar {
        width: 100%;
        flex: 1 1 auto;
        border-left: none;
        border-top: 1px solid var(--border-default);
    }

    .sub-entry {
        flex-wrap: wrap;
    }

    .sub-lang-input {
        flex: 0 0 100%;
    }

    .sub-file-input {
        flex: 1;
    }

    body.theme-cinnamoroll::before {
        font-size: 0.7rem;
        letter-spacing: 6px;
    }

    body.theme-cinnamoroll .cinnamoroll-mascot {
        width: 70px;
        height: 70px;
        bottom: 10px;
        left: 10px;
    }
}

@media (max-width: 480px) {
    .host-wrapper { padding: 2.5rem 0.75rem 2rem; }
    .glass-panel { padding: 1.25rem 1rem; }

    .preview-meta-row { flex-direction: column; gap: 0.4rem; }

    h1 { font-size: 1.8rem; }
    .subtitle { font-size: 0.9rem; margin-bottom: 1.5rem; }

    .welcome-title { font-size: 2.2rem; }
    .pulse-btn { padding: 16px 36px; font-size: 1rem; }
}

/* ════════════════════════════════════════════════════════════
   SELECTION & FOCUS
   ════════════════════════════════════════════════════════════ */
::selection {
    background: rgba(168, 85, 247, 0.3);
    color: #fff;
}

body.theme-cinnamoroll ::selection {
    background: rgba(124, 200, 240, 0.3);
    color: var(--text-primary);
}

/* Focus ring for accessibility */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   ERROR TOAST
   ════════════════════════════════════════════════════════════ */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-elevated);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--error);
    padding: 14px 24px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10001;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    animation: toastIn 0.4s var(--ease-smooth) both;
    max-width: 90vw;
    text-align: center;
}

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

@keyframes toastOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(20px); opacity: 0; }
}
