:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --muted: #8b93a7;
  --text: #eef1f6;
  --accent: #4f8cff;
  --danger: #e5484d;
  --ok: #3fb950;
  --border: #2a2f3a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.muted { color: var(--muted); }
.error { color: #ff6b6b; min-height: 1.2em; margin: 0.4rem 0 0; }
strong { color: var(--text); }

/* --- Карточки (лобби / pre-join) --- */
.card {
  max-width: 420px;
  margin: auto;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.card h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
label { display: block; margin: 1rem 0 0; font-size: 0.9rem; color: var(--muted); }
input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1218;
  color: var(--text);
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button {
  margin-top: 1.2rem;
  width: 100%;
  padding: 0.8rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.hint { font-size: 0.8rem; margin-top: 1rem; }

.preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  margin-top: 1rem;
  object-fit: cover;
}
.mirror { transform: scaleX(-1); }

/* --- Звонок --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 0.5rem;
}
.dot.ok { background: var(--ok); }
.dot.err { background: #ff6b6b; }
.badge {
  background: #0f1218;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}
.ghost {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 16px;
  align-content: start;
}
.tile {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
}
.tile[data-state="failed"], .tile[data-state="disconnected"] { border-color: #ff6b6b; }
.tile[data-state="connected"] { border-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile-label {
  position: absolute;
  left: 8px; bottom: 8px;
  padding: 0.15rem 0.55rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  font-size: 0.8rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
}
.ctrl {
  width: auto;
  margin: 0;
  padding: 0.7rem 1.1rem;
  background: #0f1218;
  border: 1px solid var(--border);
  font-size: 1.1rem;
}
.ctrl.off { background: #3a2326; border-color: #6b2b30; }
.ctrl.danger { background: #b3343a; border-color: #b3343a; }
