:root {
  --bg: #101311;
  --bg2: #171b18;
  --card: #1c211d;
  --line: #2a312b;
  --text: #eef2ea;
  --muted: #8f9a90;
  --accent: #dbfc86;
  --accent-ink: #17301f;
  --danger: #ff8f80;
  --radius: 16px;
  --tab-h: 58px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
body.no-scroll { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); font-size: 14px; }
.grow { flex: 1; text-align: left; }
.pad { padding: 8px 4px; }
.icon { display: inline-flex; align-items: center; justify-content: center; }

#view { padding: calc(var(--safe-t) + 14px) 16px calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 28px); max-width: 720px; margin: 0 auto; min-height: 100vh; }
.head { margin: 6px 0 16px; }
.head h1 { font-size: 28px; }

/* ── кнопки ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { height: 48px; padding: 0 24px; }
.btn:disabled { opacity: .55; }
.btn:active, .chip:active, .menu-item:active, .row:active { transform: scale(.98); }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--muted); flex: none; }
.icon-btn.on { color: var(--accent); }
.link { color: var(--accent); font-size: 14px; font-weight: 600; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 38px; padding: 0 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 500; }

/* ── обложки ── */
.cover { position: relative; display: flex; align-items: center; justify-content: center; border-radius: 12px; overflow: hidden; color: rgba(255,255,255,.55); flex: none; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.xs { width: 44px; height: 44px; border-radius: 10px; }
.cover.sm { width: 52px; height: 52px; }
.cover.lg { width: 148px; height: 148px; border-radius: 16px; }
.cover.xl { width: min(78vw, 360px); aspect-ratio: 1; border-radius: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }

/* ── списки ── */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-radius: 12px; cursor: pointer; transition: transform .1s; }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title { font-weight: 600; font-size: 16px; }
.row-sub { color: var(--muted); font-size: 14px; }
.row.playing .row-title { color: var(--accent); }
.empty { text-align: center; padding: 56px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-title { font-size: 18px; font-weight: 700; }
.skeleton { display: grid; gap: 12px; padding-top: 8px; }
.sk-row { height: 52px; border-radius: 12px; background: linear-gradient(90deg, var(--bg2), var(--card), var(--bg2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ── главная ── */
.hero { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 24px; background: linear-gradient(135deg, #cfe9d0, #7fb59a 60%, #3d7a5e); color: #12301f; margin-bottom: 14px; }
.hero-art { width: 84px; height: 84px; border-radius: 22px; background: rgba(255,255,255,.35); display: flex; align-items: center; justify-content: center; flex: none; }
.hero-body { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hero-title { font-size: 20px; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.hero .btn.primary { background: #12301f; color: var(--accent); }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; opacity: .7; }
.shelf { margin: 8px 0 18px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.shelf-head h2 { font-size: 20px; }
.shelf-sub { margin-top: 2px; }
.setup { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; margin: 4px 0 16px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); }
.setup .eyebrow { color: var(--accent); opacity: 1; }
.setup-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.setup .btn { margin-top: 6px; }
.taste { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.taste-tags { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.taste-tag { padding: 4px 12px; border-radius: 999px; background: rgba(219,252,134,.12); color: var(--accent); font-size: 13px; font-weight: 600; }
.chip.pick.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.cards { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
.cards::-webkit-scrollbar { display: none; }
.card { flex: none; width: 148px; text-align: left; scroll-snap-align: start; }
.card-title { margin-top: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.about { color: var(--muted); font-size: 12.5px; margin: 22px 0 0; line-height: 1.5; }

/* ── поиск, библиотека ── */
.searchbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; margin: 0 0 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.search-input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; color: var(--text); font-size: 16px; }
.seg { display: flex; gap: 6px; padding: 4px; background: var(--card); border-radius: 999px; margin-bottom: 14px; }
.seg button { flex: 1; height: 36px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.playbar { display: flex; gap: 10px; margin: 2px 0 10px; }
.subhead { display: flex; align-items: center; gap: 4px; margin: 0 0 8px -10px; }
.subhead h1 { flex: 1; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 0; text-align: left; }
.pl-cover { background: var(--card); color: var(--muted); }
.results > .btn, .list + .btn, #view > div > .btn { display: flex; margin: 14px auto; }

/* ── мини-плеер и вкладки ── */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(16,19,17,.94); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
#tabs button.on { color: var(--accent); }
#mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + var(--safe-b) + 6px); z-index: 19; height: var(--mini-h); display: flex; align-items: center; gap: 4px; padding: 0 6px 0 10px; border-radius: 18px; background: #232a25; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.4); overflow: hidden; max-width: 704px; margin: 0 auto; }
#mini[hidden], #full[hidden] { display: none; }
.mini-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; height: 100%; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.08); }
.mini-progress div { height: 100%; width: 0; background: var(--accent); }
#m-play { color: var(--text); }

/* ── полный плеер ── */
#full { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; padding: calc(var(--safe-t) + 8px) 20px calc(var(--safe-b) + 18px); background: radial-gradient(120% 70% at 50% 0%, #223a2c 0%, var(--bg) 62%); overflow-y: auto; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.full-top { width: 100%; max-width: 420px; display: flex; justify-content: space-between; align-items: center; }
.full-top .icon-btn { color: var(--text); }
.full-art { margin: 14px 0 22px; }
.full-meta { width: 100%; max-width: 420px; display: flex; align-items: center; gap: 10px; }
.full-text { flex: 1; min-width: 0; }
.full-title { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.full-artist { color: var(--muted); margin-top: 2px; }
.scrub-wrap { width: 100%; max-width: 420px; margin: 18px 0 6px; }
.scrub { width: 100%; height: 28px; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; }
.scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) var(--p, 0%), rgba(255,255,255,.16) 0); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--text); }
.scrub::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.16); }
.scrub::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.scrub::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--text); }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.controls { width: 100%; max-width: 420px; display: flex; align-items: center; justify-content: space-between; margin: 10px 0 18px; }
.controls .icon-btn { color: var(--text); width: 52px; height: 52px; }
.controls .mode-btn { color: var(--muted); }
.controls .mode-btn.on { color: var(--accent); }
.repeat[data-mode='one']::after { content: '1'; position: absolute; font-size: 10px; font-weight: 800; margin-top: -2px; }
.play-btn { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(219,252,134,.25); }
.full-foot { display: flex; gap: 10px; margin-top: auto; padding-top: 8px; }

/* ── шторки, меню, тосты ── */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 82vh; overflow-y: auto; background: var(--bg2); border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--safe-b) + 18px); animation: rise .2s ease-out; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet-title { font-size: 17px; margin: 0 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 14px; height: 52px; text-align: left; font-size: 16px; border-radius: 12px; }
.menu-item.accent { color: var(--accent); font-weight: 600; }
.menu-item.danger { color: var(--danger); }
.big-add { width: 100%; margin-bottom: 4px; }
.credit { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.5; }
.form { display: flex; flex-direction: column; gap: 12px; }
.text-input { height: 50px; padding: 0 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); outline: 0; font-size: 16px; }
.text-input:focus { border-color: var(--accent); }
#toast { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--mini-h) + var(--safe-b) + 18px); z-index: 80; display: flex; justify-content: center; pointer-events: none; }
.toast-item { background: #eef2ea; color: #101311; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: fade .15s; max-width: 90vw; }
.fatal { padding-top: 22vh; }

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