/* ===== Встреча: каркас ===== */
.screen-room { background: var(--bg); overflow: hidden; }

.room-top {
  flex: none; height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.room-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 2s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
.room-code { letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sep { color: var(--text-3); }
.room-timer { color: var(--text-2); font-variant-numeric: tabular-nums; }
.room-top-actions { display: flex; align-items: center; gap: 10px; flex: none; }

/* Индикатор качества связи: 3 столбика */
.net { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.net i { width: 4px; border-radius: 1px; background: rgba(255, 255, 255, .22); }
.net i:nth-child(1) { height: 5px; }
.net i:nth-child(2) { height: 9px; }
.net i:nth-child(3) { height: 14px; }
.net[data-q="good"] i { background: var(--ok); }
.net[data-q="fair"] i:nth-child(-n+2) { background: var(--warn); }
.net[data-q="poor"] i:nth-child(1) { background: var(--danger); }

.room-body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 0 12px; }

/* ===== Сцена и раскладки ===== */
.stage { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; gap: 10px; }
.spotlight { flex: 1; min-width: 0; min-height: 0; display: flex; }
.spotlight > .tile { flex: 1; }
.grid { min-width: 0; min-height: 0; }

.stage[data-mode="grid"] .spotlight { display: none; }
.stage[data-mode="grid"] .grid {
  flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px;
}
.stage[data-mode="grid"] .grid > .tile { width: var(--tw, 320px); height: var(--th, 180px); }

.stage[data-mode="solo"] .grid { display: none; }

.stage[data-mode="pair"] .grid {
  position: absolute; right: 14px; bottom: 14px; z-index: 6;
  width: clamp(150px, 24%, 300px); aspect-ratio: 16 / 9;
}
.stage[data-mode="pair"] .grid > .tile { width: 100%; height: 100%; box-shadow: var(--shadow); outline: 1px solid var(--border-2); }

.stage[data-mode="spotlight"] .grid {
  flex: none; width: 232px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
  scrollbar-width: thin;
}
.stage[data-mode="spotlight"] .grid > .tile { flex: none; width: 100%; aspect-ratio: 16 / 9; }

/* ===== Плитка участника ===== */
.tile {
  position: relative; overflow: hidden; isolation: isolate; container-type: size;
  border-radius: var(--radius); background: var(--surface); min-width: 0; min-height: 0;
}
.tile video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .2s; background: transparent;
}
.tile.has-video video { opacity: 1; }
.tile.mirror video { transform: scaleX(-1); }
.tile.kind-screen { background: #07080a; }
.tile.kind-screen video, .spotlight > .tile video { object-fit: contain; }
.tile-avatar { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .2s; }
.tile.has-video .tile-avatar { opacity: 0; }
.tile .avatar { width: clamp(40px, 34cqmin, 128px); height: clamp(40px, 34cqmin, 128px); font-size: clamp(15px, 12cqmin, 44px); }
.tile.kind-screen .tile-avatar { color: var(--text-3); font-size: 14px; }

.tile::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--ok); opacity: 0; transition: opacity .15s;
}
.tile.speaking::after { opacity: 1; }

