:root {
    --ios-blue: #333333;
    --ios-gray-1: #8E8E93;
    --text-primary: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --text-tertiary: rgba(60, 60, 67, 0.3);
    --bg-glass: rgba(255, 255, 255, 0.8);
    --divider: rgba(60, 60, 67, 0.1);
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
}

body {
    height: 100vh;
    height: 100dvh;
    /* 动态视口高度，适配手机浏览器 */
    background: #f2f2f7;
    overflow: hidden;
    color: var(--text-primary);
}

/* 背景容器 */
.bg-container {
    display: none;
    /* 隐藏背景 */
    position: fixed;
    inset: -20%;
    width: 140%;
    height: 140%;
    z-index: -2;
}

/* 双层背景实现淡入淡出 */
.bg-layer {
    position: absolute;
    inset: 0;
    background-image: url('https://y.gtimg.cn/music/photo_new/T002R800x800M000003y8dsH2wBHlo_1.jpg');
    background-size: cover;
    background-position: center;
    filter: blur(20px) saturate(200%) brightness(0.85);
    opacity: 1;
    transition: opacity 0.8s ease-in-out;
    animation: bgFloat 20s linear infinite;
    animation-play-state: paused;
}

.bg-layer.fade-out {
    opacity: 0;
}

/* 播放时才启动动画 */
body.playing .bg-layer {
    animation-play-state: running;
}

@keyframes bgFloat {
    0% {
        transform: scale(1.2) rotate(0deg);
    }

    100% {
        transform: scale(1.2) rotate(360deg);
    }
}

.bg-mask {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.25);
    z-index: -1;
}

/* 主视图（垂直布局）*/
.player-view {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* 动态视口高度 */
    display: flex;
    flex-direction: column;
    background: var(--bg-glass);
    backdrop-filter: blur(50px) saturate(180%);
    -webkit-backdrop-filter: blur(50px) saturate(180%);
}

/* 顶部栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    /* 支持沉浸式状态栏的设备，顶部增加安全区填充 */
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid var(--divider);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--ios-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 18px;
    transition: background 0.2s;
}

.search-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.top-bar-actions {
    display: flex;
    gap: 8px;
}

/* 播放列表抽屉特定样式 */
.playlist-drawer .drawer-header {
    justify-content: flex-start;
}

.playlist-drawer .drawer-header h2 {
    flex: 1;
}

.clear-playlist-btn {
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

.clear-playlist-btn:hover {
    color: #FF3B30;
}

.playlist-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.playlist-list::-webkit-scrollbar {
    width: 5px;
}

.playlist-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.playlist-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.playlist-list::-webkit-scrollbar-track {
    background: transparent;
}

.playlist-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: background 0.2s;
    cursor: pointer;
}

.playlist-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.playlist-item.playing {
    background: rgba(0, 0, 0, 0.08);
}

.playlist-item .item-cover {
    width: 45px;
    height: 45px;
    border-radius: 6px;
    margin-right: 12px;
    object-fit: cover;
}

.playlist-item .item-info {
    flex: 1;
    min-width: 0;
}

.playlist-item .item-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item .item-artist {
    font-size: 12px;
    color: var(--text-secondary);
}

.playlist-item .remove-btn {
    border: none;
    background: none;
    color: var(--text-tertiary);
    font-size: 14px;
    padding: 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.playlist-item:hover .remove-btn {
    opacity: 1;
}

.playlist-item .remove-btn:hover {
    color: #FF3B30;
}

/* 搜索结果中的"添加到播放列表"按钮 */
.action-btn.add-next {
    background: rgba(52, 199, 89, 0.1);
    color: #34C759;
}

/* 主内容区 - 居中布局 */
.main-view {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 20px;
    padding-bottom: 100px;
    position: relative;
}

/* 封面视图 */
.cover-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-bottom: 100px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    cursor: pointer;
}

.cover-view.active {
    opacity: 1;
    pointer-events: auto;
}

.album-cover-large {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s ease;
}

.album-cover-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.player-view.playing .album-cover-large {
    transform: scale(1.02);
}

/* 歌曲信息 */
.song-meta {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 0px;
    max-width: 300px;
}

.song-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    transition: opacity 0.3s ease;
}

