:root {
  --bg: #121212;
  --bg-2: #181818;
  --bg-3: #242424;
  --bg-hover: #2a2a2a;
  --side: #000;
  --text: #fff;
  --muted: #b3b3b3;
  --dim: #6a6a6a;
  --green: #1ed760;
  --green-dark: #1db954;
  --gold: #f0c35a;
  --red: #f15e6c;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--side);
  color: var(--text);
  font: 15px/1.45 Figtree, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
svg { fill: currentColor; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; justify-self: end; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 280px 1fr; gap: 8px; padding: 8px; height: 100vh; }
.sidebar { background: var(--bg); border-radius: var(--radius); padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 24px; letter-spacing: -.5px; padding: 0 8px; }
.logo svg { width: 36px; height: 36px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 16px; padding: 8px; color: var(--muted); font-weight: 700; border-radius: 4px; transition: color .15s; }
.sidebar nav a:hover { color: var(--text); }
.sidebar nav svg { width: 24px; height: 24px; }
.sidebar-note { background: var(--bg-3); border-radius: var(--radius); padding: 16px; font-size: 13px; color: var(--muted); }
.sidebar-note strong { color: var(--text); font-size: 15px; }
.sidebar-note p { margin: 8px 0 0; }

.main { background: var(--bg); border-radius: var(--radius); overflow-y: auto; position: relative; }
.topbar { position: sticky; top: 0; z-index: 5; padding: 16px 24px; background: rgba(18, 18, 18, .85); backdrop-filter: blur(12px); }
.search { position: relative; max-width: 520px; }
.search svg { position: absolute; left: 14px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; height: 48px; padding: 0 20px 0 48px; border-radius: 500px; border: 2px solid transparent;
  background: var(--bg-3); color: var(--text); font: inherit; outline: none; transition: border-color .15s, background .15s;
}
.search input:hover { background: var(--bg-hover); border-color: #333; }
.search input:focus { border-color: var(--text); }
.content { padding: 8px 24px 48px; }

/* ---------- hero ---------- */
.hero { padding: 64px 32px; margin: 0 -24px; background: linear-gradient(180deg, #1e3a29 0%, var(--bg) 100%); }
.hero h1 { font-size: clamp(36px, 6vw, 72px); line-height: 1; letter-spacing: -2px; margin: 0 0 16px; font-weight: 800; }
.hero p { max-width: 620px; color: var(--muted); font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.chip { background: rgba(255, 255, 255, .08); padding: 6px 14px; border-radius: 500px; font-size: 13px; }
.chip b { color: var(--green); }

.section-title { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin: 32px 0 16px; }

/* ---------- track list ---------- */
.tracklist { display: flex; flex-direction: column; }
.tl-head, .tl-row { display: grid; grid-template-columns: 32px minmax(0, 4fr) minmax(0, 3fr) 60px 70px; gap: 16px; align-items: center; padding: 0 16px; }
.tl-head { color: var(--muted); font-size: 13px; height: 36px; border-bottom: 1px solid #2a2a2a; margin-bottom: 8px; }
.tl-row { height: 58px; border-radius: 4px; }
.tl-row:hover { background: var(--bg-hover); }
.tl-row .num { color: var(--muted); text-align: right; }
.tl-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tl-title img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; flex: none; }
.tl-title > span { min-width: 0; }
.tl-title strong, .tl-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-title strong { font-weight: 500; }
.tl-title small { color: var(--muted); font-size: 13px; }
.tl-row .pill { opacity: 0; transition: opacity .15s; }
.tl-row:hover .pill { opacity: 1; }
i.e { display: inline-block; font-style: normal; font-size: 9px; font-weight: 700; background: var(--muted); color: #000; border-radius: 2px; padding: 1px 4px; margin-right: 6px; vertical-align: 1px; }

.pill { display: inline-block; border: 1px solid var(--dim); padding: 4px 14px; border-radius: 500px; font-size: 13px; font-weight: 700; }
.pill:hover { border-color: var(--text); }

/* ---------- headers ---------- */
.collection-head, .track-head { display: flex; align-items: flex-end; gap: 24px; padding: 48px 24px 24px; margin: -8px -24px 0; position: relative; isolation: isolate; }
.track-head::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background-image: var(--cover); background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.4); opacity: .55; mask-image: linear-gradient(180deg, #000 30%, transparent);
}
.collection-head img, .track-head .cover { width: 232px; height: 232px; object-fit: cover; border-radius: 6px; box-shadow: 0 8px 40px rgba(0, 0, 0, .6); flex: none; }
.collection-head small, .track-meta small { font-size: 13px; font-weight: 700; }
.collection-head h1, .track-meta h1 { font-size: clamp(32px, 6vw, 80px); line-height: 1.05; letter-spacing: -2px; margin: 6px 0 12px; font-weight: 800; }
.track-meta p { margin: 0; color: var(--muted); }
.track-meta p strong { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
.tags div { background: rgba(0, 0, 0, .35); border-radius: 4px; padding: 4px 10px; font-size: 12px; display: flex; gap: 6px; }
.tags dt { color: var(--muted); }
.tags dd { margin: 0; font-weight: 700; }
.open-spotify { color: var(--muted); font-size: 13px; font-weight: 700; }
.open-spotify:hover { color: var(--text); }

/* ---------- candidates ---------- */
.candidates { display: flex; flex-direction: column; gap: 8px; }
.candidate { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto auto; gap: 16px; align-items: center; padding: 10px 16px 10px 10px; background: var(--bg-2); border-radius: var(--radius); transition: background .15s; position: relative; }
.candidate:hover { background: var(--bg-hover); }
.candidate img { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; }
.candidate.best { outline: 1px solid var(--green); }
.candidate.best::after { content: "Best match"; position: absolute; top: -9px; left: 16px; background: var(--green); color: #000; font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 500px; }
.candidate.dead { opacity: .45; }
.candidate.dead .dl { pointer-events: none; }
.c-info { min-width: 0; }
.c-title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-title:hover { text-decoration: underline; }
.c-info small { color: var(--muted); font-size: 13px; }
.warn { color: var(--gold); }
.lic { color: var(--green); }
.src { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 3px; margin-right: 4px; color: #000; }
.src-soundcloud { background: #ff7a1a; }
.src-jamendo { background: #f5b6d1; }
.src-archive { background: #d9d9d9; }
.src-audius { background: #b77bff; }
.match { font-size: 13px; color: var(--muted); white-space: nowrap; }
.badge { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 500px; background: var(--bg-3); color: var(--muted); white-space: nowrap; min-width: 64px; text-align: center; }
.badge.lossless { background: rgba(30, 215, 96, .15); color: var(--green); }
.badge.lossy { background: rgba(240, 195, 90, .12); color: var(--gold); }
.badge.loading { animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .4; } }

.btn-green { display: inline-flex; align-items: center; justify-content: center; background: var(--green); color: #000; font: inherit; font-weight: 800; border: 0; border-radius: 500px; padding: 10px 24px; cursor: pointer; transition: transform .1s, background .15s; white-space: nowrap; }
.btn-green:hover { transform: scale(1.04); background: #3be477; }
.btn-green.busy { background: var(--bg-3); color: var(--muted); pointer-events: none; }

.notice { background: var(--bg-2); border-left: 3px solid var(--green); border-radius: 4px; padding: 14px 16px; margin: 16px 0; color: var(--muted); }
.notice a { color: var(--text); text-decoration: underline; }
.notice.error { border-left-color: var(--red); color: var(--text); }
.notice.small { font-size: 13px; padding: 8px 12px; border-left-color: var(--gold); }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(180deg, #1e3a29, #000); }
.login-box { background: var(--bg); padding: 40px; border-radius: var(--radius); width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 16px; }
.login-box h1 { margin: 0; text-align: center; letter-spacing: -1px; }
.login-box input { height: 48px; border-radius: 4px; border: 1px solid var(--dim); background: var(--bg-2); color: var(--text); padding: 0 14px; font: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; padding: 0; gap: 0; height: auto; min-height: 100vh; }
  .sidebar { flex-direction: row; align-items: center; justify-content: space-between; border-radius: 0; padding: 12px 16px; }
  .sidebar nav { flex-direction: row; }
  .sidebar nav a { padding: 6px; }
  .sidebar-note { display: none; }
  .main { border-radius: 0; overflow: visible; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .hero, .collection-head, .track-head { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .tl-head, .tl-row { grid-template-columns: 24px minmax(0, 1fr) 44px; gap: 12px; padding: 0 8px; }
  .tl-row > :last-child, .tl-head > :last-child { display: none; }
  .collection-head, .track-head { flex-direction: column; align-items: flex-start; }
  .collection-head img, .track-head .cover { width: 180px; height: 180px; }
  .candidate { grid-template-columns: 48px minmax(0, 1fr) auto; row-gap: 8px; }
  .candidate img { width: 48px; height: 48px; }
  .candidate .match { grid-column: 2; }
  .candidate .dl { grid-column: 1 / -1; }
}
