:root {
    --bg: #000000;
    --bg-elevated: #121212;
    --surface: #181818;
    --surface-2: #202020;
    --surface-3: #282828;
    --border: #2f2f2f;
    --text: #ffffff;
    --muted: #b3b3b3;
    --green: #1ed760;
    --green-deep: #169c46;
    --danger: #f15e6c;
    --success: #1ed760;
    --player-h: 92px;
    --radius: 8px;
    --sidebar-w: 248px;
    --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(30, 215, 96, 0.16), transparent 24%),
        linear-gradient(180deg, #1a1a1a 0%, #0b0b0b 24%, #000000 100%);
    color: var(--text);
    font-family: var(--font);
    padding-bottom: calc(var(--player-h) + 20px);
}

a,
button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
}

.sidebar,
.content-shell {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
}

.sidebar {
    border-radius: var(--radius);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green);
    color: #000;
}

.brand-mark svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 48px;
    padding: 0 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.18s ease, color 0.18s ease;
}

.nav-link:hover,
.nav-link.active {
    background: var(--surface-2);
    color: var(--text);
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.offline-chip {
    display: none;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(30, 215, 96, 0.14);
    color: #8ef0b0;
    font-size: 0.8rem;
    font-weight: 700;
}

.sidebar-mini-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
}

.sidebar-mini-link:hover {
    color: var(--text);
}

.content-shell {
    border-radius: var(--radius);
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 18px 24px;
    background: linear-gradient(180deg, rgba(18, 18, 18, 0.95), rgba(18, 18, 18, 0.78));
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.topbar-main {
    display: flex;
    align-items: center;
    gap: 18px;
}

.search-wrap {
    position: relative;
    flex: 1;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 10px 0 42px;
    border-radius: 999px;
    background: #ffffff;
    color: #111;
}

.search-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: #111;
}

#search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #111;
}

#search-input::placeholder {
    color: #555;
}

#search-btn,
.ghost-btn,
.primary-btn,
.save-btn,
.section-link,
.text-link,
.row-play,
.floating-play,
#btn-download,
.ctrl-btn,
#btn-play {
    border: none;
    cursor: pointer;
}

#search-btn {
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: #111;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ghost-btn,
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
}

.ghost-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.ghost-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.primary-btn {
    background: var(--green);
    color: #000;
}

.primary-btn:hover {
    background: #3be477;
}

.main-view {
    padding: 0 24px 24px;
}

.view-hero {
    padding: 18px 0 10px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
}

.eyebrow.muted {
    opacity: 0.8;
}

#view-title {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1;
}

#view-subtitle {
    margin: 14px 0 0;
    max-width: 720px;
    color: var(--muted);
    font-size: 1rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.6fr);
    gap: 18px;
    padding: 28px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(30, 215, 96, 0.24), rgba(32, 32, 32, 0.96));
    margin-bottom: 28px;
}

.hero-panel-copy h2 {
    margin: 0 0 10px;
    font-size: clamp(1.6rem, 2.4vw, 2.6rem);
}

.hero-panel-copy p,
.hero-panel-stat span,
.section-head p,
.media-card-copy p,
.detail-copy p,
.now-playing-copy p,
.empty-panel,
.loading-panel p {
    color: var(--muted);
}