.song-artist {
    font-size: 16px;
    color: var(--ios-blue);
    font-weight: 500;
    transition: opacity 0.3s ease;
}

/* 歌词视图 */
.lyrics-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    padding-bottom: 100px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    cursor: pointer;
}

.lyrics-view.active {
    opacity: 1;
    pointer-events: auto;
}

.song-meta-mini {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 10px;
    flex-shrink: 0;
}

.lyrics-scroll {
    flex: 1;
    overflow-y: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    /* 歌词顶部和底部渐隐效果 */
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    scrollbar-width: none;
    transition: opacity 0.3s ease;
}

/* 用于使首尾歌词能居中 */
.lyrics-scroll::before {
    content: '';
    flex: 0 0 30%;
    /* 上方空间稍小 */
}

.lyrics-scroll::after {
    content: '';
    flex: 0 0 50%;
    /* 下方空间稍大 */
}

.lyrics-scroll::-webkit-scrollbar {
    display: none;
}

.lrc-line {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 20px 0;
    /* 平滑过渡动画，0.2s 适中速度 */
    transition: all 0.2s ease-out;
    filter: blur(1px);
    opacity: 0.6;
    transform: scale(0.98);
    cursor: pointer;
}

.lrc-line.active {
    filter: blur(0);
    opacity: 1;
    transform: scale(1.05);
    color: var(--text-primary);
    font-size: 24px;
    transition: all 0.2s ease-out;
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
}

/* 底部控制栏 - 单行 */
.bottom-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--controls-bg, rgba(255, 255, 255, 0.4));
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--divider);
    padding: 0 20px 8px 20px;
    /* 支持 iPhone 等带安全区的设备 */
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    /* 颜色平滑过渡 */
    transition: background 0.8s ease-out;
}

.bottom-controls .progress-bar {
    height: 3px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 0;
    cursor: pointer;
    margin: 0 -20px 10px -20px;
    /* 延伸到页面宽度 */
    width: calc(100% + 40px);
}

.bottom-controls .progress-fill {
    height: 100%;
    width: 0%;
    background: var(--ios-gray-1);
    border-radius: 2px;
    transition: width 0.1s linear;
}

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

.controls-left,
.controls-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.controls-right {
    justify-content: flex-end;
}

.controls-center {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.time-label {
    font-size: 11px;
    color: var(--text-tertiary);
    min-width: 35px;
}

.ctrl-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 18px;
    padding: 4px;
    transition: transform 0.1s;
}

.ctrl-btn:active {
    transform: scale(0.9);
}

.play-btn-main {
    font-size: 32px;
}

/* 音质切换按钮 */
.quality-toggle-btn {
    background: none;
    border: none;
    padding: 12px 16px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    z-index: 10;
}

.quality-toggle-btn:hover {
    opacity: 0.7;
}

.quality-toggle-btn:active {
    transform: scale(0.95);
    opacity: 0.6;
}

/* 播放模式按钮 */
.mode-btn {
    font-size: 16px;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    position: relative;
    /* 与左侧音质按钮对称 */
    padding: 12px 16px;
    min-width: 44px;
    min-height: 44px;
}

.mode-btn.active {
    opacity: 1;
}

.mode-btn:hover {
    opacity: 0.8;
}

.mode-btn:active {
    transform: scale(0.85);
}

.mode-badge {
    position: absolute;
    font-size: 9px;
    font-weight: 700;
    top: 8px;
    right: 10px;
}

/* 搜索抽屉 */
.search-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    max-width: 500px;
    height: 100vh;
    height: 100dvh;
    /* 动态视口高度 */
    background: var(--bg-glass);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.search-drawer.open {
    transform: translateX(0);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
}

.drawer-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    /* 支持沉浸式状态栏的设备，顶部增加安全区填充 */
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--divider);
    gap: 16px;
}

.close-drawer {
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--ios-blue);
    padding: 8px;
}

.drawer-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.drawer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
    gap: 8px;
}

.search-input-wrapper i {
    color: var(--text-tertiary);
    font-size: 14px;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 16px;
}

.search-input-wrapper button {
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
}

.search-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-secondary);
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.results-list::-webkit-scrollbar {
    width: 5px;
}

