/* Все цвета и размеры — в переменных: под новый дизайн меняется в основном этот блок */
/* Палитра и шрифт — как на лендинге СВОЙГРАМ */
:root {
  --accent: #398cff;
  --accent-2: #4bd8ff;
  --accent-grad: linear-gradient(110deg, #078edb, #245ce8);
  --accent-text: #fff;
  --bg: #050914;
  --panel: #091329;
  --panel-2: #0c1930;
  --text: #f3f7ff;
  --muted: #9caac2;
  --border: rgba(94, 151, 232, .19);
  --hover: #0c1930;
  --active: #10284c;
  --bubble-in: #0f1f3b;
  --bubble-out: #1b4fc0;
  --chat-bg: #050914;
  --danger: #f47b84;
  --online: #43e3b1;
  --radius: 14px;
  --sidebar-w: 340px;
  --font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;

}
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
#app { height: 100dvh; }

/* ---------- Вход и профиль ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background: var(--screen);
}
.card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px 24px;
}
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 24px; font-weight: 800; letter-spacing: -.7px; margin-bottom: 12px; color: var(--text); text-decoration: none; }
.logo img { width: 44px; height: 44px; border-radius: 11px; box-shadow: 0 0 18px rgba(43,136,255,.35); }
.logo .accent { color: var(--link); }
.to-site { display: block; text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); text-decoration: none; }
.to-site:hover { color: var(--text); }
.card h1 { font-size: 20px; margin: 8px 0 4px; }
.card p { margin: 0 0 16px; }
.card form { display: flex; flex-direction: column; gap: 12px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg); outline: none;
}
.card input:focus { border-color: var(--accent); }
.code-input { font-size: 24px; letter-spacing: 8px; text-align: center; }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix span { padding-left: 14px; color: var(--muted); }
.input-prefix input { border: 0; background: transparent; padding-left: 2px; }
.btn {
  padding: 13px; border: 1px solid transparent; border-radius: 12px; background: var(--accent-grad);
  color: var(--accent-text); font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-outline { display: block; text-align: center; text-decoration: none; margin-bottom: 10px; background: transparent; color: var(--accent); border: 1px solid var(--accent); box-shadow: none; }
.btn-danger-outline { width: 100%; background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:disabled { color: var(--muted); cursor: default; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.profile-top { margin-bottom: 4px; }
.error { color: var(--danger); font-size: 14px; min-height: 0; }
.error:empty { display: none; }
#profile-extra { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Основной экран ---------- */
.main { display: flex; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
}
.side-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px; border-radius: 10px; cursor: pointer; width: 100%; text-align: left; }
.me:hover { background: var(--hover); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 12px; color: var(--muted); }
.search { padding: 10px 12px; }
.search input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); outline: none;
}
.search input:focus { border-color: var(--accent); }
.list { flex: 1; overflow-y: auto; }
.list-title { padding: 10px 16px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.list-empty { padding: 24px 16px; color: var(--muted); text-align: center; }

.item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 0 6px; border-radius: 12px; cursor: pointer; }
.item:hover { background: var(--hover); }
.item.active { background: var(--active); }
.item-body { flex: 1; min-width: 0; }
.item-top, .item-bottom { display: flex; align-items: center; gap: 6px; }
.item-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.item-text { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-text .you { color: var(--text); }
.item-text.typing { color: var(--accent); }
.badge { background: var(--accent-grad); color: var(--accent-text); font-size: 12px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }
.ticks { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.ticks.read { color: var(--accent-2); }

.avatar {
  --h: 210;
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; position: relative;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 16px;
  background: hsl(var(--h) 55% 52%);
}
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.avatar.online::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 12px; height: 12px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--panel);
}

/* ---------- Чат ---------- */
.chat {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--chat-bg);
}
.chat-empty { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.peer { min-width: 0; }
.peer-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 13px; color: var(--muted); }
.peer-status.on { color: var(--accent); }
.icon-btn { background: none; border: 0; font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--accent); }
.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; margin: 10px 0 6px; padding: 3px 10px; border-radius: 10px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.msg {
  max-width: min(560px, 80%); padding: 7px 10px 5px; border-radius: var(--radius);
  background: var(--bubble-in); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
}
.msg.out { background: var(--bubble-out); align-self: flex-end; color: var(--out-text); }
.msg.out .msg-meta { color: var(--out-meta); }
.msg.out .msg-meta .ticks.read { color: var(--accent-2); }
.msg.group-start { margin-top: 6px; }
.msg-meta { float: right; margin: 6px 0 -2px 10px; font-size: 11px; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; }
.msg-meta .ticks.read { color: var(--accent-2); }
.msg.error { cursor: pointer; }
.msg.error .msg-meta { color: var(--danger); }
.loading-older { align-self: center; font-size: 12px; color: var(--muted); padding: 6px; }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px; padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg); outline: none; line-height: 1.35;
}
.composer textarea:focus { border-color: var(--accent); }
.send {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent-grad);
  color: var(--accent-text); font-size: 18px; cursor: pointer; flex-shrink: 0;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--menu-bg); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 10;
}

/* ---------- Телефон ---------- */
@media (max-width: 720px) {
  .sidebar { width: 100%; border-right: 0; }
  .chat { display: none; }
  .main.chat-open .sidebar { display: none; }
  .main.chat-open .chat { display: flex; }
  .back { display: block; }
  .msg { max-width: 85%; }
}

/* ---------- Список чатов в стиле макета с лендинга ---------- */
.app-heading { display: flex; align-items: center; gap: 9px; padding: 16px 16px 12px; }
.mini-shield { width: 30px; height: 30px; display: grid; place-items: center; }
.mini-shield img { width: 100%; height: 100%; border-radius: 8px; }
.app-title { font-size: 17px; font-weight: 800; letter-spacing: -.4px; }
.app-title .accent { color: var(--link); }
.conn { font-size: 12px; color: var(--muted); }
.compose {
  margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 0; background: none;
  font-size: 22px; line-height: 1; color: var(--link); cursor: pointer;
}
.compose:hover { background: var(--hover); }

.search { position: relative; padding: 0 14px 4px; }
.search-ico { position: absolute; left: 26px; top: 50%; transform: translateY(-60%); color: var(--muted); font-size: 18px; pointer-events: none; }
.search input { background: var(--ios-field); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px 10px 36px; }
.search input::placeholder { color: var(--muted); }

.chat-tabs { display: flex; gap: 22px; padding: 12px 16px 0; border-bottom: 1px solid var(--ios-hair); }
.tab {
  background: none; border: 0; padding: 0 0 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.list { padding-top: 2px; }
.item { margin: 0; border-radius: 0; padding: 11px 16px; position: relative; }
.item::after { content: ""; position: absolute; left: 72px; right: 16px; bottom: 0; border-bottom: 1px solid var(--ios-hair); }
.item:hover { background: var(--hover); }
.item.active { background: var(--active); }
.item.active::after { display: none; }
.item .avatar { width: 46px; height: 46px; }
.item-name { font-weight: 700; }
.item-time { color: var(--muted); }
.item-text { color: var(--muted); }
.badge { background: var(--accent); }

.avatar { background: linear-gradient(135deg, #3d9bff, #3242a9); font-weight: 800; }

.bottom-nav {
  display: flex; justify-content: space-around; align-items: center;
  height: 58px; padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box;
  background: var(--ios-bar); border-top: 1px solid var(--ios-hair);
}
.bottom-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1;
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 0;
}
.bottom-nav .nav-ico { font-size: 18px; line-height: 1; }
.bottom-nav small { font-size: 11px; }
.bottom-nav .selected { color: var(--accent); }

/* ---------- Выбор страны (код телефона) ---------- */
.phone-row { display: flex; gap: 8px; }
.phone-row input { flex: 1; min-width: 0; }
.cc-btn {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.cc-btn:hover, .cc-btn.open { border-color: var(--accent); }
.flag { width: 24px; height: 18px; border-radius: 3px; object-fit: cover; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.caret { color: var(--muted); font-size: 12px; }
.cc-panel { border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); overflow: hidden; }
.cc-panel input { border: 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 0 !important; background: transparent !important; }
.cc-list { max-height: 260px; overflow-y: auto; }
.cc-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 0; background: none; cursor: pointer; text-align: left; }
.cc-item:hover, .cc-item.active { background: var(--active); }
.cc-item .cc-name { flex: 1; }
.cc-item .cc-dial { color: var(--muted); }

/* ---------- Переключатель в настройках ---------- */
.switch-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.switch-title { color: var(--text); font-size: 15px; }
.switch {
  appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 13px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #9caac2; transition: transform .2s, background .2s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(20px); background: #fff; }

/* ---------- Цитата, меню сообщения, панель ответа/редактирования ---------- */
.msg { position: relative; }
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-2); } 100% { box-shadow: none; } }
.quote {
  display: block; margin: 0 0 5px; padding: 3px 8px; border-left: 3px solid var(--accent-2);
  border-radius: 6px; background: var(--soft); cursor: pointer; max-width: 100%;
}
.msg.out .quote { border-left-color: var(--out-accent); background: var(--soft-2); }
.quote b { display: block; font-size: 13px; color: var(--accent-2); }
.msg.out .quote b { color: var(--out-accent); }
.quote span { display: block; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote.deleted span { font-style: italic; opacity: .6; }
.edited { font-size: 11px; opacity: .8; }

.msg-menu {
  position: fixed; z-index: 20; min-width: 200px; padding: 6px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.msg-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; font-size: 14px;
}
.msg-menu button:hover { background: var(--active); }
.msg-menu button.danger { color: var(--danger); }
.msg-menu .mi { width: 18px; text-align: center; opacity: .85; }

.compose-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 0; background: var(--panel);
}
.cb-icon { color: var(--accent-2); font-size: 18px; }
.cb-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent-2); padding-left: 10px; }
.cb-title { font-size: 13px; color: var(--accent-2); font-weight: 600; }
.cb-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Фото профиля ---------- */
.avatar-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.avatar.xl { width: 84px; height: 84px; font-size: 30px; }
.avatar.loading { opacity: .5; }
.avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.avatar-actions .link { font-size: 14px; }
.link.danger { color: var(--danger); }

/* ---------- Фото и файлы в сообщениях ---------- */
.attach {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: none; font-size: 20px;
  cursor: pointer; flex-shrink: 0; opacity: .85;
}
.attach:hover { background: var(--hover); opacity: 1; }
.msg.has-att { padding: 4px 4px 5px; }

.msg.has-att .msg-meta { margin-right: 6px; }
.msg.has-att .quote { margin: 2px 2px 5px; }
.att-img-wrap { position: relative; display: block; margin-bottom: 4px; }
.att-img {
  display: block; max-width: min(320px, 100%); max-height: 360px; width: auto; height: auto;
  border-radius: 10px; cursor: zoom-in; background: var(--soft);
}
.upl {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 10px;
  background: rgba(0,0,0,.45); color: #fff; font-weight: 700; font-size: 15px;
}
.att-file {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px 4px; min-width: 220px;
  color: inherit; text-decoration: none; border-radius: 10px;
}
a.att-file:hover { background: var(--soft); }
.att-file .file-ico {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent-grad); color: #fff; font-size: 18px;
}
.msg.out .att-file .file-ico { background: var(--out-accent); color: var(--on-out-accent); }
.att-file .file-info { min-width: 0; display: flex; flex-direction: column; }
.att-file .file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.att-file .file-size { font-size: 12px; opacity: .75; }

.lightbox {
  position: fixed; inset: 0; z-index: 30; background: rgba(2,5,12,.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: calc(100dvh - 90px); border-radius: 8px; }
.lightbox-bar { display: flex; gap: 24px; }
.lightbox-bar a, .lightbox-bar button { color: #fff; background: none; border: 0; font-size: 15px; cursor: pointer; text-decoration: none; }
.drop-hint {
  position: fixed; inset: 16px; z-index: 25; display: grid; place-items: center; pointer-events: none;
  border: 3px dashed var(--accent-2); border-radius: 20px; background: rgba(5,9,20,.75);
  color: var(--text); font-size: 20px; font-weight: 700;
}
.msg > .msg-text { display: inline; }

.msg.has-att > .msg-text { padding: 0 6px; }
.msg.has-img { max-width: min(328px, 85%); }
.msg.has-img .att-img { max-width: 100%; }

/* =====================================================================
   Интерфейс в стиле Telegram на iPhone (поверх базовых стилей)
   ===================================================================== */
:root {
  --ios-bar: rgba(13, 18, 30, .86);
  --ios-hair: rgba(255, 255, 255, .09);
  --ios-gray: #8d93a0;
  --ios-field: #161d2b;
  --ios-cell: #111827;
  --ios-blue: #3e88f7;
  --bubble-in: #1b2433;
  --bubble-out: #2b63de;
  --radius: 18px;
}
.ico { width: 24px; height: 24px; fill: currentColor; display: block; }

/* ---------- шапка «Чаты» ---------- */
.ios-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 52px; padding: 0 8px 0 16px;
}
.nav-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.nav-side { display: flex; align-items: center; min-width: 0; }
.nav-side.right { justify-content: flex-end; }
.nav-side .conn { font-size: 13px; color: var(--ios-gray); }
.nav-icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--ios-blue);
  display: grid; place-items: center; cursor: pointer;
}
.nav-icon-btn .ico { width: 23px; height: 23px; }
.nav-icon-btn:hover { background: var(--hover); }

