:root {
  --bg: #121212;
  --surface: #1c1c1e;
  --surface-2: #26262a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #fff;
  --muted: #9a9aa0;
  --accent: #ffdb4d;
  --accent-2: #ffb800;
  --like: #ff5470;
  --danger: #ff5a5f;
  --sidebar-w: 240px;
  --bar-h: 80px;
  --nav-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "YS Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.35;
}
body.no-scroll { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
i[data-i] { display: inline-flex; }
svg { width: 24px; height: 24px; display: block; }

/* ---------- Каркас ---------- */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 24px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 12px; font-size: 20px; font-weight: 700; }
.logo-dot { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-2)); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px; border-radius: 12px;
  color: var(--muted); font-weight: 500; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-admin { margin-top: auto; }
@media (min-width: 761px) {
  /* плеер закреплён поверх всей ширины — панель заканчивается над ним */
  body.has-track .sidebar { bottom: var(--bar-h); }
}

.content {
  margin-left: var(--sidebar-w);
  padding: 32px 40px 48px;
  min-height: 100vh;
}
body.has-track .content { padding-bottom: calc(var(--bar-h) + 32px); }

/* ---------- Шапка ---------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; margin-bottom: 24px; }
.hero-text { flex: 1 1 260px; min-width: 0; }
.hero h1 { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.hero-sub { margin-top: 6px; color: var(--muted); }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  flex: 1 1 100%; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 44px;
  background: var(--surface); border-radius: 22px; color: var(--muted);
  border: 1px solid transparent; transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.search input::placeholder { color: var(--muted); }

/* ---------- Кнопки ---------- */
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; border-radius: 22px; font-weight: 600;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #000; }
.btn-primary:hover { transform: scale(1.03); }
.btn-primary:disabled { opacity: .5; pointer-events: none; }
.btn-primary svg, .btn-ghost svg { width: 20px; height: 20px; }
.btn-ghost { background: var(--surface-2); }
.btn-ghost:hover { background: #33333a; }
.btn-ghost.icon-only { width: 44px; padding: 0; }
.btn-danger { color: var(--danger); background: rgba(255, 90, 95, .12); }
.btn-danger:hover { background: rgba(255, 90, 95, .2); }
.file-btn { cursor: pointer; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.icon-btn.on { color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; }

.play-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #000; transition: transform .1s;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn.big { width: 64px; height: 64px; }
.play-btn.big svg { width: 30px; height: 30px; }

/* like: контур -> заливка */
.like { color: var(--muted); }
.like:not(.on) svg path { fill: none; stroke: currentColor; stroke-width: 2; }
.like.on { color: var(--like); }

/* ---------- Значок «E» ---------- */
.badge-e {
  display: none;
  align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  margin-left: 6px; border-radius: 4px;
  background: rgba(255, 255, 255, .22); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1; vertical-align: 1px;
  flex: none;
}
.badge-e.show { display: inline-flex; }
.switch-text .badge-e { display: inline-flex; }
.badge-mat {
  display: none; margin-left: 6px; flex: none;
  color: var(--danger); font-size: 12px; font-weight: 700; line-height: 1;
}
.badge-mat.show { display: inline; }

/* ---------- Об исполнителе ---------- */
.artist-card { display: flex; align-items: center; gap: 32px; margin-bottom: 32px; }
.cover.artist-photo { width: 200px; height: 200px; border-radius: 50%; box-shadow: 0 16px 40px rgba(0, 0, 0, .4); }
.artist-photo svg { width: 40%; height: 40%; }
.cover.round { border-radius: 50%; }
.artist-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.artist-info h1 { margin: 6px 0 16px; font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.artist-bio { max-width: 720px; white-space: pre-wrap; font-size: 17px; line-height: 1.65; color: #e8e8ec; }
.artist .empty { padding: 24px 0; text-align: left; }

/* первая буква названия трека */
.fl { color: var(--danger); }
.track.playing .t-title .fl { color: var(--danger); }

/* ---------- Обложки ---------- */
.cover {
  position: relative; overflow: hidden; flex: none;
  background: linear-gradient(135deg, #34343b, #202024);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #5c5c66;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover svg { width: 45%; height: 45%; }

/* ---------- Список треков ---------- */
.track-list { display: flex; flex-direction: column; }
.track {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 12px; cursor: pointer;
  transition: background .12s;
}
.track:hover { background: var(--surface); }
.track.playing { background: var(--surface-2); }
.t-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.t-cover { width: 48px; height: 48px; border-radius: 6px; position: relative; }
.t-cover .cover { width: 100%; height: 100%; border-radius: 6px; }
.t-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5); border-radius: 6px; opacity: 0; transition: opacity .12s;
}
.t-play svg { width: 22px; height: 22px; }
.t-play .eq { display: none; }
.track:hover .t-play { opacity: 1; }
.track.playing .t-play { opacity: 1; }
.track.playing .t-play .ico { display: none; }
.track.playing .t-play .eq { display: flex; }
.track.playing.paused .t-play .eq { display: none; }
.track.playing.paused .t-play .ico { display: block; }
.eq { align-items: flex-end; gap: 3px; height: 16px; }
.eq span { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq span:nth-child(2) { animation-delay: -.3s; }
.eq span:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }

.t-text { min-width: 0; }
.t-title { display: flex; align-items: center; font-weight: 500; }
.t-title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track.playing .t-title > span:first-child { color: var(--accent); }
.t-artist { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-plays { color: var(--muted); font-size: 13px; padding: 0 12px; white-space: nowrap; }
.t-like, .t-share { opacity: 0; }
.track:hover .t-like, .track:hover .t-share, .t-like.on { opacity: 1; }
.np-side-btns { display: flex; align-items: center; flex: none; }
.t-edit { display: none; }
body.is-admin .t-edit { display: inline-flex; }
.track { grid-template-columns: 1fr auto auto auto; }
body.is-admin .track { grid-template-columns: 1fr auto auto auto auto; }

/* ---------- Переключатель вида ---------- */
.view-toggle { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-2); border-radius: 22px; height: 44px; align-items: center; }
.view-toggle .icon-btn { width: 40px; height: 40px; }
.view-toggle .icon-btn.on { background: rgba(255, 255, 255, .14); color: var(--text); }

/* ---------- Плитки (~100×100 мм) ---------- */
.track-list.grid {
  display: grid; gap: 20px; justify-content: start;
  grid-template-columns: repeat(auto-fill, min(100mm, 100%));
}
.track.tile {
  display: block; position: relative; padding: 0; overflow: hidden;
  width: 100%; aspect-ratio: 1; border-radius: 16px; background: var(--surface-2);
}
.track.tile:hover, .track.tile.playing { background: var(--surface-2); }
.tile-cover.cover { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; }
.tile-cover.cover svg { width: 30%; height: 30%; }
.tile .t-play {
  inset: auto; left: 50%; top: 50%; width: 64px; height: 64px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--accent); color: #000; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.tile .t-play svg { width: 30px; height: 30px; }
.tile .eq { height: 22px; }
.tile .eq span { background: #000; width: 4px; }
.tile-meta {
  position: absolute; left: 0; right: 0; bottom: 0; min-width: 0;
  padding: 56px 16px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0));
}
.tile .t-title { font-size: 17px; font-weight: 600; }
.tile .t-artist { color: #d0d0d6; font-size: 14px; }
.tile-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.tile-actions .icon-btn { background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(6px); }
.tile-actions .icon-btn:hover { background: rgba(0, 0, 0, .7); }
.tile-actions .like.on { color: var(--like); }
.tile-actions .like:not(.on) { color: #fff; }

.empty { padding: 64px 0; text-align: center; color: var(--muted); }

/* ---------- Плеер ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bar-h);
  display: none; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(24, 24, 26, .96); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line); z-index: 20;
}
body.has-track .bar { display: flex; }
.bar-progress-line { display: none; }
.bar-info { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; cursor: pointer; }
.bar-info .cover { width: 52px; height: 52px; }
.bar-meta { min-width: 0; }
.bar-title { display: flex; align-items: center; font-weight: 500; }
.bar-title .np-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-artist { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-center { flex: 1.6 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 640px; }
.bar-controls { display: flex; align-items: center; gap: 8px; }
.bar-seek { display: flex; align-items: center; gap: 10px; width: 100%; }
.time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 36px; }
.time.js-dur { text-align: right; }
.bar-right { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
#volume { width: 96px; margin-left: 4px; }

/* range */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px; outline: 0; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), rgba(255, 255, 255, .18) var(--p, 0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; opacity: 0; transition: opacity .12s;
}
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { opacity: 1; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }

/* ---------- Сейчас играет ---------- */
.np {
  position: fixed; inset: 0; z-index: 50; overflow-y: auto;
  background: radial-gradient(120% 80% at 50% 0%, #2a2a31 0%, var(--bg) 60%);
  transform: translateY(100%); visibility: hidden;
  transition: transform .3s ease, visibility 0s .3s;
  padding: 0 24px calc(24px + var(--safe-b));
}
.np.open { transform: none; visibility: visible; transition: transform .3s ease; }
.np-head { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.np-head-title { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.np-head-spacer { width: 40px; }
.np-body { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 56px; align-items: start; }
.cover-big { width: 100%; aspect-ratio: 1; border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.np-info { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; }
.np-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.np-title-big { display: flex; align-items: center; font-size: 22px; font-weight: 700; }
.np-artist-big { color: var(--muted); margin-top: 2px; }
.np-controls { justify-content: center; gap: 16px; }
.np-right { padding-top: 8px; }
.lyrics-head { display: flex; align-items: center; font-size: 22px; font-weight: 700; margin-bottom: 16px; }
.lyrics { white-space: pre-wrap; font-size: 20px; line-height: 1.6; color: #e8e8ec; }
.lyrics.none { color: var(--muted); font-size: 16px; }

/* ---------- Редактор / модалка ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s; z-index: 60; }
.scrim.open { opacity: 1; visibility: visible; transition: opacity .2s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw;
  display: flex; flex-direction: column; background: var(--surface);
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; z-index: 61;
}
.drawer.open { transform: none; visibility: visible; transition: transform .25s ease; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.ed-cover-row { display: flex; align-items: center; gap: 16px; }
.cover-edit { width: 112px; height: 112px; border-radius: 10px; }
.ed-cover-actions { display: flex; flex-direction: column; gap: 8px; }
.ed-cover-actions .btn-ghost { height: 36px; padding: 0 16px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--muted); font-size: 13px; }
.field input[type="text"], .field input[type="password"], .field textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; outline: 0;
}
.field textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="file"] { font-size: 13px; color: var(--muted); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 44px; height: 26px; border-radius: 13px; background: var(--surface-2); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #000; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: flex; align-items: center; }

.modal {
  position: fixed; left: 50%; top: 50%; width: 360px; max-width: calc(100vw - 32px);
  transform: translate(-50%, -46%); opacity: 0; visibility: hidden;
  background: var(--surface); border-radius: 16px; padding: 24px; z-index: 61;
  transition: opacity .2s, transform .2s, visibility 0s .2s;
}
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); transition: opacity .2s, transform .2s; }
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.form-error { min-height: 20px; margin-top: 8px; color: var(--danger); font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 24px); transform: translate(-50%, 20px);
  background: #fff; color: #000; padding: 10px 18px; border-radius: 20px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-flex !important; }

/* ---------- Мобильная версия ---------- */
@media (max-width: 860px) {
  .np-body { grid-template-columns: 1fr; gap: 32px; }
  .cover-big { max-width: 360px; margin: 0 auto; }
}

@media (max-width: 760px) {
  body { font-size: 14px; }

  /* нижняя навигация */
  .sidebar {
    top: auto; width: auto; right: 0; height: calc(var(--nav-h) + var(--safe-b));
    padding: 0 8px var(--safe-b); flex-direction: row; gap: 0;
    border-right: 0; border-top: 1px solid var(--line);
    background: rgba(18, 18, 18, .97); backdrop-filter: blur(20px); z-index: 30;
  }
  .logo { display: none; }
  .nav { flex-direction: row; justify-content: space-around; align-items: stretch; }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 4px; font-size: 11px; border-radius: 10px; background: none !important; }
  .nav-item.active { color: var(--accent); }
  .nav-admin { margin-top: 0; }
  .nav-item svg { width: 22px; height: 22px; }

  .content { margin-left: 0; padding: 20px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
  body.has-track .content { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 84px); }
  .hero h1 { font-size: 30px; }
  .artist-card { flex-direction: column; align-items: flex-start; gap: 20px; }
  .cover.artist-photo { width: 140px; height: 140px; }
  .artist-info h1 { font-size: 30px; }
  .artist-bio { font-size: 16px; }
  .hero { gap: 12px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn-primary { flex: 1; }
  .search { max-width: none; }

  .track { padding: 8px 4px; }
  .t-plays { display: none; }
  .t-like, .t-share { opacity: 1; }
  .t-cover { width: 44px; height: 44px; }

  /* мини-плеер */
  .bar {
    left: 8px; right: 8px; bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
    height: 64px; padding: 0 8px 0 8px; gap: 8px; border: 1px solid var(--line); border-radius: 14px;
  }
  .bar-info .cover { width: 46px; height: 46px; }
  .bar-center { flex: none; max-width: none; }
  .hide-m { display: none !important; }
  .bar-progress-line { display: block; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 12px; }
  .bar-progress-line input { height: 2px; margin: 0; position: absolute; bottom: 4px; }
  .bar-progress-line input::-webkit-slider-thumb { opacity: 0; }
  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 90px); }

  .np { padding: 0 20px calc(24px + var(--safe-b)); }
  .np-title-big { font-size: 20px; }
  .lyrics { font-size: 18px; }
  input[type="range"]::-webkit-slider-thumb { opacity: 1; }
  .np .play-btn.big { width: 68px; height: 68px; }

  /* редактор — шторка снизу */
  .drawer {
    top: auto; left: 0; right: 0; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .drawer.open { transform: none; }
  .modal { width: calc(100vw - 32px); }
}

@media (hover: none) {
  .t-like, .t-share { opacity: 1; }
  .t-play { display: none; }
  .track.playing .t-play { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
