/* ============================================================
   lossless — design tokens
   Dark, warm-neutral. Terracotta accent for CTA.
   Status colors: pending=neutral, active=blue, success=green, error=red
   8px spacing grid · radii: poster 8 · card 12 · button 8
   ============================================================ */
:root {
  /* surfaces — warm near-black */
  --bg:        #100e0d;
  --bg-grain:  #14110f;
  --surface:   #1a1715;
  --surface-2: #221e1b;
  --surface-3: #2b2622;
  --hover:     rgba(255,255,255,0.04);
  --hover-2:   rgba(255,255,255,0.06);

  /* lines */
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.11);
  --border-strong: rgba(255,255,255,0.16);

  /* text */
  --text:      #f1ece7;
  --text-2:    #a8a097;
  --text-3:    #756d64;
  --text-4:    #524b44;

  /* accent — terracotta */
  --accent:    #d9532c;
  --accent-hover: #e2683f;
  --accent-press: #c5471f;
  --accent-soft:  rgba(217,83,44,0.14);
  --accent-ring:  rgba(217,83,44,0.40);
  --on-accent: #fff7f3;

  /* status */
  --st-pending:   #8a827a;
  --st-pending-bg: rgba(255,255,255,0.06);
  --st-active:    #4d8df0;
  --st-active-bg:  rgba(77,141,240,0.15);
  --st-success:   #3fb27f;
  --st-success-bg: rgba(63,178,127,0.15);
  --st-error:     #e8585d;
  --st-error-bg:   rgba(232,88,93,0.15);

  /* type */
  --sans: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --bnav-h: 50px; /* высота мобильного навбара (без safe-area) — для отступов и позиции плеера */
  --r-poster: 8px;
  --r-card: 12px;
  --r-btn: 9px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 8px 24px -8px rgba(0,0,0,0.55);
  --shadow-pop: 0 16px 48px -12px rgba(0,0,0,0.7);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* gutter всегда зарезервирован: блокировка прокрутки фона при открытом плеере
   (player.jsx, body overflow:hidden) не убирает полосу и не сдвигает интерфейс. */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
  min-height: 100vh;
}

/* subtle warm vignette + grain so the dark isn't flat */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(217,83,44,0.07), transparent 55%),
    radial-gradient(100% 60% at 100% 0%, rgba(217,83,44,0.04), transparent 50%);
  z-index: 0;
}

::selection { background: var(--accent-soft); color: var(--text); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

/* ============================================================ LAYOUT */
#root { position: relative; z-index: 1; }
.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px 160px;
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 0 14px;
  background: linear-gradient(var(--bg) 62%, transparent);
  backdrop-filter: blur(2px);
}
.wordmark {
  display: flex; align-items: baseline; gap: 2px;
  font-family: var(--mono);
  font-weight: 700; font-size: 17px; letter-spacing: -0.02em;
  color: var(--text);
  cursor: pointer; border-radius: var(--r-btn); padding: 2px 6px; margin: -2px -6px;
  transition: color .15s, background .15s;
}
.wordmark:hover { color: var(--accent-hover); background: var(--accent-soft); }
.wordmark:hover .sub { color: var(--text-2); }
.wordmark:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wordmark .dot { color: var(--accent); }
.wordmark .sub {
  margin-left: 10px; font-family: var(--sans); font-weight: 500;
  font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3);
  align-self: center;
}
.topbar .spacer { flex: 1; }
.ghost-stat {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
}
.ghost-stat.on { color: var(--text-2); }
.ghost-stat .gs-ico { display: none; color: var(--text-4); }
.ghost-stat.on .gs-ico { color: var(--accent); }
.ghost-stat .dotled { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); }
.ghost-stat.on .dotled { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.1s ease-in-out infinite; }
.ghost-stat .gs-num { color: var(--text-2); font-weight: 600; }
.ghost-stat.on .gs-num { color: var(--accent); }

.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.section-head h2 {
  font-size: 13px; font-weight: 600; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3);
}
.section-head .rule { flex: 1; height: 1px; background: var(--border); align-self: center; }
.section-head .count { font-family: var(--mono); font-size: 12px; color: var(--text-4); }

/* ============================================================ SEARCH INPUT */
.search-wrap {
  position: sticky; top: 60px; z-index: 30;
  background: linear-gradient(var(--bg) 80%, transparent);
  padding-bottom: 8px;
}
.search-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 0 16px;
  height: 60px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface-2);
}
.search-box .ico { color: var(--text-3); flex-shrink: 0; transition: color .18s; }
.search-box:focus-within .ico { color: var(--accent); }
.search-box input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 17px; font-weight: 450;
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-3); }
.clear-btn {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--text-3); background: var(--hover);
  transition: all .15s;
  flex-shrink: 0;
}
.clear-btn:hover { color: var(--text); background: var(--hover-2); }
.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text-4);
  border: 1px solid var(--border-2); border-radius: 5px; padding: 2px 6px;
  flex-shrink: 0;
}
.alt-btn {
  display: grid; place-items: center;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-3); background: none;
  border: 1px solid var(--border-2);
  transition: all .15s;
  flex-shrink: 0;
}
.alt-btn:hover { color: var(--text); border-color: var(--text-3); background: var(--hover); }
.alt-btn.on {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.alt-btn.on:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ============================================================ BEST MATCH */
.best {
  margin-top: 16px;
  display: flex; align-items: center; gap: 18px;
  padding: 16px;
  border-radius: var(--r-card);
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 70%),
    var(--surface);
  border: 1px solid var(--border-2);
  position: relative;
  overflow: hidden;
}
.best .badge-tl {
  position: absolute; top: 14px; right: 14px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 6px;
}
.best .cover { width: 92px; height: 92px; border-radius: var(--r-poster); flex-shrink: 0; }
.best .meta { flex: 1; min-width: 0; }
.best .meta .kind {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 5px;
}
.best .meta .title { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.best .meta .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.best-flag { display: none; }

/* ============================================================ TABS */
.tabs {
  display: flex; gap: 4px;
  margin-top: 26px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--bg) 70%, transparent);
}
.tab {
  position: relative;
  padding: 11px 14px 13px;
  font-size: 14px; font-weight: 550; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
  transition: color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); }
.tab .n { font-family: var(--mono); font-size: 11px; color: var(--text-4); }
.tab.active .n { color: var(--accent); }
.tab .underline {
  position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}

