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

html, body {
  height: 100%;
  background: #0d0f12;
  color: #e8eaed;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

/* ---- Логин ---- */

#login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0f12;
  z-index: 100;
}

#login[hidden] {
  display: none;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  padding: 32px;
  background: #16191d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.login-card input {
  background: #0d0f12;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 14px;
  color: #e8eaed;
  font-size: 15px;
  outline: none;
}

.login-card input:focus {
  border-color: #2d7ff9;
}

.login-error {
  color: #f28b82;
  font-size: 13px;
  min-height: 16px;
  text-align: center;
}

/* ---- Сетка видео ---- */

#grid {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 8px;
  padding: 8px 8px 88px;
  align-items: stretch;
}

.tile {
  position: relative;
  background: #16191d;
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #16191d;
}

.tile.novideo video {
  visibility: hidden; /* собеседник не шлёт видео — тёмная плитка вместо замороженного кадра */
}

.tile .name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  background: rgba(13, 15, 18, 0.7);
  border-radius: 8px;
  font-size: 13px;
  backdrop-filter: blur(6px);
}

/* Громкость участника: справа снизу, разворачивается по наведению */
.tile .vol {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(13, 15, 18, 0.7);
  border-radius: 8px;
  backdrop-filter: blur(6px);
  opacity: 0.55;
  transition: opacity 0.15s;
}

.tile .vol:hover {
  opacity: 1;
}

.tile .vol svg {
  width: 18px;
  height: 18px;
  fill: #e8eaed;
  cursor: pointer;
  flex: none;
}

.tile .vol.muted svg {
  fill: #f28b82;
}

.tile .vol input[type='range'] {
  width: 0;
  opacity: 0;
  transition: width 0.15s, opacity 0.15s;
  accent-color: #8ab4f8;
  cursor: pointer;
}

.tile .vol:hover input[type='range'] {
  width: 90px;
  opacity: 1;
}

/* ---- Список участников ---- */

#roster {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 6;
  background: rgba(22, 25, 29, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 160px;
  max-width: 240px;
}

#roster[hidden] {
  display: none;
}

.roster-title {
  font-size: 11px;
  color: #9aa0a6;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#rosterList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#rosterList li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa0a6;
  flex: none;
}

.dot.connected {
  background: #4caf7d;
}

.dot.connecting {
  background: #e0b34c;
}

.dot.failed {
  background: #f28b82;
}

#localVideo {
  position: fixed;
  right: 16px;
  bottom: 96px;
  width: 220px;
  max-width: 26vw;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  background: #16191d;
  transform: scaleX(-1);
  z-index: 5;
}

#localVideo.screen {
  transform: none;
  object-fit: contain;
}

/* ---- Статус ---- */

#status {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0f12;
  z-index: 4;
}

#status.hidden {
  display: none;
}

.status-card {
  text-align: center;
  padding: 32px;
  max-width: 480px;
}

.status-card h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-card p {
  color: #9aa0a6;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
  word-break: break-all;
}

.btn-copy {
  background: #2d7ff9;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-copy:hover {
  background: #1a6ce8;
}

/* ---- Панель управления ---- */

#controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(22, 25, 29, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  z-index: 10;
}

.ctl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #e8eaed;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 12px;
  transition: background 0.15s;
  min-width: 72px;
}

.ctl:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ctl svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.ctl span {
  font-size: 11px;
  color: #9aa0a6;
}

.ctl.off {
  color: #f28b82;
}

.ctl .icon-off {
  display: none;
}

.ctl.off .icon-on {
  display: none;
}

.ctl.off .icon-off {
  display: inline;
}

.ctl.off span {
  color: #f28b82;
}

.ctl.active {
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.12);
}

.ctl.active span {
  color: #8ab4f8;
}

.ctl.danger {
  color: #f28b82;
}

.ctl.danger:hover {
  background: rgba(242, 139, 130, 0.15);
}
