:root {
  --bg: #0b0a12;
  --bg-2: #100e19;
  --surface: #16131f;
  --surface-2: #1e1a2b;
  --surface-3: #282338;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f5f3fb;
  --muted: #a39db6;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #d946ef 50%, #f97316 100%);
  --rec: #ff3b5c;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.ico { width: 20px; height: 20px; flex: none; display: block; }
[data-icon] { display: inline-flex; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform .12s ease, background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 24px -8px rgba(217, 70, 239, .55); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn-rec { background: var(--rec); color: #fff; height: 48px; }
.btn-rec .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.btn-rec.on .dot { border-radius: 3px; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12px; font-weight: 500; padding: 0 4px; }
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18);
  background: rgba(15, 12, 25, .55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; color: #fff;
}
.round-btn.off { background: var(--rec); border-color: transparent; }
.round-btn.on { background: var(--accent); border-color: transparent; }
.mini-btn { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(255,255,255,.1); display: grid; place-items: center; }
.mini-btn .ico { width: 16px; height: 16px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.row-btns.center { justify-content: center; }

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand.small { font-size: 16px; gap: 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--grad); position: relative; flex: none;
  box-shadow: 0 6px 18px -6px rgba(217, 70, 239, .7);
}
.brand-mark::after { content: ''; position: absolute; left: 9px; top: 5px; width: 10px; height: 18px; border: 2.5px solid #fff; border-radius: 3px; }
.brand.small .brand-mark { width: 24px; height: 24px; border-radius: 8px; }
.brand.small .brand-mark::after { left: 7.5px; top: 4px; width: 9px; height: 16px; border-width: 2px; }
.pill-soft { font-size: 13px; color: var(--muted); padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; }

/* ---------- главная ---------- */
#view-home {
  min-height: 100dvh;
  background:
    radial-gradient(60% 50% at 80% 10%, rgba(139, 92, 246, .22), transparent 70%),
    radial-gradient(50% 50% at 10% 90%, rgba(236, 72, 153, .14), transparent 70%), var(--bg);
}
.home { max-width: 1180px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 20px 40px; }
.home-top { display: flex; justify-content: space-between; align-items: center; }
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; min-height: calc(100dvh - 120px); }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #d8b4fe; margin-bottom: 14px; }
.hero h1 { font-size: clamp(34px, 5.4vw, 64px); line-height: 1.04; letter-spacing: -.035em; margin: 0 0 18px; font-weight: 800; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 18px; color: #cdc8dc; max-width: 560px; margin: 0 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.join-form { display: flex; gap: 8px; flex: 1 1 280px; max-width: 380px; }
.join-form input {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line-2);
  background: rgba(255,255,255,.04); outline: none;
}
.join-form input:focus { border-color: var(--accent); }
.join-form .btn { height: 52px; }
.features { list-style: none; padding: 0; margin: 32px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.features li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 99px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 13px; color: #ddd8ea; }
.features .ico { width: 16px; height: 16px; color: #c4b5fd; }

.hero-visual { display: grid; place-items: center; }
.mock-phone {
  width: min(320px, 70vw); aspect-ratio: 9/16; border-radius: 34px; position: relative; overflow: hidden;
  border: 8px solid #1c1a26; box-shadow: 0 40px 80px -30px rgba(139, 92, 246, .55), 0 0 0 1px rgba(255,255,255,.08);
  display: grid; grid-template-rows: 1fr 1fr; transform: rotate(3deg);
}
.mock-half { position: relative; overflow: hidden; }
.mock-half.a { background: radial-gradient(80% 70% at 30% 30%, #19d4b8 0%, transparent 60%), radial-gradient(70% 70% at 80% 60%, #7c4dff 0%, transparent 60%), #070a1c; }
.mock-half.b { background: linear-gradient(180deg, #2b1055, #e0567a 70%, #ffb07d); }
.mock-person { position: absolute; left: 50%; bottom: -12%; width: 56%; height: 82%; transform: translateX(-50%); }
.mock-person::before { content: ''; position: absolute; left: 50%; top: 0; width: 46%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: #f1d3c0; }
.mock-person::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 58%; border-radius: 48% 48% 0 0; background: #2b2a3a; }
.mock-half.b .mock-person::after { background: #f5f0e8; }
.mock-half.b .mock-person::before { background: #c99a7c; }
.mock-name { position: absolute; left: 10px; bottom: 10px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: rgba(0,0,0,.5); }
.mock-caption {
  position: absolute; left: 0; right: 0; top: 66%; text-align: center; font: 900 26px Montserrat, sans-serif;
  color: #fff; -webkit-text-stroke: 6px #000; paint-order: stroke fill; letter-spacing: .01em;
}
.mock-caption b { color: #ffe14d; }
.mock-rec { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: rgba(0,0,0,.5); }
.mock-rec i { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }

/* ---------- формы ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); outline: none; font-size: 15px;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.alert { padding: 12px 14px; border-radius: 12px; background: rgba(255, 59, 92, .12); border: 1px solid rgba(255, 59, 92, .35); color: #ffc2cd; font-size: 14px; margin-bottom: 14px; }
.alert a { color: #fff; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
small { color: var(--muted); font-weight: 400; }

.switch { display: flex; align-items: center; gap: 12px; padding: 9px 0; cursor: pointer; font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 40px; height: 24px; border-radius: 99px; background: var(--surface-3); position: relative; flex: none; transition: background .2s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.big { font-weight: 600; font-size: 15px; }

.ctl { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; margin: 8px 0; font-size: 13.5px; color: #d6d1e4; }
.ctl output { font-size: 12px; color: var(--muted); min-width: 34px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(139, 92, 246, .35); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1; min-width: 0; padding: 8px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.1; }
.seg button small { display: block; font-size: 10.5px; font-weight: 500; margin-top: 2px; opacity: .8; }
.seg button.on { background: var(--surface-3); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.06) inset; }
.seg.small button { padding: 6px 4px; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-2); background: transparent; font-size: 13px; color: #ddd8ea; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- гримёрка ---------- */
#view-prejoin { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 60% at 30% 30%, rgba(139, 92, 246, .18), transparent 70%), var(--bg); }
.prejoin { display: grid; grid-template-columns: auto 420px; gap: 36px; align-items: center; max-width: 1000px; width: 100%; }
.pj-preview { display: grid; place-items: center; }
.pj-frame {
  position: relative; height: min(78dvh, 720px); aspect-ratio: 9/16; border-radius: 28px; overflow: hidden;
  background: #120f1c; border: 1px solid var(--line-2); box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
}
.pj-frame canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.pj-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.pj-tools { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 10px; }
.pj-bottom { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; align-items: center; gap: 14px; }
.meter { width: 90px; height: 8px; border-radius: 8px; background: rgba(0,0,0,.45); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #a3e635 70%, #facc15); border-radius: 8px; transition: width .08s linear; }
.pj-form h2 { margin: 14px 0 4px; font-size: 28px; letter-spacing: -.02em; }
.pj-form > p.muted { margin: 0 0 18px; }

/* ---------- фоны ---------- */
.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bg-grid.compact { grid-template-columns: repeat(6, 1fr); gap: 6px; }
.bg-tile {
  position: relative; aspect-ratio: 3/4; border-radius: 12px; border: 2px solid transparent; overflow: hidden; padding: 0;
  background: var(--surface-2) center/cover no-repeat; display: flex; align-items: flex-end; justify-content: center;
}
.bg-tile.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(139, 92, 246, .55); }
.bg-tile span { width: 100%; padding: 14px 3px 4px; font-size: 10.5px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); text-align: center; line-height: 1.1; }
.bg-tile .ico { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%); width: 22px; height: 22px; opacity: .9; }
.bg-tile.t-none { background: repeating-conic-gradient(#2a2638 0 25%, #221f30 0 50%) 0 0/14px 14px; }
.bg-tile.t-blur-light { background: radial-gradient(circle at 50% 40%, #8a7fb0, #3c3554); filter: saturate(.8); }
.bg-tile.t-blur { background: radial-gradient(circle at 50% 40%, #6d6290, #241f36); }
.bg-tile.t-green { background: #00b140; }
.bg-tile.t-upload { background: var(--surface-2); border: 2px dashed var(--line-2); }
.bg-grid.compact .bg-tile span { font-size: 9px; padding: 10px 2px 3px; }

/* ---------- студия ---------- */
#view-studio { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line); min-height: 58px; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 12px; flex: 1; }
.tb-right { justify-content: flex-end; }
.tb-center { display: flex; gap: 8px; }
.room-code { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font: 600 13px ui-monospace, 'SF Mono', Menlo, monospace; color: #d8d3e8; }
.room-code .ico { width: 15px; height: 15px; }
.people { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.people .ico { width: 18px; height: 18px; }
.rec-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 99px; background: rgba(255, 59, 92, .15); border: 1px solid rgba(255, 59, 92, .4); font: 700 14px ui-monospace, Menlo, monospace; color: #ffd0d8; }
.rec-badge i { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.net-badge { padding: 6px 12px; border-radius: 99px; background: rgba(245, 158, 11, .15); color: #fcd34d; font-size: 13px; font-weight: 600; }
@keyframes blink { 50% { opacity: .25; } }

.studio { display: grid; grid-template-columns: minmax(0, 1fr) 372px; min-height: 0; }
.stage-area { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; min-width: 0; min-height: 0; }
.stage-box { position: relative; border-radius: 18px; overflow: hidden; background: #000; box-shadow: 0 30px 70px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.07); flex: none; touch-action: none; }
.stage-box canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.stage-box canvas:active { cursor: grabbing; }
.stage-chip { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); padding: 5px 12px; border-radius: 99px; background: rgba(10,8,18,.65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 12px; font-weight: 600; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }
.stage-chip.show { opacity: 1; }
.stage-empty { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); text-align: center; background: rgba(10,8,18,.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line-2); width: max-content; max-width: 90%; }
.stage-empty p { margin: 0 0 10px; font-weight: 600; }

.safe-zones { position: absolute; inset: 0; pointer-events: none; }
.safe-zones > div { position: absolute; background: rgba(255, 59, 92, .16); border: 1px dashed rgba(255, 120, 140, .7); }
.sz-top { left: 0; right: 0; top: 0; height: 8%; }
.sz-bottom { left: 0; right: 0; bottom: 0; height: 22%; }
.sz-right { right: 0; top: 8%; bottom: 22%; width: 14%; }
.sz-label { position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 600; color: #ffd0d8; text-shadow: 0 1px 2px #000; }

.countdown { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); font: 900 clamp(80px, 22vh, 200px) Montserrat, Inter, sans-serif; color: #fff; text-shadow: 0 10px 40px rgba(0,0,0,.5); }
.countdown span { animation: pop .9s ease-out both; }
@keyframes pop { 0% { transform: scale(1.6); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .0; } }

.prompter { position: absolute; left: 6%; right: 6%; top: 3%; background: rgba(8, 6, 14, .78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 14px; border: 1px solid rgba(255,255,255,.12); overflow: hidden; }
.prompter-view { height: clamp(120px, 26%, 240px); max-height: 30vh; overflow: hidden; position: relative; -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 70%, transparent); mask-image: linear-gradient(transparent, #000 22%, #000 70%, transparent); }
.prompter-text { padding: 60px 18px 120px; font-weight: 600; line-height: 1.35; white-space: pre-wrap; will-change: transform; }
.prompter.mirror .prompter-text { transform-origin: center; }
.prompter-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid rgba(255,255,255,.08); }
.prompter-bar input { flex: 1; }

.filmstrip { display: flex; gap: 10px; justify-content: center; flex: none; max-width: 100%; overflow-x: auto; padding: 2px; }
.tile { position: relative; width: 132px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--surface-2); flex: none; border: 2px solid transparent; transition: border-color .15s; cursor: pointer; }
.tile.speaking { border-color: var(--ok); }
.tile.selected { box-shadow: 0 0 0 2px var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile-name { position: absolute; left: 6px; bottom: 5px; right: 6px; font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-name .ico { width: 13px; height: 13px; color: #ff8fa3; }
.tile-q { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.tile-q.ok { background: var(--warn); }
.tile-q.bad, .tile-q.connecting { background: var(--rec); }
.tile-q.local { display: none; }
.tile-unmute { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.6); font-size: 11px; font-weight: 600; border: 0; color: #fff; }

/* панель */
.panel { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.panel-grip { display: none; }
.panel-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
.panel-tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; flex: 1 0 auto; min-width: 44px; }
.panel-tabs button .ico { width: 19px; height: 19px; }
.panel-tabs button.on { background: var(--surface-3); color: #fff; }
.panel-tabs .panel-close { display: none; }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 18px 24px; overscroll-behavior: contain; }
.panel-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 10px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.panel-body h3 small { text-transform: none; letter-spacing: 0; font-size: 12px; }
.tab { display: none; }
.tab.on { display: block; }

.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lay-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.lay-tile.on { border-color: var(--accent); color: #fff; background: rgba(139, 92, 246, .14); }
.lay-ico { width: 26px; height: 44px; border-radius: 5px; border: 2px solid currentColor; position: relative; overflow: hidden; display: grid; gap: 2px; padding: 2px; }
.lay-ico i { background: currentColor; opacity: .55; border-radius: 2px; }
.lay-ico.l-stack { grid-template-rows: 1fr 1fr; }
.lay-ico.l-columns { grid-template-columns: 1fr 1fr; }
.lay-ico.l-grid { grid-template: 1fr 1fr / 1fr 1fr; }
.lay-ico.l-solo i, .lay-ico.l-speaker i { opacity: .55; }
.lay-ico.l-pip i:first-child { position: absolute; inset: 2px; }
.lay-ico.l-pip i:last-child { position: absolute; right: 3px; bottom: 7px; width: 9px; height: 12px; opacity: 1; background: #fff; }
.lay-ico.l-auto { place-items: center; font-size: 13px; font-weight: 800; }
.lay-ico.l-facetime i:first-child { position: absolute; inset: 2px; }
.lay-ico.l-facetime i:last-child { position: absolute; right: 3px; bottom: 3px; width: 8px; height: 12px; opacity: 1; background: #fff; border-radius: 3px; }
.lay-ico.l-facetime::before { content: ''; position: absolute; left: 3px; right: 3px; top: 3px; height: 7px; border-radius: 3px; background: rgba(255,255,255,.85); z-index: 1; }
.lay-ico.l-speaker::after { content: ''; position: absolute; left: 50%; top: 40%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--ok); }

.cap-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cap-style { height: 64px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(135deg, #3b2a5c, #19324a); display: grid; place-items: center; padding: 0 4px; }
.cap-style.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139, 92, 246, .45); }
.cap-style .s-tiktok { font: 900 15px Montserrat, sans-serif; color: #fff; -webkit-text-stroke: 4px #000; paint-order: stroke fill; }
.cap-style .s-tiktok b { color: #ffe14d; }
.cap-style .s-box { font: 600 12px Inter, sans-serif; background: rgba(0,0,0,.7); padding: 4px 8px; border-radius: 6px; }
.cap-style .s-minimal { font: 700 13px Inter, sans-serif; text-shadow: 0 1px 6px #000; }

.logo-row { display: flex; gap: 14px; align-items: flex-start; }
.logo-preview { width: 72px; height: 72px; border-radius: 12px; border: 1px dashed var(--line-2); display: grid; place-items: center; font-size: 12px; color: var(--muted); background: var(--bg-2) center/contain no-repeat; flex: none; }
.col { flex: 1; min-width: 0; }
.logo-row .row-btns { margin-top: 0; }

.rec-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; }
.rec-card .seg { margin-top: 6px; }
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-session { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg-2); }
.rec-session h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.rec-file { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; border-top: 1px solid var(--line); }
.rec-file:first-of-type { border-top: 0; }
.rec-file .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-file .sz { color: var(--muted); font-size: 12px; }
.rec-file a { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); flex: none; }
.rec-file a .ico { width: 16px; height: 16px; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.badge.conv { background: rgba(245, 158, 11, .18); color: #fcd34d; }

.net-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.net-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); }
.net-row b { font-weight: 600; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-2); font: 600 12px ui-monospace, Menlo, monospace; color: #fff; text-align: center; }

/* док */
.dock { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); }
.dock-group { display: flex; gap: 4px; align-items: center; }
.dock-tabs { padding: 0 10px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 58px; padding: 7px 8px; border: 0; border-radius: 12px; background: transparent; color: #e3dff0; }
.dock-btn em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 500; }
.dock-btn:hover { background: var(--surface-2); }
.dock-btn .ico { width: 22px; height: 22px; }
.dock-btn.off { color: #ff8fa3; }
.dock-btn.off .ico { color: #fff; background: var(--rec); border-radius: 50%; padding: 4px; width: 30px; height: 30px; margin: -4px 0; }
.dock-btn.on-accent { color: #d8b4fe; }
.dock-btn.danger:hover { background: rgba(255, 59, 92, .15); color: #ff8fa3; }
.dock-rec { display: flex; align-items: center; gap: 9px; height: 46px; padding: 0 20px 0 16px; border-radius: 99px; border: 0; background: var(--rec); color: #fff; font-weight: 800; letter-spacing: .04em; box-shadow: 0 8px 24px -8px rgba(255, 59, 92, .7); }
.dock-rec i { width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: border-radius .2s; }
.dock-rec.on { background: #2a1520; border: 2px solid var(--rec); box-shadow: none; }
.dock-rec.on i { border-radius: 3px; background: var(--rec); }

/* модалки */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 10, .7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { position: relative; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 22px; padding: 26px; }
.modal-card.wide { width: min(820px, 100%); }
.modal-card h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.modal-x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-2); display: grid; place-items: center; }
.qr-box { display: grid; place-items: center; margin: 18px 0; }
.qr-box img { width: 210px; height: 210px; background: #fff; border-radius: 16px; padding: 10px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; padding: 0 12px; height: 42px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); font-size: 13px; }
.inv-alt { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.inv-alt a { color: #d8b4fe; word-break: break-all; }
.result { display: grid; grid-template-columns: 260px 1fr; gap: 22px; margin-top: 14px; }
.result video { width: 100%; aspect-ratio: 9/16; max-height: 64dvh; background: #000; border-radius: 14px; object-fit: contain; }
.res-side { display: flex; flex-direction: column; gap: 10px; }
.res-side p { margin: 0; }

/* тосты */
.toasts { position: fixed; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 12px; background: #231f33; border: 1px solid var(--line-2); box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 14px; font-weight: 500; opacity: 0; transform: translateY(-8px); transition: all .25s; text-align: center; }
.toast.show { opacity: 1; transform: none; }
.toast-ok { border-color: rgba(34, 197, 94, .5); }
.toast-err { border-color: rgba(255, 59, 92, .55); }

/* свои фоны */
.bg-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.bg-tile > span { position: relative; }
.bg-badge { position: absolute; top: 5px; left: 5px; font-size: 9px; padding: 2px 5px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; }
.bg-del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.65); display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.bg-del .ico { position: static; transform: none; width: 13px; height: 13px; }
.bg-tile:hover .bg-del { opacity: 1; }
@media (pointer: coarse) { .bg-del { opacity: 1; } }
.bg-mine code { font: 600 11.5px ui-monospace, Menlo, monospace; color: #ddd6f3; word-break: break-all; }
.tab.drop { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 14px; }

/* плитка «Пригласить» в ленте участников */
.tile-invite { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--line-2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; }
.tile-invite:hover { border-color: var(--accent); color: #fff; }
.tile-invite .ico { width: 20px; height: 20px; }

/* ---------- библиотека записей ---------- */
#view-library { min-height: 100dvh; background: radial-gradient(60% 40% at 80% 0%, rgba(139, 92, 246, .16), transparent 70%), var(--bg); }
.lib { max-width: 1100px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 20px 60px; }
.lib .brand { text-decoration: none; }
.lib h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.03em; margin: 28px 0 16px; }
.lib-folder { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 18px 20px; margin-bottom: 24px; }
.lib-folder-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lib-folder code { font: 600 14px ui-monospace, 'SF Mono', Menlo, monospace; color: #e9e4f7; word-break: break-all; }
.lib-folder .row-btns { margin: 0; }
.lib-path { display: flex; gap: 8px; width: 100%; }
.lib-path input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); font: 13px ui-monospace, Menlo, monospace; }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.lib-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.lib-card video { width: 100%; aspect-ratio: 9/16; max-height: 420px; background: #000; object-fit: contain; display: block; }
.lib-card .lib-noprev { aspect-ratio: 16/9; display: grid; place-items: center; color: var(--muted); background: var(--bg-2); font-size: 13px; }
.lib-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.lib-body h4 { margin: 0; font-size: 15px; }
.lib-meta { font-size: 12.5px; color: var(--muted); }
.lib-body .row-btns { margin: 4px 0 0; }
.lib-empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.lib-empty .btn { margin-top: 14px; }
.btn-danger { background: rgba(255, 59, 92, .12); border-color: rgba(255, 59, 92, .35); color: #ffb3c0; }
.btn-danger:hover { background: rgba(255, 59, 92, .22); }

.login { max-width: 380px; margin: 0 auto; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.login h2 { margin: 0; font-size: 22px; color: var(--text); }
.login p { margin: 0; }
.login input { height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); font-size: 15px; outline: none; }
.login input:focus { border-color: var(--accent); }
.lib .home-top .row-btns { margin: 0; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .studio { grid-template-columns: minmax(0, 1fr) 330px; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 36px; min-height: auto; padding-top: 30px; }
  .hero-visual { order: -1; }
  .mock-phone { width: min(220px, 56vw); }
  .prejoin { grid-template-columns: 1fr; gap: 18px; }
  .pj-frame { height: min(56dvh, 520px); }
  .studio { grid-template-columns: 1fr; }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 64dvh; border-left: 0;
    border-radius: 22px 22px 0 0; border-top: 1px solid var(--line-2); box-shadow: 0 -20px 60px rgba(0,0,0,.6);
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); padding-bottom: var(--safe-b);
  }
  .panel.open { transform: none; }
  .panel-grip { display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--line-2); margin: 8px auto 0; flex: none; }
  .panel-tabs .panel-close { display: flex; margin-left: auto; justify-content: center; }
  .hide-sm { display: none !important; }
  .stage-area { padding: 8px; gap: 8px; }
  .stage-box { border-radius: 14px; }
  .filmstrip { gap: 6px; }
  .tile { width: 84px; height: 56px; border-radius: 9px; }
  .dock { gap: 6px; padding: 6px 8px calc(6px + var(--safe-b)); justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  .dock::-webkit-scrollbar { display: none; }
  .dock-group { flex: none; }
  .dock-tabs { padding: 0 4px; }
  .dock-btn { min-width: 42px; padding: 6px 4px; }
  .dock-btn em { font-size: 9.5px; }
  .dock-btn .ico { width: 21px; height: 21px; }
  .dock-rec { height: 42px; padding: 0 12px; }
  .dock-rec span { display: none; }
  .topbar { padding: calc(6px + var(--safe-t)) 10px 6px; min-height: 48px; }
  .result { grid-template-columns: 1fr; }
  .result video { max-height: 46dvh; }
}

/* Средняя ширина (узкое окно, планшет): подписи кнопок мельче, чтобы REC и «Выйти» всегда помещались. */
@media (max-width: 900px) and (min-width: 521px) {
  .dock-btn { min-width: 50px; padding: 6px 2px; }
  .dock-btn em { font-size: 10px; }
}

@media (max-width: 760px) {
  .dock-btn em { display: none; }
  .dock-btn { min-width: 40px; }
}

@media (max-width: 520px) {
  .hide-xs { display: none !important; }
  .card { padding: 20px; border-radius: 18px; }
  #view-prejoin { padding: 12px; place-items: start center; }
  .pj-frame { height: 50dvh; border-radius: 20px; }
  #pj-join { position: sticky; bottom: calc(12px + var(--safe-b)); z-index: 5; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .bg-grid.compact { grid-template-columns: repeat(5, 1fr); }
  .dock-group { gap: 0; }
  .dock-btn { min-width: 38px; }
  .dock-btn em { display: none; }
  .room-code { padding: 0 10px; font-size: 12px; }
  .ctl { grid-template-columns: 90px 1fr auto; }
  .layout-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Узкие телефоны: «Зеркало» остаётся в гримёрке и во вкладке «Фон», чтобы REC и «Выйти» помещались. */
@media (max-width: 430px) {
  #d-mirror { display: none; }
  .dock-btn { min-width: 36px; }
}

@media (pointer: coarse) {
  .hide-touch { display: none !important; }
}
