* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

html { color-scheme: dark; }

body {
  background: #0a0a0f;
  color: #d4d4dc;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px;
  font-size: 14px;
}

body.hidden { visibility: hidden; }

.app {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
  padding-bottom: 100px; /* отступ под плавающий плеер */
}

/* ==================== ШАПКА ==================== */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1a1a24;
}

h1.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #e8e8f0;
}

.brand-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #8b5cf6;
}

h1.brand span { line-height: 1; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #13131c;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid #1f1f2c;
  color: #8a8a99;
}

.user-badge span { color: #a78bfa; font-weight: 500; }
.user-badge .icon { color: #6b6b7a; }

.upload-btn, .logout-btn, .admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid #2a2a3a;
  color: #d4d4dc;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all .15s ease;
}

.upload-btn {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
}

.upload-btn:hover {
  background: #7c3aed;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.logout-btn:hover {
  background: #13131c;
  border-color: #3a3a4a;
  color: #f87171;
}

.admin-btn { color: #a78bfa; }

.admin-btn:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: #8b5cf6;
}

/* ==================== ВКЛАДКИ ==================== */

.tabs-nav {
  display: flex;
  gap: 4px;
  background: #0e0e15;
  border: 1px solid #1a1a24;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 16px;
}

.nav-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: #6b6b7a;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all .15s;
}

