/**
 * YouTube Playlist View - Filtered (Responsive Redesign)
 * Modern, responsive layout with dark theme using design tokens
 */

/* Universal box-sizing reset */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ==================== BASE & LAYOUT ==================== */

html {
    overflow-x: hidden; /* Clip shadows at viewport edge */
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll and clip shadows on mobile */
}

/* ==================== AMBIENT BACKGROUND ==================== */
/* Full-page blurred background from currently playing song */

.ambient-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.ambient-backdrop.active {
    opacity: 1;
}

.ambient-blur {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    pointer-events: none;
}

.ambient-scrim {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background-color: rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

/* Auth prompt banner needs to be above ambient layers on this page */
.auth-prompt-banner {
    position: relative;
    z-index: 5;
}

/* All content needs to be above the ambient layers */
.container {
    position: relative;
    z-index: 10;
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--space-3);
}

/* Main Two-Column Layout */
.main-content {
    display: grid;
    grid-template-columns: clamp(320px, 30%, 420px) 1fr;
    gap: var(--space-3);
    align-items: start;
}

/* ==================== RIGHT COLUMN LAYOUT ==================== */
.right-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-2); /* Reduced from space-3 for tighter spacing */
}

/* ==================== PLAYLIST PANEL ==================== */

.playlist-panel {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.playlist-header {
    padding: 0;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

/* Three-Tab Navigation */
.playlist-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(40, 40, 40, 0.5);
    position: relative;
}

.playlist-tab {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base) var(--transition-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.playlist-tab:hover {
    background: rgba(60, 60, 60, 0.5);
    color: var(--text-primary);
}

.playlist-tab.active {
    background: rgba(30, 30, 30, 0.5);
    color: var(--text-primary);
    border-bottom-color: var(--accent-primary);
}

.playlist-tab svg {
    width: 16px;
    height: 16px;
}

/* Create Tab - Special Styling */
.playlist-tab-create {
    background: linear-gradient(135deg, var(--create-tab-gradient-start) 0%, var(--create-tab-gradient-end) 100%);
    color: white !important;
    border-bottom-color: transparent !important;
}

.playlist-tab-create:hover {
    background: linear-gradient(135deg, var(--create-tab-gradient-hover-start) 0%, var(--create-tab-gradient-hover-end) 100%);
}

.playlist-tab-create.active {
    background: linear-gradient(135deg, var(--create-tab-gradient-start) 0%, var(--create-tab-gradient-end) 100%);
}

/* ==================== UTILITY CLASSES ==================== */

/* Mobile-only elements (hidden on desktop) */
.mobile-only {
    display: none;
}

/* Desktop-only elements (hidden on mobile) */
.desktop-only {
    display: block;
}

/* Mobile video header - hidden on desktop */
.mobile-video-header {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-only {
        display: flex; /* Most mobile-only elements are flex containers */
    }
    .desktop-only {
        display: none !important;
    }
    .mobile-video-header {
        display: block; /* Show on mobile */
    }
}

/* ==================== PHASE 6: THREE-STATE LIBRARY NAVIGATION ==================== */

/* Top bar with tabs and create button - Desktop: hidden, Mobile: fixed at top */
.library-top-bar {
    display: none; /* Hidden on desktop by default */
}

/* Mobile: Library top bar FIXED at top of screen */
@media (max-width: 1023px) {
    .library-top-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-1) var(--space-2); /* Reduced from space-3 space-4 for compact UI */
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001; /* Above content but below modals */
        height: 40px; /* Reduced from 48px */
        box-sizing: border-box;
    }
}

/* Legacy desktop styles for library-top-bar (if somehow shown) */
.library-top-bar:not(.mobile-only) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1) var(--space-2); /* Reduced for compact UI */
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
}

.library-tabs {
    display: flex;
    gap: var(--space-6);
}

.library-tab {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    padding: var(--space-2) 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast) var(--transition-ease);
}

.library-tab:hover {
    color: rgba(255, 255, 255, 0.9);
}

.library-tab.active {
    color: white;
    border-bottom-color: var(--accent-primary);
}

.library-tab i,
.library-tab svg {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 2px;
}

.library-create-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.85) 0%, rgba(180, 101, 218, 0.85) 100%);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast) var(--transition-ease);
}

.library-create-btn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 1) 0%, rgba(180, 101, 218, 1) 100%);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.5);
    transform: scale(1.05);
}

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

/* Library view containers (Queue, Playlists) */
.library-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.library-view.hidden {
    display: none;
}

/* Tab Content (includes .library-view for Phase 6) */
.playlist-tab-content,
.library-view {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
}

.playlist-tab-content.active,
.library-view:not(.hidden) {
    display: flex;
}

/* Playing Tab Styles */
.playlist-playing-header {
    padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2); /* top right bottom left - keep left full, others half */
    border-bottom: 1px solid var(--border-secondary);
}

.playlist-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-1); /* Reduced from space-2 to allow playlist name to be slightly longer */
    position: relative; /* For absolute positioning of playlist-menu */
    min-height: 32px; /* Ensure proper vertical centering */
}

.playlist-name {
    margin: 0; /* Remove bottom margin for cleaner alignment */
    font-size: var(--text-sm); /* Match venue header size */
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap; /* Never wrap to second line */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ... when truncated */
    line-height: 1.4; /* Better vertical centering */
}

/* Add to Library Button (for unsaved/transient playlists) */
.add-to-library-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.add-to-library-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.add-to-library-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.add-to-library-btn i,
.add-to-library-btn svg {
    width: 14px;
    height: 14px;
}

/* Spinning loader animation for save button */
.add-to-library-btn .loading-spinner {
    animation: spin 1s linear infinite;
}

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

.playlist-meta {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Library Tab Styles */
.library-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-secondary);
}

.library-search {
    position: relative;
    display: flex;
    align-items: center;
}

.library-search svg {
    position: absolute;
    left: var(--space-3);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.library-search input {
    width: 100%;
    padding: var(--space-2) var(--space-2) var(--space-2) 36px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: border-color var(--transition-base);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.library-search input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.library-search input::placeholder {
    color: var(--text-tertiary);
}

.library-playlists {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.library-playlists::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.library-playlists::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.library-playlists::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-sm);
}

.library-playlists::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.library-playlist-card {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-2);
    margin-bottom: 0;
    cursor: pointer;
    transition: background-color var(--transition-base) var(--transition-ease);
    display: flex;
    flex-direction: row;
    gap: var(--space-3);
    align-items: flex-start;
}

.library-playlist-card:hover {
    background: var(--bg-hover);
    border-bottom-color: var(--border-primary);
}

.library-playlist-card.active {
    background: var(--accent-primary-bg-15);
    border-left: 4px solid var(--accent-primary);
    border-bottom: 1px solid var(--accent-primary-bg-20);
}

.library-playlist-card:nth-child(even) {
    background: var(--bg-tertiary);
}

.library-playlist-card:nth-child(even):hover {
    background: var(--bg-hover);
}

/* Album Section (grid + song count) */
.playlist-album-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

/* Album Art Grid (2x2 layout) */
.playlist-album-grid {
    width: 80px;
    height: 80px;
    display: grid;
    grid-template-columns: 40px 40px;
    grid-template-rows: 40px 40px;
    gap: 0;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.playlist-album-grid img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    display: block;
}

/* Empty playlist placeholder */
.playlist-album-empty {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
}

.playlist-album-empty i,
.playlist-album-empty svg {
    width: 32px;
    height: 32px;
}

/* Song count below album grid */
.playlist-album-section .library-playlist-meta {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-tertiary);
    margin: 0;
    text-align: center;
    white-space: nowrap;
}

/* Playlist Info Container */
.library-playlist-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.library-playlist-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: 0;
    padding: 0 36px 0 0;
}

.library-playlist-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    flex: 1;
}

.btn-delete-playlist {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-playlist:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}

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

.library-playlist-meta {
    font-size: var(--text-sm);
    font-weight: var(--font-normal);
    color: var(--text-tertiary);
    margin: 0;
}

.library-playlist-progress {
    margin-top: var(--space-2);
}

