* { box-sizing: border-box; }

:root {
  --bg: #07080a;
  --ink: #f2f3f6;
  --muted: #8c919c;
  --faint: #6c717c;
  --line: rgba(255, 255, 255, .09);
  --field: rgba(255, 255, 255, .05);
  --danger: #ff9a9a;
  --ease: cubic-bezier(.22, .8, .24, 1);
  color-scheme: dark;
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(55% 42% at 50% -6%, rgba(125, 132, 255, .14), transparent 70%),
    radial-gradient(45% 45% at 96% 104%, rgba(255, 110, 160, .07), transparent 70%);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: auto;
}

.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.brand__mark {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #08090b;
  background: linear-gradient(160deg, #ffffff, #c6cad4);
  box-shadow: 0 10px 30px -10px rgba(255, 255, 255, .45), inset 0 0 0 1px rgba(255, 255, 255, .7);
}

.brand__mark svg {
  width: 18px;
  height: 18px;
  margin-left: 2px;
  fill: currentColor;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.03em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .95);
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .95);
}

/* ---------- search ---------- */

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 18px;
  background: rgba(12, 13, 18, .72);
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.search:focus-within {
  border-color: rgba(255, 255, 255, .26);
  background: rgba(14, 15, 20, .86);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .05);
}

.search__icon {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: stroke .2s;
}

.search:focus-within .search__icon { stroke: var(--ink); }

.search input {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  background: none;
  outline: 0;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
}

.search input::placeholder { color: var(--faint); }

.search__submit {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: var(--ink);
  color: #08090b;
  cursor: pointer;
  transition: transform .18s var(--ease), background .2s;
}

.search__submit svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search__submit:hover { transform: scale(1.05); }
.search__submit:active { transform: scale(.96); }

.search.is-bad {
  border-color: rgba(255, 110, 110, .45);
  animation: shake .4s var(--ease);
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.note {
  margin: 11px 0 0;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .95);
}

.note strong { color: #a4a9b3; font-weight: 500; }

/* ---------- card ---------- */

.card {
  position: relative;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  align-items: start;
  column-gap: 16px;
  margin-top: 26px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(14, 15, 21, .78), rgba(9, 10, 15, .7));
  box-shadow: 0 34px 70px -28px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .07);
  backdrop-filter: blur(24px) saturate(1.08);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .35s var(--ease), transform .45s var(--ease);
}

.card.is-in { opacity: 1; transform: none; }
.card[hidden] { display: none; }

/* цветной ореол из обложки */
.card::before {
  content: "";
  position: absolute;
  inset: -8%;
  z-index: -1;
  border-radius: 38%;
  background-image: var(--art, none);
  background-size: cover;
  background-position: center;
  filter: blur(50px) saturate(1.7);
  opacity: calc(.08 + var(--level, 0) * .5 + var(--beat, 0) * .16);
  transform: scale(.94);
  pointer-events: none;
  transition: opacity .2s linear;
}

.card.is-playing::before { animation: ambient 11s ease-in-out infinite alternate; }

@keyframes ambient {
  from { transform: scale(.94); }
  to { transform: scale(1.07); }
}

/* ---------- cover / audio player ---------- */

.cover {
  position: relative;
  display: block;
  grid-column: 1;
  grid-row: 1 / span 3;
  align-self: center;
  width: 168px;
  height: 168px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 0%, rgba(125, 132, 255, .22), transparent 60%),
    linear-gradient(160deg, #1a1c23, #0d0e12);
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  transform: scale(calc(1 + var(--beat, 0) * .045));
  box-shadow:
    0 0 34px rgba(255, 255, 255, .06),
    0 0 calc(var(--beat, 0) * 150px) rgba(255, 255, 255, .6);
  will-change: transform;
}

.cover__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .5s var(--ease), transform 1.2s var(--ease);
}

.cover__img.is-ready { opacity: 1; }
.cover.is-playing .cover__img { animation: breathe 26s ease-in-out infinite alternate; }

@media (hover: hover) {
  .cover:hover .cover__img.is-ready { transform: scale(1.025); }
}

.cover::after {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: 2;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .16) 50%, transparent 58%);
  transform: translateX(-65%);
  opacity: 0;
  pointer-events: none;
}

.cover.is-playing::after { animation: sweep 1.3s var(--ease) 1; }

@keyframes breathe {
  from { transform: scale(1); }
  to { transform: scale(1.055); }
}

@keyframes sweep {
  0% { transform: translateX(-65%); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateX(65%); opacity: 0; }
}

.cover__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
}

@media (hover: hover) {
  .cover:hover .cover__overlay { opacity: 1; }
}

.cover:focus-visible .cover__overlay { opacity: 1; }

