:root {
  --bg: #0e0e10;
  --panel: #151518;
  --raised: #1c1c21;
  --hover: #202026;
  --line: #26262d;
  --text: #ececf1;
  --muted: #8d8d98;
  --faint: #5c5c66;
  --accent: #d4f25c;
  --accent-ink: #111208;
  --danger: #ff6b6b;
  --player-h: 76px;
  --cols: 36px minmax(220px, 3fr) minmax(120px, 2fr) 60px 76px 56px 64px 104px 84px 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: rgba(14, 14, 16, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--raised); border: 1px solid transparent; border-radius: 8px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--line); background: var(--hover); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); }
.search input::placeholder { color: var(--faint); }
.stats { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.link { color: var(--muted); font-size: 12px; }
.link:hover { color: var(--text); }

.name {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px 0 4px; border-radius: 17px;
  background: var(--raised); color: var(--muted); font-size: 13px; white-space: nowrap;
}
.name:hover { color: var(--text); }
.name .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: #2b2b33; color: var(--text); font-weight: 650; font-size: 12px; text-transform: uppercase;
}
.name input { width: 120px; background: none; border: 0; outline: none; color: var(--text); }

main { padding: 8px 12px calc(var(--player-h) + 90px); }

.row {
  display: grid; grid-template-columns: var(--cols); align-items: center; gap: 12px;
  min-height: 56px; padding: 0 12px; border-radius: 6px;
  color: var(--muted); font-size: 13px;
  user-select: none;
}
.row > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rows .row:hover { background: var(--hover); }
#rows .row.group.open, #rows .row.child { background: var(--panel); border-radius: 0; }
#rows .row.group.open { border-radius: 8px 8px 0 0; margin-top: 6px; }
#rows .row.child.last { border-radius: 0 0 8px 8px; margin-bottom: 6px; }
#rows .row.group.open:hover, #rows .row.child:hover { background: var(--hover); }
#rows .row.selected { background: rgba(212, 242, 92, 0.08); }
#rows .row.selected:hover { background: rgba(212, 242, 92, 0.12); }
.row.head {
  position: sticky; top: 60px; z-index: 10;
  min-height: 38px; margin-bottom: 4px;
  background: var(--bg); border-bottom: 1px solid var(--line); border-radius: 0;
  font-size: 12px; color: var(--faint);
}
.row.head button { color: var(--faint); font-size: 12px; letter-spacing: 0.02em; }
.row.head button:hover, .row.head button.on { color: var(--text); }
.row.head button.on::after { content: " ↓"; }
.row.head button.on.asc::after { content: " ↑"; }
.row.head .dot { margin: 0 6px; color: var(--faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row.head .num { text-align: right; }

.check {
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid #44444e; display: grid; place-items: center;
}
.check:hover { border-color: var(--muted); }
.check[aria-checked="true"], .check[aria-checked="mixed"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"]::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink); transform: rotate(-45deg);
}
.check[aria-checked="mixed"]::after { content: ""; width: 8px; height: 2px; background: var(--accent-ink); border-radius: 1px; }

.title-cell { display: flex; align-items: center; gap: 12px; }
.art {
  position: relative; flex: none;
  width: 40px; height: 40px; border-radius: 4px; overflow: hidden;
  background: var(--raised); color: var(--faint);
  display: grid; place-items: center;
}
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art .overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55); color: #fff; opacity: 0; transition: opacity 0.12s;
}
.art .overlay svg { width: 20px; height: 20px; }
.row:hover .art .overlay, .row.playing .art .overlay { opacity: 1; }
.titles { min-width: 0; }
.title { color: var(--text); font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.playing .title { color: var(--accent); }
.row.group .title { display: flex; align-items: center; gap: 8px; }
.row.group .title { font-weight: 600; }
.row.group .kind { color: var(--text); font-weight: 600; font-size: 11px; letter-spacing: 0.04em; }
.title-cell .art:not(.tn) { margin-right: 8px; }
.album-art { overflow: visible; background: none; }
.album-art .sleeve {
  position: relative; z-index: 1; width: 100%; height: 100%;
  display: grid; place-items: center; overflow: hidden;
  border-radius: 4px; background: var(--raised); box-shadow: 3px 0 8px rgba(0, 0, 0, 0.55);
}
.album-art .disc {
  position: absolute; top: 2px; left: 10px; width: 36px; height: 36px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 13%, #0a0a0c 14% 24%, #24242a 25% 26%, #0a0a0c 27% 40%, #24242a 41% 42%, #0a0a0c 43%);
  transition: transform 0.2s ease;
}
.row.group:hover .album-art .disc, .row.group.open .album-art .disc { transform: translateX(6px); }
.album-art .overlay { z-index: 2; border-radius: 4px; }
.row.group .chev { width: 14px; height: 14px; color: var(--faint); transition: transform 0.15s; }
.row.group.open .chev { transform: rotate(90deg); }
.row.group { cursor: pointer; }
.row.child .title-cell { padding-left: 16px; }
.row.child .c-album { visibility: hidden; }
.art.tn { width: 32px; height: 32px; margin: 0 4px; background: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.c-key .camelot { color: var(--text); font-variant-numeric: tabular-nums; }
.c-key .musical { margin-left: 6px; color: var(--faint); }
.pending { color: var(--faint); }
.badge {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: var(--raised); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}
.badge.lossless { color: var(--text); }
.c-actions { display: flex; justify-content: flex-end; gap: 2px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted); text-decoration: none;
}
.icon-btn:hover { color: var(--text); background: var(--raised); }
#rows .c-actions .icon-btn { opacity: 0; }
#rows .row:hover .c-actions .icon-btn { opacity: 1; }
#rows .c-actions .del:hover { color: var(--danger); }

.selbar {
  position: fixed; left: 50%; bottom: calc(var(--player-h) + 16px); z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 18px; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: transform 0.16s ease, opacity 0.16s ease;
  font-size: 13px; white-space: nowrap;
}
.selbar.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#selInfo { margin-right: 8px; font-variant-numeric: tabular-nums; }

.uploads {
  position: fixed; right: 16px; bottom: calc(var(--player-h) + 16px); z-index: 31;
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.uploads-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.uploads-list { max-height: 300px; overflow-y: auto; }
.up { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.up:last-child { border-bottom: 0; }
.up-name { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.up-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-name span:last-child { color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }
.up-status { margin-top: 2px; color: var(--muted); font-size: 12px; }
.up.error .up-status { color: var(--danger); }
.up.done .up-status { color: var(--accent); }
.bar { height: 3px; margin-top: 8px; border-radius: 2px; background: #2c2c34; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.bar.busy i { width: 30% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.dropzone {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(14, 14, 16, 0.82);
}
.dropzone div {
  padding: 44px 56px; border: 2px dashed var(--accent); border-radius: 16px;
  color: var(--text); font-size: 16px; font-weight: 600;
}

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  height: var(--player-h);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now-art { width: 48px; height: 48px; border-radius: 4px; overflow: hidden; flex: none; background: var(--raised); display: grid; place-items: center; color: var(--faint); }
.now-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.now .artist { color: var(--muted); font-size: 12px; }
.transport { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.buttons { display: flex; align-items: center; gap: 14px; }
.play-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg);
}
.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 18px; height: 18px; }
.seek { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.seek span { width: 40px; }
.seek span:first-child { text-align: right; }
.side { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); }
.side input { width: 110px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 16px; margin: 0; background: none; cursor: pointer;
  --p: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--p), #3a3a43 var(--p));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: #3a3a43; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%;
  background: var(--text); opacity: 0; transition: opacity 0.1s;
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); opacity: 0; }
input[type="range"]:hover::-webkit-slider-thumb { opacity: 1; }
input[type="range"]:hover::-moz-range-thumb { opacity: 1; }
input[type="range"]:hover::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--p), #3a3a43 var(--p)); }
input[type="range"]:hover::-moz-range-progress { background: var(--accent); }

.toast {
  position: fixed; left: 50%; top: 76px; z-index: 60; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 13px;
}

@media (max-width: 1100px) {
  :root { --cols: 36px minmax(200px, 3fr) 60px 76px 56px 64px 96px 76px; }
  .c-album, .c-added { display: none; }
}

@media (max-width: 760px) {
  :root { --cols: 28px minmax(0, 1fr) 44px 40px 40px; --player-h: 128px; }
  .top { padding: 0 12px; gap: 8px; }
  .search { max-width: none; }
  .stats { display: none; }
  .name { padding-right: 4px; }
  .name > span:not(.avatar) { display: none; }
  .c-time, .c-fmt, .c-by, .c-added, .c-album { display: none; }
  .c-key .musical { display: none; }
  .row { gap: 10px; padding: 0 6px; }
  #rows .c-actions .icon-btn { opacity: 1; }
  #rows .c-actions .del { display: none; }
  main { padding: 4px 6px calc(var(--player-h) + 90px); }
  .player { grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 12px 16px; gap: 10px 16px; }
  .now { grid-column: 1; grid-row: 1; }
  .transport { display: contents; }
  .buttons { grid-column: 2; grid-row: 1; }
  .seek { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .side { display: none; }
}
