/* ---------- токены ---------- */
:root {
  --ya: #ffcc00;
  --sc: #ff5a1f;
  --vk: #2f80ff;
  --fav: #ff4f7b;

  --bg: #111a2e;
  --surface: #192440;
  --raised: #223052;
  --tx: #eef1fa;
  --mut: #93a0bf;
  --on-tx: #111a2e;
  --scrim: rgba(8, 12, 24, 0.55);
  --glow-op: 0.5;
  --tile-l: 30%;
  --tile-fg-l: 86%;

  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;

  --tabs-h: 62px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
  --bg: #f2f4fa;
  --surface: #ffffff;
  --raised: #e4e9f4;
  --tx: #141a2e;
  --mut: #626c8a;
  --on-tx: #ffffff;
  --scrim: rgba(8, 12, 24, 0.5);
  --glow-op: 0.38;
  --tile-l: 82%;
  --tile-fg-l: 26%;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f2f4fa;
    --surface: #ffffff;
    --raised: #e4e9f4;
    --tx: #141a2e;
    --mut: #626c8a;
    --on-tx: #ffffff;
    --glow-op: 0.38;
    --tile-l: 82%;
    --tile-fg-l: 26%;
  }
}

/* ---------- основа ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--tx);
  font: 400 15px/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2, p { margin: 0; }

:focus-visible { outline: 2px solid var(--vk); outline-offset: 2px; }

#app { height: 100dvh; display: flex; flex-direction: column; }

#view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px calc(var(--tabs-h) + var(--safe-b) + 24px);
  outline: none;
  scrollbar-width: none;
}
#view::-webkit-scrollbar { display: none; }
body.has-mini #view { padding-bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 32px); }

.i { width: 24px; height: 24px; display: block; flex: none; }
.flip { transform: scaleX(-1); }

/* ---------- эквалайзер из трёх цветов: знак Triplay ---------- */
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; width: 18px; }
.eq i {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  transform-origin: bottom;
  animation: eq 0.9s ease-in-out infinite;
  animation-play-state: paused;
}
.eq i:nth-child(1) { background: var(--ya); animation-delay: -0.35s; }
.eq i:nth-child(2) { background: var(--sc); animation-duration: 0.72s; animation-delay: -0.1s; }
.eq i:nth-child(3) { background: var(--vk); animation-duration: 1.05s; animation-delay: -0.6s; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}
.eq.live i { animation-play-state: running; }
.eq.xl { height: 44px; width: 44px; gap: 6px; }
.eq.xl i { border-radius: 4px; }

/* ---------- заголовки разделов ---------- */
.head { margin-bottom: 14px; }
.head h1 {
  font: 600 22px/1.15 var(--font-display);
  letter-spacing: -0.01em;
}
.head .sub { color: var(--mut); margin-top: 6px; }
.head-back { display: flex; align-items: center; gap: 4px; margin: -6px 0 10px -8px; color: var(--mut); font-weight: 500; }
.head-back .ico { width: 36px; height: 36px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--tx);
  font-weight: 600; font-size: 14px;
  transition: transform 0.12s;
}
.btn:active { transform: scale(0.97); }
.btn .i { width: 18px; height: 18px; }
.btn.primary { background: var(--tx); color: var(--on-tx); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.ico {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: var(--tx);
  flex: none;
}
.ico:active { background: var(--raised); }
.ico.ghost { visibility: hidden; }

.bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.filter {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 8px;
  color: var(--mut);
}
.filter .i { width: 20px; height: 20px; }
.filter input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; outline: 0;
  color: var(--tx);
  -webkit-appearance: none; appearance: none;
}
.filter input::placeholder { color: var(--mut); }
.filter:focus-within { box-shadow: 0 0 0 2px var(--vk); }
.filter input::-webkit-search-cancel-button { display: none; }