/* ---------- поиск ---------- */
.search { padding: 2px 12px 8px; position: relative; }
.search .search-ico {
  position: absolute; left: 22px; top: 50%; transform: translateY(-58%);
  width: 18px; height: 18px; fill: var(--ios-gray); pointer-events: none;
}
.search input {
  height: 36px; padding: 0 12px 0 34px; border-radius: 10px; border: 0;
  background: var(--ios-field); font-size: 16px;
}
.search input::placeholder { color: var(--ios-gray); }
.search input:focus { box-shadow: 0 0 0 1px rgba(62,136,247,.5); }

.chat-tabs { padding: 4px 16px 0; border-bottom: 1px solid var(--ios-hair); }
.tab { font-size: 14px; }
.tab.active { color: var(--ios-blue); border-bottom-color: var(--ios-blue); }

/* ---------- строки чатов ---------- */
.sidebar { background: var(--bg); }
.item { padding: 7px 14px 7px 12px; gap: 11px; align-items: flex-start; }
.item .avatar { width: 58px; height: 58px; font-size: 21px; margin-top: 1px; }
.item::after { left: 82px; right: 0; border-bottom: 1px solid var(--ios-hair); }
.item-body { padding-top: 3px; }
.item-name { font-size: 16.5px; font-weight: 600; }
.item-time { font-size: 14px; color: var(--ios-gray); }
.item-bottom { align-items: flex-start; margin-top: 1px; }
.item-text {
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  font-size: 15px; line-height: 1.3; color: var(--ios-gray); min-height: 39px;
}
.item-text .you { color: var(--text); }
.badge { background: var(--ios-blue); min-width: 22px; height: 22px; border-radius: 11px; margin-top: 8px; }
.ticks.read, .item .ticks.read { color: var(--ios-blue); }
.list-title { color: var(--ios-gray); }

/* ---------- нижняя панель (таб-бар) ---------- */
.tabbar {
  display: flex; justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  background: var(--ios-bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--ios-hair);
}
.tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1;
  background: none; border: 0; color: var(--ios-gray); cursor: pointer; padding: 2px 0;
}
.tabbar .tab-ico { width: 27px; height: 27px; fill: currentColor; }
.tabbar small { font-size: 10.5px; font-weight: 500; }
.tabbar .selected { color: var(--ios-blue); }
.tab-badge, .back-badge {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: #ff3b30; color: #fff;
  font-size: 12px; font-weight: 600; display: grid; place-items: center;
}
.tab-badge { position: absolute; top: -1px; left: calc(50% + 6px); }
.tab-badge.hidden, .back-badge.hidden { display: none; }

/* ---------- шапка чата: «‹ Чаты» · имя по центру · аватар ---------- */
.chat-head {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  height: 56px; padding: 0 12px 0 4px;
  background: var(--ios-bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--ios-hair);
}
.back-btn {
  justify-self: start; display: flex; align-items: center; gap: 0; border: 0; background: none;
  color: var(--ios-blue); font-size: 17px; cursor: pointer; padding: 6px 4px; visibility: hidden;
}
.back-btn .ico { width: 30px; height: 30px; margin-right: -4px; }
.back-badge { margin-left: 6px; background: var(--ios-blue); }
.chat-head .peer { text-align: center; min-width: 0; }
.peer-name { font-size: 16.5px; font-weight: 600; }
.peer-status { font-size: 13px; color: var(--ios-gray); }
.peer-status.on { color: var(--ios-blue); }
.chat-head .avatar.sm { justify-self: end; width: 38px; height: 38px; font-size: 15px; }
.chat-head .avatar.online::after { width: 10px; height: 10px; }

/* ---------- фон переписки ---------- */
.chat {
  background:
    radial-gradient(var(--chat-dots) 1px, transparent 1.3px) 0 0 / 22px 22px,
    var(--chat-bg);
}
.day {
  background: var(--chip-bg); color: var(--chip-text); backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 500; padding: 3px 11px; border-radius: 12px;
}

/* ---------- пузыри с «хвостиками» ---------- */
.messages { padding: 10px 14px; gap: 2px; }
.msg { border-radius: var(--radius); font-size: 16px; line-height: 1.32; box-shadow: none; padding: 6px 11px 6px 12px; }
.msg.group-start { margin-top: 7px; }
.msg.out { background: var(--bubble-out); }
.msg.group-end.out { border-bottom-right-radius: 5px; margin-right: 7px; }
.msg.group-end:not(.out) { border-bottom-left-radius: 5px; margin-left: 7px; }
.msg:not(.out):not(.group-end) { margin-left: 7px; }
.msg.out:not(.group-end) { margin-right: 7px; }
.msg.group-end::after {
  content: ""; position: absolute; bottom: 0; width: 10px; height: 17px;
  -webkit-mask: var(--tail) no-repeat; mask: var(--tail) no-repeat;
}
.msg.group-end.out::after {
  right: -7px; background: var(--bubble-out);
  --tail: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 17'><path d='M0 0v17h10C4.5 15.8 1 11.6 0 0z'/></svg>");
}
.msg.group-end:not(.out)::after {
  left: -7px; background: var(--bubble-in);
  --tail: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 17'><path d='M10 0v17H0C5.5 15.8 9 11.6 10 0z'/></svg>");
}
.msg-meta { font-size: 12px; margin-top: 7px; }
.msg.out .msg-meta { color: var(--out-meta); }
.msg.out .msg-meta .ticks.read { color: var(--out-accent); }
.quote { border-left-width: 3px; border-radius: 6px; }

/* ---------- поле ввода ---------- */
.composer {
  align-items: flex-end; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--ios-bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--ios-hair);
}
.attach {
  width: 38px; height: 38px; color: var(--ios-gray); display: grid; place-items: center; opacity: 1;
}
.attach .ico { width: 26px; height: 26px; transform: rotate(45deg); }
.attach:hover { color: var(--ios-blue); background: none; }
.composer textarea {
  min-height: 36px; padding: 7px 14px; border-radius: 18px; font-size: 16px;
  background: var(--ios-field); border: 1px solid transparent;
}
.composer textarea:focus { border-color: var(--accent); }
.send {
  width: 36px; height: 36px; background: var(--ios-blue); display: none; place-items: center; margin-bottom: 0;
}
.send .ico { width: 22px; height: 22px; fill: #fff; }
.composer.has-text .send { display: grid; }
.compose-bar { background: var(--ios-bar); border-top: 1px solid var(--ios-hair); padding-bottom: 6px; }
.compose-bar .icon-btn { color: var(--ios-gray); display: grid; place-items: center; }
.compose-bar .icon-btn .ico { width: 20px; height: 20px; }
.cb-icon, .cb-title { color: var(--ios-blue); }
.cb-body { border-left-color: var(--ios-blue); }

/* ---------- меню сообщения ---------- */
.msg-menu { background: var(--menu-bg); backdrop-filter: blur(20px); border-radius: 14px; padding: 4px; }
.msg-menu button { padding: 11px 14px; font-size: 15px; border-radius: 10px; }

/* ---------- настройки как в iOS ---------- */
.group-title {
  margin: 18px 4px 6px; font-size: 13px; color: var(--ios-gray); text-transform: uppercase; letter-spacing: .3px;
}
.group { background: var(--ios-cell); border-radius: 14px; overflow: hidden; }
.group + .group { margin-top: 18px; }
.cell { display: flex; align-items: center; min-height: 46px; padding: 10px 16px; position: relative; width: 100%; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--ios-hair); }
.field-cell { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; color: var(--ios-gray); }
.card .field-cell input, .card .field-cell .input-prefix { border: 0; background: transparent; padding-left: 0; padding-right: 0; }
.card .field-cell input:focus { box-shadow: none; }
.card .field-cell .input-prefix span { padding-left: 0; }
.cell-label { font-size: 12px; }
.kv { justify-content: space-between; gap: 12px; font-size: 16px; }
.kv span:last-child { color: var(--ios-gray); text-align: right; overflow: hidden; text-overflow: ellipsis; }
.link-cell { color: var(--ios-blue); text-decoration: none; font-size: 16px; }
.danger-cell { border: 0; background: none; color: var(--danger); font-size: 16px; cursor: pointer; justify-content: center; }
.switch-row { margin: 0; }
#form-profile .btn { margin-top: 14px; }

.profile-top { display: none; }
.me-head { display: none; }
.settings-mode.auth { place-items: start center; background: var(--screen); padding: 0; }
.settings-mode .card { max-width: 600px; background: transparent; border: 0; border-radius: 0; padding: 0 16px 32px; }
.settings-mode .profile-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 52px; margin: 0 -8px 6px;
}
.back-link { display: flex; align-items: center; border: 0; background: none; color: var(--ios-blue); font-size: 17px; cursor: pointer; padding: 0; }
.back-link .ico { width: 30px; height: 30px; margin-right: -4px; }
.profile-nav-title { font-size: 17px; font-weight: 700; }
.settings-mode .avatar-edit { flex-direction: column; text-align: center; gap: 8px; margin: 8px 0 4px; }
.settings-mode .avatar.xl { width: 100px; height: 100px; font-size: 36px; }
.settings-mode .me-head { display: block; }
.me-head-name { font-size: 24px; font-weight: 700; }
.me-head-sub { color: var(--ios-gray); font-size: 15px; margin-top: 3px; }
.settings-mode .avatar-actions { flex-direction: row; gap: 18px; }
.settings-mode #profile-title, .settings-mode #profile-hint { display: none; }

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  .back-btn { visibility: visible; }
  .msg { max-width: 82%; }
}
.card input.switch { width: 50px; height: 30px; padding: 0; flex: none; border-radius: 15px; }
.card input.switch::after { width: 26px; height: 26px; top: 1px; left: 1px; }
.card input.switch:checked { background: #34c759; border-color: #34c759; }
.card input.switch:checked::after { transform: translateX(20px); }
.settings-mode .avatar-actions .link { color: var(--ios-blue); }
.settings-mode .avatar-actions .link.danger { color: var(--danger); }
#profile-extra { border-top: 0; margin-top: 6px; padding-top: 0; }
.card label.switch-row { flex-direction: row; align-items: center; gap: 14px; color: var(--text); font-size: 15px; }

/* ================= Этап 1: реакции, закреп, поиск, профиль, эмодзи ================= */
.chat { position: relative; }
button.avatar { border: 0; padding: 0; cursor: pointer; }
.chat-head .peer {
  border: 0; background: none; color: inherit; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; padding: 4px 8px; border-radius: 10px; max-width: 100%;
}
.chat-head .peer-name { display: flex; gap: 4px; align-items: center; max-width: 100%; overflow: hidden; }
.chat-head .peer-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted-ico { font-size: 12px; opacity: .7; }
.head-right { justify-self: end; display: flex; align-items: center; gap: 4px; }
.head-right .nav-icon-btn { width: 38px; height: 38px; display: grid; place-items: center; }
.head-right .nav-icon-btn .ico { fill: var(--ios-blue); }

/* список чатов */
.badge.muted { background: var(--badge-muted); }
.pin-ico { font-size: 13px; opacity: .65; margin-top: 8px; filter: grayscale(1); }
.item.pinned { background: var(--soft); }
.item.pinned:hover { background: var(--hover); }

/* закреплённое сообщение */
.pinned-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; cursor: pointer;
  background: var(--ios-bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--ios-hair);
}
.pb-line { width: 2px; align-self: stretch; border-radius: 1px; background: var(--ios-blue); }
.pb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pb-title { color: var(--ios-blue); font-size: 13.5px; font-weight: 600; }
.pb-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-bar .icon-btn { color: var(--ios-gray); display: grid; place-items: center; }
.pinned-bar .icon-btn .ico { width: 18px; height: 18px; fill: currentColor; }

/* поиск по переписке */
.chat-search {
  display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 12px 0 0;
  background: var(--ios-bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--ios-hair);
}
.chat-search .cs-field { flex: 1; }
.cs-cancel { color: var(--ios-blue); font-size: 16px; }
.cs-nav {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)) 16px;
  background: var(--ios-bar); border-top: 1px solid var(--ios-hair);
}
#cs-count { flex: 1; color: var(--ios-gray); font-size: 15px; }
.cs-nav .icon-btn { display: grid; place-items: center; }
.cs-nav .icon-btn .ico { width: 28px; height: 28px; fill: var(--ios-blue); }
.cs-nav .icon-btn:disabled .ico { fill: var(--muted); }