/* Library Filter Pills */
.library-filter-pills {
    margin-top: 0;
    padding: var(--space-1) 0;
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.mini-pill {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

/* Playlist Menu (Three Dots) */
.playlist-menu {
    position: absolute;
    top: 0;
    right: 0;
}

.btn-playlist-menu {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    opacity: 0.6;
    transition: opacity var(--transition-base), background var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

.library-playlist-card:hover .btn-playlist-menu {
    opacity: 1;
}

.btn-playlist-menu:hover {
    opacity: 1;
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.playlist-menu-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: var(--space-1);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 140px;
    z-index: var(--z-popover);
    overflow: hidden;
}

.playlist-menu-dropdown .menu-item {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: none;
    text-align: left;
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.playlist-menu-dropdown .menu-item:hover {
    background: var(--bg-hover);
}

.playlist-menu-dropdown .menu-item svg {
    width: 16px;
    height: 16px;
}

.playlist-menu-dropdown .menu-delete {
    color: var(--color-error);
}

.playlist-menu-dropdown .menu-delete:hover {
    background: var(--color-error-bg);
}

/* Playlist Name Field */
.playlist-name-field {
    margin-bottom: var(--space-5);
}

.playlist-name-field label {
    display: block;
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.playlist-name-field .form-input {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: border-color var(--transition-base);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.playlist-name-field .form-input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.playlist-name-field .form-input::placeholder {
    color: var(--text-tertiary);
}

/* Empty States */
.playlist-empty-state,
.library-empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-5);
    color: var(--text-tertiary);
}

.empty-state-icon {
    margin-bottom: var(--space-4);
}

.empty-state-icon svg {
    width: 48px;
    height: 48px;
    color: var(--text-disabled);
}

.playlist-empty-state p,
.library-empty-state p {
    margin: var(--space-2) 0;
    font-size: var(--text-sm);
}

.empty-state-hint {
    font-size: var(--text-sm);
    color: var(--text-disabled);
}

.playlist-empty-state {
    display: none;
}

.playlist-empty-state.visible {
    display: block;
}

/* Playlist Loading State */
.playlist-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-5);
    color: var(--text-secondary);
    gap: var(--space-3);
}

.playlist-loading-state i,
.playlist-loading-state svg {
    width: 32px;
    height: 32px;
    color: var(--text-disabled);
    animation: spin 1s linear infinite;
}

.playlist-loading-state span {
    font-size: var(--text-sm);
    color: var(--text-disabled);
}

.playlist-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-1);
    cursor: pointer;
    transition: background var(--transition-base);
}

.playlist-item:hover {
    background: linear-gradient(30deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.01) 100%);
}

.playlist-item.active {
    background-color: var(--accent-primary-bg-15);
}

.playlist-item-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Artist Grouping Styles
   - artist-group: Wrapper for multi-song artists (image + content)
   - artist-header: Artist name row (inside artist-group)
   - song-only: Song title row (inside artist-group)
   - flat: Image + artist + song on one line (for single-song artists)
   ========================================================================== */

/* Artist group wrapper: image on left, content (artist name + songs) on right */
.artist-group {
    display: flex;
    flex-direction: row;
    align-items: flex-start;  /* Top-align image with content */
    gap: var(--space-2);
    padding-left: var(--space-1);
    padding-right: 4px;  /* 4px here + 4px from .playlist-item = 8px total, matching show header */
    margin-bottom: 6px;
}

/* Artist group image: spans full height of the group */
.artist-group-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-top: var(--space-1);  /* Align with first row's padding */
}

/* Artist group content: contains artist header and song rows */
.artist-group-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Artist header row inside artist-group */
.artist-group-content .playlist-item-artist-header {
    padding-left: 3px;
    padding-top: calc(var(--space-1) + 2px);
}

/* Song-only row inside artist-group */
.artist-group-content .playlist-item-song-only {
    padding-left: 3px;
}

/* Song-only row: compact height for clickability */
.playlist-item-song-only {
    padding-top: calc(var(--space-1) + 3px);
    padding-bottom: calc(var(--space-1) + 3px);
    min-height: auto;
}

/* Flat row: standard single-song artist layout (unchanged from original) */
.playlist-item-flat {
    /* Uses default playlist-item styles */
}

/* Remove bottom margin from last artist-group in container */
.artist-group:last-child {
    margin-bottom: 0;
}

/* Last song in an artist group gets bottom margin for spacing between artists */
.playlist-item.last-in-group {
    margin-bottom: 6px;
}

/* Remove bottom margin from last item in container to avoid double spacing */
.playlist-item.last-in-group:last-child {
    margin-bottom: 0;
}

.playlist-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.playlist-item-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.playlist-item-artist {
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-separator {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    font-weight: var(--font-normal);
}

.playlist-item-song {
    font-size: var(--text-xs);
    font-weight: var(--font-normal);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Spotify audio-only indicator icon */
.spotify-audio-icon {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    vertical-align: middle;
    margin-left: 4px;
}

/* Equalizer Bars - Context Rules for Playlist View */
/* Base styles are in design-tokens.css */

/* Hide equalizer by default in playlist items */
.playlist-item .equalizer-bars {
    display: none;
}

/* Show equalizer only for active (playing) playlist item */
.playlist-item.active .equalizer-bars {
    display: inline-flex;
}

/* Pause equalizer animation when playback is paused */
.playlist-item.active.paused .equalizer-bar {
    animation-play-state: paused;
}

.playlist-item-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.rating-display {
    color: var(--accent-primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.rating-star {
    font-size: 0.85em;
}

/* Favorite button in artist header row */
.playlist-item-artist-header .fav-btn--artist-row {
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.playlist-item-artist-header .fav-btn--artist-row:hover {
    opacity: 1;
}

.playlist-item-artist-header .fav-btn--artist-row.fav-btn--active {
    opacity: 1;
}

/* ==========================================================================
   Show Group Containers with Gradient Background
   ========================================================================== */

.playlist-show-group {
    position: relative;
    margin-bottom: var(--space-1);
    border-radius: var(--radius-md);
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.055) 0%,
        transparent 100%
    );
}

/* Alternate groups get a slightly different gradient for visual rhythm */
.playlist-show-group.alt {
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.035) 0%,
        transparent 65%
    );
}

/* No-show section - more muted */
.playlist-show-group.no-show-group {
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.025) 0%,
        transparent 100%
    );
}

/* Show Grouping Headers */
.playlist-show-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 5px 8px 5px var(--space-3);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 3px solid rgba(139, 92, 246, 0.7);
    color: rgba(255, 255, 255, 0.7);
    font-weight: var(--font-medium);
    font-size: 11px;
    margin: 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    transition: background 0.2s ease, backdrop-filter 0.2s ease, -webkit-backdrop-filter 0.2s ease;
}

/* Show header text (truncates with ellipsis) */
.playlist-show-header__text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Favorite button in show header */
.playlist-show-header .fav-btn--header {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.playlist-show-header .fav-btn--header:hover {
    opacity: 1;
}

.playlist-show-header .fav-btn--header.fav-btn--active {
    opacity: 1;
}

/* When header is stuck at top, fully opaque neutral gray to prevent text overlap */
.playlist-show-header.stuck {
    background: rgb(40, 40, 40);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
}

.playlist-show-header.no-show {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
    border-left: 3px solid rgba(255, 255, 255, 0.15);
}

/* Multi-Show Badge */
.multi-show-badge {
    display: inline-block;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background-color: var(--bg-hover);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    cursor: help;
    margin-left: var(--space-2);
}

.multi-show-badge:hover {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

/* Multi-Show Tooltip */
.multi-show-tooltip {
    position: fixed;
    background: var(--overlay-darker);
    color: white;
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    z-index: var(--z-tooltip);
    min-width: 200px;
    max-width: 350px;
    box-shadow: var(--shadow-xl);
    pointer-events: none;
}

.tooltip-header {
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--white-border-20);
    color: var(--accent-primary);
}

.tooltip-show {
    padding: var(--space-1) 0;
    line-height: var(--leading-normal);
    color: var(--white-text-90);
}

.tooltip-show.current-show {
    color: var(--accent-primary);
    font-weight: var(--font-medium);
}

/* Scrollbar styling */
.playlist-items::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.playlist-items::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.playlist-items::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-sm);
}

.playlist-items::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ==================== PLAYER PANEL ==================== */

.player-panel {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* ==================== UNIFIED CONTROLS BAR (mini bar style) ==================== */
.player-controls-bar {
    padding: var(--space-2) var(--space-3);
}

.player-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
    gap: var(--space-3);
}

.now-playing-inline {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.now-playing-artist {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-separator {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    display: none; /* Hidden until content loads */
}

.now-playing-separator.visible {
    display: inline;
}

.now-playing-song {
    font-size: calc(var(--text-sm) * 0.9);
    font-weight: var(--font-normal);
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.next-show-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    color: var(--accent-primary);
    flex-shrink: 0;
}

.next-show-info svg {
    width: 12px;
    height: 12px;
}

/* Hide ticket icon when no date */
.next-show-info:empty,
.next-show-info:not(:has(span:not(:empty))) {
    display: none;
}

.player-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Desktop sizing moved below base rules - see "DESKTOP: Larger Controls" section */

/* Desktop: player-panel is now inside playlist-panel, visible at top */
@media (min-width: 768px) {
    .playlist-panel {
        position: relative; /* Not fixed on desktop */
        display: flex;
        flex-direction: column;
        height: auto;
        transform: none !important; /* Override mobile transform */
    }

    .player-panel {
        position: relative; /* Not sticky on desktop */
        border-radius: var(--radius-md);
        border-bottom: 1px solid var(--border-secondary);
        margin-bottom: 0; /* Removed spacing - gap handled by .right-column */
        /* No order - use natural DOM order (tabs first, then content, then player-panel) */
    }

    /* No order rules on desktop - let natural DOM order prevail */
    /* On desktop: tabs → content → player-panel (below video) */
}

/* Playback Controls Row (with mode indicator) */
.playback-controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-2);
    position: relative;
    flex-wrap: nowrap;
}

