:root {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --hover-bg: #2a2a2a;
    --primary-color: #31c27c; /* 类似QQ音乐的绿色 */
    --text-main: #ffffff;
    --text-sub: #b3b3b3;
    --border-color: #333333;
    --glass-bg: rgba(30, 30, 30, 0.8);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* 防止全屏滚动 */
    height: 100vh;
    height: 100dvh; /* 适配移动端动态地址栏 */
}

.player-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100vw;
}

/* 主体区域 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 30px;
    gap: 30px;
}

/* 左侧：封面与歌词 */
.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 50%;
}

.album-art-container {
    width: 280px;
    height: 280px;
    border-radius: 15px;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin-bottom: 25px;
    transition: transform 0.3s ease;
    position: relative;
}

.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 10;
}

.loading-overlay.active {
    opacity: 1;
}

.modern-loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: loader-spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(49, 194, 124, 0.4);
}

@keyframes loader-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 13px;
    letter-spacing: 2px;
    color: #fff;
    font-weight: 300;
    animation: text-pulse 1.5s infinite ease-in-out;
}

@keyframes text-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.album-art-container:hover {
    transform: scale(1.02);
}

.album-art {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 80px;
    color: var(--text-sub);
    border-radius: 50%;
    background: radial-gradient(circle, #333, #111);
    overflow: hidden; /* 防止图片溢出圆形边框 */
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.album-art.playing {
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.song-info {
    text-align: center;
    margin-bottom: 30px;
}

.song-info h2 {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 10px;
}

.song-info p {
    font-size: 14px;
    color: var(--text-sub);
}

.visualizer-container {
    width: 100%;
    height: 50px;
    max-width: 350px;
    margin-bottom: 20px;
}

canvas#visualizerCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.lyrics-container {
    flex: 1;
    width: 100%;
    max-width: 450px;
    text-align: center;
    overflow-y: auto;
    mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    padding: 20px 0;
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 4px;
}

.lyrics-placeholder {
    color: var(--text-sub);
    margin: 10px 0;
    font-size: 16px;
    line-height: 2;
    opacity: 0.6;
}

/* 右侧：播放列表 */
.right-panel {
    flex: 1;
    background-color: var(--panel-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
}

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

.playlist-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.playlist-header span {
    font-size: 13px;
    color: var(--text-sub);
}

.playlist {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 10px 0;
}

.playlist-item {
    padding: 15px 25px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s;
}

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

.playlist-item.active {
    background-color: var(--hover-bg);
}

.playlist-item.active .song-name {
    color: var(--primary-color);
}

.song-index {
    width: 35px;
    color: var(--text-sub);
    font-size: 15px;
}

.song-details {
    flex: 1;
}

.song-name {
    font-size: 16px;
    margin-bottom: 5px;
}

.song-artist {
    font-size: 13px;
    color: var(--text-sub);
}

.song-play-icon {
    display: none;
    color: var(--primary-color);
}
.playlist-item.active .song-index-num { display: none; }
.playlist-item.active .song-play-icon { display: inline-block; }


/* 底部控制栏 */
.controls-bar {
    height: 100px;
    background-color: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0 30px;
    position: relative;
    z-index: 100;
}

/* 进度条 */
.progress-container {
    display: flex;
    align-items: center;
    height: 25px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-sub);
    gap: 15px;
}

.progress-bar-wrapper {
    flex: 1;
    height: 4px;
    background-color: #444;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    touch-action: none;
}
.progress-bar-wrapper:hover .progress-bar::after {
    opacity: 1;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    border-radius: 2px;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

/* 控制区域整体 */
.controls-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 65px;
}

/* 迷你信息 */
.mini-song-info {
    display: flex;
    align-items: center;
    width: 250px;
    gap: 15px;
}

.mini-album {
    width: 45px;
    height: 45px;
    background: radial-gradient(circle, #444, #222);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #666;
    overflow: hidden; /* 保持缩略图不撑破方框 */
}

.mini-text {
    overflow: hidden;
}

.mini-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 播放控制按钮 */
.player-controls {
    display: flex;
    align-items: center;
    gap: 25px;
    flex: 1;
    justify-content: center;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.control-btn:hover {
    color: var(--primary-color);
}

.play-btn {
    font-size: 22px;
    background-color: var(--primary-color);
    color: #fff;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(49, 194, 124, 0.4);
}

.play-btn:hover {
    transform: scale(1.05);
    background-color: #2eb070;
    color: #fff;
}

/* 音量控制 */
.volume-container {
    width: 250px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    color: var(--text-sub);
}

.volume-container i {
    cursor: pointer;
    width: 20px;
    text-align: center;
}

.volume-container i:hover {
    color: #fff;
}

.volume-bar-wrapper {
    width: 100px;
    height: 4px;
    background-color: #444;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    touch-action: none;
}

.volume-bar-wrapper:hover .volume-bar::after {
    opacity: 1;
}

.volume-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 50%;
    border-radius: 2px;
    position: relative;
}

.volume-bar::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

#playlistBtn {
    display: none;
}

/* 响应式设计：移动端 */
@media (max-width: 800px) {
    .main-content {
        flex-direction: column;
        padding: 15px;
        gap: 10px;
    }
    
    .left-panel {
        max-width: 100%;
        height: 45vh; /* 优化视觉占比 */
    }
    
    .album-art-container {
        width: 220px;
        height: 220px;
        margin-bottom: 15px;
    }
    
    .lyrics-container {
        padding: 0;
        mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent);
        -webkit-mask-image: linear-gradient(to bottom, transparent, black 25%, black 75%, transparent);
    }
    
    .right-panel {
        position: fixed;
        bottom: 170px; /* 进一步提高，匹配更高的底部栏 */
        left: 0;
        right: 0;
        height: 50vh;
        z-index: 90;
        transform: translateY(120%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 25px 25px 0 0;
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px)); /* 更大的底部弹窗安全底距 */
    }
    
    .right-panel.show {
        transform: translateY(0);
    }
    
    .mini-song-info {
        display: none;
    }
    
    .controls-bar {
        padding: 15px;
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px)); /* 确保普通设备和苹果无按键设备都有足够的防遮挡空白距离 */
        height: auto;
    }

    .controls-wrapper {
        flex-direction: column;
        height: auto;
        gap: 15px;
        margin-top: 15px;
    }

    .player-controls {
        gap: 25px; /* 让控制键分散排开更好点按 */
        width: 100%;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .play-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .volume-container {
        position: static;
        display: flex;
        width: 90%;
        max-width: 300px;
        background-color: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0 auto;
        gap: 15px;
    }

    .volume-bar-wrapper {
        width: 80%;
    }
    
    #playlistBtn {
        display: flex;
    }
}
