:root {
    color-scheme: dark;
    --bg: #090b10;
    --panel: #121720;
    --panel-2: #171e2a;
    --text: #f6f7fb;
    --muted: #9aa5b4;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.22);
    --accent: #21d4a3;
    --accent-2: #ff4d7d;
    --shadow: 0 18px 70px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(33, 212, 163, 0.14), transparent 27rem),
        radial-gradient(circle at top right, rgba(255, 77, 125, 0.1), transparent 24rem),
        linear-gradient(135deg, #080a0f 0%, #111723 58%, #120d16 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="ocean"] {
    --accent: #42c8ff;
    --accent-2: #6cf0d2;
    background:
        radial-gradient(circle at top left, rgba(66, 200, 255, 0.16), transparent 27rem),
        radial-gradient(circle at top right, rgba(108, 240, 210, 0.1), transparent 24rem),
        linear-gradient(135deg, #061018 0%, #102333 58%, #07161e 100%);
}

body[data-theme="rose"] {
    --accent: #ff4d9d;
    --accent-2: #ffd166;
    background:
        radial-gradient(circle at top left, rgba(255, 77, 157, 0.16), transparent 27rem),
        radial-gradient(circle at top right, rgba(255, 209, 102, 0.1), transparent 24rem),
        linear-gradient(135deg, #10070d 0%, #22121f 58%, #160b13 100%);
}

body[data-theme="mono"] {
    --accent: #f6f7fb;
    --accent-2: #9aa5b4;
    background:
        radial-gradient(circle at top left, rgba(246, 247, 251, 0.1), transparent 27rem),
        linear-gradient(135deg, #090b10 0%, #141820 58%, #0d1016 100%);
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px max(14px, calc((100vw - 1180px) / 2));
    background: rgba(9, 11, 16, 0.84);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand-mark,
.disc,
.track-art {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #07100d;
    flex: 0 0 auto;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
}

.brand strong,
.brand small,
.now-playing strong,
.now-playing small,
.track-main strong,
.track-main small {
    display: block;
}

.brand small,
.empty,
.panel-head input,
.track-main small,
.now-playing small,
.folder-item small,
.file-drop small,
.upload-box label span {
    color: var(--muted);
}

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
}

.icon-button:hover,
.icon-button.is-active {
    border-color: rgba(33, 212, 163, 0.9);
    background: rgba(33, 212, 163, 0.16);
    color: var(--accent);
}

.upload-trigger {
    flex: 0 0 auto;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.online-status {
    display: grid;
    place-items: center;
    width: 44px;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    color: #39f08b;
}

.privileged-label {
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
}

.online-status span {
    position: relative;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #39f08b;
    box-shadow: 0 0 16px rgba(57, 240, 139, 0.9);
}

.online-status span::before,
.online-status span::after {
    content: "";
    position: absolute;
    inset: -7px;
    border: 2px solid rgba(57, 240, 139, 0.8);
    border-radius: 50%;
    animation: onlineWave 1.8s ease-out infinite;
}

.online-status span::after {
    animation-delay: 0.55s;
}

.online-status small {
    margin-top: 2px;
    color: #b8ffd7;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    text-transform: lowercase;
}

@keyframes onlineWave {
    0% {
        opacity: 0.95;
        transform: scale(0.35);
    }
    100% {
        opacity: 0;
        transform: scale(1.35);
    }
}

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 198px;
}

.app-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.app-layout.is-folder-view {
    grid-template-columns: minmax(0, 1fr);
}

.app-layout.is-home-view {
    grid-template-columns: minmax(0, 1fr);
}

.panel,
.upload-card,
.player-shell {
    background: rgba(18, 23, 32, 0.88);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.panel,
.upload-card {
    border-radius: 8px;
    padding: 18px;
}

.tracks-panel {
    min-height: 140px;
}

.is-home-view .tracks-panel,
.is-folder-music .tracks-panel {
    padding: 26px 30px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
        rgba(18, 23, 32, 0.88);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.tracks-panel .panel-head {
    display: grid;
    grid-template-columns: auto minmax(260px, 380px);
    align-items: center;
}

.tracks-panel .search-shell {
    justify-self: end;
}

h2,
p {
    margin-top: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.tracks-panel h2 {
    font-size: 20px;
}

.upload-note {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.folder-form input,
.upload-box select {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}

.search-shell {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 8px;
    min-width: min(360px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035)),
        rgba(12, 15, 22, 0.92);
    padding: 7px 8px 7px 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 34px rgba(0, 0, 0, 0.24);
}

.search-shell:focus-within {
    border-color: rgba(33, 212, 163, 0.78);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 0 3px rgba(33, 212, 163, 0.12),
        0 18px 40px rgba(0, 0, 0, 0.28);
}

.search-shell > svg {
    color: var(--accent);
}

.search-shell input {
    min-width: 0;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    outline: none;
    padding: 6px 0;
}

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

.search-shell button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    opacity: 0;
    pointer-events: none;
}

.search-shell button.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.search-shell button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.folder-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 46px;
    gap: 8px;
    margin-bottom: 14px;
}

.folder-form button,
.upload-box button {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #06100d;
    font-weight: 900;
}

.folder-list,
.track-list,
.upload-progress {
    display: grid;
    gap: 10px;
}

.track-list {
    max-height: 370px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-color: rgba(33, 212, 163, 0.7) rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
}

.folder-list {
    max-height: 380px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-color: rgba(33, 212, 163, 0.7) rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
}

.folder-list::-webkit-scrollbar,
.track-list::-webkit-scrollbar {
    width: 8px;
}

.folder-list::-webkit-scrollbar-track,
.track-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
}

.folder-list::-webkit-scrollbar-thumb,
.track-list::-webkit-scrollbar-thumb {
    background: rgba(33, 212, 163, 0.7);
    border-radius: 999px;
}

.no-results {
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
    text-align: left;
}

.folder-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: stretch;
}

.folder-item,
.track-item {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    text-align: left;
}

.folder-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
}

.delete-button {
    display: grid;
    place-items: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 77, 125, 0.35);
    border-radius: 8px;
    background: rgba(255, 77, 125, 0.11);
    color: #ff6d96;
}