.player-mode-indicator {
    position: absolute;
    left: var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-mode-indicator .mode-icon {
    display: inline-block;
}

/* Settings Button (Gear Icon) */
.btn-settings {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Player Container
 * 
 * Uses padding-bottom technique for YouTube (16:9 aspect ratio)
 * Switches to fixed height for Spotify (152px standard embed height)
 * 
 * Note: Spotify embeds cannot be forced into 16:9 aspect ratio due to
 * internal layout constraints. The container height adjusts when switching
 * between players, with smooth transitions to minimize jarring movement.
 */
.player-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio for YouTube */
    height: 0;
    overflow: hidden;
    background: var(--bg-primary);
    z-index: var(--z-base);
    transition: padding-bottom 0.3s ease, height 0.3s ease; /* Smooth transition when switching players */
}

.player-container.spotify-active {
    padding-bottom: 0; /* Remove padding-bottom for Spotify */
    height: var(--player-spotify-height); /* Use Spotify's standard embed height (152px) */
    overflow: visible; /* Allow Spotify embed to show */
    background: var(--bg-primary);
}

.player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-tertiary);
}

.player-placeholder-icon {
    margin-bottom: var(--space-3);
}

.player-placeholder-icon svg {
    width: 48px;
    height: 48px;
}

#youtube-player,
#youtube-player-mobile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#spotify-player-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#spotify-embed {
    width: 100%;
    height: 100%;
}

/* Style the Spotify iframe */
#spotify-embed > iframe {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Video Loading Overlay */
#video-loading-overlay,
#video-loading-overlay-mobile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    color: white;
    animation: spinner-rotate 3s linear infinite;
}

.loading-text {
    color: white;
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    text-align: center;
}

@keyframes spinner-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Spotify Preview Message */
.spotify-preview-message {
    padding: var(--space-2);
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: var(--text-xs);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

.spotify-preview-message svg {
    width: 14px;
    height: 14px;
}

/* Video Error Message */
.video-error-message {
    padding: var(--space-2);
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: var(--text-xs);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

.video-error-message svg {
    width: 14px;
    height: 14px;
}

.video-error-message a {
    color: var(--color-warning);
    text-decoration: underline;
    font-weight: var(--font-semibold);
}

.video-error-message a:hover {
    color: var(--color-warning-hover);
}

/* Now Playing styles moved to UNIFIED CONTROLS BAR section above */

.now-playing-song-small {
    font-size: var(--text-sm);
    font-weight: var(--font-normal);
    color: var(--text-secondary);
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Hide +60s button */
#skip60Btn {
    display: none;
}

.control-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: var(--space-1);
    cursor: pointer;
    transition: color var(--transition-fast);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

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

.control-btn-primary {
    background: var(--accent-primary);
    border-radius: 50%;
    color: white;
    min-width: 36px;
    min-height: 36px;
}

/* Fill play/pause icons solid white */
.control-btn-primary svg {
    fill: white;
    stroke: white;
}

/* Only apply hover styles on devices that support hover (desktop) */
@media (hover: hover) and (pointer: fine) {
    .control-btn:hover:not(:disabled) {
        color: white;
    }

    .control-btn-primary:hover:not(:disabled) {
        background: var(--accent-primary-hover, #c77de6);
        color: white;
    }
}

/* Mobile touch feedback - button should not stay highlighted after tap */
.control-btn:focus {
    outline: none;
}

/* Only show focus indicator for keyboard navigation, not touch/mouse */
.control-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Brief visual feedback during tap/click - works on all devices */
.control-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

/* Rating Section */
.rating-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
}

.rating-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    white-space: nowrap;
    display: none; /* Hidden on both desktop and mobile */
}

.rating-stars {
    display: flex;
    gap: 0;
    align-items: center;
    justify-content: center;
}

/* Mobile/Narrow: Horizontal layout with centered stars */
@media (max-width: 767px) {
    /* Mobile: Player panel ALWAYS visible, fixed at bottom above app nav */
    .player-panel {
        display: block !important; /* Override any hiding rules */
        position: fixed !important;
        bottom: calc(56px + env(safe-area-inset-bottom)) !important; /* Above app bottom nav */
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 99998 !important;
        background: rgba(0, 0, 0, 0.4) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .player-controls-bar {
        padding: var(--space-2) var(--space-1); /* Reduced horizontal padding */
    }

    .player-info-row {
        margin-bottom: var(--space-2);
        padding: 0 var(--space-1); /* Match reduced padding */
    }

    .playback-controls-row {
        flex-direction: row; /* Side by side: controls left, stars right */
        gap: 4px; /* Minimal gap between controls and stars */
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    .playback-controls {
        flex-shrink: 1; /* Allow controls to shrink if needed */
        gap: var(--space-1); /* Very tight spacing between buttons to fit */
        display: flex;
        align-items: center;
    }

    /* Mobile playback controls - sized for touch */
    .control-btn {
        min-width: 37px;
        min-height: 37px;
    }

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

    .control-btn-primary {
        min-width: 40px;
        min-height: 40px;
    }

    .rating-section {
        flex-direction: row; /* Horizontal stars */
        border-left: none;
        border-top: none; /* No separator - same row now */
        padding-left: 0;
        padding-right: 0;
        gap: 0;
        position: relative;
        width: auto; /* Let it size naturally */
        flex-shrink: 0; /* Don't shrink stars */
        align-items: center;
        justify-content: flex-end; /* Align stars to the right */
        height: 37px; /* Match control button height for alignment */
    }

    .rating-label {
        display: none; /* Hide label on mobile */
    }

    .rating-stars {
        display: flex;
        align-items: center;
        height: 100%;
    }
}

/* Desktop: Ensure side-by-side stays on one line */
@media (min-width: 768px) {
    .playback-controls-row {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    .rating-section {
        flex-direction: row;
        flex-shrink: 0;
    }
}

.rating-star-btn {
    padding: 4px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rating-star-btn svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

/* Only apply hover styles on devices that support hover (desktop) */
@media (hover: hover) and (pointer: fine) {
    .rating-star-btn:hover:not(:disabled) {
        color: var(--star-yellow);
    }

    .rating-star-btn:hover:not(:disabled) svg {
        transform: scale(1.1);
    }
}

/* Mobile touch feedback - prevent stuck hover state */
.rating-star-btn:focus {
    outline: none;
}

/* Only show focus indicator for keyboard navigation */
.rating-star-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Brief visual feedback during tap/click */
.rating-star-btn:active:not(:disabled) svg {
    transform: scale(1.1);
}

.rating-star-btn.filled {
    color: var(--star-yellow);
}

.rating-star-btn.filled svg {
    fill: var(--star-yellow);
    stroke: var(--star-yellow);
}

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

.rating-star-btn:disabled:hover {
    transform: none;
    background: transparent;
}

/* Animation for rating set */
@keyframes starFill {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.4);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.rating-star-btn.animating {
    animation: starFill 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rating-message {
    margin-top: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    text-align: center;
    display: none;
}

.rating-message.success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.rating-message.error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* ==================== DESKTOP: Larger Controls ==================== */
/* Must come AFTER base control/star rules to override them */
@media (min-width: 769px) {
    .player-controls-bar {
        padding: var(--space-4) var(--space-5);
    }

    .player-info-row {
        margin-bottom: var(--space-3);
        gap: var(--space-4);
    }

    .now-playing-artist {
        font-size: var(--text-lg);
    }

    .now-playing-separator {
        font-size: var(--text-lg);
    }

    .now-playing-song {
        font-size: calc(var(--text-base) * 0.9);
    }

    .next-show-info {
        font-size: var(--text-sm);
        gap: 6px;
    }

    .next-show-info svg {
        width: 16px;
        height: 16px;
    }

    .playback-controls {
        gap: var(--space-3);
    }

    /* Playback controls */
    .control-btn {
        min-width: 41px;
        min-height: 41px;
        font-size: var(--text-sm);
    }

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

    .control-btn-primary {
        min-width: 47px;
        min-height: 47px;
    }

    /* Rating stars */
    .rating-section {
        gap: 4px;
    }

    .rating-star-btn {
        padding: 6px;
    }

    .rating-star-btn svg {
        width: 29px;
        height: 29px;
    }
}

/* Settings Modal Specific Styles */
.settings-section {
    margin-bottom: var(--space-5);
}

.settings-section h3 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--space-3) 0;
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: var(--space-5) 0;
}

.skip-option-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.skip-option-group input[type="checkbox"] {
    cursor: pointer;
}

.skip-option-group label {
    cursor: pointer;
    margin: 0;
    white-space: nowrap;
}

.skip-option-group select {
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    cursor: pointer;
    min-width: 50px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-full-width {
    width: 100%;
}

/* Custom Checkboxes */
#skipRatedCheckbox, #autoSkipCheckbox, #autoplayOnLoadCheckbox {
    appearance: none;
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-sm);
    width: 16px;
    height: 16px;
    cursor: pointer;
    position: relative;
}

#skipRatedCheckbox:hover, #autoSkipCheckbox:hover, #autoplayOnLoadCheckbox:hover {
    border-color: var(--accent-primary);
}

#skipRatedCheckbox:checked, #autoSkipCheckbox:checked, #autoplayOnLoadCheckbox:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

#skipRatedCheckbox:checked::after, #autoSkipCheckbox:checked::after, #autoplayOnLoadCheckbox:checked::after {
    content: '✓';
    font-size: 12px;
    color: white;
    font-weight: bold;
    position: absolute;
    left: 2px;
    top: -1px;
}

/* ==================== VIDEO OPTIONS PANEL ==================== */

.video-options-panel {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.video-options-toggle {
    width: 100%;
    padding: var(--space-2);
    background: rgba(40, 40, 40, 0.5);
    border: none;
    border-bottom: 1px solid var(--border-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.video-options-toggle svg {
    width: 16px;
    height: 16px;
}

.video-options-toggle:hover {
    background: var(--bg-hover);
}

.video-options-container {
    padding: var(--space-2);
    overflow-x: hidden;
}

.video-selection-diagnostic {
    padding: var(--space-2);
    background: var(--accent-primary-bg-10);
    border: 1px solid var(--accent-primary-border-30);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--accent-primary);
    margin-bottom: var(--space-3);
    display: none !important;
}

.video-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.video-card {
    background: transparent;
    border: none;
    outline: none;
    border-radius: 0;
    padding: var(--space-1) var(--space-1);
    transition: background var(--transition-base);
    cursor: pointer;
    display: flex;
    flex-direction: row;
    gap: var(--space-2);
    align-items: flex-start;
    min-width: 0;
}

.video-card:hover {
    background: linear-gradient(30deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.01) 100%);
}

.video-card.default {
    background: transparent;
}

.video-card.default:hover {
    background: linear-gradient(30deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.01) 100%);
}

.video-thumbnail-container {
    position: relative;
    flex-shrink: 0;
    width: 140px;
}

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.video-left-column {
    flex-shrink: 0;
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.video-info-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-right: 32px;
}

.external-link-icon {
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    width: 20px;
    height: 20px;
    background: var(--overlay-medium);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.external-link-icon svg {
    width: 12px;
    height: 12px;
    color: white;
}

.video-playing-overlay {
    position: absolute;
    top: var(--space-1);
    left: var(--space-1);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.video-playing-overlay .equalizer-bars {
    margin-left: 0;
    height: 10px;
    gap: 2px;
}

.video-playing-overlay .equalizer-bar {
    width: 2px;
}

/* Pause equalizer when video is paused */
.video-card.paused .video-playing-overlay .equalizer-bar {
    animation-play-state: paused;
}

.video-title {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0;
    padding-top: 3px; /* Small spacing above title */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.video-meta-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: 0;
}

.video-channel-inline {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.video-channel {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-2);
}

.video-badges {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}

.default-badge {
    background: var(--accent-primary);
    color: var(--text-inverse);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-lg);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.video-type-badge {
    background: var(--badge-muted-bg);
    color: var(--badge-muted-text);
    padding: 2px 6px;
    border-radius: var(--radius-lg);
    font-size: 10px;
    font-weight: var(--font-medium);
    opacity: 0.65;
}

.set-default-btn {
    width: 100%;
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
}

.set-default-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.set-default-btn:disabled {
    background: var(--accent-primary-bg-10);
    opacity: 1;
}

/* Disabled Videos */
.disabled-videos-header {
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: 0;
    margin: var(--space-3) calc(var(--space-4) * -1) var(--space-2) calc(var(--space-4) * -1);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.disabled-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.disabled-header-main svg {
    width: 16px;
    height: 16px;
    color: var(--color-error);
}

.disabled-header-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-weight: var(--font-normal);
    padding-left: 22px;
}

.video-card-disabled {
    background: transparent;
    border: none;
    outline: none;
}

.video-card-disabled:hover {
    background: linear-gradient(30deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.01) 100%);
}

.thumbnail-external-icon {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    background: var(--overlay-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}

.thumbnail-external-icon svg {
    width: 14px;
    height: 14px;
    color: white;
}

.disabled-video-buttons {
    display: flex;
    gap: var(--space-2);
    width: 100%;
}

.btn-watch-youtube {
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    justify-content: center;
    white-space: nowrap;
    flex: 1;
    transition: all var(--transition-base);
}

.btn-watch-youtube:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-watch-youtube svg {
    width: 12px;
    height: 12px;
}

.btn-try-stagemuse {
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    justify-content: center;
    white-space: nowrap;
    flex: 1;
    transition: all var(--transition-base);
}

.btn-try-stagemuse:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-try-stagemuse svg {
    width: 12px;
    height: 12px;
}

.btn-open-youtube {
    width: 100%;
    padding: var(--space-2);
    background: var(--color-error);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    cursor: pointer;
}

.btn-open-youtube:hover {
    background: var(--color-error-hover);
}

.video-options-message {
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    text-align: center;
    display: none;
}

.video-options-message.success {
    background: var(--color-success-bg);
    color: var(--color-success);
    display: block;
}

.video-options-message.error {
    background: var(--color-error-bg);
    color: var(--color-error);
    display: block;
}

.search-youtube-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--accent-primary);
    color: var(--text-inverse);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    transition: background var(--transition-base);
    cursor: pointer;
    white-space: nowrap;
}

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

.search-youtube-btn i {
    width: 16px;
    height: 16px;
}

/* ==================== MODALS ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-dark);
    overflow: auto;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-2xl);
}

.modal-content-large {
    max-width: 900px;
}

.modal-content-small {
    max-width: 500px;
}

.modal-content-fit {
    height: fit-content;
}

.modal-content-fit .modal-body {
    max-height: none;
}

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

.modal-header h2 {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

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

.modal-body {
    padding: var(--space-5);
    max-height: 70vh;
    overflow-y: auto;
}

#new-playlist-modal .modal-body {
    padding-bottom: 0;
}

/* Scrollbar styling for new playlist modal */
#new-playlist-modal .modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#new-playlist-modal .modal-body::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

#new-playlist-modal .modal-body::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

#new-playlist-modal .modal-body::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-sm);
}

