:root {
  --bg: #0e1014;
  --panel: #161920;
  --panel2: #1e222b;
  --text: #e9ebf1;
  --muted: #9aa1b2;
  --accent: #ff4d5e;
  --accent2: #ff7a59;
  --ok: #3ecf8e;
  --warn: #f5b84b;
  --border: #2a2f3a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

button { font: inherit; cursor: pointer; color: var(--text); background: var(--panel2);
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .9rem; }
button:hover { border-color: #414857; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; font-weight: 600; }
button.danger { background: #351a1f; border-color: #5a2730; color: #ffb7bf; }
button.off { background: #351a1f; border-color: #5a2730; color: #ffb7bf; }
button.ghost { background: transparent; }

input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .8rem; width: 100%; min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Lobby */
.lobby { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.card h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.card h1 span { color: var(--accent); }
.sub, .hint { margin: 0; color: var(--muted); }
.hint { font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.msg { margin: 0; min-height: 1.2em; color: #ffb7bf; font-size: 13px; }

/* App */
.app { height: 100%; display: flex; flex-direction: column; }
.bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.load { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.room { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
.room b { color: var(--text); }

.stage { flex: 1; display: flex; gap: 12px; padding: 12px; min-height: 0; }
.player-wrap { position: relative; flex: 1; min-width: 0; background: #000; border-radius: 12px; overflow: hidden; }
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--muted); pointer-events: none; }
.unlock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  background: var(--accent); border: 0; font-weight: 600; padding: .9rem 1.3rem; box-shadow: 0 8px 30px #0008; }

.call { width: 300px; flex: none; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tiles { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow: auto; min-height: 0; }
.tile { position: relative; flex: none; aspect-ratio: 16 / 9; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tile video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile.self video { transform: scaleX(-1); }
.avatar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700; color: var(--muted); background: var(--panel2); }
.label { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.label span { background: rgba(0, 0, 0, .6); padding: 2px 8px; border-radius: 999px; }
.label span:empty { display: none; }
.label .net.relay { color: var(--warn); }
.label .net.direct { color: var(--ok); }
.tile.failed { border-color: #5a2730; }
.call-status { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.call-status:empty { display: none; }
.call-status.bad { color: #ffb7bf; }

.volumes { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.vol { flex-direction: row; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.vol-name { width: 48px; flex: none; color: var(--muted); }
.vol-val { width: 38px; flex: none; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.vol input[type=range] { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
.vol input[type=range]:focus { outline: none; }

.controls { display: flex; gap: 8px; }
.controls button { flex: 1; padding-left: .4rem; padding-right: .4rem; }

.status { display: flex; justify-content: space-between; gap: 12px; padding: 6px 14px; font-size: 12px;
  color: var(--muted); border-top: 1px solid var(--border); background: var(--panel); }

.toast { position: fixed; left: 50%; bottom: 44px; transform: translate(-50%, 10px); opacity: 0;
  background: #000d; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px;
  pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app { height: auto; min-height: 100%; }
  .stage { flex-direction: column; }
  .player-wrap { flex: none; aspect-ratio: 16 / 9; }
  .call { width: 100%; }
  .tiles { flex-direction: row; overflow-x: auto; }
  .tile { width: 46%; min-width: 150px; }
  .room { white-space: normal; }
}