body:not(.is-privileged) .delete-button {
    display: none;
}

body:not(.is-privileged) .folder-row {
    grid-template-columns: minmax(0, 1fr);
}

body:not(.is-privileged) .track-actions {
    display: none;
}

.delete-button:hover {
    border-color: rgba(255, 77, 125, 0.8);
    background: rgba(255, 77, 125, 0.2);
}

.folder-item.is-active,
.track-item.is-playing {
    border-color: rgba(33, 212, 163, 0.8);
    background: rgba(33, 212, 163, 0.12);
}

.upload-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 5, 8, 0.72);
    backdrop-filter: blur(14px);
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 5, 8, 0.74);
    backdrop-filter: blur(14px);
}

.privilege-modal {
    position: fixed;
    inset: 0;
    z-index: 75;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 5, 8, 0.74);
    backdrop-filter: blur(14px);
}

.privilege-modal[hidden] {
    display: none;
}

.privilege-card {
    width: min(390px, 100%);
    padding: 18px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(18, 23, 32, 0.96);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
}

.pin-display {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}

.pin-display span {
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.pin-display span.is-filled {
    background: var(--accent);
    box-shadow: 0 0 18px rgba(33, 212, 163, 0.38);
}

.pin-error {
    margin: 0 0 12px;
    color: #ff6d96;
    font-weight: 800;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.pin-pad button,
.privilege-submit {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-weight: 900;
}

.pin-pad button:hover {
    border-color: rgba(33, 212, 163, 0.8);
    color: var(--accent);
}

.privilege-submit {
    width: 100%;
    margin-top: 12px;
    border: 0;
    background: var(--accent);
    color: #06100d;
}

.confirm-card {
    width: min(430px, 100%);
    padding: 22px;
    border: 1px solid rgba(255, 77, 125, 0.34);
    border-radius: 8px;
    background: rgba(18, 23, 32, 0.96);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
    text-align: center;
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: rgba(255, 77, 125, 0.14);
    color: #ff6d96;
}

.confirm-icon svg {
    width: 30px;
    height: 30px;
}

.confirm-card h2 {
    margin-bottom: 8px;
}

.confirm-card p {
    margin-bottom: 18px;
    color: var(--muted);
    line-height: 1.5;
}

.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.danger-button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: #ff4d7d;
    color: #fff;
    font-weight: 900;
}

.danger-button:hover {
    background: #ff2f67;
}

.upload-modal[hidden] {
    display: none;
}

.confirm-modal[hidden] {
    display: none;
}

.upload-card {
    width: min(520px, 100%);
}

.upload-box {
    display: grid;
    gap: 14px;
}

.upload-box label {
    display: grid;
    gap: 7px;
}

.file-drop {
    min-height: 142px;
    place-items: center;
    justify-content: center;
    padding: 22px;
    border: 1px dashed rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    text-align: center;
}

.file-drop input {
    width: 100%;
}

.file-drop span {
    color: var(--text);
    font-weight: 800;
}

.upload-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.upload-box button {
    min-height: 48px;
}

.upload-box button[type="submit"] {
    display: inline-grid;
    grid-template-columns: 20px auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.button-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(6, 16, 13, 0.26);
    border-top-color: #06100d;
    border-radius: 50%;
    opacity: 0;
}

.is-uploading .button-spinner {
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

.secondary-button {
    min-width: 92px;
    border: 1px solid var(--line-strong) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text) !important;
}

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

.progress-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.progress-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.track-item {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px;
}

.is-folder-music .track-item {
    grid-template-columns: 48px minmax(0, 1fr) 44px;
}

.track-actions {
    display: none;
}

.is-folder-music .track-actions {
    display: grid;
    place-items: center;
}

.is-folder-music .track-actions .delete-button {
    pointer-events: auto;
}

.back-folder {
    flex: 0 0 auto;
}

.track-art {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

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

.track-main strong,
.track-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-shell {
    position: fixed;
    left: 50%;
    bottom: 76px;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    width: min(980px, calc(100% - 28px));
    padding: 14px;
    border-radius: 8px;
    transform: translateX(-50%);
    backdrop-filter: blur(18px);
    box-shadow:
        -18px 0 42px rgba(255, 255, 255, 0.12),
        18px 0 42px rgba(255, 255, 255, 0.12),
        0 -14px 40px rgba(255, 255, 255, 0.1),
        0 18px 70px rgba(0, 0, 0, 0.42);
}

.player-shell audio {
    grid-column: 1 / -1;
}

.theme-picker {
    position: relative;
    z-index: 5;
    justify-self: center;
}

.theme-trigger {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-left-color: rgba(255, 255, 255, 0.55);
    border-right-color: rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06)),
        rgba(18, 23, 32, 0.96);
    color: var(--text);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
}