#new-playlist-modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.modal-description {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    line-height: var(--leading-relaxed);
}

/* Share Modal Specific Styles */
#share-modal .share-link-container {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
}

#share-modal .share-link-container .form-input {
    flex: 1;
    padding: var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    transition: border-color var(--transition-base);
}

#share-modal .share-link-container .form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#share-modal .share-link-container .form-input::selection {
    background: var(--accent-primary);
    color: white;
}

#share-modal #copy-link-btn {
    padding: var(--space-2) var(--space-3) !important;
    font-size: 0.8125rem !important;
    flex-shrink: 0;
    gap: var(--space-2);
}

#share-modal #copy-link-btn svg {
    width: 14px;
    height: 14px;
}

#share-modal .share-info {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: rgba(59, 130, 246, 0.08);
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent-primary);
}

#share-modal .share-info small {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.5;
}

#share-modal .share-info svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--accent-primary);
    opacity: 0.7;
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-primary);
}

.modal-footer-sticky {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    margin-top: var(--space-5);
    margin-left: calc(var(--space-5) * -1);
    margin-right: calc(var(--space-5) * -1);
    background: var(--bg-secondary);
    border-top: 2px solid var(--border-primary);
    box-shadow: var(--shadow-sticky);
    z-index: var(--z-sticky);
}

.modal-footer-actions {
    display: flex;
    gap: var(--space-3);
    flex-shrink: 0;
}

/* Saved Playlist Items in Modal */
.saved-playlist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    transition: all var(--transition-base);
}

.saved-playlist-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.playlist-item-info h3 {
    margin: 0 0 var(--space-1) 0;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.playlist-item-info p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.progress-info {
    margin-top: var(--space-2);
}

.mini-progress {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-1);
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-primary-hover));
}

.progress-label {
    font-size: var(--text-xs);
    color: var(--accent-primary);
    font-weight: var(--font-medium);
}

.btn-load-playlist {
    padding: var(--space-2) var(--space-4);
    background: var(--color-success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-load-playlist:hover {
    background: var(--color-success-hover);
    transform: translateY(-1px);
}

.empty-message {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--space-10) var(--space-5);
}

/* ==================== BUTTONS ==================== */

.btn {
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    transition: all var(--transition-base) var(--transition-ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

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

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--create-tab-gradient-start) 0%, var(--create-tab-gradient-end) 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--create-tab-gradient-hover-start) 0%, var(--create-tab-gradient-hover-end) 100%);
}

.btn-secondary {
    background: var(--bg-active);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

/* Filter Form Styles */
.filter-form {
    margin: 0;
}

.form-group-dates label,
.form-group-songs label {
    display: block;
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.form-group-songs {
    margin-top: var(--space-4);
}

.date-inputs-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.date-inputs-row input[type="date"] {
    flex: 1;
    max-width: 180px;
    padding: 8px 12px; /* Increased from 6px to 8px for ~20% taller touch targets */
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer; /* Make entire field appear clickable */
    /* Style the calendar icon for dark theme */
    color-scheme: dark;
}

/* Webkit browsers (Chrome, Safari, Edge) - style calendar picker icon */
.date-inputs-row input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: brightness(0) invert(0.7); /* Light gray icon - brightness(0) makes it black first, then invert lightens it */
    opacity: 1;
}

.date-inputs-row input[type="date"]::-webkit-calendar-picker-indicator:hover {
    filter: brightness(0) invert(1); /* White on hover - full invert to white */
}

.date-separator {
    color: var(--text-secondary);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
}

.number-input-controls {
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 40px;
}

.number-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    width: 44px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base) var(--transition-ease);
    padding: 0;
}

.number-btn:hover:not(:disabled) {
    background: var(--bg-hover);
}

