:root {
    --primary: #b79b50;              /* Gold as primary */
    --primary-hover: #c5a85c;        /* Slightly lighter gold for hover */
    --secondary: #fffafa;            /* Maroon as secondary */
    --text: #333333;                 /* Dark grey text */
    --text-secondary: rgba(51, 51, 51, 0.7);  /* Semi-transparent dark grey */
    --progress-bg: #e0e0e0;          /* Light grey progress background */
    --background: #f5f5f5;           /* Light grey background */
    --transition-speed: 0.2s;        
    --border-radius: 12px;           
}


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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
}

.container {
    width: min(90vw, 800px);  
    min-width: 400px;
    padding: 2rem;
    padding-top: 320px; /* Base padding for player */
    transition: padding-top 0.3s ease-out; /* Smooth transition for padding changes */
}

.container.transcript-open {
    padding-top: 520px; /* Extra space when transcript is open */
}

.player {
    background: var(--secondary);
    padding: 2rem 2rem 1.25rem;
    border-radius: var(--border-radius);
    width: min(90vw, 800px);
    min-width: 400px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
}

.playlist {
    background: var(--secondary);
    border-radius: var(--border-radius);
    width: 100%;
    overflow: hidden;
}

.playlist-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

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

.playlist-item.active {
    background-color: rgba(255, 255, 255, 0.1);
}

.playlist-item-number {
    font-size: 0.9rem;
    opacity: 0.7;
    width: 2rem;
}

.playlist-item-details {
    flex-grow: 1;
}

.playlist-item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.playlist-item-artist {
    font-size: 0.8rem;
    opacity: 0.7;
}

.playlist-wrapper {
    width: 100%;
    transition: margin-top 0.3s ease-out;
}

.title {
    font-size: 1.2rem;
    margin: 0 0 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 1rem 0;
}

