:root {
    --bg-base: #1c1c1e;
    --text-primary: rgba(255, 255, 255, 0.9);
    --text-secondary: rgba(235, 235, 245, 0.6);
    --glass-bg: rgba(40, 40, 40, 0.35);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.2);
    --accent: #fa243c;
    --lyric-inactive: rgba(255, 255, 255, 0.4);
    --lyric-active: rgba(255, 255, 255, 1);
    --lyric-highlight: #ffffff;

    --c1: #ef4444;
    /* red */
    --c2: #f97316;
    /* orange */
    --c3: #8b5cf6;
    /* purple */
    --c4: #ec4899;
    /* pink */
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow: hidden;
    /* Prevent body scroll, everything is absolute/fixed */
    height: 100vh;
    width: 100vw;
}

/* Dynamic Mesh Background */
.mesh-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #000;
    filter: blur(80px) saturate(150%);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: float 20s infinite ease-in-out alternate;
    mix-blend-mode: screen;
}

.blob.color-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: var(--c1);
    animation-delay: 0s;
}

.blob.color-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: var(--c2);
    animation-delay: -5s;
}

.blob.color-3 {
    top: 20%;
    right: 10%;
    width: 40vw;
    height: 40vw;
    background: var(--c3);
    animation-delay: -10s;
}

.blob.color-4 {
    bottom: 10%;
    left: 20%;
    width: 50vw;
    height: 50vw;
    background: var(--c4);
    animation-delay: -15s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(10%, -10%) scale(1.1);
    }

    66% {
        transform: translate(-5%, 15%) scale(0.9);
    }

    100% {
        transform: translate(15%, 5%) scale(1.05);
    }
}