.number-btn:active:not(:disabled) {
    background: var(--bg-active);
}

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

.number-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.number-btn-minus {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
}

.number-btn-plus {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}

.number-input-controls input[type="number"] {
    width: 60px;
    height: 40px;
    text-align: center;
    border: 1px solid var(--border-primary);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    -moz-appearance: textfield;
    appearance: textfield;
    padding: 0;
    box-sizing: border-box;
}

.number-input-controls input[type="number"]::-webkit-outer-spin-button,
.number-input-controls input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.artist-count-display {
    padding: var(--space-3) 0;
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    flex-grow: 1;
}

/* Collapsible Filter Sections */
.filter-section-collapsible {
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    overflow: hidden;
    background: rgba(30, 30, 30, 0.65);
}

.filter-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: rgba(40, 40, 40, 0.5);
    border: none;
    width: 100%;
    cursor: pointer;
    transition: all var(--transition-base) var(--transition-ease);
    text-align: left;
}

.filter-section-header:hover {
    background: rgba(60, 60, 60, 0.5);
}

.filter-section-header.active {
    background: rgba(30, 30, 30, 0.5);
    border-bottom: 1px solid var(--border-primary);
}

.filter-section-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform var(--transition-base) var(--transition-ease);
    color: var(--text-secondary);
}

.filter-section-header.active .filter-section-chevron {
    transform: rotate(90deg);
}

.filter-section-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.filter-section-title {
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    color: var(--text-primary);
    flex-shrink: 0;
}

.filter-section-summary {
    flex: 1;
    text-align: right;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.filter-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-section-content.active {
    max-height: 2000px;
}

.filter-section-body {
    padding: var(--space-4);
}

/* Filter Summary Pills */
/* Container for song count + filter pills */
/* Hidden for cleaner UI - filter info available via "Filters" menu item */
.filters-container {
    display: none; /* Hidden but code preserved for potential future use */
    /* Original styles preserved below */
    /* display: flex; */
    flex-wrap: wrap; /* Wrap on desktop */
    gap: var(--space-2);
    padding: calc(var(--space-2) + 1px) 0 var(--space-2) 2px; /* 2px left, +1px top */
    align-items: center;
}

.filters-container .playlist-meta {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: var(--text-xs); /* Match filter pill text size */
}

.filters-container .filter-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: 0;
}

.filter-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    align-items: center;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition-base) var(--transition-ease);
}

.filter-pill svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.filter-pill.pill-edit {
    background: linear-gradient(135deg, var(--create-tab-gradient-start) 0%, var(--create-tab-gradient-end) 100%);
    color: white;
    border-color: var(--create-tab-gradient-start);
    cursor: pointer;
    padding: var(--space-1) var(--space-3);
}

.filter-pill.pill-edit:hover {
    background: linear-gradient(135deg, var(--create-tab-gradient-hover-start) 0%, var(--create-tab-gradient-hover-end) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-gradient-sm);
}

/* AI Name Generation */
.ai-sparkle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base) var(--transition-ease);
    flex-shrink: 0;
}

.ai-sparkle-btn:hover {
    transform: scale(1.05);
    background: var(--bg-hover);
}

.ai-sparkle-btn:active {
    transform: scale(0.95);
}

.ai-sparkle-btn:disabled {
    background: var(--bg-active);
    cursor: not-allowed;
    transform: none;
}

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

.ai-sparkle-btn.loading {
    background: var(--bg-active);
    pointer-events: none;
}

.ai-sparkle-btn.loading svg {
    animation: sparkle-rotate 1s linear infinite;
}

@keyframes sparkle-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.generating-name {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-style: italic;
}

.generating-name .sparkle {
    display: inline-block;
    animation: sparkle-pulse 1.5s ease-in-out infinite;
}

@keyframes sparkle-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2) rotate(180deg);
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

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

.modal.show {
    display: block;
}

/* Debug Mode - Genre Display */
.playlist-item-genres {
    display: none;
    margin-left: var(--space-2);
    padding: 2px 6px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}

.playlist-item.show-genres .playlist-item-genres {
    display: inline-block;
}

/* ==================== RESPONSIVE DESIGN ==================== */

.playlist-close-btn {
    display: none; /* Hidden by default, shown on mobile when expanded */
    background: transparent;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    min-width: 38px; /* Touch target size */
    min-height: 38px;
    align-items: center;
    justify-content: center;
}

.playlist-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.playlist-close-btn:active {
    background: var(--bg-active);
}

.playlist-close-btn svg {
    width: 24px; /* Larger icon for better visibility */
    height: 24px;
}

/* Mobile/Tablet: Full-screen modal for Create/Edit playlist */
/* Must match the 1023px breakpoint where mobile layout is active */
@media (max-width: 1023px) {
    #new-playlist-modal,
    #playlist-filters-view-modal {
        z-index: 100000 !important; /* Above mobile video header, player panel (99998), and bottom nav (99999) */
        overflow: hidden;
    }

    #new-playlist-modal .modal-content,
    #playlist-filters-view-modal .modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    #new-playlist-modal .modal-header,
    #playlist-filters-view-modal .modal-header {
        flex-shrink: 0;
        padding: var(--space-3) var(--space-4);
        border-bottom: 2px solid var(--border-primary);
    }

    #new-playlist-modal .modal-body,
    #playlist-filters-view-modal .modal-body {
        flex: 1;
        max-height: none;
        overflow-y: auto;
        padding: var(--space-4);
        padding-bottom: 0;
    }

    #new-playlist-modal .modal-footer-sticky {
        flex-shrink: 0;
        margin-top: 0;
        margin-left: calc(var(--space-4) * -1);
        margin-right: calc(var(--space-4) * -1);
    }
}

