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

:root {
  --bg:      #0f0f0f;
  --card:    #181818;
  --hover:   #282828;
  --border:  #333;
  --green:   #1DB954;
  --green2:  #1ed760;
  --text:    #fff;
  --sub:     #b3b3b3;
  --muted:   #535353;
  --radius:  12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  padding-bottom: 80px;
}
body.has-player { padding-bottom: 150px; }

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-bar {
  display: flex;
  gap: 8px;
}
.search-bar input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 16px;
  outline: none;
  -webkit-appearance: none;
}
.search-bar input::placeholder { color: var(--muted); }
.search-bar input:focus { border-color: var(--green); }
.btn-search {
  background: var(--green);
  border: none;
  border-radius: 24px;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-search:active { background: var(--green2); }

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: var(--card);
  border: none;
  border-radius: 20px;
  color: var(--sub);
  font-size: 13px;
  padding: 6px 16px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  background: var(--text);
  color: #000;
  font-weight: 600;
}

main { padding: 12px 16px; padding-bottom: 20px; }

.quality-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.quality-bar label { color: var(--sub); font-size: 13px; }
.quality-bar select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 10px;
  outline: none;
}

.track {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.track:active { background: var(--hover); }

.cover {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--hover);
  flex-shrink: 0;
}
.cover-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--hover);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 20px;
}
.track-info { flex: 1; min-width: 0; }
.track-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-sub {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.track-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.badge {
  font-size: 10px;
  color: var(--green);
  background: rgba(29,185,84,.15);
  border-radius: 4px;
  padding: 1px 5px;
}
.dur { font-size: 11px; color: var(--muted); }

.btn-dl {
  background: var(--green);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, transform 0.2s;
}
.btn-dl:active { background: var(--green2); transform: scale(0.95); }
.btn-dl.loading {
  background: var(--hover);
  color: #fff;
  cursor: default;
  pointer-events: none;
}
.btn-dl.done {
  background: #1a3a2a;
  color: var(--green);
}
.btn-dl .perc {
  font-size: 10px;
  font-weight: 700;
}

.spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-play {
  background: var(--green);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  -webkit-tap-highlight-color: transparent;
}
.btn-play:active { background: var(--green2); }
.btn-play.playing { background: #ff9900; }

.btn-vlc-android {
  background: #3ddc84;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  -webkit-tap-highlight-color: transparent;
}
.btn-vlc-android:active { background: #2bb673; }

.btn-vlc-windows {
  background: #0078d4;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.btn-vlc-windows:active { background: #005a9e; }

.btn-vlc-android-big, .btn-vlc-windows-big {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  margin-top: 10px;
  margin-left: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn-vlc-android-big {
  background: #3ddc84;
  color: #000;
}
.btn-vlc-android-big:active { background: #2bb673; }
.btn-vlc-windows-big {
  background: #0078d4;
  color: #fff;
}
.btn-vlc-windows-big:active { background: #005a9e; }

.btn-dl-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green);
  border: none;
  border-radius: 20px;
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  margin-top: 10px;
  -webkit-tap-highlight-color: transparent;
}

.btn-download-m3u {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ff9900;
  border: none;
  border-radius: 20px;
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  margin-top: 10px;
  margin-left: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn-download-m3u:active { background: #e68a00; }
.btn-download-m3u-small {
  background: #ff9900;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  -webkit-tap-highlight-color: transparent;
}
.btn-download-m3u-small:active { background: #e68a00; }

.albums-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 480px) {
  .albums-grid { grid-template-columns: repeat(3, 1fr); }
}

.album-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.album-card:active { opacity: .8; }
.album-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--hover);
}
.album-card-info { padding: 8px 10px 10px; }
.album-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.album-artist {
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.album-header {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.album-header img {
  width: 110px;
  height: 110px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--hover);
}
.album-header-info h2 { font-size: 17px; margin-bottom: 4px; }
.album-header-info p  { font-size: 13px; color: var(--sub); }
.album-header-info .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}
.spinner {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 28px;
  animation: spin 1s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--sub);
  font-size: 14px;
  padding: 4px 0 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:active { color: var(--text); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 20px;
  z-index: 999;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.track-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Плеер */
#player {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 1000;
  align-items: center;
  gap: 12px;
}
#player.visible { display: flex; }
#player-cover {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--hover);
}
#player-info { flex: 1; min-width: 0; }
#player-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#player-artist {
  font-size: 12px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#player-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
#player-current, #player-duration {
  font-size: 11px;
  color: var(--muted);
  min-width: 36px;
}
#player-progress {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  accent-color: var(--green);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
#player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
}
#player-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
#player-controls button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  -webkit-tap-highlight-color: transparent;
}
#player-controls button:active { opacity: 0.6; }
#player-play {
  background: var(--green);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#player-play:active { background: var(--green2); }
#player-close {
  color: var(--muted);
  font-size: 18px;
}
#player-close:active { color: var(--text); }