/* ---------- строки треков ---------- */
.list { display: flex; flex-direction: column; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 62px;
  cursor: pointer;
  border-radius: 12px;
}
.row:active { background: var(--surface); }
.row .meta { flex: 1; min-width: 0; }
.meta .t, .meta .a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .t { font-weight: 600; }
.meta .a { color: var(--mut); font-size: 13.5px; margin-top: 1px; }
.row.now .t { color: var(--tx); }
.row .dur { color: var(--mut); font-size: 13px; font-variant-numeric: tabular-nums; }
.row .ico { width: 40px; height: 40px; margin-right: -6px; }
.row .ico .i { width: 22px; height: 22px; }
.row .ico + .ico { margin-left: 0; }

.heart { color: var(--mut); }
.heart.on { color: var(--fav); }
.heart.on .i { fill: var(--fav); }
.add.done { color: var(--vk); }

/* ---------- обложка ---------- */
.cover {
  --h: 220;
  position: relative;
  width: 48px; height: 48px;
  border-radius: 10px;
  overflow: hidden;
  flex: none;
  display: grid; place-items: center;
  background: hsl(var(--h) 42% var(--tile-l));
  color: hsl(var(--h) 60% var(--tile-fg-l));
  font: 600 18px var(--font-display);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .src {
  position: absolute; right: 4px; bottom: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(8, 12, 24, 0.45);
}
.cover .eqwrap {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--scrim);
}
.cover.sm { width: 44px; height: 44px; border-radius: 9px; }
.cover.lg { border-radius: 22px; width: 100%; height: 100%; font-size: 64px; }
.cover.lg .src { width: 14px; height: 14px; right: 14px; bottom: 14px; }

body.playing .row.now .eq i { animation-play-state: running; }

/* ---------- пустые состояния и сообщения ---------- */
.state {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 36px 0;
  max-width: 34ch;
}
.state.center { align-items: center; text-align: center; margin: 0 auto; padding-top: 80px; }
.state h2 { font: 600 18px/1.25 var(--font-display); letter-spacing: -0.01em; }
.state p { color: var(--mut); }
.state .bar { margin: 4px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px; font-weight: 500;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.off { color: var(--mut); }

/* ---------- импорт ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-weight: 600; }
.field .filter { margin-bottom: 0; }
.import-actions { display: flex; gap: 8px; margin-top: 12px; }
.hint { color: var(--mut); font-size: 13.5px; margin-top: 14px; max-width: 46ch; }

.result {
  margin-top: 22px; padding: 18px;
  background: var(--surface);
  border-radius: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.result h2 { font: 600 17px/1.25 var(--font-display); letter-spacing: -0.01em; }
.result p { color: var(--mut); }
.result .btn { align-self: flex-start; margin-top: 4px; }
.result.err h2 { color: var(--fav); }

.fail summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.fail ol { margin: 6px 0 0; padding-left: 22px; color: var(--mut); font-size: 13.5px; }
.fail li { margin: 4px 0; overflow-wrap: anywhere; }

/* ---------- новинки ---------- */
.rel-row .meta { flex: 1; }
.rel-row .chev { color: var(--mut); width: 20px; height: 20px; }

/* ---------- нижняя панель ---------- */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding-bottom: var(--safe-b);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

#tabs { display: flex; height: var(--tabs-h); padding: 4px 6px 0; }
#tabs button {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px;
  color: var(--mut);
  font-size: 11px; font-weight: 500;
  padding-top: 2px;
}
.tab-i {
  display: grid; place-items: center;
  width: 52px; height: 30px; border-radius: 999px;
  transition: background 0.2s;
}
#tabs .i { width: 22px; height: 22px; }
#tabs button[aria-current="page"] { color: var(--tx); }
#tabs button[aria-current="page"] .tab-i { background: var(--raised); }

/* ---------- мини-плеер ---------- */
#mini {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  height: var(--mini-h);
  margin: 8px 8px 0;
  padding: 0 6px 0 10px;
  background: var(--raised);
  border-radius: 18px;
  overflow: hidden;
}
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.mini-progress span { display: block; height: 100%; width: 0; background: var(--tx); opacity: 0.85; }
.mini-open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  height: 100%;
}
.mini-open .meta { display: block; flex: 1; min-width: 0; }