/* ==================== PHASE 6: MOBILE LAYOUT ==================== */
/* Tablet/Mobile: Stack to single column with top tabs */
@media (max-width: 1023px) {
    /* ==================== MOBILE VIDEO STICKY HEADER SYSTEM ==================== */
    /* CSS Custom Properties for mobile video heights */
    :root {
        --video-height-full: 56.25vw;        /* YouTube 16:9 */
        --video-height-shrunk: 28vw;         /* YouTube 50% */
        --video-height-spotify: 152px;       /* Spotify full */
        --video-height-spotify-shrunk: 80px; /* Spotify compact */
        --tab-bar-height: 40px; /* Reduced from 48px for compact mobile UI */
        --player-controls-height: 64px;
        --app-nav-height: 52px;
    }

    /* Mobile Video Header - Fixed container for video + tabs */
    .mobile-video-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        background: transparent; /* Transparent to allow glass effect on child elements */
        transform: translateZ(0); /* GPU acceleration */
        will-change: height;
        padding-top: env(safe-area-inset-top, 0px); /* iOS notch/Dynamic Island safe area */
    }

    /* Player container inside mobile header uses dynamic height */
    .mobile-video-header .player-container {
        position: relative;
        height: var(--video-height-full);
        padding-bottom: 0 !important; /* Override aspect-ratio trick */
        transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        background: #000; /* Solid background for video area */
    }

    .mobile-video-header .player-container.shrunk {
        height: var(--video-height-shrunk);
    }

    /* Spotify overrides for mobile video header */
    .mobile-video-header .player-container.spotify-active {
        height: var(--video-height-spotify);
    }

    .mobile-video-header .player-container.spotify-active.shrunk {
        height: var(--video-height-spotify-shrunk);
    }

    /* Ensure iframe fills the dynamic height container */
    .mobile-video-header .player-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    /* Tab bar inside mobile header - sits below video */
    .mobile-video-header .library-top-bar {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        background: rgba(0, 0, 0, 0.4) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    /* Content area margin adjusts based on video state */
    .mobile-content-area {
        margin-top: calc(var(--video-height-full) + var(--tab-bar-height));
        transition: margin-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: calc(var(--player-controls-height) + var(--app-nav-height) + env(safe-area-inset-bottom));
    }

    body.video-shrunk .mobile-content-area {
        margin-top: calc(var(--video-height-shrunk) + var(--tab-bar-height));
    }

    /* Spotify active state margins */
    body.spotify-playing .mobile-content-area {
        margin-top: calc(var(--video-height-spotify) + var(--tab-bar-height));
    }

    body.spotify-playing.video-shrunk .mobile-content-area {
        margin-top: calc(var(--video-height-spotify-shrunk) + var(--tab-bar-height));
    }

    /* Desktop player container should be hidden on mobile (we use mobile header) */
    .right-column .player-container {
        display: none !important;
    }

    /* Hide the old library-top-bar on mobile (replaced by mobile-video-header) */
    #library-top-bar {
        display: none !important;
    }

    /* View states are defined in the MOBILE VIEW STATE POSITIONING section below */

    /* Videos view styling */
    #videos-view {
        display: flex;
        flex: 1;
        flex-direction: column;
        overflow-y: auto;
        padding: var(--space-3);
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* Critical for flex children to scroll properly */
    }

    /* Ensure video options container fills the space */
    #videos-view #video-options-container-mobile {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #videos-view .video-options-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
        padding: 0;
    }

    /* Mobile video cards - vertical layout for narrow grid columns */
    #videos-view .video-card {
        flex-direction: column;
        padding: 0;
        gap: 0;
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        overflow: hidden;
        border: none;
    }

    #videos-view .video-card.default {
        background: var(--bg-secondary);
    }

    #videos-view .video-thumbnail-container,
    #videos-view .video-left-column {
        width: 100%;
        flex-shrink: 0;
    }

    #videos-view .video-thumbnail {
        width: 100%;
        aspect-ratio: 16/9;
        border-radius: 0;
        display: block;
    }

    #videos-view .video-info-column {
        padding: var(--space-2);
        flex: 1;
    }

    #videos-view .video-meta-row {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-1);
        align-items: center;
    }

    #videos-view .video-type-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    #videos-view .video-title {
        font-size: var(--text-xs);
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: var(--space-1);
    }

    #videos-view .video-channel-inline {
        font-size: 10px;
        color: var(--text-secondary);
    }

    /* Hide some details on mobile to save space */
    #videos-view .video-stats,
    #videos-view .video-match-info {
        display: none;
    }

    /* Disabled video cards in mobile */
    #videos-view .video-card-disabled {
        flex-direction: column;
        padding: 0;
        gap: 0;
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        overflow: hidden;
        border: none;
    }

    #videos-view .video-card-disabled .video-left-column {
        width: 100%;
    }

    #videos-view .video-card-disabled .buttons-container {
        display: flex;
        gap: var(--space-2);
        padding: var(--space-2);
    }

    #videos-view .video-options-message {
        text-align: center;
        padding: var(--space-6) var(--space-4);
        color: var(--text-secondary);
    }

    #videos-view .video-options-message .empty-state-icon {
        margin-bottom: var(--space-3);
        color: var(--text-tertiary);
    }

    #videos-view .video-options-message .empty-state-icon svg {
        width: 48px;
        height: 48px;
    }

    #videos-view .video-options-message p {
        margin: 0 0 var(--space-2) 0;
    }

    #videos-view .video-options-message .empty-state-hint {
        font-size: var(--text-sm);
        color: var(--text-tertiary);
    }

    /* ==================== END MOBILE VIDEO STICKY HEADER SYSTEM ==================== */

    .container {
        padding: 0;
        /* Space for fixed mobile-video-header (video + tabs) - safe area handled by header itself */
        padding-top: calc(var(--video-height-full) + var(--tab-bar-height));
        padding-bottom: calc(56px + env(safe-area-inset-bottom)); /* Space for app nav */
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        transition: padding-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.video-shrunk .container {
        padding-top: calc(var(--video-height-shrunk) + var(--tab-bar-height));
    }

    body.spotify-playing .container {
        padding-top: calc(var(--video-height-spotify) + var(--tab-bar-height));
    }

    body.spotify-playing.video-shrunk .container {
        padding-top: calc(var(--video-height-spotify-shrunk) + var(--tab-bar-height));
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: stretch; /* Override base 'start' to make children full width */
    }

    /* Phase 6: Mobile layout for three-state Library navigation */
    /* Player controls are ALWAYS visible on mobile - fixed at bottom */

    /* Player View: Make playlist-panel not take up space, but allow fixed player-panel to show */
    body.view-player .playlist-panel {
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.view-player .playlist-panel > *:not(.player-panel) {
        display: none !important;
    }

    body.view-player #queue-view,
    body.view-player #playlists-view {
        display: none !important;
    }

    body.view-player .right-column {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        padding-top: var(--space-2); /* Small gap below tabs */
        padding-bottom: 120px; /* Space for player controls + app nav */
    }

    /* Phase 6: Always hide backdrop on mobile - views replace each other, no overlay */
    .playlist-backdrop {
        display: none !important;
    }

    /* ==================== MOBILE VIEW STATE POSITIONING ==================== */
    /* All three mobile views (Queue, Videos, Playlists) need the playlist-panel
       positioned below the mobile-video-header (video + tabs) */

    /* Common: Hide right-column (desktop video area) on all mobile views */
    body.view-queue .right-column,
    body.view-videos .right-column,
    body.view-playlists .right-column {
        opacity: 0 !important;
        pointer-events: none !important;
        position: absolute !important;
        z-index: -1 !important;
    }

    /* Common: Position playlist-panel below the mobile-video-header (includes safe area) */
    body.view-queue .playlist-panel,
    body.view-videos .playlist-panel,
    body.view-playlists .playlist-panel {
        display: flex !important;
        flex-direction: column;
        position: fixed !important;
        top: calc(var(--video-height-full) + var(--tab-bar-height) + env(safe-area-inset-top, 0px)) !important;
        left: 0;
        right: 0;
        bottom: calc(var(--player-controls-height) + var(--app-nav-height) + env(safe-area-inset-bottom)) !important;
        width: 100%;
        height: auto;
        padding: 0;
        overflow: hidden;
        transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* When video is shrunk, move playlist-panel up */
    body.video-shrunk.view-queue .playlist-panel,
    body.video-shrunk.view-videos .playlist-panel,
    body.video-shrunk.view-playlists .playlist-panel {
        top: calc(var(--video-height-shrunk) + var(--tab-bar-height) + env(safe-area-inset-top, 0px)) !important;
    }

    /* Spotify playing states */
    body.spotify-playing.view-queue .playlist-panel,
    body.spotify-playing.view-videos .playlist-panel,
    body.spotify-playing.view-playlists .playlist-panel {
        top: calc(var(--video-height-spotify) + var(--tab-bar-height) + env(safe-area-inset-top, 0px)) !important;
    }

    body.spotify-playing.video-shrunk.view-queue .playlist-panel,
    body.spotify-playing.video-shrunk.view-videos .playlist-panel,
    body.spotify-playing.video-shrunk.view-playlists .playlist-panel {
        top: calc(var(--video-height-spotify-shrunk) + var(--tab-bar-height) + env(safe-area-inset-top, 0px)) !important;
    }

    /* Common: Hide desktop tabs on mobile */
    body.view-queue .playlist-panel .playlist-header,
    body.view-videos .playlist-panel .playlist-header,
    body.view-playlists .playlist-panel .playlist-header {
        display: none !important;
    }

    /* Queue View specific */
    body.view-queue #queue-view {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    body.view-queue #queue-view::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    body.view-queue #videos-view,
    body.view-queue #playlists-view {
        display: none !important;
    }

    /* Videos View specific */
    body.view-videos #videos-view {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    body.view-videos #videos-view::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    body.view-videos #queue-view,
    body.view-videos #playlists-view {
        display: none !important;
    }

    /* Playlists View specific */
    body.view-playlists #playlists-view {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    body.view-playlists #playlists-view::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    body.view-playlists #queue-view,
    body.view-playlists #videos-view {
        display: none !important;
    }

    /* Hide desktop video-options-panel on mobile (we use #videos-view instead) */
    .video-options-panel,
    #video-options-panel,
    .right-column .video-options-panel {
        display: none !important;
    }

    /* Also hide the desktop video-options-container in case JS shows it */
    .right-column #video-options-container {
        display: none !important;
    }

    /* ==================== PLAYER PANEL FIXED AT BOTTOM ==================== */
    /* Critical: Player-panel must ALWAYS be fixed at bottom for all mobile views */
    body.view-queue .player-panel,
    body.view-videos .player-panel,
    body.view-playlists .player-panel {
        display: block !important;
        position: fixed !important;
        bottom: calc(var(--app-nav-height) + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        z-index: 99998 !important;
        background: rgba(0, 0, 0, 0.4) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        margin: 0;
        transform: none !important; /* Cancel any transforms */
    }

    /* Phase 6: Compact controls below video player */
    .mobile-compact-controls {
        display: flex;
        flex-direction: column;
        background: var(--bg-secondary);
        padding: var(--space-2) var(--space-3);
        border-top: 1px solid var(--border-primary);
    }

    .mobile-compact-controls .now-playing-line {
        font-size: var(--text-sm);
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: var(--space-2);
    }

    .mobile-compact-controls .controls-ratings-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* LEGACY: Collapsed/expanded states - only used on desktop or when Phase 6 views not active */
    /* These rules must NOT apply when body has view-queue, view-videos, or view-playlists classes */
    /* Legacy collapsed rules - not used with Phase 6 view system */

    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.collapsed .playlist-header {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
        border-bottom: none !important;
    }

    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.collapsed .playlist-tab-content,
    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.collapsed .library-view {
        display: none !important;
    }

    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.collapsed .playlist-close-btn {
        display: none !important;
    }

    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.expanded {
        transform: translateY(0);
        overflow: hidden;
    }

    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.expanded .playlist-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* When expanded, tab content should fill remaining space */
    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.expanded .playlist-tab-content,
    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel:not(.collapsed) .playlist-tab-content,
    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel.expanded .library-view,
    body:not(.view-queue):not(.view-videos):not(.view-playlists) .playlist-panel:not(.collapsed) .library-view {
        flex: 1 1 auto !important; /* Expand to fill available space */
        max-height: none !important; /* Remove height restriction */
    }

    .playlist-panel.collapsed .playlist-tabs {
        cursor: pointer;
    }

    /* Hide active tab indicator when collapsed - only show when expanded */
    .playlist-panel.collapsed .playlist-tab.active {
        border-bottom-color: transparent;
        color: var(--text-secondary) !important; /* Force grey even when active */
        background: transparent !important; /* Same background as non-active tabs */
    }

    /* Make non-active tabs grey when collapsed */
    .playlist-panel.collapsed .playlist-tab {
        color: var(--text-secondary);
    }

    /* Add vertical dividers between tabs when collapsed */
    .playlist-panel.collapsed .playlist-tab:not(:last-child) {
        border-right: 1px solid rgba(255, 255, 255, 0.15);
    }

    .playlist-tabs {
        border-radius: 0;
        margin: 0;
        padding: 0;
        display: flex; /* Ensure no inline gaps */
    }

    .playlist-tab {
        font-size: var(--text-sm);
        padding: var(--space-3);
        margin: 0;
        line-height: 1; /* Remove extra line-height spacing */
        height: 48px; /* Explicit height to match transform calculation */
        min-height: 48px;
        box-sizing: border-box; /* Include border in height */
    }

    /* Phase 6: Library Top Bar Mobile Styles - Compact */
    .library-top-bar {
        padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2); /* top right bottom left - less right padding to align + with menu below */
        height: 40px; /* Reduced from 48px */
        min-height: 40px;
        box-sizing: border-box;
    }

    .library-tabs {
        gap: var(--space-5);
    }

    .library-tab {
        font-size: var(--text-sm);
        padding: 6px 0; /* Reduced from var(--space-2) which is 8px */
    }

    /* Phase 6: Library tabs collapsed state */
    .playlist-panel.collapsed .library-top-bar {
        cursor: pointer;
    }

    .playlist-panel.collapsed .library-tab {
        color: var(--text-secondary);
        border-bottom-color: transparent;
    }

    .playlist-panel.collapsed .library-tab.active {
        color: var(--text-secondary) !important;
        border-bottom-color: transparent !important;
    }

    .library-create-btn {
        width: 28px; /* Reduced from 32px */
        height: 28px;
    }

    .library-create-btn svg {
        width: 14px; /* Reduced from 16px */
        height: 14px;
    }

    /* Compact playlist header on mobile */
    .playlist-playing-header {
        padding: 2px var(--space-1) 2px var(--space-2); /* Reduced top/bottom from 4px to 2px */
    }

    /* Phase 6: Library views fill available space in Queue/Playlists views */
    body.view-queue #queue-view.library-view,
    body.view-playlists #playlists-view.library-view {
        flex: 1 1 auto !important;
        max-height: none !important;
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0 !important; /* No extra padding - parent handles spacing */
    }

    /* Player panel on mobile - always fixed at bottom, always visible */
    .player-panel {
        display: block !important;
        position: fixed !important;
        bottom: calc(56px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        z-index: 99998 !important;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }

    /* CRITICAL: Hide player panel when full-screen modal is open - must come AFTER all other player-panel rules */
    body.modal-open .player-panel,
    body.modal-open .mobile-video-header {
        display: none !important;
    }

    .playlist-tab-content,
    .library-view:not(.hidden) {
        flex: 0 1 auto; /* Don't expand to fill space, only as tall as content */
        max-height: calc(100vh - 60px - 140px); /* Viewport minus header minus collapsed drawer height */
        overflow-y: auto; /* Make content scrollable */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Reduce padding on empty states to eliminate excess space */
    .playlist-empty-state,
    .library-empty-state {
        padding: var(--space-4) var(--space-3); /* Much smaller padding on mobile */
    }

    /* Prevent playlist items from expanding */
    .playlist-items {
        flex: 0 1 auto; /* Don't expand, only as tall as content */
        min-height: 0;
    }

    .library-playlists {
        flex: 0 1 auto; /* Don't expand, only as tall as content */
    }

    /* Make playlist name wrap earlier to avoid menu button */
    .playlist-name {
        max-width: calc(100% - 60px); /* Leave room for menu button */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .player-container.interaction-disabled {
        pointer-events: none;
        z-index: 0;
    }

    .playlist-backdrop.visible {
        z-index: 85; /* Below playlist panel */
    }

    .modal-content {
        width: 95%;
        margin: 2% auto;
    }

    .modal-body {
        padding: var(--space-4);
        max-height: 80vh;
    }
}

.playlist-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--backdrop-light);
    z-index: 85;
    transition: opacity 0.3s ease-out;
}

