:root {
  --bg: #0b0f14;
  --surface: #141b26;
  --elevated: #1a2332;
  --border: #2d3a4d;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.45);
  --danger: #ef4444;
  --ok: #22c55e;
  --speak: #a78bfa;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --tap-min: 44px;
  font-family: system-ui, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2744 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.15);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.small {
  font-size: 0.85rem;
  margin-top: 0;
}

.panel {
  max-width: 900px;
  margin: 0 auto;
  padding-top: max(2rem, var(--safe-top));
  padding-bottom: max(1.5rem, var(--safe-bottom));
  padding-left: max(1.25rem, var(--safe-left));
  padding-right: max(1.25rem, var(--safe-right));
}

.brand-header {
  margin-bottom: 1.25rem;
}

.brand-mark {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.brand-name {
  color: var(--text);
}

.brand-divider {
  color: var(--muted);
  font-weight: 400;
}

.brand-club {
  background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tagline {
  margin: 0.5rem 0 0;
}

.brand-public {
  margin: 0.35rem 0 0;
}

.brand-public a {
  color: var(--accent);
  text-decoration: none;
}

.brand-public a:hover {
  text-decoration: underline;
}

.lobby-status {
  min-height: 1.5rem;
  margin-bottom: 0.75rem;
}

.lobby-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.2rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.lobby-tab {
  flex: 1;
  min-width: 5.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.lobby-tab:hover {
  color: var(--text);
  background: var(--elevated);
}

.lobby-tab.is-active {
  color: var(--text);
  background: var(--elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.lobby-panel {
  animation: lobbyFade 0.2s ease-out;
}

/* Вкладка «Комната»: та же ширина, что и блок табов (на всю полосу .panel) */
#panel-room {
  width: 100%;
  box-sizing: border-box;
}

#panel-room .lobby-actions.lobby-actions--sym {
  width: 100%;
}

@keyframes lobbyFade {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

.lobby-panel .card + .card {
  margin-top: 0.75rem;
}

/* Сетка «Создать / Войти»: отступ только через gap, иначе вторая колонка визуально ниже первой */
#panel-room .lobby-actions .card + .card {
  margin-top: 0;
}

.catalog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.catalog-head h2 {
  margin: 0;
  flex: 1;
}

.btn-inline {
  width: auto !important;
  margin-top: 0 !important;
  padding: 0.35rem 0.55rem !important;
  font-size: 1.1rem;
  line-height: 1;
}

.resend-line {
  margin: 0.75rem 0 0;
}

.catalog-list--empty {
  min-height: 2rem;
}

.lobby-settings {
  margin: 0;
}

.lobby-settings h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.lobby-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.lobby-settings-actions button {
  flex: 1;
  min-width: 140px;
}

button.secondary {
  background: transparent;
  border-color: var(--border);
}

.lobby-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  padding-bottom: max(0.25rem, var(--safe-bottom));
  border-top: 1px solid var(--border);
  text-align: center;
}

.room-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  margin: 0 0 0.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

input[type="email"] {
  width: 100%;
}

button {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  touch-action: manipulation;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.lobby-actions {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

/* Симметричный блок: одна колонка на узком экране, две равные колонки и одна высота строки */
.lobby-actions.lobby-actions--sym {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

@media (min-width: 640px) {
  .lobby-actions {
    grid-template-columns: 1fr 1fr;
  }

  .lobby-actions.lobby-actions--sym {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.card--lobby {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 15.5rem;
  height: 100%;
  align-self: stretch;
  box-sizing: border-box;
}

.card-lobby-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

/* Одинаковая «шапка», чтобы при переносе заголовка кнопки оставались на одной линии снизу */
.card--lobby > h2 {
  margin: 0;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  line-height: 1.25;
}

.card--lobby > button {
  width: 100%;
  margin-top: auto;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.persistent-card > button#btnPersistCreate {
  width: 100%;
  margin-top: 0.75rem;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.auth-captcha {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-captcha-label {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0;
}

.auth-captcha-title {
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-captcha-prompt {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-captcha-refresh {
  flex: 0 0 auto;
  width: auto !important;
  margin-top: 0 !important;
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.auth-actions button {
  flex: 1;
  min-width: 120px;
  margin-top: 0;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.auth-actions button.secondary {
  background: transparent;
  border-color: var(--border);
  font-weight: 600;
}

.auth-user {
  margin-top: 0.5rem;
}

.auth-profile {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--elevated);
}

.auth-profile-main {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.auth-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 4rem;
  height: 4rem;
  cursor: pointer;
}

.auth-avatar-preview {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--surface);
  display: block;
}

.auth-avatar-preview.hidden {
  display: none !important;
}

.auth-avatar-fallback {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--muted);
  background: linear-gradient(145deg, var(--surface) 0%, #1e2a3d 100%);
  border: 2px solid var(--border);
}

.auth-avatar-fallback.hidden {
  display: none !important;
}

.auth-profile-info {
  flex: 1;
  min-width: 0;
}

.auth-email {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}

.auth-avatar-hint {
  margin: 0;
  line-height: 1.35;
}

.auth-profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.auth-profile-actions button {
  flex: 1 1 auto;
  min-width: min(100%, 7.5rem);
  margin-top: 0;
  width: auto;
}

.forgot-line {
  margin: 0.75rem 0 0;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.catalog-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--elevated);
}

.catalog-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  overflow: hidden;
}

.catalog-icon-img {
  max-width: 2.5rem;
  max-height: 2.5rem;
  object-fit: contain;
}

.catalog-info {
  flex: 1;
  min-width: 0;
}

.catalog-info .catalog-desc {
  margin: 0.35rem 0 0;
}

.catalog-item button.small {
  width: auto;
  margin-top: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.persistent-card textarea {
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.error {
  color: #fca5a5;
  margin-top: 1rem;
}

.success-banner {
  color: var(--ok);
  margin-top: 1rem;
  font-weight: 600;
}

button.linkish {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
  width: auto;
  margin: 0;
}

button.linkish:hover {
  color: #93c5fd;
}

.room {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
  padding-top: max(0.75rem, var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: rgba(20, 27, 38, 0.92);
  backdrop-filter: blur(8px);
}

.room-bar > div:first-child {
  min-width: 0;
  flex: 1;
}

.room-desc-line {
  margin: 0.35rem 0 0;
  max-width: min(100%, 42rem);
  line-height: 1.35;
}

.room-admin-settings {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
}

.room-admin-settings-title,
.room-admin-participants-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.room-admin-settings label {
  display: block;
  margin-bottom: 0.5rem;
}

.room-admin-settings textarea {
  width: 100%;
  resize: vertical;
  min-height: 3.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}

.admin-room-clear-pwd {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem !important;
}

.admin-room-clear-pwd input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#btnAdminRoomSave {
  margin-top: 0.25rem;
}

#roomIdLabel {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.room-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.room-admin {
  padding: 0.5rem 1rem 0.75rem;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
  border-bottom: 1px solid var(--border);
  background: rgba(12, 16, 22, 0.65);
}

.room-admin-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
}

.room-admin-details summary::-webkit-details-marker {
  display: none;
}

.room-admin-details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.room-admin-details[open] summary::before {
  transform: rotate(90deg);
}

.admin-participants {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.admin-actions button {
  width: auto;
  margin: 0;
}

.room-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

@media (min-width: 900px) {
  .room-main {
    grid-template-columns: 1fr 320px;
  }
}

.video-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.75rem;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
  gap: 0.5rem;
}

.video-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.5rem;
}

.video-layout.layout--spotlight {
  min-height: 420px;
}

.spotlight {
  flex: 1;
  min-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.spotlight .tile {
  aspect-ratio: auto;
  height: 100%;
  min-height: 200px;
  border-radius: 12px;
}

.spotlight .tile video {
  object-fit: contain;
}

.video-grid {
  flex: 1;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  align-content: start;
  min-height: 160px;
}

.video-grid.is-strip {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  max-height: 200px;
  overflow-y: auto;
  padding-bottom: 2px;
}

.video-grid.is-strip .tile {
  aspect-ratio: 4 / 3;
}

.tile {
  position: relative;
  background: #0a0a0a;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.tile.tile--speaking {
  border-color: var(--speak);
  box-shadow: 0 0 0 2px var(--accent-glow), 0 0 24px rgba(167, 139, 250, 0.25);
}

.tile.tile--focused {
  outline: 2px solid var(--accent);
}

.tile-avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  opacity: 0.28;
  pointer-events: none;
}

.tile video {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.tile-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem;
  font-size: 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  pointer-events: none;
}

.tile-name {
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-badges {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  pointer-events: none;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.badge-screen {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.35);
}

.tile-mic {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.45);
}

.tile-mic.is-muted {
  opacity: 0.45;
  color: #fca5a5;
}

.tile-expand {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tile:hover .tile-expand {
  opacity: 1;
}

.tile-expand:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding: 0.5rem 0;
}

.tool-group {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  min-height: 2.5rem;
}

.tool-btn.on {
  border-color: rgba(34, 197, 94, 0.55);
}

.tool-btn.off {
  opacity: 0.75;
  border-color: rgba(239, 68, 68, 0.55);
}

.tool-btn.screen-active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
}

.tool-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.tool-label {
  font-size: 0.8rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .tool-label {
    display: none;
  }

  .tool-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0.55rem 0.7rem;
    justify-content: center;
  }
}

.mic-meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
  padding: 0 2px 4px;
}

.mic-meter-seg {
  width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  height: 20%;
  transition: height 0.05s linear, background 0.1s ease;
}

.mic-meter-seg.active {
  background: linear-gradient(180deg, var(--ok), #16a34a);
}

.mic-meter-seg.active.hot {
  background: linear-gradient(180deg, #fbbf24, #ea580c);
}

.focus-hint {
  flex: 1;
  min-width: 140px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

.chat {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  min-height: 280px;
}

@media (min-width: 900px) {
  .chat {
    border-top: none;
    border-left: 1px solid var(--border);
  }
}

.chat h3 {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.msg {
  line-height: 1.4;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(45, 58, 77, 0.5);
}

.msg:last-child {
  border-bottom: none;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.msg .who {
  color: var(--accent);
  font-weight: 600;
}

.msg-time {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.msg-body {
  word-break: break-word;
}

.chat-attach-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #0a0a0a;
}

.chat-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.chat-attach-file:hover {
  background: rgba(59, 130, 246, 0.15);
}

.chat-file-pend {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem 0;
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-attach-btn {
  flex-shrink: 0;
  padding: 0.5rem 0.65rem;
  font-size: 1.1rem;
  line-height: 1;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  align-items: center;
}

.chat-form input[type="text"] {
  flex: 1;
  min-width: 0;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
  padding-bottom: max(1rem, var(--safe-bottom));
  padding-top: max(1rem, var(--safe-top));
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 1.25rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--elevated);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-actions button.primary {
  margin-left: auto;
}

/* ——— Мобильные устройства ——— */
@media (max-width: 639px) {
  body {
    overflow-x: hidden;
  }

  .panel {
    padding-top: max(1rem, var(--safe-top));
    padding-left: max(0.75rem, var(--safe-left));
    padding-right: max(0.75rem, var(--safe-right));
  }

  .brand-mark {
    font-size: clamp(1.15rem, 5vw, 1.6rem);
  }

  .lobby-tab {
    min-height: var(--tap-min);
    padding: 0.55rem 0.5rem;
    font-size: 0.85rem;
  }

  .card--lobby {
    min-height: 14.5rem;
  }

  button,
  .card--lobby > button,
  .persistent-card > button {
    min-height: var(--tap-min);
  }

  .auth-actions button {
    min-height: var(--tap-min);
  }

  /* iOS: не увеличивать страницу при фокусе на поле (нужен ≥16px) */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px;
  }

  .catalog-item {
    flex-direction: column;
    align-items: stretch;
  }

  .catalog-item .catalog-info {
    width: 100%;
  }

  .catalog-item button.small {
    width: 100%;
    min-height: var(--tap-min);
    padding: 0.5rem 0.75rem;
  }

  .room-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .room-bar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .room-bar-actions button {
    flex: 1;
    min-height: var(--tap-min);
  }

  .video-layout.layout--spotlight {
    min-height: min(50vh, 380px);
  }

  .spotlight {
    min-height: min(40vh, 200px);
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
    gap: 0.5rem;
    min-height: 120px;
  }

  .video-grid.is-strip {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    max-height: min(28vh, 180px);
  }

  .toolbar {
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0 0.65rem;
  }

  .tool-group {
    gap: 0.25rem;
  }

  .mic-meter {
    height: 26px;
  }

  .focus-hint {
    display: none;
  }

  .tile-expand {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    opacity: 0.92;
  }

  .chat {
    min-height: min(42vh, 260px);
    max-height: 55vh;
  }

  .chat h3 {
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
  }

  .chat-log {
    padding: 0.6rem;
    font-size: 0.88rem;
  }

  .chat-form {
    flex-wrap: wrap;
    padding: 0.6rem;
    padding-bottom: max(0.6rem, var(--safe-bottom));
    gap: 0.45rem;
  }

  .chat-form input[type="text"] {
    flex: 1 1 100%;
    order: -1;
    min-height: var(--tap-min);
  }

  .chat-attach-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
  }

  .chat-form button[type="submit"] {
    flex: 1;
    min-height: var(--tap-min);
  }

  button.linkish {
    min-height: var(--tap-min);
    padding: 0.4rem 0.5rem;
    align-items: center;
    display: inline-flex;
    justify-content: center;
  }

  .chat-attach-img {
    max-height: 180px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
    padding-left: max(0, var(--safe-left));
    padding-right: max(0, var(--safe-right));
    padding-bottom: 0;
  }

  .modal-card {
    width: 100%;
    max-width: none;
    border-radius: 16px 16px 0 0;
    max-height: min(90dvh, 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1rem max(1.25rem, var(--safe-bottom));
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-actions button {
    width: 100%;
    min-height: var(--tap-min);
    margin-left: 0 !important;
  }

  .admin-participant-row {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-actions {
    justify-content: stretch;
  }

  .admin-actions button {
    flex: 1;
    min-width: 0;
    min-height: var(--tap-min);
  }
}

/* Сенсор: кнопка разворота плитки всегда видна (нет :hover) */
@media (hover: none) and (pointer: coarse) {
  .tile-expand {
    opacity: 0.92;
  }

  .tile:hover .tile-expand {
    opacity: 0.92;
  }
}

/* Очень узкий экран */
@media (max-width: 380px) {
  .video-grid {
    grid-template-columns: 1fr 1fr;
  }

  .brand-public {
    font-size: 0.8rem;
    word-break: break-all;
  }
}