.results-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.result-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.item-cover {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-right: 12px;
    object-fit: cover;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.item-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: var(--ios-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:active {
    transform: scale(0.9);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
    /* 手机端底部安全区 */
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 15px;
    flex-shrink: 0;
}

.page-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--ios-blue);
    font-size: 16px;
}

.page-btn:disabled {
    color: var(--ios-gray-2);
}

/* 遮罩 */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.drawer-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* 通知 */
.notification-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    color: #333;
}

.toast.error {
    color: #FF3B30;
}

/* 响应式 - 桌面端 */
@media (min-width: 768px) {
    .search-drawer {
        max-width: 450px;
    }
}

/* 响应式 - 手机端 */
@media (max-width: 480px) {

    /* 顶部栏 */
    .top-bar {
        padding: 12px 16px;
    }

    .logo {
        font-size: 16px;
    }

    .search-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* 封面视图 */
    .main-view {
        padding: 15px;
        padding-bottom: 90px;
    }

    .cover-view {
        padding: 15px;
        padding-bottom: 90px;
    }

    .album-cover-large {
        width: 220px;
        height: 220px;
        border-radius: 12px;
    }

    .song-meta {
        margin-top: 20px;
        max-width: 260px;
    }

    .song-title {
        font-size: 18px;
    }

    .song-artist {
        font-size: 14px;
    }

    /* 歌词视图 */
    .lyrics-view {
        padding: 15px;
        padding-bottom: 90px;
    }

    .song-meta-mini {
        font-size: 12px;
        padding: 8px;
    }

    .lrc-line {
        font-size: 16px;
        margin: 15px 0;
    }

    .lrc-line.active {
        font-size: 18px;
    }

    .lyrics-scroll {
        padding: 15px;
    }

    /* 底部控制栏 */
    .bottom-controls {
        padding: 0 12px 8px 12px;
    }

    .bottom-controls .progress-bar {
        margin: 0 -12px 8px -12px;
        width: calc(100% + 24px);
    }

    /* 隐藏手机端不需要的元素 */
    .volume-control,
    .time-label {
        display: none;
    }

    .controls-left {
        flex: 0;
        gap: 8px;
    }

    .controls-right {
        flex: 0;
        gap: 8px;
    }

    .controls-center {
        flex: 1;
        justify-content: center;
        gap: 32px;
    }

    .ctrl-btn {
        font-size: 22px;
        padding: 8px;
    }

    .play-btn-main {
        font-size: 40px;
    }

    /* 抽屉全屏 */
    .search-drawer {
        max-width: 100vw;
        width: 100vw;
    }

    .drawer-header {
        padding: 14px 16px;
    }

    .drawer-header h2 {
        font-size: 18px;
    }

    .drawer-content {
        padding: 12px;
    }

    .search-input-wrapper {
        padding: 10px;
        margin-bottom: 12px;
    }

    .search-input-wrapper input {
        font-size: 15px;
    }

    /* 搜索结果项 */
    .result-item {
        padding: 10px;
        margin-bottom: 6px;
    }

    .item-cover {
        width: 45px;
        height: 45px;
        border-radius: 6px;
    }

    .item-title {
        font-size: 14px;
    }

    .item-artist {
        font-size: 12px;
    }

    .action-btn {
        width: 32px;
        height: 32px;
    }

    /* 播放列表项 */
    .playlist-item {
        padding: 10px;
    }

    .playlist-item .item-cover {
        width: 40px;
        height: 40px;
    }

    .playlist-item .item-title {
        font-size: 13px;
    }

    .playlist-item .item-artist {
        font-size: 11px;
    }

    /* 移除hover时才显示的逻辑，手机端始终显示删除按钮 */
    .playlist-item .remove-btn {
        opacity: 0.6;
    }

    /* 通知 */
    .notification-container {
        top: 70px;
        width: auto;
        max-width: 80%;
    }

    .toast {
        padding: 10px 20px;
        font-size: 13px;
        border-radius: 20px;
        white-space: nowrap;
    }
}

/* 超小屏幕适配 (< 360px) */
@media (max-width: 360px) {
    .album-cover-large {
        width: 180px;
        height: 180px;
    }

    .song-title {
        font-size: 16px;
    }

    .ctrl-btn {
        font-size: 20px;
    }

    .play-btn-main {
        font-size: 36px;
    }

    .controls-center {
        gap: 24px;
    }
}