:root {
  --bg: #0e0e11;
  --surface: #17171c;
  --surface-2: #1f1f26;
  --line: #2a2a33;
  --text: #ecedf1;
  --muted: #8f92a1;
  --accent: #7c6cff;
  --accent-soft: rgba(124, 108, 255, 0.16);
  /* Standalone mode puts the player under the phone's gesture bar without this. */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 calc(148px + var(--safe-b));
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* ---------- шапка ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: calc(12px + var(--safe-t)) 16px 10px;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(12px);
}

.top-row { display: flex; align-items: center; justify-content: space-between; }
.top h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }

.search {
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--muted); }

/* ---------- список ---------- */

.list { padding: 4px 8px 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.row:active { background: var(--surface); }
.row.current { background: var(--accent-soft); }

.cover {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--surface-2) center/cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
}

.row-meta { flex: 1 1 auto; min-width: 0; }
.row-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row.current .row-title { color: var(--accent); }
.row-sub {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 6px; color: var(--text); font-weight: 600; }

/* ---------- кнопки ---------- */

.icon-btn {
  border: 0;
  background: none;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { font-size: 15px; color: var(--muted); }
.icon-btn.on { color: var(--accent); }
.icon-btn.play {
  background: var(--accent);
  color: #fff;
  width: 46px;
  height: 46px;
  font-size: 19px;
}
.icon-btn.play:active { filter: brightness(1.1); background: var(--accent); }

/* Offline state is the one thing worth colouring in the row itself. */
.dl { font-size: 15px; color: var(--muted); }
.dl.saved { color: #4ec98a; }
.dl.busy { color: var(--accent); }

/* ---------- плеер ---------- */

.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding: 6px 14px calc(10px + var(--safe-b));
  background: rgba(23, 23, 28, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.pl-progress { padding: 2px 0 0; }

.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: none;
  margin: 0;
}
.seek::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line); }
.seek::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line); }
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
}
.seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--accent); }

.pl-times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-top: -2px;
}

.pl-body { display: flex; align-items: center; gap: 12px; padding: 4px 0 0; }

.pl-cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }

.pl-meta { flex: 1 1 auto; min-width: 0; }
.pl-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pl-artist { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pl-controls { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }

/* На узком экране обложка в плеере только крадёт место у названия. */
@media (max-width: 380px) {
  .pl-cover { display: none; }
  .pl-controls .small { display: none; }
}

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(160px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 20;
  max-width: 90vw;
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

/* ---------- иконки ---------- */

.icon-btn svg { display: block; }
.icon-btn.play svg { width: 1.15em; height: 1.15em; margin: 0 auto; }
.cover svg { width: 22px; height: 22px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { transform-origin: 50% 50%; animation: spin 0.9s linear infinite; }
