:root {
  --bg: #121212;
  --bg-elev: #181818;
  --bg-elev2: #242424;
  --text: #ffffff;
  --text-dim: #b3b3b3;
  --accent: #1db954;
  /* акцентный цвет альбома/трека, задаётся из JS */
  --album-accent: #333;
  --track-accent: #333;
  --lyric-bg: #333;
  --lyric-color: #ddd;
  --lyric-scale: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

.hidden { display: none !important; }

.view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: 110px; /* место под плеер */
}

/* ---------- Topbar ---------- */
.topbar { margin-bottom: 24px; }
.logo { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }

/* ---------- Albums grid ---------- */
.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}
.album-card {
  background: var(--bg-elev);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s;
  will-change: background;
}
.album-card:hover, .album-card:focus { background: var(--bg-elev2); outline: none; }
.album-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #333;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.album-card .ac-name { margin-top: 12px; font-weight: 700; font-size: 15px; }
.album-card .ac-artist { margin-top: 4px; color: var(--text-dim); font-size: 13px; }

.ac-name, .ac-artist, .pc-title, .pc-artist, .pn-title, .pn-artist {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Album header ---------- */
.album-header {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 40px 24px 24px;
  margin: -24px -24px 24px;
  background: linear-gradient(180deg, var(--album-accent) 0%, transparent 100%);
  border-radius: 0 0 8px 8px;
}
.album-header img {
  width: 200px; height: 200px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  background: #333;
}
.ah-info { flex: 1; min-width: 0; }
.ah-label { font-size: 12px; text-transform: uppercase; opacity: 0.8; }
.ah-title { font-size: 44px; font-weight: 900; line-height: 1.05; margin: 8px 0; }
.ah-sub { color: var(--text-dim); font-size: 14px; }
.ah-actions { display: flex; align-items: center; gap: 20px; margin-top: 20px; }
.play-big {
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--accent); color: #000;
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.play-big:hover { transform: scale(1.06); }
.mode-toggle {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; padding: 8px;
}
.mode-toggle.active { color: var(--accent); }

.back-btn {
  position: sticky; top: 0; z-index: 5;
  background: rgba(0,0,0,0.4); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 24px; cursor: pointer; backdrop-filter: blur(6px);
}

/* ---------- Tracks list ---------- */
.tracks-list { display: flex; flex-direction: column; }
.track-row {
  display: grid;
  grid-template-columns: 32px 48px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.track-row:hover { background: var(--bg-elev2); }
.track-row.playing .tr-name { color: var(--accent); }
.tr-idx { color: var(--text-dim); text-align: right; font-size: 14px; }
.tr-poster { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background:#333; }
.tr-main { min-width: 0; }
.tr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-artist { color: var(--text-dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-dur { color: var(--text-dim); font-size: 14px; }

.sentinel { height: 1px; }

/* ---------- Karaoke ---------- */
.karaoke {
  position: fixed; inset: 0; z-index: 40;
  background: var(--lyric-bg);
  display: flex; flex-direction: column;
  transition: background 0.6s ease;
}
.karaoke-close {
  position: absolute; top: 16px; left: 16px; z-index: 2;
  background: rgba(0,0,0,0.2); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 26px; cursor: pointer;
}
.karaoke-scale {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  display: flex; gap: 8px;
}
.karaoke-scale button {
  background: rgba(0,0,0,0.2); border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 15px; cursor: pointer;
}
.lyrics-container {
  flex: 1; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 0 24px 120px;
  mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 80%, transparent 100%);
}
.lyrics-scroll {
  width: 100%; max-width: 900px;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.lyric-line {
  font-size: calc(28px * var(--lyric-scale));
  font-weight: 800;
  line-height: 1.35;
  padding: 6px 0;
  color: var(--lyric-color);
  transition: opacity 0.3s, font-size 0.3s, color 0.3s;
}
.lyric-line.past { opacity: 0.2; }        /* прозрачнее */
.lyric-line.future { opacity: 0.1; }      /* будущий текст ещё тусклее */
.lyric-line.active {
  opacity: 1;
  font-size: calc(38px * var(--lyric-scale));
  color: #fff;
}

/* ---------- Player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg-elev);
  border-top: 1px solid #000;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  height: 90px;
}
.player-current, .player-next { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pc-poster, .pn-poster { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background:#333; }
.pc-meta, .pn-meta { min-width: 0; }
.pc-title { font-weight: 600; font-size: 14px; }
.pc-artist, .pn-artist { color: var(--text-dim); font-size: 12px; }

.player-center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.player-controls { display: flex; align-items: center; gap: 20px; }
.player-controls button {
  background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer;
}
.btn-play {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff !important; color: #000 !important;
  display: flex; align-items: center; justify-content: center;
}
.btn-mode.active { color: var(--accent) !important; }
.player-seek { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 600px; }
.time { color: var(--text-dim); font-size: 12px; width: 40px; text-align: center; }
#seek {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: #4d4d4d; cursor: pointer;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  border-radius: 50%; background: #fff;
}

/* Следующий трек: визуально отделяем */
.player-next {
  justify-content: flex-end;
  opacity: 0.75;
  border-left: 1px solid #333;
  padding-left: 16px;
}
.player-next .pn-body { display: flex; align-items: center; gap: 12px; text-align: right; }
.pn-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); margin-right: 8px; white-space: nowrap;
}

/* ---------- Адаптив (телефон) ---------- */
@media (max-width: 720px) {
  .player { grid-template-columns: 1fr auto; height: auto; padding: 10px; }
  .player-next { display: none; }         /* на телефоне прячем "далее" */
  .player-seek { display: none; }         /* компактный плеер */
  .album-header { flex-direction: column; align-items: flex-start; }
  .album-header img { width: 140px; height: 140px; }
  .ah-title { font-size: 30px; }
  .lyric-line { font-size: calc(22px * var(--lyric-scale)); }
  .lyric-line.active { font-size: calc(28px * var(--lyric-scale)); }
}

/* ---------- ТВ / большие экраны ---------- */
@media (min-width: 1600px) {
  .lyrics-scroll { max-width: 1100px; }
}