.hero-kicker {
    margin: 0 0 10px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.hero-panel-stat {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 6px;
}

.hero-panel-stat strong {
    font-size: 3rem;
    line-height: 1;
}

.view-content {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.content-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
}

.section-head h2 {
    margin: 0;
    font-size: 1.55rem;
}

.section-head p {
    margin: 6px 0 0;
}

.section-link,
.text-link {
    padding: 0;
    background: transparent;
}

.section-link,
.text-link.subtle {
    color: var(--muted);
}

.section-link:hover,
.text-link:hover {
    color: var(--text);
}

.text-link.strong {
    color: var(--text);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
}

.card-grid.spacious {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.media-card {
    position: relative;
    min-width: 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: background 0.18s ease, transform 0.18s ease;
}

.media-card:hover {
    background: var(--surface-2);
    transform: translateY(-2px);
}

.media-card-hit {
    width: 100%;
    padding: 16px;
    background: transparent;
    color: inherit;
    text-align: left;
}

.media-art {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    border-radius: 6px;
    background: var(--surface-3);
}

.artist-card .media-art {
    border-radius: 50%;
}

.media-card-copy {
    padding-top: 14px;
}

.media-card-copy h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.media-card-copy p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

.floating-play {
    position: absolute;
    right: 18px;
    bottom: 74px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--green);
    color: #000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.media-card:hover .floating-play {
    opacity: 1;
    transform: translateY(0);
}

.floating-play svg,
.row-index-hover svg {
    width: 18px;
    height: 18px;
}

.track-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.track-row,
.offline-row {
    display: grid;
    grid-template-columns: 46px 52px minmax(0, 1fr) minmax(140px, 0.6fr) 64px 92px;
    gap: 14px;
    align-items: center;
    min-height: 72px;
    padding: 0 12px;
    border-radius: 6px;
    transition: background 0.16s ease;
}

.track-row:hover,
.offline-row:hover,
.track-row.playing,
.offline-row.playing {
    background: rgba(255, 255, 255, 0.08);
}

.row-play {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
}

.row-index,
.row-index-hover {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.row-index-hover {
    opacity: 0;
}

.track-row:hover .row-index,
.track-row.playing .row-index,
.offline-row:hover .row-index,
.offline-row.playing .row-index {
    opacity: 0;
}

.track-row:hover .row-index-hover,
.track-row.playing .row-index-hover,
.offline-row:hover .row-index-hover,
.offline-row.playing .row-index-hover {
    opacity: 1;
}

.row-cover {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--surface-3);
}

.row-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.row-copy .text-link,
.album-link {
    text-align: left;
}

.row-copy .strong,
.album-link {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-time {
    color: var(--muted);
    font-size: 0.9rem;
}

.save-btn {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
}

.save-btn.saved {
    background: rgba(30, 215, 96, 0.2);
    color: #95f3b8;
}

.icon-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.detail-head,
.now-playing-layout {
    display: grid;
    gap: 22px;
}

.detail-head {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: end;
}

.detail-art,
.now-playing-art {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface-3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.detail-art.round {
    border-radius: 50%;
}

.detail-copy h2,
.now-playing-copy h2 {
    margin: 8px 0 12px;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 0.95;
}

.now-playing-layout {
    grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.now-playing-card,
.queue-panel {
    padding: 22px;
    border-radius: var(--radius);
    background: var(--surface);
}

.now-playing-mobile-controls {
    display: none;
}

.now-playing-button-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.np-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.np-btn.primary {
    width: 56px;
    height: 56px;
    background: var(--text);
    color: #000;
}

.np-btn svg,
.np-volume-icon svg {
    width: 18px;
    height: 18px;
}

.now-playing-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
}

.np-volume-icon {
    display: inline-flex;
    color: var(--muted);
}

#now-playing-volume {
    width: 100%;
    appearance: none;
    height: 4px;
    border-radius: 999px;
    background: #4d4d4d;
}

#now-playing-volume::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text);
}

.queue-table {
    max-height: 620px;
    overflow: auto;
}

.clickable-player {
    cursor: pointer;
}

.loading-panel,
.empty-panel {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

.compact-empty {
    min-height: 160px;
}

.spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--green);
    animation: spin 0.8s linear infinite;
}

.empty-note {
    margin: 0;
}

#player-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1.2fr) minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    min-height: var(--player-h);
    padding: 0 20px;
    background: rgba(24, 24, 24, 0.98);
    border-top: 1px solid var(--border);
    transform: translateY(100%);
    transition: transform 0.24s ease;
}

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

.player-info,
.player-extras,
.volume-block,
.ctrl-btns,
.player-controls,
.progress-wrap {
    display: flex;
    align-items: center;
}

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

.player-info {
    gap: 12px;
}

#player-cover {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--surface-3);
}

#player-title,
#player-artist {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#player-title {
    font-size: 0.95rem;
    font-weight: 700;
}

#player-artist {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.player-controls {
    flex-direction: column;
    gap: 8px;
}

.ctrl-btns {
    gap: 16px;
}

.ctrl-btn,
#btn-play,
#btn-download {
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn {
    color: var(--muted);
}

.ctrl-btn:hover,
#btn-download:hover {
    color: var(--text);
}

.ctrl-btn svg,
#btn-download svg {
    width: 18px;
    height: 18px;
}

#btn-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text);
    color: #000;
}

.progress-wrap {
    width: 100%;
    gap: 8px;
}

.time {
    color: var(--muted);
    font-size: 0.74rem;
}

#progress-bar,
#volume-slider {
    appearance: none;
    height: 4px;
    border-radius: 999px;
    background: #4d4d4d;
}

#progress-bar {
    flex: 1;
}

#volume-slider {
    width: 96px;
}

#progress-bar::-webkit-slider-thumb,
#volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text);
}

.player-extras {
    justify-content: flex-end;
    gap: 14px;
}

.volume-block {
    gap: 8px;
}

.vol-icon svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
}