.tile-top {
  position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 6px; pointer-events: none;
}
.tile-badges { display: flex; gap: 6px; min-width: 0; }
.tile-hand, .tile-status {
  display: none; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 8px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tile-hand { background: var(--warn); color: #241a00; }
.tile-hand .ico { width: 14px; height: 14px; }
.tile.hand .tile-hand { display: inline-flex; }
.tile-status { background: rgba(10, 12, 16, .7); color: var(--text-2); font-weight: 600; }
.tile.connecting .tile-status { display: inline-flex; }
.tile-net { padding: 5px 6px; border-radius: 7px; background: rgba(10, 12, 16, .6); opacity: 0; transition: opacity .15s; }
.tile:hover .tile-net, .tile-net[data-q="fair"], .tile-net[data-q="poor"] { opacity: 1; }
.tile-net .net { height: 12px; }
.tile-net .net i:nth-child(3) { height: 12px; }
.tile-net .net i:nth-child(2) { height: 8px; }
.tile-net .net i:nth-child(1) { height: 4px; }

.tile-label {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; max-width: calc(100% - 96px);
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 8px;
  background: rgba(10, 12, 16, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 13px; font-weight: 600;
}
.tile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-mic { display: none; color: #ff7b7b; }
.tile-mic .ico { width: 15px; height: 15px; }
.tile.mic-off .tile-mic { display: grid; }

.tile-actions {
  position: absolute; right: 8px; bottom: 8px; z-index: 4; display: flex; gap: 6px;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
.tile-actions button {
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: rgba(10, 12, 16, .65); color: #fff;
}
.tile-actions button:hover { background: rgba(30, 34, 44, .9); }
.tile-actions .ico { width: 16px; height: 16px; }
.tile.pinned .tile-actions [data-act="pin"] { background: var(--accent); }

/* Маленькие плитки — компактные подписи */
@container (max-height: 120px) {
  .tile-label { height: 22px; padding: 0 7px; font-size: 11px; left: 5px; bottom: 5px; max-width: calc(100% - 10px); }
  .tile-actions, .tile-net { display: none; }
  .tile-top { top: 5px; left: 5px; right: 5px; }
}

.share-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 12px;
  background: rgba(34, 39, 51, .95); border: 1px solid var(--border-2); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.share-banner .ico { width: 18px; height: 18px; color: var(--accent); }

.audio-unlock {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px;
  border: 0; background: var(--accent); color: #fff; font-weight: 700; box-shadow: var(--shadow);
}

/* ===== Боковая панель: чат и участники ===== */
.side-panel {
  flex: none; width: 340px; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.panel-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--border);
}
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--bg-2); }
.tab { border: 0; background: transparent; color: var(--text-2); height: 30px; padding: 0 12px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.count { color: var(--text-3); font-weight: 500; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; }
.chat-empty { margin: auto; max-width: 220px; color: var(--text-3); font-size: 14px; text-align: center; }
.msg { padding: 1px 0; }
.msg.first { margin-top: 12px; }
.msg.first:first-of-type { margin-top: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; font-size: 13px; }
.msg-name { font-weight: 700; color: var(--c, var(--text)); }
.msg-time { color: var(--text-3); font-size: 12px; }
.msg-text { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a { color: #a5b8ff; }
.chat-form { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form .input { max-height: 120px; background: var(--bg-2); }
.chat-form .icon-btn { width: 42px; height: 42px; border-radius: 12px; }

.people-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 10px; }
.person:hover { background: var(--surface-2); }
.person .avatar { width: 36px; height: 36px; font-size: 13px; }
.person-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.person-name small { color: var(--text-3); font-weight: 500; }
.person-icons { display: flex; gap: 8px; color: var(--text-3); }
.person-icons .ico { width: 18px; height: 18px; }
.person-icons .off { color: #ff7b7b; }
.person-icons .hand { color: var(--warn); }
.person-icons .screen { color: var(--accent); }

/* ===== Панель управления ===== */
.controls {
  flex: none; height: 80px; padding: 0 16px; padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
}
.controls-center { display: flex; align-items: center; gap: 10px; }
.controls-side { display: flex; align-items: center; gap: 6px; min-width: 0; }
.controls-right { justify-content: flex-end; }
.clock { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.ctrl-leave { width: 66px; border-radius: 999px; background: var(--danger); color: #fff; }
.ctrl-leave:hover { background: #f46a6a; }
.ctrl-leave .ico { transform: rotate(135deg); }
.ctrl-flat { background: transparent; color: var(--text-2); }
.ctrl-flat:hover { background: var(--surface-2); color: var(--text); }
.ctrl-flat.active { background: var(--accent-soft); color: var(--accent); }
.ctrl.hand-on { background: var(--warn); color: #241a00; }
.ctrl.hand-on:hover { background: #fcd34d; }
.dot-badge { position: absolute; top: 9px; right: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }

.popover-wrap { position: relative; }
.reactions-pop {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 2px; padding: 6px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--border-2); box-shadow: var(--shadow);
}
.reactions-pop button { width: 42px; height: 42px; border: 0; border-radius: 11px; background: transparent; font-size: 24px; line-height: 1; transition: transform .1s, background .1s; }
.reactions-pop button:hover { background: var(--surface-3); transform: scale(1.12); }

.reactions-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.reaction { position: absolute; bottom: 96px; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: float-up 3.4s ease-out forwards; }
.reaction .emoji { font-size: 42px; line-height: 1; }
.reaction .who { padding: 2px 8px; border-radius: 6px; background: rgba(10, 12, 16, .75); font-size: 12px; font-weight: 600; white-space: nowrap; }
@keyframes float-up {
  0% { transform: translateY(0) scale(.5); opacity: 0; }
  10% { transform: translateY(-24px) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-50vh) scale(1); opacity: 0; }
}

/* ===== Адаптив ===== */
@media (max-width: 760px) {
  .room-top { height: 48px; padding-left: 12px; padding-right: 8px; }
  .room-top-actions { gap: 6px; }
  #btn-copy-link span { display: none; }
  #btn-copy-link { width: 32px; padding: 0; justify-content: center; }
  .room-body { padding: 0 6px; }
  .stage[data-mode="spotlight"] { flex-direction: column; }
  .stage[data-mode="spotlight"] .grid { width: auto; height: 92px; flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .stage[data-mode="spotlight"] .grid > .tile { width: 150px; height: 100%; aspect-ratio: auto; }
  .stage[data-mode="pair"] .grid { width: 34%; aspect-ratio: 3 / 4; right: 10px; bottom: 10px; }
  .stage[data-mode="grid"] .grid { gap: 6px; }
  .tile { border-radius: 12px; }
  .side-panel { position: fixed; inset: 0; z-index: 30; width: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .controls { display: flex; justify-content: center; gap: 6px; height: auto; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); }
  .controls-center, .controls-right { display: contents; }
  .controls-left, #ctl-people { display: none; }
  .ctrl { width: 44px; height: 44px; }
  .ctrl .ico { width: 20px; height: 20px; }
  .ctrl-leave { width: 54px; order: 10; }
  .toasts { bottom: 84px; }
  .reactions-pop { left: auto; right: -60px; transform: none; }
}
@media (max-width: 380px) {
  .controls { gap: 4px; }
  .ctrl { width: 40px; height: 40px; }
  .ctrl-leave { width: 48px; }
}
