/* Wavefy — тёмная тема в духе Spotify, акцент оранжевый */
:root {
  --bg: #121212;
  --surface: #181818;
  --card: #242424;
  --hover: #2e2e2e;
  --text: #ffffff;
  --dim: #b3b3b3;
  --accent: #ff7a00;
  --accent-2: #ff9a33;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(180deg, #20140a 0%, var(--bg) 300px);
}

.hidden { display: none !important; }

/* ── шапка ── */
#topbar { padding: 14px 16px 4px; }
#topbar-row { display: flex; align-items: center; gap: 10px; }
#back-btn {
  background: none; border: none; color: var(--text);
  font-size: 34px; line-height: 1; padding: 0 6px 0 0; cursor: pointer;
}
#topbar-title { font-size: 13px; color: var(--dim); }
#topbar-sub { font-size: 24px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── контент ── */
#content { flex: 1; overflow-y: auto; padding-bottom: 10px; }
.screen { min-height: 100%; }

/* ── полки с карточками ── */
.shelf { margin: 20px 0 26px; }
.shelf-title { font-size: 20px; font-weight: 800; padding: 0 16px; margin-bottom: 12px; }
.shelf-scroll {
  display: flex; gap: 12px; overflow-x: auto;
  padding: 0 16px; scrollbar-width: none;
}
.shelf-scroll::-webkit-scrollbar { display: none; }
.card {
  position: relative;
  width: 140px; flex: 0 0 140px; background: var(--card);
  border-radius: var(--radius); padding: 12px; cursor: pointer;
  transition: background 0.15s; border: none; text-align: left;
}
.card-add {
  position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,0.65);
  color: #fff; width: 26px; height: 26px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .1s;
}
.card-add:active { transform: scale(1.15); color: var(--accent-2); }
.card:active { background: var(--hover); }
.card img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; margin-bottom: 10px; background: #333; display: block;
}
.card .name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 12px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── строки треков ── */
.track-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; cursor: pointer;
}
.track-row:active { background: var(--hover); }
.track-row .idx { width: 20px; color: var(--dim); font-size: 14px; text-align: center; flex: 0 0 20px; }
.track-row img { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; background: #333; flex: 0 0 46px; }
.track-row .meta { flex: 1; min-width: 0; }
.track-row .title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row .artist { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row .dur { font-size: 13px; color: var(--dim); flex: 0 0 auto; }

/* ── иконки ── */
.ico { width: 22px; height: 22px; display: block; }
.ico.big { width: 26px; height: 26px; }
.ico.xs { width: 13px; height: 13px; }
.idx-ico { width: 16px; height: 16px; margin: 0 auto; }
.dl-spin {
  width: 16px; height: 16px; border-radius: 50%; display: block;
  border: 2px solid rgba(255,122,0,.3); border-top-color: var(--accent);
  animation: spin360 .8s linear infinite;
}
@keyframes spin360 { to { transform: rotate(360deg); } }

/* ── кнопки-иконки в строках треков ── */
.track-row .add, .track-row .rm, .track-row .dl {
  background: none; border: none; color: var(--dim);
  padding: 8px; cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center;
  transition: color .15s, transform .1s;
}
.track-row .add:active { color: var(--accent); transform: scale(1.2); }
.track-row .dl:active { color: var(--accent); transform: scale(1.2); }
.track-row .rm:active { color: #ff4d4d; transform: scale(1.2); }
.track-row.playing .idx, .track-row.playing .title { color: var(--accent); }

/* ── поиск ── */
#search-input {
  width: calc(100% - 32px); margin: 8px 16px 4px; padding: 13px 16px;
  border: none; border-radius: var(--radius); background: var(--card);
  color: var(--text); font-size: 15px; outline: none;
}
#search-input::placeholder { color: var(--dim); }

/* ── коллекция (плейлист/альбом) ── */
#collection-header {
  display: flex; align-items: flex-end; gap: 16px;
  padding: 16px 16px 22px;
  background: linear-gradient(180deg, rgba(255,122,0,0.85) 0%, rgba(255,122,0,0.35) 55%, transparent 100%);
}
#collection-header img { width: 140px; height: 140px; border-radius: 10px; object-fit: cover; box-shadow: 0 8px 24px rgba(0,0,0,0.5); background: #333; }
#collection-header .info { flex: 1; min-width: 0; }
#collection-header .kind { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
#collection-header .title { font-size: 24px; font-weight: 900; margin-top: 6px; }

/* ── пустое состояние ── */
.empty { color: var(--dim); font-size: 15px; text-align: center; padding: 48px 32px; }
.empty.small { padding: 16px 32px 0; font-size: 14px; }

/* ── библиотека ── */
#create-pl {
  background: var(--accent); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; transition: transform .1s;
}
#create-pl:active { transform: scale(0.9); }
#create-pl .ico { width: 15px; height: 15px; }
.playlist-card { position: relative; }
.playlist-card .count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,0.65); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.playlist-card .remove-pl {
  position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,0.65); border: none;
  color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── нижний лист «добавить в плейлист» ── */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
#sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  background: var(--surface); border-radius: 16px 16px 0 0; padding: 18px 16px 24px;
  max-height: 70vh; display: flex; flex-direction: column;
  animation: sheetup .25s ease;
}
#sheet-title { font-size: 17px; font-weight: 800; margin-bottom: 12px; }
#sheet-list { overflow-y: auto; flex: 1; }
.sheet-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 4px; cursor: pointer; border-bottom: 1px solid #262626;
  font-size: 15px;
}
.sheet-item:active { color: var(--accent); }
#sheet-new { display: flex; gap: 8px; margin-top: 12px; }
#sheet-name {
  flex: 1; padding: 11px 14px; border: none; border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 14px; outline: none;
}
#sheet-create {
  background: var(--accent); border: none; color: #fff; border-radius: 10px;
  padding: 0 16px; font-weight: 700; cursor: pointer;
}

/* ── мини-плеер ── */
#player-bar {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 12px 12px 0 0; border-top: 1px solid #2c2c2c;
  padding: 0;
}
/* ── перемотка ── */
#player-seek-row { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; }
#t-cur, #t-total { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 34px; }
#t-total { text-align: right; }
#player-seek {
  -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 2px; outline: none;
  background: linear-gradient(to right, var(--accent) calc(var(--val, 0) * 1%), #3a3a3a 0);
}
#player-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: none; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
#player-seek::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff; border: none;
}
#player-main { display: flex; align-items: center; gap: 12px; padding: 8px 16px 10px; }
#player-cover img { width: 44px; height: 44px; border-radius: 6px; display: block; background: #333; }
#player-meta { flex: 1; min-width: 0; }
#player-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-artist { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ── контролы плеера: prev / play (кольцо загрузки) / next ── */
#player-controls { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.pc-btn {
  background: none; border: none; color: var(--dim); cursor: pointer;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  transition: color .15s, transform .1s;
}
.pc-btn:active { color: var(--text); transform: scale(0.9); }
.pc-btn .ico { width: 26px; height: 26px; }

#play-wrap { position: relative; width: 52px; height: 52px; flex: 0 0 52px; }
#play-ring {
  position: absolute; inset: -2px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), rgba(255,255,255,.10) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px));
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
#play-ring.on { opacity: 1; }
#play-ring.spin {
  /* загрузка: яркая серая дуга крутится вокруг Play */
  background: conic-gradient(#cfcfcf 0 35%, rgba(255,255,255,.10) 35%);
  animation: spin360 .8s linear infinite;
}
#player-btn {
  position: absolute; inset: 3px;
  border-radius: 50%; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
#player-btn:active { background: var(--accent-2); transform: scale(0.93); }

/* ── нижняя навигация ── */
#bottom-nav { display: flex; background: var(--surface); border-top: 1px solid #222; }
.nav-btn {
  flex: 1; background: none; border: none; color: var(--dim);
  padding: 10px 0 14px; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.nav-btn .ico { width: 22px; height: 22px; }
.nav-btn.active { color: var(--text); }
.nav-btn.active .ico { color: var(--accent); }

/* ── тост ── */
#toast {
  position: fixed; bottom: 132px; left: 50%; transform: translateX(-50%);
  background: #fff; color: #000; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; font-weight: 600; z-index: 10; max-width: 85vw; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: fadein .2s ease;
}

/* ── анимации ── */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetup { from { transform: translateY(40%); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
#player-bar { animation: sheetup .25s ease; }
.track-row.playing .title { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* ── индикаторы офлайн-кеша ── */
.cflag {
  display: none; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 10px; flex: none; align-self: center;
}
.cflag.on { display: inline-block; }
#cache-info { color: var(--dim); font-size: 12px; margin-top: 8px; }
