:root {
  --bg: #0b0b0d;
  --surface: #141417;
  --surface-2: #1b1b20;
  --line: #26262c;
  --text: #f2f2f4;
  --muted: #8a8a94;
  --accent: #ffffff;
  --danger: #ff5b5b;
  --radius: 14px;
  --tap: 46px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: calc(220px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* --------------------------------------------------- строки чипов (тэги) */
/* Чипы переносятся на новые строки: когда плейлистов много, они все видны,
   а если строк стало слишком много — ряд прокручивается по вертикали. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  max-height: 42vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { width: 6px; }
.chip-row::-webkit-scrollbar-thumb { background: #33333c; border-radius: 3px; }
.chip-row::-webkit-scrollbar-track { background: transparent; }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.chip:active { background: var(--surface-2); }
.chip.active {
  background: var(--text);
  border-color: var(--text);
  color: #101013;
  font-weight: 600;
}
.chip .chip-count { color: inherit; opacity: 0.55; margin-left: 6px; font-size: 11px; }

/* список плейлистов в панели «в какой плейлист» */
.playlist-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.playlist-list:empty::before { content: 'Плейлистов пока нет — создай первый в поле ниже'; color: var(--muted); font-size: 13px; }
.playlist-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.playlist-list button:active { background: #24242b; }
.playlist-list button .already { color: var(--muted); font-size: 12px; flex: none; }

/* редактор тэгов в панели песни */
.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tag-chips:empty::before { content: 'тэгов пока нет'; color: var(--muted); font-size: 13px; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tag-chip span { color: var(--muted); font-size: 15px; line-height: 1; }
.tag-chip:active span { color: var(--danger); }

.tag-add { display: flex; gap: 8px; }
.tag-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  outline: none;
}
.tag-input:focus { border-color: #3a3a44; }
.tag-add-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tag-add-btn:active { background: #24242b; }

.tag-known { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag-known:empty { display: none; }
.tag-known button {
  border: 1px dashed #33333c;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.tag-known button:active { color: var(--text); border-color: #4a4a55; }

/* ------------------------------------------------------------------ шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 11, 13, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

/* верхняя строка шапки: название (или поиск) и стрелка действий */
.top-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* стрелка прячет и показывает все кнопки — на телефоне они мешают */
.actions-toggle { flex: none; }
.actions-toggle svg { transition: transform 0.15s ease; }
.top.actions-open .actions-toggle svg { transform: rotate(180deg); }

.top h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* название списка — кнопка: по нажатию раскрывается строка плейлистов */
.top-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 8px 6px;
  margin: 0 0 0 -6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.top-title.has-lists::after {
  content: ' ▾';
  font-size: 11px;
  opacity: 0.7;
}
.top-title.has-lists.open::after { content: ' ▴'; }
.top-title:active { color: var(--text); }
.top.selecting .top-title { color: var(--text); cursor: default; }
.top .icon-btn.active { border-color: #4a4a55; color: var(--text); }
.top .icon-btn:disabled { opacity: 0.4; }

/* поиск: занимает место заголовка, пока открыт */
.search-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 6px 0 10px;
  height: 38px;
}
.search-box svg { color: var(--muted); flex: none; }
.search-box input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  /* 16px — иначе Safari на iPhone приближает страницу при фокусе */
  font-size: 16px;
}
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box .icon-btn { width: 26px; height: 26px; border: none; background: transparent; }

/* пока идёт поиск, кнопки прячутся — полю нужна вся ширина */
.top.searching .top-actions { display: none; }
.top.searching #searchBox { flex: 1; }

/* Всегда под рукой: плюс и обновление — рядом со стрелкой справа.
   Когда открывается ряд действий, они уступают ему место. */
.top-quick {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: none;
}
.top.actions-open .top-quick { display: none; }
.top.selecting .top-quick { display: none; }
.top.searching .top-quick { display: none; }

/* Кнопки действий. Скрыты, пока не нажата стрелка; выезжают справа налево
   и держатся у правого края рядом со стрелкой. */
.top-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
  margin-left: auto;
}

.top.actions-open .top-actions {
  display: flex;
  animation: actionsIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes actionsIn {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .top.actions-open .top-actions { animation: none; }
}

/* пока идёт обновление — иконка крутится */
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* когда кнопки раскрыты, название убираем — место нужно им */
.top.actions-open .top-title { display: none; }
.top.actions-open #searchBox { display: none; }

/* выход из приложения — в конце строки, отделён от частых кнопок */
.top-actions .logout {
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  border-radius: 0 12px 12px 0;
  color: var(--muted);
}

/* режим выбора: действия нужны сразу, стрелку прячем */
.top.selecting .actions-toggle { display: none; }
.top.selecting .top-actions { display: flex; animation: actionsIn 0.24s cubic-bezier(0.22, 1, 0.36, 1); }
/* в режиме выбора название не раскрывает список плейлистов — стрелку убираем */
.top.selecting .top-title::after { content: none; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ------------------------------------------------------------------ список */
.list { list-style: none; margin: 0; padding: 0; }

.track {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.track-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--tap) 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 10px 10px;
  background: var(--bg);
}

.track.play-btn-hit .track-main, .track:active .track-main { background: #101013; }
.track.current .track-main { background: #131316; }
.track.picked .track-main { background: #1a1a20; }

.track.dragging {
  overflow: visible;
  border-bottom-color: transparent;
}
.track.dragging .track-main {
  z-index: 30;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.track .play {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.track .play svg { width: 30px; height: 30px; display: block; }
.track.current .play { color: var(--accent); }

.track .meta {
  min-width: 0;
  overflow: hidden;
}
.track .title {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track.current .title { font-weight: 650; }
.track .sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.track .sub:empty { display: none; }

/* иконок в строке теперь нет — она стала чище: только стрелка, название и тэги */
.row-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  touch-action: none;
}
.row-icon svg { width: 21px; height: 21px; display: block; }

/* подсказка вместо строки тэгов, пока их нет */
.chip-row-hint { padding: 9px 16px; }
.tag-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.tag-hint b { color: var(--text); font-weight: 600; }

/* режим удаления: вместо ↕ чекбокс */
.row-check {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.row-check span {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1.5px solid #4a4a55;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.track.picked .row-check span { background: var(--text); border-color: var(--text); }
.track.picked .row-check span::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #101013;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* разворачивающийся блок текста */
.lyrics-wrap {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.26s ease;
}
.track.open .lyrics-wrap { grid-template-rows: 1fr; }

.lyrics-inner { overflow: hidden; }

.lyrics {
  position: relative;
  margin: 8px 0 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #9a9aa4;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  max-height: 46vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* построчная подсветка: активная строка — жирная и белая */
.lyric-line { padding: 2px 0; transition: color 0.15s ease, font-weight 0.15s ease; }
.lyric-line.active { color: var(--text); font-weight: 700; }
.lyric-line.past { color: #6d6d76; }
.lyric-line.empty { height: 0.7em; padding: 0; }
.lyrics-empty { color: var(--muted); }

.lyrics-edit {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  resize: vertical;
  outline: none;
}
.lyrics-edit:focus { border-color: #3a3a44; }

.lyrics-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 10px; }
.lyrics-tools .wide-btn {
  flex: 1 1 148px;
  width: auto;
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
}
.lyrics-tools .wide-btn { padding: 9px 14px; font-size: 14px; }

/* -------------------------------------------------------------- пустой вид */
.empty { padding: 48px 22px; text-align: center; color: var(--text); }
.empty p { margin: 0 0 10px; }
.empty .muted { font-size: 14px; line-height: 1.6; }

/* ------------------------------------------------------------------ плеер */
/* ------------------------------------------------------------------ плеер
   Панель сжата: полоса перемотки идёт по самому верху, время — в строке кнопок. */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: rgba(20, 20, 23, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.5);
}

.player-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.now { min-width: 0; }
.now-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-artist { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-artist:empty { display: none; }

/* кнопка в углу панели — разворачивает текст текущей песни */
.lyrics-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 8px 14px;
  cursor: pointer;
}
.lyrics-btn:active { background: #26262d; }

.time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.seek-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }

.seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.seek::-webkit-slider-runnable-track { height: 3px; background: var(--line); border-radius: 2px; }
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
}
.seek::-moz-range-track { height: 3px; background: var(--line); border-radius: 2px; }
.seek::-moz-range-thumb { width: 13px; height: 13px; border: none; border-radius: 50%; background: var(--accent); }

.controls { display: flex; align-items: center; justify-content: center; gap: 26px; margin-top: 4px; }
.ctrl {
  border: none;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 6px;
  cursor: pointer;
}
.ctrl:active { opacity: 0.65; }
.play-ctrl {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ------------------------------------------------- разворачивающиеся панели */
.sheet { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet.open { pointer-events: auto; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.24s ease;
}
.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(102%);
  transition: transform 0.28s cubic-bezier(0.22, 0.7, 0.2, 1);
}
.sheet.open .sheet-panel { transform: translateY(0); }

/* В невысоких окнах (например, браузер на компьютере) панель сжимается,
   чтобы кнопки экспорта были видны сразу, без прокрутки внутри панели. */
@media (max-height: 640px) {
  .sheet-panel { max-height: 96vh; padding-top: 10px; padding-bottom: 10px; }
  .sheet-head { margin-bottom: 8px; }
  .field { margin-bottom: 8px; }
  .field > span { margin-bottom: 4px; }
  .field input[type="text"], .field select, .field textarea { padding: 9px 12px; }
  .wide-btn { padding: 11px 14px; margin-bottom: 8px; font-size: 14px; }
  .sheet-subhead { display: none; }
  .row-btns {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .row-btns .wide-btn { margin-bottom: 0; padding: 11px 8px; }
}

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-title { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 0; }

.field { display: block; margin-bottom: 14px; }

.sheet-subhead {
  margin: 16px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* две кнопки в ряд — чтобы панель не разрасталась по высоте */
.row-btns { display: flex; gap: 8px; }
.row-btns .wide-btn {
  flex: 1;
  margin-bottom: 0;
  padding: 13px 10px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.row-btns .wide-btn svg { width: 16px; height: 16px; flex: none; color: var(--muted); }

.sheet-note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  outline: none;
}
.field textarea { resize: vertical; line-height: 1.5; white-space: pre-wrap; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #3a3a44; }
.field input[type="file"] { font-size: 14px; color: var(--muted); width: 100%; }

.wide-btn {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: center;
  cursor: pointer;
}
.wide-btn:active { background: #24242b; }
.wide-btn.primary { background: #f2f2f4; color: #101013; border-color: #f2f2f4; font-weight: 600; }
.wide-btn.danger { color: var(--danger); }

.confirm-message {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.5;
  color: #c9c9d1;
}

/* ------------------------------------------------- полноэкранный режим
   Текст занимает весь экран, плеер лежит поверх него полупрозрачным слоем. */
.fs {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.22, 0.7, 0.2, 1);
}
.fs.open { transform: translateY(0); }

body.fs-open { overflow: hidden; }

.fs-lyrics {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-gutter: stable both-edges;   /* полоса прокрутки не сдвигает текст влево */
  padding: 16vh 22px 46vh;
  /* вертикальная прокрутка остаётся, а масштаб страницы щипком мы обрабатываем сами */
  touch-action: pan-y;
}

/* Строки прижаты влево, а сам блок текста стоит по центру экрана.
   Ширина растёт вместе с размером шрифта, чтобы строки не рвались. */
.lyrics-lines {
  max-width: clamp(440px, calc(var(--fs-font, 21px) * 30), 1000px);
  margin: 0 auto;
}

/* На широком окне колонка занимает не всю ширину, иначе поля по краям
   не видны и текст кажется прижатым влево. На телефоне — вся ширина. */
@media (min-width: 520px) {
  .lyrics-lines { width: 86%; }
}

/* вариант «строки по центру» — переключается иконкой в окне воспроизведения */
body.text-center .lyrics-lines { text-align: center; }

/* «весь текст заглавными» — только вид, текст в базе не меняется */
body.text-caps .lyric-line { text-transform: uppercase; }

.fs-lyrics .lyric-line {
  font-size: var(--fs-font, 21px);
  line-height: 1.5;
  padding: 5px 0;
  color: #6f6f79;
}
.fs-lyrics .lyric-line.active { color: var(--text); font-weight: 700; }
.fs-lyrics .lyric-line.past { color: #4d4d55; }
.fs-lyrics .lyric-line.empty { height: 0.6em; padding: 0; }
.fs-lyrics .lyrics-empty { font-size: 16px; }

.fs-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 28px;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0.97) 32%, rgba(11, 11, 13, 0));
  touch-action: none;
}
.fs-titles { flex: 1; min-width: 0; text-align: center; }
.fs-top .icon-btn { border-radius: 50%; background: rgba(30, 30, 36, 0.7); }
.fs-top .icon-btn { width: 34px; height: 34px; }
.fs-font-btn { font-size: 13px; font-weight: 700; letter-spacing: -0.02em; }
.fs-font-btn:active { color: var(--text); }
.fs-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fs-artist {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fs-artist:empty { display: none; }

.fs-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  /* Стекло: текст песни виден сквозь плеер. Сверху прозрачнее — там волна
     и строки текста, снизу плотнее — там кнопки, которым нужен контраст.
     Размытие небольшое: сильное превращает буквы в серое пятно. */
  background: linear-gradient(
    to bottom,
    rgba(11, 11, 13, 0.52) 0%,
    rgba(11, 11, 13, 0.62) 55%,
    rgba(11, 11, 13, 0.72) 100%
  );
  backdrop-filter: blur(5px) saturate(1.2);
  -webkit-backdrop-filter: blur(5px) saturate(1.2);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px 20px 0 0;
  transition: background 0.6s ease, backdrop-filter 0.6s ease, -webkit-backdrop-filter 0.6s ease;
}

/* Во время игры панель уходит почти в полную прозрачность — текст читается
   сквозь неё. Любое касание возвращает панель к обычному виду. */
.fs-bottom.faded {
  background: linear-gradient(
    to bottom,
    rgba(11, 11, 13, 0.10) 0%,
    rgba(11, 11, 13, 0.20) 55%,
    rgba(11, 11, 13, 0.34) 100%
  );
  backdrop-filter: blur(2px) saturate(1.1);
  -webkit-backdrop-filter: blur(2px) saturate(1.1);
  border-top-color: rgba(255, 255, 255, 0.04);
}

.fs-wave-wrap { position: relative; height: 54px; }
.fs-wave { display: block; width: 100%; height: 54px; touch-action: none; cursor: pointer; }
.fs-wave-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.fs-wave-hint.hidden { display: none; }

.fs-under-wave {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0;
}
.fs-under-wave .time:first-child { text-align: left; }
.fs-under-wave .time:last-child { text-align: right; }

.fs-bottom .controls { position: relative; margin-top: 2px; }

/* В горизонтальной ориентации экран низкий — плеер поджимаем,
   чтобы текста помещалось больше. Правила идут после базовых,
   иначе волна остаётся прежней высоты. */
@media (orientation: landscape) and (max-height: 520px) {
  .fs-top { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .fs-title { font-size: 14px; }
  .fs-bottom { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
  .fs-wave-wrap { height: 30px; }
  .fs-wave { height: 30px; }
  .fs-follow { width: 40px; height: 40px; }
  .fs-follow svg { width: 21px; height: 21px; }
  .fs-under-wave { margin: 0; }
}

/* переключатель автопрокрутки: на одной строке с кнопкой воспроизведения,
   прижат вправо и не увеличивает высоту плеера (вынут из потока) */
.fs-follow {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  background: transparent;
  color: #6b6b74;
  cursor: pointer;
  transition: color 0.15s ease;
}
.fs-follow svg { width: 25px; height: 25px; display: block; }
.fs-follow.on { color: var(--text); }
.fs-follow .slash { display: none; }
.fs-follow:not(.on) .slash { display: block; }
.fs-follow:active { opacity: 0.6; }

/* закреплённая автопрокрутка: видно по кольцу вокруг иконки */
.fs-follow.locked {
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55);
}

/* переключатель выравнивания строк — рядом с автопрокруткой */
#fsAlign { right: 50px; }

/* ------------------------------------------------- тап-синхронизация текста */
.sync-panel {
  height: 92vh;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sync-hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }

.sync-transport { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ctrl-text {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.sync-transport .time { margin-left: auto; min-width: 84px; text-align: right; }
.sync-transport .play-ctrl { width: 46px; height: 46px; }

.sync-wave-wrap { margin-bottom: 12px; }

.sync-next-label {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px 2px;
}

.sync-next {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-height: 74px;
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 12px;
}
.sync-next.done { color: var(--muted); font-weight: 400; font-size: 14px; }

.sync-tap {
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 16px;
  background: #f2f2f4;
  color: #101013;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-bottom: 10px;
}
.sync-tap:active { background: #cfcfd4; }
.sync-tap:disabled { background: var(--surface-2); color: var(--muted); }

.sync-actions { display: flex; gap: 8px; }
.sync-actions .wide-btn { margin-bottom: 12px; padding: 11px 8px; font-size: 13px; }

.sync-list { position: relative; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 8px; }

.sync-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1e1e23;
  font-size: 14px;
}
.sync-row .stamp {
  background: transparent;
  border: none;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.sync-row .stamp.set { color: var(--text); }
.sync-row.current { background: #1a1a1f; border-radius: 10px; }
.sync-row .stext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b9b9c2; }

/* строка, которая звучит прямо сейчас */
.sync-row.playing { box-shadow: inset 3px 0 0 rgba(242, 242, 244, 0.55); }
.sync-row.playing .stext { color: var(--text); font-weight: 600; }

/* строка, которой поставится время по нажатию кнопки */
.sync-row.current { background: #26262e; border-radius: 10px; }
.sync-row.current .stext { color: var(--text); }
.sync-row.current .stamp { color: var(--text); }
.sync-row .stext.blank { color: #55555c; font-style: italic; }
.sync-row .nudge { display: flex; gap: 4px; }
.sync-row .nudge button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 8px;
  font-size: 11px;
  padding: 5px 7px;
  cursor: pointer;
}
.sync-row .nudge button:active { color: var(--text); }

.sync-footer { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.sync-footer .wide-btn { margin-bottom: 0; }

/* ------------------------------------------------------------------- вход */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.login { width: 100%; max-width: 340px; text-align: center; }
.login-title { font-size: 15px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.login-hint { font-size: 14px; color: var(--text); margin: 0 0 22px; }
.login-form { display: block; }

.pin-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  font-size: 26px;
  letter-spacing: 0.34em;
  text-align: center;
  padding: 16px;
  margin-bottom: 12px;
  outline: none;
}
.pin-input:focus { border-color: #3a3a44; }

.login-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.login-note { color: var(--muted); font-size: 12px; margin: 14px 0 0; line-height: 1.5; }

/* ------------------------------------------------------------------- тост */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(180px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(240, 240, 244, 0.96);
  color: #101013;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
