:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel2: #1b2330;
  --line: #263043;
  --text: #e8edf4;
  --muted: #8b98ab;
  --accent: #ff7a1a;
  --accent2: #2fbf71;
  --hot: #ff4d4d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
@media (min-width: 961px) {
  body { height: 100vh; overflow: hidden; }
}
.hidden { display: none !important; }

/* topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 26px; width: auto; display: block; }
.live-meta { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--muted); }
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  color: #fff; background: var(--hot); border-radius: 6px; padding: 3px 10px; font-weight: 700; font-size: 12px;
}
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* layout */
.layout {
  flex: 1; display: grid; grid-template-columns: 1fr 360px; gap: 16px;
  padding: 16px 20px; max-width: 1400px; width: 100%; margin: 0 auto;
  min-height: 0;
}
.stage { display: flex; flex-direction: column; min-height: 0; }
.room-title { font-size: 20px; margin-bottom: 12px; }

/* player */
.player {
  position: relative; aspect-ratio: 16/9; background: #000;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
@media (min-width: 961px) {
  .player { aspect-ratio: none; flex: 1; min-height: 0; }
}
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }

.player-placeholder {
  z-index: 2;
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, #131c2b 0%, #05070b 100%);
  text-align: center;
}
.ph-icon { font-size: 54px; color: var(--accent); opacity: .9; }
.ph-text { color: var(--muted); line-height: 1.5; }
.speed { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.player-hud {
  z-index: 3;
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center;
  padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.85));
}
.hud-btn { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.hud-progress { flex: 1; height: 5px; background: #333; border-radius: 3px; overflow: hidden; }
.hud-progress-fill { height: 100%; width: 0; background: var(--accent); }
.hud-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* offers: иконки слева + одна активная кнопка — всё в одну строку */
.offer-row { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.offer-row:has(.offer-active:empty):has(.offer-icons:empty) { display: none; }
.offer-icons { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.offer-icon {
  width: 46px; height: 46px; border-radius: 12px; font-size: 20px;
  background: var(--panel2); border: 1px solid var(--line); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: border-color .2s, transform .2s;
}
.offer-icon:hover { border-color: var(--accent); transform: scale(1.08); }
.offer-active { flex: 1; min-width: 0; }
.offer-active .offer-bar {
  margin-top: 0; padding: 0; background: none; border: none; box-shadow: none; animation: none;
}
.offer-active .offer-bar .btn { height: 46px; padding: 0 16px; font-size: 14.5px; border-radius: 12px; }

/* test bar (?test=1) */
.test-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; background: rgba(0,0,0,.85); backdrop-filter: blur(4px);
}
.tb-label { font-size: 10px; font-weight: 800; color: #ffd166; letter-spacing: .1em; }
.test-bar input[type="range"] { flex: 1; accent-color: var(--accent); }
.tb-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); font-size: 12px; padding: 4px 9px; cursor: pointer;
}
.tb-btn:hover { border-color: var(--accent); }
.tb-reset { color: var(--hot); }

/* offer bars */
.offer-bar {
  margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  font-size: 14px; line-height: 1.4; animation: slideUp .4s ease;
}
.offer-hot { border-color: var(--hot); box-shadow: 0 0 24px rgba(255,77,77,.15); }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }

/* cta bar */
.cta-bar {
  margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap;
  animation: slideUp .4s ease;
}
.cta-bar .btn { flex: 1; min-width: 180px; padding: 13px 14px; font-size: 14px; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.modal-title { font-size: 18px; font-weight: 800; }
.modal-sub { font-size: 13px; color: var(--muted); line-height: 1.5; }
.modal input {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 11px 12px; font-size: 14px; outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* buttons */
.btn {
  border: none; border-radius: 9px; padding: 10px 18px; font-size: 14px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.1); }
.btn-hot { background: var(--hot); color: #fff; }
.btn-hot:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.linklike { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

/* chat */
.chat {
  display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; min-height: 480px;
}
@media (min-width: 961px) {
  .chat { min-height: 0; height: 100%; }
}
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px;
}
.chat-you { font-weight: 400; font-size: 12px; color: var(--muted); }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: 13.5px; line-height: 1.45; }
.msg-name { font-weight: 700; font-size: 12px; margin-bottom: 2px; }
.msg-user .msg-name { color: #7ab3ff; }
.msg-peer .msg-name { color: var(--muted); }
.msg-system { background: rgba(47,191,113,.1); border: 1px solid rgba(47,191,113,.35); border-radius: 10px; padding: 8px 10px; }
.msg-system .msg-name { color: var(--accent2); }
.msg-manager { background: rgba(255,122,26,.1); border: 1px solid rgba(255,122,26,.4); border-radius: 10px; padding: 8px 10px; }
.msg-manager .msg-name { color: var(--accent); }
/* персональная CTA-карточка в чате */
.msg-cta { background: none !important; border: none !important; padding: 0 !important; }
.cta-personal {
  background: linear-gradient(135deg, rgba(255,77,77,.12), rgba(255,122,26,.12));
  border: 1px solid var(--hot); border-radius: 12px; padding: 12px;
  box-shadow: 0 0 20px rgba(255,77,77,.18);
  animation: ctaGlow 2s ease-in-out infinite;
}
@keyframes ctaGlow { 50% { box-shadow: 0 0 32px rgba(255,77,77,.35); } }
.cta-badge {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: #fff; background: var(--hot);
  border-radius: 5px; padding: 2px 8px; margin-bottom: 8px;
}
.cta-personal .msg-name { color: var(--accent2); margin-bottom: 4px; }
.cta-text { font-size: 13.5px; line-height: 1.5; margin-bottom: 10px; }
.cta-btn { width: 100%; padding: 12px; font-size: 14px; }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 10px 12px; font-size: 14px; outline: none;
}
.chat-form input:focus { border-color: var(--accent); }

/* manager page */
.manager-wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px; }
.manager-wrap h1 { font-size: 20px; margin-bottom: 6px; }
.manager-wrap .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.q-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.q-card.answered { opacity: .55; }
.q-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.q-text { font-size: 15px; margin-bottom: 10px; }
.q-answer { display: flex; gap: 8px; }
.q-answer input {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); padding: 9px 12px; font-size: 14px; outline: none;
}
.q-given { margin-top: 8px; font-size: 13.5px; color: var(--accent2); }
.events { margin-top: 32px; }
.events h2 { font-size: 16px; margin-bottom: 10px; }
.event-row { font-size: 13px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.event-row b { color: var(--text); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 10px 12px; gap: 12px; }
  .chat { min-height: 380px; }

  /* topbar: компактно */
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .brand-logo { height: 18px; }
  .live-meta { gap: 8px; font-size: 11px; }
  .live-badge { font-size: 10px; padding: 2px 7px; }
  .elapsed { display: none; } /* экономим место, прогресс виден в плеере */

  /* контент */
  .room-title { font-size: 15px; margin-bottom: 8px; line-height: 1.3; }
  .player { aspect-ratio: 16/9; border-radius: 10px; }
  .ph-icon { font-size: 36px; }
  .ph-text { font-size: 13px; }
  .speed { font-size: 11px; }
  .hud-time { font-size: 11px; }
  .hud-btn { font-size: 16px; }

  /* CTA: кнопки во всю ширину, крупные для пальца */
  .cta-bar { flex-direction: column; gap: 8px; margin-top: 10px; }
  .cta-bar .btn { min-width: 0; width: 100%; padding: 14px; font-size: 15px; }

  /* офферы: вертикально, кнопка во всю ширину */
  .offer-bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; font-size: 13px; margin-top: 10px; }
  .offer-bar .btn { width: 100%; padding: 13px; }

  /* чат */
  .chat { border-radius: 10px; height: 62vh; min-height: 0; }
  .chat-head { padding: 10px 12px; font-size: 13px; }
  .chat-messages { padding: 10px 12px; }
  .chat-form { padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .chat-form input { font-size: 16px; padding: 12px; } /* 16px — без автозума на iOS */
  .chat-form .btn { padding: 12px 16px; }

  /* модалка на весь экран */
  .modal { width: calc(100vw - 32px); padding: 18px; }
  .modal input { font-size: 16px; padding: 13px 12px; }
  .modal-actions .btn { flex: 1; }
}
