:root {
    --bg: #0a0a12;
    --surface: #11111c;
    --surface-2: #1a1a2b;
    --border: #23233a;
    --text: #f2f3f5;
    --muted: #8e90a6;
    --accent: #5865f2;
    --accent-glow: rgba(88, 101, 242, 0.35);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

/* ---------------------------------------------------------------- layout */

.app {
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr) 72px;
    height: 100vh;
    height: 100dvh;
}

/* --------------------------------------------------------------- top bar */

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    min-width: 0;
}

.guild {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 0;
    min-width: 0;
}

.guild-icon {
    position: relative;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 9px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.guild-icon img,
.guild-icon .fallback-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fallback-icon {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.fallback-icon svg {
    width: 18px;
    height: 18px;
}

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

.search {
    position: relative;
    flex: 0 1 600px;
    min-width: 0;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 17px;
    height: 17px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 41px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

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

#search-input:hover {
    border-color: #30304d;
}

#search-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#search-input::-webkit-search-cancel-button {
    cursor: pointer;
    filter: invert(0.6);
}

.user {
    display: flex;
    justify-content: flex-end;
    flex: 1 1 0;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.avatar-fallback {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
}

/* ---------------------------------------------------------- search results */

.search-results {
    position: absolute;
    z-index: 50;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
}

.result {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.result:hover,
.result:focus-visible {
    background: var(--surface-2);
    outline: none;
}

.result-thumb,
.queue-thumb {
    position: relative;
    flex: none;
    overflow: hidden;
    border-radius: 6px;
    background: var(--surface-2);
}

.result-thumb {
    width: 40px;
    height: 40px;
}

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

.thumb-empty::after {
    content: "♪";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 15px;
}

.result-meta {
    min-width: 0;
    flex: 1 1 auto;
}

.result-title,
.queue-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-author,
.queue-author {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-duration {
    flex: none;
    color: var(--muted);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.search-empty {
    padding: 18px 10px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ------------------------------------------------------------ now playing */

.main {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 24px;
    overflow: hidden;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: min(680px, 100%);
}

.art-shell {
    position: relative;
    isolation: isolate;
    width: 210px;
    height: 210px;
}

.art-shell::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -46px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 68%);
    filter: blur(8px);
    pointer-events: none;
}

.art {
    width: 210px;
    height: 210px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    box-shadow: 0 14px 44px var(--accent-glow);
}

.art-fallback {
    display: grid;
    place-items: center;
    color: var(--muted);
}

.art-fallback svg {
    width: 56px;
    height: 56px;
    opacity: 0.55;
}

.track-title {
    margin: 24px 0 0;
    font-size: 24px;
    font-weight: 300;
    line-height: 1.3;
    color: var(--text);
    overflow-wrap: anywhere;
}

.track-title.is-idle {
    font-size: 18px;
    font-weight: 400;
    color: var(--muted);
}

.track-author {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.track-author:empty {
    display: none;
}

/* ------------------------------------------------------------ player bar */

.player {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

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

.now-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    flex: none;
    overflow: hidden;
    border-radius: 7px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

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

.thumb-fallback {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: var(--muted);
}

.thumb-fallback svg {
    width: 20px;
    height: 20px;
}

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

.now-title {
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

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

.icon-button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.icon-button svg {
    width: 17px;
    height: 17px;
}

#play-pause .icon-play,
#play-pause.is-paused .icon-pause {
    display: none;
}

#play-pause.is-paused .icon-play {
    display: block;
}

.icon-button:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-2);
}

.icon-button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.icon-button:disabled {
    opacity: 0.35;
    cursor: default;
}

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

.time {
    flex: none;
    min-width: 38px;
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.time-total {
    text-align: right;
}

.progress {
    flex: 1 1 auto;
    height: 4px;
    overflow: hidden;
    background: var(--border);
    border-radius: 999px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width 250ms linear;
    box-shadow: 0 0 10px var(--accent-glow);
}

.player-right {
    display: flex;
    justify-content: flex-end;
    min-width: 0;
}

.queue-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.queue-toggle svg {
    width: 15px;
    height: 15px;
}

.queue-toggle:hover {
    color: var(--text);
    background: var(--surface-2);
}

.queue-toggle:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.queue-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* ------------------------------------------------------------ queue panel */

.queue-panel {
    position: fixed;
    z-index: 40;
    top: 64px;
    bottom: 72px;
    right: 0;
    display: flex;
    flex-direction: column;
    width: 340px;
    max-width: 92vw;
    padding: 16px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 44px rgba(0, 0, 0, 0.4);
    transform: translateX(102%);
    transition: transform 200ms ease, visibility 200ms;
    visibility: hidden;
    pointer-events: none;
}

.queue-panel.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

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

.queue-head h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.queue-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: 8px;
    transition: background-color 150ms ease;
}

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

.queue-thumb {
    width: 40px;
    height: 40px;
}

.queue-item-body {
    min-width: 0;
    flex: 1 1 auto;
}

.queue-empty {
    margin: auto;
    padding: 24px 12px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.queue-more {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* ----------------------------------------------------------------- toast */

.toast {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: 88px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 16px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    opacity: 0;
    transform: translate(-50%, 10px);
    transition: opacity 200ms ease, transform 200ms ease;
    pointer-events: none;
}

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

/* --------------------------------------------------------------- notices */

.notice {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.notice-card {
    max-width: 430px;
    padding: 32px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.notice-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    color: var(--accent);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: 0 0 30px var(--accent-glow);
}

.notice-icon svg {
    width: 24px;
    height: 24px;
}

.notice-card h1 {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 600;
    line-height: 1.35;
}

.notice-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.6;
}

.notice-card code {
    padding: 1px 6px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 12.5px;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 720px) {
    .topbar {
        gap: 12px;
        padding: 0 12px;
    }

    .guild-name {
        display: none;
    }

    .now-meta {
        display: none;
    }

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

    .art-shell,
    .art {
        width: 150px;
        height: 150px;
    }

    .art-shell::before {
        inset: -30px;
    }

    .track-title {
        margin-top: 18px;
        font-size: 20px;
    }

    .main {
        padding: 16px;
    }
}

@media (max-width: 460px) {
    .queue-toggle span:not(.queue-count) {
        display: none;
    }

    .queue-panel {
        width: 100vw;
        max-width: 100vw;
        border-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 1ms !important;
    }

    .progress-fill {
        transition: none;
    }
}
