:root {
  --bg: #0d0f14;
  --panel: #151922;
  --panel-2: #1c212d;
  --line: #262c3a;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #2787f5;      /* фирменный синий VK */
  --accent-2: #5aa8ff;
  --live: #ff3b47;
  --mod: #ffb020;
  --error: #ff6b6b;
  --radius: 14px;
  --chat-w: 380px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2740 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- Шапка ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 15, 20, .7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.live-dot.on { background: var(--live); box-shadow: 0 0 0 0 rgba(255, 59, 71, .6); animation: ping 1.6s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 10px rgba(255, 59, 71, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 59, 71, 0); } }
.online { color: var(--muted); font-size: 14px; white-space: nowrap; }
.online .eye { color: var(--live); font-size: 10px; vertical-align: 2px; }

/* ---------- Раскладка ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--chat-w);
  gap: 20px;
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100dvh - 59px);
}
.stage { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 59px - 40px - 90px);
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: linear-gradient(160deg, #111827, #0b0d12);
}
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); margin-bottom: 18px; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .4; } }
.empty-title { font-size: clamp(20px, 3vw, 30px); font-weight: 700; margin: 0 0 8px; }
.empty-sub { color: var(--muted); margin: 0; max-width: 420px; }

.stage-info h1 { font-size: clamp(18px, 2.2vw, 24px); margin: 0 0 4px; }
.hint { color: var(--muted); margin: 0; font-size: 13px; }

/* ---------- Чат ---------- */
.chat {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
  overflow: hidden;
}
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.chat-status { color: var(--muted); font-weight: 400; font-size: 12px; }

.messages {
  list-style: none; margin: 0; padding: 10px 6px 10px 12px;
  flex: 1; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.msg {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 6px 8px; border-radius: 10px;
  line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg:hover { background: var(--panel-2); }
.msg.mine { background: rgba(39, 135, 245, .08); }
.msg.mod { background: rgba(255, 176, 32, .1); border: 1px solid rgba(255, 176, 32, .25); }
.avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--panel-2); object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.msg-body { min-width: 0; }
.msg-name { font-weight: 600; font-size: 13px; margin-right: 6px; }
.msg.mod .msg-name { color: var(--mod); }
.msg-time { color: var(--muted); font-size: 11px; }
.msg-text { white-space: pre-wrap; }
.sys { color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }

.new-below {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 140px;
  border: 0; border-radius: 999px; padding: 6px 14px;
  background: var(--accent); color: #fff; cursor: pointer; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}

.chat-foot { border-top: 1px solid var(--line); padding: 12px; background: var(--panel); }
.login-title { margin: 0 0 10px; color: var(--muted); font-size: 14px; text-align: center; }
#vkidContainer:empty { display: none; }
#vkidContainer { margin-bottom: 10px; }
.guest { display: flex; gap: 8px; }
.guest input, .compose textarea {
  flex: 1; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.guest input:focus, .compose textarea:focus { border-color: var(--accent); }
.guest button, .compose button[type=submit] {
  border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  padding: 0 16px; cursor: pointer; font-weight: 600;
}
.guest button:hover, .compose button[type=submit]:hover { background: var(--accent-2); }
.compose button[type=submit]:disabled { opacity: .5; cursor: default; }

.me { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.me-name { font-weight: 600; color: var(--text); }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; font-size: 13px; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { resize: none; max-height: 120px; line-height: 1.4; overflow-y: hidden; }
.compose button[type=submit] { height: 42px; font-size: 18px; }
.error { color: var(--error); font-size: 13px; margin: 6px 0 0; min-height: 0; }
.error:empty { display: none; }

/* ---------- Мобильные ---------- */
@media (max-width: 900px) {
  .top { padding: 10px 16px; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0; gap: 0;
    height: calc(100dvh - 51px);
  }
  .player { border-radius: 0; border: 0; max-height: none; }
  .stage { gap: 0; }
  .stage-info { padding: 10px 16px; }
  .hint { display: none; }
  .chat { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .chat-head { padding: 10px 16px; }
  .chat-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .new-below { bottom: 120px; }
}
