:root {
    color-scheme: dark;
    --bg: #121212;
    --surface: #181818;
    --surface-2: #282828;
    --sidebar-bg: #000000;
    --player-bar-bg: #181818;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-dim: #b3b3b3;
    --accent: #1db954;
    --accent-hover: #1ed760;
    --accent-dim: #1db95426;
    --danger: #f15e6c;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    --radius-lg: 8px;
    --radius-md: 6px;
    --radius-sm: 4px;
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg: #ffffff;
        --surface: #f6f6f6;
        --surface-2: #e9e9e9;
        --sidebar-bg: #f6f6f6;
        --player-bar-bg: #f6f6f6;
        --border: #e0e0e0;
        --text: #121212;
        --text-dim: #6a6a6a;
        --accent: #1db954;
        --accent-hover: #169c46;
        --accent-dim: #1db95420;
        --danger: #d92e3f;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 2rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.brand-icon {
    width: 22px;
    height: 22px;
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem;
}

a {
    color: var(--text);
}

button {
    font-family: inherit;
    cursor: pointer;
}

.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: 999px;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 700;
    transition: transform 0.1s ease, border-color 0.15s ease;
}

.btn:hover {
    border-color: var(--text);
    transform: scale(1.03);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 0 0 1rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Layout: sidebar + scrollable main content + fixed bottom player bar */
.dashboard-shell {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    position: sticky;
    top: 1.5rem;
}

.sidebar-section {
    margin-top: 1.75rem;
}

.sidebar-section h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 700;
    margin: 0 0 0.75rem;
    padding: 0 0.5rem;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding-bottom: 130px;
}

@media (max-width: 900px) {
    .dashboard-shell {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: static;
    }
}

.guild-switcher {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.guild-switcher a {
    text-decoration: none;
    color: var(--text-dim);
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}

.guild-switcher a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.guild-switcher a.active {
    color: var(--text);
    background: var(--surface-2);
}

.add-track-form {
    display: flex;
    gap: 0.6rem;
}

.add-track-form input {
    flex: 1;
    min-width: 0;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.add-track-status {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    color: var(--text-dim);
    min-height: 1em;
}

.file-search-input {
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    margin-bottom: 0.9rem;
}

.file-breadcrumbs {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.file-breadcrumbs a {
    cursor: pointer;
    color: var(--text-dim);
    text-decoration: none;
}

.file-breadcrumbs a:hover {
    color: var(--text);
    text-decoration: underline;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.file-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.file-row:hover {
    background: var(--surface-2);
}

.file-row-folder svg {
    width: 18px;
    height: 18px;
    fill: var(--text-dim);
    flex-shrink: 0;
}

.thumb {
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    flex-shrink: 0;
    display: block;
}

.thumb-lg {
    width: 72px;
    height: 72px;
}

.thumb-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
}

.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-dim);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    font-size: 1.4rem;
}

.thumb-placeholder.thumb-sm {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.now-playing-info {
    min-width: 0;
    flex: 1;
}

.now-playing-info .now-playing-track {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-requester {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin: 0.15rem 0 0;
}

/* Fixed bottom player bar (Spotify-style) */
.now-playing-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--player-bar-bg);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.now-playing-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.now-playing-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.now-playing-left .thumb,
.now-playing-left .thumb-placeholder {
    width: 56px;
    height: 56px;
}

.now-playing-center {
    flex: 2;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.now-playing-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.progress-wrap {
    width: 100%;
}

.progress-bar {
    position: relative;
    height: 4px;
    border-radius: 999px;
    background: var(--surface-2);
    cursor: pointer;
    overflow: hidden;
}

.progress-bar:hover {
    height: 6px;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--text-dim);
    border-radius: 999px;
}

.progress-bar:hover .progress-fill {
    background: var(--accent);
}

.progress-times {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 480px;
    overflow-y: auto;
}

.history-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.history-info {
    min-width: 0;
    flex: 1;
}

.history-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.history-artist, .history-requester {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.now-playing-track {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-artist {
    color: var(--text-dim);
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
}

.now-playing-empty {
    color: var(--text-dim);
    font-style: italic;
}

.transport {
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

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

.icon-btn:hover {
    color: var(--text);
}

.icon-btn:active {
    transform: scale(0.94);
}

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

.icon-btn-primary {
    width: 40px;
    height: 40px;
    background: var(--text);
    color: var(--bg);
}

.icon-btn-primary:hover {
    background: var(--accent-hover);
    color: #000000;
    transform: scale(1.06);
}

.icon-btn-sm {
    width: 30px;
    height: 30px;
    background: var(--surface-2);
    color: var(--text-dim);
}

.icon-btn-sm:hover {
    color: var(--text);
    background: var(--surface-2);
}

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

.row-actions {
    white-space: nowrap;
    text-align: right;
}

.row-actions .icon-btn-sm {
    margin-left: 0.3rem;
}

.requested-by {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Volume knob */
.knob-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    user-select: none;
}

.knob {
    position: relative;
    width: 56px;
    height: 56px;
    touch-action: none;
    cursor: grab;
}

.knob:active {
    cursor: grabbing;
}

.knob svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.knob-track {
    fill: none;
    stroke: var(--surface-2);
    stroke-width: 8;
    stroke-linecap: round;
}

.knob-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.05s linear;
}

.knob-pointer {
    stroke: var(--text);
    stroke-width: 3;
    stroke-linecap: round;
    transform-origin: 50% 50%;
}

.knob-value {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 600;
}

.knob-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

/* Queue table */
table.queue-table {
    border-collapse: collapse;
    width: 100%;
}

table.queue-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
    padding: 0 0.6rem 0.6rem;
    border-bottom: 1px solid var(--border);
}

table.queue-table td {
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

table.queue-table tbody tr {
    cursor: grab;
    transition: background 0.15s ease;
}

table.queue-table tbody tr:hover {
    background: var(--surface-2);
}

table.queue-table tbody tr.dragging {
    opacity: 0.4;
}

table.queue-table .queue-position {
    color: var(--text-dim);
    width: 2rem;
}

table.queue-table .drag-handle {
    color: var(--text-dim);
    width: 1.5rem;
    text-align: center;
}

.queue-empty {
    color: var(--text-dim);
    font-style: italic;
    padding: 0.5rem 0;
}

/* Admin */
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 0.6rem;
    text-align: left;
    font-size: 0.9rem;
}

form.inline {
    display: inline;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-width: 360px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.form-grid input, .form-grid select {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 320px;
    margin: 4rem auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.login-form input {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.error {
    color: var(--danger);
    font-size: 0.85rem;
}
