/* Светлая тема — мягкий серо-голубой «утренний туман»: не белый лист,
   а спокойный холодный фон, как пара к тёмной серо-синей (слово Олега 29.11). */
:root {
  --bg: #e8edf4;
  --panel: #fbfcfe;
  --panel-2: #e2e8f0;
  --text: #17202d;
  --muted: #5e6b7e;
  --line: rgba(23, 32, 45, .10);
  --accent: #2c7ed3;
  --accent-2: #1f66b2;
  --accent-soft: rgba(44, 126, 211, .13);
  --bubble-in: #ffffff;
  --bubble-in-text: #17202d;
  --bubble-out: linear-gradient(135deg, #4b9ae2, #2c6db8);
  --bubble-out-text: #ffffff;
  --danger: #c84343;
  --shadow: 0 14px 40px rgba(30, 45, 70, .14);
  --chat-bg: radial-gradient(1200px 600px at 12% 0%, rgba(44,126,211,.09), transparent 60%),
             radial-gradient(900px 500px at 100% 100%, rgba(110,120,150,.08), transparent 55%),
             var(--bg);
  --radius: 16px;
  color-scheme: light;
}

/* Тёмная тема — серая с тёмно-синим и светлыми акцентами (слово Олега 29.11).
   Включается атрибутом data-theme="dark" на <html>; по умолчанию тёмная. */
:root[data-theme="dark"] {
  --bg: #1a2130;
  --panel: #232b3b;
  --panel-2: #2b3547;
  --text: #e9eef6;
  --muted: #a2afc2;
  --line: rgba(255, 255, 255, .09);
  --accent: #8cc5ff;
  --accent-2: #69a9e8;
  --accent-soft: rgba(140, 197, 255, .16);
  --bubble-in: #2a3444;
  --bubble-in-text: #eaf0f8;
  --bubble-out: linear-gradient(135deg, #5b93d6, #3e6ea8);
  --bubble-out-text: #ffffff;
  --danger: #ff7a7a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .38);
  --chat-bg: radial-gradient(1000px 600px at 0% 0%, rgba(140,197,255,.11), transparent 60%),
             radial-gradient(800px 500px at 100% 100%, rgba(160,170,190,.09), transparent 55%),
             var(--bg);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.name { font-weight: 600; }

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------ вход */

.auth {
  position: relative;
  min-height: calc(100dvh - var(--kb-h, 0px));
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 24px max(24px, env(safe-area-inset-bottom));
  background: var(--bg);
  overflow: auto;
}

/* Когда открыта экранная клавиатура, экран входа прижимается кверху:
   иначе поле PIN уезжает под клавиатуру и тап попадает в «Имя». */
@media (max-height: 700px) {
  .auth { justify-content: flex-start; padding-top: 14px; }
}
.input { scroll-margin: 110px 0 140px; }

.auth-glow {
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(600px 400px at 25% 20%, rgba(47, 149, 232, .20), transparent 65%),
    radial-gradient(500px 400px at 80% 75%, rgba(120, 100, 255, .16), transparent 65%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.auth-card h1 {
  margin: 14px 0 4px;
  font-size: 28px;
  letter-spacing: -.02em;
}

.auth-card .muted { margin: 0 0 22px; font-size: 14px; }

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #42b4ff, #1f7fd0);
  box-shadow: 0 10px 24px rgba(47, 149, 232, .35);
}

.brand-mark.small {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  font-size: 16px;
  box-shadow: none;
}

img.brand-mark {
  object-fit: cover;
  background: none;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  margin: 12px 2px 6px;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 13px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  /* Поля должны выделяться и копироваться пальцем: Олег 01.12.2026 —
     «не могу ни открыть ссылку, ни скопировать». */
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  margin-top: 20px;
  border: 0;
  border-radius: 13px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #34a0f0, #1f7fd0);
  box-shadow: 0 8px 22px rgba(47, 149, 232, .30);
  transition: transform .1s, filter .15s;
}

.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { filter: grayscale(.5) brightness(.9); }

.auth-err {
  min-height: 18px;
  margin: 12px 2px 0;
  font-size: 13px;
  color: var(--danger);
}

.link-btn {
  position: relative;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  padding: 6px 10px;
}

/* ------------------------------------------------------------ каркас */

.app {
  display: flex;
  height: 100dvh;
  /* Клавиатура на iPhone не уменьшает 100dvh — окно уходило под неё
     (жалоба Эллины 30.11.2026). --kb-h считает app.js по visualViewport. */
  height: calc(100dvh - var(--kb-h, 0px));
  overflow: hidden;
}

.side {
  position: relative;
  flex: 0 0 360px;
  width: 360px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}

.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* Переключатель темы на экране входа — виден до входа в аккаунт. */
.theme-float {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 6;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(20, 30, 45, .10);
}

.search-wrap {
  position: relative;
  margin: 8px 12px 10px;
}

.search-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--panel-2);
  padding: 10px 12px 10px 40px;
  font-size: 15px;
  outline: none;
}

.search::placeholder { color: var(--muted); }
.search:focus { box-shadow: 0 0 0 2px var(--accent-soft); }

.dialogs {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 12px;
  min-height: 0;
}

.side.searching .dialogs { display: none; }

.dialog {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  transition: background .12s;
}

.dialog:hover { background: var(--panel-2); }
.dialog.active { background: var(--accent-soft); }

.dialog-main {
  flex: 1;
  min-width: 0;
}

.dialog-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.dialog-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-time { font-size: 12px; color: var(--muted); flex: 0 0 auto; }

.dialog-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.dialog-preview {
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.search-results {
  padding: 0 8px 10px;
  overflow-y: auto;
  max-height: 45%;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.search-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 10px 6px;
}

.person {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
}

.person:hover { background: var(--panel-2); }

/* Заявки в контакты */
.requests {
  padding: 0 8px 8px;
  overflow-y: auto;
  max-height: 42%;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.req {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--panel-2);
  margin: 0 2px 6px;
}
.req-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.req-text .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.req-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.req-btn.ok { background: #2e7d5b; color: #fff; }
.req-btn.no { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.side-me {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.side-me-text { display: flex; flex-direction: column; line-height: 1.25; }

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

.avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  user-select: none;
  letter-spacing: .01em;
}

.av-0 { background: linear-gradient(135deg, #ff9a62, #f06292); }
.av-1 { background: linear-gradient(135deg, #56c3ff, #2f7cf0); }
.av-2 { background: linear-gradient(135deg, #7be0a4, #2fae76); }
.av-3 { background: linear-gradient(135deg, #c49bff, #7a5af0); }
.av-4 { background: linear-gradient(135deg, #ffd36e, #f39c2a); }
.av-5 { background: linear-gradient(135deg, #66d9d0, #259d94); }
.av-6 { background: linear-gradient(135deg, #ff9fb8, #e05580); }
.av-7 { background: linear-gradient(135deg, #9fb4ff, #5a74e8); }

/* ------------------------------------------------------------ чат */

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--chat-bg);
  overflow: hidden;
}

.empty {
  margin: auto;
  text-align: center;
  padding: 30px;
  animation: rise .35s ease both;
}

.empty-mark {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #42b4ff, #1f7fd0);
  box-shadow: 0 16px 34px rgba(47, 149, 232, .30);
}

.empty h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.empty p { margin: 0; font-size: 14px; line-height: 1.5; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  min-height: 62px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}

.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; }

/* Онлайн собеседника: зелёная точка и цвет подписи. */
#chatSub.online { color: #2e9e5b; }
#chatSub.online::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #2e9e5b;
  vertical-align: 1px;
}

#themeChat { margin-left: auto; flex: none; }

/* Баланс Эли в шапке её чата: виден всегда, обновляется сам. */
.chat-bal {
  flex: none;
  margin-left: auto;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--chip, rgba(127,127,127,.12));
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px 9px;
  white-space: nowrap;
}
.chat-bal.low { color: #c98a00; }
.chat-bal.off { color: #c0392b; }
.chat-bal.hidden { display: none; }
.chat-bal + #themeChat { margin-left: 8px; }

/* Кнопка «Статус» в шапке чата с Элей. */
.chat-stat { flex: none; }
.chat-stat.hidden { display: none; }
.chat-stat.on { color: var(--accent, #a85c76); }

/* Раскрытая строка статуса под шапкой. */
#chatStatBar {
  padding: 7px 16px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}
#chatStatBar.hidden { display: none; }

.chat-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chat-title .name { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.only-mobile { display: none; }

.log-loading {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Лента не должна дёргаться сама: браузерное «прижатие» при догрузке
     фото выше экрана и появление полосы прокрутки двигали сообщения
     под пальцем (Олег, 01.12.2026). */
  overflow-anchor: none;
  scrollbar-gutter: stable;
  padding: 16px max(14px, calc((100% - 760px) / 2)) 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day {
  align-self: center;
  margin: 14px 0 8px;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(10, 20, 35, .06);
}

.msg {
  display: flex;
  justify-content: flex-start;
  max-width: 100%;
  animation: bubble .18s ease both;
  /* Свайп влево — ответ на сообщение. Без этого браузер забирает
     горизонтальный жест себе (жест «назад») и до кода он не доходит. */
  touch-action: pan-y;
  will-change: transform;
}

/* Плавный возврат на место — только когда палец отпустили. Пока тянешь,
   сообщение идёт за пальцем без задержки (иначе дёргается). */
.msg.swipe-back {
  transition: transform .16s ease-out;
}

/* Сообщение, сдвинутое влево: подсветка «отпусти — ответишь». */
.msg.swipe-reply .bubble {
  box-shadow: 0 0 0 2px var(--accent, #a85c76);
}

/* Сообщение, сдвинутое вправо: подсветка «отпусти — перешлёшь». */
.msg.swipe-forward .bubble {
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Свайп по ролику или фото не должен превращаться в перетаскивание. */
.msg video, .msg img { -webkit-user-drag: none; user-select: none; }

.msg.out { justify-content: flex-end; }
.msg.gap { margin-top: 10px; }

.bubble {
  position: relative;
  max-width: min(74%, 560px);
  min-width: 74px;
  padding: 7px 11px 6px;
  border-radius: var(--radius);
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: 0 2px 10px rgba(10, 20, 35, .07);
}

.msg.in .bubble { border-bottom-left-radius: 6px; }

/* Эля печатает… */
.msg.typing .bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
}
.tdots { display: inline-flex; gap: 3px; }
.tdots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .35;
  animation: tdot 1.2s infinite;
}
.tdots i:nth-child(2) { animation-delay: .2s; }
.tdots i:nth-child(3) { animation-delay: .4s; }
.tlabel { font-size: 13px; opacity: .7; }
@keyframes tdot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.msg.out .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(31, 127, 208, .22);
}

.msg + .msg .bubble { margin-top: 0; }

/* --- Отправка: сообщение уже в чате, строка загрузки внутри пузыря --- */
.msg.pending .bubble,
.msg.failed .bubble { padding-bottom: 14px; }

.msg-progress {
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 5px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .28);
  overflow: hidden;
  display: block;
}
.msg-progress i {
  display: block;
  height: 100%;
  width: 30%;
  border-radius: 2px;
  background: #fff;
  animation: sendbar 1.1s ease-in-out infinite;
}
.msg.det .msg-progress i { animation: none; }
.msg.failed .msg-progress { background: rgba(255, 120, 120, .35); }
.msg.failed .msg-progress i { background: #ffd1d1; }

.msg-state {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.25;
  opacity: .78;
}
.msg.failed .bubble { box-shadow: 0 0 0 2px #e05353; }
.msg.failed .msg-state { opacity: .95; cursor: pointer; }

/* Пока сообщение грузится, вложения не открываем: серверного файла ещё нет. */
.msg.pending a,
.msg.pending button { pointer-events: none; }

@keyframes sendbar {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(380%); }
}

.bubble-author {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.bubble-text {
  font-size: 15.5px;
  line-height: 1.36;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Ссылки в сообщении: обычная — подчёркнутая, установочный файл — красный. */
.msg-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.msg-link.checking {
  opacity: 0.65;
  cursor: progress;
}
.unknown-link {
  color: #8a6d00;
  font-weight: 600;
}
.danger-link {
  color: #b42318;
  font-weight: 700;
}
.msg.out .msg-link { color: #fff; }
.msg.out .unknown-link { color: #ffe9a8; }
.msg.out .danger-link { color: #ffe0dc; }

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1;
  opacity: .62;
}

/* Плашка «похоже на мошенников» под входящим сообщением. */
.scam-warn {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  margin-top: 7px;
  padding: 7px 9px;
  border-radius: 10px;
  background: #fff4e5;
  border: 1px solid #f0b26b;
  color: #7a3e00;
  font-size: 13px;
  line-height: 1.3;
  white-space: normal;
}
.scam-warn .scam-icon { font-size: 14px; line-height: 1.1; }
.scam-warn .scam-text { font-weight: 600; }

.msg.out .meta { color: rgba(255, 255, 255, .85); opacity: .8; }

/* ------------------------------------------------------------ голосовое */

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 186px;
  padding: 2px 0 3px;
}

.play {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  transition: transform .12s, background .15s;
}

.play:active { transform: scale(.94); }

.msg.out .play { background: rgba(255, 255, 255, .20); color: #fff; }

.play svg { width: 16px; height: 16px; }

.track {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  padding-bottom: 4px;
}

.bars {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  min-width: 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

/* Белая полоска прогресса: перематывается касанием или мышью. */
.prog {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  opacity: .9;
  pointer-events: none;
}

.bar {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: .30;
  transition: opacity .1s;
}

.bar.on { opacity: .95; }

/* Скорость голосового: одна кнопка 1× → 1,5× → 2×, как в MAX. */
.speed {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  padding: 4px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform .12s;
}

.speed:active { transform: scale(.94); }

.msg.out .speed { background: rgba(255, 255, 255, .20); color: #fff; }

.h1 { height: 5px; }  .h2 { height: 8px; }  .h3 { height: 11px; }
.h4 { height: 14px; } .h5 { height: 17px; } .h6 { height: 20px; }
.h7 { height: 23px; } .h8 { height: 26px; } .h9 { height: 21px; }
.h10 { height: 17px; } .h11 { height: 12px; } .h12 { height: 8px; }

.ptime {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  opacity: .7;
  min-width: 32px;
  text-align: right;
}

/* ------------------------------------------------------------ ввод */

.composer {
  display: flex;
  flex-wrap: wrap;          /* полоса ответа встаёт над строкой ввода */
  align-items: flex-end;
  gap: 8px;
  padding: 10px max(14px, calc((100% - 760px) / 2)) calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  z-index: 2;
}

.field-wrap {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 9px 14px;
  min-height: 46px;
  display: flex;
  align-items: center;
  transition: box-shadow .15s, border-color .15s;
}

.field-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#field {
  width: 100%;
  max-height: 128px;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 16px;
  line-height: 22px;
  padding: 2px 0;
}

#field::placeholder { color: var(--muted); }

.round {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform .12s, opacity .15s, background .15s;
}

.round:active { transform: scale(.94); }

.mic {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.mic:hover { color: var(--accent); }

.send {
  display: none;
  background: linear-gradient(135deg, #34a0f0, #1f7fd0);
  color: #fff;
  box-shadow: 0 6px 18px rgba(47, 149, 232, .35);
}

.composer.hastext .send { display: grid; animation: pop .14s ease both; }
.composer .send.sending { opacity: .55; pointer-events: none; }
.composer.hastext .mic { display: none; }

.rec-cancel {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--danger);
  display: none;
  place-items: center;
}

.rec-info {
  display: none;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 26px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4b4b;
  animation: pulse 1s infinite;
}

.rec-hint {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer.recording .rec-cancel { display: grid; }
.composer.recording .send { display: grid; }
.composer.recording .mic { display: none; }
.composer.recording #field { display: none; }
.composer.recording .rec-info { display: flex; }
.composer.cancelled .rec-dot { background: var(--muted); animation: none; }
.composer.cancelled .rec-hint { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------ мелочи */

.toast {
  position: fixed;
  left: 50%;
  /* Всплывашка — сверху по центру, сразу под шапкой чата с именем
     собеседника (просьба Олега 30.11.2026), а не внизу справа. */
  top: calc(62px + 10px + env(safe-area-inset-top, 0px));
  bottom: auto;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(16, 22, 31, .92);
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: drop .2s ease both;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(125, 140, 160, .35); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Всплывашка сверху: сохраняем центрирование (translateX), иначе
   конечный кадр анимации сбрасывал его и плашка прыгала вбок. */
@keyframes drop {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bubble {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Возврат в чат: показываем сохранённые сообщения сразу и без анимации.
   Иначе двести пузырей одновременно всплывают — экран «моргает». */
.log.bulk .msg { animation: none !important; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.82); }
}

@media (max-width: 760px) {
  .side { flex: 1 1 auto; width: 100%; border-right: 0; }
  .chat { display: none; }

  body.chat-open .side { display: none; }
  body.chat-open .chat { display: flex; }

  .only-mobile { display: grid; }

  .log { padding: 12px 10px 6px; }
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .bubble { max-width: 82%; }
  .chat-head { padding: 8px 10px; }
  .search-results { max-height: 50%; }
}

@media (min-width: 761px) {
  .only-mobile { display: none; }
}

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

/* ------------------------------------------------------------ вложения */

.attach {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
}
.attach:hover { color: var(--accent); }

.attach-menu {
  position: fixed;
  right: max(14px, calc((100% - 760px) / 2));
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 25;
  min-width: 200px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(10, 20, 35, .28);
  animation: pop .14s ease both;
}
.attach-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: left;
}
.attach-menu button:hover,
.attach-menu button:active { background: var(--accent-soft); color: var(--accent); }
.attach-menu svg { flex: 0 0 auto; }

.bubble.media { padding: 5px; }
.bubble.media .meta { padding: 3px 6px 0; }
.bubble.media .bubble-text.caption { padding: 5px 6px 1px; }

.msg-img {
  display: block;
  max-width: min(420px, 68vw);
  max-height: 460px;
  width: auto;
  height: auto;
  border-radius: 12px;
  background: var(--panel-2);
  cursor: zoom-in;
}

.msg-video {
  display: block;
  max-width: min(420px, 68vw);
  max-height: 460px;
  border-radius: 12px;
  background: #000;
}

.note-box { position: relative; width: 200px; height: 200px; }
.msg-note {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  cursor: pointer;
}
.note-snd {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}

.file-box { display: flex; flex-direction: column; gap: 6px; }
.msg-audio { display: block; width: 250px; max-width: 100%; height: 36px; }

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  max-width: 300px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: inherit;
  text-decoration: none;
}
.file-card:hover { border-color: var(--accent); }
.file-icon { flex: 0 0 auto; font-size: 24px; line-height: 1; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 600;
  word-break: break-word;
}
.file-size { font-size: 11.5px; color: var(--muted); }
.file-down { flex: 0 0 auto; font-size: 18px; color: var(--muted); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 8, 12, .92);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
/* APK больше нет (02.12.2026): полоса обновления удалена. */

.lightbox-save {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: 22px;
  background: #2f7cf6;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}

.note-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(4, 8, 12, .9);
  padding: 24px;
}
.note-overlay video {
  width: min(72vw, 58vh);
  height: min(72vw, 58vh);
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, .85);
  background: #000;
}
.note-time {
  color: #fff;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.note-hint {
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
  margin-top: -12px;
  min-height: 16px;
}
.note-actions { display: flex; gap: 14px; }
.note-btn {
  padding: 11px 24px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font-size: 15px;
}
.note-btn.send-note { background: var(--accent); border-color: var(--accent); }

/* Съёмка фото: полный экран, прямоугольный кадр, кнопка «Снять». */
.cam-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #000;
  padding: 18px 18px 34px;
}
.cam-overlay video {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  background: #000;
}
.cam-overlay .note-actions { flex: none; }

@media (max-width: 520px) {
  .msg-img, .msg-video { max-width: 72vw; }
  .note-box, .msg-note { width: 170px; height: 170px; }
  .attach-menu { right: 10px; left: auto; }
}

/* карточка файла в исходящем синем пузыре — светлый текст на синем */
.msg.out .file-card {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .28);
  color: #fff;
}
.msg.out .file-card:hover { border-color: rgba(255, 255, 255, .65); }
.msg.out .file-size,
.msg.out .file-down { color: rgba(255, 255, 255, .78); }

/* Аватар Эли — живое лицо вместо инициалов */
.avatar.bot-pic {
  background-image: url('/avatar-elly.jpg?v=20261202d');
  background-size: cover;
  background-position: center 22%;
  color: transparent;
}

/* Подсказка про защищённый адрес: по обычному http микрофон и камера
   браузером запрещены. Показываем ссылку, а не молчим. */
.secure-note {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  background: #8a5a00;
  color: #fff;
}
.secure-note a { color: #ffe08a; font-weight: 600; }
.secure-note .secure-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.secure-note.hidden { display: none; }

body.has-secure-note .app { height: calc(100dvh - 34px - var(--kb-h, 0px)); margin-top: 34px; }
body.has-secure-note .auth { padding-top: 34px; }

/* Голова Эли рядом с её сообщениями в личном чате */
.msg .msg-av {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  align-self: flex-end;
  margin-right: 8px;
  background-size: cover;
  background-position: center 22%;
  box-shadow: 0 2px 8px rgba(10, 20, 35, .18);
}

/* Профиль: свои данные, как в MAX */
.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 14, 22, .55);
  backdrop-filter: blur(2px);
}
.profile-overlay.hidden { display: none; }
.profile-card {
  width: 100%;
  max-width: 460px;
  max-height: 92dvh;
  overflow: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.profile-card h2 { margin: 0 0 6px; font-size: 21px; }
.profile-note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.profile-card label { display: block; margin: 12px 0 5px; font-size: 13px; color: var(--muted); }
.profile-card .input { width: 100%; }
.profile-card textarea { resize: vertical; }
.avatar img.av-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pf-photo { display: flex; align-items: center; gap: 14px; margin: 0 0 8px; }
.pf-avatar { width: 64px; height: 64px; font-size: 22px; }
.pf-photo-text { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.profile-card select.input { padding-right: 38px; }
.profile-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.profile-actions .btn-primary { margin: 0; }
.pin-change {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line, rgba(127, 127, 127, .25));
}
.pin-change .btn-primary { margin: 2px 0 0; }

/* Значок темы: в тёмной показываем солнце, в светлой — луну. */
:root[data-theme="light"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: none; }
.ico-moon, .ico-sun { display: inline-flex; }

/* Поле выбора файла: не display:none и не hidden — иначе WebView на
   Android 15 не открывает галерею по клику. Держим в углу, невидимым. */
.file-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  left: -9999px;
}

/* Реакции на сообщения: чипы под пузырём и кнопка выбора. */
.reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 6px;
  align-items: center;
}
/* Как в MAX: реакции идут отдельной строкой под пузырём, а не сбоку. */
.msg { flex-wrap: wrap; }
.msg .reacts { flex-basis: 100%; }
/* В личном чате у сообщений Эли слева голова — сдвигаем реакции под пузырь. */
.msg.in:has(.msg-av) .reacts { padding-left: 42px; }
.msg.out .reacts { justify-content: flex-end; }
.react-chip {
  font: inherit;
  font-size: 12.5px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.react-chip.mine {
  border-color: var(--accent, #a85c76);
  background: rgba(168, 92, 118, .16);
}
.react-add {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  width: 26px;
  height: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: .55;
}
.msg:hover .react-add, .react-add:focus { opacity: 1; }
.react-pop {
  position: fixed;
  z-index: 999;
  display: grid;
  grid-template-columns: repeat(6, 38px);
  gap: 2px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.react-opt {
  font-size: 20px;
  line-height: 1;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.react-opt:hover { background: rgba(127, 127, 127, .16); }

/* Мои устройства в профиле. */
.devices-block { margin: 14px 0 6px; }
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 6px;
}
.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.device-row.current { border-color: var(--accent, #a85c76); }
.device-info { min-width: 0; flex: 1; }
.device-name { font-size: 13.5px; }
.device-meta { margin-top: 2px; }
.device-kill { flex: none; font-size: 12.5px; }

/* Праздники и дни рождения: полоска на сегодня и список на 90 дней. */
.event-banner { margin: 0 12px 10px; }
.event-banner.hidden { display: none; }
.event-banner button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--accent-soft);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.event-banner button:hover { border-color: var(--accent); }
.event-banner .eb-ico { flex: none; font-size: 17px; }
.event-banner .eb-text { min-width: 0; }
.calendar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 55dvh;
  overflow-y: auto;
  margin: 4px 0 14px;
  padding-right: 2px;
}
.cal-day {
  margin: 12px 0 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-group:first-child .cal-day { margin-top: 2px; }
.cal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel-2);
}
.cal-row + .cal-row { margin-top: 4px; }
.cal-row.cal-link { cursor: pointer; }
.cal-row.cal-link:hover { box-shadow: 0 0 0 1px var(--accent); }
.cal-ico { flex: none; width: 24px; text-align: center; font-size: 17px; }
.cal-main { display: flex; flex-direction: column; min-width: 0; }
.cal-name { font-size: 14.5px; font-weight: 600; }
.cal-when { font-size: 12px; color: var(--muted); }
.calendar-foot { margin: 0 0 4px; font-size: 12px; line-height: 1.4; color: var(--muted); }

/* Ответ на сообщение — как в MAX: тонкая полоска слева, имя цветным,
   текст в одну строку с многоточием. */
.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 0 5px;
  padding: 4px 8px 4px 9px;
  border-left: 3px solid var(--accent, #a85c76);
  border-radius: 6px;
  background: rgba(127, 127, 127, .13);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
}
.reply-quote .reply-who {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--accent, #a85c76);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-quote .reply-text {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg.out .reply-quote {
  background: rgba(255, 255, 255, .16);
}
.msg.out .reply-quote .reply-who { color: #fff; }
.msg.out .reply-quote .reply-text { color: rgba(255, 255, 255, .82); }

/* Полоса «отвечаю на…» над полем ввода — как в MAX. */
.reply-bar {
  flex: 0 0 100%;           /* отдельная строка над полем ввода, как в MAX */
  order: -1;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px 6px 10px;
  border-left: 3px solid var(--accent, #a85c76);
  border-radius: 8px;
  background: rgba(127, 127, 127, .13);
}
.reply-bar.hidden { display: none; }
.reply-bar-body { min-width: 0; flex: 1; }
.reply-bar-who {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #a85c76);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-text {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-x {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reply-bar-x:hover { background: rgba(127, 127, 127, .18); }

/* Пересылка: выбор чата и превью сообщения. */
.forward-card { max-width: 420px; }
.forward-preview {
  margin: 0 0 12px;
  padding: 9px 11px;
  border-left: 3px solid #3b82f6;
  border-radius: 8px;
  background: rgba(127, 127, 127, .13);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.forward-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 52dvh;
  overflow: auto;
  margin: 0 0 14px;
}
.forward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: rgba(127, 127, 127, .10);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.forward-item:hover { background: rgba(127, 127, 127, .18); }
.forward-item:disabled { opacity: .6; cursor: default; }
.forward-item .avatar { flex: none; }
.forward-item .fwd-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Подсветка сообщения, к которому вернулись по цитате. */
.msg.flash .bubble {
  animation: flashBubble 1.2s ease;
}
@keyframes flashBubble {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 2px var(--accent, #a85c76); }
}

/* Кнопка «переименовать устройство» рядом с названием. */
.device-name { display: flex; align-items: center; gap: 6px; }
.device-ren {
  font-size: 13px;
  line-height: 1;
  padding: 2px 5px;
  opacity: .5;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.device-ren:hover { opacity: 1; }

/* Семья: детский код приглашения (30.11.2026). */
.family-block { margin-top: 16px; }
.invite-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.12);
  border: 1px solid rgba(127, 127, 127, 0.25);
}
.invite-title { font-weight: 600; margin-bottom: 4px; }
.invite-line { font-size: 13px; line-height: 1.35; }
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  letter-spacing: 0.06em;
  margin: 6px 0;
  user-select: all;
}

/* Тревога «это не я»: заметная, но не кричащая красная кнопка. */
.security-block { border-top: 1px solid var(--line, #2a3446); padding-top: 14px; }

/* Раскрывающаяся памятка против мошенников. */
.scam-rules {
  margin: 10px 0 4px;
  border: 1px solid var(--line, #2a3446);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}
.scam-rules summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent, #7ab8ff);
  list-style: none;
}
.scam-rules summary::-webkit-details-marker { display: none; }
.scam-rules summary::before { content: '🛡 '; }
.scam-rules ul { margin: 8px 0 2px; padding-left: 18px; }
.scam-rules li { margin: 6px 0; line-height: 1.35; }
.btn-danger {
  display: block;
  width: 100%;
  margin: 8px 0 6px;
  border: 1px solid #b0413e;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #ffd9d6;
  background: rgba(176, 65, 62, .16);
  cursor: pointer;
}
.btn-danger:active { transform: scale(.985); }
.btn-danger:disabled { opacity: .6; }
.sec-event {
  padding: 8px 0;
  border-bottom: 1px solid var(--line, #2a3446);
  font-size: 13px;
}
.sec-event:last-child { border-bottom: 0; }
.sec-event .sec-when { color: var(--muted, #8a94a6); font-size: 12px; }

/* Свои стикеры: кнопка у поля ввода и панель с набором (30.11.2026) */
.stickers-btn {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
}
.stickers-btn:hover, .stickers-btn.active { color: var(--accent); }

.sticker-panel {
  position: fixed;
  left: 0;
  right: 0;
  /* Панель стоит НАД строкой ввода, а не поверх неё: иначе не видно
     поле и кнопку «отправить», и кажется, что всё зависло (Олег, 30.11). */
  bottom: var(--composer-h, 0px);
  z-index: 40;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 12px max(14px, calc((100% - 760px) / 2)) 12px;
  max-height: 48vh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
}
.sticker-panel.hidden { display: none; }

.sticker-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.sticker-tab {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.sticker-tab.active {
  background: rgba(127, 127, 127, .14);
  color: var(--text, #e8edf5);
  font-weight: 600;
}
.sticker-close {
  margin-left: auto;
  border: 0;
  background: rgba(127, 127, 127, .12);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.sticker-close:hover { color: var(--text, #e8edf5); }

/* Переключатель набора: рыжий кот или серая кошка (30.11.2026) */
.sticker-variants {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.sticker-variant {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 13px;
  cursor: pointer;
}
.sticker-variant.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sticker-panel.emoji-mode {
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.emoji-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.emoji-cats {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  min-height: 42px;
  padding: 4px 0;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
  scrollbar-width: none;
}
.emoji-cats::-webkit-scrollbar { display: none; }
.emoji-cat {
  border: 0;
  background: transparent;
  font-size: 19px;
  line-height: 1.6;
  padding: 4px 7px;
  border-radius: 10px;
  cursor: pointer;
  opacity: .72;
  flex: 0 0 auto;
}
.emoji-cat:hover, .emoji-cat:active { background: rgba(127, 127, 127, .14); opacity: 1; }
.emoji-scroll {
  position: relative;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.emoji-title {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
  padding: 6px 2px 4px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
}
.emoji-grid.hidden, .sticker-grid.hidden { display: none; }
.emoji-opt {
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1.2;
  padding: 5px 0;
  border-radius: 10px;
  cursor: pointer;
}
.emoji-opt:hover { background: rgba(127, 127, 127, .12); }
.emoji-opt:active { transform: scale(.94); }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.sticker-opt {
  border: 0;
  background: transparent;
  padding: 4px;
  border-radius: 16px;
  cursor: pointer;
}
.sticker-opt:hover { background: rgba(127, 127, 127, .12); }
.sticker-opt:active { transform: scale(.96); }
.sticker-opt img { width: 100%; max-width: 96px; display: block; margin: 0 auto; }

.bubble-sticker {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 2px !important;
}
.sticker-img { width: 150px; height: 150px; display: block; }
@media (max-width: 420px) { .sticker-img { width: 132px; height: 132px; } }

/* Черновик фото перед отправкой: снимок, подпись, голосовое (как в MAX). */
.draft-card { width: min(92vw, 460px); }
.draft-photo {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  border-radius: 12px;
  background: #0d1117;
  margin-bottom: 10px;
}
.draft-name { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.draft-caption { width: 100%; resize: none; min-height: 44px; max-height: 120px; }
.draft-audio {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text);
}
.draft-audio.hidden { display: none; }

/* Просмотр чатов ребёнка опекуном — только чтение (30.11.2026). */
.childview-card {
  max-width: 760px;
  width: min(100%, 760px);
  max-height: min(86dvh, 820px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.childview-head { display: flex; align-items: center; gap: 10px; }
.childview-head h2 {
  flex: 1; margin: 0; font-size: 18px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.childview-body {
  flex: 1;
  min-height: 120px;
  margin-top: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.child-room { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.child-room .cr-title { font-size: 14px; font-weight: 600; }
.child-room .cr-preview {
  margin-top: 2px; font-size: 12.5px; opacity: .7;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.childview-log { display: flex; flex-direction: column; gap: 8px; }
.childview-empty { padding: 18px 6px; text-align: center; }

/* Согласие на обработку персональных данных при регистрации (30.11.2026). */
.consent {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 10px 0 2px; font-size: 12.5px; color: var(--muted);
  line-height: 1.35; text-align: left;
}
.consent input { margin-top: 2px; flex: none; }

/* --- Платная Эля: полоса «не подключена» и заявки (30.11.2026) ---------- */
.elly-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px max(14px, calc((100% - 760px) / 2)) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  z-index: 2;
}
.elly-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}
.elly-bar .btn-primary { flex: none; }

.elly-card { max-height: 88vh; overflow-y: auto; }
.elly-prices { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.elly-price {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.elly-price-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font-size: 14px;
}
.elly-price-right {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.elly-sum { font-weight: 700; white-space: nowrap; }
.elly-mine, .elly-pending {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.elly-sub { font-size: 13px; font-weight: 600; margin-top: 4px; }
.elly-order {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  text-align: left;
  padding: 4px 0;
}
.elly-order-body { flex: 1; min-width: 0; }
.elly-order .link-btn { flex: none; }

/* Телефон и код из SMS в одну строку: код короткий, кнопка рядом. */
.sms-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.sms-row .input { flex: 1; min-width: 0; }
.sms-row .link-btn { flex: none; white-space: nowrap; }

/* Фото при регистрации — круг с силуэтом и «+», как в MAX.
   Решение Олега 01.12.2026: синюю строчку «Выбрать фото» пожилые люди
   не замечают, а кружок видно сразу. */
.pick-photo{
  display:flex;flex-direction:column;align-items:center;gap:8px;
  margin:6px 0 16px;cursor:pointer;-webkit-tap-highlight-color:transparent;
}
.pick-photo-ring{
  position:relative;width:104px;height:104px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:var(--panel-2);border:2px dashed rgba(94,107,126,.45);
  transition:border-color .15s ease, background .15s ease;
}
.pick-photo:active .pick-photo-ring{background:var(--accent-soft)}
.pick-photo-icon{width:50px;height:50px;color:var(--muted)}
.pick-photo-img{
  position:absolute;inset:0;width:100%;height:100%;border-radius:50%;
  object-fit:cover;display:none;
}
.pick-photo.has-photo .pick-photo-img{display:block}
.pick-photo.has-photo .pick-photo-icon{display:none}
.pick-photo.has-photo .pick-photo-ring{border-style:solid;border-color:var(--accent)}
.pick-photo-plus{
  position:absolute;right:-2px;bottom:-2px;width:34px;height:34px;
  border-radius:50%;background:var(--accent);color:#fff;
  font-size:23px;line-height:30px;font-weight:600;text-align:center;
  border:2px solid var(--panel);box-shadow:0 2px 8px rgba(0,0,0,.22);
}
.pick-photo-hint{
  font-size:13px;color:var(--muted);text-align:center;max-width:250px;
}

/* Кнопка «Войти в существующий аккаунт» под регистрацией (01.12.2026). */
.btn-outline {
  margin-top: 10px;
  border: 1.5px solid var(--accent);
  border-radius: 13px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  transition: transform .1s, background .15s;
}
.btn-outline:active { transform: scale(.985); }

/* Кнопка «Войти в существующий аккаунт» стоит сразу под заголовком:
   на телефоне страница регистрации длиннее экрана, и до нижней кнопки
   не доскроллить (Олег, 01.12.2026). */
#authSwitchTop {
  width: 100%;
  margin: 0 0 18px;
  padding: 11px 14px;
  font-size: 15px;
}

/* Защита от съёмки экрана телефоном: пока окно не в фокусе, переписка
   размыта — сфотографировать можно только то, что видно (Олег, 01.12.2026). */
body.privacy-blur #app,
body.privacy-blur #auth {
  filter: blur(14px);
  transition: filter .12s ease;
}
body.privacy-blur #app::after {
  content: "Переписка скрыта — вернитесь в окно";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--muted);
  background: rgba(0, 0, 0, .06);
  pointer-events: none;
}

/* Кнопка «Включить уведомления» в браузере (Web Push). */
.svyaz-push-btn{position:fixed;z-index:9998;left:50%;transform:translateX(-50%);
 bottom:88px;max-width:86vw;padding:10px 16px;border:0;border-radius:22px;
 background:#2f7d4f;color:#fff;font:14px/1.2 sans-serif;
 box-shadow:0 6px 18px rgba(0,0,0,.35)}

/* Заставка «Связь» только в Яндекс Браузере (iPhone, iPad, Mac).
   Решение Олега 01.12.2026. Показывается из gate.js. */
.yagate{position:fixed;top:0;right:0;bottom:0;left:0;z-index:100000;
 overflow:auto;display:flex;align-items:center;justify-content:center;
 padding:22px;background:var(--bg);color:var(--text)}
.yagate-card{width:100%;max-width:430px;box-sizing:border-box;
 background:var(--panel);border:1px solid var(--line);
 border-radius:var(--radius);padding:26px 22px;box-shadow:var(--shadow)}
.yagate-logo{display:block;margin:0 auto 12px;border-radius:16px}
.yagate-title{font-size:21px;line-height:1.3;margin:0 0 10px;text-align:center}
.yagate-text{font-size:15px;line-height:1.5;margin:0 0 16px;
 color:var(--muted);text-align:center}
.yagate-steps{margin:0 0 18px;padding-left:22px;font-size:15px;line-height:1.55}
.yagate-steps li{margin:6px 0}
.yagate-btn{display:block;width:100%;box-sizing:border-box;text-align:center;
 padding:13px 16px;border:0;border-radius:12px;background:#2c7ed3;color:#fff;
 font:inherit;font-size:15px;font-weight:600;cursor:pointer;
 text-decoration:none;line-height:1.25}
.yagate-btn-quiet{margin-top:10px;background:transparent;color:var(--accent);
 border:1px solid var(--line);font-weight:500}
.yagate-hint{min-height:20px;margin:10px 0 0;font-size:13px;
 color:var(--muted);text-align:center}
.yagate-hidden{position:fixed;left:-9999px;top:0;opacity:0}
