:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #18212f;
  --muted: #5b6678;
  --line: #e1e6ee;
  --brand: #2353a8;
  --brand-ink: #ffffff;
  --brand-soft: #e7eefb;
  --ok: #1d8a4e;
  --ok-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff4dd;
  --danger: #c0352b;
  --room: #11161f;
  --room-2: #1b2230;
  --room-ink: #eef2f8;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 16px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px calc(32px + env(safe-area-inset-bottom)); }
.hero { text-align: center; margin: 12px 0 24px; }
.hero .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; }
.lead { color: var(--muted); margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; box-shadow: 0 1px 2px rgba(20, 30, 50, .04), 0 8px 24px rgba(20, 30, 50, .05); }
.meta { color: var(--muted); margin: 0 0 6px; }
.badge { display: inline-block; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 13px; padding: 3px 10px; border-radius: 99px; margin-bottom: 10px; }
.foot { color: var(--muted); font-size: 13px; text-align: center; margin-top: 20px; }

form { margin-top: 18px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
label input { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
label input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 20px; height: 20px; margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
@media (max-width: 460px) { .row2 { grid-template-columns: 1fr; gap: 0; } }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 10px; }
.center { text-align: center; }
.err { color: var(--danger); font-size: 14px; min-height: 0; margin: 0 0 10px; }
.err:empty { display: none; }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.small-link { display: block; text-align: center; color: var(--muted); font-size: 14px; margin-top: 14px; }
button.link { background: none; border: 0; color: var(--brand); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; word-break: break-all; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { border-color: #c8d0dc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions .btn.big { flex: 1 1 220px; width: auto; }

.linkbox { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 14px 0; }
.linkbox.mod { border-color: #f0d9a8; background: #fffaf0; }
.linkhead { font-weight: 700; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.pin { font-size: 30px; font-weight: 700; letter-spacing: 4px; font-variant-numeric: tabular-nums; }

.waiting { text-align: center; padding: 18px 0 4px; }
.waiting .btn { margin-top: 10px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ собрание */
.page-room .room { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--room); color: var(--room-ink); }
.rhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--room-2); }
.rtitle { min-width: 0; display: flex; flex-direction: column; }
.rtitle b, .rtitle span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rtitle span { font-size: 13px; color: #a9b4c6; }
.rcount { font-size: 14px; color: #c9d2e0; white-space: nowrap; }
.rbody { flex: 1; display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; display: grid; place-items: center; overflow: hidden; }
#mainVideo { width: 100%; height: 100%; object-fit: cover; background: #000; }
#mainVideo.contain { object-fit: contain; }
#mainVideo.mirror { transform: scaleX(-1); }
#pipVideo { position: absolute; right: 12px; top: 12px; width: 22%; max-width: 220px; min-width: 110px; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .25); background: #000; }
.placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; }
.placeholder .avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; font-size: 34px; font-weight: 700; color: #fff; }
.placeholder .hint { color: #9aa6b8; }
.speakers { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; max-width: calc(100% - 24px); }
.spk { background: rgba(10, 14, 22, .78); border-radius: 99px; padding: 6px 12px; font-size: 14px; border: 2px solid transparent; }
.spk.on { border-color: #4cd47f; box-shadow: 0 0 0 3px rgba(76, 212, 127, .25); }
.spk .mic { margin-right: 6px; }
.unmute { position: absolute; inset: auto 50% 50% auto; transform: translate(50%, 50%); font-size: 18px; padding: 16px 24px; z-index: 3; }
.toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(10, 14, 22, .9); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); text-align: center; z-index: 4; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }

.bar { display: flex; justify-content: safe center; gap: 6px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--room-2); overflow-x: auto; }
.tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 76px; min-height: 58px; padding: 6px 10px; border-radius: 12px; border: 0; background: #2a3344; color: var(--room-ink); font: inherit; font-size: 12px; cursor: pointer; }
.tool:hover { background: #343f53; }
.tool .ico { font-size: 22px; line-height: 1; }
.tool.on { background: #33496f; }
.tool.off { background: #4a2a2a; }
.tool.raised { background: #f2b33d; color: #1d1600; }
.tool.danger { background: var(--danger); color: #fff; }
.tool .cnt { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 700; color: #ffd36b; }
#handBtn { min-width: 128px; }
body:not(.is-mod) [data-m] { display: none; }
body.is-mod [data-p] { display: none; }
@media (max-width: 560px) {
  .tool { min-width: 58px; padding: 6px; }
  .tool .lbl { font-size: 11px; }
  #handBtn { min-width: 110px; }
  body.is-mod .tool .lbl { display: none; }
  body.is-mod .tool { min-height: 50px; min-width: 40px; flex: 1 1 0; max-width: 56px; }
  body.is-mod .bar { gap: 4px; padding-left: 6px; padding-right: 6px; }
}

.side { width: 360px; max-width: 100%; display: flex; flex-direction: column; background: #fff; color: var(--ink); border-left: 1px solid #000; min-height: 0; }
@media (max-width: 899px) { .side { position: absolute; inset: auto 0 0 0; top: 64px; width: auto; bottom: 78px; z-index: 5; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .4); } }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; font: inherit; font-size: 14px; font-weight: 600; padding: 12px 6px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .close { flex: 0 0 44px; font-size: 22px; }
.tabs .cnt { color: var(--danger); }
.pane { flex: 1; overflow-y: auto; padding: 10px 12px; min-height: 0; }
.pane.chat { display: flex; flex-direction: column; padding: 0; }
.empty { color: var(--muted); text-align: center; font-size: 14px; padding: 18px 0; }
.listhead { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 16px 0 6px; }
.prow { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prow.away { opacity: .55; }
.pinfo { min-width: 0; display: flex; flex-direction: column; }
.pinfo b, .pinfo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinfo span { font-size: 13px; color: var(--muted); }
.pst { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pbtns { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.search { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; }
#csvBtn { width: 100%; margin-top: 12px; }

.msgs { flex: 1; overflow-y: auto; padding: 10px 12px; min-height: 0; }
.msg { margin-bottom: 10px; }
.mwho { font-size: 12px; color: var(--muted); font-weight: 600; }
.mwho .mt { font-weight: 400; margin-left: 6px; }
.mwho .tag { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 0 5px; font-weight: 600; }
.mtext { background: #f0f3f8; border-radius: 10px; padding: 7px 10px; white-space: pre-wrap; word-wrap: break-word; display: inline-block; max-width: 100%; }
.msg.mod .mtext { background: var(--brand-soft); }
.msg.mine { text-align: right; }
.msg.mine .mtext { background: var(--ok-soft); text-align: left; }
.chatform { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); margin: 0; }
.chatform input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }

.pchat { position: absolute; right: 12px; bottom: 90px; width: 360px; max-width: calc(100% - 24px); height: 420px; max-height: calc(100% - 170px); background: #fff; color: var(--ink); border-radius: 16px; display: flex; flex-direction: column; z-index: 6; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.pchathead { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.pchathead .close { border: 0; background: none; font-size: 22px; width: 40px; height: 40px; cursor: pointer; color: var(--muted); }
.pchat .hint { padding: 0 12px; margin: 4px 0 0; font-size: 12px; }

.modal { position: fixed; inset: 0; background: rgba(10, 14, 22, .55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.mbox { background: #fff; color: var(--ink); border-radius: 16px; padding: 20px; max-width: 400px; width: 100%; }
.mbox .actions { justify-content: flex-end; }
/* Родителю — картинка ведущего целиком (доска, слайды), без обрезки краёв. */
body:not(.is-mod) #mainVideo { object-fit: contain; }
