:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #131826;
    --bg-glass: rgba(19, 24, 38, 0.7);
    --bg-glass-strong: rgba(19, 24, 38, 0.88);
    --bg-card: #1a2030;
    --bg-hover: #232b3f;
    --text-primary: #e8eaf0;
    --text-secondary: #a0a8b8;
    --text-muted: #6b7385;
    --accent: #7c5fff;
    --accent-hover: #6a4dff;
    --accent-glow: rgba(124, 95, 255, 0.3);
    --border: #2a3045;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --bg-gradient: linear-gradient(135deg, #0a0e1a 0%, #131826 50%, #1a1a2e 100%);
    --cover-gradient: linear-gradient(135deg, #2a3045, #1a2030);
    --scrollbar-thumb: #2a3045;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.78);
    --bg-glass-strong: rgba(255, 255, 255, 0.9);
    --bg-card: #ffffff;
    --bg-hover: #ebebef;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5e;
    --text-muted: #8a8a9e;
    --border: #e2e2e8;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --bg-gradient: linear-gradient(135deg, #f5f5f7 0%, #ffffff 50%, #fafafc 100%);
    --cover-gradient: linear-gradient(135deg, #e8eaf0, #d4d8e0);
    --scrollbar-thumb: #d4d4dc;
    color-scheme: light;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

/* Top nav */
.top-nav {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--accent), #ff8a3d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.brand:hover {
    opacity: 0.85;
}

.view-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.view-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.view-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.view-tab.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* Main view container */
.main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px 110px;
}

.main::-webkit-scrollbar {
    width: 10px;
}

.main::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

.main::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.view {
    max-width: 1200px;
    margin: 0 auto;
}

.view.hidden {
    display: none;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.view-all {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.15s;
}

.view-all:hover {
    color: var(--accent);
}

/* Banner carousel */
.banner-carousel {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 33.3333%;
    max-height: 320px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 40px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.banner-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    width: 100%;
    transform: translateX(0);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.banner-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.banner-slide img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 0;
}

.banner-slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.7) 100%);
    pointer-events: none;
}

.banner-slide-content {
    position: absolute;
    bottom: 48px;
    left: 32px;
    width: calc(100% - 64px);
    box-sizing: border-box;
    color: white;
    z-index: 1;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.banner-slide-content h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    overflow-wrap: break-word;
}

.banner-slide-content p {
    font-size: 14px;
    opacity: 0.9;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    overflow-wrap: break-word;
    margin: 0;
}

.banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-carousel:hover .banner-arrow {
    opacity: 1;
}

.banner-arrow:hover {
    background: rgba(0, 0, 0, 0.6);
}

.banner-prev { left: 16px; }
.banner-next { right: 16px; }

.banner-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
}

.banner-dot.active {
    background: white;
    width: 24px;
    border-radius: 4px;
}

/* Album grid (used for both Featured and All Albums) */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}

.album-card {
    cursor: pointer;
    transition: transform 0.2s;
}

.album-card:hover {
    transform: translateY(-4px);
}

.album-card-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: var(--cover-gradient);
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    margin-bottom: 12px;
}

.album-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.album-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 48px;
}

.album-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.album-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Album detail view */
.back-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 24px;
    transition: all 0.2s;
    font-family: inherit;
}

.back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.now-playing-back {
    margin-top: 8px;
    margin-bottom: 24px;
}

.album-detail-header {
    display: flex;
    gap: 32px;
    margin-bottom: 40px;
    align-items: flex-end;
}

.album-detail-cover {
    width: 240px;
    height: 240px;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--cover-gradient);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.album-detail-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

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

.album-detail-info .album-kind {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.album-detail-info h1 {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 12px;
    word-break: break-word;
}

.album-detail-meta {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.album-detail-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 60ch;
}

.album-track-list {
    list-style: none;
}

.album-track {
    display: grid;
    grid-template-columns: auto 40px 1fr auto auto;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.album-track:hover {
    background: var(--bg-hover);
}

.album-track.playing {
    background: var(--bg-hover);
}

.album-track.playing .album-track-num,
.album-track.playing .album-track-title {
    color: var(--accent);
}

.album-track-num {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.album-track-title {
    font-size: 15px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-clickable {
    cursor: pointer;
    transition: color 0.15s;
}

.tt-clickable:hover {
    color: var(--accent);
}

.album-track-duration {
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

.album-track-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease 0.05s;
}

.album-track:hover .album-track-actions,
.album-track.playing .album-track-actions {
    opacity: 1;
}

.action-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
    padding: 0;
}

.action-btn-sm:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.action-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    transition: background 0.15s;
    flex-shrink: 0;
}

.action-play:hover {
    background: var(--accent-hover);
    color: white;
}

.album-track-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease 0.05s;
}

.album-track:hover .album-track-actions,
.album-track.playing .album-track-actions {
    opacity: 1;
}

/* Now Playing view */
.now-playing-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    max-width: 900px;
    margin: 0 auto;
}

