* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #111; color: #eee; }
.screen { display: none; padding: 24px; min-height: 100vh; }
.screen.active { display: block; }
.hidden { display: none !important; }
.error { color: #ff6b6b; }

button {
  background: #2a2a2a; color: #eee; border: 1px solid #444;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
button:hover { background: #3a3a3a; }

input {
  background: #1a1a1a; color: #eee; border: 1px solid #444;
  padding: 8px 12px; border-radius: 6px; font-size: 14px;
}

#login-users { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
#invite-box { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#invite-status { width: 100%; margin-top: 4px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #1c1c1c; padding: 24px; border-radius: 8px; border: 1px solid #333; max-width: 480px; }

.room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }

.room-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  height: calc(100vh - 100px);
  transition: grid-template-columns .2s ease;
}
.room-body.chat-collapsed { grid-template-columns: 1fr 0px; }
.room-body.chat-collapsed .chat-side { display: none; }

.video-side {
  position: relative; background: #000; border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
}

/* плеер фильма — растягивается */
#player-wrap { flex: 1; min-height: 0; position: relative; background: #000; }
#player { width: 100%; height: 100%; display: block; background: #000; }

#no-film {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
}

/* каталог на весь video-side */
#catalog {
  position: absolute; inset: 0; background: #111; padding: 16px; overflow-y: auto; z-index: 5;
}
#catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 12px; }
.film-card { cursor: pointer; background: #1c1c1c; border-radius: 6px; overflow: hidden; border: 1px solid #333; }
.film-card img { width: 100%; display: block; aspect-ratio: 2/3; object-fit: cover; background: #333; }
.film-card p { margin: 8px; font-size: 13px; }

/* ============ Плитки звонка ПОД фильмом ============ */
#call-strip {
  display: grid;
  grid-template-columns: 1fr 1.6fr; /* партнёр шире своей */
  gap: 8px;
  padding: 8px;
  background: #0a0a0a;
  border-top: 1px solid #222;
  height: 160px;
  flex: 0 0 auto;
}
.call-tile { position: relative; background: #000; border-radius: 6px; overflow: hidden; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-label {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; font-size: 11px;
}
.tile-off {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  color: #888; font-size: 12px; background: #000;
}
.call-tile.cam-off .tile-off { display: flex; }

/* ============ Круглые кнопки управления, автоскрытие ============ */
.call-controls {
  position: absolute; left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex; gap: 12px;
  z-index: 6;
  transition: opacity .3s ease;
  opacity: 0;
  pointer-events: none;
}
.call-controls.visible { opacity: 1; pointer-events: auto; }
.circle-toggle {
  width: 52px; height: 52px; border-radius: 50%;
  padding: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); border: 2px solid #666;
  color: #fff; font-size: 22px;
  position: relative;
}
.circle-toggle.on {
  border-color: #2ecc71; background: rgba(20,80,40,.75);
  color: #2ecc71;
}
.circle-toggle.off {
  border-color: #e74c3c; background: rgba(80,20,20,.75);
  color: #e74c3c;
}
.circle-toggle.off::after {
  content: ''; position: absolute;
  left: 8%; right: 8%; top: 50%;
  height: 3px; background: currentColor;
  transform: rotate(-45deg); border-radius: 2px;
}
.circle-toggle.hidden { display: none; }

/* плашка "дай доступ" */
.perm-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(180, 30, 30, .95); color: #fff;
  padding: 10px 14px; border-radius: 8px; max-width: 80%;
  font-size: 13px; text-align: center; z-index: 7;
  pointer-events: none;
}

/* Чат */
.chat-side { display: flex; flex-direction: column; background: #1a1a1a; border-radius: 8px; overflow: hidden; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #333; font-size: 13px; }
#chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { padding: 6px 10px; border-radius: 8px; background: #262626; max-width: 90%; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: #2f5d8a; }
.msg .who { font-size: 11px; opacity: .7; display: block; }
#chat-form { display: flex; border-top: 1px solid #333; }
#chat-form input { flex: 1; border: none; border-radius: 0; }
#chat-form button { border-radius: 0; border: none; border-left: 1px solid #333; }

#btn-expand-chat {
  position: fixed; right: 8px; top: 50%; transform: translateY(-50%);
  z-index: 20; padding: 12px 6px;
}

#chat-toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  background: #2f5d8a; color: #fff;
  padding: 10px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
#chat-toast button { background: #fff; color: #2f5d8a; border: none; padding: 4px 10px; }