:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1f2530;
  --text: #e8ebf0;
  --muted: #9aa4b2;
  --accent: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

/* ВАЖНО: авторские display-правила (.join/.room) перебивают UA-стиль
   [hidden]{display:none} — без этого hidden-атрибут не скрывает элемент. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2a3140;
}
.brand { font-weight: 700; font-size: 18px; }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.channel { color: var(--muted); font-size: 13px; }

/* Экран входа */
.join {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 53px);
}
.join-card {
  background: var(--panel);
  padding: 28px;
  border-radius: 12px;
  width: min(420px, 92vw);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.join-card h1 { font-size: 20px; margin: 0 0 18px; }
.join-card label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0 6px; }
.join-card input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #2a3140;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
}
.join-card .primary {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.join-card .primary:disabled { opacity: .6; cursor: default; }
.hint { color: var(--muted); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* Комната */
.room { position: relative; height: calc(100vh - 53px); display: flex; flex-direction: column; }
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 10px;
  overflow: auto;
}
.tile {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile .name {
  position: absolute;
  left: 8px; bottom: 8px;
  background: rgba(0,0,0,.55);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.tile .badge {
  position: absolute;
  right: 8px; top: 8px;
  background: rgba(0,0,0,.55);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* Локальное превью */
.local {
  position: absolute;
  right: 16px; bottom: 76px;
  width: 220px;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  z-index: 5;
}
.local video { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; }
.local-label { padding: 6px 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
#connState { font-size: 11px; }

/* Панель управления */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid #2a3140;
}
.controls button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.controls button:hover { filter: brightness(1.15); }
.controls button.danger { background: var(--danger); color: #fff; }
.controls button.active { outline: 2px solid var(--ok); }
.controls button.muted { outline: 2px solid var(--danger); }
.status { margin-left: auto; color: var(--muted); font-size: 13px; }