.theme-trigger svg {
    width: 19px;
    height: 19px;
}

.theme-trigger:hover,
.theme-trigger:focus-visible {
    border-color: rgba(33, 212, 163, 0.85);
    color: var(--accent);
}

.theme-menu {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    display: grid;
    gap: 8px;
    width: min(270px, calc(100vw - 28px));
    padding: 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(12, 15, 22, 0.96);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.48);
    transform: translateX(-50%);
    backdrop-filter: blur(18px);
}

.theme-menu strong {
    padding: 4px 4px 2px;
}

.theme-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    text-align: left;
}

.theme-menu button.is-active,
.theme-menu button:hover {
    border-color: rgba(33, 212, 163, 0.7);
    background: rgba(33, 212, 163, 0.12);
}

.theme-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.theme-dot-default {
    background: linear-gradient(135deg, #21d4a3, #ff4d7d);
}

.theme-dot-ocean {
    background: linear-gradient(135deg, #42c8ff, #6cf0d2);
}

.theme-dot-rose {
    background: linear-gradient(135deg, #ff4d9d, #ffd166);
}

.theme-dot-mono {
    background: linear-gradient(135deg, #f6f7fb, #9aa5b4);
}

.now-playing {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.disc {
    width: 54px;
    height: 54px;
    border-radius: 50%;
}

.now-playing em {
    display: block;
    min-height: 18px;
    color: var(--accent);
    font-size: 12px;
    font-style: normal;
}

.now-playing hr {
    width: 100%;
    height: 1px;
    margin: 5px 0 0;
    border: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
}

.title-marquee {
    display: block;
    max-width: 100%;
    overflow: hidden;
}

.title-marquee strong {
    display: inline-block;
    min-width: max-content;
    padding-right: 18px;
    white-space: nowrap;
}

.title-marquee.is-moving strong {
    animation: titleSnake 7s ease-in-out infinite alternate;
}

@keyframes titleSnake {
    0%,
    18% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(var(--marquee-distance));
    }
}

.repeat-controls {
    display: flex;
    gap: 8px;
    justify-self: end;
}

audio {
    width: 100%;
    accent-color: var(--accent);
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 12px;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(2, minmax(96px, 1fr));
    gap: 10px;
    width: min(380px, calc(100% - 28px));
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(10, 13, 19, 0.92);
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
    backdrop-filter: blur(18px);
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
}

.nav-item.is-active,
.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

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

    .library-panel {
        scroll-margin-top: 84px;
    }

    .player-shell {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .player-shell audio {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .page {
        width: min(100% - 20px, 1180px);
        padding-top: 12px;
        padding-bottom: 218px;
    }

    .topbar {
        padding: 10px;
    }

    .brand small {
        display: none;
    }

    .panel,
    .upload-card {
        padding: 16px;
    }

    .is-home-view .tracks-panel,
    .is-folder-music .tracks-panel {
        padding: 18px;
    }

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

    .tracks-panel .panel-head {
        grid-template-columns: 1fr;
    }

    .tracks-panel .search-shell {
        justify-self: stretch;
    }

    .track-list {
        max-height: 330px;
    }

    .folder-list {
        max-height: 340px;
    }

    .player-shell {
        bottom: 76px;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .theme-picker {
        justify-self: end;
    }

    .theme-trigger {
        width: 36px;
        height: 36px;
    }

    .theme-menu {
        bottom: calc(100% + 8px);
        width: min(260px, calc(100vw - 20px));
    }

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

    .disc {
        width: 46px;
        height: 46px;
    }

    .repeat-controls .icon-button {
        width: 40px;
        height: 40px;
    }
}
