:root {
  --bg: #101114;
  --bg2: #17181d;
  --bg3: #202229;
  --line: #2a2c35;
  --text: #eceef3;
  --muted: #9097a6;
  --accent: #9d8cff;
  --accent2: #7c68f5;
  --ok: #4fd18b;
  --err: #ff6b6b;
  --radius: 12px;
  --tabs-h: 58px;
  --mini-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
body.player-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; }
h3 { margin: 18px 0 8px; font-size: 17px; }
p { margin: 6px 0; }

.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.err { color: var(--err); }
.ok { color: var(--ok); }
.pad { padding: 0 16px; }
.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

.ic, .icon-btn svg, .btn svg, #tabs svg, .play-btn svg, .pill svg { display: inline-flex; }
.ic svg, .icon-btn svg, .btn svg, #tabs svg, .play-btn svg, .pill svg { width: 22px; height: 22px; fill: currentColor; }

/* ---- header and tabs ---- */
#top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  height: 52px; padding: 0 6px 0 10px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(16, 17, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
#title { flex: 1; margin: 0 6px; font-size: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#net { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg3); color: var(--muted); }
#view { padding: 4px 16px 24px; padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 24px); max-width: 900px; margin: 0 auto; }
body.has-mini #view { padding-bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 24px); }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bg2); border-top: 1px solid var(--line);
}
#tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted);
}
#tabs a.on { color: var(--accent); }
body.login-page #tabs, body.login-page #mini, body.login-page #settings-link, body.login-page #profile-link { display: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:active { background: var(--bg3); }
.icon-btn.on { color: var(--accent); }
.icon-btn.big svg { width: 34px; height: 34px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg3); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.6; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer;
}

.input {
  width: 100%; padding: 11px 14px; margin: 6px 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg2); color: var(--text); font: inherit; outline: none;
}
.input:focus { border-color: var(--accent2); }
textarea.input { resize: vertical; min-height: 90px; }
select.input { appearance: auto; }
.field { display: block; margin: 8px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); }