/* кнопки play/pause: переключение иконок и загрузчик */
.pp .i-pause, .pp .eq { display: none; }
body.playing .pp .i-play { display: none; }
body.playing .pp .i-pause { display: block; }
body.loading .pp .i-play, body.loading .pp .i-pause { display: none; }
body.loading .pp .eq { display: inline-flex; }
.pp .eq i { background: currentColor; }

/* ---------- полноэкранный плеер ---------- */
#sheet {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  overflow: hidden;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.34s;
}
#sheet.open {
  transform: none;
  visibility: visible;
  transition: transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}
.glow {
  --h: 220;
  position: absolute; inset: -30%;
  background: hsl(var(--h) 50% 36%) center / cover no-repeat;
  filter: blur(70px) saturate(1.5);
  opacity: var(--glow-op);
  transform: translateZ(0);
}
.sheet-in {
  position: relative; height: 100%;
  display: flex; flex-direction: column;
  padding: 10px 24px calc(18px + var(--safe-b));
  max-width: 520px; margin: 0 auto;
}
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-top .ico { margin: 0 -10px; }
.src-line { display: flex; align-items: center; gap: 8px; color: var(--mut); font-size: 13.5px; font-weight: 500; }
.src-line .dot { width: 9px; height: 9px; border-radius: 50%; }

.big-cover {
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: 14px 0;
}
.big-cover .cover.lg {
  width: min(100%, 100cqh);
  height: auto; aspect-ratio: 1;
  max-height: 100%;
  box-shadow: 0 24px 60px rgba(8, 12, 24, 0.45);
}
.big-cover { container-type: size; }

.np { display: flex; align-items: center; gap: 12px; }
.now-meta { flex: 1; min-width: 0; }
.now-t {
  font-weight: 700; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.now-a { color: var(--mut); font-size: 16px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np .ico { width: 48px; height: 48px; margin-right: -10px; }
.np .ico .i { width: 26px; height: 26px; }

.seek { margin-top: 14px; }
.seek input[type="range"] {
  --p: 0%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer;
}
.seek input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--tx) var(--p), var(--raised) var(--p));
}
.seek input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--raised); }
.seek input[type="range"]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--tx); }
.seek input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--tx); margin-top: -4.5px;
  transition: transform 0.12s;
}
.seek input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--tx); }
.seek input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.4); }
.times { display: flex; justify-content: space-between; color: var(--mut); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }

.ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.ctl .ico .i { width: 24px; height: 24px; }
.ctl .ico.big { width: 56px; height: 56px; }
.ctl .ico.big .i { width: 30px; height: 30px; }
.ctl .ico[aria-pressed="true"] { color: var(--vk); }
.ctl .ico .one { display: none; position: absolute; }
.ctl #btnRepeat { position: relative; }
.ctl #btnRepeat .one { inset: 0; margin: auto; }
.ctl #btnRepeat.is-one .one { display: block; }
.pp-big {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tx); color: var(--on-tx);
  transition: transform 0.12s;
}
.pp-big:active { transform: scale(0.95); }
.pp-big .i { width: 34px; height: 34px; }
.pp-big .eq { height: 26px; width: 26px; }

.lib-toggle { align-self: center; margin-top: 10px; background: var(--surface); }

/* ---------- уведомления ---------- */
#toast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  background: var(--tx); color: var(--on-tx);
  border-radius: 14px;
  font-weight: 500; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
body.has-mini #toast { bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 26px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.sheet-open #toast { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 64px); transform: translate(-50%, -12px); }
body.sheet-open #toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .eq i { animation: none; transform: scaleY(0.75); }
  .eq i:nth-child(2) { transform: scaleY(1); }
  .eq i:nth-child(3) { transform: scaleY(0.5); }
  #sheet, #sheet.open, #toast, .btn, .pp-big { transition: none; }
}

@media (max-height: 640px) {
  .now-t { font-size: 19px; }
  .pp-big { width: 64px; height: 64px; }
  .big-cover { padding: 8px 0; }
}
