:root {
  --bg: #0e1116;
  --card: #161b22;
  --card2: #1c2330;
  --accent: #7ee787;
  --accent-dim: rgba(126, 231, 135, 0.14);
  --accent-line: rgba(126, 231, 135, 0.35);
  --text: #e6edf3;
  --muted: #8b949e;
  --border: #2a3342;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overflow-x: clip;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  position: relative;
  z-index: 1;
}

/* живой фон: полупрозрачные волны в цвете палитры */
.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.bg i {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.85;
  background-color: color-mix(in srgb, var(--accent) 22%, transparent);
  transition: background-color 1.2s ease;
  animation: drift 18s ease-in-out infinite alternate;
}
.bg i:nth-child(1) { width: 60vmax; height: 60vmax; left: -16vmax; top: -18vmax; opacity: 0.7; }
.bg i:nth-child(2) {
  width: 52vmax; height: 52vmax; right: -14vmax; bottom: -16vmax;
  animation-duration: 23s; animation-delay: -8s; opacity: 0.55;
}
.bg i:nth-child(3) {
  width: 40vmax; height: 40vmax; left: 50%; top: 45%;
  animation-duration: 15s; animation-delay: -4s; opacity: 0.42;
}
.bg i:nth-child(4) {
  width: 34vmax; height: 34vmax; left: 30%; bottom: -14vmax;
  animation-duration: 20s; animation-delay: -11s; opacity: 0.38;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vmax, -3vmax) scale(1.12); }
  to { transform: translate(-3vmax, 4vmax) scale(0.94); }
}

.player {
  width: 100%;
  max-width: 360px;
  max-height: 100dvh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.cover-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-bottom: 0;
  transition: grid-template-rows 0.45s ease, opacity 0.35s ease, margin-bottom 0.45s ease;
}
.cover-wrap.show {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-bottom: 10px;
}
.cover-wrap-inner { overflow: hidden; min-height: 0; }
.cover-wrap:not(.show) .cover { visibility: hidden; }
.cover {
  width: 160px;
  height: 160px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.cover.loaded { opacity: 1; }

.title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.artist {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.time-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin: 12px 0 4px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #2a3342;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

.controls {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: var(--accent);
  color: #0e1116;
  border-color: var(--accent);
  width: 52px;
  height: 52px;
  transition: background-color 0.6s ease, border-color 0.6s ease, transform 0.12s;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  color: var(--muted);
}
.vol { flex: 1; }
.vol-val { font-size: 11px; min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn.muted { color: #f85149; }

.playlist {
  list-style: none;
  margin: 14px 0 0;
  padding: 2px;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  max-height: 26dvh;
  scrollbar-width: none; /* скроллбар скрыт, колёсико/тач работают */
}
.playlist::-webkit-scrollbar { display: none; }

.track {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 15px 16px;
  min-height: 64px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  line-height: 1.55;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.track:hover { background: var(--card2); }
.track.active { background: var(--accent-dim); border-color: var(--accent-line); }
.track .meta { flex: 1; min-width: 0; overflow: hidden; }
.track .t { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .a { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .d { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* плавная смена палитры от обложки (точка пинга всегда зелёная) */
.sound-btn { transition: background-color 0.6s ease; }
.track.active { transition: background-color 0.6s ease, border-color 0.6s ease; }

.conn {
  margin-top: 8px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ping-tip {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.35s ease, max-width 0.35s ease;
}
.conn:hover .ping-tip { opacity: 1; max-width: 140px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f0a35e;
  display: inline-block;
}
.dot.on {
  background: #7ee787;
  box-shadow: 0 0 8px #7ee787;
  animation: ping 1.6s ease-in-out infinite;
}
.dot.off { background: #f85149; }
@keyframes ping {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 #7ee787; }
  50% { opacity: 0.6; transform: scale(0.85); box-shadow: 0 0 0 5px transparent; }
}

.sound-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 17, 22, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fadein 0.25s ease;
}
.sound-overlay[hidden] { display: none; }
.sound-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px;
  text-align: center;
  max-width: 300px;
}
.sound-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sound-btn {
  margin-top: 14px;
  background: var(--accent);
  color: #0e1116;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 11px 28px;
  cursor: pointer;
}
.sound-btn:hover { filter: brightness(1.08); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
