/* =============================================================================
   Spa Scene Management - Styles
   ============================================================================= */

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-light: #0f3460;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #2d3a5a;
    --success: #4ecdc4;
    --warning: #ffe66d;
    --danger: #ff6b6b;
    --selected-blue: #4a9eff;
}

/* =============================================================================
   Unified Card Component
   Used for scene cards across Browser, Editor, Videos, and Selector
   ============================================================================= */

.spa-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid transparent;
    outline: none;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

/* Hover/Focus state - red border with shadow */
.spa-card:hover,
.spa-card:focus {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
    transform: translateY(-4px);
}

/* Active/Selected state (currently editing or selected in panel) */
.spa-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
}

/* Last-activated / Most Recent - thick blue outline */
.spa-card.last-activated {
    outline: 4px solid var(--selected-blue);
    outline-offset: -1px;
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.3);
}

/* Combined: last-activated AND hover/focus */
.spa-card.last-activated:hover,
.spa-card.last-activated:focus,
.spa-card.last-activated.active {
    border-color: var(--accent);
    outline: 4px solid var(--selected-blue);
    outline-offset: -1px;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.4), 0 0 30px rgba(74, 158, 255, 0.4);
}

/* Card thumbnail area */
.spa-card-thumbnail {
    position: relative;
    height: 200px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Single image/video thumbnails */
.spa-card-thumbnail > img,
.spa-card-thumbnail > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.spa-card:hover .spa-card-thumbnail > img,
.spa-card:hover .spa-card-thumbnail > video,
.spa-card:focus .spa-card-thumbnail > img,
.spa-card:focus .spa-card-thumbnail > video {
    transform: scale(1.05);
}

/* Split video thumbnails (TV + Window side by side) */
.spa-card-thumbnail .preview-videos {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 2px;
}

.spa-card-thumbnail .preview-videos .preview-video {
    flex: 1;
    min-width: 0;
    height: 100%;
    object-fit: cover;
    background: var(--bg-dark);
}

.spa-card-thumbnail .preview-videos .preview-video-placeholder {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 300;
}

/* Energy emoji - bottom left of thumbnail */
.spa-card-energy {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 1.4rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Duration badge - bottom right of thumbnail */
.spa-card-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Card info area - fixed height for consistency */
.spa-card-info {
    padding: 1.25rem;
    height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.spa-card-name {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Meta tags - allows 2 rows of wrapping */
.spa-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    overflow: hidden;
    max-height: 52px; /* ~2 rows of tags */
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* =============================================================================
   Taskbar Navigation
   Windows-style taskbar with icons and hamburger menu
   ============================================================================= */

.spa-nav {
    display: flex;
    align-items: center;
    padding: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    height: 48px;
}

.spa-nav-icons {
    display: flex;
    align-items: center;
    height: 100%;
}

.spa-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.spa-nav-icon:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.spa-nav-icon.active {
    color: var(--accent);
    background: var(--bg-light);
}

.spa-nav-icon.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 8px;
    right: 8px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

.spa-nav-icon svg {
    width: 22px;
    height: 22px;
}

/* Hamburger Menu */
.spa-nav-menu {
    position: relative;
}

.spa-nav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
}

.spa-nav-menu.open .spa-nav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.spa-nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.spa-nav-dropdown-item:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.spa-nav-dropdown-item.active {
    color: var(--accent);
}

.spa-nav-dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.spa-nav-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Spacer to push content to the right */
.spa-nav-spacer {
    flex: 1;
}

/* Nav control popups (lighting, volume) */
.spa-nav-control {
    position: relative;
}

.spa-nav-popup {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 200;
}

.spa-nav-control.open .spa-nav-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Vertical slider (HA style) - shared base */
.vertical-slider {
    position: relative;
    width: 56px;
    height: 240px;
    background: var(--bg-dark);
    border-radius: 28px;
    overflow: hidden;
    cursor: pointer;
    touch-action: none;
}

.vertical-slider-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 28px;
    transition: height 0.05s ease;
}

.vertical-slider-value {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 1;
    pointer-events: none;
    color: var(--bg-dark);
    text-shadow: 0 0 4px rgba(255,255,255,0.5);
}

.vertical-slider-label {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    z-index: 1;
    pointer-events: none;
    white-space: nowrap;
}

.vertical-slider-icon {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    z-index: 1;
    pointer-events: none;
}

.vertical-slider-icon svg {
    width: 22px;
    height: 22px;
}

/* Brightness popup - yellow/gold gradient */
.brightness-popup {
    width: auto;
    padding: 1rem;
}

.brightness-slider .vertical-slider-fill {
    background: linear-gradient(to top, #e65100, #ffb300, #ffeb3b);
}

/* Volume popup with 3 vertical sliders side by side */
.volume-popup {
    width: auto;
    padding: 1rem;
}

.volume-sliders-row {
    display: flex;
    gap: 0.5rem;
}

/* Volume sliders - blue/cyan gradient */
.volume-slider .vertical-slider-fill {
    background: linear-gradient(to top, #01579b, #0288d1, #4fc3f7);
}

/* Right-aligned nav actions */
.spa-nav-actions {
    display: flex;
    align-items: center;
    padding-right: 1rem;
    gap: 0.5rem;
}

.spa-nav-actions .btn-action {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.spa-nav-actions .btn-action:hover {
    background: var(--accent-hover);
}

/* =============================================================================
   TV Browser Styles
   ============================================================================= */

.browser {
    overflow: hidden;
}

.browser-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 2rem;
}

.browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.browser-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
}

.header-info {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.scene-carousel {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    flex: 1;
    align-items: center;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.scene-carousel::-webkit-scrollbar {
    display: none;
}

/* Browser carousel-specific overrides (uses spa-card as base) */
.scene-carousel .scene-card {
    flex: 0 0 400px;
    min-width: 400px;
    max-width: 400px;
    scroll-snap-align: center;
}

/* Focus on carousel cards with scale */
.scene-carousel .spa-card:focus,
.scene-carousel .spa-card.selected {
    transform: scale(1.03);
}

.scene-preview {
    height: 200px;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Video thumbnails container */
.preview-videos {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 2px;
}

.preview-video {
    flex: 1;
    width: 50%;
    height: 100%;
    object-fit: cover;
    background: var(--bg-dark);
}

.preview-video-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: 300;
}

/* Card loading overlay */
.card-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
}

.scene-card.loading .card-loading-overlay {
    display: flex;
}

/* Card status badge */
.card-status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: none;
}

.scene-card.activated .card-status-badge {
    display: block;
    background: var(--success);
    color: var(--bg-dark);
}

.scene-card.activated .card-status-badge::after {
    content: 'Active';
}

.scene-card.error .card-status-badge {
    display: block;
    background: var(--danger);
    color: white;
}

.scene-card.error .card-status-badge::after {
    content: 'Error';
}

.scene-card.partial .card-status-badge {
    display: block;
    background: var(--warning);
    color: var(--bg-dark);
}

.scene-card.partial .card-status-badge::after {
    content: 'Partial';
}

.preview-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scene-icon {
    font-size: 3rem;
    font-weight: bold;
}

.scene-info {
    padding: 1.5rem;
    height: 120px;
    overflow: hidden;
}

.scene-name {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.scene-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.energy-level {
    display: flex;
    gap: 4px;
}

/* Scene Energy Badge */
.scene-energy {
    position: absolute;
    bottom: 8px;
    left: 8px;
    font-size: 1.4rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Scene Meta Tags */
.scene-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.no-scenes {
    text-align: center;
    color: var(--text-secondary);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.no-scenes .hint {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.browser-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.nav-item {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

kbd {
    background: var(--bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: inherit;
    margin-right: 0.25rem;
}

/* Selection Overlay */
.selection-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.selection-overlay.visible {
    display: flex;
}

.overlay-content {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 16px;
    text-align: center;
    min-width: 400px;
}

.overlay-content h2 {
    margin-bottom: 2rem;
    font-size: 2rem;
}

.overlay-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.action-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    background: var(--bg-light);
    color: var(--text-primary);
    transition: all 0.2s;
}

.action-btn:hover,
.action-btn:focus {
    transform: scale(1.05);
}

.action-btn.primary {
    background: var(--accent);
}

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

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 1.5rem auto;
    border: 3px solid var(--bg-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* =============================================================================
   Editor Styles
   ============================================================================= */

.editor-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.editor-header h1 {
    font-size: 1.75rem;
    font-weight: 400;
}

.btn-browser {
    background: var(--bg-light);
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-browser:hover {
    background: var(--bg-card);
}

.editor-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    min-height: calc(100vh - 120px);
}

/* Scene List Sidebar */
.scene-list {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    height: fit-content;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.list-header h2 {
    font-size: 1rem;
    font-weight: 500;
}

.btn-new {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

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

#sceneList {
    list-style: none;
}

.scene-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.scene-item:hover {
    background: var(--bg-light);
}

.scene-item.active {
    background: var(--bg-light);
    border-left: 3px solid var(--accent);
}

.scene-item .scene-name {
    font-size: 0.95rem;
}

.energy-badge {
    font-size: 1rem;
}

/* Editor Form */
.editor-form {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 150px);
}

.form-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
}

.hidden {
    display: none;
}

.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.form-row label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.form-row input[type="text"],
.form-row select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row.inline {
    display: flex;
    gap: 1.5rem;
}

.input-group {
    flex: 1;
}

.input-group input[type="range"] {
    width: 100%;
}

.range-value {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* Energy Slider */
.energy-slider {
    padding-top: 0.5rem;
}

.energy-slider input[type="range"] {
    width: 100%;
    margin-bottom: 0.5rem;
}

.energy-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-save,
.btn-delete,
.btn-cancel {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-save {
    background: var(--accent);
    color: white;
}

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

.btn-delete {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.btn-cancel {
    background: var(--bg-light);
    color: var(--text-secondary);
}

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

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .scene-list {
        max-height: 200px;
    }

    .scene-carousel {
        padding: 1rem 0;
    }

    .scene-card {
        flex: 0 0 300px;
        min-width: 300px;
        max-width: 300px;
    }
}

@media (max-width: 600px) {
    .browser-container {
        padding: 1rem;
    }

    .browser-header h1 {
        font-size: 1.5rem;
    }

    .header-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .scene-card {
        flex: 0 0 85vw;
        min-width: 85vw;
        max-width: 85vw;
    }

    .form-row.inline {
        flex-direction: column;
    }
}

/* =============================================================================
   TV Remote Panel
   ============================================================================= */

.remote-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1100;
}

.remote-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.remote-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 1101;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.remote-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.remote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.remote-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.remote-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
}

.remote-close:hover {
    color: var(--text-primary);
}

.remote-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* D-pad layout using CSS Grid */
.remote-dpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.remote-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s ease, transform 0.1s ease;
}

.remote-btn:hover {
    background: var(--bg-hover);
}

.remote-btn:active {
    background: var(--accent);
    transform: scale(0.95);
}

.remote-btn svg {
    width: 24px;
    height: 24px;
}

/* D-pad button positions */
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center {
    grid-column: 2;
    grid-row: 2;
    background: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}
.dpad-center:hover {
    background: var(--accent-hover);
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Action buttons row */
.remote-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.action-btn {
    flex: 1;
    max-width: 100px;
    padding: 0.75rem 0.5rem;
    flex-direction: column;
    gap: 0.25rem;
}

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

.action-btn span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.action-btn:active span {
    color: var(--text-primary);
}

/* =============================================================================
   Power Control Panel
   ============================================================================= */

.power-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1200;
}

.power-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.power-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 340px;
    max-width: 90vw;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 1201;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.power-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.power-header {
    background: var(--bg-dark);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.power-countdown {
    text-align: center;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.power-countdown-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ff6b6b;
    font-variant-numeric: tabular-nums;
}

.power-header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-power-cancel {
    flex: 1;
    padding: 0.6rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-power-cancel:hover {
    background: var(--bg-light);
}

.btn-power-now {
    flex: 1;
    padding: 0.6rem 1rem;
    background: #dc3545;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-power-now:hover {
    background: #c82333;
}

.power-devices {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.power-device {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.15s ease;
}

.power-device-icon {
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
}

.power-device-icon svg {
    width: 100%;
    height: 100%;
}

.power-device-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.power-device-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-light);
    border: 2px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

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

.power-device-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.power-device-btn:active {
    transform: scale(0.95);
}

.power-device-btn.off {
    background: var(--bg-input);
    border-color: var(--border);
    color: var(--text-muted);
    opacity: 0.5;
}

/* =============================================================================
   Screen Mode Toggle
   ============================================================================= */

.screen-mode-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 2px;
    margin-right: 0.5rem;
}

.screen-mode-toggle .mode-option {
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.screen-mode-toggle .mode-option:hover {
    color: var(--text-primary);
}

.screen-mode-toggle .mode-option.active {
    background: var(--accent);
    color: white;
}

/* =============================================================================
   Remote App Buttons
   ============================================================================= */

.remote-apps {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.remote-btn.app-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
}

.remote-btn.app-btn:hover {
    background: var(--bg-card);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.remote-btn.app-btn:active {
    transform: scale(0.95);
}

.remote-btn.app-btn svg {
    width: 24px;
    height: 24px;
}

.remote-btn.app-btn span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* App-specific colors on hover */
.remote-btn.app-btn[data-app="plex"]:hover {
    border-color: #e5a00d;
    color: #e5a00d;
}

.remote-btn.app-btn[data-app="netflix"]:hover {
    border-color: #e50914;
    color: #e50914;
}

.remote-btn.app-btn[data-app="youtube"]:hover {
    border-color: #ff0000;
    color: #ff0000;
}

/* =============================================================================
   Debug Panel
   ============================================================================= */

/* Debug panel backdrop */
.debug-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
}

.debug-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.debug-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.debug-panel.visible {
    transform: translateX(0);
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.debug-header h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.debug-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.debug-clear {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.debug-clear:hover {
    background: var(--border);
}

.debug-close {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.debug-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.debug-entry {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.debug-entry:last-child {
    border-bottom: none;
}

.debug-header-row {
    margin-bottom: 0.25rem;
}

.debug-datetime {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.debug-trigger-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.debug-source {
    background: var(--accent);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.debug-separator {
    color: var(--text-muted);
}

.debug-trigger {
    color: var(--text-primary);
    font-weight: 600;
}

.debug-action-type {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.debug-modes-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.debug-modes-label {
    color: var(--text-muted);
    min-width: 50px;
}

.debug-modes-value {
    color: var(--text-secondary);
}

.debug-actions-section {
    margin: 0.5rem 0;
}

.debug-status-row {
    margin-top: 0.5rem;
}

.debug-actions-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.debug-actions-list li {
    padding: 0.2rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.debug-actions-list .action-icon {
    flex-shrink: 0;
    width: 1rem;
    text-align: center;
}

.debug-actions-list .action-success {
    color: var(--success);
}

.debug-actions-list .action-fail {
    color: var(--danger);
}

/* Dial events */
.debug-dial-event {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.25rem;
}

.dial-button {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.dial-action {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.debug-description {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.debug-generic {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.debug-json {
    background: var(--bg-dark);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    overflow-x: auto;
    margin: 0.25rem 0;
}

.debug-status {
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
}

.debug-status.success {
    background: var(--success);
    color: var(--bg-dark);
}

.debug-status.partial {
    background: var(--warning);
    color: var(--bg-dark);
}

.debug-status.error {
    background: var(--danger);
    color: white;
}

/* Adjust browser container when debug panel is open */
body.debug-open .browser-container {
    margin-right: 400px;
    transition: margin-right 0.3s ease;
}

@media (max-width: 900px) {
    .debug-panel {
        width: 100%;
    }

    body.debug-open .browser-container {
        margin-right: 0;
    }
}

/* =============================================================================
   Scene Auto Selector Styles
   ============================================================================= */

.selector {
    overflow-y: auto;
}

.selector-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.selector-header {
    text-align: center;
    margin-bottom: 2rem;
}

.selector-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.selector-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.current-scene-section {
    margin-bottom: 2rem;
}

.current-scene-section h2,
.scene-list-section h2 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.default-scene-display {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Selector default card - fixed width */
.default-scene-display .spa-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 400px;
    height: 320px;
}

.default-scene-display .spa-card.default-card {
    cursor: default;
}

.default-scene-display .spa-card.default-card:hover {
    transform: none;
}

.default-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--selected-blue);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.no-default {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 2px dashed var(--border);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.scene-list-section {
    flex: 1;
}

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

.scene-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scene-list-item:hover {
    border-color: var(--border);
    background: var(--bg-light);
}

.scene-list-item.selected {
    border-color: var(--accent);
    background: var(--bg-light);
}

.scene-list-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.scene-list-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.scene-list-name {
    font-size: 1.1rem;
    font-weight: 500;
}

.scene-list-videos {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

.scene-list-check {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--success);
}

.selector-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.selector-footer .footer-nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.selector-footer .nav-item {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.selector-footer kbd {
    background: var(--bg-light);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-right: 0.3rem;
}

/* =============================================================================
   Video Center Styles
   ============================================================================= */

.videos-page {
    overflow: hidden;
}

.videos-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 2rem;
}

.videos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.videos-header h1 {
    font-size: 2rem;
    font-weight: 300;
}

.video-count {
    color: var(--text-secondary);
    font-size: 1rem;
}

.videos-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin-top: 1.5rem;
}

/* Video Gallery Grid */
.video-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-auto-rows: 320px; /* Fixed height: 200px thumbnail + 120px info */
    gap: 1.5rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
    padding-bottom: 1rem;
    align-content: start;
}

/* Ensure video cards maintain fixed height */
.video-gallery .spa-card {
    height: 320px;
}

/* Video-specific overrides (uses spa-card as base) */
.video-card.playing {
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

/* Thumbnail placeholder for videos */
.thumbnail-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--bg-light));
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-icon {
    font-size: 2rem;
    font-weight: bold;
}

/* Play overlay for videos */
.play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spa-card:hover .play-overlay,
.spa-card:focus .play-overlay {
    opacity: 1;
}

.play-icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    padding-left: 5px;
}

.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.video-tag {
    background: var(--bg-light);
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* Video Metadata Tags (colored by type) */
.video-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.meta-tag {
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    text-transform: capitalize;
    font-weight: 500;
}

/* Time of Day - Yellow/Orange */
.meta-tag.tag-time {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

/* Weather - Blue */
.meta-tag.tag-weather {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Season - Green */
.meta-tag.tag-season {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Environment - Purple */
.meta-tag.tag-environment {
    background: rgba(156, 39, 176, 0.2);
    color: #ba68c8;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

/* Special Date - Red/Pink */
.meta-tag.tag-special {
    background: rgba(233, 30, 99, 0.2);
    color: #f48fb1;
    border: 1px solid rgba(233, 30, 99, 0.3);
}

/* Energy Level Badge */
.video-energy {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 1.2rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.no-videos {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.no-videos .hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-family: monospace;
}

/* =============================================================================
   Video Edit Panel (matches Scene Editor Panel style)
   ============================================================================= */

/* Panel backdrop for click-outside-to-close */
.videos-page .panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 99;
}

.videos-page .panel-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

/* Video Edit Panel (slide-in overlay - matches scene editor) */
.video-edit-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50%;
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-edit-panel.open {
    transform: translateX(0);
}

/* Panel Header (matches scene editor) */
.video-edit-panel .panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.video-edit-panel .video-name-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 500;
    padding: 0.25rem 0;
    outline: none;
    min-width: 0;
}

.video-edit-panel .video-name-input:focus {
    border-bottom-color: var(--accent);
}

.video-edit-panel .video-name-input::placeholder {
    color: var(--text-muted);
}

.video-edit-panel .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.video-edit-panel .header-actions .btn-icon {
    background: var(--bg-light);
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.video-edit-panel .header-actions .btn-icon:hover {
    background: var(--border);
    color: var(--text-primary);
}

.video-edit-panel .header-actions .btn-icon.btn-delete {
    color: #e57373;
}

.video-edit-panel .header-actions .btn-icon.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.video-edit-panel .header-actions .btn-icon svg {
    width: 16px;
    height: 16px;
}

.video-edit-panel .header-actions .btn-save {
    background: #4caf50;
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s ease;
}

.video-edit-panel .header-actions .btn-save:hover {
    background: #43a047;
}

.video-edit-panel .header-actions .btn-save svg {
    width: 16px;
    height: 16px;
}

/* Panel Content (scrollable) */
.video-edit-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Custom scrollbar for panel (matches scene editor) */
.video-edit-panel .panel-content::-webkit-scrollbar {
    width: 8px;
}

.video-edit-panel .panel-content::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.video-edit-panel .panel-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.video-edit-panel .panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.video-wrapper video {
    width: 100%;
    display: block;
}

.video-details {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detail-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: monospace;
    word-break: break-all;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.no-tags-note,
.no-scenes-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.used-in-scenes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scene-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: 6px;
}

.scene-link .scene-name {
    font-weight: 500;
}

.scene-link .scene-usage {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Save status container */
.save-status-container {
    text-align: center;
    padding: 0.5rem 0;
}

/* Videos Footer */
.videos-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

/* Adjust gallery when panel is open */
.videos-layout:has(.video-edit-panel.open) .video-gallery {
    margin-right: calc(50% + 1rem);
}

/* Responsive adjustments for video center */
@media (max-width: 1200px) {
    .video-edit-panel {
        width: 60%;
    }

    .videos-layout:has(.video-edit-panel.open) .video-gallery {
        margin-right: calc(60% + 1rem);
    }
}

@media (max-width: 900px) {
    .video-edit-panel {
        width: 100%;
        max-width: none;
    }

    .videos-layout:has(.video-edit-panel.open) .video-gallery {
        display: none;
    }

    .video-gallery {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 600px) {
    .videos-container {
        padding: 1rem;
    }

    .videos-header h1 {
        font-size: 1.5rem;
    }

    .video-gallery {
        grid-template-columns: 1fr;
    }

    .video-edit-panel .panel-content {
        padding: 1rem;
    }
}

/* =============================================================================
   Add Video Button & Downloads Queue
   ============================================================================= */

.btn-add-video {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 1rem;
}

.btn-add-video:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* Downloads Queue */
.downloads-queue {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.queue-header h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.btn-toggle-queue {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-toggle-queue:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.queue-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 6px;
    border-left: 3px solid var(--border);
}

.queue-item.status-pending {
    border-left-color: var(--text-muted);
}

.queue-item.status-downloading {
    border-left-color: var(--accent);
}

.queue-item.status-processing {
    border-left-color: orange;
}

.queue-item.status-completed {
    border-left-color: var(--success);
}

.queue-item.status-error {
    border-left-color: var(--danger);
}

.job-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.job-status-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.job-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.job-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-progress {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-dismiss-job {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

.btn-restart-job {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
    margin-right: 0.5rem;
}

.btn-restart-job:hover {
    background: var(--accent);
    color: white;
}

.job-actions {
    display: flex;
    align-items: center;
}

/* =============================================================================
   Add Video Modal
   ============================================================================= */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.btn-close-modal {
    background: var(--bg-light);
    border: none;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Add Video Form */
.add-video-modal form {
    padding: 1.5rem;
}

.add-video-modal .form-group {
    margin-bottom: 1.25rem;
}

/* Form row - two fields side by side */
.form-row {
    display: flex;
    gap: 1rem;
}

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

/* Energy picker - clickable emoji buttons */
.energy-picker {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
}

.energy-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--bg-light);
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.energy-btn:hover {
    background: var(--bg-card);
    border-color: var(--border);
    transform: scale(1.1);
}

.energy-btn.selected {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.5);
}

/* Duration preview - shows calculated loops and warnings */
.duration-preview {
    background: var(--bg-light);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.duration-preview .preview-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.duration-preview .preview-warning {
    color: var(--warning);
    font-size: 0.85rem;
    font-weight: 500;
}

.duration-preview .preview-warning.error {
    color: var(--danger);
}

.duration-preview.has-warning {
    border: 1px solid var(--warning);
}

.duration-preview.has-error {
    border: 2px solid var(--danger);
    background: rgba(255, 107, 107, 0.1);
}

/* Highlight loop input when too short */
.add-video-modal input.input-error {
    border-color: var(--danger);
    background: rgba(255, 107, 107, 0.1);
}

.add-video-modal label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.add-video-modal input[type="text"],
.add-video-modal input[type="url"] {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.add-video-modal input:focus {
    outline: none;
    border-color: var(--accent);
}

.url-input-group {
    display: flex;
    gap: 0.5rem;
}

.url-input-group input {
    flex: 1;
}

.btn-fetch {
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-fetch:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-fetch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.url-status {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    min-height: 1.2em;
}

.url-status.loading {
    color: var(--accent);
}

.url-status.success {
    color: var(--success);
}

.url-status.error {
    color: var(--danger);
}

.video-preview {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

.video-preview img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
}

.preview-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
}

.preview-uploader {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-duration {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.input-hint {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

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

.btn-submit {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-submit:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Metadata Section (details/summary) */
.metadata-section {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 1rem 0;
}

.metadata-section summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metadata-section summary:hover {
    color: var(--text-primary);
}

.metadata-section summary::marker {
    color: var(--accent);
}

.metadata-section[open] summary {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.metadata-section .form-group {
    padding: 0 1rem;
    margin-bottom: 1rem;
}

.metadata-section .form-group:last-child {
    margin-bottom: 0.75rem;
}

.metadata-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Compact checkbox group for modal */
.checkbox-group.compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.checkbox-group.compact .checkbox-label {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

/* =============================================================================
   Video Metadata Form
   ============================================================================= */

.video-metadata-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.video-metadata-form .form-input {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.video-metadata-form .form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.video-metadata-form .form-input::placeholder {
    color: var(--text-muted);
}

/* Checkbox Group */
.video-metadata-form .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    border-color: var(--accent);
}

.checkbox-label:has(input:checked) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label span {
    text-transform: capitalize;
}

/* Energy Slider (shared) */
.energy-slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.energy-label-end {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    min-width: 55px;
}

.energy-label-end:last-child {
    text-align: right;
}

.energy-slider-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.energy-slider-wrapper input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: var(--bg-light);
    border-radius: 4px;
    outline: none;
}

.energy-slider-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.energy-slider-wrapper input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.energy-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
}

.energy-ticks span {
    font-size: 1rem;
    text-align: center;
    width: 20px;
    cursor: default;
}

/* WordPress-style Tag Input */
.tag-input-container {
    position: relative;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem;
    min-height: 44px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.tag-input-container:focus-within {
    border-color: var(--accent);
}

.tag-input-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--accent);
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.tag-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 0;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    margin-left: 0.2rem;
}

.tag-remove:hover {
    color: white;
}

.tag-input {
    flex: 1;
    min-width: 120px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.3rem;
    font-size: 0.9rem;
    outline: none;
}

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

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tag-suggestion {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.tag-suggestion:hover,
.tag-suggestion.active {
    background: var(--bg-light);
}

.tag-suggestion-new {
    color: var(--accent);
    border-top: 1px solid var(--border);
}

/* Form Actions */
.video-metadata-form .form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.video-metadata-form .btn-save {
    background: var(--accent);
    border: none;
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-metadata-form .btn-save:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.save-status {
    font-size: 0.85rem;
}

.save-status.saving {
    color: var(--accent);
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--danger);
}
