:root { color-scheme: dark; --bg: #1b1b1f; --card: #26262c; --accent: #ff6b8b; --text: #f2f2f5; --muted: #9a9aa5; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#app { height: 100%; display: flex; flex-direction: column; }
.auth { margin: auto; width: min(360px, 90vw); background: var(--card); padding: 24px; border-radius: 16px; display: grid; gap: 12px; }
.auth h1 { margin: 0 0 4px; font-size: 22px; }
input, button { font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid #3a3a42; background: #1f1f24; color: var(--text); }
button { background: var(--accent); border: 0; color: #fff; font-weight: 600; cursor: pointer; }
button.link { background: none; color: var(--muted); font-weight: 400; }
.error { color: #ff8a8a; min-height: 1.4em; margin: 0; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--card); }
.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 20px; }
.chat { flex: 1; overflow-y: auto; padding: 12px; }
.muted { color: var(--muted); text-align: center; }
.call { position: fixed; inset: 0; background: #000; z-index: 10; display: flex; flex-direction: column; }
.call[hidden] { display: none; }
#remote { flex: 1; width: 100%; min-height: 0; object-fit: cover; background: #111; }
#local { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px; width: 28vw; max-width: 160px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: #222; transform: scaleX(-1); }
.status { position: absolute; top: 40%; width: 100%; text-align: center; margin: 0; font-size: 20px; text-shadow: 0 1px 6px #000; }
.controls { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 24px); width: 100%; display: flex; justify-content: center; gap: 16px; }
.controls button { min-width: 130px; border-radius: 28px; }
button.danger { background: #e5484d; }
.chat { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--card); white-space: pre-wrap; overflow-wrap: anywhere; align-self: flex-start; }
.msg.mine { background: var(--accent); align-self: flex-end; }
.msg time { margin-left: 8px; font-size: 11px; opacity: .65; }
.msg.pending { opacity: .55; }
.msg.failed { outline: 1px solid #e5484d; }
.composer { display: flex; gap: 8px; padding: 8px 12px; background: var(--card); }
.composer input { flex: 1; min-width: 0; font-size: 16px; }
.composer button { width: 44px; padding: 0; border-radius: 50%; }
.msg img { display: block; max-width: 100%; max-height: 50vh; border-radius: 10px; }
.msg audio { display: block; max-width: 100%; }
.iconbtn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border-radius: 50%; background: #1f1f24; cursor: pointer; font-size: 18px; }
.iconbtn.recording { background: #e5484d; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
button.small { padding: 8px 10px; font-size: 14px; }
.hint { margin: 0; padding: 8px 12px; font-size: 13px; color: var(--muted); background: var(--card); }
.spacer { flex: 1; }
.bar { gap: 8px; }
.round.dim { background: #1f1f24; }
.controls { flex-wrap: wrap; padding: 0 12px; }
.controls .ctl { background: rgba(255,255,255,.18); }
.settings { border: 0; border-radius: 16px; padding: 20px; background: var(--card); color: var(--text); width: min(360px, 92vw); }
.settings::backdrop { background: rgba(0,0,0,.6); }
.settings form { display: grid; gap: 12px; }
.settings h2 { margin: 0; font-size: 18px; }
.settings label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.settings select { font: inherit; padding: 10px; border-radius: 10px; border: 1px solid #3a3a42; background: #1f1f24; color: var(--text); }

/* Рамка с видео собеседника: пропорции как у картинки, скруглённые углы, без обрезки */
.call { --ar: 1.7778; align-items: center; justify-content: center; background: #0d0d10; }
.stage {
  --room-h: calc(100dvh - 140px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  aspect-ratio: var(--ar);
  width: min(calc(100vw - 24px), calc(var(--room-h) * var(--ar)));
  border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  margin-top: calc(env(safe-area-inset-top) + 8px);
  transition: width .35s ease, aspect-ratio .35s ease; /* телефон повернули — рамка плавно меняет форму */
}
@media (prefers-reduced-motion: reduce) { .stage { transition: none; } }
.stage #remote { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
