:root {
    --bg-base: #f4f4f4;
    --bg-glass: rgba(255, 255, 255, 0.5); /* Semi-transparent background for glass effect */
    --bg-sidebar: rgba(248, 248, 248, 0.7);
    --bg-player: var(--bg-glass);
    --bg-elevated: #ffffff;
    
    --text-main: #000000;
    --text-sub: #666666;
    
    --brand-green: #1DB954;
    --border-color: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: #E0E0E0; /* A slightly darker background to see the app wrapper */
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; 
    /* Mac specific optimizations for crisp text */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-wrapper {
    display: flex;
    background-color: var(--bg-base);
    flex-direction: column;
    height: 100vh;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    display: flex;
    width: 240px;
    background-color: var(--bg-sidebar); /* Fallback for older browsers */
    background-color: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); /* For Safari */
    padding: 24px;
    border-right: 1px solid var(--border-color);
    flex-direction: column;
    gap: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.menu-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.book-picker {
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(236, 243, 255, 0.8));
    border: 1px solid rgba(0, 123, 255, 0.16);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(25, 48, 78, 0.08);
    display: flex;
    gap: 9px;
    padding: 4px 12px;
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.book-picker::after {
    border-bottom: 2px solid var(--text-sub);
    border-right: 2px solid var(--text-sub);
    content: '';
    height: 7px;
    pointer-events: none;
    position: absolute;
    right: 14px;
    top: 14px;
    transform: rotate(45deg);
    width: 7px;
}

.book-picker:hover {
    border-color: rgba(0, 123, 255, 0.36);
    box-shadow: 0 10px 28px rgba(25, 48, 78, 0.13);
    transform: translateY(-1px);
}

.book-picker:focus-within {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.18), 0 10px 28px rgba(25, 48, 78, 0.1);
}

.book-picker-icon {
    color: #007bff;
    font-size: 17px;
    line-height: 1;
}

.book-dropdown {
    background: transparent;
    border: 0;
    color: var(--text-main);
    cursor: pointer;
    flex: 1;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    min-width: 0;
    outline: none;
    padding: 9px 26px 9px 0;
    text-align: left;
    width: 100%;
}

.book-options {
    background: #fff;
    border: 1px solid rgba(0, 123, 255, 0.16);
    border-radius: 10px;
    box-shadow: 0 14px 32px rgba(25, 48, 78, 0.16);
    display: none;
    left: 0;
    padding: 6px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 10;
}