/* реакции */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.react {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px 0 7px; border-radius: 13px;
  border: 0; cursor: pointer; background: rgba(62,136,247,.18); color: var(--ios-blue); font-size: 13px; font-weight: 600;
}
.react .re { font-size: 15px; }
.react.mine { background: var(--ios-blue); color: #fff; }
.msg.out .react { background: var(--soft-2); color: var(--out-accent); }
.msg.out .react.mine { background: var(--out-accent); color: var(--on-out-accent); }
.msg.has-img .reacts { margin: 6px 6px 2px; }
.react-row { display: flex; gap: 2px; padding: 4px 4px 6px; border-bottom: 1px solid var(--ios-hair); margin-bottom: 4px; }
.msg-menu .react-row button.rr {
  width: 36px; height: 36px; padding: 0; font-size: 22px; border-radius: 50%; display: grid; place-items: center;
  transition: transform .12s;
}
.msg-menu .react-row button.rr:hover { transform: scale(1.2); background: none; }
.msg-menu .react-row button.rr.mine { background: rgba(62,136,247,.35); }

/* поле ввода и эмодзи */
.input-wrap { flex: 1; position: relative; display: flex; }
.input-wrap textarea { flex: 1; padding-right: 40px; }
.emoji-btn {
  position: absolute; right: 4px; bottom: 3px; width: 30px; height: 30px; border: 0; background: none;
  display: grid; place-items: center; cursor: pointer; border-radius: 50%;
}
.emoji-btn .ico { width: 24px; height: 24px; fill: var(--ios-gray); }
.emoji-btn:hover .ico, .emoji-btn.active .ico { fill: var(--ios-blue); }
.emoji-panel {
  height: 290px; display: flex; flex-direction: column; background: var(--ios-bar);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--ios-hair);
}
.ep-grid {
  flex: 1; overflow-y: auto; padding: 4px 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  align-content: start;
}
.ep-title { grid-column: 1 / -1; color: var(--ios-gray); font-size: 12px; text-transform: uppercase; padding: 6px 4px; letter-spacing: .3px; }
.ep-empty { grid-column: 1 / -1; color: var(--ios-gray); padding: 24px; text-align: center; }
.ep-e { width: 40px; height: 40px; border: 0; background: none; font-size: 27px; cursor: pointer; border-radius: 8px; padding: 0; }
.ep-e:hover { background: var(--soft); }
.ep-tabs { display: flex; justify-content: space-around; border-top: 1px solid var(--ios-hair); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
.ep-tabs button { border: 0; background: none; font-size: 20px; padding: 4px 6px; border-radius: 8px; cursor: pointer; opacity: .5; filter: grayscale(.6); }
.ep-tabs button.active { opacity: 1; filter: none; background: var(--soft-2); }

/* профиль собеседника */
.peer-profile {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--bg);
}
.pp-head {
  height: 56px; display: flex; align-items: center; padding: 0 8px; flex: none;
  background: var(--ios-bar); border-bottom: 1px solid var(--ios-hair);
}
.pp-body { flex: 1; overflow-y: auto; padding: 0 16px 32px; width: 100%; max-width: 640px; margin: 0 auto; }
.pp-top { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 0 14px; }
.pp-top .avatar.xl { width: 100px; height: 100px; font-size: 36px; }
.avatar.clickable { cursor: zoom-in; }
.pp-name { font-size: 24px; font-weight: 700; margin-top: 12px; overflow-wrap: anywhere; }
.pp-status { color: var(--ios-gray); font-size: 15px; margin-top: 2px; }
.pp-status.on { color: var(--ios-blue); }
.pp-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.pp-action {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border: 0;
  border-radius: 12px; background: var(--ios-cell); color: var(--ios-blue); font-size: 12px; cursor: pointer;
}
.pp-action:hover { background: var(--hover); }
.pa-ico { font-size: 20px; }
.info-cell { flex-direction: column; align-items: flex-start; gap: 2px; }
.info-cell.clickable { cursor: pointer; }
.info-cell.clickable:hover { background: var(--hover); }
.ic-label { font-size: 13px; color: var(--ios-gray); }
.ic-value { font-size: 16px; overflow-wrap: anywhere; white-space: pre-wrap; }
.pp-seg { display: flex; background: var(--ios-field); border-radius: 9px; padding: 2px; margin: 22px 0 12px; }
.pp-seg button { flex: 1; border: 0; background: none; color: var(--text); padding: 6px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.pp-seg button.active { background: var(--seg-sel); font-weight: 600; }
.pp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border-radius: 10px; overflow: hidden; }
.pp-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; display: block; background: var(--soft); }
.pp-files .att-file { color: var(--text); text-decoration: none; gap: 12px; border-radius: 0; margin: 0; }
.pp-files .file-ico { background: var(--ios-blue); color: #fff; }
.pp-files .file-name { max-width: none; }

/* настройки: о себе и день рождения */
.group-hint { margin: 6px 4px 0; color: var(--ios-gray); }
.card .field-cell input[type=date] { color-scheme: dark; }
.reacts .msg-meta { float: none; margin: 0 0 -2px auto; padding-left: 10px; align-self: flex-end; }

/* ================= Этап 2: пересылка, выбор, блокировка, приватность ================= */
.fwd { font-size: 13.5px; font-weight: 600; color: var(--ios-blue); margin-bottom: 3px; }
.msg.out .fwd { color: var(--out-accent); }
.select-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 56px; padding: 0 16px;
  background: var(--ios-bar); border-bottom: 1px solid var(--ios-hair); font-weight: 600;
}
.select-bar .link { justify-self: start; color: var(--ios-blue); font-size: 16px; }
.select-actions, .blocked-bar {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  background: var(--ios-bar); border-top: 1px solid var(--ios-hair);
}
.select-actions .link { font-size: 16px; color: var(--ios-blue); }
.select-actions .link.danger { color: var(--danger); }
.select-actions .link:disabled { color: var(--muted); }
.blocked-bar { justify-content: center; }
.blocked-bar .link { color: var(--ios-blue); font-size: 16px; }
.chat-view.selecting .compose-bar { display: none; }
.messages .msg.selectable { cursor: pointer; }
.chat-view.selecting .messages { padding-left: 46px; }
.msg.selectable::before {
  content: ""; position: absolute; left: -38px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box;
}
.msg.out.selectable::before { left: auto; right: calc(100% + 14px); }
.msg.selectable.selected::before {
  background: var(--ios-blue) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='white' d='M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>") center / 16px no-repeat;
  border-color: var(--ios-blue);
}
.msg { position: relative; }
.chat-view.selecting .msg.out { margin-left: 0; }
.nav-cell { border: 0; background: none; color: var(--text); cursor: pointer; text-align: left; }
.nav-cell span:last-child::after { content: " ›"; color: var(--ios-gray); }
.nav-cell:hover { background: var(--hover); }
.pp-danger { margin-top: 22px; }
.pp-danger .danger-cell.unblock { color: var(--ios-blue); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.modal-card {
  width: min(420px, 100%); max-height: min(620px, 90dvh); display: flex; flex-direction: column;
  background: var(--ios-cell); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 18px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-head .icon-btn { color: var(--ios-gray); display: grid; place-items: center; }
.modal-head .icon-btn .ico { width: 20px; height: 20px; fill: currentColor; }
.modal-body { overflow-y: auto; padding-bottom: 8px; }
.modal-search {
  width: calc(100% - 32px); margin: 4px 16px 8px; padding: 9px 12px; border-radius: 10px; border: 0;
  background: var(--ios-field); color: var(--text); font-size: 16px; outline: none;
}
.modal .item .link { color: var(--ios-blue); flex-shrink: 0; }

/* ================= Этап 3: альбомы, видео, предпросмотр, обрезка ================= */
.album { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; width: min(360px, 70vw); border-radius: 12px; overflow: hidden; }
.album .album-cell { margin: 0; border-radius: 0; position: relative; }
.album .album-cell .att-img { width: 100%; height: 100%; aspect-ratio: 1 / 1 !important; object-fit: cover; border-radius: 0; display: block; }
.msg.album-msg { padding: 3px; }
.msg.album-msg .msg-text { padding: 4px 8px 0; }
.msg.album-msg > .msg-meta { margin-right: 6px; }
.att-video { position: relative; cursor: pointer; }
.att-video .att-img { display: block; background: #000; }
.att-video .play, .sp-item .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 18px; padding-left: 3px; pointer-events: none;
}
.dur {
  position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 8px; font-size: 12px;
  background: rgba(0,0,0,.55); color: #fff; pointer-events: none;
}
.album .play { width: 34px; height: 34px; font-size: 14px; }
.lightbox video { max-width: 100%; max-height: calc(100dvh - 90px); border-radius: 8px; background: #000; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.08); color: #fff; font-size: 34px; cursor: pointer;
}
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-nav:hover { background: rgba(255,255,255,.16); }
.pp-cell { position: relative; cursor: zoom-in; }
.pp-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--soft); }
.pp-grid img { cursor: inherit; }

/* окно отправки */
.send-card { width: min(460px, 100%); }
.sp-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px 12px 10px; overflow-y: auto; max-height: 52dvh; }
.sp-items.single { grid-template-columns: 1fr; }
.sp-item { position: relative; border-radius: 10px; overflow: hidden; background: var(--ios-field); }
.sp-item img, .sp-item video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.sp-items.single .sp-item img, .sp-items.single .sp-item video { aspect-ratio: auto; max-height: 46dvh; object-fit: contain; }
.sp-item.file { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 10px 70px 10px 12px; }
.sp-item.file .file-ico { width: 42px; height: 42px; border-radius: 50%; background: var(--ios-blue); display: grid; place-items: center; font-size: 18px; flex: none; }
.sp-item .file-info { display: flex; flex-direction: column; min-width: 0; }
.sp-item .file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-item .file-size { font-size: 12px; color: var(--ios-gray); }
.sp-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.sp-tools button {
  width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 13px;
}
.sp-tools button:hover { background: rgba(0,0,0,.8); }
.sp-option { display: flex; align-items: center; gap: 12px; padding: 8px 16px; cursor: pointer; }
.sp-option > span { flex: 1; display: flex; flex-direction: column; font-size: 15px; }
.sp-option small { font-size: 12px; }
.sp-bottom { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 12px; border-top: 1px solid var(--ios-hair); }
.sp-bottom textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px; padding: 9px 12px; border-radius: 12px;
  border: 1px solid transparent; background: var(--ios-field); color: var(--text); font-size: 15px; outline: none;
}
.sp-send { width: auto; padding: 0 18px; height: 40px; margin: 0; }

