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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-width);
  height: 100vh;
}

/* ---------------- player ---------------- */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-width: 0;
}

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

/* 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; }
.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;
}
.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; }

.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:hover .controls,
.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 { display: flex; align-items: center; }
.vol-range {
  width: 0;
  opacity: 0;
  transition: width 0.18s, opacity 0.18s;
  accent-color: var(--accent);
}
.vol:hover .vol-range { width: 80px; opacity: 1; margin-left: 4px; }

.seek { flex: 1; height: 56px; display: flex; align-items: center; cursor: pointer; min-width: 40px; }
.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; }

.quality { position: relative; }
.q-btn { font-size: 13px; font-weight: 600; min-width: 48px; }
.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; }
.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 {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  min-height: 0;
}
.chat-tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 12px 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.chat-settings-toggle {
  width: 48px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}
.chat-settings-toggle:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.chat-settings {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: #141417;
  font-size: 12px;
}
.chat-settings.hidden { display: none; }
.chat-settings label { display: grid; grid-template-columns: 48px 1fr 52px; 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;
}

.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));
}
.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; 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-height: 0; overflow: hidden; }
.feed.hidden { display: none; }

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

.msg {
  padding: 4px 6px;
  font-size: var(--chat-font-size);
  line-height: 1.45;
  word-wrap: break-word;
  border-radius: 4px;
}
.msg:hover { background: rgba(255, 255, 255, 0.04); }
.msg.reply-target { outline: 1px solid #9f86ff; background: rgba(111, 84, 255, 0.2); }
.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: 18px; vertical-align: -5px; }
.msg .who { font-weight: 700; }
.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 a { color: #4d9fff; text-decoration: none; word-break: break-all; }
.msg .text a:hover { text-decoration: underline; }
.msg .mention { color: #ffd54a; font-weight: 600; }
.emote { height: 22px; vertical-align: -6px; margin: 0 1px; }

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

/* ----- скрытие чата ----- */
.layout.chat-hidden { grid-template-columns: minmax(0, 1fr) 0; }
.layout.chat-hidden .chat { display: none; }
.chat-hide-btn {
  width: 40px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}
.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; }

/* ----- кошельки: клик = копировать ----- */
.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; }

/* ----- иконки платформ в бейджах ----- */
.msg .badge { display: inline-flex; align-items: center; gap: 3px; }
.msg .badge svg { width: 11px; height: 11px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .player { aspect-ratio: 16 / 9; height: auto; }
  .stage { align-items: stretch; }
  .chat { border-left: none; border-top: 1px solid var(--border); }
  .chat-settings label:nth-child(2) { display: none; }
  .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; }
}