.nav-tab:hover { color: #a8a8b4; }

.nav-tab.active {
  background: #8b5cf6;
  color: white;
}

.nav-tab .icon { color: currentColor; }

.nav-tab em {
  font-style: normal;
  opacity: 0.75;
  margin-left: 4px;
  font-weight: 400;
}

/* ==================== ОСНОВНАЯ ОБЛАСТЬ ==================== */

main {
  flex: 1;
  min-height: 0;
  margin-bottom: 16px;
}

.view {
  display: none;
  background: #0e0e15;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #1a1a24;
  min-height: 400px;
}

.view.active { display: block; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6b7a;
}

.panel-header h2 .icon { color: #8b5cf6; }

/* ==================== ПОИСК ==================== */

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 280px;
}

.search-wrap .icon {
  position: absolute;
  left: 12px;
  color: #4a4a58;
  pointer-events: none;
}

.search-input {
  background: #13131c;
  border: 1px solid #1f1f2c;
  border-radius: 6px;
  padding: 8px 14px 8px 34px;
  color: #d4d4dc;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}

.search-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.search-input::placeholder { color: #4a4a58; }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #5a5a68;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}

.search-clear:hover {
  color: #d4d4dc;
  background: rgba(255,255,255,0.06);
}

.search-wrap.has-value .search-clear { display: flex; }
.search-wrap.has-value .search-input { padding-right: 34px; }

/* ==================== ИКОНКИ ==================== */

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 15px; height: 15px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }

/* ==================== ОБЛОЖКИ ==================== */

.cover-img,
.cover-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #13131c;
  color: #4a4a58;
}

.cover-fallback .icon { color: #4a4a58; }

/* ==================== БЛОК «НАЙДЕННЫЕ ПЕСНИ» ==================== */

.search-results {
  background: #0e0e15;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  animation: slideDown 0.15s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid #1f1f2c;
}

.search-results-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b5cf6;
}

.search-results-hint {
  font-size: 0.72rem;
  color: #5a5a68;
  font-variant-numeric: tabular-nums;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.search-results-list::-webkit-scrollbar { width: 8px; }
.search-results-list::-webkit-scrollbar-track { background: transparent; }
.search-results-list::-webkit-scrollbar-thumb { background: #1f1f2c; border-radius: 4px; }

.search-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #13131c;
  border: 1px solid #1f1f2c;
  transition: border-color .15s, background .15s;
}

.search-result-row:hover {
  border-color: #2a2a3a;
  background: #171722;
}

.search-result-cover {
  width: 44px;
  height: 44px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  background: #0e0e15;
  border: 1px solid #1f1f2c;
}

.search-result-cover .cover-fallback .icon {
  width: 20px;
  height: 20px;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 0.86rem;
  font-weight: 500;
  color: #e8e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-artist {
  font-size: 0.76rem;
  color: #a78bfa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.search-result-album {
  font-size: 0.7rem;
  color: #6b6b7a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.search-result-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #8b5cf6;
  border: 1px solid #8b5cf6;
  color: #fff;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-result-add:hover:not(:disabled) {
  background: #7c3aed;
  border-color: #7c3aed;
}

.search-result-add:disabled {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
  cursor: default;
}

.search-result-add .icon { color: currentColor; }

/* ==================== БИБЛИОТЕКА ==================== */

.library-tree {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 5px;
}

.library-tree::-webkit-scrollbar { width: 8px; }
.library-tree::-webkit-scrollbar-track { background: transparent; }
.library-tree::-webkit-scrollbar-thumb { background: #1f1f2c; border-radius: 4px; }
.library-tree::-webkit-scrollbar-thumb:hover { background: #2a2a3a; }

.artist-block { margin-bottom: 2px; }

.artist-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: #c8c8d4;
  transition: background .12s;
  user-select: none;
}

.artist-header:hover { background: #13131c; }

.artist-header::before {
  content: '▸';
  font-size: 0.7rem;
  color: #8b5cf6;
  transition: transform .15s;
  display: inline-block;
  width: 10px;
  flex-shrink: 0;
}

.artist-block.open > .artist-header::before { transform: rotate(90deg); }

.artist-name { flex: 1; }

.artist-count {
  font-size: 0.72rem;
  color: #5a5a68;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.artist-albums { display: none; padding-left: 16px; margin-top: 1px; }
.artist-block.open > .artist-albums { display: block; }

.album-block { margin-bottom: 4px; }

.album-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
}

.album-top:hover { background: #13131c; }

.album-cover {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #13131c;
  border: 1px solid #1f1f2c;
}

.album-cover .cover-fallback .icon {
  width: 22px;
  height: 22px;
}

.album-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  font-size: 0.95rem;
  color: #b8b8c4;
  min-width: 0;
}

.album-header::before {
  content: '▸';
  font-size: 0.7rem;
  color: #5a5a68;
  transition: transform .15s;
  display: inline-block;
  width: 10px;
  flex-shrink: 0;
}

.album-block.open > .album-top .album-header::before {
  transform: rotate(90deg);
  color: #8b5cf6;
}

.album-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-title em {
  font-style: normal;
  color: #5a5a68;
  font-size: 0.8rem;
  margin-left: 4px;
}

.album-count {
  font-size: 0.72rem;
  color: #4a4a58;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.album-songs {
  display: none;
  padding-left: 80px;
  margin-top: 2px;
  margin-bottom: 8px;
}

.album-block.open > .album-songs { display: block; }

.library-song {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background .12s;
  border-left: 2px solid transparent;
}

.library-song:hover {
  background: #13131c;
  border-left-color: #8b5cf6;
}

.library-song .song-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b8b8c4;
}

.library-song .add-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid #2a2a3a;
  color: #8a8a99;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  transition: all .15s;
  opacity: 0;
}

.library-song:hover .add-btn { opacity: 1; }

.library-song .add-btn:hover {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: white;
}

.library-song.in-playlist .add-btn {
  opacity: 1;
  border-color: #1f2f1f;
  color: #4ade80;
  cursor: default;
  font-size: 0.68rem;
}

.library-song.in-playlist .add-btn:hover {
  background: transparent;
  border-color: #1f2f1f;
  color: #4ade80;
}

.library-song.in-playlist .add-btn .icon { color: #4ade80; }

mark.hit {
  background: rgba(139, 92, 246, 0.35);
  color: #e8e8f0;
  border-radius: 3px;
  padding: 0 2px;
}

/* ==================== ПЛЕЙЛИСТ ==================== */

.modes { display: flex; gap: 6px; }

.modes button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #1f1f2c;
  color: #4a4a58;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all .15s;
}

.modes button:hover { border-color: #2a2a3a; color: #8a8a99; }

.modes button.active {
  color: #a78bfa;
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}

#playlist {
  list-style: none;
  max-height: 520px;
  overflow-y: auto;
}

#playlist::-webkit-scrollbar { width: 8px; }
#playlist::-webkit-scrollbar-track { background: transparent; }
#playlist::-webkit-scrollbar-thumb { background: #1f1f2c; border-radius: 4px; }
#playlist::-webkit-scrollbar-thumb:hover { background: #2a2a3a; }

#playlist li {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
  transition: background .12s;
  border-left: 2px solid transparent;
}

#playlist li:hover { background: #13131c; }

#playlist li.active {
  background: rgba(139, 92, 246, 0.08);
  border-left-color: #8b5cf6;
}

