:root {
    --bg: #0e0e10;
    --surface: #18181b;
    --surface2: #1f1f23;
    --border: #2a2a2e;
    --text: #f0f0f2;
    --text2: #c8c8d0;
    --text3: #9a9aaa;
    --accent: #c19a5b;
    --accent2: #d4af72;
    --red: #ef4444;
    --red-dim: #7f1d1d;
    --green: #22c55e;
}

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

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

/* --- Header --- */

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-shrink: 0;
}

header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
}

header #track-count {
    font-size: 12px;
    color: var(--text3);
}

.search-wrap {
    flex: 1;
    max-width: 480px;
}

#filter {
    width: 100%;
    padding: 8px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

#filter::placeholder { color: var(--text3); }
#filter:focus { border-color: var(--accent); }

/* --- Collection nav --- */

nav#collections {
    padding: 10px 20px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

nav .pill {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

nav .pill:hover { border-color: var(--text3); color: var(--text); }
nav .pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #111;
    font-weight: 600;
}

.pill-group { display: inline-flex; gap: 0; }
.pill-group .pill:first-child { border-radius: 20px 0 0 20px; }
.pill-group .pill-shuffle {
    border-radius: 0 20px 20px 0;
    border-left: none;
    font-size: 11px;
    padding: 5px 10px;
    color: var(--text3);
}
.pill-group .pill-shuffle:hover { background: var(--accent); border-color: var(--accent); color: #111; }

/* --- Main table --- */

main { padding: 0 20px 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead { position: sticky; top: 55px; z-index: 5; background: var(--bg); }

th {
    text-align: left;
    padding: 10px 10px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text3);
    border-bottom: 1px solid var(--border);
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }

td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    transition: background 0.1s;
}

td:first-child { color: var(--text); }

tr:hover td { background: var(--surface); }

tr.liked td:first-child { color: var(--accent2); font-weight: 500; }

tr.trashed {
    opacity: 0.35;
    text-decoration: line-through;
    text-decoration-color: var(--text3);
}

.col-dur { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-actions { white-space: nowrap; text-align: right; }

#no-results {
    text-align: center;
    padding: 40px;
    color: var(--text3);
    font-size: 15px;
}

#no-results.hidden { display: none; }

/* --- Buttons --- */

button {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    font-size: 12px;
    margin-left: 3px;
    transition: all 0.12s;
}

button:hover { background: var(--surface); border-color: var(--text3); color: var(--text); }

.btn-rate {
    width: 28px;
    padding: 4px 0;
    text-align: center;
    font-size: 15px;
    border: none;
    background: transparent;
    color: var(--text3);
    border-radius: 4px;
}

.btn-rate:hover { background: var(--surface2); }

.btn-like:hover, .btn-like.active { color: var(--red); }
.btn-trash.active { color: var(--red); background: var(--red-dim); }
.btn-trash:hover { color: var(--red); }

.btn-play {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.btn-rear { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-rear:hover { background: var(--accent); color: #111; }

.btn-here { border-color: var(--border); }

/* --- Local player --- */

#local-player {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    background: var(--surface);
    padding: 6px 20px;
    border-top: 1px solid var(--border);
    z-index: 20;
}

#local-player.hidden { display: none; }
#local-audio { width: 100%; height: 32px; filter: invert(1) hue-rotate(180deg) brightness(0.8); }

/* --- Now-playing footer --- */

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 20;
}

footer.hidden { display: none; }

#np-rating { display: flex; gap: 4px; flex-shrink: 0; }
#np-rating .btn-rate { font-size: 18px; color: var(--text3); }
#np-rating .btn-like.active { color: var(--red); }
#np-rating .btn-trash.active { color: var(--red); }

#np-track { flex: 1; min-width: 0; }
#np-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#np-artist {
    font-size: 12px;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#np-time {
    font-size: 13px;
    color: var(--text3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#np-controls { display: flex; gap: 6px; flex-shrink: 0; }
#np-controls button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 6px;
}
#np-controls button:hover { border-color: var(--accent); color: var(--accent); }

/* --- Responsive --- */

@media (max-width: 768px) {
    header { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
    .search-wrap { max-width: 100%; order: 3; flex-basis: 100%; }
    main { padding: 0 10px 20px; }
    nav#collections { padding: 8px 14px; }
    .hide-sm { display: none; }
    th, td { padding: 6px 6px; }
    .btn-play { padding: 4px 8px; font-size: 11px; }
}