.cover-wrap {
    position: relative;
    width: 280px;
    height: 280px;
}

#visualizer {
    position: absolute;
    top: -70px;
    left: -70px;
    width: 420px;
    height: 420px;
    pointer-events: none;
    z-index: 0;
}

.cover-large {
    width: 280px;
    height: 280px;
    border-radius: 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    color: var(--text-muted);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.cover-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-vinyl {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vinyl-svg {
    width: 88%;
    height: 88%;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.vinyl-rotate {
    transform-origin: 120px 120px;
    animation: vinylSpin 4s linear infinite;
    animation-play-state: paused;
}

.cover-large.vinyl-spinning .vinyl-rotate {
    animation-play-state: running;
}

@keyframes vinylSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.vinyl-label {
    fill: var(--accent);
}

.now-playing-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.now-playing-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.now-playing-info-header h2 {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
}

.now-playing-info-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
    font-family: inherit;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-btn:disabled,
.action-btn[href="#"] {
    opacity: 0.4;
    pointer-events: none;
}

#song-artist {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 4px;
}

#song-meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 8px;
}

.lyrics-pane {
    grid-column: 1 / -1;
    margin-top: 32px;
    max-height: 360px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 0;
    text-align: center;
    line-height: 2;
    font-size: 16px;
    scroll-behavior: smooth;
    position: relative;
}

.lyrics-pane::-webkit-scrollbar {
    width: 6px;
}

.lyrics-pane::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.lyric-line {
    color: var(--text-muted);
    transition: all 0.3s;
    cursor: pointer;
    padding: 4px 16px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.lyric-line:hover {
    color: var(--text-secondary);
}

.lyric-line.active {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    transform: scale(1.05);
}

.lyrics-empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 60px 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: all 0.3s;
    z-index: 200;
    pointer-events: none;
    font-size: 13px;
    white-space: nowrap;
    max-width: calc(100vw - 40px);
}

.toast.toast-long {
    white-space: normal;
    word-break: break-all;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    padding: 12px 18px;
    max-width: 480px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Player bar */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    z-index: 100;
}

.player-song {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cover-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--cover-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-muted);
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
}

.cover-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder-sm {
    line-height: 1;
}

.player-info {
    min-width: 0;
    cursor: pointer;
}

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

.player-artist {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.muted {
    color: var(--text-muted);
}

.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    font-family: inherit;
    position: relative;
}

.btn-icon .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    font-weight: 700;
    background: white;
    color: var(--accent);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-icon.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-icon.active:hover {
    background: var(--accent-hover);
}

.btn-icon.active.repeat-one .badge {
    display: flex;
}

.btn-icon svg {
    display: block;
}

.btn-icon .icon-sun { display: none; }
.btn-icon .icon-moon { display: block; }
:root[data-theme="light"] .btn-icon .icon-sun { display: block; }
:root[data-theme="light"] .btn-icon .icon-moon { display: none; }

.btn-server .server-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
}
.btn-server[data-source="us"] {
    color: var(--accent);
}

.btn-play {
    background: var(--accent);
    color: white;
    width: 40px;
    height: 40px;
    font-size: 16px;
}

.btn-play:hover {
    background: var(--accent-hover);
    color: white;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}

.time {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.progress {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.progress:hover {
    height: 6px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0;
    pointer-events: none;
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

:root[data-theme="light"] .progress-handle {
    background: var(--accent);
}

.progress:hover .progress-handle {
    opacity: 1;
}

.player-extras {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.volume {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-icon {
    display: block;
    color: var(--text-secondary);
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.15s;
}

.volume-icon:hover {
    color: var(--text-primary);
}

.volume-off {
    display: none;
}

.volume[data-muted="true"] .volume-on {
    display: none;
}

.volume[data-muted="true"] .volume-off {
    display: block;
}

.volume input[type=range] {
    width: 100px;
    accent-color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
    .top-nav {
        padding: 12px 16px;
    }
    .brand { font-size: 16px; }
    .view-tab { padding: 6px 12px; font-size: 13px; }
    .main { padding: 16px 16px 130px; }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }
    .banner-carousel { margin-bottom: 24px; }
    .banner-slide-content h3 { font-size: 20px; }
    .banner-slide-content p { font-size: 11px; line-height: 1.4; }
    .now-playing-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .cover-wrap, .cover-large {
        width: 220px;
        height: 220px;
        margin: 0 auto;
    }
    #visualizer { width: 340px; height: 340px; top: -60px; left: -60px; }
    .album-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .album-detail-cover { width: 200px; height: 200px; }
    .player-bar {
        grid-template-columns: 1fr 1fr;
        height: auto;
        padding: 12px;
        gap: 12px;
    }
    .player-extras { display: none; }
}