.playlist-backdrop.visible {
    display: block;
}

@media (max-width: 768px) {
    /* Nuclear option: Remove ALL shadows on mobile to prevent right-edge gradient */
    *, *::before, *::after {
        box-shadow: none !important;
    }

    .container {
        padding: 0;
        /* Padding-top handled by 1023px media query with video height variables */
        /* CRITICAL: Must leave space for player controls + app nav */
        padding-bottom: calc(var(--player-controls-height) + var(--app-nav-height) + env(safe-area-inset-bottom));
    }

    .playback-controls-row {
        padding: var(--space-1) var(--space-1) 0; /* Minimal padding to fit all buttons */
        gap: var(--space-1); /* Tight gap between controls and stars */
    }

    .now-playing-info {
        padding: var(--space-1) var(--space-2); /* Reduced vertical padding to half */
        border-bottom: 1px solid var(--border-secondary);
    }

    /* Make now-playing row tappable when drawer is expanded */
    .playlist-panel:not(.collapsed) .now-playing-info {
        cursor: pointer;
    }

    .playback-controls {
        padding: 0; /* No padding - rely on parent container */
        gap: var(--space-1); /* Tighter gap between buttons */
    }

    /* Mobile playback controls - sized for touch */
    .control-btn {
        padding: var(--space-1);
        font-size: var(--text-xs);
        min-height: 37px !important;
        min-width: 37px !important;
    }

    .control-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    .control-btn-primary {
        min-height: 40px !important;
        min-width: 40px !important;
    }

    .rating-section {
        padding: 0; /* No padding - align perfectly with control buttons */
        height: 37px; /* Match control button height */
        display: flex;
        align-items: center;
        margin-top: -3px; /* Shift up to align with controls */
    }

    .rating-stars {
        gap: 0; /* No gap between stars */
        display: flex;
        align-items: center;
    }

    .rating-star-btn {
        min-width: 33px; /* 10% larger for small phones */
        min-height: 37px; /* Match control button height */
        padding: 2px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .rating-star-btn svg {
        width: 26px; /* 10% larger for small phones */
        height: 26px;
    }

    .btn-settings {
        min-width: 48px;
        min-height: 48px;
        padding: var(--space-3);
    }

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

    .player-mode-indicator {
        font-size: 9px;
        left: var(--space-1);
    }

    .playlist-item-image {
        width: 50px;
        height: 50px;
    }

    /* Artist group image sizing for mobile */
    .artist-group-image {
        width: 50px;
        height: 50px;
    }

    /* Artist header inside artist-group should not have min-height */
    .artist-group-content .playlist-item-artist-header {
        min-height: auto;
        padding-top: 10px;
        padding-bottom: 8px;
    }

    /* Song-only rows inside artist-group - compact */
    .artist-group-content .playlist-item-song-only {
        min-height: auto;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    /* Match image width on mobile for song title alignment */
    .playlist-item-indent {
        width: 50px;  /* Same as .playlist-item-image width on mobile */
    }

    .playlist-item {
        padding: 0 var(--space-1);
        min-height: 56px;
    }

    /* Compact song-only rows on mobile - must come after .playlist-item and use higher specificity */
    .playlist-item.playlist-item-song-only {
        min-height: auto;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .modal-close {
        min-width: 48px;
        min-height: 48px;
    }

    /* Close button sizing already set in base styles */

    .video-options-panel {
        border-radius: 0;
        box-shadow: none;
    }

    .video-options-container {
        padding: var(--space-1) 0 0 0;
    }

    .video-options-grid {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 0;
    }

    .video-card {
        margin: 0;
    }

    .date-inputs-row {
        flex-wrap: nowrap;
        gap: var(--space-2);
    }

    .date-inputs-row input[type="date"] {
        min-width: 0;
        font-size: var(--text-sm);
        /* Height and padding set in later mobile media query block for consistency */
    }

    .date-separator {
        font-size: var(--text-sm);
        flex-shrink: 0;
    }

    /* Container for song count + filter pills on mobile */
    .filters-container {
        flex-wrap: nowrap; /* Don't wrap on mobile */
        overflow-x: auto; /* Horizontal scroll */
        overflow-y: hidden;
        padding: 15px 0 15px 5px; /* 15px top/bottom, 5px left */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    .filters-container::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    /* Song count in filters container on mobile */
    .filters-container .playlist-meta {
        font-weight: var(--font-medium);
        padding-right: var(--space-1);
    }

    /* Filter summary inside container on mobile */
    .filters-container .filter-summary {
        display: flex !important; /* Always show, override inline style */
        flex-wrap: nowrap; /* Don't wrap on mobile */
    }

    .filter-pill {
        font-size: var(--text-xs);
        padding: var(--space-1) var(--space-2);
    }

    .filter-pill svg {
        width: 11px;
        height: 11px;
    }

    .mini-progress {
        width: 150px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* Larger mobile phones (400px+) - more comfortable touch targets */
@media (min-width: 400px) and (max-width: 768px) {
    .control-btn {
        min-height: 40px !important;
        min-width: 40px !important;
    }

    .control-btn svg {
        width: 22px !important;
        height: 22px !important;
    }

    .control-btn-primary {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    .control-btn-primary svg {
        width: 24px !important;
        height: 24px !important;
    }

    .rating-star-btn {
        min-width: 36px;
    }

    .rating-star-btn svg {
        width: 28px;
        height: 28px;
    }

    .rating-section {
        height: 40px; /* Match larger control button height */
    }
}

/* Filter Drawer (Mobile) */
.filter-drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--backdrop-medium);
    z-index: 100001; /* Above modal (100000) */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filter-drawer-overlay.active {
    display: block;
    opacity: 1;
}

.filter-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    bottom: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-secondary);
    z-index: 100002; /* Above overlay (100001) */
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-mobile-drawer);
}

.filter-drawer.active {
    right: 0;
}

.filter-drawer-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-primary);
    flex-shrink: 0;
}

.filter-drawer-back {
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.filter-drawer-back svg {
    width: 20px;
    height: 20px;
}

.filter-drawer-title {
    flex: 1;
    font-weight: var(--font-semibold);
    font-size: var(--text-base);
    color: var(--text-primary);
}

.filter-drawer-done {
    background: none;
    border: none;
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    color: var(--accent-primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    min-height: 44px;
}

.filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    padding-bottom: max(calc(var(--space-4) + 100px), calc(env(safe-area-inset-bottom) + 100px)); /* Smart padding: uses safe-area on iOS, fixed padding otherwise */
}

body.drawer-open,
body.modal-open {
    overflow: hidden;
}

@media (min-width: 769px) {
    .filter-drawer-overlay,
    .filter-drawer {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .filter-section-collapsible .filter-section-content {
        max-height: 0 !important;
    }

    .filter-section-collapsible .filter-section-content.active {
        max-height: 0 !important;
    }

    #new-playlist-modal .modal-body {
        overflow-x: hidden;
    }

    #new-playlist-modal .modal-content {
        overflow-x: hidden;
    }
}

/* ==================== DESKTOP MODAL IMPROVEMENTS ==================== */

/* Desktop: Improve modal height utilization (>1024px) */
@media (min-width: 1025px) {
    /* Fix scrollbar on modal wrapper */
    #new-playlist-modal {
        overflow: hidden;           /* Prevent scrollbar on modal backdrop */
        display: flex;
        align-items: center;        /* Center vertically */
        padding: var(--space-5) 0;  /* Add top/bottom padding (20px) */
    }

    #new-playlist-modal .modal-content {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 40px);  /* Full height minus padding (20px top + 20px bottom) */
        margin: 0 auto;             /* Center horizontally only */
    }

    #new-playlist-modal .modal-body {
        flex: 1;                    /* Fill available space */
        max-height: none;           /* Remove the 70vh cap */
        overflow-y: auto;           /* Keep scrolling when needed */
    }
}

