/* duo-chat — Telegram Dark, mobile-first */

:root {
  --bg: #0e1621;
  --panel: #17212b;
  --panel2: #242f3d;
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --text: #f5f5f5;
  --text2: #708499;
  --accent: #5288c1;
  --link: #6ab3f3;
  --check: #71bbe7;
  --online: #4dcd5e;
  --danger: #e05a4f;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Аватары ---------- */

.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
}
.av-40 { width: 40px; height: 40px; font-size: 17px; }
.av-64 { width: 64px; height: 64px; font-size: 26px; }
.av-yura  { background: linear-gradient(135deg, #e17076, #c94f5e); }
.av-amina { background: linear-gradient(135deg, #7bc862, #5fb389); }
.av-x     { background: linear-gradient(135deg, #7f91a4, #566a7e); }

/* ---------- Экран входа ---------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px env(safe-area-inset-right) calc(24px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
.login-box {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-logo { width: 88px; height: 88px; border-radius: 22px; margin-bottom: 16px; }
.login-title { font-size: 24px; font-weight: 600; margin-bottom: 28px; }
.login-users { display: flex; gap: 16px; width: 100%; justify-content: center; }
.login-user {
  flex: 1;
  max-width: 156px;
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 500;
  transition: background .15s, transform .1s;
}
.login-user:active { transform: scale(.96); }
@media (hover: hover) { .login-user:hover { background: var(--panel2); } }

.login-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.login-selected { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; margin-bottom: 6px; }
.login-pass {
  width: 100%;
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
.login-pass:focus { border-color: var(--accent); }
.login-pass.shake { animation: shake .45s; border-color: var(--danger); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-8px); }
  30%, 60%, 90% { transform: translateX(8px); }
}
.login-submit {
  width: 100%;
  background: var(--accent);
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  transition: filter .15s;
}
.login-submit:active { filter: brightness(.85); }
.login-error { color: var(--danger); font-size: 14px; min-height: 18px; text-align: center; }
.login-back { color: var(--text2); font-size: 15px; padding: 6px; }

/* ---------- Каркас приложения ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--vvh, 100dvh);
  overflow: hidden;
  position: relative;
}

/* ---------- Шапка ---------- */

.header {
  background: var(--panel);
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
  z-index: 30;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  position: relative;
}
.header-main, .header-search {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 6px 0 10px;
  gap: 10px;
}
.header-main { cursor: default; }
.header-info { flex: 1; min-width: 0; }
.header-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-status.st-online { color: var(--accent); }
.header-status.st-typing { color: var(--accent); }

.tdot {
  display: inline-block;
  animation: tdotBlink 1.2s infinite;
}
.tdot.td1 { animation-delay: .2s; }
.tdot.td2 { animation-delay: .4s; }
@keyframes tdotBlink {
  0%, 60%, 100% { opacity: .25; }
  30% { opacity: 1; }
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text2);
  flex-shrink: 0;
  transition: background .15s;
}
.icon-btn:active { background: rgba(255,255,255,.06); }

.search-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  height: 100%;
}
.search-input::placeholder { color: var(--text2); }

/* ---------- Меню ⋮ ---------- */

.menu {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 52px);
  right: 8px;
  background: rgba(29,40,52,.92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-radius: 12px;
  padding: 6px 0;
  min-width: 210px;
  z-index: 60;
  box-shadow: 0 6px 28px rgba(0,0,0,.5);
  animation: popIn .13s ease-out;
  transform-origin: top right;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.menu-item svg { color: var(--text2); flex-shrink: 0; }
.menu-item:active { background: rgba(255,255,255,.06); }
.menu-danger, .menu-danger svg { color: var(--danger); }

/* ---------- Результаты поиска ---------- */

.search-results {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 56px);
  left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 40;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  color: var(--text);
}
.sr-item:active { background: var(--panel); }
.sr-body { flex: 1; min-width: 0; }
.sr-top { display: flex; justify-content: space-between; gap: 8px; }
.sr-name { font-size: 15px; font-weight: 600; }
.sr-date { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.sr-snippet { font-size: 14px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-empty { padding: 28px 16px; text-align: center; color: var(--text2); font-size: 14px; }

/* ---------- Пуш-баннер ---------- */

.push-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  padding: 8px 8px 8px 14px;
  flex-shrink: 0;
  z-index: 25;
}
.push-banner-text { flex: 1; font-size: 14px; }
.push-banner-yes {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
}
.push-banner-no {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
}

/* ---------- Лента ---------- */

.feed {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: 8px 12px 10px;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.04' stroke-width='2'%3E%3Ccircle cx='30' cy='34' r='6'/%3E%3Cpath d='M92 22c5-8 17-6 18 3 1 7-9 12-9 12s-10-7-9-15z'/%3E%3Crect x='170' y='30' width='14' height='14' rx='4' transform='rotate(18 177 37)'/%3E%3Cpath d='M40 110l8 8m0-8l-8 8'/%3E%3Ccircle cx='130' cy='96' r='8'/%3E%3Cpath d='M196 100c5-8 17-6 18 3 1 7-9 12-9 12s-10-7-9-15z'/%3E%3Cpath d='M24 176c4-6 13-5 14 2 1 6-7 10-7 10s-8-6-7-12z'/%3E%3Ccircle cx='104' cy='182' r='5'/%3E%3Crect x='158' y='168' width='12' height='12' rx='3' transform='rotate(-14 164 174)'/%3E%3Cpath d='M212 190l8 8m0-8l-8 8'/%3E%3Ccircle cx='66' cy='64' r='3'/%3E%3Ccircle cx='222' cy='64' r='3'/%3E%3Ccircle cx='150' cy='140' r='3'/%3E%3Ccircle cx='60' cy='224' r='3'/%3E%3C/g%3E%3C/svg%3E");
  scrollbar-width: thin;
  scrollbar-color: var(--panel2) transparent;
}
.feed::-webkit-scrollbar { width: 5px; }
.feed::-webkit-scrollbar-thumb { background: var(--panel2); border-radius: 3px; }

.feed-spacer { flex: 1 0 auto; }

/* Чип даты */
.date-chip {
  align-self: center;
  position: sticky;
  top: 6px;
  z-index: 5;
  background: rgba(14,22,33,.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 10px 0 4px;
  user-select: none;
}

/* Разделитель непрочитанных */
.unread-divider {
  align-self: stretch;
  text-align: center;
  background: rgba(36,47,61,.7);
  border-radius: 8px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 0;
  margin: 10px 0 4px;
  user-select: none;
}

/* ---------- Пузыри ---------- */

.row {
  display: flex;
  margin-top: 7px;
  position: relative;
  touch-action: pan-y;
}
/* GPU-слой только на время свайпа-ответа: статичный will-change на сотнях
   строк = сотни композитных слоёв и jank/выгрузка вкладки на iPhone */
.row.swiping { will-change: transform; }
.row.grp { margin-top: 2px; }
.row.out { justify-content: flex-end; }
.row.appear { animation: msgIn .18s ease-out; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.row.flash::before {
  content: "";
  position: absolute;
  inset: -3px -12px;
  background: rgba(82,136,193,.28);
  border-radius: 8px;
  animation: flashFade 1.4s ease-out forwards;
  pointer-events: none;
}
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }

.bubble {
  position: relative;
  max-width: min(80%, 480px);
  background: var(--bubble-in);
  border-radius: var(--radius);
  padding: 6px 10px 7px;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: 0 1px 1px rgba(0,0,0,.25);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  word-break: break-word;
}
.out .bubble { background: var(--bubble-out); }

/* Хвостики (только у последнего в группе) */
.row.tail .bubble::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 10px;
  height: 18px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 18'%3E%3Cpath d='M0 0v7.5c0 4.6 3.2 8.4 10 10.5-5.8-.2-8.8-4.7-10-18z' fill='%23000'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 18'%3E%3Cpath d='M0 0v7.5c0 4.6 3.2 8.4 10 10.5-5.8-.2-8.8-4.7-10-18z' fill='%23000'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.row.tail.in .bubble::after { left: -9px; background: var(--bubble-in); transform: scaleX(-1); }
.row.tail.out .bubble::after { right: -9px; background: var(--bubble-out); }
.row.tail.in .bubble { border-bottom-left-radius: 4px; }
.row.tail.out .bubble { border-bottom-right-radius: 4px; }

/* Текст */
.txt { white-space: pre-wrap; }
.txt::after { content: ""; display: table; clear: both; }
.txt a, .msg-link { color: var(--link); text-decoration: none; -webkit-user-select: text; user-select: text; }
.txt a:active { text-decoration: underline; }

/* Мета (время + галочки) */
.meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 6px -2px -4px 8px;
  font-size: 11.5px;
  color: var(--text2);
  line-height: 1;
  user-select: none;
  position: relative;
  top: 4px;
}
.out .meta { color: rgba(255,255,255,.55); }
.meta .edited { font-style: normal; margin-right: 2px; }
.ticks { display: inline-flex; align-items: center; letter-spacing: -3px; font-size: 13px; }
.ticks.t-pending { font-size: 11px; letter-spacing: 0; }
.ticks.t-read { color: var(--check); }
.ticks.t-fail { color: var(--danger); letter-spacing: 0; font-weight: 700; font-size: 12px; }
.row.failed .bubble { outline: 1px solid rgba(224,90,79,.5); }

/* Мета поверх фото/видео */
.bubble.media { padding: 3px; }
.bubble.media .meta {
  float: none;
  position: absolute;
  right: 8px;
  bottom: 8px;
  top: auto;
  margin: 0;
  background: rgba(0,0,0,.45);
  border-radius: 10px;
  padding: 3px 7px;
  color: #fff;
  z-index: 2;
}
.bubble.media .meta.meta-top { top: 8px; bottom: auto; }
.bubble.media .quote { margin: 4px 7px 6px; }

/* Строка меты для голосовых/файлов */
.meta-line { display: flex; justify-content: flex-end; }
.meta-line .meta { float: none; top: 0; margin: 3px 0 -2px; }

/* Цитата reply */
.quote {
  display: block;
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  padding: 2px 8px 3px;
  margin-bottom: 4px;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.quote-name { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out .quote-name { color: #9ec4ea; }
.out .quote { border-left-color: #9ec4ea; }
.quote-snippet { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out .quote-snippet { color: rgba(255,255,255,.6); }

/* Фото */
.photo-wrap {
  position: relative;
  display: block;
  border-radius: 9px;
  overflow: hidden;
  max-width: 100%;
  background: var(--panel2);
  cursor: pointer;
}
.photo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: cover;
}

/* Видео */
.video-wrap { position: relative; border-radius: 9px; overflow: hidden; max-width: 100%; background: #000; min-width: 220px; }
.video-wrap video { display: block; width: 100%; max-height: 320px; }

/* Прелоадер аплоада */
.up-ov {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border-radius: 9px;
}
.up-circ {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  animation: spin 1.1s linear infinite;
}
.up-circ span { animation: spinBack 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinBack { to { transform: rotate(-360deg); } }

/* Голосовое */
.voice { display: flex; align-items: center; gap: 10px; padding: 3px 2px 2px; min-width: 190px; }
.voice-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.out .voice-btn { background: #7bacd4; }
.voice-btn:active { filter: brightness(.85); }
.voice-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wave { display: flex; align-items: center; gap: 2px; height: 26px; cursor: pointer; }
.wave i {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.35);
  min-height: 4px;
  transition: background .1s;
}
.in .wave i { background: rgba(112,132,153,.55); }
.wave i.on { background: #fff; }
.in .wave i.on { background: var(--accent); }
.voice-dur { font-size: 12.5px; color: var(--text2); }
.out .voice-dur { color: rgba(255,255,255,.6); }

/* Файл */
.filebox { display: flex; align-items: center; gap: 10px; padding: 3px 2px 2px; min-width: 180px; cursor: pointer; }
.file-ic {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.out .file-ic { background: #7bacd4; }
.file-body { min-width: 0; }
.file-name { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-size { font-size: 12.5px; color: var(--text2); }
.out .file-size { color: rgba(255,255,255,.6); }

/* Реакции */
.reacts { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.react-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,.09);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  animation: popIn .15s ease-out;
}
.react-chip.mine { background: rgba(82,136,193,.55); }
.react-chip b { font-size: 12px; font-weight: 600; color: var(--text); }

/* ---------- FAB ---------- */

.fab {
  position: absolute;
  right: 12px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--panel2);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  z-index: 20;
  animation: popIn .15s ease-out;
}
.fab-badge {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Панель ввода ---------- */

.composer {
  background: var(--panel);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
  position: relative;
  z-index: 25;
  box-shadow: 0 -1px 2px rgba(0,0,0,.3);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  padding: 6px 4px;
  gap: 0;
}
.comp-btn { color: var(--text2); margin-bottom: 1px; }
.input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 22px;
  max-height: 134px;
  padding: 10px 2px;
  overflow-y: auto;
  scrollbar-width: none;
}
.input::-webkit-scrollbar { display: none; }
.input::placeholder { color: var(--text2); }

.send-btn {
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text2);
  flex-shrink: 0;
  margin: 0 2px 0 0;
  transition: color .15s, transform .12s;
}
.send-btn .ic-send { display: none; color: var(--accent); }
.send-btn.mode-send .ic-send { display: block; animation: popIn .12s ease-out; }
.send-btn.mode-send .ic-mic { display: none; }
.send-btn:active { transform: scale(.9); }
.send-btn.rec-armed { color: #fff; background: var(--danger); }

/* Reply/edit бар */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px 0 12px;
}
.reply-bar-icon { color: var(--accent); flex-shrink: 0; }
.reply-bar-body {
  flex: 1;
  min-width: 0;
  border-left: 2px solid var(--accent);
  padding-left: 9px;
}
.reply-bar-title { font-size: 13.5px; font-weight: 600; color: var(--accent); }
.reply-bar-snippet { font-size: 13.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Запись голосового */
.record-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px 9px 16px;
  min-height: 58px;
}
.rec-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: recPulse 1.1s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}
.rec-timer { font-size: 16px; font-variant-numeric: tabular-nums; flex: 1; }
.rec-cancel { color: var(--danger); font-size: 15px; font-weight: 500; padding: 8px 12px; }
.rec-stop {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Попапы (скрепка, эмодзи) ---------- */

.popup {
  position: absolute;
  bottom: calc(100% + 6px);
  background: rgba(29,40,52,.95);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-radius: 14px;
  box-shadow: 0 6px 28px rgba(0,0,0,.5);
  z-index: 50;
  animation: popIn .13s ease-out;
}
.attach-popup { left: 8px; transform-origin: bottom left; padding: 6px 0; min-width: 190px; }
.popup-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.popup-item svg { color: var(--text2); }
.popup-item:active { background: rgba(255,255,255,.06); }

.emoji-popup {
  right: 8px;
  transform-origin: bottom right;
  display: grid;
  grid-template-columns: repeat(8, 40px);
  padding: 8px;
  max-width: calc(100vw - 16px);
}
.emoji-cell {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 8px;
}
.emoji-cell:active { background: rgba(255,255,255,.08); }
@media (max-width: 380px) { .emoji-popup { grid-template-columns: repeat(6, 40px); } }

/* ---------- Контекстное меню ---------- */

.ctx-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
}
.ctx {
  position: fixed;
  z-index: 95;
  background: rgba(29,40,52,.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  min-width: 200px;
  overflow: hidden;
  animation: popIn .14s ease-out;
}
.ctx-reacts {
  display: flex;
  gap: 2px;
  padding: 8px 10px 6px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.ctx-react {
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 50%;
  transition: transform .12s;
}
.ctx-react:active { transform: scale(1.3); }
.ctx-react.mine { background: rgba(82,136,193,.4); }
.ctx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.ctx-item svg { color: var(--text2); flex-shrink: 0; }
.ctx-item:active { background: rgba(255,255,255,.06); }
.ctx-item.danger, .ctx-item.danger svg { color: var(--danger); }

/* ---------- Просмотр фото ---------- */

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.94);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.viewer-top {
  position: absolute;
  top: env(safe-area-inset-top);
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.viewer-btn { color: #fff; width: 48px; height: 48px; }
.viewer-img {
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  object-fit: contain;
}

/* ---------- Кружки (видеосообщения) ---------- */

/* Пузырь-кружок: без обычной подложки, просто круг на фоне чата */
.bubble.bubble-round {
  background: none;
  box-shadow: none;
  padding: 0;
  max-width: none;
}
.row.tail .bubble-round::after { display: none; }
.bubble-round .quote {
  background: rgba(23,33,43,.92);
  border-radius: 8px;
  margin: 0 0 6px;
}
.round-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  cursor: pointer;
}
@media (max-width: 379px) { .round-wrap { width: 200px; height: 200px; } }
.round-wrap video {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  border-radius: 50%;
  object-fit: cover;
  background: #000;
}
.round-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.round-ring circle {
  fill: none;
  stroke: rgba(255,255,255,.85);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.round-play {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0,0,0,.16);
}
.round-play svg { width: 48px; height: 48px; filter: drop-shadow(0 1px 5px rgba(0,0,0,.55)); }
.round-wrap.playing .round-play { display: none; }
.round-dur {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  background: rgba(0,0,0,.45);
  color: #fff;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  z-index: 2;
  pointer-events: none;
}
.bubble-round .meta.meta-round {
  float: none;
  position: absolute;
  right: 0;
  bottom: 4px;
  top: auto;
  margin: 0;
  background: rgba(0,0,0,.5);
  border-radius: 10px;
  padding: 3px 7px;
  color: #fff;
  z-index: 2;
}
.bubble-round .up-ov { inset: 6px; border-radius: 50%; }
.bubble-round .reacts { justify-content: center; margin-top: 6px; }

/* Оверлей записи кружка */
.round-ov {
  position: fixed;
  inset: 0;
  background: rgba(8,13,20,.96);
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s ease-out;
}
.round-ov-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-bottom: env(safe-area-inset-bottom);
}
.round-prev-wrap {
  width: min(78vw, 320px);
  height: min(78vw, 320px);
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  animation: roundRecPulse 1.2s ease-in-out infinite;
}
@keyframes roundRecPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(224,90,79,.7), 0 10px 50px rgba(0,0,0,.6); }
  50%      { box-shadow: 0 0 0 8px rgba(224,90,79,.25), 0 10px 50px rgba(0,0,0,.6); }
}
.round-prev-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* селфи-зеркало */
}
.round-ov-row { display: flex; align-items: center; gap: 10px; }
.round-timer { flex: none; font-size: 18px; }
.round-ov-btns { display: flex; align-items: center; gap: 30px; }
.rec-stop-big { width: 56px; height: 56px; }

/* Иконка камеры в кнопке отправки (режим кружка) */
.send-btn .ic-cam { display: none; }
.send-btn.mode-mic.cam-mode .ic-cam { display: block; }
.send-btn.mode-mic.cam-mode .ic-mic { display: none; }
.send-btn.mode-send .ic-cam { display: none; }

/* ---------- Сообщение «звонок» в ленте ---------- */

.callmsg { display: flex; align-items: center; gap: 10px; padding: 3px 2px 2px; min-width: 190px; cursor: pointer; }
.callmsg-ic {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.out .callmsg-ic { background: #7bacd4; }
.callmsg-ic.bad { background: var(--danger); }
.callmsg-title { font-size: 14.5px; font-weight: 500; }
.callmsg-sub { font-size: 12.5px; color: var(--text2); }
.out .callmsg-sub { color: rgba(255,255,255,.6); }

/* ---------- Экран звонка ---------- */

.call {
  position: fixed;
  inset: 0;
  z-index: 115;
  background: #0b1119;
  animation: fadeIn .15s ease-out;
}
.call-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b1119;
  visibility: hidden;
}
.call.has-video .call-remote { visibility: visible; }
.call-avatar-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 32%, #1d2a3a 0%, #0b1119 72%);
}
.call.has-video .call-avatar-wrap { display: none; }
.av-96 { width: 96px; height: 96px; font-size: 38px; }
.call-top {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 20px);
  left: 0; right: 0;
  text-align: center;
  z-index: 5;
  text-shadow: 0 1px 5px rgba(0,0,0,.65);
  pointer-events: none;
}
.call-name { font-size: 22px; font-weight: 600; color: #fff; }
.call-status { font-size: 14px; color: rgba(255,255,255,.78); margin-top: 4px; font-variant-numeric: tabular-nums; }
.call-pip {
  position: absolute;
  right: 12px;
  top: calc(env(safe-area-inset-top) + 88px);
  width: 96px;
  height: 128px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  z-index: 6;
}
.call-pip video { width: 100%; height: 100%; object-fit: cover; }
.call-pip.mirror video { transform: scaleX(-1); }
.call-pip-off {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
}
.call-controls {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  display: flex;
  justify-content: center;
  z-index: 6;
}
.call-btnrow { display: flex; align-items: center; gap: 18px; }
.call-in-row { gap: 64px; }
.call-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.call-btn:active { transform: scale(.92); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn .ic-off { display: none; }
.call-btn.off { background: rgba(255,255,255,.88); color: #0b1119; }
.call-btn.off .ic-on { display: none; }
.call-btn.off .ic-off { display: block; }
.call-btn.danger { background: var(--danger); }
.call-btn.green { background: var(--online); }
.call-btn-big { width: 68px; height: 68px; }
.call-btn-big svg { width: 30px; height: 30px; }
#callInBtns .green { animation: acceptPulse 1.3s ease-in-out infinite; }
@keyframes acceptPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77,205,94,.5); }
  60%      { box-shadow: 0 0 0 14px rgba(77,205,94,0); }
}

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(29,40,52,.95);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 120;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: popIn .15s ease-out;
}

/* ---------- Десктоп ---------- */

@media (min-width: 700px) {
  .app { max-width: 720px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .icon-btn, .menu-item, .popup-item, .ctx-item, .sr-item, .react-chip, .fab, .login-user {
    transition: background .15s;
  }
  .icon-btn:hover { background: rgba(255,255,255,.06); }
  .menu-item:hover, .popup-item:hover, .ctx-item:hover, .sr-item:hover { background: rgba(255,255,255,.06); }
  .fab:hover { color: var(--text); }
  .ctx-react:hover { transform: scale(1.25); }
  .emoji-cell:hover { background: rgba(255,255,255,.08); }
}
