/* Watchdog — Global Styles */

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #e8e8e8;
    --text-secondary: #999;
    --accent: #4a9eff;
    --accent-hover: #6ab4ff;
    --error: #ff4a4a;
    --success: #4aff7a;
    --border: #333;
    --radius: 8px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* MARK: - Entry Page */

.entry-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.entry-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.entry-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
}

.entry-card p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: rgba(255, 140, 50, 0.4);
    box-shadow: 0 0 0 1px rgba(255, 80, 120, 0.3), 0 0 8px rgba(255, 140, 50, 0.15);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.btn-primary {
    width: 100%;
    padding: 0.7rem;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    opacity: 0.85;
}

.error-banner {
    background: rgba(255, 74, 74, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
}

/* MARK: - Room Page */

[x-cloak] { display: none !important; }

.room-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Non-interactive UI chrome: prevent text selection, show pointer on clickable */
.panel-header,
.panel-title,
.sidebar-handle,
.sidebar-close-btn,
.panel-resize-handle,
.fs-controls,
.fs-btn,
.queue-item,
.queue-item-actions,
.queue-clear-btn,
.viewers-list,
.chat-date-pill,
.chat-header {
    user-select: none;
    -webkit-user-select: none;
}

/* Hide backdrops on desktop (mobile-only overlays) */
.sidebar-backdrop,
.chat-backdrop {
    display: none;
}

/* MARK: - Room Body (Player + Sidebar) */

.room-body {
    width: 100%;
    height: 100%;
}

/* MARK: - Viewers Panel (floating, fades with controls) */

.viewers-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 14;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: auto;
    min-width: 120px;
    max-width: 240px;
}

.viewers-panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.viewers-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.viewers-entry {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.viewers-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.viewers-avatar svg {
    width: 100%;
    height: 100%;
}

.viewers-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* MARK: - Video Player */

.player-area {
    width: 100%;
    height: 100%;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* MARK: - Join Overlay */

.join-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
}

.join-overlay-content {
    text-align: center;
    padding: 1.25rem 1.75rem;
    border-radius: 16px;
    position: relative;
    background: rgba(30, 30, 30, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    max-width: 320px;
}

/* Gradient border via mask */
.join-overlay-content::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

.join-overlay-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.join-overlay-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.join-marquee {
    overflow: hidden;
}

.join-marquee-inner {
    display: flex;
    width: max-content;
    animation: title-roll 12s linear infinite;
}

.join-marquee-inner span {
    white-space: nowrap;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.9);
}

.join-marquee-dupe {
    padding-left: 3rem;
}

.join-overlay-btn {
    padding: 0.5rem 2rem;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}

.join-overlay-btn:hover {
    opacity: 0.85;
}

/* MARK: - Toast Notifications */

.toast-container {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    pointer-events: none;
}

.toast {
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0.65;
}

.toast-enter { transition: all 0.2s ease-out; }
.toast-enter-start { opacity: 0; transform: translateY(0.5rem); }
.toast-enter-end { opacity: 1; transform: translateY(0); }
.toast-leave { transition: all 0.3s ease-in; }
.toast-leave-start { opacity: 1; }
.toast-leave-end { opacity: 0; }

/* MARK: - Resolving Overlay */

.resolving-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 30, 30, 0.4);
    border: none;
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 5;
    gap: 0.75rem;
    padding: 1.5rem 2.5rem;
    pointer-events: none;
}

/* Gradient border (matches join overlay) */
.resolving-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

/* Orbit dots loader — 5 dots converge into gradient blob, split back out */
.resolving-dots {
    position: relative;
    width: 48px;
    height: 48px;
}

.resolving-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin: -5px 0 0 -5px;
    animation: dot-merge 2s ease-in-out infinite;
}