/* обрезка */
#crop-modal { background: rgba(0,0,0,.92); z-index: 60; padding: 0; }
.crop-card { width: 100%; height: 100%; display: flex; flex-direction: column; }
.crop-stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.crop-box {
  position: absolute; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); border: 2px solid #fff; cursor: move; touch-action: none;
  background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
}
.crop-box i { position: absolute; width: 22px; height: 22px; border: 3px solid #fff; }
.crop-box i[data-h=nw] { left: -4px; top: -4px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.crop-box i[data-h=ne] { right: -4px; top: -4px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.crop-box i[data-h=sw] { left: -4px; bottom: -4px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.crop-box i[data-h=se] { right: -4px; bottom: -4px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.crop-bar { display: flex; justify-content: space-between; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); }
.crop-bar .link { color: #fff; font-size: 16px; }
.crop-bar .link.strong { color: var(--ios-blue); font-weight: 700; }

/* ================= Этап 4: голосовые, стикеры, отложенные ================= */
.mic {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--ios-gray);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.mic .ico { width: 26px; height: 26px; fill: currentColor; }
.mic:hover { color: var(--ios-blue); }
.composer.has-text .mic { display: none; }
.rec-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 16px;
  background: var(--ios-bar); border-top: 1px solid var(--ios-hair); min-height: 50px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: recblink 1s infinite; flex: none; }
@keyframes recblink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 42px; }
.rec-wave { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 2px; height: 36px; overflow: hidden; }
.rec-wave i { width: 3px; border-radius: 2px; background: var(--ios-blue); flex: none; }
.rec-bar .link { color: var(--ios-gray); font-size: 15px; }
.rec-bar .rec-send { display: grid; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice-play {
  width: 42px; height: 42px; border-radius: 50%; border: 0; flex: none; cursor: pointer;
  background: var(--ios-blue); color: #fff; font-size: 15px; display: grid; place-items: center;
}
.msg.out .voice-play { background: var(--out-accent); color: var(--on-out-accent); }
.voice-right { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.voice-bars { display: flex; align-items: flex-end; gap: 2px; height: 26px; cursor: pointer; }
.voice-bars i { width: 3px; border-radius: 2px; background: color-mix(in srgb, var(--ios-blue) 35%, transparent); flex: none; }
.voice-bars i.on { background: var(--ios-blue); }
.msg.out .voice-bars i { background: color-mix(in srgb, var(--out-accent) 35%, transparent); }
.msg.out .voice-bars i.on { background: var(--out-accent); }
.voice-time { font-size: 12px; opacity: .75; }
.msg.voice-msg .msg-meta { margin-top: -14px; }

.msg.sticker-msg, .msg.jumbo { background: none !important; box-shadow: none; padding: 0; }
.msg.sticker-msg::after, .msg.jumbo::after { display: none; }
.sticker-img { width: 160px; height: 160px; display: block; object-fit: contain; }
.msg.sticker-msg .msg-meta, .msg.jumbo .msg-meta {
  float: none; display: inline-flex; margin: 2px 0 0; padding: 1px 7px; border-radius: 10px;
  background: rgba(0,0,0,.35); color: var(--chip-text) !important;
}
.msg.sticker-msg.out, .msg.jumbo.out { text-align: right; }
.msg.jumbo .msg-text { font-size: 52px; line-height: 1.15; }
.msg.sticker-msg .quote, .msg.sticker-msg .fwd { background: rgba(0,0,0,.35); padding: 4px 8px; border-radius: 10px; }

.ep-grid.stickers { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.ep-sticker { border: 0; background: none; padding: 4px; border-radius: 10px; cursor: pointer; }
.ep-sticker:hover { background: var(--soft); }
.ep-sticker img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.ep-tabs .sticker-tab img { width: 22px; height: 22px; display: block; }

.sched-bar {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 14px; border: 0; cursor: pointer; text-align: left;
  background: var(--ios-bar); color: var(--ios-blue); border-bottom: 1px solid var(--ios-hair); font-size: 14px;
}
.sched-bar span:nth-child(2) { flex: 1; }
.sched-bar .chev { color: var(--ios-gray); }
.sched-options { margin: 0 12px; border-radius: 12px; overflow: hidden; background: var(--ios-field); }
.sched-options .cell { justify-content: space-between; }
.sched-custom { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 6px; }
.sched-custom input[type=datetime-local] {
  padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; background: var(--ios-field); color: var(--text); font-size: 15px;
}
.sched-silent { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.sched-custom .btn { margin: 0; }
.sched-item { padding: 10px 16px; border-bottom: 1px solid var(--ios-hair); }
.sched-when { font-size: 13px; color: var(--ios-blue); font-weight: 600; }
.sched-text { margin: 3px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sched-actions { display: flex; gap: 18px; }
.sched-actions .link { font-size: 14px; color: var(--ios-blue); }
.sched-actions .link.danger { color: var(--danger); }

/* ================= Этап 5: группы ================= */
.group-ico { font-size: 13px; }
.service-msg {
  align-self: center; margin: 6px auto; padding: 4px 12px; border-radius: 12px; font-size: 13px; text-align: center;
  background: var(--chip-bg); color: var(--chip-text); max-width: 80%; backdrop-filter: blur(8px);
}
.sender-name { font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.mention { color: var(--ios-blue); cursor: pointer; font-weight: 500; }
.msg.out .mention { color: var(--out-accent); text-decoration: underline; }
.mention.mention-me { background: rgba(62,136,247,.2); border-radius: 4px; padding: 0 2px; }
.mention-suggest {
  max-height: 240px; overflow-y: auto; background: var(--ios-bar); border-top: 1px solid var(--ios-hair);
  backdrop-filter: blur(20px);
}
.ms-item { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; }
.ms-item.active, .ms-item:hover { background: var(--soft); }
.ms-item .avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.ms-name { font-weight: 600; }
.ms-un { color: var(--ios-gray); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.chip { background: var(--ios-blue); color: #fff; border-radius: 14px; padding: 4px 10px; font-size: 14px; cursor: pointer; }
.chips:empty { display: none; }
.pick {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); flex: none;
  display: grid; place-items: center; font-size: 13px; color: #fff;
}
.pick.on { background: var(--ios-blue); border-color: var(--ios-blue); }
.modal-go { margin: 10px 16px 6px; width: calc(100% - 32px); }
.modal-note { padding: 0 16px; }
.modal-area { min-height: 70px; resize: vertical; font-family: inherit; }
.role { color: var(--ios-gray); font-size: 13px; flex: none; }
.pp-members .item { margin: 0; border-radius: 0; }
.pp-members .add-members { color: var(--ios-blue); }
.pp-invite { margin-top: 14px; }
.link-value { color: var(--ios-blue); word-break: break-all; }
.avatar.editable { cursor: pointer; }
.online-text { color: var(--ios-blue) !important; }

/* ================= Этап 6: каналы ================= */
.views { opacity: .85; margin-right: 4px; }
.fwd.clickable { cursor: pointer; }
.channel-about { margin-top: 8px; color: var(--muted); text-align: center; white-space: pre-wrap; }
#channel-bar .link { color: var(--ios-blue); font-size: 16px; }

/* =====================================================================
   Темы: тёмная и светлая, как в Telegram. По умолчанию — как в системе,
   выбор вручную ставит <html data-theme="light|dark">.
   ===================================================================== */
:root, :root[data-theme="dark"] {
  --accent: #3798ff;
  --accent-2: #5ad9ff;
  --accent-grad: linear-gradient(135deg, #55cfff, #2678ff);
  --link: #62c4ff;
  --screen: #080d17;
  --bg: #0b111c;
  --panel: #0f1828;
  --panel-2: #142133;
  --text: #edf4ff;
  --muted: #8191a9;
  --border: #1c2a3e;
  --hover: #121e2e;
  --active: #142b47;
  --seg-sel: #142944;
  --bubble-in: #141f2e;
  --bubble-in-2: #111a27;
  --bubble-in-border: #243247;
  --bubble-out: #1765c7;
  --bubble-out-2: #1455b2;
  --bubble-out-border: #277ee4;
  --chat-bg: #080d17;
  --chat-dots: rgba(55, 152, 255, .05);
  --danger: #ff5a6e;
  --online: #45d6a4;
  --ios-bar: rgba(11, 19, 32, .94);
  --ios-hair: #1c2a3e;
  --ios-gray: #8191a9;
  --ios-field: #101a29;
  --ios-cell: #0f1828;
  --ios-blue: #3798ff;
  --out-text: #ffffff;
  --out-meta: #b9dcff;
  --out-accent: #ffffff;
  --on-out-accent: #1765c7;
  --in-meta: #8295ae;
  --soft: rgba(255, 255, 255, .05);
  --soft-2: rgba(255, 255, 255, .1);
  --chip-bg: #101d2e;
  --chip-text: #879ab4;
  --badge-muted: #33445c;
  --menu-bg: rgba(16, 26, 41, .98);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --accent: #287df0;
  --accent-2: #149ed4;
  --accent-grad: linear-gradient(135deg, #328df7, #176bdb);
  --link: #176fdb;
  --screen: #f4f7fb;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --text: #142238;
  --muted: #74839a;
  --border: #e5ebf3;
  --hover: #f0f5fc;
  --active: #e7f2ff;
  --seg-sel: #eaf4ff;
  --bubble-in: #ffffff;
  --bubble-in-2: #f8faff;
  --bubble-in-border: #e2e9f2;
  --bubble-out: #328df7;
  --bubble-out-2: #176bdb;
  --bubble-out-border: #287de5;
  --chat-bg: #eef3fa;
  --chat-dots: rgba(40, 125, 240, .06);
  --danger: #e6536c;
  --online: #17a979;
  --ios-bar: rgba(255, 255, 255, .94);
  --ios-hair: #e5ebf3;
  --ios-gray: #8492a7;
  --ios-field: #f5f8fc;
  --ios-cell: #ffffff;
  --ios-blue: #287df0;
  --out-text: #ffffff;
  --out-meta: #d4e8ff;
  --out-accent: #ffffff;
  --on-out-accent: #176bdb;
  --in-meta: #8b9bb0;
  --soft: rgba(20, 34, 56, .05);
  --soft-2: rgba(255, 255, 255, .18);
  --chip-bg: #edf3fa;
  --chip-text: #71839b;
  --badge-muted: #b8c3d1;
  --menu-bg: rgba(255, 255, 255, .98);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
  --accent: #287df0;
  --accent-2: #149ed4;
  --accent-grad: linear-gradient(135deg, #328df7, #176bdb);
  --link: #176fdb;
  --screen: #f4f7fb;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --text: #142238;
  --muted: #74839a;
  --border: #e5ebf3;
  --hover: #f0f5fc;
  --active: #e7f2ff;
  --seg-sel: #eaf4ff;
  --bubble-in: #ffffff;
  --bubble-in-2: #f8faff;
  --bubble-in-border: #e2e9f2;
  --bubble-out: #328df7;
  --bubble-out-2: #176bdb;
  --bubble-out-border: #287de5;
  --chat-bg: #eef3fa;
  --chat-dots: rgba(40, 125, 240, .06);
  --danger: #e6536c;
  --online: #17a979;
  --ios-bar: rgba(255, 255, 255, .94);
  --ios-hair: #e5ebf3;
  --ios-gray: #8492a7;
  --ios-field: #f5f8fc;
  --ios-cell: #ffffff;
  --ios-blue: #287df0;
  --out-text: #ffffff;
  --out-meta: #d4e8ff;
  --out-accent: #ffffff;
  --on-out-accent: #176bdb;
  --in-meta: #8b9bb0;
  --soft: rgba(20, 34, 56, .05);
  --soft-2: rgba(255, 255, 255, .18);
  --chip-bg: #edf3fa;
  --chip-text: #71839b;
  --badge-muted: #b8c3d1;
  --menu-bg: rgba(255, 255, 255, .98);
  color-scheme: light;
  }
}
.msg.out a { color: var(--out-accent); }
.msg { box-shadow: 0 1px 1px rgba(0, 0, 0, .08); }
.theme-seg { display: flex; gap: 4px; padding: 4px; margin: 0; border-radius: 14px; background: var(--ios-cell); }
.theme-seg button {
  flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 9px; cursor: pointer;
  color: var(--text); font-size: 14px;
}
.theme-seg button.active { background: var(--seg-sel); color: var(--link); font-weight: 600; }

/* ---------- звонок ---------- */
.call {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--screen) 86%, transparent); backdrop-filter: blur(18px);
}
.call-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 36px 24px 28px; border-radius: 28px; background: var(--ios-cell); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.call-avatar { width: 112px; height: 112px; font-size: 40px; margin-bottom: 8px; }
.call-name { font-size: 24px; font-weight: 700; text-align: center; }
.call-status { color: var(--muted); font-size: 15px; min-height: 20px; font-variant-numeric: tabular-nums; }
.call.ringing .call-avatar { animation: callpulse 1.6s ease-out infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 26px transparent; } }
.call-actions { display: flex; gap: 22px; margin-top: 26px; }
.call-btn {
  width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none;
  color: var(--text); cursor: pointer; padding: 0;
}
.call-btn .ico {
  width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: var(--soft-2); fill: var(--text); box-sizing: border-box;
}
.call-btn small { font-size: 12px; color: var(--muted); }
.call-btn.on .ico { background: var(--text); fill: var(--ios-cell); }
.call-btn.accept .ico { background: #34c759; fill: #fff; }
.call-btn.hangup .ico { background: #ff3b30; fill: #fff; }
.msg-service.call-line { cursor: default; }

.delete-form { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
.delete-form .code-input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--ios-field); outline: none; }

/* ---------- макет 2026: пузыри без хвостиков, вкладки-«пилюли», поле ввода ---------- */
.msg { background: linear-gradient(145deg, var(--bubble-in), var(--bubble-in-2)); border: 1px solid var(--bubble-in-border);
  border-radius: 16px; box-shadow: none; }
.msg .msg-meta { color: var(--in-meta); }
.msg.out { background: linear-gradient(135deg, var(--bubble-out), var(--bubble-out-2)); border-color: var(--bubble-out-border); }
.msg.group-end.out { border-bottom-right-radius: 5px; }
.msg.group-end:not(.out) { border-bottom-left-radius: 5px; }
.msg.group-end::after { display: none; }
.msg.sticker-msg, .msg.jumbo { background: none; border-color: transparent; }
.chat-tabs { gap: 6px; padding: 4px 12px 10px; border-bottom: 1px solid var(--ios-hair); }
.tab { border: 1px solid transparent; border-radius: 999px; padding: 6px 13px; margin: 0; background: var(--panel-2);
  color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.tab.active { background: var(--seg-sel); color: var(--link); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; display: inline-grid; place-items: center; }
.item { border-radius: 12px; margin: 2px 6px; }
.item::after { display: none; }
.item.active { background: var(--active); }
.badge { background: var(--accent); }
.attach { width: 36px; height: 36px; border: 1.5px solid var(--accent); border-radius: 50%; color: var(--accent); margin-bottom: 3px; }
.attach .ico { width: 22px; height: 22px; transform: none; }
.composer { background: var(--bg); }
.composer textarea { border-radius: 16px; background: var(--ios-field); border: 1px solid var(--ios-hair); min-height: 42px; padding: 10px 14px; }
.send { width: 40px; height: 40px; background: var(--accent-grad); }
.day { background: var(--chip-bg); color: var(--chip-text); border: 1px solid var(--ios-hair); }

/* ---------- жалобы и модерация ---------- */
.report-reasons { margin: 10px 0; }
.report-reason { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none; cursor: pointer; font-size: 15px; color: inherit; }
.report-reason.on { color: var(--accent, #3798ff); font-weight: 600; }
.report-reason.on::after { content: '✓'; float: right; }
.report-comment { width: 100%; box-sizing: border-box; border-radius: 12px; padding: 10px 12px; margin: 4px 0 12px; resize: vertical;
  background: var(--ios-field, rgba(127,127,127,.12)); color: inherit; border: 1px solid var(--ios-hair, rgba(127,127,127,.2)); font: inherit; }
.modal-card.wide { width: min(720px, 100%); max-height: 92dvh; }
.modal-body .pp-seg { margin-bottom: 10px; }
.mod-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.mod-card { border: 1px solid var(--ios-hair, rgba(127,127,127,.2)); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.mod-row { flex-direction: row; align-items: center; justify-content: space-between; }
.mod-head { display: flex; gap: 8px; align-items: center; }
.mod-reason { font-weight: 700; font-size: 15px; }
.mod-count { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(230,83,108,.18); color: #e6536c; }
.mod-meta { font-size: 12px; color: var(--ios-gray, #8b9bb0); }
.mod-quote { border-left: 3px solid var(--accent, #3798ff); padding: 6px 10px; border-radius: 6px; background: rgba(127,127,127,.08); white-space: pre-wrap; word-break: break-word; }
.mod-img { display: block; max-width: 220px; max-height: 220px; border-radius: 8px; margin-top: 6px; }
.mod-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mod-done { font-size: 13px; color: var(--ios-gray, #8b9bb0); font-style: italic; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { background: var(--danger, #e6536c); box-shadow: none; }

/* ---------- согласие с документами ---------- */
.consent { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(circle at 50% 0%, rgba(55,152,255,.35), transparent 60%), var(--bg, #080d17); }
.consent-card { width: min(440px, 100%); text-align: center; }
.consent-logo svg { width: 84px; height: 84px; filter: drop-shadow(0 8px 30px rgba(55,152,255,.6)); }
.consent-card h2 { margin: 14px 0 6px; font-size: 24px; }
.consent-checks { background: var(--ios-cell, #111a2a); border-radius: 18px; margin: 22px 0 6px; text-align: left; overflow: hidden; }
.consent-line { display: flex; gap: 14px; align-items: center; padding: 15px 16px; cursor: pointer; font-size: 15px; }
.consent-line + .consent-line { border-top: 1px solid var(--ios-hair, rgba(127,127,127,.2)); }
.consent-line input { width: 22px; height: 22px; accent-color: var(--accent, #3798ff); flex: none; }
.consent-line a, .consent-policy { color: var(--accent, #3798ff); font-weight: 600; }
.consent-policy { display: inline-block; margin: 8px 0 4px; font-size: 14px; font-weight: 500; }
.consent .btn { width: 100%; margin-top: 16px; font-size: 16px; }
.consent .link { background: none; border: 0; color: var(--ios-gray, #8b9bb0); margin-top: 14px; cursor: pointer; font-size: 15px; }
a.doc-link { text-decoration: none; color: inherit; }

/* ---------- папки и архив ---------- */
.chat-tabs { overflow-x: auto; scrollbar-width: none; }
.chat-tabs .tab { white-space: nowrap; flex: none; }
.chat-tabs .tab-count { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--accent, #3798ff); color: #fff; }
.chat-tabs .tab-edit { margin-left: auto; opacity: .75; }
.archive-av { display: grid; place-items: center; font-size: 22px; background: linear-gradient(135deg, #8e99a4, #5f6b78) !important; }
.badge.muted { background: var(--ios-gray, #8b9bb0); }
.folder-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.folder-main { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; min-width: 0; }
.folder-emoji { font-size: 22px; width: 30px; text-align: center; }
.folder-title { font-weight: 600; }
.icon-btn.small { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(127,127,127,.12); color: inherit; cursor: pointer; }
.link-cell { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--accent, #3798ff); padding: 13px 14px; cursor: pointer; font-size: 15px; }
.folder-name { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px; font: inherit; font-size: 16px; color: inherit;
  background: var(--ios-field, rgba(127,127,127,.12)); border: 1px solid var(--ios-hair, rgba(127,127,127,.2)); margin: 4px 0 10px; }
.folder-emojis { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.femoji { width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; background: rgba(127,127,127,.12); font-size: 18px; cursor: pointer; }
.femoji.on { border-color: var(--accent, #3798ff); background: rgba(55,152,255,.2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; cursor: pointer; }
.folder-chats { max-height: 260px; overflow: auto; }
.folder-chat { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; }
.avatar.small { width: 32px; height: 32px; font-size: 13px; }
.modal-body > .btn { width: 100%; margin-top: 12px; }

/* ---------- этап 5: оформление, превью, кружки, черновики ---------- */
.draft-label { color: var(--danger, #e6536c); }
.msg-text b { font-weight: 700; }
.fmt-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; padding: 1px 5px; border-radius: 5px; background: rgba(127,127,127,.18); }
.fmt-pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; white-space: pre-wrap; margin: 4px 0; padding: 8px 10px; border-radius: 8px; background: rgba(127,127,127,.16); }
.spoiler { background: rgba(139,155,176,.6); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s, background .2s; }
.spoiler.shown { color: inherit; background: rgba(127,127,127,.12); cursor: text; }
.msg-link { color: inherit; text-decoration: underline; word-break: break-all; }
.msg.in .msg-link { color: var(--accent, #3798ff); }
.link-preview { display: block; margin: 6px 0 2px; padding: 6px 10px; border-left: 3px solid currentColor; border-radius: 6px;
  background: rgba(127,127,127,.12); color: inherit; text-decoration: none; max-width: 320px; }
.msg.in .link-preview { border-left-color: var(--accent, #3798ff); background: rgba(55,152,255,.08); }
.lp-site { font-weight: 700; font-size: 13px; }
.msg.in .lp-site { color: var(--accent, #3798ff); }
.lp-title { font-weight: 600; font-size: 14px; }
.lp-desc { font-size: 13px; opacity: .85; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lp-img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 6px; margin-top: 6px; }
.voice-meta { display: flex; align-items: center; gap: 8px; }
.voice-speed { border: 0; border-radius: 8px; padding: 1px 6px; font-size: 11px; font-weight: 700; cursor: pointer; background: currentColor; }
.voice-speed { color: inherit; background: rgba(127,127,127,.25); }
.voice-speed.hidden { display: none; }
.round { position: relative; width: 220px; height: 220px; border-radius: 50%; overflow: hidden; cursor: pointer; background: #000;
  box-shadow: 0 0 0 3px rgba(255,255,255,.15); --p: 0; }
.round-video { width: 100%; height: 100%; object-fit: cover; }
.round-play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.45); color: #fff; font-size: 22px; pointer-events: none; }
.round.playing .round-play { display: none; }
.round-time { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; color: #fff;
  background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 10px; pointer-events: none; }
.round.playing { box-shadow: 0 0 0 3px #fff; }

/* ---------- этап 6: управление группой, комментарии ---------- */
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.slow-select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--ios-hair, rgba(127,127,127,.3)); background: transparent; color: inherit; }
.cm-btn { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 0; border-top: 1px solid rgba(127,127,127,.2);
  background: none; color: var(--accent, #3798ff); font-weight: 600; font-size: 14px; text-align: left; cursor: pointer; }
.cm-post { padding: 10px 14px; border-radius: 14px; background: rgba(127,127,127,.1); margin-bottom: 10px; }
.cm-title { font-weight: 700; color: var(--accent, #3798ff); font-size: 14px; margin-bottom: 4px; }
.cm-list { display: flex; flex-direction: column; gap: 6px; max-height: 50dvh; overflow: auto; padding: 4px 0; }
.cm-row { align-self: flex-start; max-width: 80%; padding: 6px 12px; border-radius: 14px; background: rgba(127,127,127,.12); }
.cm-row.mine { align-self: flex-end; background: var(--accent-grad, #3798ff); color: #fff; }
.cm-name { font-weight: 700; font-size: 13px; color: var(--accent, #3798ff); }
.cm-time { font-size: 11px; opacity: .6; text-align: right; }
.cm-form { display: flex; gap: 8px; margin-top: 10px; }
.cm-form .folder-name { margin: 0; }
.cm-form .btn { width: auto; margin: 0; padding: 0 16px; }

/* ---------- видеозвонок ---------- */
.call-remote, .call-local { position: absolute; background: #000; object-fit: cover; }
.call-remote { inset: 0; width: 100%; height: 100%; z-index: 0; }
.call-local { right: 16px; top: 16px; width: 160px; height: 120px; border-radius: 14px; z-index: 2; cursor: pointer;
  box-shadow: 0 8px 30px rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.25); }
.call-local.big { inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; z-index: 0; cursor: default; }
.call-local.mirror { transform: scaleX(-1); }
.call.swapped .call-remote:not(.hidden) { inset: auto; right: 16px; top: 16px; width: 160px; height: 120px; border-radius: 14px; z-index: 2; }
.call.swapped .call-local:not(.big) { inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; z-index: 0; }
.call.video { background: #000; }
.call.video .call-card { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: rgba(0,0,0,.45); backdrop-filter: blur(12px); color: #fff; padding: 14px 20px; max-width: 520px; width: auto; }
.call.video .call-avatar { display: none; }
.call.video .call-name { font-size: 18px; }
.call.video .call-status, .call.video .call-btn small { color: rgba(255,255,255,.75); }
.call.video .call-btn .ico { background: rgba(255,255,255,.18); fill: #fff; }
.call.video .call-btn.on .ico { background: #fff; fill: #1b3a5c; }
.call.video .call-btn.hangup .ico { background: #ff3b30; }
.call.video .call-actions { margin-top: 10px; }
.call-btn.hidden { display: none; }

/* ---------- опросы ---------- */
.poll { min-width: 240px; max-width: 320px; padding: 2px 0 4px; }
.poll-q { font-weight: 600; font-size: 15px; }
.poll-kind { font-size: 12px; opacity: .65; margin: 1px 0 8px; }
.poll-opt { display: flex; gap: 10px; align-items: flex-start; padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.poll-opt.res { cursor: default; }
.poll-opt:not(.res):hover { background: var(--hover); }
.poll-mark { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; opacity: .5; flex: none; margin-top: 1px; }
.poll-mark.sq { border-radius: 5px; }
.poll-opt.picked .poll-mark { background: var(--accent); border-color: var(--accent); opacity: 1; }
.poll-pct { width: 44px; flex: none; white-space: nowrap; font-weight: 600; font-size: 14px; }
.poll-body { flex: 1; min-width: 0; }
.poll-text { display: flex; gap: 6px; align-items: center; word-break: break-word; }
.poll-check { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; }
.poll-opt.right .poll-check { background: #34c759; }
.poll-opt.wrong .poll-check { background: #ff453a; }
.poll-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 15%, transparent); margin-top: 5px; overflow: hidden; }
.poll-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.msg.out .poll-bar i { background: var(--out-accent, var(--accent)); }
.poll-opt.right .poll-bar i { background: #34c759; }
.poll-opt.wrong .poll-bar i { background: #ff453a; }
.poll-voters { font-size: 12px; opacity: .65; margin-top: 3px; }
.poll-vote { width: 100%; margin-top: 6px; padding: 8px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font: 600 14px var(--font); cursor: pointer; }
.poll-vote:disabled { opacity: .5; cursor: default; }
.poll-expl { margin-top: 6px; font-size: 14px; }
.poll-foot { margin-top: 6px; font-size: 12px; opacity: .65; }
.poll-edit { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.poll-edit-row { display: flex; gap: 8px; align-items: center; }
.poll-edit-row .field { flex: 1; margin: 0; }
.poll-correct { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--muted); background: transparent; color: transparent; cursor: pointer; }
.poll-correct.on { background: #34c759; border-color: #34c759; color: #fff; }
#modal-body > .field { margin-bottom: 10px; }
#modal-body > .group { margin: 10px 0; }

/* ---------- геопозиция ---------- */
.loc { width: 270px; max-width: 100%; padding-bottom: 4px; }
.loc-map { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px; height: 140px; border-radius: 12px; overflow: hidden; background: #d9e2ea; }
.loc-map i { border-radius: 3px; background: #f4f7fa; }
.loc-map i.park { background: #cde8c9; }
.loc-map i.water { background: #b9daf2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .loc-map { background: #31455b; }
  :root:not([data-theme="light"]) .loc-map i { background: #263749; }
  :root:not([data-theme="light"]) .loc-map i.park { background: #26473a; }
  :root:not([data-theme="light"]) .loc-map i.water { background: #1f3b57; }
}
:root[data-theme="dark"] .loc-map { background: #31455b; }
:root[data-theme="dark"] .loc-map i { background: #263749; }
:root[data-theme="dark"] .loc-map i.park { background: #26473a; }
:root[data-theme="dark"] .loc-map i.water { background: #1f3b57; }
.loc-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -85%); color: #e5484d; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.loc-pin.live { color: var(--accent); }
.loc-pin.live::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--accent); opacity: .5; animation: loc-pulse 1.4s infinite; }
@keyframes loc-pulse { from { transform: scale(.6); opacity: .6; } to { transform: scale(3); opacity: 0; } }
.loc-info { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.loc-txt { flex: 1; display: flex; flex-direction: column; }
.loc-txt small { opacity: .65; font-size: 12px; }
.loc-stop { border: 0; background: transparent; color: var(--danger); font: 600 14px var(--font); cursor: pointer; padding: 6px; }
.loc-preview { width: 100%; margin-bottom: 8px; }
.loc-live-btns { display: flex; gap: 8px; }
.loc-live-btns .btn { flex: 1; margin: 0; }
#modal-body > .btn { width: 100%; margin-top: 10px; }

/* ---------- истории ---------- */
.stories-row { display: flex; gap: 4px; overflow-x: auto; padding: 4px 10px 8px; scrollbar-width: none; }
.stories-row::-webkit-scrollbar { display: none; }
.stories-row:empty { display: none; }
.story-bubble { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--text); cursor: pointer; padding: 2px 0; border-radius: 12px; font: inherit; }
.story-bubble:hover { background: var(--hover); }
.story-bubble small { font-size: 12px; max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-bubble.seen small { color: var(--muted); }
.story-ring { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; padding: 3px; }
.story-bubble.unseen .story-ring { background: conic-gradient(#3d8bff, #7b5cff, #2bc3ff, #3d8bff); }
.story-bubble.unseen.close .story-ring { background: conic-gradient(#34c759, #8be36b, #34c759); }
.story-bubble.seen .story-ring { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.story-av { width: 50px !important; height: 50px !important; box-shadow: 0 0 0 2px var(--panel, var(--bg)); }
.story-plus { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; box-shadow: 0 0 0 2px var(--panel, var(--bg)); }
.story-preview { display: block; width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; background: #000; margin-bottom: 10px; }
.story-aud { display: flex; gap: 8px; margin: 10px 0 4px; }
.story-aud button { flex: 1; padding: 9px; border-radius: 18px; border: 1px solid var(--border); background: transparent; color: var(--text); font: 500 14px var(--font); cursor: pointer; }
.story-aud button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.story-view { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.92); display: grid; place-items: center; }
.sv-card { position: relative; width: min(420px, 100vw); height: min(760px, 100vh); background: #000; border-radius: 14px; overflow: hidden; color: #fff; }
@media (max-width: 600px) { .sv-card { border-radius: 0; } }
.sv-stage { position: absolute; inset: 0; }
.sv-media { width: 100%; height: 100%; object-fit: contain; }
.sv-zone { position: absolute; top: 0; bottom: 0; cursor: pointer; }
.sv-zone.prev { left: 0; width: 33%; }
.sv-zone.next { right: 0; width: 67%; }
.sv-bars { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 3px; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #fff; }
.sv-head { position: absolute; top: 18px; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: linear-gradient(rgba(0,0,0,.45), transparent); }
.sv-head .avatar { width: 36px; height: 36px; font-size: 14px; }
.sv-who { flex: 1; display: flex; flex-direction: column; }
.sv-who small { opacity: .75; font-size: 12px; }
.sv-btn { border: 0; background: transparent; color: #fff; font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.sv-btn:hover { background: rgba(255,255,255,.15); }
.sv-foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 14px; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.sv-caption { margin-bottom: 10px; font-size: 15px; white-space: pre-wrap; }
.sv-views { border: 0; border-radius: 18px; padding: 8px 14px; background: rgba(255,255,255,.18); color: #fff; font: 14px var(--font); cursor: pointer; }
.sv-react { display: flex; justify-content: space-around; }
.sv-react button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); font-size: 22px; cursor: pointer; }
.sv-react button.on { background: rgba(255,255,255,.4); }
.sv-r { font-size: 20px; }
.cf-list { max-height: 50vh; overflow: auto; margin: 8px 0; }
.cf-row { margin: 0; }
.cf-row input { width: 20px; height: 20px; }

/* ---------- боты ---------- */
.bot-kb { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; min-width: 220px; }
.bot-kb-row { display: flex; gap: 4px; }
.bot-kb-btn { flex: 1; min-height: 34px; padding: 6px 8px; border: 0; border-radius: 8px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.out .bot-kb-btn { background: rgba(255,255,255,.18); color: inherit; }
.bot-kb-btn:disabled { opacity: .6; }
.bot-token { display: block; padding: 10px; border-radius: 10px; background: var(--ios-field, var(--hover)); word-break: break-all; font-size: 13px; margin: 8px 0; user-select: all; }
.bots-list { margin-bottom: 12px; }
.bot-row { cursor: default; margin: 0; }
.bot-row .link { font-size: 13px; white-space: nowrap; }
.bot-new .field { margin-bottom: 8px; }
.item-text.danger { color: var(--danger); }
.modal-text { padding: 4px 4px 8px; font-size: 15px; white-space: pre-wrap; }

/* ---------- групповой звонок ---------- */
.gcall-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: color-mix(in srgb, #34c759 14%, var(--panel, var(--bg))); border-bottom: 1px solid var(--border); }
.gcb-dot { width: 10px; height: 10px; border-radius: 50%; background: #34c759; animation: gcb 1.4s infinite; flex: none; }
@keyframes gcb { 50% { opacity: .35; } }
.gcb-text { flex: 1; font-size: 14px; }
.gcall { position: fixed; inset: 0; z-index: 75; background: #0b1119; color: #fff; display: flex; flex-direction: column; }
.gc-top { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px; }
.gc-top span { opacity: .6; font-size: 13px; }
.gc-grid { flex: 1; display: grid; gap: 8px; padding: 0 12px; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.gc-grid[data-n="1"] { grid-template-columns: 1fr; }
.gc-grid[data-n="2"] { grid-template-columns: 1fr 1fr; }
.gc-grid[data-n="5"], .gc-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
.gc-grid[data-n="7"], .gc-grid[data-n="8"] { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .gc-grid, .gc-grid[data-n] { grid-template-columns: 1fr 1fr; } .gc-grid[data-n="1"] { grid-template-columns: 1fr; } }
.gc-tile { position: relative; border-radius: 16px; overflow: hidden; background: #1a2534; display: grid; place-items: center; min-height: 120px; }
.gc-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.gc-tile.video video { opacity: 1; }
.gc-tile.screen video { object-fit: contain; background: #000; }
.gc-tile.video .gc-av { display: none; }
.gc-av { width: 84px !important; height: 84px !important; font-size: 30px !important; }
.gc-name { position: absolute; left: 10px; bottom: 8px; font-size: 13px; padding: 3px 8px; border-radius: 8px; background: rgba(0,0,0,.45); }
.gcall .gc-actions { display: flex; justify-content: center; gap: 22px; padding: 18px 12px 26px; }
.gcall .call-btn small { color: rgba(255,255,255,.7); }
.gcall .call-btn .ico { background: rgba(255,255,255,.14); fill: #fff; }
.gcall .call-btn.off .ico, .gcall .call-btn.on .ico { background: #fff; fill: #0b1119; }
.gcall .call-btn.hangup .ico { background: #ff3b30; fill: #fff; }

/* ---------- статистика ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 6px; }
.stat-tile { padding: 12px; border-radius: 12px; background: var(--ios-field, var(--hover)); display: flex; flex-direction: column; gap: 2px; }
.stat-tile b { font-size: 20px; }
.stat-tile small { color: var(--muted); font-size: 12px; }
.stat-chart { width: 100%; height: auto; display: block; margin: 4px 0 8px; }
.stat-chart .axis { stroke: var(--border); stroke-width: 1; }
.stat-chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.stat-chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.stat-chart .bar { fill: var(--accent); opacity: .85; }
.stat-chart .lbl { font-size: 11px; fill: var(--muted); }
.stat-chart .lbl.end { text-anchor: end; }
.stat-posts { display: flex; flex-direction: column; }
.stat-post { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.stat-post .sp-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-post .sp-num { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted-sub { color: var(--muted); font-size: 13px; margin: 6px 2px; }
.modal-body:has(> .stat-tiles, > .poll-edit, > .story-preview, > .bots-list, > .cf-list, > .loc-preview, > .modal-text, > .muted-sub, > .bot-token, > .sp-pack-grid, > .sp-section) { padding: 0 14px 14px; }
.loc-tiles { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- упоминания, контакт, поиск ---------- */
.badge.mention { background: var(--accent); color: #fff; font-weight: 700; margin-right: 4px; }
.item-text b.hit { color: var(--text); font-weight: 600; }
.mention-btn { position: absolute; right: 18px; bottom: 86px; z-index: 6; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--panel, var(--bg)); color: var(--accent); font: 700 22px var(--font); box-shadow: 0 3px 12px rgba(0,0,0,.2); cursor: pointer; }
.mention-btn::after { content: attr(data-n); position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; }
.contact-card { min-width: 230px; padding: 2px 0 4px; }
.cc-top { display: flex; gap: 10px; align-items: center; }
.cc-text { display: flex; flex-direction: column; min-width: 0; }
.cc-text small { opacity: .65; font-size: 13px; }
.contact-btn { width: 100%; margin-top: 8px; padding: 8px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font: 600 14px var(--font); cursor: pointer; }
.msg.out .contact-btn { background: rgba(255,255,255,.2); color: inherit; }

/* ---------- рисование на фото ---------- */
.draw-modal { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.94); display: flex; flex-direction: column; }
.draw-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; }
.draw-stage canvas { max-width: 100%; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); touch-action: none; cursor: crosshair; border-radius: 6px; }
.draw-bar { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 12px; }
.draw-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); cursor: pointer; }
.draw-color.on { width: 32px; height: 32px; border-color: #fff; }
.draw-actions { display: flex; justify-content: space-between; padding: 10px 16px 18px; }
.draw-btn { border: 0; background: transparent; color: #fff; font: 600 16px var(--font); cursor: pointer; padding: 8px 10px; border-radius: 8px; }
.draw-btn:hover { background: rgba(255,255,255,.12); }
.draw-btn.primary { color: #4da3ff; }

/* вход по QR-коду */
.qr-box { position: relative; width: 240px; height: 240px; margin: 4px auto 6px; border-radius: 18px; background: #fff;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; box-shadow: 0 2px 14px rgba(16,32,63,.12); overflow: hidden; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box .qr-logo { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%, -50%);
  border-radius: 12px; border: 4px solid #fff; background: #fff; }
.qr-box .qr-wait { color: #6b7a90; font-size: 14px; }
.qr-steps { margin: 6px 0 4px; padding-left: 22px; color: var(--text); font-size: 14px; line-height: 1.55; }
.qr-steps li { margin: 2px 0; }
.btn-qr-login, .btn-phone-login { align-self: center; }

/* стикеры: полоска наборов, просмотр набора, «Мои стикеры» */
.sp-bar { flex: 0 0 auto; display: flex; gap: 4px; overflow-x: auto; padding: 4px 8px;
  background: var(--panel); border-bottom: 1px solid var(--ios-hair); scrollbar-width: none; }
.sp-tab { flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; cursor: pointer; display: grid; place-items: center; font-size: 18px; color: var(--ios-gray); }
.sp-tab:hover { background: var(--soft); }
.sp-tab img { width: 30px; height: 30px; object-fit: contain; }
.sp-gear { margin-left: auto; }
.sticker-img { cursor: pointer; }
.sp-pack-grid { padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 4px; max-height: 56vh; overflow-y: auto; margin-bottom: 12px; }
.sp-pack-btn { width: 100%; }
.sp-pack-btn.danger { color: #e5484d; }
.sp-section { color: var(--ios-gray); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; margin: 12px 0 4px; }
.sp-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--ios-hair); }
.sp-row img { width: 46px; height: 46px; object-fit: contain; }
.sp-row-text { flex: 1; min-width: 0; cursor: pointer; }
.sp-row-title { font-weight: 600; }
.sp-move { font-size: 16px; padding: 2px 6px; }
.sp-row .link.danger { color: #e5484d; }
.sp-add { border: 0; border-radius: 14px; padding: 6px 14px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.sp-note { margin-top: 12px; font-size: 13px; }

/* анимированные эмодзи */
.msg.jumbo .msg-text.emoji-anim { display: inline-block; cursor: pointer; transform-origin: 50% 80%; user-select: none; }
.em-beat { animation: em-beat 1s ease-in-out 2; }
.em-laugh { animation: em-laugh .5s ease-in-out 4; }
.em-flame { animation: em-flame .7s ease-in-out 3; transform-origin: 50% 100% !important; }
.em-wave { animation: em-wave .9s ease-in-out 2; transform-origin: 70% 90% !important; }
.em-pop { animation: em-pop .9s cubic-bezier(.2,1.6,.4,1) 1; }
.em-shake { animation: em-shake .4s linear 4; }
.em-sad { animation: em-sad 1.4s ease-in-out 2; }
.em-bounce { animation: em-bounce .8s cubic-bezier(.3,1.6,.5,1) 2; }
.em-sleep { animation: em-sleep 2s ease-in-out 2; }
.em-tilt { animation: em-tilt 1.2s ease-in-out 2; }
@keyframes em-beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.18); } 60% { transform: scale(1); } }
@keyframes em-laugh { 0%,100% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-12deg) translateY(-4px); } 75% { transform: rotate(12deg) translateY(-4px); } }
@keyframes em-flame { 0%,100% { transform: scale(1,1) skewX(0); } 33% { transform: scale(.94,1.12) skewX(4deg); } 66% { transform: scale(1.06,.95) skewX(-4deg); } }
@keyframes em-wave { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-22deg); } 40% { transform: rotate(16deg); } 60% { transform: rotate(-16deg); } 80% { transform: rotate(10deg); } }
@keyframes em-pop { 0% { transform: scale(.3) rotate(-30deg); opacity: .4; } 60% { transform: scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes em-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-4deg); } 75% { transform: translateX(6px) rotate(4deg); } }
@keyframes em-sad { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(6px) rotate(-6deg); } }
@keyframes em-bounce { 0%,100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-18px) scale(1.12); } 70% { transform: translateY(0) scale(.95,1.05); } }
@keyframes em-sleep { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08) rotate(-5deg); } }
@keyframes em-tilt { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-14deg); } 70% { transform: rotate(10deg); } }
.emoji-particle { position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, -50%); animation: em-fly 1.05s ease-out forwards; }
@keyframes em-fly { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(40deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .emoji-anim { animation: none !important; } .emoji-particle { display: none; } }

/* несколько закреплённых: деления слева */
.pb-line.multi { background: none; display: flex; flex-direction: column; gap: 2px; }
.pb-line.multi i { flex: 1; border-radius: 1px; background: color-mix(in srgb, var(--ios-blue) 35%, transparent); }
.pb-line.multi i.on { background: var(--ios-blue); }

/* ---------- этап 1 ---------- */
.composer { position: relative; }
.fmt-bar { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 30; display: flex; gap: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 4px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.fmt-bar button { border: 0; background: none; color: var(--text); min-width: 34px; height: 32px; border-radius: 8px; cursor: pointer; font: 600 15px var(--font); }
.fmt-bar button:hover { background: var(--hover); }
.fmt-bar .fmt-i { font-style: italic; } .fmt-bar .fmt-s { text-decoration: line-through; } .fmt-bar .fmt-code { font-family: monospace; }
.media-spoiler { position: relative; overflow: hidden; }
.media-spoiler > img, .media-spoiler > video { filter: blur(26px) saturate(1.3); transform: scale(1.1); }
.media-spoiler .play, .media-spoiler .dur { display: none; }
.ms-cover { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  background: radial-gradient(circle, rgba(255,255,255,.18) 1px, transparent 1.5px) 0 0/9px 9px, rgba(0,0,0,.25); text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.once-box { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-width: 220px; border-radius: 12px; background: rgba(0,0,0,.08); cursor: pointer; }
.once-box.expired { cursor: default; opacity: .7; }
.once-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed currentColor; font-weight: 700; }
.once-view { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.once-view img, .once-view video { max-width: 100%; max-height: 86vh; user-select: none; -webkit-user-drag: none; }
.once-hint { color: #ddd; margin-top: 12px; font-size: 14px; }
.story-quote { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding: 4px 8px 4px 4px; border-left: 3px solid var(--accent);
  border-radius: 6px; background: rgba(127,127,127,.12); font-size: 13px; cursor: pointer; }
.story-quote img { width: 30px; height: 44px; object-fit: cover; border-radius: 4px; }
.translation { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(127,127,127,.25); cursor: pointer; }
.tr-head { font-size: 12px; opacity: .7; margin-bottom: 2px; }
.voice-tr { border: 0; background: rgba(127,127,127,.18); color: inherit; border-radius: 8px; font: 700 12px var(--font); padding: 4px 6px; cursor: pointer; align-self: center; margin-left: 6px; }
.voice-tr.on { background: var(--accent); color: #fff; }
.voice-wrap { display: flex; flex-direction: column; }
.voice-text { font-size: 14px; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: rgba(127,127,127,.12); }
.ep-tabs .gif-tab { font: 700 12px var(--font); }
.gif-add { grid-column: 1 / -1; border: 1px dashed var(--border); background: none; color: var(--accent); border-radius: 10px; padding: 8px; margin: 6px 4px; cursor: pointer; font: 600 14px var(--font); }
.gif-cell { border: 0; padding: 2px; background: none; border-radius: 8px; cursor: pointer; }
.gif-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.sv-reply { display: flex; gap: 6px; margin-top: 8px; }
.sv-reply input { flex: 1; padding: 9px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.35); color: #fff; font: 14px var(--font); }
.sv-reply-send { border: 0; width: 38px; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.fx-p { position: absolute; transform: translate(-50%, -50%); animation: fx-move 2s ease-out forwards; opacity: 0; }
.fx-conf { width: 10px; height: 16px; border-radius: 3px; }
@keyframes fx-move { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); } 85% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)); } }
.fx-ring { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; border: 6px solid #ff9f43; animation: fx-ring .8s ease-out forwards; }
@keyframes fx-ring { to { transform: scale(18); opacity: 0; } }
.fx-boom { position: absolute; left: 50%; top: 50%; font-size: 120px; transform: translate(-50%, -50%); animation: fx-boom .9s ease-out forwards; }
@keyframes fx-boom { 0% { transform: translate(-50%, -50%) scale(.2); opacity: 1; } 60% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fx-layer { display: none; } }

/* ---------- этап 2: темы, заявки, подписи ---------- */
.topic-bar { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--ios-bar); border-bottom: 1px solid var(--ios-hair); font-size: 14px; }
.topic-bar .topic-name { font-weight: 600; }
.topics { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.topic-new { align-self: flex-start; margin-bottom: 8px; }
.topic-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; background: var(--panel); }
.topic-row:hover { background: var(--hover); }
.topic-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--soft-2, rgba(127,127,127,.15)); font-size: 20px; font-weight: 700; color: var(--accent); }
.topic-body { flex: 1; min-width: 0; }
.topic-top { display: flex; gap: 6px; align-items: center; }
.topic-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-time { font-size: 12px; color: var(--muted); }
.topic-last { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-row .badge { min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; padding: 0 6px; }
.post-author { font-size: 12px; opacity: .7; text-align: right; margin-top: 2px; font-style: italic; }
.jr-btns { display: flex; gap: 6px; }
.composer.hidden { display: none !important; }

/* ---------- этап 3: обои чата, свои стикеры, аккаунты ---------- */
.chat[data-wc="blue"], .wp-preview[data-wc="blue"] { --chat-bg: #cfe0f7; }
.chat[data-wc="green"], .wp-preview[data-wc="green"] { --chat-bg: #d4efdc; }
.chat[data-wc="purple"], .wp-preview[data-wc="purple"] { --chat-bg: #e2d8f6; }
.chat[data-wc="pink"], .wp-preview[data-wc="pink"] { --chat-bg: #f7d9e6; }
.chat[data-wc="orange"], .wp-preview[data-wc="orange"] { --chat-bg: #f8e2c9; }
.chat[data-wc="teal"], .wp-preview[data-wc="teal"] { --chat-bg: #cdeeea; }
.chat[data-wc="gray"], .wp-preview[data-wc="gray"] { --chat-bg: #e1e4e8; }
:root[data-theme="dark"] .chat[data-wc="blue"], :root[data-theme="dark"] .wp-preview[data-wc="blue"] { --chat-bg: #0c1a33; }
:root[data-theme="dark"] .chat[data-wc="green"], :root[data-theme="dark"] .wp-preview[data-wc="green"] { --chat-bg: #0b2219; }
:root[data-theme="dark"] .chat[data-wc="purple"], :root[data-theme="dark"] .wp-preview[data-wc="purple"] { --chat-bg: #1c1233; }
:root[data-theme="dark"] .chat[data-wc="pink"], :root[data-theme="dark"] .wp-preview[data-wc="pink"] { --chat-bg: #2d1020; }
:root[data-theme="dark"] .chat[data-wc="orange"], :root[data-theme="dark"] .wp-preview[data-wc="orange"] { --chat-bg: #2b1a0a; }
:root[data-theme="dark"] .chat[data-wc="teal"], :root[data-theme="dark"] .wp-preview[data-wc="teal"] { --chat-bg: #0a2523; }
:root[data-theme="dark"] .chat[data-wc="gray"], :root[data-theme="dark"] .wp-preview[data-wc="gray"] { --chat-bg: #16181c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chat[data-wc="blue"], :root:not([data-theme="light"]) .wp-preview[data-wc="blue"] { --chat-bg: #0c1a33; }
  :root:not([data-theme="light"]) .chat[data-wc="green"], :root:not([data-theme="light"]) .wp-preview[data-wc="green"] { --chat-bg: #0b2219; }
  :root:not([data-theme="light"]) .chat[data-wc="purple"], :root:not([data-theme="light"]) .wp-preview[data-wc="purple"] { --chat-bg: #1c1233; }
  :root:not([data-theme="light"]) .chat[data-wc="pink"], :root:not([data-theme="light"]) .wp-preview[data-wc="pink"] { --chat-bg: #2d1020; }
  :root:not([data-theme="light"]) .chat[data-wc="orange"], :root:not([data-theme="light"]) .wp-preview[data-wc="orange"] { --chat-bg: #2b1a0a; }
  :root:not([data-theme="light"]) .chat[data-wc="teal"], :root:not([data-theme="light"]) .wp-preview[data-wc="teal"] { --chat-bg: #0a2523; }
  :root:not([data-theme="light"]) .chat[data-wc="gray"], :root:not([data-theme="light"]) .wp-preview[data-wc="gray"] { --chat-bg: #16181c; }
}
.wp-preview { background: radial-gradient(var(--chat-dots) 1px, transparent 1.3px) 0 0 / 22px 22px, var(--chat-bg); }
.chat[data-wp="none"], .wp-preview[data-wp="none"] { background: var(--chat-bg); }
.chat[data-wp="geometry"], .wp-preview[data-wp="geometry"] {
  background: linear-gradient(45deg, var(--chat-dots) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(-45deg, var(--chat-dots) 1px, transparent 1px) 0 0 / 28px 28px, var(--chat-bg);
}
.chat[data-wp="space"], .wp-preview[data-wp="space"] {
  background: radial-gradient(var(--chat-dots) 1.5px, transparent 2px) 0 0 / 61px 53px,
    radial-gradient(var(--chat-dots) 1px, transparent 1.4px) 17px 29px / 37px 41px,
    radial-gradient(var(--chat-dots) 2px, transparent 2.5px) 40px 9px / 97px 89px, var(--chat-bg);
}
.wp-preview { border-radius: 14px; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; min-height: 120px; }
.wp-bubble { max-width: 75%; padding: 6px 12px; border-radius: 16px; font-size: 14px; }
.wp-bubble.in { align-self: flex-start; background: var(--bubble-in, #fff); color: var(--text); }
.wp-bubble.out { align-self: flex-end; background: var(--bubble-out, #d9f2ff); color: var(--text); }
.wp-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.wp-chip { border: 1px solid var(--ios-hair); background: var(--panel); color: var(--text); border-radius: 14px; padding: 5px 11px; cursor: pointer; font: inherit; font-size: 13px; }
.wp-chip.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.wp-color { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ios-hair); cursor: pointer; }
.wp-color.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.sp-make { margin: 4px 0 10px; }
.my-st { position: relative; }
.my-st-x { position: absolute; top: 0; right: 0; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 12px; }
.my-st-emo { position: absolute; left: 2px; bottom: 2px; font-size: 14px; }
.my-st-emoji { margin-top: 10px; }
.my-st-tools { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.acc-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.acc-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.acc-name { font-weight: 600; }
.acc-check { color: var(--accent); font-weight: 700; }
.modal-text input.field, .my-st-emoji { width: 100%; box-sizing: border-box; padding: 11px 14px; border-radius: 12px; font: inherit; font-size: 15px; color: inherit;
  background: var(--ios-field, rgba(127,127,127,.12)); border: 1px solid var(--ios-hair, rgba(127,127,127,.2)); margin: 4px 0 8px; }

/* ---------- этап 4: цитаты, ответ из другого чата, непрочитанное, фильтры поиска ---------- */
.quote.has-quote span { font-style: italic; }
.quote.has-quote span::before { content: "❝ "; opacity: .6; }
.quote.ext { border-left-style: dashed; }
.badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; border-radius: 50%; }
.read-time { padding: 8px 14px 6px; font-size: 13px; color: var(--accent); border-bottom: 1px solid var(--ios-hair); }
.mention.hashtag { cursor: pointer; }
.cs-filters { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 100%; }
.cs-filters select, .cs-filters input { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 10px;
  border: 1px solid var(--ios-hair); background: var(--panel); color: var(--text); max-width: 160px; }
.cs-nav { flex-wrap: wrap; row-gap: 6px; }
.draw-btn.on { background: var(--accent); color: #fff; }

/* ---------- этап 5: ссылки, реакции, папки ---------- */
.il-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ios-hair); }
.il-row.dead { opacity: .55; }
.il-text { flex: 1; min-width: 0; }
.il-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.il-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.il-link { padding: 10px 12px; border-radius: 10px; background: var(--ios-field, rgba(127,127,127,.12)); word-break: break-all; user-select: all; }
.rx-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 8px 0 12px; }
.rx { font-size: 22px; padding: 6px 0; border-radius: 10px; border: 2px solid transparent; background: var(--ios-field, rgba(127,127,127,.12)); cursor: pointer; }
.rx.on { border-color: var(--accent); }
.theme-seg button.on { background: var(--accent); color: #fff; }
.fl-row { gap: 10px; }

/* ---------- этап 6: статус, цвет, QR, быстрые ответы, бизнес, мини-приложения ---------- */
.color-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: middle; }
.pp-top.colored { background: linear-gradient(180deg, color-mix(in srgb, var(--pp-color) 35%, transparent), transparent); border-radius: 16px; }
.qr-card { margin: 8px auto; padding: 18px; border-radius: 20px; background: #fff; border: 4px solid var(--qr-color); width: fit-content; text-align: center; }
.qr-img { width: 220px; height: 220px; display: block; }
.qr-name { color: var(--qr-color); font-weight: 700; margin-top: 6px; font-size: 18px; }
.qr-text { white-space: pre-wrap; max-height: 3.6em; overflow: hidden; }
textarea.qr-area { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 12px; font: inherit; color: inherit; resize: vertical;
  background: var(--ios-field, rgba(127,127,127,.12)); border: 1px solid var(--ios-hair, rgba(127,127,127,.2)); margin: 4px 0 8px; }
.quick-suggest .ms-item { display: block; }
.biz-hours { gap: 8px; }
.biz-hours input { max-width: 110px; }
.biz-days { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.biz-day { display: flex; align-items: center; gap: 3px; font-size: 14px; }
.webapp { position: fixed; z-index: 60; right: 24px; bottom: 24px; width: min(420px, calc(100vw - 32px)); height: min(720px, calc(100vh - 48px));
  background: var(--panel); border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.webapp-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--ios-hair); }
.webapp-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.webapp-frame { flex: 1; border: 0; width: 100%; background: #fff; }
.webapp-main { margin: 8px; }
@media (max-width: 700px) { .webapp { inset: 0; width: auto; height: auto; border-radius: 0; } }
.bot-menu-btn { border: none; background: var(--accent); color: #fff; border-radius: 16px; padding: 6px 12px; font: inherit; font-size: 14px;
  cursor: pointer; white-space: nowrap; align-self: center; margin-right: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- этап 7 ---------- */
.rd-react { font-size: 20px; }
.btn-danger { background: var(--danger, #e5484d); color: #fff; }
.modal .btn + .btn, .modal .btn-outline + .btn-outline { margin-top: 6px; }

/* ===== Этап 8 ===== */
.dice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px; min-width: 110px; cursor: default; }
.dice-emo { font-size: 72px; line-height: 1; display: inline-block; }
.dice-res { font-size: 14px; font-weight: 600; min-height: 18px; color: var(--text); }
.dice-emo.rolling { animation: dice-roll .5s linear infinite; }
.dice-emo.d2.rolling, .dice-emo.d3.rolling { animation: dice-throw .6s ease-in-out infinite; }
.dice-emo.d1.rolling { animation: dice-dart .6s ease-in-out infinite; }
.dice-emo.d5.rolling { animation: dice-slot .25s linear infinite; }
.dice-emo.done { animation: dice-land .35s ease-out; }
@keyframes dice-roll { 0% { transform: rotate(0) translateY(0); } 25% { transform: rotate(90deg) translateY(-14px); } 50% { transform: rotate(180deg) translateY(0); } 75% { transform: rotate(270deg) translateY(-8px); } 100% { transform: rotate(360deg) translateY(0); } }
@keyframes dice-throw { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-30px) scale(.8); } }
@keyframes dice-dart { 0% { transform: scale(1.4) rotate(-20deg); opacity: .6; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes dice-slot { 0% { transform: translateY(-6px); } 50% { transform: translateY(6px); } 100% { transform: translateY(-6px); } }
@keyframes dice-land { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
.dice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.dice-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel, var(--bg)); color: var(--text); cursor: pointer; }
.dice-pick:hover { border-color: var(--accent); }
.dp-emo { font-size: 36px; }
.voice-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.music-bar { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--panel, var(--bg)); }
.music-bar.hidden { display: none; }
.mb-btn { border: 0; background: none; color: var(--accent); font-size: 18px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.mb-btn:disabled { opacity: .35; cursor: default; }
.mb-btn:not(:disabled):hover { background: var(--hover, rgba(127,127,127,.12)); }
.mb-close { color: var(--muted); margin-left: auto; }
.mb-title { flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.att-file.on .file-name { color: var(--accent); }
.gif-search { grid-column: 1 / -1; width: 100%; box-sizing: border-box; padding: 8px 12px; border-radius: 18px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; margin-bottom: 6px; }
.gif-res { display: contents; }
.pp-sec-title { font-size: 13px; color: var(--muted); padding: 10px 16px 4px; }
.pp-stories { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; }
.pp-story { flex: 0 0 auto; width: 72px; height: 112px; border-radius: 10px; overflow: hidden; border: 2px solid var(--accent); padding: 0; background: #000; cursor: pointer; }
.pp-story img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.ph-cell { position: relative; border-radius: 10px; overflow: hidden; background: var(--border); }
.ph-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: pointer; }
.photo-grid.arch .ph-cell img { aspect-ratio: 9 / 16; }
.ph-cell.current { outline: 2px solid var(--accent); }
.ph-badge { position: absolute; top: 4px; left: 4px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 8px; }
.ph-date { position: absolute; bottom: 4px; left: 4px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 8px; }
.ph-btns { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px; padding: 4px 6px; background: var(--panel, var(--bg)); font-size: 12px; }
.sv-btn.on { color: var(--accent); }

/* ===== Этап 9 ===== */
.sender-name.anon { font-style: normal; }
.sender-name.clickable { cursor: pointer; }
.sendas { border: 0; background: none; padding: 0 2px; cursor: pointer; display: inline-flex; align-items: center; }
.sendas.hidden { display: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.tr-flag { display: block; border: 0; background: none; color: var(--accent); font-size: 12px; padding: 2px 0 0; cursor: pointer; }
.sim-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 12px 12px; }
.sim-ch { flex: 0 0 96px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: var(--text); cursor: pointer; padding: 6px; border-radius: 12px; }
.sim-ch:hover { background: var(--hover, rgba(127,127,127,.1)); }
.sim-t { font-size: 13px; text-align: center; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-ch small { color: var(--muted); font-size: 11px; }
.wp-own { display: flex; flex-direction: column; gap: 8px; }
.wp-opt { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.wp-opt input[type=range] { flex: 1; }
main.chat[data-wimg] { position: relative; isolation: isolate; overflow: hidden; background: #000; }
main.chat[data-wimg]::before { content: ''; position: absolute; inset: 0; z-index: -1; transform: scale(1.06);
  background: linear-gradient(rgba(0,0,0,var(--wp-dim, 0)), rgba(0,0,0,var(--wp-dim, 0))), var(--wp-img) center / cover no-repeat;
  filter: blur(var(--wp-blur, 0px)); }

/* ===== Этап 10 ===== */
.vt-video { width: 100%; max-height: 50vh; border-radius: 12px; background: #000; }
.fx-canvas { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; background: #000; }
.sp-badge { position: absolute; left: 6px; bottom: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.6); padding: 1px 6px; border-radius: 8px; }
.sp-tools button.on { color: var(--accent); }
#modal { z-index: 55; }   /* окно поверх предпросмотра отправки */
.modal-body .wp-opt { padding: 2px 16px; } .modal-body .fx-canvas, .modal-body .vt-video { display: block; margin: 0 auto 8px; }
.cemoji { width: 1.45em; height: 1.45em; vertical-align: -0.35em; object-fit: contain; margin: 0 1px; }
.sp-tab.sp-emo.on { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.imported { font-size: 12px; color: var(--muted); margin-bottom: 2px; } .msg.out .imported { color: inherit; opacity: .75; }
/* переключатель «Эмодзи | GIF | Стикеры», как в Telegram */
.ep-mode { display: flex; justify-content: center; gap: 4px; padding: 6px 8px 8px; border-top: 1px solid var(--border); }
.ep-seg { flex: 0 1 120px; border: 0; background: none; color: var(--muted); font: 600 14px var(--font, inherit); padding: 6px 10px; border-radius: 16px; cursor: pointer; }
.ep-seg:hover { background: var(--hover, rgba(127,127,127,.1)); }
.ep-seg.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.ep-tabs.hidden { display: none; }

/* ===== больше фонов чата: узоры и градиенты ===== */
.chat[data-wp="hearts"], .wp-preview[data-wp="hearts"] { background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2272%22%20height%3D%2272%22%3E%3Cg%20transform%3D%22translate%288%2C8%29%22%3E%3Cpath%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20d%3D%22M12%2021s-7-4.6-9.3-9C1.2%209%203%205%206.6%205c2.2%200%203.6%201.4%205.4%203.4C13.8%206.4%2015.2%205%2017.4%205%2021%205%2022.8%209%2021.3%2012%2019%2016.4%2012%2021%2012%2021z%22/%3E%3C/g%3E%3Cg%20transform%3D%22translate%2846%2C44%29%20scale%28.7%29%22%3E%3Cpath%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20d%3D%22M12%2021s-7-4.6-9.3-9C1.2%209%203%205%206.6%205c2.2%200%203.6%201.4%205.4%203.4C13.8%206.4%2015.2%205%2017.4%205%2021%205%2022.8%209%2021.3%2012%2019%2016.4%2012%2021%2012%2021z%22/%3E%3C/g%3E%3C/svg%3E") 0 0 / auto, var(--chat-bg); }
.chat[data-wp="stars"], .wp-preview[data-wp="stars"] { background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2272%22%20height%3D%2272%22%3E%3Cg%20transform%3D%22translate%286%2C6%29%22%3E%3Cpath%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20d%3D%22M12%202l2.9%206.3%206.9.7-5.2%204.6%201.5%206.8L12%2017l-6.1%203.4%201.5-6.8L2.2%209l6.9-.7z%22/%3E%3C/g%3E%3Cg%20transform%3D%22translate%2844%2C40%29%20scale%28.6%29%22%3E%3Cpath%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20d%3D%22M12%202l2.9%206.3%206.9.7-5.2%204.6%201.5%206.8L12%2017l-6.1%203.4%201.5-6.8L2.2%209l6.9-.7z%22/%3E%3C/g%3E%3Ccircle%20cx%3D%2258%22%20cy%3D%2212%22%20r%3D%221.6%22%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22/%3E%3Ccircle%20cx%3D%2220%22%20cy%3D%2256%22%20r%3D%221.3%22%20fill%3D%22rgba%28110%2C130%2C170%2C0.22%29%22/%3E%3C/svg%3E") 0 0 / auto, var(--chat-bg); }
.chat[data-wp="waves"], .wp-preview[data-wp="waves"] { background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2260%22%20height%3D%2240%22%3E%3Cpath%20d%3D%22M0%2012%20Q%2015%202%2030%2012%20T%2060%2012%22%20fill%3D%22none%22%20stroke%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20stroke-width%3D%222%22/%3E%3Cpath%20d%3D%22M0%2032%20Q%2015%2022%2030%2032%20T%2060%2032%22%20fill%3D%22none%22%20stroke%3D%22rgba%28110%2C130%2C170%2C0.22%29%22%20stroke-width%3D%222%22/%3E%3C/svg%3E") 0 0 / auto, var(--chat-bg); }
.chat[data-wp="grid"], .wp-preview[data-wp="grid"] { background: linear-gradient(var(--chat-dots) 1px, transparent 1px) 0 0 / 26px 26px, linear-gradient(90deg, var(--chat-dots) 1px, transparent 1px) 0 0 / 26px 26px, var(--chat-bg); }
.chat[data-wp="g_sunset"], .wp-preview[data-wp="g_sunset"] { background: linear-gradient(160deg, #ffd3a5,#fd6585); }
:root[data-theme="dark"] .chat[data-wp="g_sunset"], :root[data-theme="dark"] .wp-preview[data-wp="g_sunset"] { background: linear-gradient(160deg, #3a1c2b,#5a2a1a); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_sunset"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_sunset"] { background: linear-gradient(160deg, #3a1c2b,#5a2a1a); } }
.chat[data-wp="g_ocean"], .wp-preview[data-wp="g_ocean"] { background: linear-gradient(160deg, #89f7fe,#66a6ff); }
:root[data-theme="dark"] .chat[data-wp="g_ocean"], :root[data-theme="dark"] .wp-preview[data-wp="g_ocean"] { background: linear-gradient(160deg, #0b2545,#13315c); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_ocean"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_ocean"] { background: linear-gradient(160deg, #0b2545,#13315c); } }
.chat[data-wp="g_mint"], .wp-preview[data-wp="g_mint"] { background: linear-gradient(160deg, #d4fc79,#96e6a1); }
:root[data-theme="dark"] .chat[data-wp="g_mint"], :root[data-theme="dark"] .wp-preview[data-wp="g_mint"] { background: linear-gradient(160deg, #0f2e22,#1d4436); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_mint"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_mint"] { background: linear-gradient(160deg, #0f2e22,#1d4436); } }
.chat[data-wp="g_lavender"], .wp-preview[data-wp="g_lavender"] { background: linear-gradient(160deg, #e0c3fc,#8ec5fc); }
:root[data-theme="dark"] .chat[data-wp="g_lavender"], :root[data-theme="dark"] .wp-preview[data-wp="g_lavender"] { background: linear-gradient(160deg, #2a1f45,#1d2b4a); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_lavender"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_lavender"] { background: linear-gradient(160deg, #2a1f45,#1d2b4a); } }
.chat[data-wp="g_peach"], .wp-preview[data-wp="g_peach"] { background: linear-gradient(160deg, #fbc2eb,#a6c1ee); }
:root[data-theme="dark"] .chat[data-wp="g_peach"], :root[data-theme="dark"] .wp-preview[data-wp="g_peach"] { background: linear-gradient(160deg, #3b2340,#232f4f); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_peach"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_peach"] { background: linear-gradient(160deg, #3b2340,#232f4f); } }
.chat[data-wp="g_aurora"], .wp-preview[data-wp="g_aurora"] { background: linear-gradient(160deg, #43e97b,#38f9d7,#4facfe); }
:root[data-theme="dark"] .chat[data-wp="g_aurora"], :root[data-theme="dark"] .wp-preview[data-wp="g_aurora"] { background: linear-gradient(160deg, #0c3b2e,#0d3a4a,#13294b); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_aurora"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_aurora"] { background: linear-gradient(160deg, #0c3b2e,#0d3a4a,#13294b); } }
.chat[data-wp="g_night"], .wp-preview[data-wp="g_night"] { background: linear-gradient(160deg, #232526,#414345); }
:root[data-theme="dark"] .chat[data-wp="g_night"], :root[data-theme="dark"] .wp-preview[data-wp="g_night"] { background: linear-gradient(160deg, #141516,#2a2c2e); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_night"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_night"] { background: linear-gradient(160deg, #141516,#2a2c2e); } }
.chat[data-wp="g_candy"], .wp-preview[data-wp="g_candy"] { background: linear-gradient(160deg, #f6d365,#fda085); }
:root[data-theme="dark"] .chat[data-wp="g_candy"], :root[data-theme="dark"] .wp-preview[data-wp="g_candy"] { background: linear-gradient(160deg, #3d2c12,#4a2418); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat[data-wp="g_candy"], :root:not([data-theme="light"]) .wp-preview[data-wp="g_candy"] { background: linear-gradient(160deg, #3d2c12,#4a2418); } }
