:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --border: #2a2a2e;
  --text: #efeff1;
  --muted: #adadb8;
  --chat-message-opacity: 1;
  --chat-nick-opacity: 1;
  --accent: #53fc18;
  --vk: #4d8eff;
  --live: #fa2a2a;
  --chat-width: 340px;
  --chat-font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overscroll-behavior: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-width);
  /* высота строки жёстко = экран, иначе при скрытом чате строка сжимается
     под натуральный размер видео (1080px) и плеер вылазит за экран */
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh; /* на мобиле учитываем адресную строку */
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

/* ---------------- player ---------------- */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.player {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.player.pointer-idle:fullscreen:not(.paused):not(.offline),
.player.pointer-idle:fullscreen:not(.paused):not(.offline) *,
.player.pointer-idle:-webkit-full-screen:not(.paused):not(.offline),
.player.pointer-idle:-webkit-full-screen:not(.paused):not(.offline) * {
  cursor: none !important;
}
@media (pointer: coarse) {
  .controls,
  .player.show-controls .controls {
    opacity: 1;
  }
  .player.pointer-idle:not(.offline) .controls {
    opacity: 0.92;
  }
}

@media (pointer: coarse) and (orientation: portrait) and (max-width: 800px) {
  .player.pointer-idle:not(.paused):not(.offline) .controls {
    opacity: 0;
    pointer-events: none;
  }
  .player.show-controls .controls,
  .player.paused .controls {
    pointer-events: auto;
  }
}

/* object-fit: contain → на ультравайде видео вписывается по ВЫСОТЕ,
   по бокам появляются чёрные бордюры, картинка не растягивается за экран */
#video { width: 100%; height: 100%; background: #000; display: block; object-fit: contain; }

.offline-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eee;
}
.offline-image.hidden { display: none; }
.offline-info {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 5px;
  width: min(420px, calc(100% - 28px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.76);
  color: #c8c8cf;
  text-align: center;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.offline-info strong { color: #fff; font-size: 15px; }
.offline-info b { color: #fff; font-weight: 600; }
.offline-info.hidden { display: none; }
.online-stats {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #bbb;
  font-size: 12px;
  max-width: calc(100% - 24px);
  /* прячем, пока мышь не водят по плееру (как контролы) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.player.show-controls .online-stats,
.player.paused .online-stats,
.player.offline .online-stats { opacity: 1; pointer-events: auto; }
.player.rtc-mode .seek,
.player.rtc-mode .behind,
.player.rtc-mode #btn-live,
.player.rtc-mode .speed { display: none; }
.online-stats span { padding: 2px 5px; white-space: nowrap; }
.online-stats strong { color: #fff; }
.online-stats span:nth-child(2) strong { color: var(--accent); }
.online-stats span:nth-child(3) strong { color: #78a9ff; }
.online-stats a {
  padding: 2px 5px;
  color: #bbb;
  text-decoration: none;
}
.online-stats a:hover { color: #fff; text-decoration: underline; }
.player.offline .clickcatch,
.player.offline .controls,
.player.offline .bigplay,
.player.offline .unmute { display: none; }
/* Тайтл стрима (из бота JORA): заметный, но компактный; в фулскрине скрыт */
.stream-title-wrap {
  position: absolute;
  z-index: 4;
  top: 52px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(60%, 560px);
  pointer-events: none;
}
.stream-title-wrap.hidden { display: none; }
.chat-only .stream-title-wrap, .brand-hidden .stream-title-wrap { top: 12px; }
/* В фулскрине тайтл не нужен — ничто не должно мешать видео */
.player:fullscreen .stream-title-wrap { display: none; }
.player:-webkit-full-screen .stream-title-wrap { display: none; }
.stream-title {
  min-width: 0;
  padding: 5px 12px;
  border: 1px solid color-mix(in srgb, var(--accent, #ff5fa2) 60%, transparent);
  border-radius: 9px;
  /* яркая капсула в акцент выбранной темы (фолбэк — розовый) */
  background: linear-gradient(135deg, var(--accent-bright, #ff6eb0), var(--accent-dark, #b3186f));
  color: var(--accent-contrast, #fff);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  /* длинное название не режем в одну строку: до двух строк, дальше многоточие */
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 12px var(--pz-glow, rgba(255, 95, 162, 0.45));
  text-decoration: none;
  pointer-events: none;
  transition: filter 0.15s, transform 0.15s;
}
/* если у анонса была ссылка (видос/кинопоиск) — плашка кликабельна */
.stream-title[href] { pointer-events: auto; cursor: pointer; }
.stream-title[href]:hover { filter: brightness(1.15); transform: translateY(-1px); }
.stream-title-close {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.7;
}
.stream-title-close:hover { opacity: 1; }
/* мобила: даём плашке всю ширину плеера */
@media (max-width: 900px) {
  .stream-title-wrap { left: 12px; right: 12px; max-width: none; justify-content: flex-end; }
  .stream-title { font-size: 12px; }
}

.clickcatch { position: absolute; inset: 0 0 56px 0; cursor: pointer; }

.status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}
.status.hidden { display: none; }

.bigplay {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  font-size: 34px; color: #fff;
  cursor: pointer;
  pointer-events: auto;
}
.bigplay.hidden { display: none; }

.unmute {
  position: absolute;
  left: 50%; top: 16px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #06210a;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 5;
}
.unmute.hidden { display: none; }

.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  opacity: 0;
  transition: opacity 0.18s;
}
.player.paused .controls,
.player.show-controls .controls { opacity: 1; }

.ctl {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.ctl:hover { background: rgba(255, 255, 255, 0.14); }
.ctl svg { width: 22px; height: 22px; fill: currentColor; }
.ctl .hidden { display: none; }

.vol { position: relative; display: flex; align-items: center; }
/* Вертикальный бегунок громкости во всплывашке над кнопкой — работает при любом
   размере окна плеера (а не только в фуллскрине, как горизонтальный). */
.vol-popup {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  padding: 12px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 7;
}
.vol-popup::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 10px;
}
.vol:hover .vol-popup,
.vol.volume-open .vol-popup { opacity: 1; pointer-events: auto; }
.vol.volume-closed .vol-popup { opacity: 0; pointer-events: none; }
.vol-range {
  -webkit-appearance: slider-vertical;       /* старый WebKit */
  appearance: slider-vertical;
  writing-mode: vertical-lr;                  /* совр. стандарт: вертикальный range */
  direction: rtl;                            /* вверх = громче */
  width: 6px;
  height: 96px;
  accent-color: var(--accent);
  cursor: pointer;
}

.seek { position: relative; flex: 1; height: 56px; display: flex; align-items: center; cursor: pointer; min-width: 40px; }
.seek-tip {
  position: absolute;
  bottom: 68%;
  transform: translateX(-50%);
  z-index: 6;
  display: grid;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.25;
  text-align: center;
}
.seek-tip span:last-child {
  color: var(--muted);
}
.seek-tip.hidden { display: none; }
@media (max-width: 700px) {
  .seek-tip {
    left: 50% !important;
    bottom: calc(100% + 4px);
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }
}
.seek-track {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
}
.seek-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
}
.seek-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px; height: 13px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}
.seek:hover .seek-knob { opacity: 1; }

.behind {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.behind.hidden { display: none; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.live-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.player.at-live .live-dot { background: var(--live); box-shadow: 0 0 7px var(--live); }
.player.at-live .live { color: #fff; }

.dvrbtn { font-size: 12px; font-weight: 600; color: var(--muted); }
.dvrbtn:hover { color: #fff; }
.dvrbtn.active { color: var(--accent); background: rgba(83, 252, 24, 0.12); }
/* в режиме записи точка LIVE серая (мы не на эфире) */
.player.dvr-mode .live-dot { background: var(--muted) !important; box-shadow: none !important; }

.ll-btn { font-size: 12px; font-weight: 800; letter-spacing: 0.2px; min-width: 42px; white-space: nowrap; }
.ll-btn.active { color: var(--accent); background: rgba(83, 252, 24, 0.14); }
.ll-btn.hidden { display: none; }
.player.rtc-mode .ll-btn { margin-left: auto; }

.cc-btn { font-size: 12px; font-weight: 800; letter-spacing: 0.5px; min-width: 34px; }
.cc-btn.active { color: var(--accent); background: rgba(83, 252, 24, 0.14); }
.cc-btn.hidden { display: none; }

/* Оверлей живых субтитров — над панелью управления, на видео не влияет */
.cc-overlay {
  position: absolute;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 72%;
  z-index: 6;
  text-align: center;
  font: 600 23px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  background: rgba(0, 0, 0, 0.74);
  padding: 8px 18px;
  border-radius: 10px;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.9);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  white-space: normal;
  word-break: break-word;
}
.cc-overlay.hidden { display: none; }
/* в полноэкранном режиме чуть крупнее */
.player:fullscreen .cc-overlay { font-size: 30px; bottom: 96px; }
.player:-webkit-full-screen .cc-overlay { font-size: 30px; bottom: 96px; }
.player:fullscreen, .player:-webkit-full-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  background: #000;
}
@media (max-width: 700px) {
  .cc-overlay { font-size: 16px; line-height: 1.35; bottom: 66px; max-width: 92%; padding: 5px 12px; }
}

.ll-intro {
  position: absolute;
  right: 92px;
  bottom: 62px;
  z-index: 9;
  width: min(360px, calc(100% - 24px));
  padding: 14px 40px 13px 15px;
  border: 1px solid rgba(83, 252, 24, 0.45);
  border-radius: 10px;
  background: rgba(24, 24, 27, 0.97);
  color: var(--text);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.65);
}
.ll-intro.hidden { display: none; }
.ll-intro strong, .ll-intro span, .ll-intro small { display: block; }
.ll-intro strong { margin-bottom: 6px; color: var(--accent); font-size: 15px; }
.ll-intro span { font-size: 13px; line-height: 1.4; }
.ll-intro small { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.ll-intro-close {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}
.ll-intro-close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.ll-intro-actions { display: flex; gap: 8px; margin-top: 11px; }
.ll-intro-actions button {
  border: 0;
  border-radius: 6px;
  padding: 7px 11px;
  background: #323238;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}
.ll-intro-actions button:first-child { background: var(--accent); color: #06210a; }
.ll-intro-actions button:hover { filter: brightness(1.12); }

.quality, .speed { position: relative; }
.q-btn { font-size: 13px; font-weight: 600; min-width: 48px; }
.speed-btn { min-width: 38px; font-size: 12px; font-weight: 700; }
.quality-menu {
  position: absolute;
  bottom: 46px;
  right: 0;
  background: #1f1f23;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 110px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.quality-menu.hidden { display: none; }
.speed-menu { min-width: 130px; }
.quality-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.quality-menu button:hover { background: rgba(255, 255, 255, 0.1); }
.quality-menu button.active { color: var(--accent); font-weight: 700; }

/* ---------------- chat ---------------- */
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chat-tabs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
  min-height: 38px;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: #101014;
}
.chat-source-filters {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #2b2b31;
  border-radius: 28px;
  background: #15151a;
}
.source-toggle {
  min-width: 48px;
  height: 25px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}
.source-toggle + .source-toggle { border-left: 1px solid #2b2b31; }
.source-toggle.active {
  background: #24242b;
  color: var(--text);
}
.source-toggle:not(.active) { opacity: 0.58; }
.chat-header-actions {
  display: flex;
  flex: 0 0 auto;
  margin-left: auto;
  gap: 2px;
  opacity: 0.42;
  transition: opacity 0.15s;
}
.chat-tabs:hover .chat-header-actions,
.chat-header-actions:focus-within { opacity: 1; }
@media (pointer: coarse) {
  .chat-header-actions { opacity: 1; }
}
.chat-online-stats {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 34px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  background: #111114;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chat-online-stats span { display: inline-flex; align-items: center; gap: 5px; }
.chat-online-stats img { width: 17px; height: 17px; object-fit: contain; border-radius: 3px; }
.chat-online-stats strong { color: var(--text); }
.chat-online-stats span:nth-child(2) strong { color: var(--accent); }
.chat-online-stats span:nth-child(3) strong { color: #78a9ff; }
.chat-online-total { padding-left: 9px; border-left: 1px solid var(--border); }
.tab {
  flex: 0 0 auto;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.tab.active { color: var(--text); box-shadow: none; }
.tab-forme { position: relative; }
.tab-forme.active::after {
  content: '×';
  margin-left: 5px;
  color: var(--muted);
  font-weight: 700;
}
.tab-forme.hidden { display: none; }
.tab-badge {
  position: absolute;
  top: 5px;
  margin-left: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--live);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}
.tab-badge.hidden { display: none; }
.chat-header-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chat-header-btn:hover,
.chat-header-btn.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.chat-header-btn svg { width: 16px; height: 16px; fill: currentColor; vertical-align: middle; }
#chat-settings-toggle svg { width: 18px; height: 18px; fill: currentColor; }
#account-toggle.connected { position: relative; color: var(--accent); }
#account-toggle.connected::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px #111114;
}

.chat-settings {
  display: grid;
  position: absolute;
  z-index: 20;
  top: 44px;
  left: 8px;
  right: 8px;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141417;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  font-size: 12px;
}
.chat-settings.hidden { display: none; }
.chat-popout {
  justify-self: stretch;
  margin-top: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f1f24;
  color: #65aaff;
  text-align: center;
  text-decoration: none;
  font-size: 12px;
}
.chat-popout:hover { background: #26262c; color: #8fc0ff; }
.build-version { color: var(--muted); text-align: center; opacity: 0.7; }

/* режим «только чат» (отдельное окно /chat): прячем плеер, чат на всю ширину */
.chat-only .stage { display: none; }
.chat-only .layout { grid-template-columns: 1fr; }
.chat-only .chat { border-left: none; }
.chat-only .chat-resize,
.chat-only .chat-hide-btn,
.chat-only .chat-show-btn,
.chat-only #chat-popout { display: none; }
.chat-only .chat-online-stats { display: flex; }
.chat-settings label { display: grid; grid-template-columns: 78px 1fr 48px; gap: 8px; align-items: center; }
.chat-settings input { width: 100%; accent-color: var(--accent); }
.chat-settings output { color: var(--muted); text-align: right; }
.chat-settings button {
  justify-self: end;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 9px;
  background: #222226;
  color: var(--text);
  cursor: pointer;
}
.chat-settings .push-toggle.active {
  border-color: rgba(83, 252, 24, 0.5);
  color: var(--accent);
}
.chat-settings #chat-time-toggle.active {
  border-color: rgba(83, 252, 24, 0.5);
  color: var(--accent);
}
.chat-blocks {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #2f2f36;
  border-radius: 7px;
  background: #151519;
}
.chat-blocks-head,
.chat-block-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.chat-blocks-head { justify-content: space-between; }
.chat-blocks-head strong { font-size: 12px; }
.chat-blocks-head button,
.chat-block-row button {
  padding: 4px 7px;
  font-size: 11px;
}
.chat-blocks-list {
  display: grid;
  gap: 5px;
  max-height: 132px;
  overflow-y: auto;
}
.chat-block-row {
  min-width: 0;
  padding: 4px 0;
}
.chat-block-source {
  flex: 0 0 auto;
  min-width: 34px;
  border-radius: 4px;
  padding: 2px 5px;
  background: #333;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
.chat-block-source.kick { background: var(--accent); color: #071b06; }
.chat-block-source.vk { background: var(--vk); color: #fff; }
.chat-block-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-block-row button {
  flex: 0 0 auto;
  color: #ff9b9b;
}
.chat-blocks-empty {
  color: var(--muted);
  font-size: 12px;
}
.chat-blocks-empty.hidden { display: none; }

.pinned {
  flex: 0 0 auto;
  max-height: min(30vh, 260px);
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #5d4a16;
  background: #211d12;
  font-size: max(11px, calc(var(--chat-font-size) - 2px));
  min-width: 0;
  max-width: 100%;
}
.pinned-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #302813;
  color: #ffd54a;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pinned-title button {
  border: 0;
  border-radius: 4px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ddd;
  cursor: pointer;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}
.pinned-title button:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.pinned-title-actions { display: flex; min-width: 0; align-items: center; gap: 5px; }
.pinned-collapsed-links { display: none; align-items: center; gap: 4px; }
.pinned-collapsed-links a {
  border: 1px solid #66551f;
  border-radius: 4px;
  padding: 2px 5px;
  background: #352d17;
  color: #65aaff;
  font-size: 10px;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
}
.pinned-collapsed-links a:hover { background: #44391c; color: #fff; }
.pinned.collapsed { max-height: none; }
.pinned.collapsed .pinned-scroll { display: none; }
.pinned.collapsed .pinned-collapsed-links { display: flex; }
.pinned-scroll { overflow-y: auto; padding: 6px 9px 8px; }
.pinned p { margin: 0 0 7px; line-height: 1.35; }
.pinned a { color: #65aaff; text-decoration: none; }
.pinned a:hover { text-decoration: underline; }
.pinned-links { display: flex; flex-wrap: wrap; gap: 7px; }
.pinned-links a {
  border: 1px solid #66551f;
  border-radius: 4px;
  padding: 4px 7px;
  background: #352d17;
  font-weight: 700;
}
.wallets { display: grid; gap: 4px; }
.wallets div { min-width: 0; }
.wallets strong { display: inline-block; min-width: 48px; color: #ffd54a; }
.wallets code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; color: #ddd; }

.feed { flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.feed.hidden { display: none; }

#messages {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 10px;
}
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.chat-composer {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  gap: 3px;
  padding: 4px 8px 5px;
  border-top: 1px solid var(--border);
  background: #111114;
}
.send-targets {
  display: inline-flex;
  flex: 0 0 auto;
  align-self: center;
  min-width: 0;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #2b2b31;
  border-radius: 28px;
  background: #15151a;
}
.send-targets.hidden { display: none; }
.chat-auth-pop button, .send-targets button {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}
.send-targets button { flex: 0 0 auto; }
.send-targets button + button { border-left: 1px solid #2b2b31; }

/* всплывающее меню авторизации под иконкой человечка */
.chat-auth-pop {
  position: absolute;
  z-index: 20;
  top: 44px;
  right: 8px;
  width: min(240px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #141417;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
.chat-auth-pop.hidden { display: none; }
.chat-auth-pop button {
  flex: 0 0 auto;
  border: 1px solid #33333a;
  padding: 8px;
  background: #222226;
  font-size: 12px;
}
.chat-auth-pop button.connected { border-color: #3d7932; color: var(--accent); }

/* нижняя панель иконок: аккаунт + настройки + статус отправки */
.composer-toolbar { display: flex; align-items: center; min-height: 16px; }
.composer-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #33333a;
  border-radius: 6px;
  background: #222226;
  color: var(--muted);
  cursor: pointer;
}
.composer-icon svg { width: 18px; height: 18px; fill: currentColor; }
.composer-icon:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.composer-icon.active { border-color: var(--accent); color: var(--text); background: rgba(83, 252, 24, 0.1); }
.chat-emote-tabs button.hidden { display: none; }
.chat-emote-picker.hidden { display: none; }
.send-targets button.active {
  background: #24242b;
  color: var(--text);
}
.send-targets button:disabled { opacity: 0.35; cursor: not-allowed; }
.chat-reply-compose.hidden { display: none; }
.chat-reply-compose {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 7px;
  border-left: 2px solid #8b72ff;
  border-radius: 3px;
  background: rgba(111, 84, 255, 0.12);
  color: #c9c2e8;
  font-size: 11px;
}
.chat-reply-compose span {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-reply-compose button {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
}
#chat-send-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  min-width: 0;
  gap: 3px 7px;
}
.quick-emotes {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
  padding: 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
}
.quick-emotes::-webkit-scrollbar { display: none; }
.quick-emotes.hidden { display: none; }
.quick-emotes button {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}
.quick-emotes button:hover { background: rgba(255, 255, 255, 0.06); }
.quick-emotes img {
  width: 23px;
  height: 23px;
  object-fit: contain;
}
.chat-input-wrap {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 5px;
  background: #17171b;
}
.chat-input-render {
  position: relative;
  z-index: 4;
  flex: 1;
  min-width: 0;
  min-height: 32px;
  max-height: 154px;
  padding: 7px 38px 6px 9px;
  color: var(--text);
  font: inherit;
  font-size: max(13px, var(--chat-font-size));
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-x: hidden;
  word-break: break-word;
  outline: none;
  user-select: text;
}
.chat-input-render.empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
.chat-input-render .emote {
  height: 1.35em;
  vertical-align: -0.28em;
  margin: 0 1px;
  user-select: all;
}
.chat-compose-row {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
}
#chat-emote-toggle {
  position: absolute;
  z-index: 5;
  right: 6px;
  bottom: 5px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #ffd54a;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
#chat-emote-toggle:hover,
#chat-emote-toggle.active { background: rgba(255, 255, 255, 0.07); }
#chat-message-input {
  display: none;
}
#chat-send-button {
  grid-column: 2;
  grid-row: 3;
  border: 0;
  border-radius: 5px;
  align-self: center;
  padding: 0 14px;
  min-height: 25px;
  background: #51f51e;
  color: #071f08;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
#chat-send-button:hover { filter: brightness(1.04); }
#chat-send-button:disabled { opacity: 0.5; cursor: wait; }
.chat-emote-picker {
  min-height: 0;
  max-height: 190px;
  border: 1px solid #33333a;
  border-radius: 6px;
  background: #18181c;
  overflow: hidden;
}
.chat-emote-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid #33333a; }
.chat-emote-tabs button {
  flex: 1 0 auto;
  border: 0;
  padding: 6px;
  background: #222226;
  color: var(--muted);
  cursor: pointer;
}
.chat-emote-tabs button.active { color: var(--text); box-shadow: inset 0 -2px var(--accent); }
.chat-emote-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 3px;
  max-height: 150px;
  padding: 6px;
  overflow-y: auto;
}
.chat-emote-list button {
  min-width: 0;
  height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 23px;
}
.chat-emote-list button:hover { background: rgba(255, 255, 255, 0.09); }
.chat-emote-list img { width: 30px; height: 30px; object-fit: contain; }
.chat-emote-empty {
  grid-column: 1 / -1;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.vk-emote-help {
  grid-column: 1 / -1;
  padding: 9px 10px;
  color: #aaa;
  font-size: 12px;
  line-height: 1.35;
  border-top: 1px solid #33333a;
}
.vk-emote-help a { color: #7aa7ff; }
.chat-send-status {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.chat-send-status.error { color: #ff7d7d; }
.chat-send-status.success { color: var(--accent); }

.msg {
  position: relative;
  min-width: 0;
  max-width: 100%;
  padding: 4px 6px;
  font-size: var(--chat-font-size);
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  border-radius: 4px;
}
.msg-time {
  display: none;
  margin-right: 5px;
  color: #777781;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
}
.show-chat-time .msg-time { display: inline; }
.msg:hover { background: rgba(255, 255, 255, 0.04); }
.msg-reply-btn {
  position: absolute;
  top: 2px;
  right: 3px;
  display: none;
  border: 0;
  border-radius: 4px;
  padding: 2px 5px;
  background: #303037;
  color: #ddd;
  cursor: pointer;
  font-size: 13px;
}
.msg:hover .msg-reply-btn, .msg:focus-within .msg-reply-btn { display: block; }
.msg.reply-target { outline: 1px solid #9f86ff; background: rgba(111, 84, 255, 0.2); }

/* ответили именно тебе — подсветка + метка «вам» */
.msg.reply-to-me {
  background: rgba(83, 252, 24, 0.12);
  box-shadow: inset 3px 0 0 var(--accent);
}
.msg.mention-to-me {
  background: rgba(83, 252, 24, 0.12);
  box-shadow: inset 3px 0 0 var(--accent);
}
.msg.reply-to-me:hover, .msg.mention-to-me:hover { background: rgba(83, 252, 24, 0.18); }
.msg.reply-to-me .reply { border-left-color: var(--accent); }
.msg.reply-to-me .reply-name::after {
  content: ' • вам';
  color: var(--accent);
  font-weight: 700;
}
.msg .reply {
  display: block;
  max-width: 94%;
  margin: 0 0 3px 24px;
  padding-left: 7px;
  border-left: 2px solid #6f54ff;
  color: #a8a8b3;
  font-size: 0.82em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg .reply[data-parent-id] { cursor: pointer; }
.msg .reply[data-parent-id]:hover { color: #ddd; border-left-color: #9f86ff; }
.msg .reply-label { color: #8d8d96; }
.msg .reply-name { color: #b89cff; font-weight: 700; }
.msg .reply-text { color: #b8b8c0; }
.msg .reply .emote { height: 1.3em; vertical-align: -0.28em; }
.msg .who { font-weight: 700; cursor: pointer; }
.msg .who { opacity: var(--chat-nick-opacity); }
.msg .who:hover { text-decoration: underline; }
.msg .badge {
  font-size: 10px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 5px;
  vertical-align: middle;
}
.msg.kick .badge { background: var(--accent); color: #000; }
.msg.vk .badge { background: var(--vk); color: #fff; }
.msg.system { color: var(--muted); font-style: italic; }
.msg .text { min-width: 0; overflow-wrap: anywhere; }
.msg .text,
.msg .reply { opacity: var(--chat-message-opacity); }
.msg .text a { color: #4d9fff; text-decoration: none; word-break: break-all; overflow-wrap: anywhere; }
.msg .text a:hover { text-decoration: underline; }
.msg .mention { color: #ffd54a; font-weight: 600; }
/* em → смайлы и иконки растут вместе с размером текста чата */
.emote { height: 1.55em; vertical-align: -0.32em; margin: 0 1px; }
.ubadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 1.2em;
  margin-right: 3px;
  border-radius: 3px;
  vertical-align: -0.22em;
  object-fit: contain;
}
.ubadge svg { width: 1.2em; height: 1.2em; fill: currentColor; }
.ubadge-moderator { color: #53fc18; }
.ubadge-broadcaster, .ubadge-owner { color: #ff4d4d; }
.ubadge-vip { color: #d8a7ff; }
.ubadge-subscriber { color: #ffd54a; }
.ubadge-founder { color: #ffc44d; }
.ubadge-og { color: #8fd7ff; }
.ubadge-sub_gifter { color: #ff8fc7; }
.ubadge-staff, .ubadge-verified { color: #53b9ff; }

#vk-frame { width: 100%; height: 100%; border: none; }

/* ----- скрытие чата ----- */
/* плеер на всю ширину; высоту строки держит базовый grid-template-rows */
.layout.chat-hidden { grid-template-columns: 1fr; }
.layout.chat-hidden .chat { display: none; }
.chat-hide-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.chat-hide-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.chat-show-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.chat-show-btn.hidden { display: none; }

.pwa-install-offer {
  position: static;
  z-index: auto;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(83, 252, 24, 0.35);
  border-radius: 5px;
  background: rgba(83, 252, 24, 0.08);
  overflow: hidden;
  text-transform: none;
  letter-spacing: 0;
}
.pwa-install-offer.hidden { display: none; }
.pwa-install {
  border: 0;
  padding: 3px 6px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}
.pwa-install-close {
  width: 23px;
  height: 23px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.pwa-install:hover, .pwa-install-close:hover { background: #202024; }

.pwa-ios-hint {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  width: min(360px, calc(100vw - 24px));
  transform: translateX(-50%);
  display: grid;
  gap: 5px;
  padding: 14px 44px 14px 16px;
  border: 1px solid #34343a;
  border-radius: 14px;
  background: rgba(24, 24, 27, 0.97);
  color: var(--text);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(16px);
}
.pwa-ios-hint span { color: var(--muted); font-size: 13px; line-height: 1.35; }
.pwa-ios-hint button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}
.pwa-ios-hint.hidden { display: none; }

/* ----- кошельки: клик = копировать ----- */
.wallets code {
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 3px;
  transition: background 0.15s;
}
.wallets code:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.wallets code.copied { background: var(--accent); color: #06210a; }
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--accent);
  color: #06210a;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.copy-toast.show { opacity: 1; }

.user-action-menu {
  position: fixed;
  z-index: 65;
  display: grid;
  gap: 5px;
  width: 176px;
  border: 1px solid #34343b;
  border-radius: 7px;
  padding: 7px;
  background: #18181c;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.68);
}
.user-action-menu.hidden { display: none; }
.user-action-menu strong {
  overflow: hidden;
  padding: 2px 4px 5px;
  color: #ffd54a;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-action-menu button {
  border: 0;
  border-radius: 5px;
  padding: 7px 9px;
  background: #29292e;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}
.user-action-menu button:hover,
.user-action-menu button:focus-visible { background: #36363d; outline: none; }
.user-action-menu button.danger { color: #ff7b7b; }

.user-history-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.72);
}
.user-history-modal.hidden { display: none; }
.user-history-card {
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  max-height: min(88vh, 900px);
  overflow: hidden;
  border: 1px solid #3a3a42;
  border-radius: 10px;
  background: #18181c;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}
.user-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #303038;
}
.user-history-head > div:first-child { min-width: 0; }
.user-history-heading {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-left: 170px;
}
.user-history-title { overflow-wrap: anywhere; }
.user-history-count { color: var(--muted); font-size: 12px; }
.user-history-platform {
  display: inline-block;
  margin-right: 7px;
  border-radius: 4px;
  padding: 2px 6px;
  background: #333;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.user-history-platform.kick { background: var(--accent); color: #081d08; }
.user-history-platform.vk { background: var(--vk); color: #fff; }
.user-history-actions { display: flex; gap: 6px; }
.user-history-actions button, .user-history-more {
  border: 1px solid #3b3b44;
  border-radius: 6px;
  padding: 6px 10px;
  background: #27272d;
  color: var(--text);
  cursor: pointer;
}
#user-history-tag { border-color: #3d7932; color: var(--accent); }
#user-history-block.danger { border-color: #6e3030; color: #ff7b7b; }
#user-history-close { min-width: 34px; font-size: 18px; }
.user-history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 100px;
  overflow-y: auto;
  padding: 12px 18px 18px;
}
.user-history-day {
  padding: 16px 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.user-history-message {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: baseline;
  padding: 5px 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.user-history-message time {
  padding-right: 12px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.user-history-content { min-width: 0; }
.user-history-content .badge img { width: 16px; height: 16px; vertical-align: -3px; }
.user-history-content .who { font-weight: 800; }
.user-history-message .reply {
  display: inline;
  margin-right: 5px;
  color: var(--muted);
  font-size: 12px;
}
.user-history-more {
  margin: 0 10px 10px;
}
.user-history-more.hidden, .user-history-empty.hidden { display: none; }
.user-history-empty { padding: 24px; color: var(--muted); text-align: center; }
@media (max-width: 680px) {
  .user-history-heading { align-items: flex-start; padding-left: 0; }
  .user-history-actions { gap: 3px; }
  .user-history-actions button:not(#user-history-close) { display: none; }
  .user-history-list { padding-inline: 9px; }
  .user-history-message { grid-template-columns: 48px minmax(0, 1fr); }
  .user-history-message time { padding-right: 8px; }
}
.chat-search-card { height: min(78vh, 720px); }
.chat-search-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #303038;
}
.chat-search-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid #454550;
  border-radius: 6px;
  padding: 8px 10px;
  background: #0f0f12;
  color: var(--text);
  font: inherit;
}
.chat-search-form button, #chat-search-close {
  border: 1px solid #3b3b44;
  border-radius: 6px;
  padding: 7px 12px;
  background: #27272d;
  color: var(--text);
  cursor: pointer;
}
.chat-search-status { padding: 7px 10px; color: var(--muted); font-size: 12px; }
.chat-search-message .search-author { margin-right: 5px; font-weight: 700; }
.chat-search-message .user-history-platform { margin-right: 5px; }

/* ----- иконки платформ в бейджах ----- */
.msg .badge { background: transparent !important; padding: 0; border-radius: 0; font-size: inherit; }
.msg .badge img { width: 1.2em; height: 1.2em; border-radius: 3px; vertical-align: -0.22em; object-fit: cover; }

/* ----- спиннер загрузки ----- */
.spinner {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 54px; height: 54px;
  z-index: 3;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  pointer-events: none;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ----- плашка «догоняю эфир» ----- */
.catchup {
  position: absolute;
  left: 50%; bottom: 64px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.catchup:not(.hidden) { opacity: 1; }

/* ----- подсказки перемотки по двойному тапу ----- */
.seek-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30%;
  height: 70%;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.seek-hint-left { left: 0; border-radius: 0 50% 50% 0 / 0 50% 50% 0; }
.seek-hint-right { right: 0; border-radius: 50% 0 0 50% / 50% 0 0 50%; }
.seek-hint.show { opacity: 1; }

/* ----- ручка изменения ширины чата ----- */
.chat-resize {
  position: absolute;
  left: -4px; top: 0; bottom: 0;
  width: 9px;
  z-index: 15;
  cursor: col-resize;
  touch-action: none;
}
.chat-resize::before {
  content: '';
  position: absolute;
  left: 3px; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s;
}
.chat-resize:hover::before { background: var(--accent); }
body.resizing-chat { user-select: none; cursor: col-resize; }
body.resizing-chat .chat-resize::before { background: var(--accent); }

/* ----- автодополнение @упоминаний ----- */
.mention-suggest {
  display: flex;
  flex-direction: column;
  max-height: 198px;
  overflow-y: auto;
  border: 1px solid #33333a;
  border-radius: 6px;
  background: #1b1b20;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45);
}
.mention-suggest.hidden { display: none; }
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}
.mention-item:hover, .mention-item.active { background: rgba(83, 252, 24, 0.14); }
.mention-item img { width: 16px; height: 16px; border-radius: 3px; flex: 0 0 auto; object-fit: cover; }
.mention-item img.emote-suggest-img { width: 24px; height: 24px; border-radius: 0; object-fit: contain; }
.mention-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 800px) {
  :root { --chat-width: 100vw; }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
  }
  .stage { width: 100%; max-width: 100vw; }
  .player {
    width: 100%;
    max-width: 100vw;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .stage { align-items: stretch; }
  .chat { border-left: none; border-top: 1px solid var(--border); }
  .online-stats {
    top: 6px;
    left: 6px;
    gap: 2px;
    max-width: calc(100% - 12px);
    padding: 3px;
    font-size: 10px;
  }
  .online-stats span, .online-stats a { padding: 2px 3px; }
  .controls {
    height: 84px;
    display: grid;
    grid-template-columns: 40px 40px minmax(48px, auto) 40px 36px 36px 38px minmax(48px, auto) 40px 40px;
    grid-template-rows: 32px 48px;
    gap: 0 2px;
    padding: 2px max(5px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left));
    background: linear-gradient(transparent 0, rgba(0, 0, 0, 0.78) 30%, rgba(0, 0, 0, 0.94) 100%);
  }
  .clickcatch { bottom: 84px; }
  .ctl {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
    border-radius: 9px;
    touch-action: manipulation;
  }
  .ctl svg { width: 23px; height: 23px; }
  #btn-play { grid-column: 1; grid-row: 2; }
  .vol { grid-column: 2; grid-row: 2; }
  .seek {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    height: 32px;
    padding: 0 5px;
    touch-action: none;
  }
  .seek-track { height: 6px; }
  .seek-knob { width: 16px; height: 16px; opacity: 1; }
  .behind { display: none; }
  #btn-live { grid-column: 3; grid-row: 2; }
  #btn-ll { grid-column: 4; grid-row: 2; min-width: 38px; padding-inline: 4px; font-size: 11px; }
  #btn-cc { grid-column: 5; grid-row: 2; min-width: 34px; padding-inline: 5px; font-size: 11px; letter-spacing: 0; }
  #btn-shazam { grid-column: 6; grid-row: 2; min-width: 36px; padding-inline: 3px; }
  .player.rtc-mode #btn-ll { grid-column: 4; margin-left: 0; }
  .player.rtc-mode #btn-cc { grid-column: 5; }
  .speed { grid-column: 7; grid-row: 2; justify-self: stretch; }
  .speed .ctl { width: 100%; }
  .quality { grid-column: 8; grid-row: 2; justify-self: stretch; }
  .quality .ctl { width: 100%; }
  #btn-pip { grid-column: 9; grid-row: 2; }
  #btn-fs { grid-column: 10; grid-row: 2; }
  .vol-popup {
    bottom: calc(100% - 2px);
    padding: 14px 12px;
  }
  .vol-range {
    display: block;
    width: 10px;
    height: 112px;
  }
  .q-btn { min-width: 48px; font-size: 11px; }
  .live { gap: 4px; font-size: 11px; }
  .quality-menu { bottom: 50px; right: 0; }
  .speed-menu { right: -42px; }
  .unmute {
    top: max(10px, env(safe-area-inset-top));
    max-width: calc(100% - 24px);
    min-height: 42px;
  }
  .ll-intro {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(90px + env(safe-area-inset-bottom));
    width: min(360px, calc(100% - 16px));
  }
  .bigplay { width: 72px; height: 72px; }
  .pinned {
    max-height: 128px;
    font-size: 10px;
  }
  .pinned-title { padding: 4px 8px; font-size: 10px; }
  .pinned-scroll { padding: 5px 8px 6px; }
  .pinned p { margin-bottom: 4px; line-height: 1.25; }
  .pinned-links { gap: 4px; }
  .pinned-links a { padding: 2px 5px; }
  .wallets { gap: 2px; }
  .wallets strong { min-width: 42px; }
  .msg { padding-right: 2px; padding-left: 2px; }
  .msg .reply { max-width: calc(100% - 18px); margin-left: 18px; }
  .chat-composer { padding: 4px 7px 5px; }
  #chat-send-form { gap: 3px 7px; }
  .send-targets button { min-height: 25px; padding: 0 11px; font-size: 11px; }
  #chat-send-button { min-height: 31px; padding-right: 13px; padding-left: 13px; font-size: 12px; }

  /* мобилка: тащить край чата не нужно (он на всю ширину), крупнее тапы */
  .chat-resize { display: none; }
  .composer-icon { width: 38px; height: 38px; }
  .composer-icon svg { width: 20px; height: 20px; }
  #chat-emote-toggle { width: 26px; height: 26px; }
  .chat-auth-pop button { min-height: 36px; }
  .catchup { bottom: 92px; font-size: 11px; padding: 4px 10px; }
  .seek-hint { font-size: 20px; }
  .spinner { width: 44px; height: 44px; border-width: 3px; }
  .chat-emote-list { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
  .chat-emote-list button { height: 42px; }
  .chat-tabs {
    min-height: 40px;
    padding: 5px 8px;
    gap: 5px;
  }
  .source-toggle { min-width: 48px; height: 25px; }
  .chat-header-actions { gap: 1px; }
  .chat-header-btn,
  .chat-hide-btn {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .layout.chat-hidden {
    grid-template-rows: minmax(0, 1fr);
  }
  .layout.chat-hidden .stage { height: 100%; }
  .layout.chat-hidden .player {
    height: 100%;
    aspect-ratio: auto;
  }
  .chat-show-btn {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(24, 24, 27, 0.92);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
  }
  .pwa-install {
    padding: 2px 5px;
    font-size: 9px;
  }
  .pwa-install-close { width: 21px; height: 21px; }
}

@media (hover: none), (pointer: coarse) {
  .msg:not(.system) { padding-right: 32px; }
  .msg-reply-btn { display: block; opacity: 0.65; }
}

@media (max-width: 480px) {
  .online-stats span:nth-child(4),
  .online-stats a { display: none; }
  .tab { font-size: 12px; }
  .source-toggle { min-width: 44px; padding: 0 8px; }
  .chat-hide-btn { width: 34px; height: 34px; flex-basis: 34px; }
  #btn-pip { display: none; }
  .speed { display: none; }
  .controls {
    grid-template-columns: 40px 40px minmax(49px, auto) 34px 36px 36px minmax(48px, auto) 40px;
  }
  #btn-cc { grid-column: 5; }
  #btn-shazam { grid-column: 6; }
  .quality { grid-column: 7; }
  #btn-pip { grid-column: 8; }
  #btn-fs { grid-column: 8; }
}

@media (max-width: 380px) {
  html.pwa-standalone #btn-pip {
    display: flex;
    grid-column: 8;
  }
  html.pwa-standalone #btn-fs { display: none; }
}

@media (display-mode: standalone) {
  html, body {
    height: 100%;
    padding: 0;
    overflow: hidden;
  }
  .layout {
    height: 100%;
    min-height: 0;
    padding-top: env(safe-area-inset-top);
  }
  .pwa-install-offer { display: none !important; }
}

/* Ветка ответов — компактный всплывающий поповер с деревом цепочки */
.thread-panel {
  position: fixed;
  left: 0; top: 0;                 /* координаты ставит JS — у места клика */
  width: min(380px, 92vw);
  max-height: min(62vh, 520px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.62);
  z-index: 80;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.thread-panel.open { display: flex; animation: thread-pop 0.12s ease-out; }
@keyframes thread-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.thread-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.thread-head strong { font-size: 13px; }
.thread-head button {
  background: none; border: none; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.thread-head button:hover { color: #fff; }
.thread-body { flex: 1 1 auto; overflow-y: auto; padding: 8px 10px; }
.thread-body .thread-msg {
  margin: 5px 0 5px calc(min(var(--depth, 0), 8) * 14px);
  border-left: 2px solid var(--border);
  padding-left: 8px;
}
.thread-body .thread-msg.thread-current {
  background: rgba(83, 252, 24, 0.10);
  border-left-color: var(--accent);
  border-radius: 4px;
}

/* Меню действий по нику — выше панели ветки (z-index 80) */
.user-action-menu { z-index: 90; }
/* Кнопка перехода к сообщению внутри ветки */
.thread-jump {
  margin-left: 6px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  vertical-align: middle;
}
.thread-jump:hover { color: var(--accent); }