/* ---- covers ---- */
.cover {
  position: relative; flex: none; overflow: hidden; border-radius: 8px; background: var(--bg3);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph svg { width: 45%; height: 45%; fill: currentColor; }
.cover.xs { width: 40px; height: 40px; border-radius: 6px; }
.cover.sm { width: 48px; height: 48px; }
.cover.md { width: 100%; aspect-ratio: 1; }
.cover.lg { width: min(220px, 60vw); aspect-ratio: 1; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.cover.xl { width: min(78vw, 46vh, 420px); aspect-ratio: 1; border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); }
.cover.round { border-radius: 50%; }

/* ---- lists ---- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 6px 4px; border-radius: 10px; cursor: pointer;
}
.row:active { background: var(--bg2); }
.row-text { flex: 1; min-width: 0; }
.row .title { font-size: 15px; }
.row .num { width: 28px; text-align: center; flex: none; font-variant-numeric: tabular-nums; }
.row .dur { flex: none; font-variant-numeric: tabular-nums; }
.row.now .title, .row.now .num { color: var(--accent); }
.row.disabled { opacity: 0.4; }
.mark svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 4px; fill: var(--accent); }
.mark.ok svg { fill: var(--ok); }
.mark.err svg { fill: var(--err); }
.mark.muted svg { fill: var(--muted); }
.row > .mark svg { width: 20px; height: 20px; margin: 0 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.hscroll {
  display: grid; grid-auto-flow: column; grid-auto-columns: 140px; gap: 14px;
  overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }
.card { display: flex; flex-direction: column; gap: 4px; min-width: 0; scroll-snap-align: start; }
.card-title { font-size: 14px; margin-top: 4px; }

.sec { margin-top: 8px; }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 12px 0; }
.actions.pad { justify-content: flex-start; padding: 0; }

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 14px 0 6px; }
.hero-text { margin-top: 14px; max-width: 100%; }

.tabs2, .seg { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.tabs2::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
.tabs2 a, .seg button {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
}
.tabs2 a.on, .seg button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.info, .box { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.box h3 { margin-top: 0; }
.bar { height: 4px; border-radius: 2px; background: var(--bg3); margin-top: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); transition: width 0.3s; }
.job { align-items: flex-start; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic svg { width: 44px; height: 44px; opacity: 0.6; }
.empty.error { color: var(--text); }
.loading { display: flex; justify-content: center; padding: 50px 0; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--bg3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-form { position: sticky; top: 52px; z-index: 5; background: var(--bg); padding-top: 6px; }

/* ---- sources ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.chip.on { color: var(--text); border-color: currentColor; }
.chip.on.src-ytm { color: #ff6b6b; }
.chip.on.src-zaycev { color: #f5a524; }
.chip.on.src-sc { color: #ff8a3d; }
.chip.on.src-ytv { color: #ff4d4d; }
.chip.on.src-yandex { color: #ffd84d; }
.chip.on.src-ia { color: #8fc1ff; }
.src-badge { display: inline-block; font-size: 10px; line-height: 1; padding: 3px 6px; margin-right: 6px; border-radius: 6px; vertical-align: 1px; font-weight: 600; letter-spacing: 0.2px; }
.src-badge.src-ytm { background: rgba(255, 70, 70, 0.16); color: #ff7b7b; }
.src-badge.src-zaycev { background: rgba(245, 165, 36, 0.16); color: #f7b84b; }
.src-badge.src-sc { background: rgba(255, 120, 40, 0.16); color: #ff9a5c; }
.src-badge.src-lib { background: rgba(157, 140, 255, 0.16); color: var(--accent); }
.src-badge.src-ytv { background: rgba(255, 50, 50, 0.13); color: #ff6262; }
.src-badge.src-yandex { background: rgba(255, 216, 77, 0.15); color: #ffd84d; }
.src-badge.src-ia { background: rgba(143, 193, 255, 0.15); color: #8fc1ff; }
.src-badge.src-new { background: rgba(79, 209, 139, 0.16); color: var(--ok); }

/* search answers arriving one by one */
.searching { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; margin: 0; }
.replace-banner { border-color: var(--accent2); }
.replace-banner .mark svg { fill: var(--accent); }
ol.steps { margin: 6px 0 10px; padding-left: 20px; color: var(--muted); }
ol.steps li { margin: 4px 0; }

/* home: the wave and "Плейлист дня" */
.mixes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 8px; }
.mix-card {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
  min-height: 132px; padding: 14px; border-radius: 16px; cursor: pointer; overflow: hidden; color: #fff;
}
.mix-card.wave { background: linear-gradient(135deg, #6a4cf5 0%, #2bc0a4 100%); }
.mix-card.daily { background: linear-gradient(135deg, #f0689a 0%, #f5a524 100%); }
.mix-card .mix-ic svg { width: 30px; height: 30px; fill: rgba(255, 255, 255, 0.9); }
.mix-title { font-size: 18px; font-weight: 700; }
.mix-text .small { opacity: 0.9; }
.mix-card .icon-btn { position: absolute; top: 8px; right: 8px; color: #fff; }
.mix-card .icon-btn.mix-play { top: auto; bottom: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.95); color: #222; }
.mix-card .icon-btn.mix-play svg { width: 26px; height: 26px; }
.mix-card .mix-text { padding-right: 46px; }
@media (max-width: 360px) { .mixes { grid-template-columns: 1fr; } }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 1px; }
.register-link { margin-top: 16px; text-align: center; color: var(--muted); }

/* ---- login ---- */
.login { max-width: 360px; margin: 10vh auto 0; display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.login .logo { margin: 0 auto 10px; width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(135deg, var(--accent2), #2bc0a4); display: flex; align-items: center; justify-content: center; }
.login .logo svg { width: 40px; height: 40px; fill: #fff; }

/* ---- mini player ---- */
#mini {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 19;
  height: var(--mini-h); background: var(--bg3); border-top: 1px solid var(--line);
}
#mini-progress { height: 2px; background: transparent; }
#mini-progress > div { height: 100%; width: 0; background: var(--accent); }
#mini-body { display: flex; align-items: center; gap: 10px; height: calc(var(--mini-h) - 2px); padding: 0 6px 0 10px; cursor: pointer; }
#mini-text { flex: 1; min-width: 0; }
#mini-cover .cover.sm { width: 44px; height: 44px; }
#mini-cover, #player-cover { flex: none; }

/* ---- full screen player ---- */
#player {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #23203a 0%, var(--bg) 60%);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: var(--safe-b);
}
#player[hidden], #mini[hidden], #queue[hidden], #sheet[hidden] { display: none; }
#player-top { display: flex; align-items: center; gap: 6px; padding: 6px; }
#player-from { flex: 1; text-align: center; font-size: 13px; }
#player-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 24px 16px; min-height: 0; }
#player-main.with-queue { flex: none; gap: 10px; }
#player-main.with-queue #player-cover { display: none; }
/* with the queue open the big cover gives way to a small one next to the title */
#player-thumb { display: none; flex: none; }
#player-main.with-queue #player-thumb { display: block; }
#player-info { width: 100%; max-width: 440px; display: flex; align-items: center; gap: 8px; }
#player-text { flex: 1; min-width: 0; }
#player-title { font-size: 21px; font-weight: 600; }
#player-artist { color: var(--muted); cursor: pointer; }
#seek { width: 100%; max-width: 440px; }
#seek-bar { width: 100%; accent-color: var(--accent); }
#seek-times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#controls { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 380px; }
.play-btn { width: 70px; height: 70px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.play-btn svg { width: 36px; height: 36px; }
#player-extra { display: flex; gap: 10px; }
#vol { display: flex; align-items: center; gap: 6px; width: 100%; max-width: 320px; }
#vol input, #mini-vol input { flex: 1; accent-color: var(--accent); min-width: 0; }
#vol .icon-btn svg { width: 24px; height: 24px; }
#mini-vol { display: none; align-items: center; gap: 2px; width: 170px; }
#mini-vol .icon-btn { width: 36px; height: 36px; }
#mini-vol .icon-btn svg { width: 20px; height: 20px; }
@media (min-width: 700px) { #mini-vol { display: flex; } }
#queue { flex: 1; overflow-y: auto; padding: 0 12px 12px; border-top: 1px solid var(--line); }
/* covers in rows are positioned: without z-index they slide over the sticky header */
.queue-head { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 4px 6px; position: sticky; top: 0; z-index: 2; background: var(--bg); box-shadow: 0 6px 8px -6px rgba(0, 0, 0, 0.6); }
.qrow { min-height: 52px; }
.qrow.past { opacity: 0.5; }
.qrow.now .ellipsis:first-child { color: var(--accent); }

/* ---- sheet ---- */
#sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sheet-box {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow-y: auto;
  background: var(--bg2); border-radius: 16px 16px 0 0; padding: 8px 8px calc(12px + var(--safe-b));
  max-width: 600px; margin: 0 auto; animation: up 0.18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-title { padding: 10px 12px 8px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.sheet-title.wrap { white-space: normal; font-weight: normal; border: 0; }
.sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px; border: 0; background: transparent; text-align: left; border-radius: 10px; cursor: pointer; }
.sheet-item:active { background: var(--bg3); }
.sheet-item svg { width: 22px; height: 22px; fill: var(--muted); }
.sheet-item.danger { color: var(--err); }
.sheet-item.danger svg { fill: var(--err); }
.sheet-form { padding: 6px 8px; }
.row-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 90vw; padding: 10px 16px; border-radius: 10px;
  background: #2d2f39; color: var(--text); font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .hscroll { grid-auto-columns: 170px; }
}

/* downloads: the server's disk */
.server-box { display: flex; flex-direction: column; gap: 4px; }
.disk-bar { height: 6px; border-radius: 3px; background: var(--bg3); overflow: hidden; margin: 4px 0 2px; }
.disk-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent2), #2bc0a4); }
.server-box .actions { margin: 6px 0 0; }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- likes and dislikes, profile ---- */
.row.song.disliked { opacity: .5; }
.row.song.disliked .title { text-decoration: line-through; text-decoration-color: var(--muted); }
#player-dislike.on { color: var(--err); }
.row-ic svg { width: 22px; height: 22px; fill: var(--muted); }
.profile-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 12px; }
.profile-head h2 { margin: 0; font-size: 22px; }
.avatar svg { width: 56px; height: 56px; fill: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 14px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.tile-v { font-size: 24px; font-weight: 700; }
.tile-l { margin-top: 2px; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 96px; margin: 4px 0 8px; }
.month { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.month-bar { flex: 1; width: 100%; display: flex; align-items: flex-end; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.month-bar > div { width: 100%; min-height: 2px; background: var(--accent2); border-radius: 4px 4px 0 0; }
.month.now .month-bar > div { background: var(--accent); }
.month-l { font-size: 10px; }
.row.fav .title { white-space: nowrap; }
.pick-list { max-height: 60vh; overflow-y: auto; }
.pick-text { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.sheet-box .input { margin: 0 0 8px; width: 100%; }