#playlist li.active .title { color: #a78bfa; }

.pl-cover {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  background: #13131c;
  border: 1px solid #1f1f2c;
}

.pl-cover .cover-fallback .icon {
  width: 18px;
  height: 18px;
}

#playlist li .title-wrap { flex: 1; overflow: hidden; }

#playlist li .title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  color: #c8c8d4;
  font-weight: 500;
  transition: color .12s;
}

#playlist li .sub {
  display: block;
  font-size: 0.72rem;
  color: #5a5a68;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

#playlist li .remove {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #5a5a68;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all .15s;
  opacity: 0;
}

#playlist li:hover .remove { opacity: 1; }

#playlist li .remove:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.empty {
  color: #4a4a58;
  text-align: center;
  padding: 40px 10px;
  font-size: 0.85rem;
}

/* ==================== ПЛЕЕР (плавающий снизу) ==================== */

.player-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 100;

  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center;
  gap: 16px;
  background: #0e0e15;
  padding: 14px 20px;
  border: 1px solid #1a1a24;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

@media (max-width: 1000px) {
  .player-bar {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas:
      "cover info quality controls"
      "progress progress progress progress"
      "volume volume volume volume";
    row-gap: 10px;
    padding: 12px 16px;
  }
  .player-cover { grid-area: cover; }
  .player-info { grid-area: info; }
  .player-controls { grid-area: controls; }
  .quality-toggle { grid-area: quality; }
  .player-progress { grid-area: progress; }
  .player-volume { grid-area: volume; }

  .app { padding-bottom: 130px; }
}

.player-cover {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: #13131c;
  border: 1px solid #1f1f2c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.player-cover .icon-lg { color: #8b5cf6; opacity: 0.85; }

.player-cover.spin { animation: pulse 3s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

.player-info {
  min-width: 0;
  overflow: hidden;
}

.player-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e8e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  font-size: 0.75rem;
  color: #6b6b7a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.player-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.player-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #1f1f2c;
  color: #8a8a99;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}

.player-controls button:hover {
  border-color: #2a2a3a;
  color: #d4d4dc;
  background: #13131c;
}

.player-controls button .icon-md { width: 16px; height: 16px; }

#playBtn {
  width: 44px;
  height: 44px;
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: white;
}

#playBtn .icon-md { width: 18px; height: 18px; }

#playBtn:hover {
  background: #7c3aed;
  border-color: #7c3aed;
  color: white;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

/* ==================== ПЕРЕКЛЮЧАТЕЛЬ КАЧЕСТВА ==================== */

.quality-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #2a2a3a;
  color: #a78bfa;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: all .15s;
  min-width: 44px;
  flex-shrink: 0;
}

.quality-toggle:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: #8b5cf6;
}

.quality-toggle.lq {
  color: #8a8a99;
  border-color: #1f1f2c;
}

.quality-toggle.lq:hover {
  color: #d4d4dc;
  border-color: #2a2a3a;
  background: #13131c;
}

/* Метка HQ в плейлисте и в блоке результатов */
.quality-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  margin-left: 6px;
  vertical-align: middle;
}

