:root {
  --bg: #17120b;
  --surface: #211a13;
  --surface-2: #2b241b;
  --surface-3: #352e25;
  --border: #383027;
  --border-strong: #4e463d;
  --text: #f3efec;
  --text-2: #bdb6ae;
  --text-3: #8c857c;
  --screen: #050402;
  --danger: #f97770;
  --accent: #f8ac3d;
  --accent-hover: #fec171;
  --accent-text: #f8ac3d;
  --on-accent: #16100a;
  --accent-soft: rgba(248, 172, 61, 0.16);
  --accent-ring: rgba(248, 172, 61, 0.45);
  --glow: rgba(248, 172, 61, 0.1);
  --shadow: rgba(0, 0, 0, 0.45);

  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Unbounded', var(--font);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --gutter: 20px;
  --topbar-h: 64px;
  --side-w: clamp(320px, 27vw, 400px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: radial-gradient(ellipse 90% 55% at 50% -12%, var(--glow), transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body.in-room {
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

button:disabled { cursor: default; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden { display: none !important; }

.icon { width: 20px; height: 20px; flex-shrink: 0; display: block; }

.input {
  width: 100%; height: 48px; padding: 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 16px; outline: none; -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:hover { border-color: var(--border-strong); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.7; }
.btn-primary.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn-primary.is-loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--on-accent);
  border-top-color: transparent;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-lg { height: 52px; font-size: 16px; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-quiet { color: var(--text-2); border: 1px solid var(--border); }
.btn-quiet .icon { width: 18px; height: 18px; }
@media (hover: hover) { .btn-quiet:hover { color: var(--text); background: var(--surface-2); } }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--border); color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn[aria-expanded='true'] { color: var(--text); background: var(--surface-2); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn-sm .icon { width: 18px; height: 18px; }
@media (hover: hover) { .icon-btn:hover { color: var(--text); background: var(--surface-2); } }

.join {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: max(72px, calc(env(safe-area-inset-top) + 64px)) max(20px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.join-theme-btn { position: fixed; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 5; background: var(--bg); }
.join-inner { width: 100%; max-width: 400px; text-align: center; }
.hall-art { display: block; width: min(100%, 300px); height: auto; margin: 0 auto 28px; overflow: visible; }
.beam-stop { stop-color: var(--accent); }
.hall-screen { stroke: var(--accent); }
.hs-back { fill: var(--surface-3); }
.hs-arm { fill: var(--border-strong); }
.hs-you .hs-back { fill: var(--accent); }
.hs-you .hs-arm { fill: var(--accent); opacity: 0.55; }

.wordmark { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 8.4vw, 40px); line-height: 1.1; letter-spacing: -0.02em; }
.lead { margin: 12px auto 0; max-width: 32ch; font-size: 16px; line-height: 1.5; color: var(--text-2); text-wrap: pretty; }

.join-form {
  margin-top: 32px;
  display: grid;
  gap: 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: 0 16px 40px -12px var(--shadow);
}

.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.form-error { margin: -4px 0 -6px; min-height: 0; font-size: 14px; color: var(--danger); }
.form-error:empty { display: none; }
.join-form .btn { margin-top: 4px; width: 100%; }
.join-note { margin: 18px auto 0; max-width: 34ch; font-size: 13px; line-height: 1.5; color: var(--text-3); text-wrap: pretty; }

.name-row { display: flex; gap: 8px; }
.name-row .input { flex: 1; }
.avatar-preview {
  width: 48px; height: 48px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid var(--border);
  overflow: hidden; padding: 0; background: var(--surface-2);
  transition: border-color 0.2s;
}
.avatar-preview:hover { border-color: var(--accent); }

.avatar-picker {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  margin-top: -4px;
  animation: slide-down 0.2s var(--ease);
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.avatar-picker-title { font-size: 13px; color: var(--text-3); margin-bottom: 10px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.avatar-item {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  overflow: hidden;
  background: var(--surface);
  transition: transform 0.15s, border-color 0.2s;
}
.avatar-item:hover { transform: scale(1.08); }
.avatar-item.is-active { border-color: var(--accent); }

.avatar-svg { width: 100%; height: 100%; display: block; }
img.avatar-svg { object-fit: cover; border-radius: 50%; }

.app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-height, 100dvh); display: flex; flex-direction: column; }

.topbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 16px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { width: 28px; height: 28px; }
.bm-screen { fill: var(--accent); }
.bm-seat { fill: var(--text-3); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.room-chip { min-width: 0; display: flex; align-items: baseline; gap: 8px; padding-left: 16px; border-left: 1px solid var(--border); line-height: 1.2; }
.room-chip-label { font-size: 13px; color: var(--text-3); flex-shrink: 0; }
.room-chip-id { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.conn-status {
  font-size: 12px;
  color: var(--text-3);
  transition: color 0.3s;
  user-select: none;
}
.conn-status.is-online { color: #4ade80; }
.conn-status.is-offline { color: var(--danger); }

.layout {
  flex: 1; min-height: 0; width: 100%; max-width: 1720px; margin: 0 auto;
  display: flex; gap: var(--gutter);
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.stage-col { --below: 176px; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; container-type: size; }
.stage { position: relative; width: 100%; display: flex; justify-content: center; }
.stage::after { content: ''; position: absolute; z-index: -1; left: 50%; bottom: -56px; width: min(92%, 980px); height: 160px; transform: translateX(-50%); background: radial-gradient(closest-side, var(--accent-ring), transparent); opacity: 0.4; pointer-events: none; }
.screen { position: relative; width: 100%; width: min(100cqw, calc((100cqh - var(--below)) * 16 / 9)); aspect-ratio: 16 / 9; border-radius: var(--r-lg); background: var(--screen); overflow: hidden; box-shadow: 0 0 0 1px var(--border), 0 24px 48px -24px var(--shadow); isolation: isolate; }
.video-container { position: absolute; inset: 0; z-index: 1; }
.video-container iframe, .video-container video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.screen-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; color: #f1ece6; background: radial-gradient(ellipse 70% 60% at 50% 45%, var(--glow), transparent 75%); }
.screen.has-video .screen-empty { display: none; }
.screen-empty-icon { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.18); color: var(--accent); }
.screen-empty-icon .icon { width: 26px; height: 26px; margin-left: 3px; }
.screen-empty-title { font-size: 17px; font-weight: 600; }
.screen-empty-text { max-width: 34ch; font-size: 14px; color: rgba(241, 236, 230, 0.62); text-wrap: pretty; }

.sync-overlay { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(5, 4, 2, 0.55); color: #f1ece6; font-size: 14px; font-weight: 500; pointer-events: none; }
.sync-overlay-spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.18); border-top-color: var(--accent); animation: sync-spin 0.9s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sync-overlay-spinner { animation: none; } }

.hall-row { width: 100%; display: flex; justify-content: center; padding-top: 18px; }
.seats { display: flex; justify-content: center; gap: 6px; }
.seat { --seat: var(--surface-2); --seat-arm: var(--surface-3); --seat-ink: var(--text-3); width: 64px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.seat-chair { position: relative; width: 42px; height: 36px; }
.seat-back { position: absolute; top: 0; left: 5px; right: 5px; bottom: 4px; display: flex; align-items: center; justify-content: center; border-radius: 11px 11px 6px 6px; background: var(--seat); color: var(--seat-ink); font-weight: 700; font-size: 14px; line-height: 1; transition: background-color 0.3s; overflow: hidden; }
button.seat { padding: 0; border-radius: 12px; text-align: center; cursor: pointer; }
button.seat:focus-visible { outline-offset: 4px; }
.seat:not(.is-taken) .seat-back { background: transparent; border: 1.5px dashed var(--border-strong); }
.seat-chair::before, .seat-chair::after { content: ''; position: absolute; bottom: 0; width: 8px; height: 22px; border-radius: 4px; background: var(--seat-arm); opacity: var(--seat-arm-opacity, 1); }
.seat-chair::before { left: 0; }
.seat-chair::after { right: 0; }
.seat:not(.is-taken) .seat-chair::before, .seat:not(.is-taken) .seat-chair::after { background: var(--surface-3); }
.seat.is-taken { --seat: var(--av); --seat-ink: var(--av-ink); --seat-arm: var(--av); --seat-arm-opacity: 0.5; }
.seat.is-you .seat-back { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.seat-name { max-width: 100%; font-size: 12px; line-height: 1.3; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.is-you .seat-name { color: var(--accent-text); font-weight: 600; }
.seat-back img.avatar-svg { border-radius: 6px 6px 4px 4px; }

.url-bar { width: 100%; max-width: 960px; display: flex; gap: 8px; margin-top: 18px; }
.url-field { position: relative; flex: 1; min-width: 0; }
.url-field-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.url-field .input { padding-left: 44px; text-overflow: ellipsis; }
.url-bar.is-error .input { border-color: var(--danger); }
.url-hint { width: 100%; max-width: 960px; margin-top: 8px; padding-left: 2px; font-size: 13px; line-height: 1.4; color: var(--text-3); }
.url-hint b { font-weight: 600; color: var(--text-2); }
.url-hint.is-error { color: var(--danger); }

.side { width: var(--side-w); flex-shrink: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.side-head { flex-shrink: 0; display: flex; align-items: center; height: 52px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.side-title { font-size: 15px; font-weight: 600; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; padding: 14px 14px 10px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.chat-messages > :first-child { margin-top: auto; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.chat-message { position: relative; display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; touch-action: pan-y; }
.chat-message.is-grouped { margin-top: 3px; }
.chat-message.own { justify-content: flex-end; }

.msg-avatar { width: 30px; height: 30px; flex-shrink: 0; padding: 0; border-radius: 50%; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; cursor: pointer; }
.chat-message.is-grouped .msg-avatar { height: 0; visibility: hidden; margin-top: 0; }

.msg-bubble {
  position: relative;
  min-width: 0;
  max-width: 82%;
  padding: 6px 12px 8px;
  border-radius: 6px 18px 18px 18px;
  background: var(--surface-2);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}

/* --- Свайп влево для ответа --- */
.chat-message.is-swiping > :is(.msg-avatar, .msg-bubble),
.chat-message.is-swipe-returning > :is(.msg-avatar, .msg-bubble) {
  transform: translate3d(var(--swipe-x, 0px), 0, 0);
}
.chat-message.is-swiping > :is(.msg-avatar, .msg-bubble) { will-change: transform; }
.chat-message.is-swipe-returning > :is(.msg-avatar, .msg-bubble) { transition: transform 0.32s var(--ease); }
body.is-reply-swiping { -webkit-user-select: none; user-select: none; }
body.is-reply-swiping .chat-messages { cursor: grabbing; }

.swipe-reply {
  position: absolute;
  top: 50%;
  right: 0;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent-text);
  pointer-events: none;
  opacity: calc((var(--swipe-p, 0) - 0.2) * 1.5);
  transform: scale(calc(0.55 + 0.45 * var(--swipe-p, 0)));
  transition: background-color 0.15s, color 0.15s;
}
.swipe-reply .icon { width: 18px; height: 18px; }
.chat-message.is-swiping .swipe-reply,
.chat-message.is-swipe-returning .swipe-reply { display: grid; }
.chat-message.is-swipe-returning .swipe-reply { transition: transform 0.32s var(--ease), opacity 0.2s, background-color 0.15s, color 0.15s; }
.chat-message.is-reply-ready .swipe-reply {
  background: var(--accent);
  color: var(--on-accent);
  animation: swipe-reply-pop 0.28s var(--ease);
}
@keyframes swipe-reply-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Подсветка сообщения после перехода по цитате */
.chat-message.is-flash .msg-bubble { animation: msg-flash 1.4s var(--ease); }
@keyframes msg-flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--accent-ring); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.chat-message.is-grouped .msg-bubble { border-radius: 6px 18px 18px 6px; }
.chat-message.own .msg-bubble { max-width: 85%; background: var(--accent); color: var(--on-accent); border-radius: 18px 6px 18px 18px; }
.chat-message.own.is-grouped .msg-bubble { border-radius: 18px 6px 6px 18px; }

.msg-author { align-self: flex-start; max-width: 100%; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--av-name, var(--accent-text)); margin-bottom: 1px; cursor: pointer; }
@media (hover: hover) { .msg-author:hover { text-decoration: underline; } }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  align-self: flex-end;
}
.msg-time {
  font-size: 11px;
  line-height: 1;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.chat-message.own .msg-time { color: inherit; opacity: 0.62; }

.msg-reply {
  background: rgba(0,0,0,0.25);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
  transition: background-color 0.2s;
}
.msg-reply:hover { background: rgba(0,0,0,0.35); }
.msg-reply-author { color: var(--accent); font-weight: 600; font-size: 13px; line-height: 1.2; }
.msg-reply-text { color: var(--text-2); font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.chat-message.own .msg-reply { background: rgba(0,0,0,0.1); border-left-color: currentColor; }
.chat-message.own .msg-reply:hover { background: rgba(0,0,0,0.16); }
.chat-message.own .msg-reply-author { color: inherit; }
.chat-message.own .msg-reply-text { color: inherit; opacity: 0.72; }

.msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
  margin-left: -4px;
  margin-bottom: -4px;
  z-index: 2;
  position: relative;
}
.reaction {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s;
}
.reaction:hover { transform: scale(1.05); }
.chat-message.own .reaction {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

.reaction-picker {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  transform: scale(0.9);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}
.reaction-picker:not(.hidden) { opacity: 1; transform: scale(1); pointer-events: auto; }
.reaction-btn {
  background: none; border: none; font-size: 22px; padding: 6px;
  cursor: pointer; border-radius: 50%; transition: transform 0.1s, background-color 0.15s; line-height: 1;
}
.reaction-btn:hover { background: var(--surface-2); transform: scale(1.2); }
.reaction-btn:active { transform: scale(0.9); }

.reply-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 0 14px;
  border-top: 1px solid var(--border);
  animation: reply-bar-in 0.22s var(--ease);
}
.reply-bar + .chat-input-area { border-top: 0; }
.reply-bar.hidden + .chat-input-area { border-top: 1px solid var(--border); }
@keyframes reply-bar-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.reply-bar-icon { color: var(--accent-text); }
.reply-bar-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--accent);
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
}
.reply-bar-author { font-weight: 600; color: var(--accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-close {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-3);
  transition: background-color 0.15s, color 0.15s;
}
.reply-bar-close .icon { width: 18px; height: 18px; }
@media (hover: hover) { .reply-bar-close:hover { color: var(--text); background: var(--surface-2); } }

.chat-system { align-self: center; margin-top: 14px; padding: 0 8px; font-size: 13px; color: var(--text-3); text-align: center; }
.chat-empty { margin: auto 0; padding: 24px 16px; text-align: center; }
.chat-empty-title { font-weight: 600; color: var(--text-2); }
.chat-empty-text { margin-top: 4px; font-size: 14px; color: var(--text-3); }
.chat-input-area { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.chat-input-area .input { height: 44px; border-radius: 22px; padding: 0 16px; }
.send-btn { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); transition: background-color 0.15s, color 0.15s, transform 0.1s; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { background: var(--surface-2); color: var(--text-3); }

.host-crown { position: absolute; top: -8px; left: -6px; font-size: 16px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); z-index: 2; }
.mute-icon { position: absolute; bottom: -4px; right: -4px; font-size: 12px; background: var(--danger); border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--bg); z-index: 2; }
.seat.is-taken:hover .seat-back { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }

body.selecting .chat-message { cursor: pointer; }
.chat-message.is-selected .msg-bubble {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-soft);
}
.chat-message.is-selected .msg-bubble::after {
  content: '✓';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  animation: slide-down 0.2s var(--ease);
}

.selection-cancel {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.selection-cancel:hover { background: var(--surface-3); color: var(--text); }

.selection-count {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.selection-delete {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.selection-delete:hover { opacity: 0.9; }
.selection-delete:disabled { opacity: 0.4; cursor: default; }

.seat-menu-popup button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 899px) {
  body.selecting .chat-input-area,
  body.selecting .reply-bar { display: none !important; }
}

.theme-menu {
  position: fixed;
  z-index: 60;
  top: var(--menu-top, 72px);
  right: var(--menu-right, 16px);
  width: 344px;
  max-height: calc(100vh - 100px);
  max-height: calc(100dvh - 100px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 24px 64px -16px var(--shadow),
    0 2px 8px var(--shadow);
  transform-origin: top right;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  visibility: hidden;
  transition: opacity 0.16s ease, transform 0.24s var(--ease), visibility 0s linear 0.24s;
  overflow: hidden;
}
.theme-menu.is-open {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

.sheet-handle { display: none; }

.theme-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.theme-menu-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.theme-menu-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.theme-menu-sub {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.3;
}

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  flex-shrink: 0;
  isolation: isolate;
}
.segmented::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 10px;
  background: var(--surface);
  box-shadow:
    0 1px 3px var(--shadow),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  transition: transform 0.32s var(--ease);
  z-index: 0;
  pointer-events: none;
}
.segmented[data-mode="light"]::before {
  transform: translateX(100%);
}
.segmented-btn {
  position: relative;
  z-index: 1;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  transition: color 0.22s;
}
.segmented-btn .icon { width: 16px; height: 16px; }
.segmented-btn.is-active { color: var(--text); }

.theme-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 8px 24px -12px var(--accent-soft);
  transition: box-shadow 0.3s;
}
.tp-strip {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.tp-chip { flex: 1; height: 100%; }
.tp-chip[data-c="bg"] { background: var(--bg); }
.tp-chip[data-c="surface"] { background: var(--surface-2); }
.tp-chip[data-c="text"] { background: var(--text); }
.tp-chip[data-c="accent"] { background: var(--accent); }

.tp-body { display: flex; align-items: center; gap: 12px; }
.tp-aa {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.02em;
}
.tp-chat { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; align-items: flex-start; }
.tp-bubble {
  font-size: 11px;
  line-height: 1.3;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-bubble.tp-own { background: var(--accent); color: var(--on-accent); align-self: flex-end; }

.tp-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.2;
}
.tp-name { font-weight: 600; color: var(--text); }
.tp-sep { color: var(--text-3); }
.tp-mode { color: var(--text-3); }

.theme-search {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.theme-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
  transition: color 0.15s;
}
.theme-search:focus-within .theme-search-icon { color: var(--text-2); }
.theme-search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.theme-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.theme-search-input::placeholder { color: var(--text-3); }

.theme-cats-wrap { position: relative; margin: 0 -16px; flex-shrink: 0; }
.theme-cats-wrap::before,
.theme-cats-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22px;
  pointer-events: none;
  z-index: 2;
}
.theme-cats-wrap::before { left: 0; background: linear-gradient(90deg, var(--surface) 30%, transparent); }
.theme-cats-wrap::after { right: 0; background: linear-gradient(-90deg, var(--surface) 30%, transparent); }
.theme-cats {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 16px 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}
.theme-cats::-webkit-scrollbar { display: none; }
.theme-cat {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.theme-cat:hover { background: var(--surface-2); color: var(--text); }
.theme-cat:active { transform: scale(0.96); }
.theme-cat.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 8px;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  margin-right: -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  flex: 1;
  min-height: 0;
  align-content: start;
}
.swatches::-webkit-scrollbar { width: 6px; }
.swatches::-webkit-scrollbar-track { background: transparent; }
.swatches::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 0 4px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
  animation: swatch-in 0.3s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 8ms);
}
.swatch:hover { transform: translateY(-2px); background: var(--surface-2); }
.swatch:active { transform: scale(0.96); }

@keyframes swatch-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.swatch-dot {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--swatch);
  color: var(--swatch-ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: box-shadow 0.2s, transform 0.2s var(--ease);
}
.swatch:hover .swatch-dot { transform: scale(1.05); }
.swatch-dot .icon {
  width: 18px;
  height: 18px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s, transform 0.2s var(--ease);
}
.swatch.is-active .swatch-dot {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--swatch),
    0 0 16px -2px var(--swatch);
}
.swatch.is-active .swatch-dot .icon { opacity: 1; transform: none; }
.swatch-name {
  font-size: 11px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.swatch.is-active .swatch-name { color: var(--text); font-weight: 600; }

.theme-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--text-3);
  text-align: center;
  flex: 1;
}
.theme-empty .icon { width: 32px; height: 32px; opacity: 0.5; }
.theme-empty p { font-size: 14px; }

.scrim { display: none; }
.toast { position: fixed; z-index: 90; left: 50%; top: calc(env(safe-area-inset-top) + 16px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: 0 12px 32px -8px var(--shadow); overflow-wrap: anywhere; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.3s var(--ease); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) { :root { --gutter: 16px; --side-w: 320px; } }
@media (max-width: 899px) {
  :root { --topbar-h: 56px; }
  .topbar { gap: 12px; }
  .brand-name { display: none; }
  .room-chip { padding-left: 12px; }
  .layout { flex-direction: column; gap: 0; padding: 0; }
  .stage-col { flex: 0 0 auto; container-type: normal; justify-content: flex-start; padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left)); }
  .screen { width: 100%; max-height: 46vh; max-height: 46dvh; }
  .hall-row { padding-top: 12px; }
  .url-bar { max-width: none; margin-top: 12px; }
  .url-hint { max-width: none; }
  .side { flex: 1; width: auto; margin-top: 14px; border-radius: 22px 22px 0 0; border-bottom: 0; border-left: 0; border-right: 0; }
  .side-head { display: none; }
  .chat-input-area { padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .reply-bar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
}
@media (max-width: 599px) {
  :root { --gutter: 12px; }
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn-sm { width: 40px; padding: 0; }
  .stage-col { padding: 0; }
  .stage, .screen { width: 100%; }
  .screen { border-radius: 0; box-shadow: none; }
  .stage::after { display: none; }
  .hall-row, .url-bar, .url-hint { padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
  .hall-row { padding-top: 10px; }
  .seats { gap: 2px; }
  .seat { width: 58px; gap: 3px; }
  .seat-chair { width: 36px; height: 30px; }
  .seat-back { left: 4px; right: 4px; font-size: 13px; border-radius: 9px 9px 5px 5px; }
  .seat-chair::before, .seat-chair::after { width: 7px; height: 18px; }
  .seat-name { font-size: 11px; }
  .url-bar { margin-top: 10px; }
  .url-bar .btn { padding: 0 16px; }
  .url-hint { display: none; }
  .stage-col:has(#videoUrlInput:focus) .url-hint, .url-hint.is-error { display: block; }
  .url-field-icon { display: none; }
  .url-field .input { padding-left: 14px; }
  .side { margin-top: 12px; }
  .chat-messages { padding: 10px 12px 8px; }
  .msg-bubble { max-width: 86%; }

  .theme-menu {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 88vh; max-height: 88dvh;
    padding: 8px max(20px, env(safe-area-inset-right)) max(20px, calc(env(safe-area-inset-bottom) + 8px)) max(20px, env(safe-area-inset-left));
    border-radius: 24px 24px 0 0; border-bottom: 0;
    opacity: 1; transform: translateY(100%);
    transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
  }
  .theme-menu.is-open { transform: none; }
  .sheet-handle { display: block; width: 36px; height: 4px; margin: 0 auto 6px; border-radius: 2px; background: var(--border-strong); }
  .segmented-btn { height: 42px; }
  .theme-cats-wrap { margin: 0 -20px; }
  .theme-cats { padding: 2px 20px 4px; }
  .swatch-dot { width: 44px; height: 44px; }
  .theme-preview { padding: 10px; }
  .tp-aa { font-size: 20px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0.45); opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0s linear 0.25s; }
  .scrim.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
  .join-form { padding: 16px; margin-top: 24px; }
}
@media (max-width: 899px) and (pointer: coarse) {
  .app:has(#chatInput:focus) .hall-row, .app:has(#chatInput:focus) .url-bar, .app:has(#chatInput:focus) .url-hint { display: none; }
  .app:has(#chatInput:focus) .side { margin-top: 0; border-radius: 0; }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root { --topbar-h: 48px; --gutter: 12px; }
  .brand-name, .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn-sm { width: 40px; padding: 0; }
  .layout { flex-direction: row; gap: 12px; padding: 0 max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .stage-col { --below: 110px; flex: 1; container-type: size; justify-content: center; padding: 0; }
  .screen { width: min(100cqw, calc((100cqh - var(--below)) * 16 / 9)); max-height: none; border-radius: 12px; }
  .hall-row { padding: 8px 0 0; }
  .seat { width: 52px; gap: 2px; }
  .seat-chair { width: 32px; height: 26px; }
  .seat-back { left: 4px; right: 4px; font-size: 12px; border-radius: 8px 8px 4px 4px; }
  .seat-chair::before, .seat-chair::after { width: 6px; height: 16px; }
  .seat-name { font-size: 10px; }
  .url-bar { margin-top: 8px; padding: 0; }
  .url-bar .input, .url-bar .btn { height: 40px; }
  .url-hint, .stage-col:has(#videoUrlInput:focus) .url-hint { display: none; }
  .url-hint.is-error { display: block; padding: 0; }
  .side { width: clamp(260px, 38vw, 340px); flex: 0 0 auto; margin-top: 0; border-radius: 16px; border: 1px solid var(--border); }
  .side-head { display: none; }
  .chat-input-area { padding: 8px; }
  .chat-input-area .input, .send-btn { height: 40px; }
  .send-btn { width: 40px; }
  .app:has(#chatInput:focus) .hall-row, .app:has(#chatInput:focus) .url-bar { display: flex; }
  .app:has(#chatInput:focus) .side { border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ================= Аккаунт и профиль ================= */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.auth-loading { width: 28px; height: 28px; margin: 40px auto 8px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: sync-spin 0.9s linear infinite; }

.auth-panel { gap: 18px; }
.auth-tabs[data-tab="register"]::before { transform: translateX(100%); }
.auth-form { display: grid; gap: 16px; }
.auth-form .btn { margin-top: 4px; width: 100%; }

.google-block { display: grid; gap: 16px; }
.google-btn { display: flex; justify-content: center; min-height: 44px; color-scheme: light; }
.or-divider { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-3); }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.me-row { display: flex; align-items: center; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.me-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 4px; margin: -4px; border-radius: 14px; text-align: left; transition: background-color 0.15s; }
@media (hover: hover) { .me-chip:hover { background: var(--surface-2); } }
.me-avatar { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.me-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: 13px; color: var(--accent-text); }

.me-btn { width: 40px; height: 40px; flex-shrink: 0; padding: 0; border-radius: 50%; overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border); transition: box-shadow 0.15s; }
@media (hover: hover) { .me-btn:hover { box-shadow: 0 0 0 2px var(--accent); } }

.btn-danger { color: var(--danger); }
.btn-danger.is-confirm { background: var(--danger); color: #fff; border-color: transparent; }

/* --- шторки (на телефоне — снизу, на компьютере — по центру) --- */
.modal-scrim { position: fixed; inset: 0; z-index: 75; background: rgba(0, 0, 0, 0.5); opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0s linear 0.2s; }
.modal-scrim.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }

.sheet {
  position: fixed;
  z-index: 80;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  max-height: min(760px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset, 0 28px 72px -18px var(--shadow), 0 2px 8px var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -48%) scale(0.98);
  transition: opacity 0.18s ease, transform 0.26s var(--ease), visibility 0s linear 0.26s;
}
.sheet.is-open { opacity: 1; visibility: visible; transform: translate(-50%, -50%); transition-delay: 0s; }
.sheet-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.sheet-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 20px 20px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* --- профиль --- */
.pf-form { display: grid; gap: 16px; }
.pf-identity { display: flex; align-items: center; gap: 16px; }
.pf-avatar { width: 88px; height: 88px; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border); transition: opacity 0.2s; }
.pf-avatar.is-busy { opacity: 0.45; animation: pf-pulse 1s ease-in-out infinite alternate; }
@keyframes pf-pulse { to { opacity: 0.25; } }
.pf-photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.pf-upload { cursor: pointer; position: relative; }
.pf-upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pf-photo-hint { flex-basis: 100%; font-size: 12px; color: var(--text-3); }
.pf-avatar-grid { grid-template-columns: repeat(8, 1fr); gap: 8px; }

.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.input.textarea { height: auto; min-height: 80px; padding: 10px 14px; line-height: 1.4; resize: vertical; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.4; color: var(--text-2); cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }
.pf-form > .btn { width: 100%; }

.pf-section { display: grid; gap: 12px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.pf-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pf-section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.link-btn { padding: 4px 6px; margin: -4px -6px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--accent-text); }
@media (hover: hover) { .link-btn:hover { background: var(--surface-2); } }

.pf-login { display: grid; gap: 6px; font-size: 14px; }
.pf-login > div { display: flex; justify-content: space-between; gap: 12px; }
.pf-login dt { color: var(--text-2); }
.pf-login dd { min-width: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.pf-muted { color: var(--text-3); font-weight: 400; }
.pf-google-link { display: flex; justify-content: center; min-height: 44px; color-scheme: light; }
.pf-password { display: grid; gap: 12px; }
.pf-password .btn { width: 100%; }
.pf-logout { width: 100%; margin-top: 24px; color: var(--text-2); }

/* --- история --- */
.history-list { list-style: none; display: grid; gap: 2px; margin: 0 -6px; }
.history-item { display: flex; align-items: center; gap: 4px; }
.hi-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 12px; color: inherit; text-decoration: none; transition: background-color 0.15s; }
@media (hover: hover) { a.hi-link:hover { background: var(--surface-2); } }
.hi-thumb { width: 72px; aspect-ratio: 16 / 9; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.hi-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hi-badge { font-size: 12px; font-weight: 700; color: var(--text-2); }
.hi-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hi-title { font-size: 14px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.hi-meta { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-play { width: 36px; height: 36px; flex-shrink: 0; margin-right: 6px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); transition: background-color 0.15s, transform 0.1s; }
.hi-play .icon { width: 18px; height: 18px; margin-left: 2px; }
.hi-play:active { transform: scale(0.94); }
@media (hover: hover) { .hi-play:hover { background: var(--accent); color: var(--on-accent); } }
.history-empty { padding: 8px 6px; font-size: 14px; line-height: 1.4; color: var(--text-3); }
.history-list.compact .hi-thumb { width: 60px; }

/* --- карточка зрителя --- */
.user-card { width: min(380px, calc(100vw - 32px)); }
.uc-close { position: absolute; top: 14px; right: 14px; z-index: 1; background: var(--surface); }
.uc-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 14px; padding: 22px 20px 20px; }
.uc-head { display: flex; align-items: center; gap: 14px; padding-right: 36px; }
.uc-avatar { width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.uc-headtext { min-width: 0; }
.uc-name { font-size: 18px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.uc-you { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: 2px; color: var(--accent-text); background: var(--accent-soft); }
.uc-sub { margin-top: 2px; font-size: 13px; color: var(--text-3); }
.uc-bio { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.uc-section { display: grid; gap: 6px; }
.uc-muted { font-size: 13px; color: var(--text-3); }
.uc-error { font-size: 14px; color: var(--danger); }
.uc-loading { height: 3px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent) 0 0 / 200% 100%; animation: uc-load 1s linear infinite; }
@keyframes uc-load { to { background-position: -200% 0; } }
.uc-actions { display: grid; gap: 8px; padding-top: 2px; }
.uc-actions .btn { width: 100%; }
.uc-actions .btn .icon { width: 18px; height: 18px; }

@media (max-width: 599px) {
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0;
    width: auto;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    opacity: 1;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom);
    transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
  }
  .sheet.is-open { transform: none; }
  .sheet .sheet-handle { margin-top: 8px; }
  .sheet-head { padding-top: 6px; }
  .uc-close { top: 18px; }
  .pf-avatar { width: 76px; height: 76px; }
  .pf-avatar-grid { gap: 6px; }
}


/* --- приглашение --- */
.invite-body { display: grid; gap: 14px; }
.invite-lead { color: var(--text-2); font-size: 14px; line-height: 1.45; }
.invite-link-row { display: flex; gap: 8px; }
.invite-link { flex: 1; min-width: 0; font-size: 14px; }
.invite-link-row .btn { flex-shrink: 0; }
.invite-share { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-share .btn { text-decoration: none; display: inline-flex; align-items: center; }
.invite-note { color: var(--text-3); font-size: 12.5px; line-height: 1.45; }


/* --- вкладки профиля --- */
.pf-tabs-wrap { flex-shrink: 0; padding: 4px 20px 10px; }
.pf-tabs { grid-template-columns: repeat(3, 1fr); }
.pf-tabs::before { width: calc((100% - 8px) / 3); }
.pf-tabs[data-tab="stats"]::before { transform: translateX(100%); }
.pf-tabs[data-tab="friends"]::before { transform: translateX(200%); }
.pf-panel.hidden { display: none; }
.pf-note { font-size: 13px; line-height: 1.45; color: var(--text-3); }

.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1; color: var(--on-accent); background: var(--accent); vertical-align: 1px; }
.count-badge.hidden { display: none; }
.me-btn-wrap { position: relative; display: inline-flex; }
.dot-badge { position: absolute; top: -3px; right: -3px; margin: 0; min-width: 16px; height: 16px; font-size: 10px; box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }

/* --- статистика --- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-tile { display: grid; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.stat-tile.wide { grid-column: 1 / -1; }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.15; }
.stat-label { font-size: 12.5px; color: var(--text-3); }
.stats-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.stats-mini span { padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.stats-mini b { color: var(--text); font-weight: 600; }

/* --- друзья --- */
.pf-friend-link { display: grid; gap: 8px; margin-bottom: 6px; }
.friends-group { display: grid; gap: 4px; margin-top: 20px; }
.friends-group .pf-section-title { margin-bottom: 4px; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 6px; margin: 0 -6px; border-radius: 12px; }
@media (hover: hover) { .friend-row:hover { background: var(--surface-2); } }
.friend-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; background: none; padding: 0; color: inherit; }
.friend-ava { position: relative; width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; overflow: visible; }
.friend-ava-in { display: block; width: 42px; height: 42px; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.friend-ava-in > * { display: block; width: 100%; height: 100%; }
.friend-ava.is-live::after { content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #3ecf6e; box-shadow: 0 0 0 2px var(--surface); }
.friend-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.friend-name { font-size: 15px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-sub.is-live { color: var(--accent-text); }
.friend-actions { display: flex; gap: 6px; flex-shrink: 0; }
.friend-actions .btn { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.friends-empty { padding: 18px 6px 4px; font-size: 14px; line-height: 1.45; color: var(--text-3); text-align: center; }


/* --- главный экран --- */
.home-panel { gap: 14px; }
.home-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.home-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.home-actions .btn .icon { width: 20px; height: 20px; }
.home-settings { padding: 0 16px; }
.home-settings .me-avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.home-settings .me-avatar > * { width: 100%; height: 100%; display: block; }
.home-settings .count-badge { margin-left: 0; }
.rooms-head { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.rooms-list { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.room-card { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); text-align: left; color: inherit; transition: border-color 0.15s, background-color 0.15s, transform 0.1s; }
@media (hover: hover) { .room-card:not(:disabled):hover { border-color: var(--accent); background: var(--surface-2); } }
.room-card:not(:disabled):active { transform: scale(0.99); }
.room-card:disabled { opacity: 0.6; cursor: default; }
.rc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rc-name { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-count { flex-shrink: 0; font-size: 12.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); }
.rc-video { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-video .rc-live { color: var(--accent-text); font-weight: 600; }
.rc-bottom { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.rc-faces { display: flex; flex-shrink: 0; }
.rc-face { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--surface); background: var(--surface-2); }
.rc-face + .rc-face { margin-left: -6px; }
.rc-face > * { width: 100%; height: 100%; display: block; }
.rc-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-tag { flex-shrink: 0; padding: 2px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-text); }
.rooms-empty { padding: 18px 8px; text-align: center; font-size: 14px; line-height: 1.5; color: var(--text-3); border: 1.5px dashed var(--border); border-radius: 16px; }

/* --- настройки комнаты --- */
.rs-vis { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.rs-vis legend { margin-bottom: 6px; }
.vis-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.vis-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.vis-option input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.vis-body { display: grid; gap: 2px; }
.vis-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.vis-desc { font-size: 12.5px; color: var(--text-3); }
.stepper { display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface-2); width: max-content; }
.stepper .icon-btn { font-size: 20px; font-weight: 600; line-height: 1; }
.stepper-value { min-width: 44px; text-align: center; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* --- выход из комнаты, места --- */
.leave-btn .icon { width: 18px; height: 18px; }
.seats { flex-wrap: wrap; }


/* --- мобильная вёрстка: ничего не должно вылезать за ширину экрана --- */
.join { grid-template-columns: minmax(0, 1fr); }
.join-inner { min-width: 0; justify-self: center; }
.join-form { min-width: 0; }
.home-actions .btn { min-width: 0; }
.home-actions .btn > span:not(.count-badge):not(.me-avatar) { overflow: hidden; text-overflow: ellipsis; }
.rc-top > *, .rc-bottom > * { min-width: 0; }
.rooms-empty { overflow-wrap: anywhere; }
.room-chip-label { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }

@media (max-width: 599px) {
  .topbar { gap: 8px; }
  .brand { display: none; }
  .room-chip { flex: 1; flex-direction: column; align-items: flex-start; gap: 1px; padding-left: 0; border-left: 0; overflow: hidden; }
  .room-chip-id { order: -1; max-width: 100%; font-size: 15px; }
  .room-chip-label { font-size: 11.5px; }
  .room-chip-label .vis-text { display: none; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .icon-btn, .topbar-actions .btn-sm { width: 38px; height: 38px; }
  .topbar-actions .me-btn { width: 36px; height: 36px; }
  .conn-status { margin-right: 2px; }
  .leave-btn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
}
@media (max-width: 359px) {
  .join { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .join-form { padding: 14px; }
  .topbar-actions [data-theme-toggle] { display: none; }
}

@media (max-width: 599px) {
  .seats { flex-wrap: nowrap; overflow-x: auto; justify-content: safe center; scrollbar-width: none; padding-top: 12px; margin-top: -12px; }
  .seats::-webkit-scrollbar { display: none; }
  .seat { flex-shrink: 0; }
  .seats .seat:not(.is-taken):nth-child(n+6) { display: none; }
}
