/* --- Базовые сбросы --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-off: #15171c;
  --text: #f2f4f8;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --accent-dark: #2f6ad9;
  --line: #262a33;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 480px;
  margin: 0 auto;
  /* рамка под экран телефона: фиксированная высота, колонка */
  height: 100vh;
  height: 100dvh;          /* учитывает адресную строку мобильного браузера */
  display: flex;
  flex-direction: column;
  overflow: hidden;         /* сама страница не скроллится — скроллится только список */
}

/* --- Шапка (не двигается, остаётся сверху) --- */
.topbar {
  flex: none;
  padding: calc(20px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, 0.92);
  position: relative;
  z-index: 20;              /* выше дропдауна-меню */
}
/* строка с заголовком и иконкой плейлистов */
.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* название текущего плейлиста — отдельной строкой под заголовком */
.topbar__playlist {
  font-size: 14px; font-weight: 600; color: var(--accent);
  margin-top: 6px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- Иконка-кнопка выбора плейлиста --- */
.pl-btn {
  flex: none;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.pl-btn:active { background: var(--line); }
.pl-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.pl-btn__icon { display: flex; }

/* --- Затемнение фона при открытом меню --- */
.pl-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 15;
}

/* --- Выпадающий список плейлистов --- */
.pl-menu {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top) + 44px);
  right: 16px;
  z-index: 25;
  min-width: 220px;
  max-width: calc(100% - 32px);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.pl-menu__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 12px 12px;
  border: none; border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px; text-align: left;
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-menu__item:active { background: var(--line); }
/* активный плейлист — подсветка акцентом + галочка */
.pl-menu__item.is-active { color: var(--accent); font-weight: 600; }
.pl-menu__check { flex: none; width: 16px; text-align: center; opacity: 0; }
.pl-menu__item.is-active .pl-menu__check { opacity: 1; }
.pl-menu__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* --- Прокручиваемая середина --- */
main {
  flex: 1 1 auto;
  min-height: 0;            /* нужно, чтобы flex-элемент мог скроллиться */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.topbar__title { font-size: 20px; font-weight: 700; }
.topbar__hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* --- Список фраз --- */
.list { list-style: none; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.item {
  position: relative;            /* якорь для пилюли в углу */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  transition: opacity .2s, background .2s;
}
/* фраза, помеченная "пропускать": приглушаем фон и текст, но не пилюлю,
   чтобы число проигрываний оставалось легко читаемым */
.item.is-off { background: var(--card-off); }
.item.is-off .item__phrase,
.item.is-off .item__translation { opacity: .45; }

/* подсветка фразы, которая играет сейчас */
.item.is-playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* текст занимает всю ширину; справа сверху оставляем место под пилюлю.
   тап по тексту = «играть отсюда» (обработчик в app.js) */
.item__text { min-width: 0; padding-right: 58px; cursor: pointer; }
/* white-space: pre-wrap — сохраняем переносы строк (длинные фразы, тексты песен) */
.item__phrase { font-size: 18px; font-weight: 600; line-height: 1.3; white-space: pre-wrap; word-break: break-word; }
.item__translation { font-size: 14px; color: var(--muted); margin-top: 3px; line-height: 1.3; white-space: pre-wrap; word-break: break-word; }

/* --- Пилюля-счётчик проигрываний (она же переключатель вкл/выкл) --- */
.item__pill {
  position: absolute;
  top: 12px; right: 12px;
  min-width: 46px;               /* вмещает три разряда (напр. "999") */
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;          /* горизонтальная капсула */
  border: 1px solid transparent;
  font: 600 13px/1 -apple-system, sans-serif;
  font-variant-numeric: tabular-nums; /* цифры не «прыгают» по ширине */
  text-align: center;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
/* включено: мягкая заливка в тон акценту */
.item__pill {
  background: rgba(79, 140, 255, 0.18);
  border-color: rgba(79, 140, 255, 0.35);
  color: #cfe0ff;
}
/* выключено: приглушённый затенённый фон, но число легко читается */
.item.is-off .item__pill {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  color: var(--muted);
}

/* --- Нижняя панель (не двигается, остаётся снизу) --- */
.playbar {
  flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(15, 17, 21, 0.95);
  border-top: 1px solid var(--line);
}
.playbar__btn {
  width: 100%;
  padding: 16px;
  font-size: 24px;           /* крупный значок ▶ / ■ */
  line-height: 1;
  color: #fff;
  background: var(--accent);
  border: none; border-radius: 14px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.playbar__btn:active { transform: scale(.99); }
.playbar__btn.is-playing { background: #e0483e; }   /* красная во время воспроизведения = "Стоп" */
.playbar__btn:disabled { background: #3a3f4b; color: var(--muted); cursor: default; }