.player-progress,
.player-volume {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-progress { min-width: 200px; }
.player-volume { min-width: 140px; max-width: 180px; }

.player-volume > .icon { color: #6b6b7a; }

audio { display: none; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: #1f1f2c;
  outline: none;
  cursor: pointer;
  min-width: 60px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8b5cf6;
  cursor: pointer;
  transition: transform .15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8b5cf6;
  border: none;
  cursor: pointer;
}

#currentTime, #duration {
  font-size: 0.72rem;
  color: #5a5a68;
  min-width: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ==================== TOAST ==================== */

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #13131c;
  border: 1px solid #2a2a3a;
  color: #d4d4dc;
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform .25s ease;
  z-index: 9999;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
  border-left: 3px solid #8b5cf6;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.toast.error {
  border-left-color: #f87171;
  color: #fca5a5;
}

.upload-btn.loading { pointer-events: none; opacity: 0.5; }

/* ==================== АВТОРИЗАЦИЯ ==================== */

.auth-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
}

.auth-card {
  background: #0e0e15;
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  border: 1px solid #1a1a24;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.auth-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 28px;
  color: #e8e8f0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-title .brand-icon { width: 24px; height: 24px; }

.tabs {
  display: flex;
  background: #13131c;
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 26px;
  border: 1px solid #1a1a24;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: #6b6b7a;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all .15s;
}

.tab:hover { color: #a8a8b4; }

.tab.active {
  background: #8b5cf6;
  color: white;
}

.field { display: block; margin-bottom: 16px; }

.field span {
  display: block;
  font-size: 0.75rem;
  color: #6b6b7a;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="file"] {
  width: 100%;
  background: #13131c;
  border: 1px solid #1f1f2c;
  border-radius: 6px;
  padding: 11px 14px;
  color: #e8e8f0;
  font-size: 0.9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.submit-btn {
  width: 100%;
  background: #8b5cf6;
  border: none;
  border-radius: 6px;
  padding: 12px;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all .15s;
}

.submit-btn:hover:not(:disabled) {
  background: #7c3aed;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.submit-btn:disabled { opacity: 0.5; cursor: wait; }

.auth-error {
  color: #f87171;
  font-size: 0.82rem;
  text-align: center;
  margin-top: 14px;
  min-height: 1.2em;
}

/* ==================== МОДАЛКИ ==================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  z-index: 1000;
  overflow-y: auto;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: #0e0e15;
  border-radius: 10px;
  padding: 28px 26px;
  width: 100%;
  max-width: 500px;
  border: 1px solid #1a1a24;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-wide { max-width: 720px; }

.modal h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1.05rem;
  color: #e8e8f0;
  font-weight: 600;
}

.modal h2 .icon { color: #8b5cf6; }

.modal-hint {
  font-size: 0.82rem;
  color: #6b6b7a;
  margin-bottom: 20px;
}

.parse-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #a78bfa;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.parse-status .icon { color: #a78bfa; }

.file-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}

.file-list::-webkit-scrollbar { width: 8px; }
.file-list::-webkit-scrollbar-track { background: transparent; }
.file-list::-webkit-scrollbar-thumb { background: #1f1f2c; border-radius: 4px; }

.file-card {
  background: #13131c;
  border: 1px solid #1f1f2c;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}

.file-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1f1f2c;
}

.file-name {
  font-size: 0.78rem;
  color: #6b6b7a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.remove-file {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #5a5a68;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all .15s;
}

.remove-file:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.file-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 80px 80px;
  gap: 10px;
}

@media (max-width: 600px) {
  .file-meta { grid-template-columns: 1fr 1fr; }
  .file-meta .meta-field:nth-child(1),
  .file-meta .meta-field:nth-child(3) { grid-column: span 2; }
}

.meta-field { display: block; }

.meta-field span {
  display: block;
  font-size: 0.68rem;
  color: #5a5a68;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.meta-field input {
  width: 100%;
  background: #0e0e15;
  border: 1px solid #1f1f2c;
  border-radius: 5px;
  padding: 8px 10px;
  color: #e8e8f0;
  font-size: 0.85rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.meta-field input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.cancel-btn {
  background: transparent;
  color: #8a8a99;
  border: 1px solid #1f1f2c;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.cancel-btn:hover {
  background: #13131c;
  color: #d4d4dc;
  border-color: #2a2a3a;
}

.modal-actions .submit-btn {
  width: auto;
  padding: 10px 24px;
  margin-top: 0;
}

/* ==================== АДМИН-ПАНЕЛЬ ==================== */

.admin-tabs {
  display: flex;
  background: #13131c;
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 16px;
  border: 1px solid #1a1a24;
}

.admin-tab {
  flex: 1;
  background: none;
  border: none;
  color: #6b6b7a;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all .15s;
}

.admin-tab:hover { color: #a8a8b4; }

.admin-tab.active {
  background: #8b5cf6;
  color: white;
}

.admin-pane { min-height: 200px; }

.admin-list {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.admin-list::-webkit-scrollbar { width: 8px; }
.admin-list::-webkit-scrollbar-track { background: transparent; }
.admin-list::-webkit-scrollbar-thumb { background: #1f1f2c; border-radius: 4px; }

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  background: #13131c;
  border: 1px solid #1f1f2c;
  transition: border-color .15s;
}

.admin-row:hover { border-color: #2a2a3a; }

.admin-row-info { flex: 1; overflow: hidden; }

.admin-row-title {
  display: block;
  font-size: 0.88rem;
  color: #e8e8f0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-sub {
  display: block;
  font-size: 0.72rem;
  color: #6b6b7a;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-badge {
  display: inline-block;
  font-style: normal;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.admin-badge.self {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.admin-del {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #5a5a68;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 5px;
  transition: all .15s;
}

.admin-del:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

.admin-loading {
  color: #5a5a68;
  text-align: center;
  padding: 30px 10px;
  font-size: 0.85rem;
}

/* ==================== МОБИЛЬНАЯ АДАПТАЦИЯ (iPhone) ==================== */

@media (max-width: 700px) {
  body {
    padding: 12px;
    font-size: 15px;
  }

  .app {
    min-height: calc(100vh - 24px);
    padding-bottom: 160px; /* плеер на мобильных выше */
  }

  /* Шапка */
  header {
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  h1.brand {
    font-size: 1rem;
    gap: 8px;
  }

  .brand-icon { width: 20px; height: 20px; }

  .header-actions {
    width: 100%;
    gap: 8px;
  }

  .user-badge span:not(.icon) {
    display: none;
  }

  .upload-btn,
  .logout-btn,
  .admin-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  /* Вкладки */
  .tabs-nav {
    padding: 3px;
    margin-bottom: 12px;
  }

  .nav-tab {
    flex-direction: column;
    gap: 2px;
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  .nav-tab .icon { width: 14px; height: 14px; }
  .nav-tab em { margin-left: 2px; }

  /* Панель */
  .view {
    padding: 14px;
    min-height: 300px;
    border-radius: 8px;
  }

  .panel-header {
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-header h2 { font-size: 0.75rem; }

  /* Поиск */
  .search-wrap {
    max-width: 100%;
    width: 100%;
  }

  /* Плейлист / библиотека */
  #playlist li,
  .library-song {
    padding: 8px 6px;
    gap: 8px;
  }

  .pl-cover {
    width: 36px;
    height: 36px;
  }

  .pl-cover .cover-fallback .icon { width: 15px; height: 15px; }

  #playlist li .title { font-size: 0.82rem; }
  #playlist li .sub { font-size: 0.7rem; }

  /* Дерево библиотеки */
  .artist-header {
    padding: 9px 10px;
    font-size: 0.85rem;
  }

  .artist-count { font-size: 0.68rem; }

  .album-top {
    padding: 8px 6px;
    gap: 8px;
  }

  .album-cover {
    width: 44px;
    height: 44px;
  }

  .album-cover .cover-fallback .icon { width: 18px; height: 18px; }

  .album-header { font-size: 0.85rem; }
  .album-count { font-size: 0.68rem; }

  .album-songs {
    padding-left: 56px;
  }

  .library-song .song-title { font-size: 0.8rem; }

  /* Кнопка «+ в плейлист» — всегда видна на тач-экранах */
  .library-song .add-btn {
    opacity: 1;
    padding: 3px 8px;
    font-size: 0.66rem;
  }

  /* HQ метка */
  .quality-badge {
    font-size: 0.55rem;
    padding: 1px 4px;
    margin-left: 4px;
  }

  /* Блок найденных песен */
  .search-result-row {
    padding: 8px;
    gap: 8px;
  }

  .search-result-cover {
    width: 40px;
    height: 40px;
  }

  .search-result-title { font-size: 0.82rem; }
  .search-result-artist { font-size: 0.72rem; }
  .search-result-album { font-size: 0.68rem; }

  .search-result-add {
    padding: 5px 10px;
    font-size: 0.68rem;
  }

  /* Плеер */
  .player-bar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "info controls"
      "progress progress"
      "volume quality";
    gap: 10px;
    padding: 12px;
    border-radius: 12px 12px 0 0;
    row-gap: 8px;
    max-width: 100%;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.6);
  }

  .player-cover { display: none; }

  .player-info {
    grid-area: info;
    min-width: 0;
  }

  .player-title { font-size: 0.85rem; }
  .player-meta { font-size: 0.7rem; }

  .player-controls {
    grid-area: controls;
    gap: 4px;
  }

  .player-controls button {
    width: 40px;
    height: 40px;
  }

  .player-controls button .icon-md {
    width: 15px;
    height: 15px;
  }

  #playBtn {
    width: 46px;
    height: 46px;
  }

  #playBtn .icon-md {
    width: 17px;
    height: 17px;
  }

  .player-progress {
    grid-area: progress;
    min-width: 0;
    width: 100%;
  }

  .player-volume {
    grid-area: volume;
    min-width: 0;
    max-width: none;
  }

  .quality-toggle {
    grid-area: quality;
    justify-self: end;
  }

  /* Модалки */
  .modal-backdrop {
    padding: 12px;
    align-items: flex-start;
  }

  .modal {
    padding: 18px;
    border-radius: 8px;
    max-width: 100%;
  }

  .modal-wide { max-width: 100%; }

  .modal h2 { font-size: 0.95rem; }

  .file-meta {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .meta-field:nth-child(1),
  .meta-field:nth-child(3) {
    grid-column: span 2;
  }

  .admin-tabs { padding: 2px; }
  .admin-tab { padding: 8px; font-size: 0.78rem; }

  .admin-row { padding: 8px 10px; }
  .admin-row-title { font-size: 0.82rem; }
  .admin-row-sub { font-size: 0.68rem; }

  /* Авторизация */
  .auth-card {
    padding: 24px 20px;
    border-radius: 10px;
  }

  .auth-title { font-size: 1rem; }

  /* Важно: 16px отключает авто-зум iOS при фокусе */
  .field input[type="text"],
  .field input[type="password"],
  .field input[type="file"] {
    font-size: 16px;
    padding: 12px 14px;
  }

  .submit-btn { padding: 14px; font-size: 0.9rem; }

  .toast {
    max-width: calc(100vw - 24px);
    font-size: 0.8rem;
    padding: 10px 16px;
  }
}

/* Очень узкие экраны (iPhone SE и подобные) */
@media (max-width: 400px) {
  body { padding: 8px; }

  header { flex-direction: column; align-items: flex-start; }

  .upload-btn span,
  .logout-btn span,
  .admin-btn span {
    display: none;
  }

  .upload-btn,
  .logout-btn,
  .admin-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
  }

  .player-controls { gap: 2px; }
  .player-controls button { width: 36px; height: 36px; }
  #playBtn { width: 42px; height: 42px; }
}