/* ============================================================ RESULT LIST ITEM */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 10px 10px 10px;
  border-radius: 10px;
  transition: background .14s;
  position: relative;
}
.row:hover { background: var(--hover); }
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 66px; right: 10px; height: 1px;
  background: var(--border);
}
.row:hover::before, .row:hover + .row::before { background: transparent; }
.row .cover { width: 48px; height: 48px; border-radius: var(--r-poster); flex-shrink: 0; }
.row .cover.artist { border-radius: 50%; }
.row .info { flex: 1; min-width: 0; }
.row .info .t {
  font-size: 15px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .info .s { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* плашки качества (additional_tags из alt-поиска) */
.t-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.t-line .t, .t-line .title { flex: 0 1 auto; min-width: 0; }
.qtags { display: flex; gap: 6px; flex-shrink: 0; }
.qtag {
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 8px; border-radius: var(--r-pill);
  background: var(--st-pending-bg); color: var(--text-2);
  border: 1px solid var(--border-2);
}
.qtag.hires    { background: var(--st-success-bg); color: var(--st-success); border-color: transparent; }
.qtag.lossless { background: var(--st-active-bg);  color: var(--st-active);  border-color: transparent; }

/* реальный формат из пробы качества (container · bitrate) рядом с длительностью */
.qfmt {
  font-family: var(--mono); font-size: 9px; font-weight: 600; line-height: 1;
  padding: 2px 6px; border-radius: var(--r-pill); flex-shrink: 0;
  white-space: nowrap; letter-spacing: 0.2px;
  background: var(--st-pending-bg); color: var(--text-3);
  border: 1px solid var(--border-2);
}
.qfmt.ll    { background: var(--st-success-bg); color: var(--st-success); border-color: transparent; }
.qfmt.lossy { background: var(--st-error-bg);   color: var(--st-error);   border-color: transparent; }
/* плашка перенесена в текстовый блок — отдельной (третьей) строкой под «артист · альбом» */
.row .info .qfmt, .best .meta .qfmt { display: inline-flex; margin-top: 5px; }
.row .num { font-family: var(--mono); font-size: 12px; color: var(--text-4); width: 22px; text-align: right; flex-shrink: 0; }
.row-dur {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-3);
  flex-shrink: 0; font-variant-numeric: tabular-nums;
  min-width: 38px; text-align: right;
}
.best-dur { font-size: 13px; }

/* highlighted "best match" — first row of its tab */
.row.is-best {
  background: linear-gradient(90deg, var(--accent-soft), transparent 55%), var(--surface);
  border: 1px solid rgba(217,83,44,0.28);
  border-radius: 10px;
  margin-bottom: 6px;
}
.row.is-best:hover { background: linear-gradient(90deg, var(--accent-soft), transparent 50%), var(--surface-2); }
.row.is-best .num { color: var(--accent); display: flex; align-items: center; justify-content: center; }
.best-pin {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.tab-empty {
  padding: 20px 12px; text-align: center;
  font-size: 13px; color: var(--text-3);
}
.row.is-best + .row::before { background: transparent; }
.row.is-best .best-flag {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 3px; white-space: nowrap;
}

/* кликабельная строка альбома → открывает экран с треками */
.row.clickable { cursor: pointer; }
.row.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dl-wrap { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* счётчик скачанных треков альбома (N/M) рядом с кнопкой при частичной закачке */
.dl-count {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted, #8a8a90);
  white-space: nowrap;
}

/* ============================================================ ALBUM DETAIL */
.album-detail { margin-top: 18px; }
.dt-head {
  display: flex; align-items: center; gap: 16px;
  padding: 4px 4px 16px 4px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.dt-back { height: 34px; flex-shrink: 0; }
.dt-cover { width: 72px; height: 72px; border-radius: var(--r-poster); flex-shrink: 0; }
.dt-meta { flex: 1; min-width: 0; }
.dt-meta .kind {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-4); margin-bottom: 3px;
}
.dt-title {
  font-size: 19px; font-weight: 650; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dt-sub {
  font-size: 13px; color: var(--text-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================ DOWNLOAD BUTTON */
.dl {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; min-width: 124px;
  border-radius: var(--r-btn);
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-2);
  transition: all .15s var(--ease);
  flex-shrink: 0;
  position: relative; overflow: hidden; /* для заливки-прогресса .dl-fill (по радиусу кнопки) */
}
.dl:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.dl:active { transform: translateY(1px); }
.dl.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.dl.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.dl[data-state="queued"] { background: var(--st-pending-bg); border-color: var(--border-2); color: var(--text-2); cursor: default; }
.dl[data-state="queued"]:hover { background: var(--st-pending-bg); color: var(--text-2); }
.dl[data-state="downloading"] { background: var(--st-active-bg); border-color: rgba(77,141,240,0.3); color: var(--st-active); cursor: default; }
.dl[data-state="downloading"]:hover { background: var(--st-active-bg); color: var(--st-active); }
.dl[data-state="done"] { background: var(--st-success-bg); border-color: rgba(63,178,127,0.3); color: var(--st-success); cursor: pointer; }
.dl[data-state="done"]:hover { background: var(--st-success); color: #fff; border-color: var(--st-success); }
/* saving — идёт скачивание файла на устройство пользователя (loader) */
.dl[data-state="saving"] { background: var(--st-active-bg); border-color: rgba(77,141,240,0.3); color: var(--st-active); cursor: default; }
.dl[data-state="saving"]:hover { background: var(--st-active-bg); color: var(--st-active); }
/* dl-fill — прогресс-бар сохранения файла на устройство (заполняет кнопку слева направо) */
.dl-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; height: 100%;
  background: rgba(77,141,240,0.30);
  transition: width .2s var(--ease);
  pointer-events: none; z-index: 0;
}
.dl-fill.indet { width: 42%; animation: dl-indet 1.1s ease-in-out infinite; }
@keyframes dl-indet { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }
.dl > svg, .dl .lbl-full { position: relative; z-index: 1; } /* иконка/текст поверх заливки */
.dl[data-state="error"] { background: var(--st-error-bg); border-color: rgba(232,88,93,0.35); color: var(--st-error); }
.dl[data-state="error"]:hover { background: var(--st-error); color: #fff; border-color: var(--st-error); }
.dl[data-state="checking"] { background: var(--st-pending-bg); border-color: var(--border-2); color: var(--text-2); cursor: default; }
.dl[data-state="checking"]:hover { background: var(--st-pending-bg); color: var(--text-2); }
.dl[data-state="less"] { background: var(--st-error-bg); border-color: rgba(232,88,93,0.25); color: var(--st-error); cursor: pointer; opacity: 0.85; }
.dl[data-state="less"]:hover { background: var(--st-error); color: #fff; border-color: var(--st-error); opacity: 1; }
.dl .spin { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* icon-only variant for tight mobile rows handled via media query */

/* ============================================================ SKELETON */
.skel { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-row { display: flex; align-items: center; gap: 14px; padding: 10px; }
.skel-cover { width: 48px; height: 48px; border-radius: var(--r-poster); flex-shrink: 0; }

/* ============================================================ EMPTY STATES */
.empty {
  text-align: center; padding: 56px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty .glyph {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-3);
}
.empty .et { font-size: 15px; font-weight: 550; color: var(--text-2); }
.empty .es { font-size: 13.5px; color: var(--text-3); max-width: 320px; }
.empty .chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.chip {
  font-size: 13px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-pill); padding: 7px 13px;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--surface-2); }

/* Недавние запросы — над пустым экраном поиска. Чипы из истории + «Очистить». */
.recent { margin-top: 16px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.recent-title { font-size: 13px; font-weight: 550; color: var(--text-3); }
.recent-clear {
  font-size: 12.5px; color: var(--text-3); background: transparent; border: none;
  padding: 2px 4px; cursor: pointer; transition: color .15s;
}
.recent-clear:hover { color: var(--accent); }

/* Полки рекомендаций на главной */
.reco { margin-top: 20px; }
.reco-shelf { margin-bottom: 22px; scroll-margin-top: 70px; }
.reco-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 0; }
.recent .chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Липкие чипы-навигация: прыжок к категории. Горизонтальный скролл, скрытый скроллбар. */
.reco-chips {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; padding: 8px 0 10px; margin-bottom: 4px;
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.reco-chips::-webkit-scrollbar { display: none; }
.reco-chip {
  flex: 0 0 auto; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-2);
  padding: 7px 13px; border-radius: var(--r-pill);
  transition: background .14s, border-color .14s, color .14s;
}
.reco-chip:hover { color: var(--text); border-color: var(--accent); background: var(--surface-2); }
.reco-chip:active { transform: scale(0.97); }

.reco-shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.reco-seeall {
  flex: 0 0 auto; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-3); background: none; border: none; padding: 2px 0;
  transition: color .14s;
}
.reco-seeall:hover { color: var(--accent); }

/* Карусель обложек: горизонтальный scroll-snap ряд карточек, скрытый скроллбар. */
.reco-row {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.reco-row::-webkit-scrollbar { display: none; }

.reco-card { flex: 0 0 150px; width: 150px; scroll-snap-align: start; cursor: pointer; }
.reco-card-cover { position: relative; width: 100%; }
.reco-card-cover .cover { width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: var(--r-card); }
.reco-card-play {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%) translateY(4px);
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity .15s, transform .15s;
}
.reco-card:hover .reco-card-play,
.reco-card:focus-visible .reco-card-play,
.reco-card.playing .reco-card-play { opacity: 1; transform: translateX(-50%) translateY(0); }
.reco-card-play:active { transform: translateX(-50%) scale(0.92); }
.reco-card-fav {
  position: absolute; top: 7px; right: 7px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(16,14,13,0.55); color: var(--text); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .15s, color .14s;
}
.reco-card:hover .reco-card-fav, .reco-card:focus-within .reco-card-fav { opacity: 1; }
.reco-card-fav.on { opacity: 1; color: var(--accent); }
.reco-card-fav:active { transform: scale(0.9); }
.reco-card-title {
  margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reco-card-sub {
  margin-top: 2px; font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-head .dt-meta .kind { color: var(--accent); }
@media (hover: none) {
  .reco-card-play { opacity: 0.92; transform: translateX(-50%) translateY(0); } /* на тач — всегда видна */
  .reco-card-fav { opacity: 0.85; }
}
@media (max-width: 560px) {
  .reco-card { flex-basis: 132px; width: 132px; }
}

/* ============================================================ DROPZONE */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  padding: 36px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
  transition: all .2s var(--ease);
  cursor: pointer;
  position: relative;
}
.dropzone:hover { border-color: var(--text-4); background: var(--surface-2); }
.dropzone.over {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-soft) inset;
}
.dropzone.error { border-color: var(--st-error); background: var(--st-error-bg); }
.dropzone.loading { pointer-events: none; }
.dz-ico {
  width: 54px; height: 54px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-2);
  color: var(--text-2);
  transition: all .2s;
}
.dropzone.over .dz-ico { background: var(--accent); color: var(--on-accent); border-color: var(--accent); transform: translateY(-2px); }
.dropzone.error .dz-ico { color: var(--st-error); border-color: rgba(232,88,93,0.4); }
.dz-title { font-size: 15.5px; font-weight: 600; color: var(--text); }
.dz-title .lnk { color: var(--accent); }
.dz-sub { font-size: 13px; color: var(--text-3); }
.dz-btn {
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 18px; border-radius: var(--r-btn);
  background: var(--surface-3); border: 1px solid var(--border-2);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}
.dz-btn:hover { border-color: var(--accent); color: var(--text); }
.dl { white-space: nowrap; }

/* format hint */
.fmt-hint {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.fmt-hint .lbl { font-size: 12px; color: var(--text-3); margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.fmt-hint code, .fmt-line {
  display: block; font-family: var(--mono); font-size: 12.5px; color: var(--text-2);
  line-height: 1.7;
}
.fmt-line .a { color: var(--text); }
.fmt-line .dash { color: var(--accent); margin: 0 6px; }

/* ============================================================ PLAYLIST TABLE */
.pl-panel { margin-top: 18px; }
.pl-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.pl-progress-wrap { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 12px; }
.progress {
  flex: 1; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden;
  position: relative;
}
.progress .bar {
  position: absolute; inset: 0 auto 0 0; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 99px;
  transition: width .4s var(--ease);
}
.progress .bar.alldone { background: linear-gradient(90deg, var(--st-success), #58c98f); }
.pl-progress-txt { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }

.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-4); padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.table thead th.c-num { width: 44px; text-align: right; }
.table thead th.c-status { width: 150px; }
.table thead th.c-act { width: 44px; }
.table tbody tr { border-bottom: 1px solid var(--border); transition: background .14s; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.row-error { background: var(--st-error-bg); }
.table tbody tr.row-error:hover { background: rgba(232,88,93,0.2); }
.table td { padding: 11px 12px; font-size: 14px; vertical-align: middle; }
.table td.c-num { font-family: var(--mono); font-size: 12px; color: var(--text-4); text-align: right; }
.table td.c-artist { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.table td.c-track { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.table td.c-act { text-align: center; }
.row-del {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  color: var(--text-4); transition: all .15s; margin: 0 auto;
}
.row-del:hover { color: var(--st-error); background: var(--st-error-bg); }

/* ============================================================ STATUS BADGE */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px 0 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.parsed   { background: var(--st-pending-bg); color: var(--text-2); }
.badge.parsed .bdot { background: var(--st-pending); }
.badge.searching { background: var(--st-pending-bg); color: var(--text-2); }
.badge.searching .bdot { background: var(--st-pending); animation: pulse 1.1s ease-in-out infinite; }
.badge.queued   { background: var(--st-pending-bg); color: var(--text-2); }
.badge.queued .bdot { background: var(--st-pending); }
.badge.downloading { background: var(--st-active-bg); color: var(--st-active); }
.badge.downloading .bdot { background: var(--st-active); }
.badge.done     { background: var(--st-success-bg); color: var(--st-success); }
.badge.done .bdot { background: var(--st-success); }
.badge.error    { background: var(--st-error-bg); color: var(--st-error); }
.badge.error .bdot { background: var(--st-error); }
.badge.partial { background: var(--st-active-bg); color: var(--st-active); }
.badge.partial .bdot { background: var(--st-active); }
.badge.incomplete { background: var(--st-error-bg); color: var(--st-error); }
.badge.incomplete .bdot { background: var(--st-error); }
.badge .spin { animation: spin .7s linear infinite; }

/* ---- панель незавершённых загрузок ---- */
.incomplete-panel .inc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line, rgba(255,255,255,0.06));
}
.incomplete-panel .inc-row:last-child { border-bottom: none; }
.inc-meta { flex: 1; min-width: 0; }
.inc-title {
  font-size: 14px; font-weight: 600; color: var(--text-1, #fff);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inc-sub { font-size: 12px; color: var(--text-4, #888); margin-top: 2px; }
.inc-err { color: var(--st-error); }
@keyframes pulse { 0%,100%{ opacity: 1 } 50%{ opacity: .3 } }

.err-ico { color: var(--st-error); display: inline-grid; place-items: center; position: relative; }
.tip { position: relative; display: inline-flex; }
.tip .tipbox {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: #2a2421; color: var(--text); font-size: 12px; font-weight: 500;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--border-2); box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: all .15s; z-index: 50;
}
.tip:hover .tipbox { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================ TOASTS */
.toast-stack {
  position: fixed; z-index: 100;
  right: 22px; bottom: 22px;
  display: flex; flex-direction: column; gap: 10px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 13px 14px;
  box-shadow: var(--shadow-pop);
  animation: toast-in .32s var(--ease);
  position: relative; overflow: hidden;
}
.toast.out { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px) scale(.97); } }
.toast .ti {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
}
.toast.success .ti { background: var(--st-success-bg); color: var(--st-success); }
.toast.error .ti { background: var(--st-error-bg); color: var(--st-error); }
.toast.info .ti { background: var(--st-active-bg); color: var(--st-active); }
.toast .tc { flex: 1; min-width: 0; }
.toast .tt { font-size: 13.5px; font-weight: 600; color: var(--text); }
.toast .ts { font-size: 12.5px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast .tx { color: var(--text-4); transition: color .15s; flex-shrink: 0; }
.toast .tx:hover { color: var(--text-2); }
.toast .tprog { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--accent); animation: tprog 3.4s linear forwards; }
.toast.success .tprog { background: var(--st-success); }
.toast.error .tprog { background: var(--st-error); }
@keyframes tprog { from { width: 100%; } to { width: 0%; } }

/* fade-in for lists */
.fade-in { animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

.cover { overflow: hidden; }
.cover-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: inherit;
}
.cover-letter {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* mobile download icon button (hidden on desktop) */
.dl .lbl-full { display: inline; }

/* ============================================================ RESPONSIVE */
@media (max-width: 767px) {
  /* hide page scrollbar on mobile — app-like look (scroll still works) */
  html { scrollbar-width: none; }
  html::-webkit-scrollbar,
  body::-webkit-scrollbar { display: none; }

  .app { padding: 0 12px 120px; }
  .topbar { padding: 11px 0 9px; gap: 10px; }
  .wordmark { font-size: 15px; }
  .wordmark .sub { display: none; }
  /* topbar — app-like: без слова lossless и без подписей у кнопок */
  .topbar .wordmark { display: none; }
  .topbar .dz-btn .lbl-full { display: none; }
  .ghost-stat { font-size: 11.5px; gap: 5px; flex-shrink: 0; }
  .ghost-stat .gs-ico { display: inline-flex; }
  .ghost-stat .dotled { display: none; }
  .ghost-stat .gs-label { display: none; }

  .section { margin-top: 12px; }
  .section-head { margin-bottom: 8px; }
  .section-head h2 { font-size: 11px; letter-spacing: 0.08em; }

  /* search */
  .search-wrap { top: 0; } /* топбар на мобильном скрыт — поле липнет к верху */
  .app.home-mode .search-wrap { display: none; } /* на главной поле поиска убрано (только мобильный) */
  /* Подборки — только на «Главной»: во вкладке «Поиск» (нет home-mode) их прячем,
     чтобы не мешали недавним запросам/выдаче. На десктопе правило не действует. */
  .app:not(.home-mode) .reco { display: none; }
  .search-box { height: 48px; padding: 0 13px; gap: 11px; border-radius: 12px; }
  .search-box .ico { width: 18px; height: 18px; }
  .search-box input { font-size: 16px; }
  .kbd { display: none; }

  /* best match — compact row, like a list item but subtly highlighted */
  .best {
    display: flex; flex-wrap: nowrap; align-items: center; gap: 11px;
    padding: 8px 10px; margin-top: 12px; border-radius: 10px;
    background: linear-gradient(90deg, var(--accent-soft), transparent 60%), var(--surface);
    border: 1px solid rgba(217,83,44,0.28);
  }
  .best .badge-tl { display: none; }
  .best .meta .kind { display: none; }
  .best .cover { width: 44px; height: 44px; }
  .best .meta { flex: 1 1 0; min-width: 0; }
  .best-flag {
    display: flex; align-items: center; gap: 5px;
    font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 2px;
  }
  .best .meta .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .best .meta .sub { font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .best .dl { width: 40px; height: 40px; padding: 0; order: 0; min-width: 0; flex-shrink: 0; }
  .best .dl svg { width: 17px; height: 17px; }

  /* tabs */
  .tabs { margin-top: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 9px 11px 11px; font-size: 13px; gap: 6px; }
  .tab svg { width: 14px; height: 14px; }

  /* result rows — denser */
  .row { gap: 11px; padding: 7px 4px; }
  .row .num { display: none; }
  .row .cover { width: 44px; height: 44px; }
  .row .info .t { font-size: 14px; white-space: nowrap; }
  .row .info .s { font-size: 12px; }
  .dl { min-width: 0; width: 40px; height: 40px; padding: 0; border-radius: 8px; }
  .dl svg { width: 17px; height: 17px; }
  .row-dur { font-size: 11.5px; min-width: 32px; }
  .dl .lbl-full { display: none; }

  /* album detail — compact header */
  .album-detail { margin-top: 12px; }
  .dt-head { gap: 11px; padding: 2px 2px 12px 2px; flex-wrap: wrap; }
  .dt-back { height: 36px; order: -1; }
  .dt-cover { width: 56px; height: 56px; }
  .dt-title { font-size: 16px; }
  .dt-sub { font-size: 12px; }
  .row + .row::before { left: 55px; right: 0; }
  .row.is-best { padding: 8px 10px; margin-bottom: 7px; }

  /* empty states — tighter */
  .empty { padding: 18px 16px; gap: 9px; }
  .empty .glyph { width: 46px; height: 46px; border-radius: 13px; }
  .empty .glyph svg { width: 20px; height: 20px; }
  .empty .et { font-size: 14px; }
  .empty .es { font-size: 12.5px; max-width: 280px; }
  .chip { font-size: 12px; padding: 6px 11px; }

  /* dropzone — compact */
  .dropzone { padding: 16px 16px; gap: 10px; border-radius: 13px; }
  .dz-ico { width: 44px; height: 44px; border-radius: 11px; }
  .dz-ico svg { width: 22px; height: 22px; }
  .dz-title { font-size: 14px; }
  .dz-sub { font-size: 12px; }
  .dz-btn { height: 36px; padding: 0 14px; font-size: 12.5px; }
  .fmt-hint { padding: 11px 13px; margin-top: 10px; }
  .fmt-hint .lbl { font-size: 11px; margin-bottom: 6px; }
  .fmt-line { font-size: 11px; line-height: 1.6; }

  /* playlist -> cards (compact) */
  .table, .table thead, .table tbody, .table tr, .table td, .table th { display: block; }
  .table thead { display: none; }
  .table tbody tr {
    background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
    padding: 9px 11px; margin-bottom: 7px;
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "num track status" "num artist status"; gap: 1px 10px; align-items: center;
  }
  .table tbody tr:hover { background: var(--surface); }
  .table td { padding: 0; border: none; }
  .table td.c-num { grid-area: num; align-self: center; font-size: 12px; width: auto; color: var(--text-4); }
  .table td.c-track { grid-area: track; max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
  .table td.c-artist { grid-area: artist; max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
  .table td.c-status { grid-area: status; }
  .table td.c-act { display: none; }

  .badge { height: 23px; font-size: 11px; padding: 0 8px 0 7px; gap: 5px; }

  /* playlist toolbar — stacked, compact */
  .pl-toolbar { gap: 8px; margin-bottom: 11px; }
  .pl-progress-wrap { order: 3; flex-basis: 100%; min-width: 0; }
  .pl-progress-txt { font-size: 11px; }
  .pl-toolbar .dl { flex: 1; min-width: 0; height: 42px; padding: 0 14px; }
  .pl-toolbar .dl .lbl-full { display: inline; }
  .pl-toolbar .dz-btn { height: 42px; }

  .toast-stack { right: 10px; left: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; }
  .toast { padding: 11px 12px; gap: 10px; border-radius: 11px; }
  .toast .ti { width: 26px; height: 26px; border-radius: 7px; }
  .toast .tt { font-size: 13px; }
  .toast .ts { font-size: 11.5px; }
}

/* very small phones */
@media (max-width: 380px) {
  .app { padding: 0 10px 120px; }
  .best .cover { width: 40px; height: 40px; }
  .row .cover { width: 40px; height: 40px; }
  .row + .row::before { left: 51px; }
  .tab { padding: 9px 9px 11px; }
  .pl-toolbar .dl, .pl-toolbar .dz-btn { padding: 0 10px; font-size: 12.5px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .app { max-width: 760px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
}

/* ============================================================ МОЯ БИБЛИОТЕКА (сердечко) */
.heart-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: transparent; border: none; border-radius: var(--r-btn);
  color: var(--text-3); cursor: pointer;
  transition: color .15s, background .15s, transform .1s;
}
.heart-btn:hover { color: var(--text); background: var(--hover-2); }
.heart-btn.on { color: var(--accent); }
.heart-btn.on:hover { color: var(--accent-hover); }
.heart-btn:active { transform: scale(0.9); }

.mylib-btn.active { border-color: var(--accent-ring); color: var(--accent); }
.mylib-count {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--r-pill); padding: 1px 7px; margin-left: 2px;
}

.mylib-cover {
  width: 92px; height: 92px; border-radius: var(--r-poster); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--accent-press), #6d2812);
  color: var(--on-accent);
}
.mylib-actions { gap: 8px; }
.mylib-src {
  font-family: var(--mono); font-size: 10.5px; white-space: nowrap; flex-shrink: 0;
  border-radius: var(--r-pill); padding: 2px 8px;
  background: var(--st-pending-bg); color: var(--st-pending);
}
.mylib-src.on { background: var(--st-success-bg); color: var(--st-success); }
.mylib-src.dl { background: var(--st-active-bg); color: var(--st-active); }
.mylib-now { color: var(--accent); }

/* играющая строка (библиотека и результаты) */
.row.playing { background: var(--accent-soft); }

/* постер-кнопка воспроизведения на треках */
.cover-play { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; border-radius: var(--r-poster); }
.cover-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cover-play .cp-ico {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); color: #fff; border-radius: var(--r-poster);
  opacity: 0; transition: opacity .15s;
}
.cover-play:hover .cp-ico, .cover-play.current .cp-ico { opacity: 1; }
@media (hover: none) { .cover-play .cp-ico { opacity: 0.85; } } /* на тач — всегда видна */

/* ============================================================ MINI PLAYER */
.mini-player {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(960px, calc(100vw - 20px));
  display: flex; align-items: center; gap: 12px;
  background: rgba(26, 23, 21, 0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-2); border-radius: var(--r-card);
  padding: 10px 12px;
  box-shadow: var(--shadow-pop);
}
.mp-cover { width: 42px; height: 42px; border-radius: var(--r-poster); flex-shrink: 0; }
.mp-meta { min-width: 0; flex: 0 1 220px; }
.mp-title { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
/* Убираем серую вспышку-подсветку от тапа на всех кнопках плеера. */
.mp-btn, .fp-btn, .fp-act, .fp-minus-btn, .fp-icon-btn { -webkit-tap-highlight-color: transparent; }
.mp-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; border-radius: var(--r-btn);
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: color .15s, background .15s;
}
.mp-btn:disabled { color: var(--text-4); cursor: default; }
/* процент сохранения файла на устройство внутри кнопки скачивания плеера */
.mp-dl-pct { font-family: var(--mono); font-size: 10.5px; font-weight: 700; line-height: 1; color: var(--st-active); }
.mp-play { background: var(--accent); color: var(--on-accent); }
/* Подсветку фона даём только устройствам с настоящим указателем: на тач-экранах
   :hover «залипает» после тапа и остаётся, пока не тапнешь в другое место. */
@media (hover: hover) {
  .mp-btn:hover:not(:disabled) { color: var(--text); background: var(--hover-2); }
  .mp-play:hover:not(:disabled) { background: var(--accent-hover); color: var(--on-accent); }
}
.mp-seek-wrap { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.mp-time { font-family: var(--mono); font-size: 11px; color: var(--text-3); flex-shrink: 0; min-width: 34px; text-align: center; }
/* Видимая полоса живёт в псевдоэлементе дорожки, а сам <input> высокий и прозрачный
   (height задаётся ниже под каждый контекст) — так палец попадает по всей высоте
   элемента, а полоса остаётся тонкой. Бегунок центрируется по дорожке через margin-top. */
.mp-seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: transparent; cursor: pointer; outline: none;
}
.mp-seek::-webkit-slider-runnable-track {
  height: 4px; border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--accent) var(--mp-fill, 0%), var(--surface-3) var(--mp-fill, 0%));
}
.mp-seek::-moz-range-track {
  height: 4px; border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--accent) var(--mp-fill, 0%), var(--surface-3) var(--mp-fill, 0%));
}
.mp-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%; margin-top: -4px;
  background: var(--text); border: none; cursor: pointer;
}
.mp-seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: none; cursor: pointer; }
.mp-seek:disabled { cursor: default; opacity: 0.55; }
.mp-seek:disabled::-webkit-slider-thumb { background: var(--text-4); }
.mp-seek:disabled::-moz-range-thumb { background: var(--text-4); }
.mp-close { margin-left: 2px; }
.mp-btn.on { color: var(--accent); }

/* На десктопе обёртка постер+мета прозрачна для flex (поведение прежнее),
   тонкая линия прогресса и нижняя навигация спрятаны. На мобильном .mp-center тоже
   прозрачна — внутри только play/next, которые ведут себя как прежде. */
.mp-tap { display: contents; }
.mp-center { display: contents; }
.mp-progress { display: none; }
.bottom-nav { display: none; }

/* ---- Десктопный мини-бар: на всю ширину, постер+название слева, полный кластер
   кнопок по центру, под ними тонкая полоса прогресса; справа — закрыть. ---- */
.mini-player.mp-desktop {
  left: 0; right: 0; width: auto; transform: none;
  bottom: 0;
  border: none; border-top: 1px solid var(--border-2); border-radius: 0;
  display: grid; grid-template-columns: 1fr minmax(auto, 720px) 1fr;
  align-items: center; gap: 16px; padding: 9px 20px;
}
.mp-desktop .mp-tap { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.mp-desktop .mp-meta { flex: 1 1 auto; }
.mp-desktop .mp-center {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 0; width: 100%;
}
.mp-desktop .mp-controls { gap: 6px; }
.mp-desktop .mp-close { justify-self: end; }
/* Тонкая кликабельная полоса прогресса под кнопками: точка-«кружок» появляется на
   текущей позиции воспроизведения при наведении. */
.mp-seekline { display: flex; align-items: center; gap: 8px; width: 100%; }
.mp-seek-line { height: 4px; }
.mp-seek-line::-webkit-slider-thumb { opacity: 0; transition: opacity .15s; }
.mp-seek-line:hover:not(:disabled)::-webkit-slider-thumb { opacity: 1; }
.mp-seek-line::-moz-range-thumb { opacity: 0; transition: opacity .15s; }
.mp-seek-line:hover:not(:disabled)::-moz-range-thumb { opacity: 1; }

/* контент и тосты не прячутся под плеером */
.app.player-open { padding-bottom: 150px; }
.app.player-open .toast-stack { bottom: calc(86px + env(safe-area-inset-bottom)); }

/* ============================================================ FULL PLAYER (полноэкранное окно, мобильный) */
.full-player {
  position: fixed; inset: 0; z-index: 95;
  pointer-events: none; visibility: hidden;
}
/* оверлей прозрачный — при сдвиге листа сразу виден статичный задник (прокрутка
   фона заблокирована эффектом в player.jsx). Непрозрачен только сам .fp-sheet. */
.full-player.open { pointer-events: auto; visibility: visible; }
.fp-sheet {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .32s var(--ease);
  overflow-y: auto;
}
.full-player.open .fp-sheet { transform: translateY(0); }
.fp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 10px; flex-shrink: 0;
}
.fp-grip { width: 38px; height: 4px; border-radius: var(--r-pill); background: var(--border-strong); }
.fp-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: var(--r-btn);
  background: transparent; color: var(--text-2); cursor: pointer;
}
@media (hover: hover) { .fp-icon-btn:hover { color: var(--text); background: var(--hover-2); } }
.fp-poster {
  display: flex; justify-content: center; align-items: center;
  height: min(78vw, 320px); margin: 4vh 0 max(4vh, 24px);
}
.fp-poster .cover {
  width: min(78vw, 320px); height: min(78vw, 320px);
  border-radius: var(--r-card); box-shadow: var(--shadow-pop);
}
/* Текст песни — панель по кнопке-микрофону, рендерится на месте обложки. Высота
   контейнера фиксирована (= обложке), поэтому открытие текста не сдвигает плеер. */
.fp-poster-lyrics { align-items: stretch; }
.fp-poster-lyrics .lyrics-panel { height: 100%; }
.lyrics-panel {
  width: 100%; height: min(46vh, 360px); overflow-y: auto;
  /* Отступ сверху опускает первую строку ниже зоны затухания, чтобы её не прятало в тень. */
  text-align: center; padding: 44px 6px 32px;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 7%, #000 88%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 7%, #000 88%, transparent);
  /* Никакого выделения/подсветки от тапа: только оранжевая active-строка по таймлайну. */
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
.lyrics-msg { display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 15px; }
.lyrics-plain { white-space: pre-wrap; color: var(--text-2); font-size: 16px; line-height: 1.7; }
.lyrics-line {
  font-size: 19px; font-weight: 650; line-height: 1.35;
  color: var(--text-4); padding: 7px 4px; transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}
.lyrics-line.seekable { cursor: pointer; }
.lyrics-line.active { color: var(--accent); }
.fp-info { text-align: center; margin-bottom: 22px; position: relative; }
.fp-title { font-size: 21px; font-weight: 700; color: var(--text); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 48px; }
.fp-artist { font-size: 15px; color: var(--text-3); margin-top: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-quality {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em;
  color: var(--text-3); text-align: center; margin: -14px 0 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fp-seek-wrap { margin-bottom: 8px; }
/* Полноэкранный плеер — здесь перематывают пальцем. Элемент высокий (большая тач-зона),
   видимая дорожка тонкая (6px), бегунок центрируется по ней. */
.fp-seek { height: 22px; }
.fp-seek::-webkit-slider-runnable-track { height: 6px; }
.fp-seek::-moz-range-track { height: 6px; }
.fp-seek::-webkit-slider-thumb { width: 15px; height: 15px; margin-top: -4.5px; }
.fp-seek::-moz-range-thumb { width: 15px; height: 15px; }
.fp-times { display: flex; justify-content: space-between; margin-top: 7px; }
.fp-times .mp-time { min-width: 0; }
.fp-controls {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 18px 0 26px;
}
.fp-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer;
  transition: background .15s, color .15s;
}
.fp-btn-sm { width: 44px; height: 44px; color: var(--text-2); }
.fp-btn.on { color: var(--accent); }
.fp-btn:disabled { color: var(--text-4); cursor: default; }
.fp-play { width: 68px; height: 68px; background: var(--accent); color: var(--on-accent); }
@media (hover: hover) { .fp-play:hover { background: var(--accent-hover); } }
.fp-actions {
  display: flex; align-items: center; justify-content: space-around;
  border-top: 1px solid var(--border); padding-top: 16px; margin-top: auto;
}
.fp-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border: none; border-radius: var(--r-btn);
  background: transparent; color: var(--text-2); cursor: pointer;
}
@media (hover: hover) { .fp-act:hover:not(:disabled) { color: var(--text); background: var(--hover-2); } }
.fp-act.on { color: var(--accent); }
.fp-act:disabled { color: var(--text-4); cursor: default; }
.fp-queue {
  margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.fp-qrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: none; background: transparent; cursor: pointer;
  padding: 8px; border-radius: var(--r-btn); text-align: left; color: var(--text-2);
}
.fp-qrow:hover { background: var(--hover); }
.fp-qrow.now { color: var(--accent); }
.fp-qcover { width: 36px; height: 36px; border-radius: var(--r-poster); flex-shrink: 0; }
.fp-qmeta { min-width: 0; flex: 1 1 auto; }
.fp-qtitle { font-size: 13.5px; font-weight: 600; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-qartist { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Очередь отдельным листом снизу (мобильный). Выезжает поверх плеера на ~60%;
   над ней — задник для тапа-закрытия. Свайп вниз / тап выше сворачивают. ---- */
.fp-queue-sheet { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.fp-queue-sheet.open { pointer-events: auto; }
.fp-queue-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.28);
  opacity: 0; transition: opacity .32s var(--ease);
}
.fp-queue-sheet.open .fp-queue-backdrop { opacity: 1; }
.fp-queue-panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  display: flex; flex-direction: column; align-items: stretch;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: var(--r-card) var(--r-card) 0 0;
  box-shadow: 0 -12px 32px -16px rgba(0, 0, 0, 0.8);
  padding: 8px 20px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .32s var(--ease);
}
.fp-queue-sheet.open .fp-queue-panel { transform: translateY(0); }
.fp-queue-panel .fp-grip { margin: 2px auto 10px; flex-shrink: 0; }
.fp-queue-panel .fp-queue-head { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 0 4px 8px; }
.fp-queue-panel .fp-queue { margin-top: 0; border-top: none; padding-top: 0; }

/* Минус (студийный инструментал). Значок-переключатель у правого края названия трека;
   показывается только когда минус готов. Абсолютная позиция — чтобы появление/смена
   состояния не двигали ни название, ни кнопки воспроизведения. */
.fp-minus-btn {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s;
}
@media (hover: hover) { .fp-minus-btn:hover { color: var(--text); background: var(--hover-2); } }
.fp-minus-btn.on { color: var(--accent); background: var(--hover-2); }

/* ---- Десктопный полноэкранный плеер: оверлей на весь экран. Очередь слева,
   управление по центру, по кнопке-микрофону справа выезжает синхронный текст. ---- */
/* .fp-main прозрачна на мобильном (дети — прямые flex-элементы листа, как раньше);
   на десктопе — центральная колонка-стек. */
.fp-main { display: contents; }
/* оверлей прозрачный (как на мобильном): при сдвиге листа сразу виден задник,
   без тёмной пелены во время сворачивания. Непрозрачен только сам .fp-sheet. */
.fp-desktop .fp-sheet {
  inset: 0; padding: 0; overflow: hidden; opacity: 1;
  /* выезжает снизу при открытии и уезжает вниз при сворачивании (.closing); третья
     колонка-текст растёт из нулевой ширины (0fr→1fr) — «выезжает» вправо. */
  transform: translateY(100%);
  transition: transform .32s var(--ease), grid-template-columns .32s var(--ease);
  display: grid; grid-template-columns: 320px minmax(0, 1fr) 0fr; background: var(--bg);
}
.fp-desktop.open .fp-sheet { transform: translateY(0); }
.fp-desktop.open.closing .fp-sheet { transform: translateY(100%); }
.fp-desktop.fp-with-lyrics .fp-sheet { grid-template-columns: 320px minmax(0, 1fr) 1fr; }
.fp-desktop .fp-main {
  display: flex; flex-direction: column; align-items: stretch;
  overflow-y: auto; padding: 22px 32px calc(28px + env(safe-area-inset-bottom));
  max-width: 640px; width: 100%; margin: 0 auto;
}
.fp-desktop .fp-grip { display: none; }
.fp-desktop .fp-poster { margin: 2vh 0 24px; }
.fp-desktop .fp-poster .cover { width: 280px; height: 280px; }
/* левая колонка — очередь (всегда видна) */
.fp-queue-col {
  border-right: 1px solid var(--border); background: var(--surface);
  overflow-y: auto; padding: 18px 12px;
  display: flex; flex-direction: column;
}
.fp-queue-head { font-size: 13px; font-weight: 700; color: var(--text-2); padding: 4px 8px 10px; }
.fp-queue-col .fp-queue { margin-top: 0; border-top: none; padding-top: 0; }
/* правая колонка — синхронный текст по кнопке-микрофону. Всегда смонтирована, но при
   закрытом тексте колонка имеет нулевую ширину — рамку/паддинг вешаем только когда
   текст открыт, иначе осталась бы висеть вертикальная линия в 1px. */
.fp-lyrics-col { overflow: hidden; display: flex; }
.fp-desktop.fp-with-lyrics .fp-lyrics-col { border-left: 1px solid var(--border); padding: 24px; }
.fp-lyrics-col .lyrics-panel { width: 100%; height: 100%; opacity: 0; transition: opacity .32s var(--ease); }
.fp-desktop.fp-with-lyrics .fp-lyrics-col .lyrics-panel { opacity: 1; }

/* ============================================================ BOTTOM NAV (мобильная навигация) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  align-items: stretch;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--border), 0 -10px 28px -16px rgba(0,0,0,0.8);
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--bnav-h); border: none; background: transparent; cursor: pointer;
  color: var(--text-3); transition: color .15s;
}
.bn-item.active { color: var(--accent); }
.bn-label { font-size: 10px; font-weight: 550; letter-spacing: 0.01em; }
.bn-ico { position: relative; display: inline-flex; }
/* бейдж активных загрузок в правом-верхнем углу иконки «Поиск» (как уведомления) */
.bn-badge {
  position: absolute; top: -5px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent);
  font: 700 10px/16px var(--mono); text-align: center;
}

/* ============================================================ PROFILE */
/* Профиль: шапка-герой + сгруппированные секции, центрированная колонка. */
.profile-screen { max-width: 560px; margin: 18px auto 0; }

.profile-head {
  display: flex; align-items: center; gap: 16px;
  padding: 4px 4px 18px 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.profile-head .dt-back { margin-right: 2px; }
.profile-avatar {
  width: 88px; height: 88px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--sans); font-weight: 700; font-size: 36px; line-height: 1;
  color: var(--accent);
  background: radial-gradient(circle at 30% 25%, var(--accent-soft), var(--surface-3));
  border: 1px solid var(--border-2);
}
.profile-id { min-width: 0; }
.profile-email { font-family: var(--mono); font-size: 15px; color: var(--text); word-break: break-all; }
.profile-meta { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* Карточка-секция с заголовком (Плейлисты / Настройки). */
.profile-section {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-card);
  padding: 6px 14px; margin-bottom: 14px;
}
.profile-section-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-4); padding: 12px 0 6px;
}

/* Строка действия: иконка + текст слева, кнопка справа; разделители между строками. */
.profile-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0;
}
.profile-row + .profile-row { border-top: 1px solid var(--border); }
.pr-info { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.pr-info .pr-ico { color: var(--text-2); flex-shrink: 0; margin-top: 1px; }
.pr-text { min-width: 0; }
.pr-title { font-size: 14px; font-weight: 600; color: var(--text); }
.pr-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.pr-action-wrap { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.pr-action { height: 36px; flex-shrink: 0; }
.import-prog { font-family: var(--mono); font-size: 12px; color: var(--text-4); white-space: nowrap; }

/* Выход — отдельная destructive-кнопка внизу. */
.profile-logout {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px; margin-top: 4px;
  border-radius: var(--r-btn); font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--st-error); border: 1px solid var(--border-2);
  transition: background .15s, border-color .15s;
}
.profile-logout.danger:hover { background: rgba(232,88,93,0.10); border-color: var(--st-error); }
.profile-logout:focus-visible { outline: 2px solid var(--st-error); outline-offset: 2px; }

/* Настройки отображения: строка «лейбл + переключатель» внутри секции. */
.profile-setting {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0;
}
.ps-text { min-width: 0; }
.ps-label { font-size: 14px; font-weight: 600; color: var(--text); }
.ps-sub { display: block; font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.ps-toggle {
  position: relative; flex-shrink: 0; width: 40px; height: 22px; padding: 0;
  border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface-3);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.ps-toggle.on { background: var(--accent); border-color: var(--accent); }
.ps-knob {
  position: absolute; top: 50%; left: 2px; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.ps-toggle.on .ps-knob { left: 20px; }
.ps-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 767px) {
  /* нижняя навигация видна только на мобильном */
  .bottom-nav { display: flex; }
  /* Пока открыта программная клавиатура (поле поиска в фокусе) — прячем нижнюю
     навигацию. iOS позиционирует position:fixed относительно layout-вьюпорта, и при
     скролле с открытой клавиатурой навбар «дёргается» к визуальному вьюпорту над
     клавиатурой. Во время ввода таб-бар всё равно не нужен. */
  .app.kb-open .bottom-nav { display: none; }
  /* хедер на мобильном пуст (всё переехало в нижнюю навигацию / бейдж) — скрываем */
  .topbar { display: none; }
  .dt-back { display: none; }
  /* высота bottom-nav (--bnav-h) учитывается в позиции плеера и отступах контента */
  .app { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); }

  /* мини-плашка на всю ширину, прижата к нижней навигации, разделение тенью (без зазора) */
  .mini-player {
    left: 0; right: 0; width: auto; transform: none;
    bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom));
    border: none; border-radius: 0;
    background: rgba(26, 23, 21, 0.97);
    padding: 9px 12px; gap: 11px;
    box-shadow: 0 -1px 0 var(--border), 0 -8px 24px -14px rgba(0,0,0,0.8);
  }
  /* тонкая линия прогресса = верхний край плашки, информативная (не кликабельна) */
  .mp-progress {
    display: block; position: absolute; top: 0; left: 0; height: 2.5px;
    width: var(--p, 0%); background: var(--accent); pointer-events: none;
    transition: width .25s linear;
  }
  .mp-tap { display: flex; align-items: center; gap: 11px; flex: 1 1 auto; min-width: 0; cursor: pointer; }
  .mp-meta { flex: 1 1 auto; }
  /* Крупные кнопки с заметным зазором — чтобы легко попадать пальцем на телефоне. */
  .mp-controls { margin-left: auto; gap: 18px; }
  .mp-controls .mp-btn { width: 52px; height: 52px; }
  .mp-controls .mp-btn svg { width: 26px; height: 26px; }
  .mp-controls .mp-play svg { width: 28px; height: 28px; }
  /* на мобильном в баре только play/pause + next справа */
  .mp-close, .mp-controls .mp-btn:first-child { display: none; }

  /* контент над мини-плеером (≈62px) + навигацией */
  .app.player-open { padding-bottom: calc(var(--bnav-h) + 62px + env(safe-area-inset-bottom)); }
  .app.player-open .toast-stack { bottom: calc(var(--bnav-h) + 62px + env(safe-area-inset-bottom)); }
  .toast-stack { bottom: calc(var(--bnav-h) + 12px + env(safe-area-inset-bottom)); }

  .mylib-src { display: none; } /* на узких экранах бейдж источника лишний */
  .mylib-cover { width: 64px; height: 64px; }

  /* профиль — на всю ширину, крупные тач-таргеты (dt-back скрыт глобально) */
  .profile-screen { max-width: none; margin-top: 12px; }
  .profile-head { gap: 14px; padding: 2px 2px 14px 2px; }
  .profile-avatar { width: 72px; height: 72px; font-size: 30px; }
  .profile-email { font-size: 14px; }
  .profile-row { padding: 13px 0; gap: 10px; }
  .pr-sub { display: none; } /* подсказки лишние на узком экране */
  .pr-action { height: 40px; padding: 0 14px; }
  .ps-sub { display: none; }
  .ps-label { font-size: 13.5px; }
  .profile-logout { height: 46px; }
}
