/* Silentia. Мягкая тёмная тема: все цвета и размеры – в переменных ниже, меняются в одном месте. */

:root {
  --bg: #0f1118;
  --surface: #161924;
  --surface-2: #1e2230;
  --surface-3: #292e3f;
  --line: rgba(255, 255, 255, 0.07);
  --fg: #eef0f7;
  --fg-sub: #aab0c2;
  --fg-dim: #6f768b;
  --accent: #8a8cff;
  --accent-hover: #a5a8ff;
  --grad: linear-gradient(135deg, #9a82ff 0%, #6f9bff 100%);
  --glow-shadow: 0 6px 22px rgba(124, 128, 255, 0.35);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ok: #52d6a4;
  --warn: #f5c46b;
  --danger: #ff6f7f;
  --radius: 26px;
  --radius-sm: 16px;
  --dur: 0.22s;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior-y: none; } /* не даём потянуть вниз и случайно обновить страницу */
body {
  background: var(--bg);
  color: var(--fg);
  /* на iPhone и Mac - скруглённый системный шрифт, он мягче; на остальных - обычный системный */
  font: 400 16px/1.5 ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

.btn {
  border: 0; cursor: pointer; border-radius: 999px;
  padding: 14px 24px; font-weight: 600; font-size: 16px; white-space: nowrap;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), filter var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn--primary { background: var(--grad); color: #fff; box-shadow: var(--glow-shadow); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--small { padding: 10px 18px; font-size: 14px; }
.btn--ghost { background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--surface-3); }
a.btn { display: block; text-align: center; text-decoration: none; }
.escape { display: grid; gap: 12px; }
.btn:focus-visible, .bar__btn:focus-visible, .field__input:focus-visible, .how summary:focus-visible,
.tile__tool:focus-visible, .tile__code:focus-visible, .tile__name--edit:focus-visible, .split:focus-visible,
.icon-btn:focus-visible, .contact__open:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

.field__input {
  width: 100%; min-width: 0;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 13px 16px; font-size: 16px; outline: none; color: var(--fg);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field__input::placeholder { color: var(--fg-dim); }
.field__input:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.field__input--code { font-size: 20px; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.field__input--code::placeholder { font-size: 16px; letter-spacing: 0; }
/* select берёт системный чёрный текст на тёмном фоне (особенно iOS) - снимаем системный вид и рисуем свою стрелку */
select.field__input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
  padding-right: 42px;
}

/* ---------- лобби, вход, настройки: карточка по центру ---------- */

.lobby {
  min-height: 100svh;
  display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(90% 60% at 50% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}
.lobby:not([hidden]) { animation: rise 0.35s var(--ease); }
.lobby__panel {
  width: min(440px, 100%); display: grid; gap: 16px;
  padding: 30px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.lobby__title { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.lobby__sub { margin: -8px 0 4px; color: var(--fg-sub); font-size: 15px; }
.field__label { font-size: 13px; color: var(--fg-sub); padding-left: 4px; }
.lobby__form { display: flex; flex-wrap: wrap; gap: 12px; }
.lobby__form .field__label { flex-basis: 100%; margin-bottom: -4px; }
.lobby__form .field__input { flex: 1; }
.toggle { display: flex; align-items: center; gap: 8px; flex-basis: 100%; font-size: 14px; color: var(--fg); }
.lobby__form #voice-hint { flex-basis: 100%; font-size: 13px; }
.lobby__note {
  margin: 0; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--fg-sub); font-size: 14px;
}
.lobby__hint { margin: -4px 0 0; padding: 0 4px; color: var(--fg-dim); font-size: 13px; flex-basis: 100%; }
.how { color: var(--fg-sub); font-size: 14px; }
.how summary { cursor: pointer; color: var(--accent-hover); font-weight: 600; list-style: none; width: fit-content; }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: ' +'; }
.how[open] summary::after { content: ' −'; }
.how ul { margin: 12px 0 0; padding: 0 0 0 18px; display: grid; gap: 8px; }
.section { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.section__title { margin: 0; font-size: 13px; font-weight: 600; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.06em; padding-left: 4px; }

@media (max-width: 560px) {
  .lobby__panel { padding: 22px; }
  .lobby__form { display: grid; }
}

/* ---------- звонок ---------- */

.call {
  height: 100svh; position: relative; overflow: hidden;
  display: grid; grid-template-rows: 1fr auto;
  background: var(--bg);
  touch-action: manipulation; /* убирает случайный зум по двойному тапу на видео */
}

.tiles {
  grid-row: 1; min-height: 0; position: relative;
  display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 1fr; grid-auto-rows: 1fr;
}
.tiles[data-count="2"] { grid-template-columns: minmax(0, var(--a, 1fr)) minmax(0, var(--b, 1fr)); }
.tiles[data-count="2"][data-dir="v"] { grid-template-columns: 1fr; grid-template-rows: minmax(0, var(--a, 1fr)) minmax(0, var(--b, 1fr)); }
.tiles[data-count="3"], .tiles[data-count="4"] { grid-template-columns: 1fr 1fr; }

/* один в звонке: своё окно маленьким в углу, остальное место – ожидание */
.tiles[data-alone="true"] {
  position: absolute; right: 16px; bottom: 96px; z-index: 2;
  width: min(280px, 38vw); aspect-ratio: 4 / 3; padding: 0;
}

/* крупно (от троих): выбранный на всё поле, остальные миниатюрами снизу */
.tiles.is-spot { display: flex; flex-wrap: wrap; justify-content: center; align-content: stretch; }
.tiles.is-spot .tile { flex: 0 1 auto; height: 22%; aspect-ratio: 16 / 9; }
.tiles.is-spot .tile.is-spot { flex: 0 0 100%; height: calc(78% - 10px); aspect-ratio: auto; order: -1; }

/* вид «собеседник крупно»: своё окно плавает поверх, как в FaceTime - можно таскать и менять размер (app.js) */
.tile--me.tile--float {
  position: absolute; z-index: 2;
  width: var(--self-w, min(260px, 30vw)); aspect-ratio: 4 / 3;
  border-color: var(--surface-3);
  touch-action: none; cursor: grab;
}
.tile--me.tile--float:active { cursor: grabbing; }
.tile--float .tile__meta { display: none; }

.tile__resize {
  display: none; position: absolute; right: 2px; bottom: 2px; width: 22px; height: 22px;
  cursor: nwse-resize; touch-action: none; z-index: 3; opacity: 0.55;
  background: linear-gradient(135deg, transparent 55%, var(--fg-dim) 55%, var(--fg-dim) 65%, transparent 65%, transparent 80%, var(--fg-dim) 80%, var(--fg-dim) 90%, transparent 90%);
}
.tile__resize:hover { opacity: 0.9; }
.tile--float .tile__resize { display: block; }

/* тап по видео прячет панель кнопок и подписи поверх окон, как в FaceTime */
.bar, .tile__meta, .tile__net, .tile__code, .tile__tool { transition: opacity var(--dur); }
.call-chrome-hidden .bar,
.call-chrome-hidden .tile__meta,
.call-chrome-hidden .tile__net,
.call-chrome-hidden .tile__code,
.call-chrome-hidden .tile__tool,
.call-chrome-hidden .tile__resize { opacity: 0; pointer-events: none; }

.split {
  position: absolute; z-index: 2; touch-action: none;
  top: 10px; bottom: 10px; width: 20px; margin-left: -10px; cursor: col-resize;
  display: grid; place-items: center;
}
.split::before {
  content: ''; width: 4px; height: 48px; border-radius: 4px;
  background: var(--fg-dim); opacity: 0.5; transition: opacity var(--dur), background var(--dur);
}
.split:hover::before, .split:active::before, .split:focus-visible::before { opacity: 1; background: var(--accent); }
.split[data-dir="v"] { top: auto; bottom: auto; left: 10px; right: 10px; width: auto; height: 20px; margin: -10px 0 0; cursor: row-resize; }
.split[data-dir="v"]::before { width: 48px; height: 4px; }

.tile {
  position: relative; overflow: hidden; min-height: 0;
  border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line);
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--surface); }
.tile.is-fit video { object-fit: contain; }
.tile--me video { transform: scaleX(-1); }
.tile--me.tile--screen video { transform: none; object-fit: contain; }
.tile__avatar { display: none; position: absolute; inset: 0; background: var(--surface); }
.tile__avatar::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px;
  border-radius: 50%; background: var(--surface-3);
}
.tile--novideo video { visibility: hidden; }
.tile--novideo .tile__avatar { display: block; }

.tile__meta {
  position: absolute; left: 10px; bottom: 10px; display: flex; gap: 8px; align-items: center; max-width: calc(100% - 20px);
  padding: 6px 12px; border-radius: 8px; background: rgba(18, 19, 22, 0.8);
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.tile__name { overflow: hidden; text-overflow: ellipsis; }
.tile__name--edit { border: 0; padding: 0; background: none; cursor: text; font-weight: 600; font-size: 13px; text-decoration: underline dotted var(--fg-dim); text-underline-offset: 3px; }
.tile__rename { width: 14ch; border: 0; border-radius: 6px; padding: 2px 6px; background: var(--surface-3); font-size: 13px; font-weight: 600; outline: none; }
.tile__you { color: var(--fg-dim); font-weight: 400; }
.tile__mute { display: none; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.tile--muted .tile__mute { display: inline-block; }
.tile__state {
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center;
  color: var(--fg-sub); font-size: 14px; text-align: center; padding: 16px;
}

/* показатель связи: сверху по центру окна собеседника, точка – зелёная, жёлтая, красная */
.tile__net {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%); margin: 0; z-index: 1;
  max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 5px 10px 5px 24px; border-radius: 8px; background: rgba(18, 19, 22, 0.8);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg-sub);
}
.tile__net::before {
  content: ''; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: var(--ok);
}
.tile__net[data-q="mid"]::before { background: var(--warn); }
.tile__net[data-q="bad"]::before { background: var(--danger); }
@media (max-width: 560px) { .tile__net { top: 52px; font-size: 11px; } }

/* сверка: по умолчанию свёрнута до слова, нажатие раскрывает шесть слов на всех окнах */
.tile__code {
  position: absolute; top: 10px; left: 10px; margin: 0; max-width: calc(100% - 110px);
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; text-align: left;
  background: rgba(18, 19, 22, 0.8); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.code__label { color: var(--fg-dim); }
.code__words { display: none; }
.codes-open .code__words { display: inline; }
.codes-open .tile__code { border-color: var(--accent); }

.tile__tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.tile__tool {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--line); background: rgba(18, 19, 22, 0.8);
  color: var(--fg); opacity: 0; transition: opacity var(--dur), background var(--dur);
}
.tile__tool:hover { background: var(--accent); }
.tile__tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile:hover .tile__tool, .tile__tool:focus-visible { opacity: 1; }
.tile.is-fit [data-act="fit"], .tile.is-spot [data-act="spot"] { background: var(--accent); opacity: 1; }
.tiles:not([data-count="3"]):not([data-count="4"]) .tile__tool--spot { display: none; }
@media (hover: none) { .tile__tool { opacity: 0.85; } }

/* ---------- ожидание собеседника ---------- */

.waiting {
  position: absolute; inset: 0 0 80px; z-index: 1;
  display: grid; place-items: center; padding: 16px;
}
.waiting__text {
  width: min(460px, 100%); display: grid; gap: 16px; justify-items: start;
  padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.waiting__hint { margin: 0; color: var(--fg-sub); font-size: 15px; }
.waiting__code { margin: 0; display: flex; align-items: baseline; gap: 14px; color: var(--fg-dim); font-size: 14px; }
.waiting__code b { color: var(--fg); font-size: 32px; font-weight: 700; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }

.chat {
  position: absolute; right: 10px; top: 10px; bottom: 88px; width: min(340px, calc(100vw - 20px)); z-index: 3;
  display: grid; grid-template-rows: 1fr auto;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.chat__log { list-style: none; margin: 0; padding: 14px; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
.msg { display: grid; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }
.msg b { font-size: 12px; color: var(--fg-dim); font-weight: 600; }
.msg--mine b { color: var(--accent-hover); }
.chat__form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.track { grid-template-rows: none; padding: 14px; overflow-y: auto; gap: 12px; align-content: start; }
.track input[type="range"] { width: 100%; }
.track__seek { display: flex; align-items: center; gap: 8px; }
.track__seek input[type="range"] { flex: 1; }
.track__seek span { font-size: 12px; color: var(--fg-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.track__lib { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.track__lib button { width: 100%; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#track-send, #track-recv { display: grid; gap: 10px; }

.status, .toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; max-width: calc(100vw - 32px); text-align: center;
  background: var(--surface-2); border: 1px solid var(--line);
}
.status { top: 14px; cursor: pointer; }
.toast { bottom: 96px; position: fixed; pointer-events: none; } /* вне звонка тоже нужен; нажатия проходят насквозь - не перекрывает кнопки */

.bar {
  grid-row: 2; position: relative; z-index: 3;
  display: flex; justify-content: center; gap: 6px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bar__btn {
  display: grid; justify-items: center; gap: 3px; min-width: 64px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  padding: 8px 10px 6px; cursor: pointer; font-size: 11px; color: var(--fg-sub);
  transition: background var(--dur), color var(--dur);
}
.bar__btn:hover { background: var(--surface-2); color: var(--fg); }
.bar__btn:disabled { opacity: 0.35; cursor: default; }
.bar__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bar__btn svg .off { display: none; }
.bar__btn[aria-pressed="true"] { color: var(--fg); }
#btn-mic[aria-pressed="true"], #btn-cam[aria-pressed="true"] { background: rgba(239, 83, 80, 0.15); color: var(--danger); }
#btn-mic[aria-pressed="true"] svg .off, #btn-cam[aria-pressed="true"] svg .off { display: inline; }
#btn-screen[aria-pressed="true"], #btn-chat[aria-pressed="true"] { background: var(--accent); color: #fff; }
#btn-self[aria-pressed="true"] { background: var(--surface-2); color: var(--fg-dim); }
.bar__btn.has-news { color: var(--ok); }
.bar__btn--leave { background: var(--danger); color: #fff; }
.bar__btn--leave:hover { background: #f26b68; color: #fff; }

@media (max-width: 820px) {
  .tiles[data-alone="true"] { width: 30vw; aspect-ratio: 3 / 4; bottom: 88px; }
  .tile--me.tile--float { aspect-ratio: 3 / 4; }
  .waiting { place-items: start stretch; }
  .waiting__code b { font-size: 26px; }
  .bar { gap: 2px; padding-left: 4px; padding-right: 4px; }
  .bar__btn { min-width: 0; flex: 1; padding: 8px 2px 6px; }
  .bar__btn span { font-size: 10px; }
  .chat { bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ================= мессенджер: мягкая тема ================= */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--glow); } 70% { box-shadow: 0 0 0 26px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* кружок с буквой: цвет свой у каждого (оттенок --h задаёт app.js по имени) */
.ava {
  --h: 250;
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, hsl(var(--h) 80% 78%), hsl(calc(var(--h) + 40) 70% 64%));
  color: #1a1c2b; font-weight: 700; font-size: 19px; line-height: 1;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.12), 0 4px 14px rgba(0, 0, 0, 0.25);
  user-select: none;
}
.ava--sm { width: 38px; height: 38px; font-size: 15px; }
.ava--xl { width: 116px; height: 116px; font-size: 44px; }

.icon-btn {
  flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); color: var(--fg-sub);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn--accent { background: var(--grad); color: #fff; box-shadow: var(--glow-shadow); }
.icon-btn--accent:hover { background: var(--grad); color: #fff; filter: brightness(1.08); }
.icon-btn--plain { background: transparent; }
.icon-btn svg, .composer svg, .voice__btn svg, .ring__btn svg, .search svg, .menu svg, .empty svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- каркас: шапка, лента, низ ---------- */

.talk {
  height: 100svh; display: grid; grid-template-rows: auto auto auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  background: var(--bg); touch-action: manipulation; position: relative;
}
.talk:not([hidden]) { animation: fade 0.25s var(--ease); }
.talk__head {
  grid-row: 1; position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.talk__title { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.talk__who {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; padding: 2px; border-radius: var(--radius-sm);
}
.talk__names { min-width: 0; display: grid; }
.talk__names b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.talk__me { font-size: 12.5px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.talk__me, .link-btn { border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--fg-dim); text-align: left; }
.me-btn { border: 0; padding: 0; background: transparent; cursor: pointer; border-radius: 50%; }
.me-btn .ava { width: 40px; height: 40px; font-size: 16px; }

.talk > .push { grid-row: 3; }
.push {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px;
  border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, #9a82ff 16%, var(--surface)), color-mix(in srgb, #6f9bff 12%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.push__text { flex: 1; margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--fg-sub); }
.push__skip { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--fg-dim); font-size: 20px; line-height: 1; cursor: pointer; }
.push__skip:hover { background: var(--surface-3); color: var(--fg); }
.talk > .push { margin: 12px 14px 0; padding: 12px 12px 12px 16px; }
.lobby .push { margin: 0; }

.talk__empty {
  grid-row: 4; grid-column: 1; align-self: center; justify-self: center;
  margin: 0; padding: 32px; max-width: 360px; color: var(--fg-dim); text-align: center; font-size: 14.5px; line-height: 1.55;
}
.empty { display: grid; justify-items: center; gap: 14px; }
.empty svg { width: 44px; height: 44px; stroke-width: 1.4; color: var(--accent); opacity: 0.8; }

/* ---------- список переписок ---------- */

.chats { grid-template-rows: auto auto auto 1fr; }
.chats > .push { grid-row: 2; }
.search {
  grid-row: 3; margin: 10px 14px 4px; position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 14px; color: var(--fg-dim); pointer-events: none; }
.search .field__input { padding-left: 44px; border-radius: 999px; background: var(--surface); }
.search button { display: none; }
.chats__list {
  grid-row: 4; grid-column: 1; list-style: none; margin: 0; padding: 6px 8px calc(16px + env(safe-area-inset-bottom));
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.chats__list li { display: flex; }
.chats__list li:not([hidden]) { animation: rise 0.3s var(--ease) both; }
.contact__open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 10px; border: 0; border-radius: 18px; background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.contact__open:hover { background: var(--surface); }
.contact__open:active { transform: scale(0.985); }
.contact__open.is-active { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.contact__main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.contact__top, .contact__bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.contact__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 15.5px; }
.contact__time { font-size: 12px; color: var(--fg-dim); flex: none; }
.contact__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--fg-sub); }
.contact__text i { font-style: normal; color: var(--accent-hover); }
.contact__count {
  flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  display: grid; place-items: center; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
  box-shadow: var(--glow-shadow);
}
.chats > .talk__empty { grid-row: 4; }

/* меню «+» */
.menu {
  position: absolute; top: calc(62px + env(safe-area-inset-top)); right: 14px; z-index: 9;
  min-width: 240px; padding: 8px; display: grid; gap: 2px;
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  transform-origin: top right;
}
.menu:not([hidden]) { animation: pop 0.2s var(--ease); }
.menu button {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-radius: 14px;
  background: transparent; color: var(--fg); font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.menu button:hover { background: var(--surface-3); }
.menu svg { color: var(--accent-hover); }

/* ---------- лента сообщений ---------- */

.talk__log {
  grid-row: 4; grid-column: 1; list-style: none; margin: 0; padding: 14px 12px 18px; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain;
}
.bubble {
  max-width: min(78%, 540px); align-self: flex-start; position: relative;
  padding: 9px 14px 7px; border-radius: 20px 20px 20px 6px;
  background: var(--surface-2); overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.42;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  margin-top: 6px;
}
.bubble--mine {
  align-self: flex-end; border-radius: 20px 20px 6px 20px;
  background: var(--grad); color: #fff;
}
/* подряд от одного человека - слипаются, углы у «хвоста» мягче */
.bubble--cont { margin-top: 0; }
.bubble--more { border-bottom-left-radius: 20px; }
.bubble--mine.bubble--more { border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; }
.bubble--cont:not(.bubble--mine) { border-top-left-radius: 8px; }
.bubble--cont.bubble--mine { border-top-right-radius: 8px; }
.bubble--new { animation: pop 0.28s var(--ease); }
.bubble img { display: block; max-width: 100%; height: auto; max-height: 60svh; border-radius: 14px; margin: 3px -8px 2px; cursor: zoom-in; }
.bubble img.is-full {
  position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; max-height: none; margin: 0;
  object-fit: contain; background: rgba(0, 0, 0, 0.94); border-radius: 0; cursor: zoom-out; animation: fade 0.2s;
}
.bubble audio { display: none; }
.bubble__time { display: block; margin-top: 1px; font-size: 11px; opacity: 0.55; text-align: right; font-variant-numeric: tabular-nums; }
.bubble__who { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 1px; color: hsl(var(--h, 250) 80% 76%); }
.bubble__day {
  align-self: center; margin: 14px 0 6px; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; color: var(--fg-sub); background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.bubble__warn { color: var(--warn); max-width: 90%; text-align: center; border-radius: 14px; }
.bubble--call { display: grid; gap: 8px; }
.bubble--call .call-line { display: flex; align-items: center; gap: 8px; }
.bubble--call svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bubble__join { background: var(--ok); color: #0b2018; border-radius: 999px; }

/* голосовое: своя кнопка, полоска, время */
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice__btn {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--grad); color: #fff; transition: transform var(--dur) var(--ease);
}
.bubble--mine .voice__btn { background: rgba(255, 255, 255, 0.95); color: var(--accent); }
.voice__btn:active { transform: scale(0.9); }
.voice__btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.voice__bar { flex: 1; height: 6px; border-radius: 3px; background: color-mix(in srgb, currentColor 22%, transparent); cursor: pointer; position: relative; }
.voice__fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: currentColor; opacity: 0.85; }
.voice__time { font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums; min-width: 32px; }

/* ---------- поле ввода ---------- */

.composer {
  grid-row: 5; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.composer__field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px;
  background: var(--surface-2); border-radius: 24px; padding: 3px;
  border: 1px solid transparent; transition: border-color var(--dur) var(--ease);
}
.composer__field:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.composer__field .field__input { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 0; }
.composer .icon-btn--plain { width: 40px; height: 40px; }
.composer [hidden] { display: none !important; }
#talk-send:not([hidden]), #talk-voice:not([hidden]) { animation: pop 0.18s var(--ease); }
.talk__rec { align-items: center; }
.talk__rec #talk-rec-time { flex: 1; font-variant-numeric: tabular-nums; }
.talk__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }

/* ---------- сведения о переписке и группа: всплывающий лист снизу ---------- */

.sheet { position: fixed; inset: 0; z-index: 8; background: rgba(6, 7, 12, 0.55); display: grid; place-items: end center; animation: fade 0.2s; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet__panel {
  width: min(540px, 100%); max-height: 88svh; overflow-y: auto; display: grid; gap: 14px;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow);
  animation: rise 0.3s var(--ease);
}
.sheet__panel::before { content: ''; justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__title { margin: 0; font-size: 19px; }
.info__members { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.info__members li { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.info__members div span { color: var(--fg-sub); font-size: 14px; }
.info__words { grid-column: 2; margin: 2px 0 0; font-size: 13px; color: var(--accent-hover); }
.info__group { display: grid; gap: 10px; }

/* ---------- входящий звонок ---------- */

.ring {
  position: fixed; inset: 0; z-index: 20; display: grid; align-content: center; justify-items: center; gap: 8px;
  padding: 24px; text-align: center; animation: fade 0.3s;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 35%, var(--bg)), var(--bg) 70%);
}
.ring .ava--xl { --glow: color-mix(in srgb, var(--accent) 45%, transparent); animation: pulse 1.8s infinite; margin-bottom: 18px; }
.ring__who { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.ring__sub { margin: 0 0 56px; color: var(--fg-sub); animation: blink 1.6s infinite; }
.ring__btns { display: flex; gap: 72px; }
.ring__btn { display: grid; justify-items: center; gap: 10px; border: 0; background: transparent; color: var(--fg-sub); font: inherit; font-size: 13px; cursor: pointer; }
.ring__btn span:first-child {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  transition: transform var(--dur) var(--ease);
}
.ring__btn:active span:first-child { transform: scale(0.9); }
.ring__btn svg { width: 30px; height: 30px; fill: currentColor; stroke: none; }
.ring__no span:first-child { background: var(--danger); box-shadow: 0 8px 28px color-mix(in srgb, var(--danger) 45%, transparent); }
.ring__no svg { transform: rotate(135deg); }
.ring__yes span:first-child { background: var(--ok); box-shadow: 0 8px 28px color-mix(in srgb, var(--ok) 45%, transparent); }

/* ---------- вход, регистрация, настройки ---------- */

.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; color: #fff;
  background: var(--grad); box-shadow: var(--glow-shadow);
}
.brand__mark svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.paste { margin-top: 12px; }
.settings__back { justify-self: start; }

/* ---------- компьютер: список слева, переписка справа ---------- */

#pane-empty { display: none; }
@media (min-width: 900px) {
  body.two-pane #chats { position: fixed; inset: 0 auto 0 0; width: 380px; border-right: 1px solid var(--line); animation: none; }
  body.two-pane #talk { margin-left: 380px; animation: none; }
  body.two-pane #talk-back, body.two-pane #talk > .push { display: none !important; }
  body.two-pane #pane-empty:not([hidden]) {
    display: grid; place-items: center; margin-left: 380px; height: 100svh; color: var(--fg-dim); text-align: center;
  }
  .talk__log { padding-left: 8%; padding-right: 8%; }
  .menu { top: 62px; }
}
@media (max-width: 899px) { #pane-empty { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.brand .lobby__sub { margin: 0; }
