/* remote.css — пульт «Караоке РУМ». Тёмная тема, крупные кнопки под палец. */
:root {
  --bg: #0B0714;
  --panel: #150E24;
  --panel-2: #1E1533;
  --purple: #593C90;
  --purple-2: #5E2177;
  --yellow: #FFDE59;
  --text: #FFFFFF;
  --muted: #8A8A8A;
  --line: rgba(122, 91, 200, .28);
  --ok: #4ADE80;
  --err: #F87171;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
/* ВАЖНО: высота фиксируется, иначе экраны с собственной прокруткой
   не получают ограниченной высоты и .screen{overflow-y:auto} не работает. */
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  /* Раньше стояло overscroll-behavior:none — на старых WebView (Tecno)
     это вместе с отсутствием своей прокрутки у .screen полностью гасило
     прокрутку длинных экранов (например, настроек пульта). */
  overscroll-behavior-y: contain;
}

.screen { display: none; }
.screen.show { display: block; }

/* Все экраны пульта прокручиваются сами.
   ПОЧЕМУ: на старых WebView (Tecno и подобные) скролл-цепочка от .wrap к body
   не передаётся, и длинный экран настроек «залипал» — листать было нечем.
   Явная прокручиваемая область + -webkit-overflow-scrolling решает это. */
