
:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-hover: #2c2c2c;
    --primary: #bb86fc;
    --secondary: #03dac6;
    --text-main: #e0e0e0;
    --text-dim: #a0a0a0;
    --border: #333;
    --scrollbar-bg: #121212;
    --scrollbar-thumb: #444;
    --danger: #ff5555;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

/* ========== Layout ========== */
#app {
    display: flex;
    height: 100%;
    width: 100%;
}

.left-panel {
    width: 40%;
    min-width: 350px;
    max-width: 500px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    transition: all 0.3s ease;
}

.right-panel {
    flex: 1;
    background: linear-gradient(145deg, #1a1a1a 0%, #0d0d0d 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

/* ========== Components: Header & Search ========== */
.header {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    margin-bottom: 15px;
}

.btn {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    white-space: nowrap;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    background: transparent;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    font-size: 0;
}

.search-box {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    transition: border-color 0.2s;
}
.search-box:focus {
    border-color: var(--primary);
}
.search-box::placeholder {
    color: #666;
}

/* ========== Playlist ========== */
.playlist-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    border-radius: 8px;
    background: var(--bg-dark);
    padding: 5px;
    min-height: 0;
}

.track-item {
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s, border-left 0.2s;
    font-size: 14px;
    border-bottom: 1px solid #222;
    border-left: 3px solid transparent;
    gap: 8px;
}

.track-item:hover {
    background: var(--bg-hover);
}
.track-item.active {
    background: rgba(187, 134, 252, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.track-info {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.track-info .track-title-text {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.track-info .track-artist-text {
    font-size: 12px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-actions {
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.track-item:hover .track-actions {
    opacity: 1;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    font-size: 14px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-delete:hover {
    background: rgba(255, 85, 85, 0.2);
}

/* ========== Controls Area ========== */
.controls-area {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 12px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.progress-bar {
    flex: 1;
    height: 5px;
    background: #333;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

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

.progress-fill::after {
    content: '';
    position: absolute;
    right: -6px;
    top: -4px;
    width: 13px;
    height: 13px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.progress-bar:hover .progress-fill::after {
    opacity: 1;
}

.buttons-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-play {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--text-main);
    color: #000;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-play:hover {
    transform: scale(1.06);
    background: #fff;
}
.btn-play:active {
    transform: scale(0.95);
}

.mode-btn {
    color: var(--text-dim);
    font-size: 16px;
    position: relative;
    transition: color 0.2s;
}
.mode-btn.active {
    color: var(--primary);
}

/* 单曲循环标记 */
.repeat-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    font-size: 9px;
    font-weight: 700;
    color: var(--primary);
    background: var(--bg-dark);
    border-radius: 50%;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 1px solid var(--primary);
    pointer-events: none;
}

/* ========== Right Panel: Visuals ========== */
.cover-art-container {
    width: 280px;
    height: 280px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 25px;
    position: relative;
    background: #222;
    flex-shrink: 0;
}

.cover-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.cover-art.playing {
    animation: pulse 4s infinite ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
    100% {
        transform: scale(1);
    }
}

.track-details {
    text-align: center;
    margin-bottom: 15px;
    z-index: 2;
    padding: 0 20px;
    max-width: 500px;
}
.track-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.track-artist {
    font-size: 15px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Lyrics ========== */
.lyrics-container {
    width: 80%;
    max-width: 600px;
    height: 180px;
    overflow-y: auto;
    text-align: center;
    mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    padding: 40px 0;
    scroll-behavior: smooth;
}

.lyric-line {
    padding: 7px 0;
    color: var(--text-dim);
    font-size: 15px;
    transition: all 0.35s;
    cursor: default;
    line-height: 1.5;
}

.lyric-line.active {
    color: var(--primary);
    font-size: 19px;
    font-weight: 600;
    text-shadow: 0 0 12px rgba(187, 134, 252, 0.35);
}

.empty-state {
    color: var(--text-dim);
    text-align: center;
    font-size: 15px;
    opacity: 0.7;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 7px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========== Volume Slider ========== */
.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100px;
    flex-shrink: 0;
}
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    background: var(--text-main);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}
.volume-slider::-webkit-slider-thumb:hover {
    background: #fff;
}
.volume-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    background: var(--text-main);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ========== Track Count Badge ========== */
.track-count {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
    padding: 0 5px;
}

.loading-state {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ========== Toast / 提示 ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 999;
    pointer-events: none;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
@keyframes toastOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }
    .left-panel {
        width: 100%;
        min-width: unset;
        max-width: unset;
        height: 48%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px;
    }
    .right-panel {
        height: 52%;
        padding: 10px;
    }
    .cover-art-container {
        width: 160px;
        height: 160px;
        margin-bottom: 12px;
    }
    .track-title {
        font-size: 18px;
    }
    .track-artist {
        font-size: 13px;
    }
    .lyrics-container {
        height: 100px;
        padding: 25px 0;
    }
    .lyric-line {
        font-size: 13px;
    }
    .lyric-line.active {
        font-size: 16px;
    }
    .buttons-row {
        gap: 6px;
    }
    .volume-control {
        width: 70px;
    }
    .btn-play {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    .btn-icon {
        width: 30px;
        height: 30px;
        font-size: 13px;
        padding: 5px;
    }
    .main-controls {
        gap: 8px;
    }
}

@media (max-width: 400px) {
    .left-panel {
        padding: 8px;
    }
    .cover-art-container {
        width: 120px;
        height: 120px;
    }
    .buttons-row {
        flex-wrap: wrap;
        justify-content: center;
    }
    .volume-control {
        width: 60px;
    }
}