:root {
    --bg: #0a0a0f;
    --bg-card: #14141f;
    --bg-hover: #1e1e2e;
    --bg-input: #1a1a28;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-dim: #8888a0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login ─────────────────────────── */

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px;
    width: 380px;
    text-align: center;
}

.login-box h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 32px;
}

.btn-oauth {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-oauth:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-oauth:disabled { opacity: 0.6; cursor: wait; transform: none; }

.login-hint {
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 12px;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover { background: var(--accent-hover); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
}

/* ── App Layout ────────────────────── */

#app {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────── */

.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border);
}

.nav-list {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 14px;
    transition: all 0.15s;
}

.nav-item:hover { color: var(--text); background: var(--bg-hover); }
.nav-item.active { color: var(--accent); background: var(--bg-hover); }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* ── Content ───────────────────────── */

.content {
    flex: 1;
    margin-left: 220px;
    padding: 32px;
    padding-bottom: 100px;
}

.page h2 {
    font-size: 24px;
    margin-bottom: 24px;
}

/* ── Search ────────────────────────── */

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-bar input { flex: 1; }
.search-bar select { width: 160px; }

.url-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.url-bar input { flex: 1; font-size: 13px; }
.url-bar button { white-space: nowrap; }

/* ── Results Grid ──────────────────── */

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.result-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.result-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg-hover);
}

.result-card .info {
    padding: 12px;
}

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

.result-card .artist {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.result-card .meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.badge-hires {
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.card-actions {
    padding: 0 12px 12px;
    display: flex;
    gap: 8px;
}

/* ── Downloads List ────────────────── */

.downloads-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dl-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.dl-item img {
    width: 56px; height: 56px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-hover);
}

.dl-cover-ph {
    width: 56px; height: 56px;
    border-radius: 6px;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 24px;
    color: var(--text-dim);
}

.dl-cover-ph::after { content: "\1F3B5"; }

.dl-item-clickable { cursor: pointer; }
.dl-item-clickable:hover { border-color: var(--accent); }

.dl-info { flex: 1; }

.dl-info .title { font-weight: 600; font-size: 14px; }
.dl-info .artist { color: var(--text-dim); font-size: 12px; }

.dl-progress {
    width: 200px;
}

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar .fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.dl-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
}

.dl-status.completed { color: var(--success); background: rgba(34,197,94,0.1); }
.dl-status.downloading { color: var(--accent); background: rgba(99,102,241,0.1); }
.dl-status.queued { color: var(--warning); background: rgba(245,158,11,0.1); }
.dl-status.error { color: var(--danger); background: rgba(239,68,68,0.1); }
.dl-status.cancelled { color: var(--text-dim); background: rgba(136,136,160,0.1); }

/* ── Library ───────────────────────── */

.breadcrumb {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-dim); }

.library-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lib-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.lib-item:hover { background: var(--bg-hover); }

.lib-item .icon { font-size: 18px; width: 24px; text-align: center; }
.lib-item .name { flex: 1; font-size: 14px; }
.lib-item .detail { color: var(--text-dim); font-size: 12px; }

/* ── Playlists ─────────────────────── */

.badge-own {
    background: var(--success);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.playlist-tracks {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pl-track {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.pl-track:hover { background: var(--bg-hover); }

.pl-num {
    width: 28px;
    text-align: right;
    color: var(--text-dim);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.pl-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pl-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-artist {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-dur {
    color: var(--text-dim);
    font-size: 12px;
    width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Settings ──────────────────────── */

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.settings-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.settings-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.settings-form input { flex: 1; }

/* ── Player ────────────────────────── */

.player {
    position: fixed;
    bottom: 0;
    left: 220px;
    right: 0;
    height: 72px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
    z-index: 100;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 200px;
}

.player-info img {
    width: 48px; height: 48px;
    border-radius: 4px;
    object-fit: cover;
}

#player-title { font-size: 13px; font-weight: 600; }
#player-artist { font-size: 11px; color: var(--text-dim); }

.player-controls {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

#player-play {
    width: 36px; height: 36px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

#player-seek {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    border: none;
    padding: 0;
}

#player-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

#player-time { font-size: 12px; color: var(--text-dim); width: 40px; }

/* ── ZIP Modal ─────────────────────── */

.zip-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.zip-modal-content {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 480px;
    max-width: 90vw;
    z-index: 1000;
}

.zip-modal-content h3 {
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Music Player Modal ───────────── */

.mp-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    z-index: 999;
}

.mp-modal {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0;
    width: 520px;
    max-width: 94vw;
    z-index: 1000;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.mp-cover-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-height: 320px;
    overflow: hidden;
    background: var(--bg-hover);
}

.mp-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mp-cover-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(transparent, var(--bg-card));
}

.mp-body {
    padding: 20px 24px 24px;
}

.mp-track-title {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-track-meta {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-seek-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.mp-seek {
    flex: 1;
    -webkit-appearance: none;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    border: none;
    padding: 0;
    outline: none;
    cursor: pointer;
}

.mp-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.mp-time {
    font-size: 11px;
    color: var(--text-dim);
    width: 42px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.mp-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 14px;
}

.mp-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    font-size: 18px;
}

.mp-btn:hover { background: var(--bg-hover); color: var(--accent); }

.mp-btn-play {
    width: 56px; height: 56px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 22px;
}

.mp-btn-play:hover { background: var(--accent-hover); color: white; }

.mp-btn-sm {
    font-size: 14px;
    padding: 6px;
}

.mp-playlist {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.mp-pl-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
}

.mp-pl-item:hover { background: var(--bg-hover); }
.mp-pl-item.active { color: var(--accent); background: var(--bg-hover); }

.mp-pl-num {
    width: 24px;
    text-align: right;
    color: var(--text-dim);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.mp-pl-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-pl-dur {
    color: var(--text-dim);
    font-size: 12px;
}

.mp-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.mp-close:hover { background: rgba(0,0,0,0.7); }

.mp-toggle-pl {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.mp-toggle-pl:hover { background: rgba(0,0,0,0.7); }

/* ── Responsive ────────────────────── */

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar .logo, .nav-item span, .sidebar-footer span { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .content { margin-left: 64px; padding: 16px; }
    .player { left: 64px; }
    .search-bar { flex-wrap: wrap; }
    .search-bar select { width: 100%; }
    .results-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