/* Utility / Layout */
.hidden {
    display: none !important;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px var(--glass-shadow);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.picker-panel {
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.picker-panel h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.picker-panel p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: inline-block;
}

.btn-primary:hover {
    transform: scale(1.05);
    background: #ff3b52;
}

.btn-primary:active {
    transform: scale(0.95);
}

/* Main Player Layout */
.player-container {
    display: flex;
    gap: 24px;
    padding: 24px 24px 0 24px;
    height: 100vh;
    width: 100%;
}

/* Sidebar Playlist */
.playlist-panel {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 16px;
    overflow: hidden;
    margin-bottom: 24px;
}

.playlist-panel h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.playlist-header h2 {
    margin-bottom: 0;
}

/* File Tree */
.track-tree {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.track-tree::-webkit-scrollbar {
    display: none;
}

.tree-folder {
    display: flex;
    flex-direction: column;
}

.tree-folder-name {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
    user-select: none;
    margin-top: 8px;
}

.tree-folder-name:hover {
    opacity: 0.8;
}

.tree-folder-name .material-icons-round {
    font-size: 20px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.tree-folder.collapsed .tree-folder-name .material-icons-round {
    transform: rotate(-90deg);
    /* points right instead of down */
}

.tree-children {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: 20px;
    /* indentation for children */
}

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

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

.track-item.active {
    background: rgba(255, 255, 255, 0.15);
}

.track-item-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.track-item .title {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-item .format {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
}

.track-item .material-icons-round {
    font-size: 20px;
    color: var(--text-secondary);
}

/* Main Lyrics Area (Rest of the screen) */
.main-lyrics-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Floating Controls */
.floating-controls {
    position: absolute;
    bottom: 32px;
    /* Hovering over lyrics */
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 960px;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    z-index: 10;
    /* Extra blur for controls */
    background: rgba(200, 200, 200, 0.2);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border-radius: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s;
}

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

.now-playing-middle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: 4px;
    /* Space for the progress bar */
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    /* Background track line for progress */
}

.now-playing-track {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.mini-artwork {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
}

.artwork-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mini-artwork:hover .artwork-image-wrapper {
    transform: scale(1.1);
}

.artwork-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.artwork-image-wrapper .material-icons-round {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
}

.fullscreen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.mini-artwork:hover .fullscreen-overlay {
    opacity: 1;
}

/* Custom Spaced Fullscreen Icon using two distinct arrows */
.fullscreen-icon-custom {
    position: relative;
    width: 28px;
    height: 28px;
}

.fullscreen-icon-custom .material-icons-round {
    position: absolute;
    font-size: 15px;
    /* Thicker arrows via text-stroke */
    font-weight: bold;
    -webkit-text-stroke: 1px #ffffff;
    color: #ffffff;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.arrow-top-right {
    top: 2px;
    right: 2px;
}

.arrow-bottom-left {
    bottom: 2px;
    left: 2px;
}

body.is-fullscreen .arrow-top-right {
    top: -4px;
    right: -4px;
}

body.is-fullscreen .arrow-bottom-left {
    bottom: -4px;
    left: -4px;
}

/* Hover expand effect (moves them further apart to increase gap) */
.mini-artwork:hover .arrow-top-right {
    transform: translate(4px, -4px);
}

.mini-artwork:hover .arrow-bottom-left {
    transform: translate(-4px, 4px);
}

body.is-fullscreen .mini-artwork:hover .arrow-top-right {
    transform: translate(-4px, 4px);
}

body.is-fullscreen .mini-artwork:hover .arrow-bottom-left {
    transform: translate(4px, -4px);
}

.track-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.track-text .title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-text .artist {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar-wrapper {
    position: absolute;
    bottom: -2px;
    /* Overlap the border-bottom exactly */
    left: 0;
    width: 100%;
    height: 2px;
    background: transparent;
    cursor: pointer;
    border-radius: 2px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--text-primary);
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s linear;
}

/* Hover slightly thickens the bar */
.progress-bar-wrapper:hover {
    height: 4px;
    bottom: -3px;
}

.time-display {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.divider-time {
    margin: 0 -8px;
    opacity: 0.5;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon .material-icons-round {
    font-size: 28px;
}

.btn-small .material-icons-round {
    font-size: 18px;
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: #fff;
    transform: scale(1.1);
}

.btn-small:hover .material-icons-round {
    color: #fff;
}

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

.btn-play {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-play .material-icons-round {
    font-size: 36px;
}

.active-icon .material-icons-round {
    color: var(--accent);
    /* active red state */
}

.lyrics-container {
    flex: 1;
    overflow-y: auto;
    padding: 60px 40px 160px;
    /* Extra bottom padding for floating controls */
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Reduced from 24px for tighter overall list spacing */
    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

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

.lyric-placeholder {
    margin: auto;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* Lyric Lines & Words */
.lyric-line {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.5px;
    color: var(--lyric-inactive);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s, padding 0.2s;
    transform-origin: left center;
    filter: blur(1px);
    opacity: 0.6;
    padding: 12px 18px;
    /* Tighter internal padding */
    border-radius: 12px;
    margin: 0;
    /* Rely on .lyrics-container gap instead */
    /* Removed min-height so the box grows with wrapped text */
    display: flex;
    /* 改用flex布局防止行内元素上下跳动导致父容器重新计算高度 */
    flex-wrap: wrap;
    align-items: baseline;
    /* Ensure elements align at their text baseline */
    gap: 4px;
    /* Reduced inner gap between wrapped words/translation */
    /* 给折行的单词和翻译增加间距 */
    /* 允许换行 */
    /* Removed align-content: flex-start to allow natural flex lines */
    backface-visibility: hidden;
    /* 防止开启3D加速时的文字模糊和抖动 */
    -webkit-font-smoothing: subpixel-antialiased;
    will-change: transform, filter, opacity;
    /* 提前告知浏览器优化 */
}

.lyric-line.active {
    color: var(--lyric-active);
    transform: translateZ(0);
    /* Removed scale(1.05) to prevent background container warping and misalignment relative to other lines */
    /* Hardware accelerate the transform */
    filter: blur(0px);
    opacity: 1;
    will-change: transform, filter, opacity;
    /* Hint to browser to optimize */
}

.lyric-line.past {
    filter: blur(2px);
    opacity: 0.4;
    transform: translateZ(0);
}

body:not(.mouse-idle) .lyric-line:hover {
    background: rgba(255, 255, 255, 0.1);
    filter: blur(0px);
    opacity: 1;
}

.lyrics-container.user-scrolling .lyric-line {
    filter: blur(0px) !important;
    opacity: 0.8;
}

.lyrics-container.user-scrolling .lyric-line.active {
    opacity: 1;
}

body:not(.mouse-idle) .lyrics-container.user-scrolling .lyric-line:hover {
    opacity: 1;
}

/* Word Level Highlight Magic */
.lyric-word {
    display: inline-block;
    position: relative;
    /* transition: color 0.1s; */
    /* --progress will be updated by JS from 0 to 100% */
    /* --float-offset will dynamically control the Y transform for the connected line effect. 
       0 = base, 1 = max float */
    --float-offset: 0;
    transform: translateY(calc(1px + (var(--float-offset) * -2px)));
    /* base is 1px, max float is -1px (1 - 2) to strongly decrease float height */
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), --float-offset 0.3s;
    vertical-align: top;
    line-height: 1.2;
    padding-bottom: 0.1em;
    /* 防止有下沉字母如g, y, p等底部被裁切的情况 */
}

/* 单词包裹，防止长行英文换行时单词在中途被截断 */
.word-wrapper {
    display: inline-flex;
    white-space: pre;
    align-items: baseline;
    /* Align inner spans to baseline */
}

/* We don't rely only on CSS classes anymore for Y-offset, JS drives --float-offset */
/* .lyric-word.active-word is still used for the gradient color logic and fallback */

/* The magic gradient text clipping trick for word karaoke effect */
/* We set background dynamically in JS using linear-gradient where black is finished, grey is unfinished */
.lyric-line.active .lyric-word {
    background: linear-gradient(to right,
            rgba(255, 255, 255, 1) var(--progress),
            rgba(255, 255, 255, 0.4) var(--progress));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Fullscreen Mode Additions */
body.is-fullscreen .player-container {
    padding: 0;
}

body.is-fullscreen .playlist-panel {
    display: none;
}

body.is-fullscreen .lyrics-container {
    padding-left: 15vw;
}

body.is-fullscreen .floating-controls.controls-hidden {
    transform: translate(-50%, 150%);
    opacity: 0;
    pointer-events: none;
}

body.mouse-idle {
    cursor: none !important;
}

body.mouse-idle * {
    cursor: none !important;
}