:root {
    color-scheme: dark;
    --bg: #0d0f14;
    --surface: #161a22;
    --surface-soft: #202633;
    --surface-hover: #2b3242;
    --text: #f5f7fb;
    --muted: #9aa4b2;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #00d9a5;
    --accent-2: #ffb84d;
    --danger: #ff5c7a;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

body.light-theme {
    color-scheme: light;
    --bg: #f6fafb;
    --surface: #ffffff;
    --surface-soft: #eef5f6;
    --surface-hover: #dfecee;
    --text: #17202a;
    --muted: #5f6f82;
    --line: rgba(23, 32, 42, 0.12);
    --accent: #008b7a;
    --accent-2: #c97800;
    --danger: #e11d48;
    --shadow: 0 20px 55px rgba(24, 48, 64, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(0, 217, 165, 0.22), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(255, 184, 77, 0.16), transparent 36rem),
        var(--bg);
    color: var(--text);
    transition: background 220ms ease, color 220ms ease;
}

body.light-theme {
    background:
        radial-gradient(circle at top left, rgba(0, 139, 122, 0.14), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(201, 120, 0, 0.1), transparent 36rem),
        var(--bg);
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 3px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    padding: 1rem;
    padding-bottom: 7.4rem;
    gap: 1rem;
}

.sidebar,
.main-view,
.player-bar {
    border: 1px solid var(--line);
    background: rgba(22, 26, 34, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

body.light-theme .sidebar,
body.light-theme .main-view,
body.light-theme .player-bar {
    background: rgba(255, 255, 255, 0.92);
}

.sidebar {
    grid-row: 1;
    position: sticky;
    top: 1rem;
    height: calc(100vh - 2rem);
    overflow-y: auto;
    align-self: start;
    border-radius: 1.25rem;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.brand-mark {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 0.9rem;
    display: grid;
    place-items: center;
    color: #04120e;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    margin-top: 0.1rem;
}

.category-nav {
    display: grid;
    gap: 0.45rem;
}

.category-button {
    width: 100%;
    min-height: 2.8rem;
    border-radius: 0.75rem;
    padding: 0 0.85rem;
    cursor: pointer;
    color: var(--muted);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.category-button:hover,
.category-button.active {
    color: var(--text);
    background: var(--surface-soft);
}

body.light-theme .category-button.active {
    background: #e8f2f4;
    box-shadow: inset 0 0 0 1px rgba(0, 139, 122, 0.12);
}

.category-button:hover {
    transform: translateX(0.18rem);
}

.main-view {
    min-width: 0;
    border-radius: 1.25rem;
    padding: 1.4rem;
    overflow: auto;
}

.topbar,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-actions {
    width: min(33rem, 100%);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 42rem;
    margin-bottom: 0;
    font-size: clamp(1.85rem, 4vw, 4rem);
    line-height: 0.98;
    letter-spacing: 0;
}

.search-box {
    width: 100%;
    min-height: 3.1rem;
    padding: 0 1rem;
    border-radius: 0.9rem;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
}

body.light-theme .search-box {
    background: #f4f8fa;
    box-shadow: inset 0 0 0 1px rgba(23, 32, 42, 0.04);
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
}

.search-box input::placeholder {
    color: #7d8795;
}

body.light-theme .search-box input::placeholder {
    color: #8391a3;
}

.hero-player {
    min-height: 18rem;
    margin: 1.35rem 0;
    border-radius: 1.15rem;
    padding: clamp(1.1rem, 4vw, 2rem);
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(120deg, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0.18)),
        linear-gradient(135deg, rgba(0, 217, 165, 0.22), rgba(255, 184, 77, 0.2));
    display: flex;
    align-items: end;
}

body.light-theme .hero-player {
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.46)),
        linear-gradient(135deg, rgba(0, 139, 122, 0.15), rgba(201, 120, 0, 0.12));
    box-shadow: inset 0 0 0 1px rgba(23, 32, 42, 0.06);
}

.hero-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.42;
    z-index: -1;
}

body.light-theme .hero-cover {
    opacity: 0.24;
}

.hero-copy {
    max-width: 35rem;
}

.hero-copy h2 {
    margin-bottom: 0.55rem;
    font-size: clamp(2rem, 5vw, 4.8rem);
    line-height: 0.95;
}

.hero-copy p:last-child {
    max-width: 32rem;
    margin-bottom: 0;
    color: #d6dde7;
    line-height: 1.6;
}

body.light-theme .hero-copy p:last-child {
    color: #344256;
}

.library-section h2 {
    margin-bottom: 0;
}

#resultCount {
    color: var(--muted);
    margin-bottom: 0;
}