.cover__play {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: #08090b;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  transition: transform .2s var(--ease);
}

.cover:hover .cover__play { transform: scale(1.05); }

.cover__play svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.cover__play .i-play { margin-left: 2px; }
.cover__play .i-pause { display: none; }
.cover.is-playing .cover__play .i-play { display: none; }
.cover.is-playing .cover__play .i-pause { display: block; }

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  pointer-events: none;
}

.spinner[hidden] { display: none; }

@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- meta ---------- */

.meta {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 2px 0 0;
}

.meta__text {
  flex: 1;
  min-width: 0;
}

.meta__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta__source {
  display: flex;
  align-items: center;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  min-width: 0;
}

.meta__source > #source {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  margin-left: 7px;
  flex: none;
  color: var(--ink);
  opacity: .9;
}

.eq i {
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
  transform: scaleY(.15);
  transform-origin: bottom;
}

.ghost {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, background .18s, border-color .18s;
}

.ghost svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.ghost:hover {
  color: var(--ink);
  background: transparent;
  border-color: transparent;
}

/* ---------- audio source / loading ---------- */

.card audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.card.is-busy .cover__img { opacity: .3; }
.card.is-busy .cover__overlay { display: none; }

/* ---------- ranges ---------- */

.range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  --fill: 0%;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ink) 0 var(--fill), rgba(255, 255, 255, .14) var(--fill) 100%);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .08);
  transition: transform .15s var(--ease);
}

.range:hover::-webkit-slider-thumb { transform: scale(1.15); }
.range:active::-webkit-slider-thumb { transform: scale(1.05); }

.range::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .14);
}

.range::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--ink);
}

.range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.range:disabled {
  opacity: .45;
  cursor: default;
}

.range:disabled::-webkit-slider-thumb { box-shadow: none; }

.range--vol {
  width: 88px;
  flex: none;
}

/* ---------- seek ---------- */

.seek {
  grid-column: 2;
  grid-row: 2;
  padding: 8px 0 0;
}

.seek__time {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: #7d828c;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* ---------- controls ---------- */

.controls {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 2px;
}

.play {
  position: relative;
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #08090b;
  cursor: pointer;
  box-shadow: 0 10px 28px -12px rgba(255, 255, 255, .6);
  transition: transform .18s var(--ease);
}

.play:hover { transform: scale(1.05); }
.play:active { transform: scale(.96); }

.play:disabled {
  opacity: .35;
  cursor: default;
  box-shadow: none;
}

.play:disabled:hover { transform: none; }
.play:disabled::after { opacity: .35; }

.play svg { width: 20px; height: 20px; fill: currentColor; }
.play .i-play { margin-left: 2px; }
.play .i-pause { display: none; }
.play.is-playing .i-play { display: none; }
.play.is-playing .i-pause { display: block; }

/* прогресс-кольцо вокруг play */
.play::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from -90deg,
    rgba(255, 255, 255, .92) calc(var(--progress, 0) * 1%),
    rgba(255, 255, 255, .12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  opacity: .9;
  pointer-events: none;
}

.volume {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  opacity: .82;
  cursor: pointer;
  transition: opacity .18s, background .18s;
}

.icon:hover { opacity: 1; background: rgba(255, 255, 255, .06); }

.icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon .i-muted { display: none; }
.icon.is-muted .i-vol { display: none; }
.icon.is-muted .i-muted { display: block; }

/* ---------- error / footer ---------- */

.error {
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 110, 110, .2);
  border-radius: 12px;
  background: rgba(255, 90, 90, .07);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.error[hidden] { display: none; }

.foot {
  position: relative;
  z-index: 1;
  margin-top: 26px;
  color: #565b65;
  font-size: 11.5px;
  letter-spacing: .02em;
  text-align: center;
}

/* ---------- a11y ---------- */

:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .55);
  outline-offset: 2px;
}

.search input:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .cover { transform: none !important; }
  .card::before { animation: none !important; }
}

/* ---------- mobile ---------- */

@media (max-width: 520px) {
  body { padding: 18px; }
  .brand { margin-bottom: 22px; }
  .brand h1 { font-size: 20px; }
  .search { padding-left: 14px; }
  .search input { font-size: 15px; }

  .card {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
    border-radius: 22px;
  }

  .cover {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
  }

  .cover__play { width: 56px; height: 56px; }

  .meta { grid-column: 1; grid-row: auto; padding: 12px 4px 0; }
  .seek { grid-column: 1; grid-row: auto; padding: 6px 4px 0; }
  .controls { grid-column: 1; grid-row: auto; padding: 6px 4px 4px; }
  .play { width: 46px; height: 46px; }
  .range--vol { width: 76px; }
}