/* ==================== VIDEO TYPE PREFERENCES ==================== */

.video-type-preference-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    max-height: 400px;
    overflow-y: auto;
}

/* Scrollbar styling for video type preferences */
.video-type-preference-list::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.video-type-preference-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.video-type-preference-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-sm);
}

.video-type-preference-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.video-type-pref-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-base);
}

.video-type-pref-item:hover {
    background: var(--bg-hover);
}

.pref-order-number {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    min-width: 24px;
}

.pref-type-label {
    flex: 1;
    font-size: var(--text-base);
    color: var(--text-primary);
    font-weight: var(--font-medium);
}

.pref-arrows {
    display: flex;
    gap: var(--space-1);
}

.pref-arrow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-base);
}

.pref-arrow-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-1px);
}

.pref-arrow-btn:active:not(:disabled) {
    transform: translateY(0);
}

.pref-arrow-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-disabled);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .video-type-pref-item {
        padding: var(--space-2) var(--space-3);
    }

    .pref-order-number {
        font-size: var(--text-sm);
        min-width: 20px;
    }

    .pref-type-label {
        font-size: var(--text-sm);
    }

    .pref-arrow-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

/* =================================================================
   DATE MODE TOGGLE BUTTONS (Horizontal Segmented Control)
   ================================================================= */

.date-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.date-mode-toggle-group {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-primary);
    overflow: hidden;
    width: fit-content;
}

.date-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    min-width: 90px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    border-right: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.date-mode-btn:last-child {
    border-right: none;
}

.date-mode-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.date-mode-btn.active {
    background: var(--accent-primary);
    color: white;
    font-weight: var(--font-semibold);
}

.date-mode-btn span {
    white-space: nowrap;
}

.help-text-inline {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Date Mode Input Sections */
.date-mode-inputs {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    margin-top: 8px;
}

.rolling-inputs-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rolling-inputs-row span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}

.rolling-inputs-row select {
    padding: 8px 12px; /* Increased from 6px to 8px for ~20% taller touch targets */
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.rolling-inputs-row select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.rolling-help-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 0;
    padding: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.all-dates-help-text {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Size 16px icons using the icon-16 class */
.icon-16,
.icon-16.lucide,
.icon-16 .lucide,
.icon-16 svg,
.icon-16 svg.lucide {
    width: 16px !important;
    height: 16px !important;
}

.rolling-help-text i {
    color: var(--text-tertiary);
}

.all-dates-help-text i {
    color: var(--text-tertiary);
}

/* More Section Help Text */
.more-help-text {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

/* Genre Filtering Options Container */
.genre-filtering-options {
    margin-top: 12px;
}

/* Conflict Resolution Section */
.conflict-resolution-section {
    margin: 0;
}

.conflict-resolution-label {
    font-size: 14px;
    font-weight: normal;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

/* Neutral Genres Section */
.neutral-genres-section {
    margin-bottom: 12px;
}

.neutral-genres-section .checkbox-option {
    margin: 0;
}

/* Prioritize Shows Section */
.prioritize-shows-section {
    margin-top: 0;
}

.prioritize-shows-section .checkbox-option {
    margin: 0;
}

/* Checkbox Option Styling */
.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.checkbox-option input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.checkbox-option span {
    color: var(--text-secondary);
}

/* Genre Conflict Toggle Buttons */
/* Genre Mode Toggle Buttons */
.genre-mode-toggle-group {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-primary);
    overflow: hidden;
    width: fit-content;
    margin-bottom: 16px;
}

.genre-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    min-width: 110px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    border-right: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.genre-mode-btn:last-child {
    border-right: none;
}

.genre-mode-btn.active {
    background: var(--accent-primary);
    color: white;
    font-weight: var(--font-semibold);
}

.genre-mode-btn:hover:not(.active) {
    background: var(--bg-hover);
}

.genre-conflict-toggle-group {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--border-primary);
    overflow: hidden;
    width: fit-content;
}

.genre-conflict-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    min-width: 90px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    border-right: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.genre-conflict-btn:last-child {
    border-right: none;
}

.genre-conflict-btn:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.genre-conflict-btn.active {
    background: var(--accent-primary);
    color: white;
    font-weight: var(--font-semibold);
}

.genre-conflict-btn span {
    white-space: nowrap;
}

/* Filter Section Body Headings (Ratings, etc.) */
.filter-section-body h4 {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-section-body h4 i {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* Rating Filter Styles */
.rating-filter {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.rating-option {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.rating-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}

.rating-option select {
    padding: 6px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.rating-option select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.rating-option select:hover {
    background: var(--bg-hover);
}

/* Small input for min songs count (2-digit width) */
.small-input,
.rating-option input[type="number"] {
    width: 50px;
    padding: 6px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.rating-option input[type="number"]::-webkit-outer-spin-button,
.rating-option input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.rating-option input[type="number"]:focus {
    outline: none;
    border-color: var(--border-focus);
}

@media (max-width: 768px) {
    .date-mode-toggle-group {
        width: 100%;
    }

    .date-mode-btn {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
        font-size: var(--text-xs);
    }

    .rolling-inputs-row {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }

    .rolling-inputs-row select {
        flex: 1 1 auto;
        min-width: 85px; /* Reduced from 100px for narrower viewports */
        padding: 12px !important; /* Larger padding for mobile touch targets (~40% taller) */
        min-height: 48px !important;
        height: 48px !important;
    }

    .rolling-help-text {
        flex-basis: 100%;
        margin-top: 6px;
    }

    /* Genre Mode Toggle Group - Mobile Responsive */
    .genre-mode-toggle-group {
        width: 100%;
    }

    .genre-mode-btn {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
        font-size: var(--text-xs);
    }

    /* Genre Conflict Toggle Group - Mobile Responsive */
    .genre-conflict-toggle-group {
        width: 100%;
    }

    .genre-conflict-btn {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
        font-size: var(--text-xs);
    }

    /* Reduce filter section body padding on mobile */
    .filter-section-body {
        padding: var(--space-3); /* Reduced from --space-4 (16px) to --space-3 (12px) */
    }

    /* Ensure modal body children don't overflow */
    #new-playlist-modal .modal-body > * {
        max-width: 100%;
    }

    /* Ensure date inputs have proper flex sizing and larger touch targets */
    .date-inputs-row input[type="date"] {
        min-width: 0;
        flex: 1 1 auto;
        font-size: var(--text-sm);
        padding: 12px !important; /* Larger padding for mobile touch targets (~40% taller) */
        min-height: 48px !important;
        height: 48px !important;
    }
}
