:root {
  --bg: #0e0e12;
  --bg2: #18181f;
  --bg3: #24242d;
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #ff5c7a;
  --accent2: #ff8a5c;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 16px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.top h1 { font-size: 26px; margin: 0; letter-spacing: -0.5px; }
.add-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 16px rgba(255, 92, 122, .35);
}
.add-btn:active { transform: scale(.93); }

/* ---------- сетка ---------- */
main { padding: 4px 16px calc(110px + var(--safe-b)); max-width: 1200px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr 1fr; } }
.tile { position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; }
.tile .cover-wrap { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg3); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.tile:active img { transform: scale(.96); }
.tile .t-title { margin-top: 8px; font-weight: 600; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .t-artist { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile.playing .t-title { color: var(--accent); }
.tile .more {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff;
  opacity: 0; transition: opacity .2s;
}
.tile .more svg { width: 18px; height: 18px; }
.tile:hover .more { opacity: 1; }
@media (hover: none) { .tile .more { opacity: 1; } }
.tile .eq {
  position: absolute; left: 8px; bottom: 8px; display: none; gap: 2px; align-items: flex-end;
  height: 16px; padding: 4px; border-radius: 6px; background: rgba(0,0,0,.6);
}
.tile.playing .eq { display: flex; }
.eq i { display: block; width: 3px; background: var(--accent); border-radius: 1px; height: 30%; }
.tile.playing.active .eq i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .2s !important; }
.eq i:nth-child(3) { animation-delay: .4s !important; }
@keyframes eq { 0%,100% { height: 25%; } 50% { height: 100%; } }

.empty { text-align: center; margin-top: 22vh; color: var(--muted); padding: 0 24px; }
.empty-title { font-size: 20px; color: var(--text); font-weight: 600; margin-bottom: 6px; }

/* ---------- мини-плеер ---------- */
.mini {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px; border-radius: 14px;
  background: rgba(36, 36, 45, .92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,.5); cursor: pointer; overflow: hidden;
  max-width: 720px; margin: 0 auto;
}
.mini img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--bg3); flex: none; }
.mini-text { flex: 1; min-width: 0; font-size: 14px; }
.mini-text div:first-child { font-weight: 600; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,255,255,.08); }
.mini-progress div { height: 100%; width: 0; background: var(--accent); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; flex: none; color: var(--text); }
.icon-btn:active { background: rgba(255,255,255,.08); }
.icon-btn.big svg { width: 32px; height: 32px; }
.icon-btn.on { color: var(--accent); }
.icon-btn .badge { position: absolute; font-size: 9px; font-weight: 700; margin-top: 1px; }

/* ---------- полный плеер ---------- */
.full {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.full.open { transform: none; }
.full-bg {
  position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(50px) saturate(1.4) brightness(.45); transform: scale(1.2);
}
.full-inner {
  position: relative; height: 100%; display: flex; flex-direction: column; align-items: center;
  padding: calc(10px + var(--safe-t)) 24px calc(28px + var(--safe-b));
  max-width: 480px; margin: 0 auto;
}
.full-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.full-cover {
  width: min(82vw, 380px, 42vh); aspect-ratio: 1; object-fit: cover; border-radius: 14px;
  margin: auto 0 0; box-shadow: 0 20px 60px rgba(0,0,0,.6); background: var(--bg3);
}
.full-meta { width: 100%; margin-top: 28px; }
.full-title { font-size: 21px; font-weight: 700; line-height: 1.25; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.seek { width: 100%; margin-top: 22px; }
.times { display: flex; justify-content: space-between; margin-top: 6px; font-variant-numeric: tabular-nums; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0;
  --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--p), rgba(255,255,255,.2) var(--p));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px;
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.controls { width: 100%; display: flex; align-items: center; justify-content: space-between; margin: 18px 0 auto; }
.play-btn {
  width: 72px; height: 72px; border-radius: 50%; background: #fff; color: #111;
  display: grid; place-items: center;
}
.play-btn svg { width: 34px; height: 34px; }
.play-btn:active { transform: scale(.94); }
.loading .spin-target { display: none; }
.spinner { width: 26px; height: 26px; border: 3px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- окна ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) { .modal { align-items: center; } }
.sheet {
  width: 100%; max-width: 440px; background: var(--bg2); border-radius: 18px 18px 0 0;
  padding: 22px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 600px) { .sheet { border-radius: 18px; } }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet input {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--bg3);
  background: var(--bg); color: var(--text); font-size: 16px; outline: none;
}
.sheet input:focus { border-color: var(--accent); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.primary, .secondary { padding: 13px; border-radius: 12px; font-weight: 600; }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.primary:disabled { opacity: .6; }
.secondary { background: var(--bg3); }
.link { color: var(--muted); padding: 6px; }
.msg { margin: 0; min-height: 1.2em; font-size: 14px; color: var(--muted); }
.msg.err { color: #ff7d7d; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #fff; color: #111; padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 500;
  transition: all .25s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
