:root {
    --accent: #fa5860;
    --accent-2: #ff8a9b;
    --accent-soft: rgba(250, 88, 96, 0.18);
    --bg: #000;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --surface-2: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.08);
    --text: #f5f5f7;
    --text-muted: #a1a1a6;
    --radius: 12px;
    --radius-lg: 20px;
    --header-h: 56px;
    --player-h: 84px;
    --header-bar-bg: rgba(0, 0, 0, 0.72);
    --header-title-gradient: linear-gradient(135deg, #fff 0%, #ffb3ba 100%);
    --content-w: 980px;
}

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

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

#page-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    transition: background 1.2s ease;
}

#page-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(250, 88, 96, 0.22), transparent 55%),
    linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: none;
}

main {
    position: relative;
    z-index: 1;
    max-width: var(--content-w);
    margin: 0 auto;
    padding: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 24px) max(16px, env(safe-area-inset-left)) calc(var(--player-h) + 24px) max(16px, env(safe-area-inset-right));
}

body:not(.player-active) main {
    padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* Hero / Now Playing */
.hero {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 28px;
    align-items: end;
    margin-bottom: 36px;
}

.hero-art {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
    background: var(--surface);
}

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

.hero-art.is-playing img {
    animation: artPulse 4s ease-in-out infinite;
}

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

.hero-art-fallback {
    position: absolute;
    inset: 0;
    display: none;
}

.hero-art.no-img .hero-art-fallback {
    display: block;
}

.hero-art.no-img img:not(.cover-default) {
    display: none;
}

.hero-art.is-default::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4) 0%, transparent 45%);
    pointer-events: none;
}

.cover-default {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hero-info {
    min-width: 0;
    padding-bottom: 4px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.hero-title {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-artist {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #ff6b72;
}

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface-hover);
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.search-box {
    flex: 1;
    min-width: 160px;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.search-box input:focus {
    border-color: rgba(250, 88, 96, 0.5);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    pointer-events: none;
}

.track-count {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Track list */
.track-list-head {
    display: grid;
    grid-template-columns: 36px 44px 1fr auto;
    gap: 12px;
    padding: 0 12px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.track-list-head .col-duration {
    width: 48px;
    text-align: right;
}

#track-list {
    list-style: none;
}

.track-item {
    display: grid;
    grid-template-columns: 36px 44px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.18s ease;
    position: relative;
}

.track-item:hover {
    background: var(--surface-hover);
}

.track-item.is-active {
    background: var(--accent-soft);
}

.track-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 999px;
    background: var(--accent);
}

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

.track-item.is-active .track-index {
    color: var(--accent);
}

.track-item:hover .track-index .num {
    display: none;
}

.track-item:hover .track-index .play-hint {
    display: block;
}

.track-index .play-hint {
    display: none;
    fill: var(--text);
}

.track-item.is-active .track-index .num,
.track-item.is-active .track-index .play-hint {
    display: none;
}

.track-item.is-active .track-index .eq {
    display: flex;
}

.eq {
    display: none;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 14px;
}

.eq span {
    width: 3px;
    background: var(--accent);
    border-radius: 1px;
    animation: eqBounce 0.8s ease-in-out infinite;
}

.eq span:nth-child(1) {
    height: 6px;
    animation-delay: 0s;
}

.eq span:nth-child(2) {
    height: 12px;
    animation-delay: 0.15s;
}

.eq span:nth-child(3) {
    height: 8px;
    animation-delay: 0.3s;
}

@keyframes eqBounce {
    0%, 100% {
        transform: scaleY(0.5);
    }
    50% {
        transform: scaleY(1);
    }
}

.track-cover {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

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

.track-cover.no-img img,
.player-cover.no-img img {
    display: none;
}

.track-cover-fallback {
    position: absolute;
    inset: 0;
}

.track-meta {
    min-width: 0;
}

.track-name {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-item.is-active .track-name {
    color: var(--accent);
}

.track-artist {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.track-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

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

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

/* Player bar */
#player-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--player-h) + env(safe-area-inset-bottom, 0px));
    z-index: 200;
    background: rgba(18, 18, 18, 0.82);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid var(--border);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

#player-bar.visible {
    transform: translateY(0);
}

.player-progress-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    cursor: pointer;
}

.player-progress-wrap input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.player-progress-bg {
    height: 100%;
    background: rgba(255, 255, 255, 0.12);
}

.player-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.1s linear;
    pointer-events: none;
}

.player-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    height: 100%;
    padding: 8px 20px 0;
    max-width: 1200px;
    margin: 0 auto;
}

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

.player-cover {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

.player-cover-fallback {
    position: absolute;
    inset: 0;
}

.player-text {
    min-width: 0;
}

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

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

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

.ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.ctrl-btn:hover {
    background: var(--surface-hover);
}

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

.ctrl-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.ctrl-btn.play-main {
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #fff;
}

.ctrl-btn.play-main:hover {
    background: #ff6b72;
}

.ctrl-btn.play-main svg {
    width: 24px;
    height: 24px;
}

.ctrl-btn.is-hidden {
    visibility: hidden;
}

.spinner.is-hidden {
    display: none;
}

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

.player-time {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-right: 8px;
    white-space: nowrap;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Settings panel */
#settings-panel {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
    visibility: hidden;
}

#settings-panel.open {
    pointer-events: auto;
    visibility: visible;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
}

#settings-panel.open .settings-backdrop {
    opacity: 1;
}

.settings-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70vh;
    padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

#settings-panel.open .settings-sheet {
    transform: translateY(0);
}

.settings-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

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

.volume-row label {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.volume-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.settings-close {
    margin-top: 20px;
    width: 100%;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--player-h) + 16px);
    transform: translateX(-50%) translateY(12px);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(28, 28, 30, 0.92);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

@media (max-width: 768px) {
    :root {
        --player-h: 72px;
    }

    main {
        padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 16px);
    }

    .hero {
        grid-template-columns: 120px 1fr;
        gap: 16px;
        margin-bottom: 24px;
    }

    .hero-art {
        border-radius: 14px;
    }

    .hero-title {
        font-size: 22px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .hero-artist {
        font-size: 14px;
        margin-bottom: 14px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .hero-actions .btn {
        height: 38px;
        padding: 0 16px;
        font-size: 13px;
    }

    .hero-actions .btn-ghost span {
        display: none;
    }

    .track-list-head {
        display: none;
    }

    .track-item {
        grid-template-columns: 28px 40px 1fr;
        padding: 10px 8px;
        min-height: 56px;
    }

    .track-duration {
        display: none;
    }

    .track-name {
        font-size: 14px;
    }

    .player-inner {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        padding: 6px 12px 0;
    }

    .player-time {
        display: none;
    }

    .player-cover {
        width: 42px;
        height: 42px;
    }

    .player-name {
        font-size: 13px;
    }

    .player-artist {
        font-size: 11px;
    }

    .ctrl-btn.prev-next {
        display: none;
    }

    .ctrl-btn {
        width: 40px;
        height: 40px;
    }

    .ctrl-btn.play-main {
        width: 42px;
        height: 42px;
    }

    .settings-sheet {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 520px) {
    .hero {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 20px;
    }

    .hero-art {
        width: min(68vw, 220px);
        max-width: 220px;
    }

    .hero-info {
        width: 100%;
        padding-bottom: 0;
    }

    .hero-actions {
        justify-content: center;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .track-count {
        text-align: center;
    }
}

@media (min-width: 769px) {
    .hero-art {
        max-width: 220px;
    }

    .ctrl-btn.mobile-settings {
        display: none;
    }
}