/* Each dot is a stop along the gradient spectrum */
.resolving-dot:nth-child(1) { background: #ff8c32; }  /* orange */
.resolving-dot:nth-child(2) { background: #ff7344; }  /* orange-red */
.resolving-dot:nth-child(3) { background: #ff5a56; }  /* coral */
.resolving-dot:nth-child(4) { background: #ff4868; }  /* pink-red */
.resolving-dot:nth-child(5) { background: #ff5078; }  /* pink */

/* Pentagon layout (72deg apart) */
.resolving-dot:nth-child(1) { --sx: 0px;     --sy: -18px; }   /* top */
.resolving-dot:nth-child(2) { --sx: 17px;    --sy: -6px; }    /* upper-right */
.resolving-dot:nth-child(3) { --sx: 11px;    --sy: 15px; }    /* lower-right */
.resolving-dot:nth-child(4) { --sx: -11px;   --sy: 15px; }    /* lower-left */
.resolving-dot:nth-child(5) { --sx: -17px;   --sy: -6px; }    /* upper-left */

@keyframes dot-merge {
    0%, 15%  { transform: translate(var(--sx), var(--sy)) scale(1); }
    45%, 55% { transform: translate(0, 0) scale(1.3); }
    85%, 100% { transform: translate(var(--sx), var(--sy)) scale(1); }
}

.resolving-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-align: center;
    padding: 0 1rem;
}

.resolving-enter { transition: opacity 0.3s ease-out; }
.resolving-enter-start { opacity: 0; }
.resolving-enter-end { opacity: 1; }
.resolving-leave { transition: opacity 0.4s ease-in; }
.resolving-leave-start { opacity: 1; }
.resolving-leave-end { opacity: 0; }

/* MARK: - Fullscreen Overlay Controls */

.fs-controls {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    z-index: 15;
    padding: 0.5rem 1.25rem 0.65rem;
    border-radius: 16px;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: auto;
}

.fs-controls-enter { transition: opacity 0.25s ease-out; }
.fs-controls-enter-start { opacity: 0; }
.fs-controls-enter-end { opacity: 1; }
.fs-controls-leave { transition: opacity 0.4s ease-in; }
.fs-controls-leave-start { opacity: 1; }
.fs-controls-leave-end { opacity: 0; }

.fs-seek-container {
    padding: 0.3rem 0;
}

/* MARK: - Custom Sliders (div-based — bypasses Safari native control overrides) */

.custom-slider {
    position: relative;
    width: 100%;
    height: 20px;
    cursor: pointer;
    touch-action: none;  /* Prevent scroll while dragging */
    display: flex;
    align-items: center;
}

.custom-slider-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.custom-slider-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 2px;
}

.custom-slider-thumb {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    pointer-events: none;  /* Clicks go through to parent */
    z-index: 2;
}

.custom-slider-vol {
    width: 80px;
}

.custom-slider-vol .custom-slider-thumb {
    width: 14px;
    height: 14px;
}

.fs-buttons-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.fs-buttons-row > :not(.fs-spacer) {
    flex-shrink: 0;
}

.fs-time {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 100px;
}

.fs-spacer { flex: 1; }

.fs-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fs-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.fs-btn-play {
    width: 48px;
    height: 48px;
    margin: 0 0.25rem;
    border: 2px solid transparent;
    background: none;
    border-image: linear-gradient(135deg, #ff8c32, #ff5078) 1;
    border-image: none; /* border-image doesn't support border-radius */
    position: relative;
}

/* Gradient ring via pseudo-element (border-image can't do rounded corners) */
.fs-btn-play::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

.fs-btn-play:hover {
    background: linear-gradient(135deg, #ff8c32, #ff5078);
}

.fs-btn-muted {
    opacity: 0.4;
}

.fs-btn-active {
    background: linear-gradient(135deg, rgba(255, 140, 50, 0.3), rgba(255, 80, 120, 0.3));
    color: #ff8c50;
}

.fs-btn-active:hover {
    background: linear-gradient(135deg, rgba(255, 140, 50, 0.45), rgba(255, 80, 120, 0.45));
    color: #ff6080;
}

.fs-panel-toggles {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.fs-volume {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Volume slider hidden on mobile — iOS uses hardware volume */

/* MARK: - CSS Fullscreen (iOS fallback) */

.room-container.css-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
}

/* Hide cursor when controls are hidden */
.video-wrapper.fs-idle {
    cursor: none;
}

/* MARK: - Title Overlay */

.title-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 14;
    padding: 1.5rem 2rem 3rem;
    background: linear-gradient(rgba(0, 0, 0, 0.6), transparent);
    pointer-events: auto;
}

.title-marquee {
    overflow: hidden;
    max-width: 40vw;
}

.title-marquee-inner {
    display: flex;
    width: max-content;
}

.title-overlay-text {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    flex-shrink: 0;
}

.title-overlay-dupe {
    display: none;
    padding-left: 3rem;
}

.title-overlay:hover .title-marquee-inner {
    animation: title-roll 12s linear infinite;
}

.title-overlay:hover .title-overlay-dupe {
    display: inline;
}

@keyframes title-roll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* MARK: - Viewer Count Badge (minimal UI only) */

.viewer-count-badge {
    display: none; /* Hidden on desktop — full viewers panel is used instead */
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 14;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
}

/* MARK: - Sidebar Handle + Close */

.sidebar-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.5rem 0.2rem;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}

.sidebar-handle:active {
    cursor: grabbing;
}

.sidebar-grip {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    margin-left: auto;
    margin-right: auto;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.sidebar-close-btn:hover {
    background: linear-gradient(135deg, rgba(255, 140, 50, 0.15), rgba(255, 80, 120, 0.15));
    color: #ff8c50;
}

/* MARK: - Panel Bottom Resize Handle */

.panel-resize-handle {
    flex-shrink: 0;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.4rem 0;
}

.panel-resize-handle::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.15s;
}

.panel-resize-handle:hover::after {
    background: rgba(255, 255, 255, 0.4);
}

/* MARK: - Queue Sidebar */

.queue-sidebar {
    position: absolute;
    z-index: 100;
    width: 280px;
    height: 250px;
    top: 80px;
    right: 16px;
    border-radius: 16px;
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 96px);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.queue-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.3rem auto 0.4rem;
    color: #fff;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.queue-clear-btn:hover {
    opacity: 1;
}

/* MARK: - Queue Add Form */

.queue-add-form {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.queue-url-input {
    flex: 1;
    padding: 0.45rem 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.queue-url-input:focus {
    border-color: rgba(255, 140, 50, 0.4);
    box-shadow: 0 0 0 1px rgba(255, 80, 120, 0.3), 0 0 8px rgba(255, 140, 50, 0.15);
}

.queue-url-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.queue-url-input:disabled {
    opacity: 0.5;
}

.queue-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.15s;
    align-self: center;
    flex-shrink: 0;
}

.queue-add-btn:hover:not(:disabled) {
    opacity: 0.85;
}

.queue-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MARK: - Queue Error */

.queue-error {
    padding: 0.4rem 0.6rem;
    background: rgba(255, 74, 74, 0.15);
    color: var(--error);
    font-size: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.queue-error-dismiss {
    opacity: 0.6;
    font-size: 0.7rem;
    text-transform: uppercase;
}

/* MARK: - Queue List */

.queue-list {
    flex: 3 1 0;
    overflow-y: auto;
    min-height: 40px;
}

.queue-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.queue-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.queue-item:active:not(.queue-item-current) {
    background: rgba(255, 140, 50, 0.12);
}

.queue-item-current {
    position: relative;
    background: rgba(255, 140, 50, 0.08);
    padding-left: calc(0.75rem - 3px);
}

.queue-item-current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #ff8c32, #ff5078);
    border-radius: 0 2px 2px 0;
}

.queue-item-resolving {
    opacity: 0.7;
}

.queue-item-resolving .queue-item-index {
    animation: pulse 1.5s ease-in-out infinite;
}

.resolve-status {
    color: var(--text-secondary);
    font-style: italic;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.queue-item-dragging {
    opacity: 0.4;
}

.queue-item-drag-over {
    position: relative;
}

.queue-item-drag-over::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #ff8c32, #ff5078);
}

.queue-item-index {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 1.2rem;
    text-align: center;
}

.queue-item-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.queue-item-title {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item:hover .queue-item-title {
    text-overflow: clip;
}

.queue-item:hover .queue-item-title span {
    display: inline-block;
    animation: marquee-scroll 5s linear 0.3s infinite;
}

@keyframes marquee-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

.queue-item-meta {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.queue-item:hover .queue-item-actions {
    opacity: 1;
}

.queue-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.queue-item-remove:hover {
    background: linear-gradient(135deg, rgba(255, 140, 50, 0.15), rgba(255, 80, 120, 0.15));
    color: #ff8c50;
}

/* MARK: - Save Queue to Playlist */

.queue-save-row {
    position: relative;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.queue-save-btn {
    width: 100%;
    padding: 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}

.queue-save-btn:hover {
    background: var(--border);
}

.save-playlist-dropdown {
    position: absolute;
    top: 100%;
    left: 0.75rem;
    right: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.3rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
}

.save-playlist-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.save-playlist-option:hover {
    background: var(--bg-tertiary);
}

.save-playlist-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.save-playlist-new {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.6rem;
}

.save-playlist-input {
    flex: 1;
    padding: 0.3rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
}

.save-playlist-input:focus {
    border-color: var(--accent);
}

.save-playlist-create-btn {
    padding: 0.3rem 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.save-playlist-create-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MARK: - Playlists Section */

.playlists-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.playlists-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.playlists-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.playlists-title {
    font-size: 0.9rem;
    font-weight: 600;
    flex: 1;
}

.playlists-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
}

.playlists-chevron {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.playlists-body {
    max-height: 300px;
    overflow-y: auto;
}

.playlists-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* MARK: - Playlist Create Form */

.playlist-create-form {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
}

.playlist-name-input {
    flex: 1;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
}

.playlist-name-input:focus {
    border-color: var(--accent);
}

.playlist-name-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.playlist-create-btn {
    padding: 0.35rem 0.6rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.playlist-create-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MARK: - Playlist Entry (Accordion) */

.playlist-entry {
    border-bottom: 1px solid rgba(51, 51, 51, 0.5);
}

.playlist-entry-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.playlist-entry-header:hover {
    background: var(--bg-tertiary);
}

.playlist-entry-chevron {
    font-size: 0.6rem;
    color: var(--text-secondary);
    width: 0.8rem;
}

.playlist-entry-name {
    flex: 1;
    font-size: 0.85rem;
}

.playlist-entry-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.playlist-entry-body {
    background: rgba(0, 0, 0, 0.15);
}

.playlist-actions {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgba(51, 51, 51, 0.3);
    flex-wrap: wrap;
}

.playlist-action-btn {
    padding: 0.2rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.15s;
}

.playlist-action-btn:hover {
    background: var(--border);
}

.playlist-action-delete {
    color: var(--error);
    border-color: rgba(255, 74, 74, 0.3);
}

.playlist-action-delete:hover {
    background: rgba(255, 74, 74, 0.1);
}

/* MARK: - Playlist Rename */

.playlist-rename-row {
    display: flex;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid rgba(51, 51, 51, 0.3);
}

.playlist-rename-input {
    flex: 1;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
}

.playlist-rename-ok {
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

/* MARK: - Playlist Items */

.playlist-items-empty {
    padding: 0.6rem 0.75rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-style: italic;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid rgba(51, 51, 51, 0.2);
    transition: background 0.15s;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.playlist-item-watched {
    opacity: 0.5;
}

.playlist-item-checkbox {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.playlist-item-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.playlist-item-title {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-duration {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.playlist-item-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.1rem 0.25rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}

.playlist-item:hover .playlist-item-remove {
    opacity: 1;
}

.playlist-item-remove:hover {
    color: var(--error);
}

/* MARK: - Chat Panel (independent floating panel) */

.chat-panel {
    position: absolute;
    z-index: 100;
    width: 280px;
    height: 250px;
    left: 24px;
    bottom: 80px;
    border-radius: 16px;
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.3rem 0.6rem;
    min-height: 60px;
}

.chat-empty {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    padding: 0.5rem 0;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.2rem 0;
}

.chat-avatar {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 0.2rem;
}

.chat-avatar svg {
    width: 100%;
    height: 100%;
}

.chat-bubble {
    font-size: 0.75rem;
    line-height: 1.4;
    word-wrap: break-word;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background-origin: border-box;
    background-clip: padding-box, border-box;
    background-image:
        linear-gradient(rgba(30, 30, 30, 0.75), rgba(30, 30, 30, 0.75)),
        linear-gradient(135deg, rgba(255, 140, 50, 0.4), rgba(255, 80, 120, 0.4));
}

.chat-date-pill {
    text-align: center;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, rgba(255, 255, 255, 0.35));
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.15rem 0.6rem;
    margin: 0.5rem auto 0.35rem;
    width: fit-content;
}

.chat-header {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.chat-sender {
    font-weight: 600;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-time {
    font-size: 0.6rem;
    color: var(--text-muted, rgba(255, 255, 255, 0.35));
    white-space: nowrap;
    margin-left: auto;
}

.chat-text {
    color: var(--text-primary);
}

.chat-input-form {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 0.45rem 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.chat-input:focus {
    border-color: rgba(255, 140, 50, 0.4);
    box-shadow: 0 0 0 1px rgba(255, 80, 120, 0.3), 0 0 8px rgba(255, 140, 50, 0.15);
}

.chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ff8c32, #ff5078);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    transition: opacity 0.15s;
    align-self: center;
}

.chat-send-btn:hover:not(:disabled) {
    opacity: 0.85;
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MARK: - Minimal UI (small viewports + iPhone) */

@media (max-width: 768px) {
    /* --- Minimal mode: video + playback controls only --- */

    /* Hide all panels and their backdrops */
    .queue-sidebar,
    .chat-panel,
    .sidebar-backdrop,
    .chat-backdrop {
        display: none !important;
    }

    /* Hide full viewers panel — replaced by compact badge */
    .viewers-panel {
        display: none !important;
    }

    /* Show compact viewer count badge */
    .viewer-count-badge {
        display: flex;
    }

    /* Hide panel toggle buttons — no panels in minimal mode */
    .fs-panel-toggles {
        display: none;
    }

    /* Hide title overlay — maximize video real estate */
    .title-overlay {
        display: none !important;
    }

    /* Hide entire volume group — iOS/mobile uses hardware volume */
    .fs-volume {
        display: none;
    }

    /* Controls: compact, centered */
    .fs-controls {
        width: calc(100% - 48px);
        bottom: max(8px, env(safe-area-inset-bottom));
        border-radius: 12px;
        padding: 0.3rem 0.75rem 0.4rem;
    }

    .fs-seek-container {
        padding: 0.25rem 0;
    }

    /* Compact button row */
    .fs-buttons-row {
        gap: 0.15rem;
    }

    .fs-btn {
        padding: 0.3rem 0.4rem;
    }

    .fs-btn-play {
        margin: 0 0.1rem;
    }

    /* Compact time display */
    .fs-time {
        font-size: 0.8rem;
        min-width: auto;
    }

    /* Larger seek bar for easier touch scrubbing */
    .custom-slider {
        height: 28px;
    }

    .custom-slider-track {
        height: 6px;
    }

    .custom-slider-thumb {
        width: 20px;
        height: 20px;
    }

    /* Entry page safe areas */
    .entry-container {
        padding: 1rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left));
    }
}

/* MARK: - Touch Device Overrides (iPad, phones — regardless of screen width) */

@media (pointer: coarse) {
    /* Larger drag handle for finger dragging */
    .sidebar-handle {
        padding: 0.6rem 0.5rem 0.4rem;
        min-height: 44px;
    }

    .sidebar-grip {
        width: 40px;
        height: 5px;
    }

    /* Larger close button (44pt minimum tap target) */
    .sidebar-close-btn {
        font-size: 1.4rem;
        padding: 0.3rem 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Larger resize handle for finger dragging */
    .panel-resize-handle {
        height: 36px;
    }

    .panel-resize-handle::after {
        width: 14px;
        height: 14px;
        background: rgba(255, 255, 255, 0.25);
    }
}