.play-pause {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.play-pause:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.play-pause:active {
    transform: scale(0.95);
}

.skip-button {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    opacity: 0.7;
    transition: all var(--transition-speed);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skip-button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.skip-button:active {
    transform: scale(0.95);
}

.skip-button svg {
    width: 20px;
    height: 20px;
}

.time {
    font-variant-numeric: tabular-nums;
    min-width: 4ch;
    text-align: center;
    opacity: 0.7;
    font-size: 0.9rem;
}

.progress-container {
    height: 20px;
    width: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 8px 0;
    touch-action: none;
}

.progress-bar {
    flex-grow: 1;
    height: 5px;
    background: var(--progress-bg);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.progress {
    background: var(--primary);
    height: 100%;
    border-radius: 3px;
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

.progress-bar:hover .progress {
    background: var(--primary-hover);
}

.volume-control {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-container {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-slider-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    border-radius: 8px;
    padding: 1rem;
    width: 12px;
    height: 120px;
    display: none;
    z-index: 10;
}

.volume-slider-container::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

.volume-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    opacity: 0.7;
    transition: opacity var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.volume-btn:hover {
    opacity: 1;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: var(--progress-bg);
    border-radius: 3px;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -50px;
    margin-top: -2px;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.speed-control {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    opacity: 0.7;
    transition: all var(--transition-speed);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 3rem;
    text-align: center;
}

.speed-control:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.speed-control:active {
    transform: scale(0.95);
}

.loading {
    opacity: 0.5;
}

.transcript-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity var(--transition-speed);
    width: 100%;
}

.transcript-toggle:hover {
    opacity: 1;
}

.transcript-toggle svg {
    transition: transform 0.3s ease;
}

.transcript-toggle.open svg {
    transform: rotate(180deg);
}

.transcript-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 0.5rem;
}

.transcript-content {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    max-height: 200px;
    overflow-y: auto;
}

.transcript-content::-webkit-scrollbar {
    width: 8px;
}

.transcript-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.transcript-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.timestamp {
    color: var(--primary);
    font-weight: 500;
    margin-right: 0.5rem;
    cursor: pointer;
}

.transcript-line {
    -webkit-user-select: none;
    user-select: none;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.transcript-line:hover {
    opacity: 0.8;
}

.transcript-line:last-child {
    margin-bottom: 0;
}

.library-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 2rem 0;
}

.week-section {
    margin-bottom: 2rem;
    background: var(--secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.week-header {
    padding: 1rem 1.5rem;
    background: #a02020;
    font-weight: 500;
    color: white;
    display: flex;
    justify-content: space-between;
}



.week-playlist {
    padding: 0.5rem 0;
}

.download-buttons {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    align-items: center;
}

.download-button {
    background: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    opacity: 0.7;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    white-space: nowrap;
}

.download-button:hover {
    opacity: 1;
    /*background: rgba(255, 255, 255, 0.1);*/
    transform: scale(1.05);
}

.download-button:active {
    transform: scale(0.95);
}



/* Mobile optimizations */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .volume-slider-container {
        display: none !important;
    }
    
    .volume-container:hover .volume-slider-container {
        display: none !important;
    }
    
    .volume-btn {
        padding: 0.5rem;
    }
    
    body {
        overflow-x: hidden;
    }
    
    .container {
        min-width: unset;
        width: 100%;
        padding: 1rem 0.5rem;
        padding-top: 320px;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .player {
        width: 100%;
        min-width: unset;
        padding: 1rem;
        box-sizing: border-box;
        left: 0;
        transform: none;
        border-radius: 0;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }
    
    .time {
        min-width: 3ch;
        font-size: 0.8rem;
    }
    
    .playlist-item {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        padding: 0.75rem;
        position: relative;
    }
    
    .playlist-item-number {
        font-size: 0.8rem;
        width: 1.5rem;
        min-width: 1.5rem;
    }
    
    .playlist-item-details {
        width: calc(100% - 110px);
        margin-bottom: 0;
        overflow: hidden;
    }
    
    .playlist-item-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .download-buttons {
        margin-left: auto;
        min-width: 80px;
        display: flex;
        justify-content: flex-end;
    }
    
    .week-header {
        font-size: 0.9rem;
    }
    
    .download-button {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .skip-button {
        width: 2rem;
        height: 2rem;
    }
    
    .play-pause {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .title {
        font-size: 1rem;
    }
}

@media screen and (max-width: 450px) {    
    .container {
        width: 100%;
        min-width: unset;
        padding: 0.5rem;
        padding-top: 280px;
        overflow-x: hidden;
    }

    .container.transcript-open {
        padding-top: 460px;
    }
    
    .player {
        width: 100%;
        left: 0;
        transform: none;
        top: 10px;
    }
    
    .playlist-item {
        padding: 0.5rem;
    }
    
    .playlist-item-number {
        font-size: 0.8rem;
        width: 1.5rem;
    }
    
    .playlist-item-title {
        font-size: 0.9rem;
    }
    
    .playlist-item-artist {
        font-size: 0.7rem;
    }
    
    .playlist-item-details {
        width: calc(100% - 90px);
    }
    
    .download-button {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .download-buttons {
        min-width: 65px;
        gap: 0.25rem;
    }
}

/* Desktop volume controls */
@media (hover: hover) {
    .volume-container:hover .volume-slider-container,
    .volume-slider-container:hover {
        display: block;
    }
}

/* Sidebar adjustments for desktop */
@media (min-width: 769px) {
    .player {
        width: min(calc(90vw - 250px), 800px);
        left: calc(50% + 125px); /* Half the sidebar width (250px/2) */
        transform: translateX(-50%);
    }
    
    .container {
        width: min(calc(90vw - 250px), 800px);
        min-width: unset;
        margin-left: auto;
        margin-right: auto;
    }
    
    .playlist-wrapper {
        width: 100%;
        max-width: 100%;
    }
    
    .playlist-item {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .week-section {
        width: 100%;
        max-width: 100%;
    }
}