.song-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.song-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.055);
    color: var(--text);
    padding: 0.7rem;
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

body.light-theme .song-card {
    background: #ffffff;
    box-shadow: 0 14px 35px rgba(24, 48, 64, 0.08);
}

.song-card:hover,
.song-card.active {
    background: var(--surface-soft);
    border-color: rgba(0, 217, 165, 0.45);
    transform: translateY(-0.18rem);
}

body.light-theme .song-card:hover,
body.light-theme .song-card.active {
    background: #f8fcfc;
    border-color: rgba(0, 139, 122, 0.45);
}

.song-select {
    width: 100%;
    padding: 0;
    border: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.song-select img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0.75rem;
    display: block;
    margin-bottom: 0.75rem;
}

.song-card strong,
.song-card span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.like-button {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 50%;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    line-height: 1;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.song-card .like-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(13, 15, 20, 0.7);
    backdrop-filter: blur(10px);
}

body.light-theme .song-card .like-button {
    background: rgba(255, 255, 255, 0.8);
}

.like-button:hover,
.like-button.active {
    color: #ffffff;
    background: var(--danger);
    transform: translateY(-0.1rem);
}

.song-card strong {
    font-size: 0.98rem;
}

.song-card span {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.tag-row {
    margin-top: 0.65rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--accent-2);
    font-size: 0.78rem;
    font-weight: 700;
}

.empty-state {
    display: none;
    margin: 1rem 0 0;
    color: var(--muted);
}

.empty-state.show {
    display: block;
}

.player-bar {
    min-width: 0;
    position: fixed;
    left: 17.5rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    display: grid;
    grid-template-columns: minmax(12rem, 20rem) minmax(18rem, 1fr) minmax(10rem, 14rem);
    gap: 1rem;
    align-items: center;
    background: rgba(22, 26, 34, 0.76);
}

.track-summary {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.player-like {
    flex: 0 0 auto;
}

.track-summary img {
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 0.8rem;
    object-fit: cover;
    background: var(--surface-soft);
}

.track-summary div {
    min-width: 0;
}

.track-summary strong,
.track-summary span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-summary span {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 0.2rem;
}

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

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.45rem;
}

.icon-button,
.play-button {
    min-width: 3rem;
    height: 2.55rem;
    border-radius: 0.75rem;
    cursor: pointer;
    color: var(--text);
    background: var(--surface-soft);
    transition: background 160ms ease, transform 160ms ease;
}

body.light-theme .icon-button {
    color: var(--text);
    background: #eef5f6;
}

body.light-theme .theme-toggle {
    color: #ffffff;
    background: #17202a;
}

body.light-theme .theme-toggle:hover {
    background: #273546;
}

.icon-button:hover,
.play-button:hover,
.mode-button.active {
    transform: translateY(-0.1rem);
    background: var(--surface-hover);
}

.mode-button {
    min-width: 4.8rem;
}

.theme-toggle {
    min-width: 4.2rem;
    flex: 0 0 auto;
}

.mode-button.active {
    color: #06140f;
    background: var(--accent-2);
    font-weight: 800;
}

.play-button {
    min-width: 4.5rem;
    color: #06140f;
    background: var(--accent);
    font-weight: 800;
}

body.light-theme .play-button {
    color: #ffffff;
    background: #008b7a;
}

body.light-theme .play-button:hover {
    background: #007263;
}

.timeline,
.volume-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timeline span {
    width: 2.7rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.volume-control {
    justify-content: end;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        padding-bottom: 12.5rem;
    }

    .sidebar {
        grid-row: auto;
        position: static;
        top: auto;
        height: auto;
        overflow-y: visible;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .category-nav {
        display: flex;
        min-width: max-content;
    }

    .category-button {
        width: auto;
        gap: 0.75rem;
    }

    .player-bar {
        left: 0.65rem;
        right: 0.65rem;
        bottom: 0.65rem;
        grid-template-columns: 1fr;
    }

    .volume-control {
        justify-content: stretch;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 0.65rem;
        padding-bottom: 12.5rem;
        gap: 0.65rem;
    }

    .topbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .hero-player {
        min-height: 15rem;
    }

    .song-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-toggle {
        width: 100%;
    }
}

@media (max-width: 430px) {
    .sidebar,
    .main-view,
    .player-bar {
        border-radius: 0.9rem;
    }

    .brand small {
        display: none;
    }

    .song-grid {
        grid-template-columns: 1fr;
    }
}