.book-options.open { display: grid; gap: 2px; }
.book-options button {
    background: transparent;
    border: 0;
    border-radius: 7px;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    padding: 9px 10px;
    text-align: left;
}
.book-options button:hover,
.book-options button[aria-selected="true"] { background: #eaf3ff; color: #0066cc; }
.book-select-native { display: none; }

.media-switcher { display: grid; gap: 6px; }
.media-tab {
    background: transparent; border: 0; border-radius: 6px; color: var(--text-sub);
    cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; padding: 11px 12px;
    text-align: left; transition: background-color 0.2s ease, color 0.2s ease;
}
.media-tab span { display: inline-block; margin-right: 8px; text-align: center; width: 16px; }
.media-tab.active { background: var(--text-main); color: var(--bg-base); }

.content-view {
    flex: 1;
    background: linear-gradient(180deg, #b3d1ff 0%, var(--bg-base) 40%);
    overflow-y: auto;
    padding: 24px;
}

.content-view::-webkit-scrollbar { width: 12px; }
.content-view::-webkit-scrollbar-track { background: transparent; }
.content-view::-webkit-scrollbar-thumb { background-color: rgba(0, 0, 0, 0.2); }

.playlist-header {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.playlist-cover {
    width: 192px;
    height: 192px;
    background: linear-gradient(135deg, #007BFF, #86B8F3);
    box-shadow: 0 4px 60px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 64px;
    font-weight: 700;
    flex-shrink: 0;
    color: white;
}

.playlist-info span { font-size: 12px; font-weight: 700; }
.playlist-info h1 { font-size: 72px; font-weight: 900; line-height: 1; margin: 10px 0; }
.playlist-info p { color: var(--text-sub); font-size: 14px; }

/* Tracklist Table */
.tracklist-header {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    padding: 10px 16px;
    color: var(--text-sub);
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.track-list { list-style: none; }
.track-list li {
    display: grid;
    grid-template-columns: 40px 1fr 1fr;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-sub);
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    align-items: center;
}

.track-list li:hover { background-color: rgba(0, 0, 0, 0.05); color: var(--text-main); }
.col-title { color: var(--text-main); font-weight: 500; }

.track-list li.active-track {
    background-color: rgba(0, 123, 255, 0.1);
}
.track-list li.active-track .col-num { color: var(--brand-green); }
.track-list li.active-track .col-title { color: var(--brand-green); font-weight: 700; }

/* Video Library */
.video-view { background: linear-gradient(145deg, #d9e9ff 0%, var(--bg-base) 48%); }
.video-header, .video-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.video-header { margin: 8px 0 26px; }
.eyebrow { color: var(--text-sub); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; }
.video-header h1 { font-size: clamp(38px, 6vw, 68px); line-height: 1; margin: 9px 0 12px; }
.video-header p { color: var(--text-sub); font-size: 14px; }
.video-count { align-items: flex-end; display: flex; flex-direction: column; color: var(--text-sub); font-size: 12px; }
.video-count strong { color: var(--text-main); font-size: 38px; line-height: 1; }
.video-stage { background: #101419; border-radius: 8px; box-shadow: 0 18px 46px rgba(25, 48, 78, 0.2); min-height: 280px; overflow: hidden; position: relative; }
.video-stage video { aspect-ratio: 16 / 9; display: block; height: auto; max-height: 62vh; object-fit: contain; width: 100%; }
.video-empty { align-items: center; color: #eaf2fc; display: flex; flex-direction: column; inset: 0; justify-content: center; padding: 40px 20px; position: absolute; text-align: center; }
.video-empty[hidden] { display: none; }
.video-empty-icon, .video-thumb { align-items: center; background: var(--brand-green); border-radius: 50%; color: #fff; display: flex; justify-content: center; }
.video-empty-icon { font-size: 20px; height: 56px; margin-bottom: 18px; padding-left: 3px; width: 56px; }
.video-empty h2 { font-size: 22px; margin-bottom: 8px; }
.video-empty p { color: #9daaba; font-size: 13px; }
.video-empty strong { color: #d9e9ff; }
.video-toolbar { border-bottom: 1px solid var(--border-color); margin: 30px 0 12px; padding-bottom: 12px; }
.video-toolbar h2 { font-size: 22px; margin-top: 6px; }
.video-format-note { color: var(--text-sub); font-size: 11px; }
.video-list { display: grid; gap: 8px; list-style: none; }
.video-card { border-radius: 6px; transition: background-color 0.2s ease; }
.video-card:hover, .video-card.active-video { background: rgba(0, 123, 255, 0.09); }
.video-card-button { align-items: center; background: none; border: 0; color: inherit; cursor: pointer; display: flex; gap: 14px; padding: 12px; text-align: left; width: 100%; }
.video-thumb { flex-shrink: 0; font-size: 12px; height: 38px; padding-left: 2px; width: 38px; }
.video-card-copy { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.video-card-copy strong { color: var(--text-main); font-size: 14px; }
.video-file { color: var(--text-sub); font-size: 12px; }
.video-file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-error { background: rgba(255, 77, 77, 0.12); }

/* Bottom Player */
.bottom-player {
    height: 90px;
    background-color: var(--bg-player); /* Fallback for older browsers */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); /* For Safari */
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.now-playing { width: 30%; display: flex; align-items: center; gap: 14px; }
.np-cover {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #007BFF, #86B8F3);
    display: flex; justify-content: center; align-items: center;
    font-size: 16px; font-weight: bold; border-radius: 4px;
    color: white;
}
#np-title { font-size: 14px; font-weight: 500; color: var(--text-main); margin-bottom: 4px; }
#np-artist { font-size: 12px; color: var(--text-sub); }

.player-controls { width: 40%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.control-buttons { display: flex; align-items: center; gap: 20px; }
.icon-btn {
    background: none; border: none; color: var(--text-sub); cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}
.icon-btn:hover { color: var(--text-main); transform: scale(1.1); }

.play-circle {
    width: 32px; height: 32px;
    background-color: var(--text-main); color: var(--bg-base);
    border: none; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; cursor: pointer;
}
.play-circle:hover { transform: scale(1.05); }
 
.progress-container {
    display: flex; align-items: center; gap: 10px;
    width: 100%; max-width: 600px; font-size: 11px; color: var(--text-sub);
}

.volume-controls { width: 30%; display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
input[type=range] {
    -webkit-appearance: none; width: 100%; height: 4px;
    background: linear-gradient(to right, var(--brand-green) var(--progress-percent, 0%), #ccc var(--progress-percent, 0%));
    border-radius: 2px; cursor: pointer;
}
.volume-controls input[type=range] { width: 100px; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 12px; width: 12px;
    background: var(--text-sub); border-radius: 50%;
    opacity: 0; transition: opacity 0.2s;
}
input[type=range]:hover::-webkit-slider-thumb { opacity: 1; background: var(--text-main); }
/* Firefox Thumb */
input[type=range]::-moz-range-thumb {
    height: 12px; width: 12px;
    background: var(--text-sub); border-radius: 50%; border: none;
    opacity: 0; transition: opacity 0.2s;
}
input[type=range]:hover::-moz-range-thumb { opacity: 1; background: var(--text-main); }
/* Firefox Track */
input[type=range]::-moz-range-track { background: transparent; /* Handled by the main element's background */ }

.player-btn {
    background-color: transparent;
    color: var(--text-sub);
    border: none;
    border-radius: 4px;
    padding: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}
.player-btn:hover { color: var(--text-main); transform: scale(1.1); }

/* =========================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
========================================= */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    /* Transform Sidebar into a Top Bar */
    .sidebar {
        width: 100%;
        padding: 16px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 16px; 
        border-bottom: 1px solid var(--border-color);
    }

    .menu-section { margin: 0; }
    .menu-label { display: none; } /* Hide "Your Library" */
    .book-picker { min-width: 150px; padding: 2px 10px; }
    .book-dropdown { font-size: 12px; padding: 8px 24px 8px 0; }
    .book-picker::after { right: 11px; top: 11px; }
    .media-switcher { display: flex; gap: 4px; }
    .media-tab { padding: 8px 10px; }
    .media-tab span { margin-right: 4px; }

    /* Adjust Playlist Header */
    .content-view { padding: 16px; }
    .playlist-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 16px;
    }
    .playlist-cover { width: 140px; height: 140px; font-size: 48px; }
    .playlist-info h1 { font-size: 32px; }
    .video-header { align-items: flex-start; }
    .video-header h1 { font-size: 40px; }
    .video-stage { min-height: 210px; }
    .video-toolbar { align-items: flex-start; }
    .video-format-note { display: none; }

    /* Adjust Tracklist (Hide File Name Column to save space) */
    .tracklist-header { grid-template-columns: 40px 1fr; }
    .tracklist-header .col-file { display: none; }
    .track-list li { grid-template-columns: 40px 1fr; padding: 12px 10px; }
    .track-list li .col-file { display: none; }

    /* Reorganize Bottom Player for Touch */
    .bottom-player {
        height: auto;
        padding: 12px 16px 24px; /* Extra padding on bottom for iOS safe area */
        flex-direction: column;
        gap: 16px;
    }

    .now-playing { width: 100%; justify-content: center; text-align: center; }
    .np-cover { display: none; } /* Hide small cover art on mobile footer */
    
    .player-controls { width: 100%; }
    .control-buttons { gap: 30px; } /* Spread buttons out for fat thumbs */
    .play-circle { width: 44px; height: 44px; } /* Larger play button for touch */

    /* On mobile, keep mute and speed controls, but hide the volume slider */
    .volume-controls {
        width: 100%;
        justify-content: center;
    }
    .volume-controls input[type=range] { display: none; }
}