#btn-download {
    width: 36px;
    height: 36px;
    color: var(--muted);
}

#btn-download[data-state="saved"] {
    color: var(--success);
}

#toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--player-h) + 12px);
    transform: translate(-50%, 10px);
    padding: 12px 18px;
    border-radius: 999px;
    background: #2a2a2a;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 30;
}

#toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

#toast.success {
    background: #173c24;
    color: #aef5c7;
}

#toast.error {
    background: #411b20;
    color: #ffb6c0;
}

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

@media (max-width: 1080px) {
    .detail-head,
    .now-playing-layout,
    .hero-panel {
        grid-template-columns: 1fr;
    }

    .track-row,
    .offline-row {
        grid-template-columns: 46px 52px minmax(0, 1fr) 64px 92px;
    }

    .album-link {
        display: none;
    }
}

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        z-index: 25;
        min-height: 74px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 0;
        border-radius: 18px;
        background: rgba(24, 24, 24, 0.98);
        border: 1px solid rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(14px);
    }

    .brand,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0;
    }

    .nav-link {
        justify-content: center;
        padding: 8px 4px;
        min-height: 56px;
        flex-direction: column;
        gap: 6px;
        font-size: 0.76rem;
    }

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

    .main-view {
        padding: 0 16px 104px;
    }

    #player-bar {
        grid-template-columns: 1fr;
        padding: 12px 16px 16px;
    }

    .player-extras {
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    body {
        padding-bottom: 178px;
    }

    .view-hero {
        padding-top: 10px;
    }

    #view-title {
        font-size: 2.15rem;
    }

    #view-subtitle {
        font-size: 0.92rem;
    }

    .hero-panel {
        padding: 18px;
        margin-bottom: 22px;
    }

    .hero-panel-stat strong {
        font-size: 2.35rem;
    }

    .card-grid,
    .card-grid.spacious {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .media-card-hit {
        padding: 12px;
    }

    .media-card-copy h3 {
        font-size: 0.92rem;
    }

    .media-card-copy p {
        font-size: 0.8rem;
    }

    .floating-play {
        right: 14px;
        bottom: 62px;
        width: 42px;
        height: 42px;
        opacity: 1;
        transform: none;
    }

    .track-row,
    .offline-row {
        grid-template-columns: 40px 48px minmax(0, 1fr) 70px;
        padding: 0 8px;
        gap: 10px;
    }

    .row-time {
        display: none;
    }

    .save-btn {
        min-height: 30px;
        padding: 0 10px;
        font-size: 0.78rem;
    }

    .row-copy .strong,
    .row-copy .subtle {
        max-width: 100%;
        font-size: 0.84rem;
    }

    .hero-actions {
        width: 100%;
    }

    .topbar-actions {
        display: none;
    }

    #player-bar {
        left: 8px;
        right: 8px;
        bottom: 86px;
        min-height: 72px;
        padding: 10px 12px;
        gap: 8px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 12px;
        background: rgba(24, 24, 24, 0.98);
        box-shadow: 0 14px 32px rgba(0, 0, 0, 0.38);
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .player-info {
        width: 100%;
        gap: 10px;
    }

    #player-cover {
        width: 44px;
        height: 44px;
        border-radius: 6px;
    }

    .player-text {
        flex: 1;
    }

    #player-title {
        font-size: 0.86rem;
    }

    #player-artist {
        font-size: 0.75rem;
        margin-top: 2px;
    }

    .player-controls {
        width: 100%;
        gap: 4px;
        grid-column: 1 / -1;
    }

    .ctrl-btns {
        width: auto;
        justify-content: flex-end;
        gap: 10px;
        position: absolute;
        right: 12px;
        top: 14px;
    }

    .ctrl-btn svg {
        width: 17px;
        height: 17px;
    }

    #btn-play {
        width: 32px;
        height: 32px;
    }

    .progress-wrap {
        gap: 6px;
        width: calc(100% - 12px);
    }

    .time {
        display: none;
    }

    .player-extras {
        display: none;
    }

    .spotify-now-playing {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .now-playing-card {
        background: linear-gradient(180deg, rgba(80, 80, 80, 0.22), rgba(24, 24, 24, 1));
        padding: 18px 18px 24px;
    }

    .now-playing-art {
        border-radius: 10px;
    }

    .now-playing-copy {
        text-align: center;
    }

    .now-playing-copy h2 {
        font-size: 2.1rem;
    }

    .now-playing-mobile-controls {
        display: block;
        margin-top: 18px;
    }

    .queue-panel {
        padding: 16px;
    }

    .queue-table {
        max-height: none;
    }
}
