:root {
  --bg: #14110f; --panel: #1f1b18; --panel2: #2a2521; --line: #3a332d;
  --text: #f3ece4; --mute: #a3978a; --acc: #e8a33d; --acc-ink: #14110f;
  --red: #d9503f; --green: #5fbf7a;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.mark { width: 56px; height: 56px; border-radius: 16px; background: var(--acc); color: var(--acc-ink);
  font: 36px/56px Georgia, serif; text-align: center; }
h1 { margin: 0; font: 600 34px/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.01em; }
h2 { margin: 0; font: 600 22px/1.2 Georgia, serif; }
.lead { margin: 0; color: var(--mute); }
.err { margin: 0; color: #ff9a8a; font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 10px 14px;
  cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap; }
.btn:hover { border-color: var(--mute); }
.btn.primary { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 14px; font-size: 17px; }
.btn:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; }
.row.center { justify-content: center; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mute); }
input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-width: 0; flex: 1; }
input:focus { outline: 2px solid var(--acc); outline-offset: -1px; }
.share { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--mute); }
.share input { font-size: 13px; color: var(--text); }
.toggles { gap: 18px; }
.chk { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.chk input { flex: none; width: 18px; height: 18px; accent-color: var(--acc); }

.preview { position: relative; aspect-ratio: 16/10; background: #000; border-radius: var(--r); overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pv-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--mute); font-size: 14px; }

/* Звонок */
.call { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; height: 100dvh; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.top .title { font: 600 18px Georgia, serif; }
.count { color: var(--mute); font-size: 14px; }
.net { margin-left: auto; color: var(--acc); font-size: 13px; }
.stage { flex: 1 1 auto; min-height: 0; padding: 0 12px 8px; display: flex; }
.stage:empty { display: none; }
.stage .tile { flex: 1; aspect-ratio: auto; }
.stage .tile video { object-fit: contain; }
.grid { flex: 1 1 auto; min-height: 0; padding: 0 12px 8px; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); grid-auto-rows: 1fr; align-content: center; }
.call.has-stage .grid { flex: 0 0 auto; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 180px;
  grid-auto-rows: 110px; overflow-x: auto; justify-content: start; }
.tile { position: relative; background: var(--panel); border: 2px solid transparent; border-radius: var(--r);
  overflow: hidden; min-height: 110px; display: flex; align-items: center; justify-content: center; transition: border-color .15s; }
.tile.speaking { border-color: var(--acc); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.me video.cam { transform: scaleX(-1); }
.ava { width: 72px; height: 72px; border-radius: 50%; background: var(--panel2); display: flex; align-items: center;
  justify-content: center; font: 600 30px Georgia, serif; color: var(--acc); }
.tag { position: absolute; left: 8px; bottom: 8px; background: rgba(20,17,15,.72); padding: 3px 9px; border-radius: 8px;
  font-size: 13px; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 16px); }
.tag .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag .off { color: var(--red); font-size: 12px; }

.bar { display: flex; justify-content: center; gap: 10px; padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line); }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; cursor: pointer;
  color: var(--text); font-size: 12px; min-width: 60px; }
.ctl .ic { width: 48px; height: 48px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; }
.ctl .ic::before { content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
.ctl.off .ic { background: #3b2320; border-color: #6a3a33; color: #ffb3a8; }
.ctl.on .ic { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.ctl.end .ic { background: var(--red); border-color: var(--red); }
.ctl:disabled { opacity: .4; cursor: default; }
#bMic { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/></svg>'); }
#bMic.off { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3M3 3l18 18"/></svg>'); }
#bCam { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linejoin="round"><rect x="3" y="6" width="13" height="12" rx="2"/><path d="M16 10l5-3v10l-5-3z"/></svg>'); }
#bCam.off { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"><rect x="3" y="6" width="13" height="12" rx="2"/><path d="M16 10l5-3v10l-5-3zM3 3l18 18"/></svg>'); }
#bScr { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="13" rx="2"/><path d="M8 21h8M12 17v4M12 14V8M9 11l3-3 3 3"/></svg>'); }
#bLink { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><path d="M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1"/></svg>'); }
#bEnd { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M12 9c-3.2 0-6.2.9-8.7 2.6-.7.5-.9 1.5-.4 2.2l1.3 1.8c.5.6 1.3.8 2 .5l2.3-1c.6-.3.9-.9.9-1.5v-1.5a12 12 0 0 1 5.2 0v1.5c0 .6.3 1.2.9 1.5l2.3 1c.7.3 1.5.1 2-.5l1.3-1.8c.5-.7.3-1.7-.4-2.2A15.4 15.4 0 0 0 12 9z"/></svg>'); }

#bDev { --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><path d="M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0"/><circle cx="16" cy="6" r="2"/><circle cx="10" cy="12" r="2"/><circle cx="18" cy="18" r="2"/></svg>'); }

/* Устройства и уровень микрофона */
.devs { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.devs label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--mute); flex: 1 1 100%; min-width: 0; }
.devs select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; font: inherit; font-size: 14px; }
.devs select:focus { outline: 2px solid var(--acc); outline-offset: -1px; }
.devs .hint { color: var(--mute); font-size: 13px; opacity: .8; }
.devs .btn.small { align-self: flex-start; padding: 6px 10px; font-size: 13px; }
.devs.panel { margin: 0 12px 8px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  justify-content: center; }
.devs.panel label { flex: 0 1 300px; }
.lvl { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.lvl b { width: 3px; background: var(--line); border-radius: 1px; transition: background .08s; }
.lvl b:nth-child(1) { height: 5px; } .lvl b:nth-child(2) { height: 8px; } .lvl b:nth-child(3) { height: 12px; }
.lvl b.on { background: var(--green); }
.ctl .ic { position: relative; }
.ctl .ic .lvl { position: absolute; right: 6px; bottom: 7px; height: 9px; }
.ctl .ic .lvl b { width: 2px; }
.ctl .ic .lvl b:nth-child(1) { height: 3px; } .ctl .ic .lvl b:nth-child(2) { height: 6px; } .ctl .ic .lvl b:nth-child(3) { height: 9px; }
.ctl.off .lvl { display: none; }

.unlock { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 5; }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 6; }

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .call.has-stage .grid { grid-auto-columns: 130px; grid-auto-rows: 90px; }
  .ctl { min-width: 52px; }
  .ctl .ic { width: 46px; height: 46px; }
}