.screen { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Обёртка: на телефоне во всю ширину, на планшете/ПК — «смартфон» по центру.
   Так пульт выглядит одинаково аккуратно и на 5", и на планшете. */
.wrap {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* ---------------- ЭКРАН ПРИВЯЗКИ ---------------- */
.brand { display: flex; align-items: center; gap: 12px; margin: 26px 0 22px; }
.brand-logo { width: 52px; height: 52px; border-radius: 14px; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.brand-name span { color: var(--yellow); }
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }

.steps { margin: 0 0 18px; padding-left: 20px; color: #C9C4D8; font-size: 14px; }
.steps li { margin-bottom: 6px; }
.steps b { color: var(--yellow); }

.lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.code-slots { display: flex; gap: 8px; justify-content: space-between; width: 100%; }
.slot {
  flex: 1 1 0;
  min-width: 0;          /* иначе flex-элемент не даёт себя сжать и лезет вправо */
  width: 100%;
  height: 58px;
  padding: 0;
  text-align: center;
  font-size: 26px; font-weight: 800; color: var(--text);
  font-family: inherit;
  background: var(--panel-2); border: 2px solid var(--line);
  border-radius: 14px; outline: none;
  -moz-appearance: textfield;
}
.slot::-webkit-outer-spin-button,
.slot::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.slot:focus { border-color: var(--yellow); }
.slot.filled { border-color: var(--purple); background: #241740; }

/* Очень узкие телефоны (iPhone SE и подобные) — делаем поля мельче,
   чтобы все 4 цифры гарантированно умещались по горизонтали. */
@media (max-width: 380px) {
  .code-slots { gap: 6px; }
  .slot { height: 50px; font-size: 22px; border-radius: 12px; }
  body { padding-left: 10px; padding-right: 10px; }
  .card { padding: 14px; }
}

/* Планшет/ПК: не растягиваем пульт на всю ширину, центрируем «смартфоном». */
@media (min-width: 620px) {
  body { padding-top: 20px; padding-bottom: 28px; }
  .wrap {
    max-width: 460px;
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 18px 16px 24px;
    background: #0E0919;
  }
  /* Панель внутри карточки-«смартфона»: компенсируем её padding, не body. */
  .ctl { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}

/* ---------------- КНОПКИ ---------------- */
.btn {
  display: block; width: 100%; padding: 15px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  color: #fff; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: linear-gradient(135deg, var(--purple), var(--purple-2)); border: 0; }
.btn.primary:disabled { opacity: .45; }
.btn.ghost { background: transparent; }
.last { margin-top: 12px; }

/* ---------------- ШАПКА ПУЛЬТА ---------------- */
.bar { display: flex; align-items: center; gap: 10px; padding: 4px 0 12px; }
.bar-left { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.wait { background: var(--yellow); }
.dot.off { background: var(--err); }
.icon-btn {
  width: 38px; height: 38px; font-size: 17px; line-height: 1;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
}
/* Фон включён — кнопка 🎵 подсвечена, чтобы админ видел состояние с одного взгляда. */
.icon-btn.bg-on { border-color:#FFDE59; background:rgba(255,222,89,.18);
  box-shadow:0 0 0 1px rgba(255,222,89,.45), 0 0 14px rgba(255,222,89,.25); }

/* ---- Экран «Настройки сессии» внутри пульта (только админ) ----
   Строки плейлиста фона: обложка, название, убрать/добавить. */
.list { margin-top:10px; display:flex; flex-direction:column; gap:8px; }
.st-item { display:flex; align-items:center; gap:10px; width:100%;
  background:rgba(255,255,255,.05); border:1px solid var(--line);
  border-radius:12px; padding:8px 10px; color:var(--text);
  font-family:inherit; text-align:left; cursor:pointer; }
.st-item:hover { border-color:#FFDE59; background:rgba(255,222,89,.08); }
.st-item img { width:58px; height:36px; object-fit:cover; border-radius:8px; flex:0 0 auto; background:#1a0b2e; }
.st-item .st-m { flex:1; min-width:0; }
.st-item .st-m b { display:block; font-size:13px; font-weight:600;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.st-item .st-m small { color:rgba(255,255,255,.5); font-size:11px; }
.st-item .st-del { flex:0 0 auto; background:transparent; border:1px solid var(--line);
  color:#ffb3b3; border-radius:8px; padding:6px 10px; cursor:pointer; font-family:inherit; }
.st-item .st-add { flex:0 0 auto; color:#FFDE59; font-weight:800; font-size:16px; }
.st-empty { color:rgba(255,255,255,.5); font-size:12px; padding:10px 0; text-align:center; }

/* ---------------- СЕЙЧАС ИГРАЕТ ---------------- */
.now-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px; margin-bottom: 12px;
}
.now-thumb {
  width: 74px; height: 52px; flex: 0 0 74px; object-fit: cover;
  border-radius: 10px; background: var(--panel-2);
}
.now-meta { min-width: 0; }
.now-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-artist { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- ПРОГРЕСС ---------------- */
.seek { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.seek .t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.track { flex: 1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.fill { height: 100%; width: 0%; background: var(--yellow); border-radius: 3px; }

/* ---------------- ТРАНСПОРТ ---------------- */
.transport { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; }
.btn-round {
  width: 58px; height: 58px; font-size: 22px; line-height: 1;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 50%; cursor: pointer;
}
.btn-round.big {
  width: 78px; height: 78px; font-size: 30px;
  background: linear-gradient(135deg, var(--purple), var(--purple-2)); border: 0;
}
.btn-round:active { transform: scale(.95); }

/* ---------------- ГРОМКОСТЬ ---------------- */
.vol { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.vol-ico { font-size: 20px; background: none; border: 0; cursor: pointer; }
.vol-val { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px; border-radius: 3px; background: var(--panel-2); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--yellow); cursor: pointer;
}

/* ---------------- ЗАКРЕПЛЁННЫЙ БЛОК УПРАВЛЕНИЯ ----------------
   Требование заказчика: при пролистывании списка песен блок «сейчас играет +
   прогресс + ⏮⏸⏭ + громкость» должен сначала уехать вверх вместе со списком,
   а потом прилипнуть к верхнему краю экрана как панель — чтобы пауза,
   переход и громкость всегда были под рукой.
   Вид закрепления выбирается в настройках пульта: .wrap[data-ui=...]. */
.ctl {
  position: sticky;
  /* env(safe-area-inset-top) — чтобы панель не заезжала под вырез iPhone. */
  top: env(safe-area-inset-top, 0);
  z-index: 30;
  /* Фон обязателен: под панелью проезжает список песен. */
  background: var(--bg);
  /* Компенсируем боковые отступы body, чтобы фон перекрывал всю ширину. */
  margin-left: -14px;
  margin-right: -14px;
  padding: 6px 14px 2px;
  border-bottom: 1px solid transparent;
  transition: border-color .18s, box-shadow .18s, padding .18s;
}
/* Класс навешивает JS, когда панель реально «прилипла» — только для тени. */
.ctl.stuck {
  border-bottom-color: var(--line);
  box-shadow: 0 12px 20px -14px rgba(0, 0, 0, .95);
}

/* Когда панель закреплена — делаем её компактнее, иначе на 5" экране
   она съедает треть видимой области и списку не остаётся места. */
.ctl.stuck .now-card { padding: 8px; margin-bottom: 8px; }
.ctl.stuck .now-thumb { width: 56px; height: 40px; flex: 0 0 56px; }
.ctl.stuck .now-title { font-size: 14px; }
.ctl.stuck .seek { margin-bottom: 8px; }
.ctl.stuck .transport { margin-bottom: 8px; gap: 14px; }
.ctl.stuck .btn-round { width: 46px; height: 46px; font-size: 18px; }
.ctl.stuck .btn-round.big { width: 60px; height: 60px; font-size: 24px; }
.ctl.stuck .vol { margin-bottom: 0; }

/* ---------------- МИНИ-ПИЛЮЛЯ (плавающее управление) ----------------
   Дубль транспорта внизу экрана: удобно одной рукой, не глядя вверх. */
.mini {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(21, 14, 36, .93);
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mini[hidden] { display: none; }
.mini-btn {
  width: 44px; height: 44px; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 50%;
  cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 222, 89, .18);
}
.mini-btn.play {
  width: 54px; height: 54px; font-size: 22px;
  background: linear-gradient(135deg, var(--purple), var(--purple-2)); border: 0;
}
.mini-btn:active { transform: scale(.94); }

/* ---------------- ВАРИАНТЫ ЗАКРЕПЛЕНИЯ (data-ui) ----------------
   list: панель стоит сверху всегда, прокручивается только список.
   Надёжнее всего на старых WebView (Tecno и подобные), где sticky
   внутри body-скролла не работает. */
.wrap[data-ui="list"] .ctl { position: static; box-shadow: none; border-bottom-color: var(--line); }

/* fixed: как auto, но пилюля показывается всегда (когда есть песня). */
.wrap[data-ui="fixed"] .ctl { position: static; }

/* Список получает собственную прокрутку — тогда одинаково работает везде. */
.wrap[data-ui="list"] .list,
.wrap[data-ui="fixed"] .list,
.wrap[data-ui="auto"] .list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* ---------------- ПОИСК ---------------- */
.search-row { display: flex; gap: 10px; margin-bottom: 14px; }
.search-row input {
  flex: 1 1 0; min-width: 0; padding: 14px; font-size: 16px; font-family: inherit;
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; outline: none;
}
.search-row input:focus { border-color: var(--yellow); }
.search-row .btn { width: auto; flex: 0 0 auto; padding: 14px 18px; }

/* ---------------- СПИСОК ---------------- */
.list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; }
.list .hint { color: var(--muted); font-size: 13px; text-align: center; padding: 22px 10px; }

/* Прокрутка списка песен.
   Почему явно: на старых WebView (Tecno и подобные) скролл-контейнером
   считается .list, а цепочка до body не передаётся — жест «гаснет» и список
   не листается. Явная прокручиваемая область лечит это на всех телефонах. */
.list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}

/* ---------------- ЭКРАН НАСТРОЕК ---------------- */
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 12px; cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 222, 89, .18);
}
.opt:active { background: #241740; }
.opt input { margin: 3px 0 0; width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--yellow); }
.opt-txt { min-width: 0; }
.opt-t { display: block; font-size: 14px; font-weight: 600; }
.opt-h { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.35; }
.opt input:checked ~ .opt-txt .opt-t { color: var(--yellow); }
.opt:has(input:checked) { border-color: var(--yellow); }
.hint.lbl-strong { color: #C9C4D8; }

.item {
  display: flex; gap: 10px; align-items: center; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 9px; cursor: pointer; width: 100%;
  color: var(--text); font-family: inherit;
  /* Важно для Android/Samsung: убирает задержку тапа и потерю кликов. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 222, 89, .18);
  user-select: none; -webkit-user-select: none;
}
.item:active { background: var(--panel-2); }
.item img { width: 68px; height: 46px; flex: 0 0 68px; object-fit: cover; border-radius: 8px; background: var(--panel-2); }
.item-meta { min-width: 0; flex: 1; }
.item-title { font-size: 14px; font-weight: 600; }
.item-title, .item-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item-play { font-size: 20px; color: var(--yellow); }

/* ---------------- ТОСТ ---------------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(90px);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 11px 18px; border-radius: 12px;
  font-size: 14px; opacity: 0; transition: .22s; pointer-events: none;
  max-width: 88vw; text-align: center; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- БЫСТРЫЕ КНОПКИ (голос / клавиатура) ---------------- */
.quick { display: flex; gap: 10px; margin-bottom: 14px; }
.quick-btn { width: auto; flex: 1; padding: 12px; font-size: 15px; }
.quick-btn.listening {
  background: linear-gradient(135deg, #c026d3, var(--purple-2));
  border-color: transparent; animation: kr-pulse 1.1s infinite;
}
@keyframes kr-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 38, 211, .5); }
  50% { box-shadow: 0 0 0 10px rgba(192, 38, 211, 0); }
}

/* ---------------- ОЧЕРЕДЬ ---------------- */
.queue-wrap {
  margin: 4px 0 14px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.queue-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 8px;
}
.queue-list { max-height: 34vh; overflow-y: auto; padding-bottom: 0; }
.queue-list .item .d { font-size: 18px; color: var(--yellow); }

.err { color: var(--err); font-size: 13px; min-height: 18px; margin: 8px 0; }

/* ---------------- АДАПТИВ ---------------- */
/* Мелкие телефоны: чуть уменьшаем транспорт и громкость, чтобы всё
   умещалось на экран по горизонтали без «уезжания» вправо. */
@media (max-width: 380px) {
  .transport { gap: 12px; }
  .btn-round { width: 52px; height: 52px; font-size: 20px; }
  .btn-round.big { width: 68px; height: 68px; font-size: 26px; }
  .vol { gap: 8px; }
  .vol-val { min-width: 34px; }
  .quick-btn { padding: 11px; font-size: 14px; }
  .search-row .btn { padding: 13px 14px; }
  .item img { width: 56px; height: 38px; flex: 0 0 56px; }
}

/* Ландшафт на телефоне: пульт ниже — уменьшаем вертикальные отступы,
   а закрепление и пилюлю отключаем: на низком экране они съедят всё место. */
@media (max-height: 460px) and (orientation: landscape) {
  .brand { margin: 8px 0 10px; }
  .brand-logo { width: 40px; height: 40px; }
  .steps { display: none; }
  .now-thumb { width: 58px; height: 42px; flex: 0 0 58px; }
  .btn-round.big { width: 64px; height: 64px; font-size: 24px; }
  .ctl { position: static; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .mini { display: none !important; }
}

/* Полоса прогресса и громкость — удобнее пальцем на тач-экране. */
@media (pointer: coarse) {
  .track { height: 8px; }
  input[type=range] { height: 8px; }
  .slot { touch-action: manipulation; }
}

/* ---------------- МАКЕТ ПУЛЬТА: ПАНЕЛЬ + ПРОКРУЧИВАЕМЫЙ СПИСОК ----------------
   Телефон превращаем в колонку во всю высоту экрана: панель управления сверху,
   список песен занимает остаток и прокручивается внутри себя.

   Зачем: раньше прокручивался только body, и на старых WebView (Tecno)
   скролл-контейнером оказывался .list без своей высоты — жест «гас» и
   список не листался вовсе. Теперь прокрутка задана явно и работает везде.

   Высоту считаем от html/body (height:100%), а не от динамической единицы
   вьюпорта: её понимают не все старые WebView, из-за чего экран мог
   «схлопнуться» в ноль. */
html, body { height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }

/* КАЖДЫЙ экран — самостоятельная прокручиваемая колонка.
   Это и лечит Tecno: длинные настройки и длинный список листаются всегда. */
.screen.show {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.screen > .wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

/* На экране пульта список песен забирает всё свободное место. */
#screenRemote > .wrap { overflow: hidden; }
#screenRemote .list { flex: 1 1 auto; min-height: 120px; }
/* Очередь не должна растягивать колонку — у неё своя высота. */
#screenRemote .queue-wrap { flex: 0 0 auto; }
#screenRemote .toast { position: fixed; }

/* Настройки/привязка/«поделиться» прокручиваются целиком, wrap не режем. */
#screenSettings > .wrap,
#screenLink > .wrap,
#screenShare > .wrap { overflow: visible; }

/* Планшет/ПК: карточка-«смартфон» со своей рамкой. */
@media (min-width: 620px) {
  body { justify-content: flex-start; }
  #screenRemote > .wrap { max-height: calc(100% - 40px); }
}

/* ---- Настройки в аккордеоне (23.10.2026): меньше «жопы» на экране ---- */
#screenSettings .card.acc-collapsed > *:not(.card-title) { display:none !important; }
#screenSettings .card .card-title[role="button"] { cursor:pointer; position:relative; padding-right:26px; }
#screenSettings .card .card-title[role="button"]::after {
  content:'▾'; position:absolute; right:0; top:0; opacity:.7; transition:transform .15s;
}
#screenSettings .card.acc-collapsed .card-title[role="button"]::after { transform:rotate(-90deg); }
#cardOverlay { border-color:rgba(255,222,89,.45); }
