:root {
  --tick-read: #2b8af7;
  --accent: #3b3fd8;
  --accent-2: #5960ff;
  --accent-soft: #eceeff;
  --bg: #ffffff;
  --bg-2: #f4f5f9;
  --chat-bg: #eef0f7;
  --text: #171a26;
  --muted: #6b7084;
  --line: #e3e5ee;
  --bubble: #ffffff;
  --bubble-mine: #dfe2ff;
  --danger: #d93a3a;
  --online: #2bb24c;
  --shadow: 0 10px 40px rgba(20, 24, 60, 0.18);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme='dark'] {
    --tick-read: #5cb4ff;
    --accent: #7c82ff;
    --accent-2: #9196ff;
    --accent-soft: #252848;
    --bg: #171923;
    --bg-2: #1f222e;
    --chat-bg: #12141c;
    --text: #e9eaf2;
    --muted: #9095aa;
    --line: #2b2f3e;
    --bubble: #232634;
    --bubble-mine: #34397a;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* Приложение не увеличивается щипком и двойным касанием целиком (как обычное приложение).
   Фото, камера кружков и т. п. увеличиваются сами — у них свой touch-action: none */
*, *::before, *::after { touch-action: pan-x pan-y; }
html { background: var(--bg-2); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
input, textarea {
  width: 100%;
  font-size: 16px; /* иначе iOS увеличивает страницу при фокусе */
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
input[type='checkbox'] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
textarea { resize: vertical; }
a { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
h1 { font-size: 22px; margin: 4px 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 4px 0 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .5px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.pad { padding: 12px; }
.pad-top { padding-top: 10px; }
.boot { height: 100vh; display: grid; place-items: center; }
.boot img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.96); } }

/* --- кнопки --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; font-weight: 500;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--bg-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; flex: none; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 50%; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 13px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.tag.red { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* --- вход и регистрация --- */
.auth {
  min-height: 100vh; min-height: 100dvh; box-sizing: border-box; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg-2);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg); padding: 28px 24px; border-radius: 20px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-brand img { border-radius: 16px; }
.auth-title { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.form-err { color: var(--danger); font-size: 14px; min-height: 1px; }
.form-err:empty { display: none; }

/* --- раскладка --- */
.layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
/* iOS 26: Safari размывает всё, что под строкой состояния, если страница «прокручиваемая».
   Закреплённое окно приложения со сплошным фоном Safari считает своей шапкой и не размывает её */
@supports (-webkit-touch-callout: none) {
  html:has(.layout), html:has(.layout) body { overflow: hidden; }
  .layout { position: fixed; inset: 0; height: auto; }
  body:has(.layout)::before { content: ''; position: fixed; left: 0; right: 0; top: 0; height: var(--safe-top); background: var(--bg); z-index: 1; pointer-events: none; }
}
.sidebar {
  width: 360px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line);
  background: var(--bg); padding-top: var(--safe-top);
}
.chat {
  flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative;
}
.chat, .bg-preview {
  background-color: var(--chat-bg);
  background-image: var(--chat-layers, none);
  background-size: var(--chat-sizes, auto);
  background-position: center;
}
:root[data-chat-photo] .day span:not([data-group-theme] *), :root[data-chat-photo] .sys span:not([data-group-theme] *), :root[data-chat-photo] .e2e-note:not([data-group-theme] *),
[data-group-theme][data-chat-photo] .day span, [data-group-theme][data-chat-photo] .sys span, [data-group-theme][data-chat-photo] .e2e-note { background: color-mix(in srgb, var(--bg) 88%, transparent); }
.chat.drop::after {
  content: 'Отпустите, чтобы отправить файл'; position: absolute; inset: 12px; border: 2px dashed var(--accent);
  border-radius: 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--chat-bg) 80%, transparent);
  font-weight: 600; color: var(--accent); pointer-events: none;
}

.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 12px; }
.me-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.brand { font-weight: 700; font-size: 19px; letter-spacing: -.3px; flex: 1; }
.brand-g { color: var(--accent); }
.side-actions { display: flex; }
.search {
  display: flex; align-items: center; gap: 8px; margin: 4px 12px 8px; padding: 0 12px;
  background: var(--bg-2); border-radius: 12px; color: var(--muted);
}
.search input { border: 0; background: transparent; padding: 9px 0; flex: 1; min-width: 0; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search-clear { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-right: -6px; border: 0; border-radius: 50%; background: var(--line); color: var(--text); cursor: pointer; padding: 0; }
.search-clear[hidden] { display: none; }
.search-clear:hover { background: var(--muted); color: var(--bg); }
.conn { text-align: center; font-size: 12px; color: var(--muted); padding: 4px; }
.conn:empty { display: none; }

.banner {
  margin: 0 12px 8px; padding: 10px 6px 10px 12px; border-radius: 12px; background: var(--accent-soft);
  display: flex; gap: 8px; align-items: center; font-size: 13px;
}
.banner > div { flex: 1; }
.banner svg { vertical-align: -3px; }
.banner .icon-btn { width: 30px; height: 30px; }

.chat-list { list-style: none; margin: 0; padding: 0 6px calc(8px + var(--safe-bottom)); overflow-y: auto; flex: 1; }
.list-empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.chat-item { position: relative; border-radius: 12px; overflow: hidden; touch-action: pan-y; }
.chat-item .ci-inner { position: relative; z-index: 1; display: flex; gap: 12px; padding: 8px 10px; border-radius: 12px; cursor: pointer; align-items: center; background: var(--bg); transition: transform .22s ease; }
.chat-item:hover .ci-inner { background: var(--bg-2); }
.chat-item.active .ci-inner { background: var(--accent); }
.chat-item.active { color: #fff; }
.chat-item .ci-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; z-index: 0; border-radius: 12px; overflow: hidden; }
.ci-act { width: 84px; border: 0; color: #fff; font: inherit; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; }
.ci-act.pin { background: #6b7280; }
.ci-act.del { background: #ef4444; }
.chat-item.active .ci-prev, .chat-item.active .ci-time { color: rgba(255, 255, 255, .8); }
.chat-item.active .badge { background: #fff; color: var(--accent); }
.ci-main { flex: 1; min-width: 0; }
.ci-top, .ci-bottom { display: flex; gap: 8px; align-items: baseline; }
.ci-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.ci-prev { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }

.avatar {
  border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.av-wrap { position: relative; flex: none; cursor: pointer; }
.dot { position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--online); border: 2px solid var(--bg); }
.chat-item.active .dot { border-color: var(--accent); }

/* --- чат --- */
.chat-empty { margin: auto; text-align: center; padding: 24px; max-width: 360px; }
.chat-empty-icon { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.chat-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: calc(8px + var(--safe-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.chat-head .back { display: none; }
.chat-head .back.topic-back { display: inline-grid; } /* из темы — к списку тем, и на компьютере */
.chat-title { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 2px; cursor: pointer; text-align: left; flex: 1; min-width: 0; }
.ct-text { min-width: 0; }
.ct-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub { font-size: 13px; color: var(--muted); }
.e2e { color: var(--online); padding: 0 6px; display: grid; }
.e2e[hidden] { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 2px; -webkit-overflow-scrolling: touch; }
.loading { text-align: center; color: var(--muted); font-size: 13px; padding: 12px; }
.e2e-note {
  align-self: center; max-width: 420px; text-align: center; font-size: 12.5px; color: var(--muted);
  background: var(--bg); border-radius: 12px; padding: 8px 12px; margin: 8px 0 12px;
}
.e2e-note svg { vertical-align: -2px; }
.day { align-self: center; margin: 10px 0 6px; }
.day span, .sys span { display: inline-block; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--muted); }
.sys { align-self: center; text-align: center; margin: 4px 0; max-width: 90%; }

.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.msg.cont { margin-top: 2px; }
.msg.mine { flex-direction: row-reverse; }
.av-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.av-spacer { width: 34px; flex: none; }
.bubble {
  position: relative; max-width: min(560px, 78%); padding: 7px 11px 6px; border-radius: var(--bubble-r, 16px); font-size: var(--msg-fs, 15px);
  background: var(--bubble); box-shadow: 0 1px 1px rgba(0, 0, 0, .06); cursor: default; overflow-wrap: anywhere;
}
.msg:not(.cont) .bubble { border-bottom-left-radius: min(6px, var(--bubble-r, 16px)); }
.msg.mine .bubble { background: var(--bubble-mine); border-bottom-left-radius: var(--bubble-r, 16px); }
.msg.mine:not(.cont) .bubble { border-bottom-right-radius: min(6px, var(--bubble-r, 16px)); }
.sender { display: block; border: 0; background: none; padding: 0; font-weight: 600; font-size: 13.5px; cursor: pointer; margin-bottom: 1px; }
.text { white-space: pre-wrap; display: inline; }
.meta { float: right; font-size: 11.5px; color: var(--muted); margin: 6px 0 -3px 10px; position: relative; top: 2px; }
/* время, «изменено» и галочки — служебные: не выделяются мышкой и не копируются вместе с текстом */
.meta, .meta *, .ticks, .pending-ico, .sender, .vtime, .vplay, .rate-btn, .tr-btn, .ikb, .reacts { -webkit-user-select: none; user-select: none; }
.fwd { font-size: 13px; color: var(--accent); margin-bottom: 3px; }
.fwd svg { vertical-align: -2px; }
.msg-actions { flex-basis: 100%; display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0 2px 42px; }
.msg.mine .msg-actions { justify-content: flex-end; padding-left: 0; }

.file { display: flex; align-items: center; gap: 10px; min-width: 200px; margin: 2px 0 4px; }
.file.busy .file-btn { opacity: 1; }
.pring { display: block; }
.pring .pring-bg { stroke: rgb(255 255 255 / .3); }
.pring .pring-fg { stroke: #fff; stroke-linecap: round; transition: stroke-dasharray .2s; }
.pring.spin { animation: pring-spin .9s linear infinite; }
@keyframes pring-spin { to { transform: rotate(360deg); } }
.file-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; padding: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.file-btn:disabled { opacity: .7; }
.file-info { min-width: 0; }
.file-name { font-weight: 500; word-break: break-all; }
.file-status { font-size: 12.5px; color: var(--muted); }
.file-img { margin: 2px -6px 4px; }
.file-img img { display: block; max-width: 100%; max-height: 340px; border-radius: 12px; cursor: zoom-in; }
.full-img { max-width: 100%; max-height: 70vh; border-radius: 10px; align-self: center; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; padding-bottom: calc(8px + var(--safe-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.composer textarea { resize: none; max-height: 160px; border-radius: 20px; padding: 9px 14px; line-height: 1.35; background: var(--bg-2); border-color: transparent; }
.composer textarea:focus { border-color: var(--accent); background: var(--bg); }
/* поле ввода с оформлением (richinput.js) — выглядит как прежнее */
.composer .rich-input { flex: 1; min-width: 0; width: 100%; font-size: 16px; max-height: 160px; overflow-y: auto; border-radius: 20px; padding: 9px 14px; line-height: 1.35;
  background: var(--bg-2); border: 1px solid transparent; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; cursor: text; transition: border-color .15s; -webkit-user-select: text; user-select: text; }
.composer .rich-input:focus { border-color: var(--accent); background: var(--bg); }
.rich-input.empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; position: absolute; }
.rich-input b { font-weight: 700; }
.rich-input .sp { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 22%, transparent) 0 3px, transparent 3px 6px); border-radius: 4px; }
.send-btn { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send-btn:active { transform: scale(.95); }

/* --- модальные окна --- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 25, .45); opacity: 0; transition: opacity .15s;
}
.modal-back.in { opacity: 1; }
.modal {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px; box-shadow: var(--shadow);
}
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.check-row { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; }
.profile-top { display: flex; align-items: center; gap: 14px; }
.profile-name { font-size: 18px; font-weight: 600; }
.online-text { color: var(--online); }
.about { white-space: pre-wrap; margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.device { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); }
.invite-box { display: flex; gap: 8px; }
.invite-box input { font-size: 13px; }

.picker { display: flex; flex-direction: column; gap: 8px; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick-list.tall { max-height: 55vh; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--bg-2); }
.pick.on { background: var(--accent-soft); }
.pick.dim { opacity: .6; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: #fff; }
.pick.on .check { background: var(--accent); border-color: var(--accent); }

.toasts { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #1d2030; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: tin .2s; }
.toast.out { opacity: 0; transition: opacity .25s; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* Перетаскиваемый край колонки с чатами (компьютер) */
.layout { --side-w-def: 360px; }
.layout .sidebar { width: var(--side-w, var(--side-w-def)); }
.side-resizer { flex: none; width: 9px; margin: 0 -5px 0 -4px; cursor: col-resize; position: relative; z-index: 5; touch-action: none; }
.side-resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: transparent; transition: background .15s, width .15s, left .15s; }
.side-resizer:hover::after, .side-resizer:focus-visible::after, body.side-resizing .side-resizer::after { background: var(--accent, #3b3fd8); width: 3px; left: 3px; }
.side-resizer:focus { outline: none; }
body.side-resizing { cursor: col-resize; user-select: none; }
body.side-resizing * { cursor: col-resize !important; user-select: none !important; }
body.side-resizing iframe, body.side-resizing video { pointer-events: none; }

/* --- телефон --- */
@media (max-width: 760px) {
  .layout .sidebar { width: 100%; border-right: 0; }
  .side-resizer { display: none; }
  .chat { display: none; }
  .layout.show-chat .sidebar { display: none; }
  .layout.show-chat .chat { display: flex; }
  .chat-head .back { display: inline-grid; }
  .messages { padding: 10px 10px 6px; }
  .bubble { max-width: 86%; }
  .modal-back { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: calc(100dvh - var(--safe-top) - 24px); }
  .modal-body { padding-bottom: calc(20px + var(--safe-bottom)); }
}

/* --- смайлики и реакции --- */
.composer { position: relative; }
.emoji-panel {
  position: absolute; left: 8px; bottom: calc(100% + 6px); width: min(380px, calc(100% - 16px)); height: 380px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; z-index: 20;
}
.emoji-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.etab { flex: none; width: 36px; height: 34px; border: 0; background: none; border-radius: 8px; font-size: 19px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.etab.on, .etab:hover { background: var(--accent-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); padding: 6px; overflow-y: auto; align-content: start; }
.emoji { border: 0; background: none; font-size: 26px; height: 42px; border-radius: 8px; cursor: pointer; line-height: 1; }
.emoji:hover { background: var(--bg-2); }
.quick-reacts { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.qr { border: 0; background: none; font-size: 20px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; line-height: 1; transition: transform .1s; }
.qr:hover { transform: scale(1.2); }
.qr.on { background: var(--accent-soft); }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 2px; }
.react {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2); font-size: 15px; line-height: 1.4;
}
.react span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.react.on { background: var(--accent); border-color: var(--accent); }
.react.on span { color: #fff; }
.msg-actions { align-items: center; }

/* --- голосовые --- */
.send-btn.mic { background: var(--accent); }
.composer.recording { align-items: center; }
.rec-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 4px; }
.rec-level { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); flex: none; transition: transform .08s; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-cancel { color: var(--danger); }
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; margin: 2px 0 3px; }
.vplay { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.vplay.busy { animation: pulse 1s infinite; }
.vwave { flex: 1; display: flex; align-items: center; gap: 2px; height: 32px; cursor: pointer; }
.vwave span { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.vwave span.done { background: var(--accent); }
.vtime { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; }

/* --- оформление --- */
.segmented { display: flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.segmented button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; color: #fff; display: grid; place-items: center; }
.swatch.on { outline: 2px solid var(--text); outline-offset: 2px; }

/* --- веб-версия на большом экране --- */
@media (min-width: 1200px) {
  .layout { --side-w-def: 380px; }
  .messages { padding-left: max(24px, calc((100% - 900px) / 2)); padding-right: max(24px, calc((100% - 900px) / 2)); }
}

/* --- выбор фона чата --- */
.bg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.bg-tile {
  position: relative; height: 64px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center; padding: 0 2px 4px; background-size: cover; background-position: center;
  color: var(--text); font-size: 11px;
}
.bg-tile .lbl { background: color-mix(in srgb, var(--bg) 82%, transparent); border-radius: 6px; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bg-tile.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.bg-tile .ico { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -62%); color: var(--muted); }
.bg-tile input[type='color'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.pattern-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.on-chip { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- инструкция по установке --- */
.guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: gs; }
.guide-steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: gs; }
.gs-ico { position: relative; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.gs-ico::after {
  content: counter(gs); position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.gs-title { font-weight: 600; }
.guide-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 500; }
.guide-status.ok { background: color-mix(in srgb, var(--online) 15%, transparent); color: var(--online); }
.guide-status.warn { background: var(--accent-soft); color: var(--accent); }
.invite-box { flex-wrap: wrap; }

/* --- галочки --- */
.meta { display: inline-flex; align-items: center; gap: 3px; }
.ticks { flex: none; color: var(--muted); }
.ticks.read { color: var(--tick-read); }
.ci-time { display: inline-flex; align-items: center; gap: 3px; }
.chat-item.active .ticks, .chat-item.active .ticks.read { color: rgba(255, 255, 255, .9); }

/* --- отправка фото --- */
.photo-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; max-height: 300px; overflow-y: auto; }
.photo-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.photo-thumbs.single { grid-template-columns: 1fr; }
.photo-thumbs.single img { aspect-ratio: auto; max-height: 300px; object-fit: contain; background: var(--bg-2); }

/* --- аудиофайлы --- */
.afile { display: flex; align-items: center; gap: 10px; min-width: 230px; margin: 2px 0 3px; }
.afile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.afile .file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 22%, transparent); cursor: pointer; position: relative; overflow: hidden; }
.afill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 3px; }
.atime { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- ответы --- */
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; background: var(--bg); border-top: 1px solid var(--line); }
.reply-bar[hidden] { display: none; }
.rb-ico { color: var(--accent); display: grid; }
.rb-main { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; cursor: pointer; }
.rb-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.rb-text, .rq-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-quote {
  display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent); border-radius: 6px;
  background: color-mix(in srgb, var(--text) 6%, transparent); padding: 4px 8px; margin: 2px 0 5px; cursor: pointer; min-width: 160px;
}
.rq-name { font-size: 13px; font-weight: 600; }
.msg.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* --- отключённые уведомления --- */
.muted-ico { display: inline-flex; vertical-align: -2px; margin-left: 5px; color: var(--muted); }
.chat-item.active .muted-ico { color: rgba(255, 255, 255, .8); }
.badge.muted { background: color-mix(in srgb, var(--muted) 70%, transparent); }
.icon-btn.muted-on { color: var(--danger); }
.menu { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.menu-item { text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 15px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--bg-2); }
.stack > .menu-item { border: 1px solid var(--line); border-radius: 12px; }

/* --- картинка группы --- */
.group-av-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; }
.group-av-pick { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; overflow: hidden; }
.group-av-pick img { width: 100%; height: 100%; object-fit: cover; }
.group-av-edit { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--bg); }

/* --- установка на экране входа --- */
.auth { gap: 16px; align-content: center; }
#install-block:empty { display: none; }
.install-card { width: 100%; max-width: 380px; background: var(--bg); border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.install-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.install-warn { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
a.btn { text-decoration: none; }

/* --- общие ссылки в админке --- */
.device.shared { background: var(--accent-soft); }
.select, .num { width: 100%; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.install-banner > svg { flex: none; color: var(--accent); }
.banner a.btn { flex: none; }

/* --- перенос истории --- */
.history-note { align-self: center; max-width: 460px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 13.5px; background: var(--bg); border: 1px solid var(--accent); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }

/* --- обрезка фото --- */
.crop-stage { position: relative; height: min(60vh, 420px); overflow: hidden; border-radius: 12px; background: #0d0f16; touch-action: none; user-select: none; cursor: grab; }
.crop-stage:active { cursor: grabbing; }
.crop-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.crop-frame { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); border: 2px solid #fff; pointer-events: none; border-radius: 4px; }
.crop-frame.round { border-radius: 50%; }
.crop-tools { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.crop-zoom { flex: 1; padding: 0; border: 0; accent-color: var(--accent); }
.crop-aspects { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-thumbs .thumb { position: relative; }
.thumb-crop { position: absolute; right: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px; padding: 5px 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; cursor: pointer; }
.menu-item svg { vertical-align: -3px; }

/* --- просмотры в группах --- */
.views { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; border: 0; background: none; padding: 0; margin-right: 4px; }
.views.clickable { cursor: pointer; }
.views.clickable:hover { color: var(--accent); }
.views.zero .vc:empty, .views .vc:empty { display: none; }

/* --- контекстное меню сообщения --- */
.ctx-menu {
  position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  opacity: 0; transform: scale(.96); transform-origin: top left; transition: opacity .12s, transform .12s;
}
.ctx-menu.in { opacity: 1; transform: none; }
.ctx-menu .quick-reacts { box-shadow: var(--shadow); }
.ctx-list {
  min-width: 220px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 5px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  /* в невысоком окне меню не обрезается, а прокручивается */
  max-height: var(--menu-max, calc(100vh - 16px)); overflow-y: auto; overscroll-behavior: contain;
}
.ctx-list > .ctx-item { flex: none; }
.ctx-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; font-size: 14.5px; text-align: left; color: var(--text);
}
.ctx-item svg { color: var(--muted); flex: none; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--bg-2); outline: none; }
.ctx-item.danger, .ctx-item.danger svg { color: var(--danger); }
.msg.selected .bubble { box-shadow: 0 0 0 2px var(--accent); }

/* --- изменённые сообщения --- */
.meta .edited { font-style: italic; margin-right: 4px; }

.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 14px; padding: 4px; align-self: center; }
.link-btn:hover { text-decoration: underline; }

/* --- проверка почты --- */
.mail-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); font-size: 14px; }
.mail-mark { font-weight: 700; width: 18px; text-align: center; }
.mail-row.ok .mail-mark { color: var(--online); }
.mail-row.bad .mail-mark { color: var(--danger); }
.mail-rec { display: flex; flex-direction: column; gap: 6px; }
.mail-rec .invite-box input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* --- опросы --- */
.poll { display: flex; flex-direction: column; gap: 6px; min-width: 240px; margin: 2px 0 4px; }
.poll-q { font-weight: 600; font-size: 15px; }
.poll-kind { margin-top: -4px; }
.poll-opt {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer; text-align: left; font-size: 14px; color: var(--text);
}
.poll-opt:not(.results):not(:disabled):hover { border-color: var(--accent); }
.poll-opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.poll-opt.results, .poll-opt:disabled { cursor: default; }
.poll-bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 18%, transparent); transition: width .3s; }
.poll-opt.mine .poll-bar { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.poll-check, .poll-text, .poll-pct { position: relative; }
.poll-check { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; color: #fff; }
.poll-opt.sel .poll-check, .poll-opt.mine .poll-check { background: var(--accent); border-color: var(--accent); }
.poll-opt.results:not(.mine) .poll-check { display: none; }
.poll-text { flex: 1; }
.poll-pct { font-weight: 600; font-size: 13px; }
.poll-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.poll-vote { align-self: flex-start; }
.link-btn.small { font-size: 13px; padding: 0; }
.row.nowrap { flex-wrap: nowrap; }

/* --- закреплённые --- */
.pin-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.pin-bar[hidden] { display: none; }
.pin-marks { display: flex; flex-direction: column; gap: 2px; align-self: stretch; justify-content: center; }
.pin-marks span { width: 3px; flex: 1; max-height: 14px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 30%, transparent); }
.pin-marks span.on { background: var(--accent); }
.pin-main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; cursor: pointer; padding: 2px 0; color: var(--text); }
.pin-title { font-size: 13px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: 2px; }
.pin-text { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poll-vote[hidden]{display:none}

/* @упоминания */
.mention-pop { margin: 0 12px; max-height: min(320px, 45vh); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgb(0 0 0 / .15); padding: 4px; }
.mention-pop[hidden] { display: none; }
.mention-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border: 0; background: none; color: inherit; font: inherit; text-align: left; border-radius: 8px; cursor: pointer; }
.mention-item.sel, .mention-item:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.mention { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; }
.msg.mine .mention { color: inherit; text-decoration: underline; }
.mention.me { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 4px; padding: 0 2px; }
.bubble.to-me { box-shadow: inset 3px 0 0 var(--accent); }
.badge.at { background: var(--accent); min-width: 22px; padding: 0; }
.chat-item.active .badge.at { background: #fff; color: var(--accent); }
#chat { position: relative; }
.mention-jump { position: absolute; right: 18px; bottom: 84px; z-index: 5; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 20px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.mention-jump[hidden] { display: none; }
/* «вниз, к последним сообщениям» — посередине над полем ввода */
.down-jump {
  position: absolute; left: 50%; bottom: 84px; z-index: 5; transform: translateX(-50%);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); box-shadow: 0 4px 14px rgb(0 0 0 / .18);
  animation: down-jump-in .15s ease-out;
}
.down-jump:hover { background: var(--bg-2); }
.down-jump[hidden] { display: none; }
.down-jump[data-count]:not([data-count=""])::after {
  content: attr(data-count); position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 5px; text-align: center;
}
@keyframes down-jump-in { from { opacity: 0; transform: translate(-50%, 6px); } }
.mention-jump[data-count]:not([data-count=""])::after { content: attr(data-count); position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: #e5484d; font-size: 11px; line-height: 18px; padding: 0 4px; }

/* Поиск по чату */
.chat-search { position: relative; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 6; }
.chat-search[hidden] { display: none; }
.cs-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; color: var(--muted); }
.cs-row input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; padding: 8px 4px; outline: none; }
.cs-count { white-space: nowrap; }
.search-results { position: absolute; left: 0; right: 0; top: 100%; max-height: min(60vh, 480px); overflow-y: auto; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.search-results[hidden] { display: none; }
.sr-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 10px 14px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sr-item:hover, .sr-item.sel { background: var(--accent-soft); }
.sr-top { display: flex; justify-content: space-between; gap: 8px; }
.sr-text { color: var(--muted); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.sr-text mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* --- окно выбора фона --- */
.bg-picker { display: flex; flex-direction: column; gap: 14px; }
.bg-preview {
  position: sticky; top: -16px; z-index: 2; height: 190px; border-radius: 16px; border: 1px solid var(--line);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; overflow: hidden;
  box-shadow: 0 6px 18px rgb(0 0 0 / .12);
}
.bg-preview .pv-day { align-self: center; font-size: 12px; padding: 3px 10px; border-radius: 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--muted); margin-bottom: auto; }
.bg-preview .pv { max-width: 75%; padding: 8px 12px; border-radius: 16px; font-size: 14px; line-height: 1.35; box-shadow: 0 1px 1px rgb(0 0 0 / .06); }
.bg-preview .pv.in { align-self: flex-start; background: var(--bubble); border-bottom-left-radius: 4px; }
.bg-preview .pv.out { align-self: flex-end; background: var(--bubble-mine); border-bottom-right-radius: 4px; }
.bg-preview .pv small { color: var(--muted); font-size: 11px; margin-left: 8px; }
.bg-section-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bg-tiles.big { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.bg-tiles.big .bg-tile { height: 120px; }
.bg-tile.pat { height: 56px; background-color: var(--bg-2); }
.bg-tile.on::after { content: ''; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 12px no-repeat; }
.range-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.bg-current { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.bg-current:hover { border-color: var(--accent); }
.bg-current .bg-preview { position: static; height: 64px; width: 96px; flex: none; padding: 6px; gap: 3px; border-radius: 10px; box-shadow: none; }
.bg-current .bg-preview .pv { padding: 0; height: 9px; width: 55%; border-radius: 5px; }
.bg-current .bg-preview .pv.out { width: 40%; }

/* --- видеосообщения («кружочки») --- */
.composer .circle-btn[hidden] { display: none; }
.bubble.circle-bubble { background: none !important; box-shadow: none; padding: 0; border-radius: 0; position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.msg.mine .bubble.circle-bubble { align-items: flex-end; }
/* Время — под кружком, а не поверх его края: в углу квадрата кружок уже закончился и подпись обрезалась */
.bubble.circle-bubble .meta { position: static; align-self: flex-end; display: inline-flex; align-items: center; height: 20px; background: rgb(0 0 0 / .45); color: #fff; border-radius: 10px; padding: 1px 7px; float: none; margin: 0; }
.bubble.circle-bubble .meta .ticks { color: #fff; }
.bubble.circle-bubble .sender { display: block; margin-bottom: 4px; }
.vcircle {
  position: relative; display: block; width: 220px; height: 220px; padding: 0; border: 0; border-radius: 22%; overflow: hidden;
  background: #000; cursor: pointer; transition: width .2s ease, height .2s ease; -webkit-tap-highlight-color: transparent; touch-action: pan-x pan-y;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.vcircle.playing { width: 280px; height: 280px; }
@media (max-width: 420px) { .vcircle.playing { width: 260px; height: 260px; } }
.vcircle video, .vcircle .vc-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 22%; }
.vcircle.mirror video, .vcircle.mirror .vc-thumb { transform: scaleX(-1); }
.vcircle.ready .vc-thumb { opacity: 0; transition: opacity .3s; }
.vcircle .vc-ring { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.vcircle .vc-ring path { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; opacity: 0; transition: stroke-dashoffset .25s linear; }
.vcircle.playing .vc-ring path { opacity: .95; }
.vcircle .vc-dur { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 4px; background: rgb(0 0 0 / .45); color: #fff; font-size: 12px; border-radius: 10px; padding: 2px 8px; pointer-events: none; }
.msg .vcircle .vc-dur { bottom: 12px; height: 20px; }
.vcircle .vc-load { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px; border-radius: 50%; border: 3px solid rgb(255 255 255 / .35); border-top-color: #fff; animation: vcspin 0.9s linear infinite; }
.vcircle.missing::after { content: '⚠'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 28px; background: rgb(0 0 0 / .35); }
@keyframes vcspin { to { transform: rotate(360deg); } }

.circle-rec {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  /* без размытия фона: размытие пересчитывается на каждом кадре камеры, и на телефонах кружок шёл рывками */
  background: rgb(10 12 20 / .96); color: #fff;
  padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}
.cr-stage { position: relative; width: min(78vw, 46vh, 340px); aspect-ratio: 1; }
.cr-video { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); border-radius: 22%; object-fit: cover; background: #000; }
.cr-video.mirror { transform: scaleX(-1); }
.cr-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.cr-ring path { fill: none; stroke-width: 6; }
.cr-track { stroke: rgb(255 255 255 / .15); }
.cr-prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.cr-time { display: flex; align-items: center; gap: 6px; font-size: 18px; font-variant-numeric: tabular-nums; }
.cr-time .muted { color: rgb(255 255 255 / .55); }
.cr-dot { width: 10px; height: 10px; border-radius: 50%; background: rgb(255 255 255 / .35); }
.circle-rec.recording .cr-dot { background: #ff3b30; animation: crblink 1s ease infinite; }
@keyframes crblink { 50% { opacity: .25; } }
.cr-hint { font-size: 14px; color: rgb(255 255 255 / .7); text-align: center; min-height: 1.3em; }
.cr-bar { display: flex; align-items: center; justify-content: center; gap: 28px; }
.cr-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / .14); color: #fff; cursor: pointer; }
.cr-btn:hover { background: rgb(255 255 255 / .24); }
.cr-btn.ghost { visibility: hidden; }
.cr-btn.big { width: 72px; height: 72px; }
.cr-btn.send { background: var(--accent); }
.cr-btn.rec { background: #fff; }
.cr-rec-dot { width: 54px; height: 54px; border-radius: 50%; background: #ff3b30; transition: transform .15s; }
.cr-btn.rec:active .cr-rec-dot { transform: scale(.9); }

/* --- звонки --- */
.call-btns { display: inline-flex; }
.call-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: color-mix(in srgb, #22c55e 14%, var(--bg)); border-bottom: 1px solid var(--line); }
.call-bar[hidden] { display: none; }
.call-bar .cb-ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #22c55e; color: #fff; flex: none; }
.call-bar .cb-title { font-weight: 600; font-size: 14px; }

.call-round { width: 68px; height: 68px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; cursor: pointer; transition: transform .1s; }
.call-round:active { transform: scale(.94); }
.call-round.red { background: #ef4444; }
.call-round.green { background: #22c55e; }
.call-round.gray { background: rgb(255 255 255 / .2); }
.call-round.pulse { animation: callpulse 1.6s ease-out infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .6); } 100% { box-shadow: 0 0 0 22px rgb(34 197 94 / 0); } }

.call-incoming, .call-screen {
  position: fixed; inset: 0; z-index: 1100; color: #fff;
  background: radial-gradient(120% 80% at 50% 0%, #2b3263 0%, #12152b 60%, #0a0c18 100%);
  padding: calc(16px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
}
.call-incoming { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.call-incoming .inc-av { margin-bottom: 14px; border-radius: 50%; animation: callpulse 2s ease-out infinite; }
.call-incoming .inc-name { font-size: 26px; font-weight: 700; }
.call-incoming .inc-kind { color: rgb(255 255 255 / .75); font-size: 15px; }
.call-incoming .inc-lock { color: rgb(255 255 255 / .5); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.call-incoming .inc-actions { display: flex; gap: 34px; margin-top: 56px; }
.inc-act { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: rgb(255 255 255 / .8); }

.call-screen { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; }
.call-screen.min { display: none; }
.cs-top { display: flex; align-items: center; gap: 10px; z-index: 2; }
.cs-name { font-size: 18px; font-weight: 600; }
.cs-status { font-size: 13px; color: rgb(255 255 255 / .7); font-variant-numeric: tabular-nums; }
.cs-lock { color: #4ade80; display: inline-flex; }
.icon-btn.light { color: #fff; }
.cs-grid { display: grid; gap: 8px; min-height: 0; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.cs-grid[data-n="2"] { grid-template-columns: 1fr 1fr; }
.cs-grid[data-n="3"], .cs-grid[data-n="4"] { grid-template-columns: 1fr 1fr; }
.cs-grid[data-n="5"], .cs-grid[data-n="6"] { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .cs-grid[data-n="2"] { grid-template-columns: 1fr; }
  .cs-grid[data-n="5"], .cs-grid[data-n="6"] { grid-template-columns: 1fr 1fr; }
}
.tile, .cs-self { position: relative; border-radius: 18px; overflow: hidden; background: #1c2040; min-height: 0; display: grid; place-items: center; }
.tile video, .cs-self video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.tile.has-video video, .cs-self.has-video video { opacity: 1; }
.tile.screen video { object-fit: contain; background: #000; }
video.mirror { transform: scaleX(-1); }
.tile .tile-av, .cs-self .tile-av { position: relative; }
.tile.has-video .tile-av, .cs-self.has-video .tile-av { display: none; }
.tile .tile-av .avatar { box-shadow: 0 0 0 0 transparent; transition: box-shadow .15s; }
.tile.speaking .tile-av .avatar { box-shadow: 0 0 0 4px #4ade80; }
.tile.speaking.has-video { box-shadow: inset 0 0 0 3px #4ade80; }
.tile-name { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 4px; background: rgb(0 0 0 / .45); padding: 3px 9px; border-radius: 10px; font-size: 13px; }
.tile-mic { display: none; color: #f87171; }
.tile.muted .tile-mic { display: inline-flex; }
.tile-conn { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; background: rgb(0 0 0 / .45); padding: 2px 10px; border-radius: 10px; display: none; }
.tile[data-conn="connecting"] .tile-conn, .tile[data-conn="failed"] .tile-conn { display: block; }
/* личный звонок: собеседник на весь экран, я — маленьким окошком */
.call-screen.direct .cs-grid { grid-row: 1 / 4; grid-column: 1; margin: calc(-16px - var(--safe-top)) -16px calc(-20px - var(--safe-bottom)); border-radius: 0; }
.call-screen.direct .cs-grid .tile { border-radius: 0; }
.call-screen.direct .cs-top, .call-screen.direct .cs-controls { grid-column: 1; }
.call-screen.direct .cs-top { grid-row: 1; }
.call-screen.direct .cs-controls { grid-row: 3; }
.call-screen.direct .cs-self { position: absolute; right: 16px; top: calc(70px + var(--safe-top)); width: 110px; height: 150px; z-index: 3; box-shadow: 0 6px 20px rgb(0 0 0 / .4); }
.call-screen.direct .cs-self:not(.has-video) { width: 76px; height: 76px; border-radius: 50%; }
.call-screen.direct .cs-self:not(.has-video) .avatar { width: 56px !important; height: 56px !important; }
.call-screen.direct:not(.live) .cs-self.has-video { inset: 0; width: auto; height: auto; border-radius: 0; z-index: 0; box-shadow: none; }
.cs-self.muted::after { content: ''; position: absolute; right: 6px; bottom: 6px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
.cs-controls { display: flex; justify-content: center; align-items: center; gap: 14px; z-index: 2; }
.call-ctl { width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / .16); color: #fff; cursor: pointer; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.call-ctl:hover { background: rgb(255 255 255 / .26); }
.call-ctl.off { background: #fff; color: #111; }
.call-ctl.on { background: var(--accent); }
.call-ctl.red { background: #ef4444; width: 64px; height: 64px; }
.call-pill {
  position: fixed; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 1050;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 22px; border: 0;
  background: #16a34a; color: #fff; font: inherit; font-size: 14px; cursor: pointer; box-shadow: 0 6px 18px rgb(0 0 0 / .25); max-width: calc(100vw - 24px);
}
.call-pill .cp-name { font-weight: 600; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-pill .cp-time { font-variant-numeric: tabular-nums; opacity: .9; }
.call-pill .cp-back { opacity: .8; font-size: 12.5px; }
.call-pill .cp-dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: crblink 1.2s ease infinite; }

.cs-self .self-name { display: none; }
.call-screen.group .cs-self .self-name { display: inline-flex; }
.cs-self.muted .tile-mic { display: inline-flex; }
.call-screen.group .cs-self.muted::after { display: none; }
.call-screen.direct .tile-name { bottom: calc(104px + var(--safe-bottom)); left: 16px; }
.check-line { font-size: 14px; line-height: 1.4; }
.check-line.ok b { color: #16a34a; }
.check-line.bad b { color: #dc2626; }
.check-line .muted { margin: 2px 0 4px 18px; }

/* экран «Приложение обновляется» (основные стили — в index.html) */
.splash.updating { background: var(--bg); color: var(--text); z-index: 3000; }
.splash.updating div:last-child { max-width: 300px; color: var(--muted); }

/* закреплённые чаты */
.chat-item .pin-ico { color: var(--muted); display: inline-flex; transform: rotate(45deg); flex: none; }
.chat-item.active .pin-ico { color: #fff; }
.chat-item.pinned + .chat-item:not(.pinned) { margin-top: 6px; }
.chat-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* --- Новости --- */
.brand { display: flex; align-items: center; gap: 0; min-width: 0; }
.news-btn {
  position: relative; margin-left: 10px; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: 0; cursor: pointer; white-space: nowrap;
}
.news-btn:hover { color: var(--accent); border-color: var(--accent); }
.news-btn.unread { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.news-btn.unread::after { content: ''; position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px var(--bg); }
@media (max-width: 380px) { .news-btn span { display: none; } .news-btn { padding: 0 7px; } }
.news { display: flex; flex-direction: column; gap: 14px; }
.news-rel { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.news-rel.fresh { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.news-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-ver { font-weight: 700; color: var(--accent); }
.news-new { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #fff; background: #ef4444; border-radius: 6px; padding: 1px 6px; }
.news-rel h3 { margin: 6px 0 8px; font-size: 16px; }
.news-rel ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.news-rel li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; line-height: 1.4; }
.news-tag { flex: none; font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 1px 6px; min-width: 84px; text-align: center; }
.news-tag.new { background: color-mix(in srgb, #22c55e 18%, transparent); color: #15803d; }
.news-tag.better { background: color-mix(in srgb, #3b82f6 18%, transparent); color: #1d4ed8; }
.news-tag.fix { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #b45309; }
:root[data-theme="dark"] .news-tag.new { color: #4ade80; }
:root[data-theme="dark"] .news-tag.better { color: #93c5fd; }
:root[data-theme="dark"] .news-tag.fix { color: #fbbf24; }

/* --- Медиа и файлы чата --- */
.mf-entry { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mf-entry:hover { border-color: var(--accent); }
.mf-entry-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.mf { display: flex; flex-direction: column; gap: 10px; min-height: 50vh; }
.mf-tabs { position: sticky; top: -16px; z-index: 2; }
.mf-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; }
.mf-count { font-size: 11px; font-weight: 600; color: var(--muted); }
.mf-tabs button.on .mf-count { color: var(--accent); }
@media (max-width: 480px) { .mf-tabs button { font-size: 12.5px; padding: 8px 2px; flex-direction: column; gap: 0; } }
.mf-status:empty { display: none; }
.mf-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.mf-month { font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 2px 0; }
.mf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
@media (max-width: 480px) { .mf-grid { grid-template-columns: repeat(3, 1fr); } }
.mf-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--bg-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.mf-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mf-tile.circle img { inset: 8%; width: 84%; height: 84%; border-radius: 22%; }
.mf-tile.missing::after { content: '⚠'; position: absolute; top: 6px; right: 8px; font-size: 14px; }
.mf-badge { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: #fff; background: rgb(0 0 0 / .5); padding: 1px 6px; border-radius: 8px; }
.mf-rows { display: flex; flex-direction: column; }
.mf-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: default; }
.mf-row[role=button] { cursor: pointer; }
.mf-row:last-child { border-bottom: 0; }
.mf-row .grow { min-width: 0; }
.mf-ext { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.mf-ext.audio { background: #f59e0b; }
.mf-ext.link { background: #0ea5e9; font-size: 18px; }
.mf-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; color: var(--text); text-decoration: none; }
a.mf-name { color: var(--accent); }
.mf-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-cap { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mf-acts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.mf-goto { white-space: nowrap; flex: none; }
.voice-row .voice { margin-top: 4px; }
.mf-view-box { display: grid; place-items: center; min-height: 200px; }
.mf-viewer .full-img.round { width: min(420px, 80vw); aspect-ratio: 1; object-fit: cover; border-radius: 22%; }
.vc-load.static { position: static; margin: 0; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: vcspin .9s linear infinite; }

/* --- истории --- */
.stories-bar { display: flex; gap: 4px; overflow-x: auto; padding: 4px 10px 8px; scrollbar-width: none; flex: none; }
.stories-bar::-webkit-scrollbar { display: none; }
.story-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 68px; flex: none; border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--text); font: inherit; }
.story-ring { position: relative; padding: 4.5px; border-radius: 50%; background: var(--line); }
.story-ring .avatar { box-shadow: 0 0 0 2px var(--bg); }
.story-item.unseen .story-ring { background: conic-gradient(from 200deg, #f59e0b, #ef4444, #d946ef, #6366f1, #22c55e, #f59e0b); }
.story-item.mine.has .story-ring { background: var(--accent); }
.story-item.mine.add .story-ring { background: none; }
.story-add { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--bg); }
.story-name { font-size: 11.5px; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.story-item.unseen .story-name { color: var(--text); font-weight: 600; }

.story-frame { position: relative; aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; background: #000; color: #fff; }
.story-frame > img, .story-frame > video, .sv-media > img, .sv-media > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.story-create .story-frame { width: min(300px, 70vw); margin: 0 auto; display: grid; place-items: center; }
.story-text-input { width: 86%; border: 0; background: none; color: #fff; text-align: center; font: 600 22px/1.3 inherit; font-family: inherit; resize: none; outline: none; z-index: 1; }
.story-text-input::placeholder { color: rgb(255 255 255 / .6); }
.story-bgs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.story-bg { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.story-bg.on { outline: 2px solid var(--accent); outline-offset: 2px; }

.story-viewer { position: fixed; inset: 0; z-index: 1200; background: rgb(8 9 14 / .96); display: flex; align-items: center; justify-content: center; gap: 18px; padding: 12px; touch-action: none; }
.sv-frame { height: min(100%, 860px); max-width: 100%; display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
.sv-media { position: absolute; inset: 0; display: grid; place-items: center; }
.sv-media .sv-blur { filter: blur(18px); transform: scale(1.1); object-fit: cover; opacity: .7; }
.vc-load.light { border-color: rgb(255 255 255 / .3); border-top-color: #fff; position: relative; z-index: 1; }
.sv-text { padding: 0 9%; text-align: center; font-size: clamp(20px, 4.4vh, 34px); font-weight: 700; line-height: 1.3; white-space: pre-wrap; word-break: break-word; text-shadow: 0 1px 8px rgb(0 0 0 / .2); }
.sv-text.long { font-size: clamp(16px, 3vh, 22px); font-weight: 600; }
.sv-top { position: relative; z-index: 2; padding: 10px 10px 30px; background: linear-gradient(rgb(0 0 0 / .45), transparent); }
.sv-bars { display: flex; gap: 4px; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgb(255 255 255 / .35); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #fff; }
.sv-who { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.sv-name { font-weight: 600; font-size: 15px; }
.sv-time { font-size: 12px; opacity: .75; }
.sv-btn { border: 0; background: none; color: #fff; padding: 6px; cursor: pointer; display: grid; place-items: center; }
.sv-caption { position: relative; z-index: 2; margin: auto 0 0; padding: 30px 16px 8px; text-align: center; font-size: 15px; background: linear-gradient(transparent, rgb(0 0 0 / .55)); white-space: pre-wrap; }
.sv-caption[hidden] { display: none; }
.sv-foot { position: relative; z-index: 2; padding: 8px 10px calc(10px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; margin-top: auto; background: linear-gradient(transparent, rgb(0 0 0 / .5)); }
.sv-caption:not([hidden]) ~ .sv-foot { margin-top: 0; background: rgb(0 0 0 / .55); } /* между ними может стоять подсказка перемотки — поэтому «~», а не «+» */
.sv-reacts { display: flex; justify-content: space-around; }
.sv-react { border: 0; background: none; font-size: 26px; cursor: pointer; transition: transform .12s; padding: 2px 4px; }
.sv-react:active, .sv-react.on { transform: scale(1.25); }
.sv-reply-row { display: flex; gap: 8px; align-items: center; }
.sv-reply { flex: 1; min-width: 0; border: 1px solid rgb(255 255 255 / .45); background: rgb(0 0 0 / .25); color: #fff; border-radius: 22px; padding: 10px 14px; font: inherit; font-size: 15px; outline: none; }
.sv-reply::placeholder { color: rgb(255 255 255 / .7); }
.sv-send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.sv-views { align-self: center; display: inline-flex; align-items: center; gap: 8px; border: 0; background: rgb(255 255 255 / .16); color: #fff; padding: 9px 16px; border-radius: 20px; font: inherit; font-size: 14px; cursor: pointer; }
.sv-nav { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .12); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.sv-nav:hover { background: rgb(255 255 255 / .22); }
.story-viewer.paused .sv-bars { opacity: .5; }
.sv-fly { position: fixed; left: 50%; bottom: 120px; z-index: 1300; font-size: 64px; pointer-events: none; animation: svfly 1.1s ease-out forwards; }
@keyframes svfly { 0% { transform: translate(-50%, 0) scale(.6); opacity: 0; } 25% { opacity: 1; transform: translate(-50%, -40px) scale(1.2); } 100% { transform: translate(-50%, -260px) scale(1); opacity: 0; } }
.sv-view-react { font-size: 22px; }
@media (max-width: 600px) {
  .story-viewer { padding: 0; }
  .sv-frame { height: 100%; width: 100%; border-radius: 0; aspect-ratio: auto; padding-top: var(--safe-top); }
  .sv-nav { display: none; }
}

/* ответ на историю в переписке */
.story-ref { display: flex; align-items: center; gap: 8px; border: 0; background: color-mix(in srgb, var(--accent) 10%, transparent); border-left: 3px solid var(--accent); border-radius: 8px; padding: 5px 10px 5px 5px; margin-bottom: 5px; cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.sr-thumb { width: 34px; height: 52px; border-radius: 6px; object-fit: cover; background: #222; flex: none; display: grid; place-items: center; overflow: hidden; color: #fff; font-size: 7px; line-height: 1.1; text-align: center; padding: 2px; }
.sr-label { font-size: 13px; font-weight: 600; color: var(--accent); }
.chat-item .ci-actions { visibility: hidden; }
.chat-item.swiping .ci-actions, .chat-item.swiped .ci-actions { visibility: visible; }

/* --- ник, телефон, поиск людей, контакты --- */
.complete-profile { position: fixed; inset: 0; z-index: 1500; background: var(--bg-2); display: grid; place-items: center; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); overflow-y: auto; }
.complete-profile .auth-card { max-width: 420px; width: 100%; }
.complete-profile h1 { font-size: 21px; }
.profile-ids { display: flex; gap: 24px; flex-wrap: wrap; }
.profile-ids > div { display: flex; flex-direction: column; gap: 2px; }
.profile-ids a, .profile-ids .copyable { font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }
.chat-list .pick-head, .pick-list .pick-head { list-style: none; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); padding: 12px 12px 4px; }
.chat-item.search-hit .ci-inner { align-items: center; }
.chat-item.search-hit .btn { flex: none; }
/* Окна, открытые поверх истории или звонка (просмотры, подтверждение удаления), — выше них */
.story-viewer ~ .modal-back, .call-screen ~ .modal-back { z-index: 1250; }

/* --- Каналы --- */
.composer[hidden], .channel-bar[hidden], .ack-chip[hidden] { display: none; }
.channel-bar { padding: 8px 10px calc(8px + var(--safe-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.channel-mute { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; padding: 10px; border-radius: 12px; cursor: pointer; }
.channel-mute:hover { background: var(--bg-2); }
.ack-btn.on { color: #fff; background: var(--accent); border-radius: 50%; }
.ack-chip { display: flex; align-items: center; gap: 8px; padding: 7px 14px; background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--accent); font-size: 13.5px; border-top: 1px solid var(--line); }
.ack-chip .linkish { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.ack-do { margin: 10px 0 2px; display: flex; width: 100%; min-width: 200px; justify-content: center; align-items: center; gap: 6px; }
.ack-done, .ack-stat { margin-top: 6px; display: flex; width: fit-content; align-items: center; gap: 5px; font-size: 13px; color: #2f9e5b; }
.ack-stat { border: 0; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); padding: 4px 10px; border-radius: 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.msg.mine .ack-stat { background: rgb(255 255 255 / .18); color: inherit; }
.ack-stat.all { color: #2f9e5b; }
.msg.mine .ack-stat.all { color: inherit; }
.ack-jump { bottom: 136px; background: #2f9e5b; display: grid; place-items: center; }
.ack-jump[hidden] { display: none; }
.badge.ack { background: #2f9e5b; min-width: 22px; padding: 0; display: inline-grid; place-items: center; }
.chat-item.active .badge.ack { background: #fff; color: #2f9e5b; }
.ch-ico { display: inline-flex; vertical-align: -2px; margin-right: 4px; opacity: .75; }
.ack-sec { font-weight: 600; font-size: 14px; margin-top: 4px; }
.role-btn { white-space: nowrap; }
.create-menu { min-width: 200px; }

/* --- Статистика в администрировании --- */
.stats { display: flex; flex-direction: column; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stat-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg-2); display: flex; flex-direction: column; gap: 2px; }
.stat-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-big { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.stat-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.stat-bar { width: 100%; max-width: 30px; min-height: 2px; border-radius: 6px 6px 0 0; background: var(--accent); }
.stat-val { font-size: 10.5px; color: var(--muted); }
.stat-act, .stat-day { font-size: 10px; color: var(--muted); white-space: nowrap; }
@media (max-width: 520px) { .stat-act { display: none; } .stat-day { font-size: 9px; } }
.howto { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; line-height: 1.4; }

/* --- Защита от копирования --- */
.messages.protected, .messages.protected * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.messages.protected img, .messages.protected video { pointer-events: auto; -webkit-user-drag: none; }
.protect-ind { color: var(--accent); display: inline-flex; align-items: center; padding: 0 4px; }
.protect-ind[hidden] { display: none; }
.protect-note { display: flex; align-items: center; gap: 6px; }
.protected-pdf { width: 100%; height: 70vh; border: 0; border-radius: 10px; background: #fff; }
.protect-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }

/* --- Код-пароль --- */
.icon-btn[hidden] { display: none; }
.lock-screen { position: fixed; inset: 0; z-index: 2500; background: var(--bg-2); display: grid; place-items: center; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); overflow-y: auto; }
.lock-box { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 320px; }
.lock-logo { border-radius: 16px; }
.lock-title { font-size: 20px; font-weight: 700; }
.lock-msg { color: var(--muted); text-align: center; min-height: 20px; font-size: 14.5px; }
.lock-dots { display: flex; gap: 14px; margin: 4px 0 10px; }
.lock-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); }
.lock-dots span.on { background: var(--accent); }
.lock-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px 22px; }
.lock-key { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--bg); color: var(--text); font-family: inherit; font-size: 28px; font-weight: 500; line-height: 1; display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.lock-key:active { background: var(--accent); color: #fff; }
.lock-key.bio { color: var(--accent); }
.lock-key[aria-label="Стереть"] { background: none; box-shadow: none; }
.lock-forgot { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; margin-top: 6px; }
.lock-screen.shake .lock-dots { animation: lockshake .4s; }
@keyframes lockshake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.code-input { font-size: 22px; letter-spacing: 6px; text-align: center; }
@media (max-height: 640px) { .lock-key { width: 60px; height: 60px; font-size: 24px; } .lock-pad { grid-template-columns: repeat(3, 60px); gap: 10px 18px; } }

/* --- Стикеры и GIF --- */
.panel-modes { display: flex; gap: 4px; padding: 6px 6px 0; flex: none; }
.pmode { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 10px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.pmode.on { background: var(--accent-soft); color: var(--accent); }
.etab-img { width: 26px; height: 26px; object-fit: contain; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); grid-auto-rows: max-content; gap: 8px; padding: 8px; overflow-y: auto; align-content: start; flex: 1; }
.sticker-head { grid-column: 1 / -1; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 2px 4px; }
/* квадрат задаёт сама картинка (aspect-ratio у <button> Safari на iPhone не всегда учитывает — стикеры наезжали друг на друга) */
.sticker { position: relative; border: 0; background: none; border-radius: 12px; padding: 6px; cursor: pointer; display: block; overflow: hidden; min-width: 0; }
.sticker:hover { background: var(--bg-2); }
.sticker img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.sticker.gif { padding: 0; background: var(--bg-2); aspect-ratio: 1; display: grid; }
.gif-send { border: 0; padding: 0; background: none; width: 100%; height: 100%; cursor: pointer; }
.gif-send img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }
.gif-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .55); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; }
.sticker:hover .gif-del, .sticker-pack .gif-del { opacity: 1; }
@media (pointer: coarse) { .gif-del { opacity: 1; } }
.gif-add { border: 2px dashed var(--line); color: var(--muted); font-size: 12px; gap: 2px; align-content: center; }
.gif-empty { grid-column: 1 / -1; }
.gif-tabs-note { padding: 6px 8px; }
.bubble.sticker-bubble { background: none !important; box-shadow: none; padding: 0; }
.bubble.sticker-bubble .meta { background: rgb(0 0 0 / .35); color: #fff; border-radius: 10px; padding: 1px 7px; float: none; display: inline-flex; margin-top: 2px; }
.bubble.sticker-bubble .sender { padding: 0 2px; }
.sticker-img { display: block; width: 160px; height: 160px; object-fit: contain; }
.sticker-gone { width: 140px; height: 120px; display: grid; place-items: center; text-align: center; font-size: 48px; border: 1px dashed var(--line); border-radius: 16px; }
.sticker-pack { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.sticker-pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); grid-auto-rows: max-content; gap: 8px; }
.sticker-pack-grid .sticker { background: var(--bg-2); cursor: default; }

/* --- Переезд на новый адрес --- */
.move-banner { display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 10px 12px; border: 0; border-radius: 14px; background: #fff4d6; color: #5c4400; text-align: left; font: inherit; cursor: pointer; }
.move-banner .small { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.move-ico { font-size: 24px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .move-banner { background: #3d3311; color: #ffe7a3; } }
:root[data-theme="dark"] .move-banner { background: #3d3311; color: #ffe7a3; }
.move-bar { height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.move-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.btn.disabled { opacity: .5; pointer-events: none; }
a.btn { text-decoration: none; text-align: center; justify-content: center; }
.stat-card.move .stat-big { color: var(--accent); }

/* --- Расшифровка голосовых --- */
.tr-btn { flex: none; border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 700; border-radius: 8px; padding: 3px 7px; cursor: pointer; margin-left: 2px; }
.msg.mine .tr-btn { background: rgb(255 255 255 / .2); color: inherit; }
.tr-btn.on { background: var(--accent); color: #fff; }
.transcript { margin-top: 6px; font-size: 14.5px; line-height: 1.4; white-space: pre-wrap; max-width: 320px; }
.transcript[hidden] { display: none; }
.circle-bubble .transcript { max-width: 240px; padding: 6px 10px; border-radius: 12px; background: var(--bubble, var(--bg)); }
.tr-busy { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; opacity: .8; }
.tr-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: trpulse 1s infinite; }
@keyframes trpulse { 50% { opacity: .25; } }

/* --- Конструктор стикеров --- */
.sm { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .sm { grid-template-columns: 1fr; } }
.sm-stage { position: sticky; top: 0; z-index: 1; background: var(--bg); padding-bottom: 6px; }
.sm-canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 16px; touch-action: none; cursor: grab;
  background: repeating-conic-gradient(#e7e9ef 0 25%, #fff 0 50%) 0 0 / 24px 24px; border: 1px solid var(--line); }
:root[data-theme="dark"] .sm-canvas { background: repeating-conic-gradient(#2a2d36 0 25%, #1f2128 0 50%) 0 0 / 24px 24px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sm-canvas { background: repeating-conic-gradient(#2a2d36 0 25%, #1f2128 0 50%) 0 0 / 24px 24px; } }
.sm-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sm-tools { display: flex; flex-direction: column; gap: 8px; }
.sm-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sm-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; padding: 6px 11px; border-radius: 999px; cursor: pointer; }
.sm-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.sm-slider { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.sm-slider input { flex: 1; }
.sm-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--bg-2); }
.sm-text { resize: none; font-size: 16px; }
.sm-colors { display: flex; gap: 6px; flex-wrap: wrap; }
.sm-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.sm-color.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.sm-emojis { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; max-height: 190px; overflow-y: auto; }
.sm-emoji { border: 0; background: none; font-size: 26px; height: 42px; border-radius: 8px; cursor: pointer; }
.sm-emoji:hover { background: var(--bg); }
.sm-save { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.sticker-empty { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; grid-column: 1 / -1; }
.move-login { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: #fff4d6; color: #5c4400; font-size: 14px; }
.move-login a { color: inherit; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .move-login { background: #3d3311; color: #ffe7a3; } }
:root[data-theme="dark"] .move-login { background: #3d3311; color: #ffe7a3; }
.story-item.locked .story-ring { opacity: .7; }
.story-lock { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--muted); display: grid; place-items: center; border: 2px solid var(--bg); }
.call-reps { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.call-rep { padding: 8px 10px; border-radius: 10px; background: var(--bg-2); display: flex; flex-direction: column; gap: 3px; border-left: 3px solid #2f9e5b; }
.call-rep.bad { border-left-color: #e5484d; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.tile audio { display: none; }
.cs-unmute { position: absolute; left: 50%; top: calc(80px + var(--safe-top)); transform: translateX(-50%); z-index: 5; border: 0; border-radius: 999px; padding: 12px 20px; background: #fff; color: #111; font: inherit; font-weight: 600; font-size: 15px; box-shadow: 0 6px 24px rgb(0 0 0 / .35); cursor: pointer; animation: trpulse 1.4s infinite; }

/* ---------- «печатает…» ---------- */
.tdots { display: inline-flex; gap: 3px; align-items: center; margin-left: 4px; vertical-align: middle; }
.tdots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .35; animation: tdot 1.2s infinite ease-in-out; }
.tdots i:nth-child(2) { animation-delay: .16s; }
.tdots i:nth-child(3) { animation-delay: .32s; }
.tdots.big { gap: 5px; margin: 0; }
.tdots.big i { width: 8px; height: 8px; background: var(--muted); }
@keyframes tdot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.typing-txt { color: var(--accent); }
.ct-sub.typing, .ci-prev.typing { color: var(--accent); }
.chat-item.active .ci-prev.typing .typing-txt { color: #fff; }
.typing-row .typing-bubble { display: inline-flex; align-items: center; gap: 6px; padding: 12px 14px; min-height: 0; color: var(--muted); transform-origin: bottom left; }
.typing-row.appear .typing-bubble { animation: typingIn .25s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes typingIn { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.msg.from-typing .bubble { transform-origin: bottom left; animation: fromTyping .38s cubic-bezier(.2, .9, .3, 1.15) both; }
@keyframes fromTyping { from { transform: scale(.32, .45); opacity: .5; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .tdots i, .typing-row.appear .typing-bubble, .msg.from-typing .bubble { animation: none; }
  .tdots i { opacity: .7; }
}

/* ---------- выбор сообщений ---------- */
.messages.selecting .msg { cursor: pointer; user-select: none; -webkit-user-select: none; border-radius: 12px; }
.messages.selecting .msg:has(.sel-mark:not(.none)):hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.msg.picked { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.sel-mark { flex: none; align-self: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: transparent; margin: 0 4px; transition: background .15s, border-color .15s; }
.sel-mark.none { visibility: hidden; }
.msg.mine .sel-mark { order: 99; margin-right: auto; }
.msg.picked .sel-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.select-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line, rgba(0,0,0,.08)); background: var(--bg); }
.select-bar[hidden] { display: none; }
.select-bar .sel-count { flex: 1; font-weight: 600; }
.select-bar .btn { display: inline-flex; align-items: center; gap: 6px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.field-row select { flex: none; }
.btn.danger.outline { background: transparent; color: var(--danger, #d33); }
.del-group { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* Окна не шире экрана: длинное содержимое переносится, а не раздвигает окно */
.modal-back { grid-template-columns: minmax(0, 1fr); }
.modal { min-width: 0; justify-self: center; }
.modal-body { min-width: 0; overflow-x: hidden; overflow-wrap: break-word; }
.modal .grow { min-width: 0; }
.adm-user { flex-wrap: wrap; }
.adm-user .adm-acts { flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) {
  .adm-user .adm-acts { flex-basis: 100%; padding-left: 44px; }
}

/* Кольцо истории вокруг аватара */
.av-story { position: relative; display: inline-flex; border-radius: 50%; cursor: pointer; flex: none; }
.av-story::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent) 45%, #d65cff);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px)); }
.av-story.seen::before { background: var(--muted); opacity: .45; }
.av-story > .avatar { box-shadow: 0 0 0 2px var(--bg); }
.chat-item.active .av-story.unseen::before { background: #fff; }
.av-story:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.profile-top .av-story::before { inset: -4px; }
/* Кто видит историю */
.story-aud-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.story-aud-btn:hover { border-color: var(--accent); }
.aud-opt.on { background: var(--accent-soft); }
.aud-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.aud-opt[data-aud="close"] .aud-ico { background: #e8f7ec; color: #22a052; }
.sv-aud { opacity: .9; }
/* Клавиатура открыта — убираем отступ под «полоску» iPhone */
.kb-open .composer, .kb-open .select-bar, .kb-open .channel-bar { padding-bottom: 8px; }

/* Новое сообщение плавно «выезжает» снизу — и своё, и собеседника */
.msg.appear .bubble { animation: msgIn .32s cubic-bezier(.2, .9, .3, 1.12) both; transform-origin: bottom left; }
.msg.mine.appear .bubble { transform-origin: bottom right; }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px) scale(.94); } 55% { opacity: 1; } to { opacity: 1; transform: none; } }
.pending-ico { display: inline-flex; opacity: .75; }
@media (prefers-reduced-motion: reduce) { .msg.appear .bubble { animation: none; } }

/* Приглашения */
.inv-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); margin-top: 2px; }
.inv-tag.on { color: #22a052; margin-left: 8px; }
.inv-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.inv-card.expired, .inv-card.exhausted, .inv-card.used { background: var(--bg-2); }
.inv-card .tag.grey { background: var(--line); color: var(--muted); }
.inv-joined { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-joined .chip { display: inline-flex; align-items: center; gap: 6px; }
.invite-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
/* Смена камеры в кружке: короткое «размытие», пока включается другая камера */
.cr-video { transition: filter .2s, opacity .2s; }
.cr-stage.flipping .cr-video { filter: blur(8px); opacity: .7; }

/* Видео в чате: обложка с длительностью, по нажатию — плеер */
.bubble.media-bubble { padding: 4px 4px 6px; }
.bubble.media-bubble .text { padding: 4px 7px 0; }
.bubble.media-bubble > .meta { margin-right: 6px; }
.vmsg { position: relative; width: min(320px, 70vw); max-height: 420px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; display: grid; place-items: center; }
.vmsg-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vmsg-thumb.empty { background: linear-gradient(135deg, #2a2d3a, #11131a); }
.vmsg video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.vmsg-play { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .5); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(4px); }
.vmsg-play svg { margin-left: 3px; }
.vmsg.busy .vmsg-play { animation: vcspin 1s linear infinite; border: 3px solid rgb(255 255 255 / .35); border-top-color: #fff; background: rgb(0 0 0 / .35); }
.vmsg.busy .vmsg-play svg { display: none; }
.vmsg-badge { position: absolute; left: 8px; top: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 4px; background: rgb(0 0 0 / .5); color: #fff; font-size: 12px; border-radius: 10px; padding: 2px 8px; }
.vmsg.ready .vmsg-badge { display: none; }
.thumb.video { position: relative; }
.thumb.video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-badge { position: absolute; left: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; background: rgb(0 0 0 / .55); color: #fff; font-size: 11px; border-radius: 8px; padding: 1px 6px; }
.photo-thumbs .thumb.video video { aspect-ratio: 1; border-radius: 10px; }
.photo-thumbs.single .thumb.video video { aspect-ratio: auto; max-height: 300px; object-fit: contain; background: #000; }
/* Зум в кружке: увеличиваем видео, а обрезка по кругу остаётся прежнего размера */
.cr-stage { touch-action: none; }
.cr-video { transform: scale(var(--z, 1)); clip-path: inset(calc((1 - 1 / var(--z, 1)) * 50%) round calc(22% / var(--z, 1))); }
.cr-video.mirror { transform: scaleX(-1) scale(var(--z, 1)); }
.cr-zoom { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; border: 0; border-radius: 12px; padding: 3px 10px; background: rgb(0 0 0 / .55); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cr-zoom[hidden] { display: none; }
.cr-zoom.dim { opacity: .6; }

/* ---------- Истории: сохранить долгим нажатием нельзя ---------- */
.story-viewer img, .story-viewer video { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.story-viewer { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- Кружок во весь экран ---------- */
.vcircle.playing { width: 220px; height: 220px; }
@media (max-width: 420px) { .vcircle.playing { width: 220px; height: 220px; } }
.vc-ph { position: absolute; inset: 0; border-radius: 22%; background: rgb(0 0 0 / .25); }
.circle-view { position: fixed; inset: 0; z-index: 1300; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgb(10 12 20 / 0); transition: background .22s; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); }
.circle-view.in { background: rgb(10 12 20 / .94); } /* без размытия фона — оно тормозит видео */
.cv-stage { position: relative; width: min(92vw, 72vh, 560px); aspect-ratio: 1; transition: transform .22s cubic-bezier(.2, .9, .3, 1); cursor: pointer; }
.cv-circle { position: absolute; inset: 0; border-radius: 22%; overflow: hidden; background: #000; }
.cv-circle video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-circle.mirror video { transform: scaleX(-1); }
.cv-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); pointer-events: none; }
.cv-ring path { fill: none; stroke: #fff; stroke-width: 1.4; stroke-linecap: round; opacity: .9; transition: stroke-dashoffset .25s linear; }
.cv-paused { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; pointer-events: none; }
.cv-paused[hidden] { display: none; }
.cv-paused svg { width: 72px; height: 72px; padding: 18px 14px 18px 22px; border-radius: 50%; background: rgb(0 0 0 / .45); }
.cv-bar { display: flex; align-items: center; gap: 10px; color: #fff; opacity: 0; transition: opacity .2s; }
.circle-view.in .cv-bar { opacity: 1; }
.cv-time { font-variant-numeric: tabular-nums; font-size: 14px; min-width: 90px; text-align: center; }
.cv-bar .icon-btn { color: #fff; background: rgb(255 255 255 / .14); border-radius: 50%; }
.cv-bar .rate-btn { background: rgb(255 255 255 / .18); color: #fff; }

/* ---------- Скорость воспроизведения ---------- */
.rate-btn { flex: none; border: 0; border-radius: 10px; padding: 2px 7px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-variant-numeric: tabular-nums; }
.rate-btn.on { background: var(--accent); color: #fff; }
.msg.mine .rate-btn { background: rgb(255 255 255 / .22); color: inherit; }
.msg.mine .rate-btn.on { background: #fff; color: var(--accent); }
.rate-pop { position: fixed; z-index: 1400; width: 240px; padding: 12px 14px; border-radius: 14px; background: var(--bg); color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.rate-head { display: flex; justify-content: space-between; font-size: 14px; }
.rate-pop input[type=range] { width: 100%; accent-color: var(--accent); }
.rate-presets { display: flex; gap: 6px; }
.rate-presets button { flex: 1; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 13px; padding: 5px 0; cursor: pointer; }
.rate-presets button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Сверка шифрования */
.pair-code { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg-2); display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.pair-code:empty { display: none; }
.pc-head { display: flex; align-items: center; gap: 6px; color: #22a052; }
.pc-emoji { display: flex; gap: 10px; font-size: 34px; line-height: 1.1; }
.pc-digits { letter-spacing: .08em; color: var(--muted); font-size: 13px; }
.keys-details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* Отложенные сообщения */
.sched-bar { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 14px; border: 0; border-top: 1px solid var(--line); background: var(--bg); color: var(--accent); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.sched-bar[hidden] { display: none; }
.sched-ico { color: var(--muted); display: inline-flex; }
.sched-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.sched-when { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); font-weight: 600; }
.sched-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sched-pick .menu-item { display: flex; align-items: center; gap: 6px; }
.sched-pick .grow-right { margin-left: auto; }

/* Папки чатов */
.folder-tabs { display: flex; gap: 6px; padding: 2px 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tabs[hidden] { display: none; }
.ftab { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--bg-2); color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ftab.on { background: var(--accent); color: #fff; }
.ftab.add { padding: 6px 9px; }
.fbadge { 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; }
.ftab.on .fbadge { background: #fff; color: var(--accent); }

/* Голосовое: прослушать и обрезать перед отправкой */
.rec-stop { color: var(--danger); }
.vp { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 4px; }
.vplay.small { width: 34px; height: 34px; flex: none; }
.vp-track { position: relative; flex: 1; height: 36px; display: flex; align-items: center; touch-action: none; }
.vp-bars { display: flex; align-items: center; gap: 2px; width: 100%; height: 100%; padding: 0 8px; }
.vp-bars span { flex: 1; min-width: 2px; border-radius: 2px; background: var(--accent); opacity: .7; }
.vp-shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); pointer-events: none; }
.vp-shade.l { left: 0; border-radius: 8px 0 0 8px; }
.vp-shade.r { right: 0; border-radius: 0 8px 8px 0; }
.vp-handle { position: absolute; top: -2px; bottom: -2px; width: 14px; margin-left: -7px; border-radius: 6px; background: var(--accent); cursor: ew-resize; touch-action: none; }
.vp-handle::after { content: ''; position: absolute; left: 6px; top: 30%; bottom: 30%; width: 2px; border-radius: 1px; background: #fff; }
.vp-head { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.vp-head[hidden] { display: none; }

/* Поделиться в G-чат */
.share-prev { display: flex; gap: 6px; overflow-x: auto; }
.share-prev img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; }
.share-file { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); font-size: 13px; max-width: 200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Скрытый текст (спойлер): «пыль» вместо букв, по нажатию — проявляется */
.spoiler { color: transparent; border-radius: 5px; cursor: pointer; -webkit-user-select: none; user-select: none;
  background-image: radial-gradient(circle, color-mix(in srgb, currentColor 0%, var(--text) 60%) 0.6px, transparent 1.2px), radial-gradient(circle, color-mix(in srgb, var(--text) 40%, transparent) 0.5px, transparent 1px);
  background-size: 4px 4px, 5px 5px; background-position: 0 0, 2px 1px; background-color: color-mix(in srgb, var(--text) 8%, transparent);
  animation: spoilerDust 1.6s linear infinite; transition: color .3s, background-color .3s; }
.spoiler .mention, .spoiler a { color: transparent; pointer-events: none; }
.spoiler.revealed { color: inherit; background: none; animation: none; cursor: text; -webkit-user-select: text; user-select: text; }
.spoiler.revealed .mention, .spoiler.revealed a { color: inherit; pointer-events: auto; }
@keyframes spoilerDust { to { background-position: 4px 4px, -3px 6px; } }
@media (prefers-reduced-motion: reduce) { .spoiler { animation: none; } }
.spoiler-chip { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 5; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 7px 14px; background: var(--text); color: var(--bg); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.spoiler-chip[hidden] { display: none; }

/* «Посмотреть один раз» */
.once-box { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 6px 4px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.once-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--accent) 14%, transparent); flex: none; }
.once-text { display: flex; flex-direction: column; gap: 2px; }
.once-box.mine { cursor: default; }
.once-view { position: fixed; inset: 0; z-index: 1500; background: #000; display: flex; flex-direction: column; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.once-top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-top)) 12px 10px 16px; color: #fff; font-size: 14px; }
.once-top .icon-btn { color: #fff; }
.once-media { flex: 1; min-height: 0; display: grid; place-items: center; }
.once-media img, .once-media video { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-touch-callout: none; }
.once-media img { pointer-events: none; }
.once-caption { color: #fff; padding: 10px 16px calc(14px + var(--safe-bottom)); text-align: center; }
.once-row span { font-size: 14px; }

/* Мини-игры */
.bubble.game-bubble { background: none !important; box-shadow: none; padding: 0; }
.game { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px; }
.msg.mine .game { align-items: flex-end; }
.game-res { font-size: 13.5px; padding: 3px 10px; border-radius: 12px; background: var(--bubble); box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg.mine .game-res { background: var(--bubble-mine); }
.game.win .game-res b { color: #22a052; }
.game-emoji { font-size: 72px; line-height: 1; }
.game.rolling .game-emoji { animation: gameThrow 1.3s cubic-bezier(.3, .7, .4, 1) both; }
.game.rolling.g-darts .game-emoji { animation-name: gameDart; }
.game.rolling.g-bowling .game-emoji { animation-name: gameRoll; }
@keyframes gameThrow { 0% { transform: translateY(40px) scale(.5) rotate(-40deg); opacity: 0; } 45% { transform: translateY(-34px) scale(1.1) rotate(200deg); opacity: 1; } 70% { transform: translateY(6px) rotate(330deg); } 85% { transform: translateY(-6px) rotate(355deg); } 100% { transform: none; } }
@keyframes gameDart { 0% { transform: scale(2.4); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } 80% { transform: scale(1.06); } 100% { transform: none; } }
@keyframes gameRoll { 0% { transform: translateX(-80px) rotate(-360deg); opacity: 0; } 70% { transform: translateX(6px) rotate(10deg); opacity: 1; } 100% { transform: none; } }
.game.win .game-emoji { filter: drop-shadow(0 0 10px rgb(255 200 0 / .6)); }
.die { width: 76px; height: 76px; border-radius: 16px; background: #fff; box-shadow: inset 0 -4px 0 rgb(0 0 0 / .12), 0 3px 10px rgb(0 0 0 / .18); display: grid; grid-template-columns: repeat(3, 1fr); padding: 10px; gap: 4px; }
.die i { border-radius: 50%; }
.die i.on { background: #d93a3a; }
.game.rolling .die { animation: dieShake .22s linear infinite; }
@keyframes dieShake { 25% { transform: rotate(14deg) translateY(-4px); } 75% { transform: rotate(-14deg) translateY(2px); } }
.slot { display: flex; gap: 6px; padding: 10px 12px; border-radius: 16px; background: linear-gradient(#2a2440, #4b3a78); box-shadow: 0 3px 10px rgb(0 0 0 / .25); }
.reel { width: 48px; height: 52px; border-radius: 10px; background: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #b5172b; overflow: hidden; }
.reel.bar { font-size: 14px; letter-spacing: -.02em; }
.game.rolling .reel:not(.stop) { filter: blur(1px); }
.reel.stop { animation: reelStop .25s ease-out; }
@keyframes reelStop { 0% { transform: translateY(-8px); } 100% { transform: none; } }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.game-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.game-tile:hover { border-color: var(--accent); }
.gt-e { font-size: 32px; line-height: 1.1; }
.menu-emoji { width: 18px; display: inline-grid; place-items: center; font-size: 16px; }
.bubble.game-bubble-ttt { padding: 10px; }
.ttt-box { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 210px; }
.ttt-head { display: flex; gap: 8px; font-size: 13.5px; font-weight: 600; }
.ttt-head .x, .ttt-cell.x { color: #d93a3a; }
.ttt-head .o, .ttt-cell.o { color: #3d8fd1; }
.ttt { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 4px; }
.ttt-cell { border: 0; border-radius: 10px; background: rgb(127 127 127 / .14); font: inherit; font-size: 32px; font-weight: 700; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.ttt-cell:disabled { cursor: default; }
.ttt-cell:not(:disabled):hover { background: rgb(127 127 127 / .26); }
.ttt-cell.win { background: rgb(34 160 82 / .3); }
.ttt-status { font-size: 13px; opacity: .8; }
.ttt-status.my { font-weight: 700; opacity: 1; }
@media (prefers-reduced-motion: reduce) { .game.rolling .game-emoji, .game.rolling .die { animation: none; } }

/* QR-код профиля */
.qr-box { align-items: center; }
.qr-card { background: linear-gradient(160deg, var(--accent), #8b6fe0); border-radius: 22px; padding: 18px 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; width: min(300px, 100%); }
.qr-card .muted { color: rgb(255 255 255 / .8); }
.qr-pic { position: relative; width: 100%; aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 8px; }
.qr-pic svg { width: 100%; height: 100%; display: block; }
.qr-av { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 4px; border-radius: 50%; background: #fff; }
.qr-name { font-weight: 700; font-size: 18px; margin-top: 8px; }
.row.center { justify-content: center; }
.qr-scan { position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #000; }
.qr-scan-video { width: 100%; height: 100%; object-fit: cover; }
.qr-frame { position: absolute; inset: 18%; border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 999px rgb(0 0 0 / .35); }

/* Фильтры кружка */
.cr-filters { display: flex; gap: 8px; overflow-x: auto; max-width: min(92vw, 420px); padding: 2px 4px; scrollbar-width: none; }
.cr-filters::-webkit-scrollbar { display: none; }
.cr-filters[hidden] { display: none; }
.cr-filter { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: rgb(255 255 255 / .75); font: inherit; font-size: 11.5px; cursor: pointer; }
.cr-fsw { width: 40px; height: 40px; border-radius: 50%; border: 2px solid transparent; background: linear-gradient(135deg, #f6c38b 0%, #e2725b 35%, #5aa7d6 70%, #4a8a4d 100%); }
.cr-filter.on { color: #fff; font-weight: 700; }
.cr-filter.on .cr-fsw { border-color: #fff; }

/* Живая аватарка */
.avatar.live { position: relative; }
.avatar .av-video::-webkit-media-controls, .avatar .av-video::-webkit-media-controls-start-playback-button { display: none !important; -webkit-appearance: none; }
.avatar .av-video { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.avatar.live.playing .av-video { opacity: 1; }
.la-box { align-items: center; }
.la-stage { position: relative; width: min(280px, 80vw); aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: #000; }
.la-video { width: 100%; height: 100%; object-fit: cover; }
.la-video.mirror { transform: scaleX(-1); }
.la-ring { position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; pointer-events: none; }
.la-ring.rec { border-color: #e5484d; animation: laPulse 1s ease-in-out infinite; }
@keyframes laPulse { 50% { border-color: rgb(229 72 77 / .4); } }

/* Альбомы */
.album { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; width: min(340px, 70vw); border-radius: 12px; overflow: hidden; }
.al-tile { grid-column: span 2; position: relative; aspect-ratio: 1; border: 0; padding: 0; margin: 0; background: rgb(127 127 127 / .2); cursor: pointer; overflow: hidden; }
.al-tile img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-touch-callout: none; }
.al-tile.video::after { content: ''; position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px; border-radius: 50%; background: rgb(0 0 0 / .45) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6v12l10-6z' fill='white'/%3E%3C/svg%3E") center/55% no-repeat; }
.al-badge { position: absolute; left: 5px; bottom: 5px; z-index: 1; display: inline-flex; align-items: center; gap: 3px; background: rgb(0 0 0 / .5); color: #fff; font-size: 11px; border-radius: 8px; padding: 1px 6px; }
.album.n2 .al-tile, .album.n4 .al-tile { grid-column: span 3; }
.album.n3 .al-tile { grid-column: span 3; }
.album.n3 .al-tile:first-child { grid-column: span 6; aspect-ratio: 2 / 1; }
.album.n5 .al-tile:nth-child(-n+2), .album.n8 .al-tile:nth-child(-n+2) { grid-column: span 3; }
.album.n7 .al-tile:nth-child(-n+4), .album.n10 .al-tile:nth-child(-n+4) { grid-column: span 3; }
.gallery { position: fixed; inset: 0; z-index: 1500; background: #000; display: flex; flex-direction: column; }
.gal-top { display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--safe-top)) 10px 8px 16px; color: #fff; }
.gal-top .icon-btn { color: #fff; }
.gal-count { flex: 1; font-size: 14px; }
.gal-stage { flex: 1; min-height: 0; display: grid; place-items: center; touch-action: pan-y; padding-bottom: var(--safe-bottom); }
.gal-stage img, .gal-stage video { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-user-drag: none; }
.gal-stage.slideL > * { animation: galL .22s ease-out; }
.gal-stage.slideR > * { animation: galR .22s ease-out; }
@keyframes galL { from { transform: translateX(60px); opacity: .3; } }
@keyframes galR { from { transform: translateX(-60px); opacity: .3; } }
.gal-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .14); color: #fff; display: grid; place-items: center; cursor: pointer; }
.gal-nav.prev { left: 12px; }
.gal-nav.next { right: 12px; }
@media (pointer: coarse) { .gal-nav { display: none; } }
.gal-err { color: #fff; padding: 20px; text-align: center; }

/* Редактор фото */
.photo-editor { position: fixed; inset: 0; z-index: 1400; background: #0d0e14; color: #fff; display: flex; flex-direction: column; -webkit-user-select: none; user-select: none; }
.pe-top { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-top)) 12px 10px; }
.pe-top .btn:not(.primary) { background: rgb(255 255 255 / .12); color: #fff; border-color: transparent; }
.pe-top .icon-btn { color: #fff; }
.pe-top .icon-btn:disabled { opacity: .35; }
.pe-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; overflow: hidden; }
.pe-frame { position: relative; touch-action: none; }
.pe-canvas { width: 100%; height: 100%; display: block; border-radius: 6px; touch-action: none; }
.pe-canvas.drawing { cursor: crosshair; }
.pe-layer { position: absolute; inset: 0; pointer-events: none; }
.pe-obj { position: absolute; pointer-events: auto; cursor: move; touch-action: none; padding: 6px; border: 1.5px dashed transparent; border-radius: 8px; white-space: pre; line-height: 1.2; }
.pe-obj.on { border-color: rgb(255 255 255 / .8); }
.pe-del { position: absolute; top: -12px; right: -12px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #e5484d; color: #fff; display: none; place-items: center; cursor: pointer; }
.pe-obj.on .pe-del { display: grid; }
.pe-text { font: 700 30px -apple-system, system-ui, sans-serif; -webkit-text-stroke-width: 5px; paint-order: stroke fill; text-align: center; display: block; }
.pe-emoji { font-size: 64px; line-height: 1.2; display: block; }
.pe-obj.sticker img { width: 110px; display: block; pointer-events: none; }
.pe-opts { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 6px 12px; }
.pe-colors { display: flex; gap: 8px; }
.pe-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .35); cursor: pointer; padding: 0; }
.pe-color.on { border-color: #fff; transform: scale(1.18); }
.modal .pe-color { border-color: var(--line); }
.modal .pe-color.on { border-color: var(--accent); }
.pe-size { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgb(255 255 255 / .75); }
.pe-size input { width: 120px; accent-color: #fff; }
.pe-hint { font-size: 12.5px; color: rgb(255 255 255 / .6); }
.pe-tools { display: flex; justify-content: space-around; gap: 4px; padding: 8px 8px calc(10px + var(--safe-bottom)); border-top: 1px solid rgb(255 255 255 / .08); }
.pe-tool { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: rgb(255 255 255 / .7); font: inherit; font-size: 11.5px; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.pe-tool.on { color: #fff; background: rgb(255 255 255 / .12); }
.pe-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-height: 60vh; overflow-y: auto; }
.pe-st { border: 0; background: var(--bg-2); border-radius: 10px; aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; padding: 4px; }
.pe-st img { width: 100%; height: 100%; object-fit: contain; }
.pe-st.emoji { font-size: 32px; }
.photo-editor ~ .modal-back { z-index: 1450; }
.pe-obj, .pe-obj.on { background: transparent !important; }
.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.fx-chips .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Узкая колонка чатов: кнопки в шапке никогда не уезжают за край */
.sidebar { container: side / inline-size; }
.side-actions { flex: none; }
.side-head .brand { min-width: 0; overflow: hidden; }
@container side (max-width: 400px) { .news-btn span { display: none; } .news-btn { padding: 0 7px; } }
@container side (max-width: 300px) { .side-head { gap: 4px; padding-left: 8px; padding-right: 6px; } .side-actions .icon-btn { width: 34px; } }

/* ---------- Боты ---------- */
.bot-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 17px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.e2e.off { color: var(--muted); }
.e2e-note.bot-note { color: #9a6a00; background: #fff6dd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .e2e-note.bot-note { color: #f2c76b; background: #3a3220; } }
:root[data-theme="dark"] .e2e-note.bot-note { color: #f2c76b; background: #3a3220; }
/* обычному боту можно всё, как человеку (файлы, стикеры, кружки); G-роботу — без стикеров и кружков */
.chat.ai-bot-chat .emoji-btn, .chat.ai-bot-chat .circle-btn { display: none !important; }
.bot-menu-btn { flex: none; align-self: flex-end; width: 34px; height: 34px; margin: 0 2px 3px; border-radius: 10px; border: 0; background: var(--accent-soft); color: var(--accent); font-family: inherit; font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer; }
.bot-menu-btn:hover { filter: brightness(.96); }
.bot-kb-btn.on { color: var(--accent); }
.bot-start { font-weight: 600; color: var(--accent); }
.bot-off { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 6px; }
.cmd-item { gap: 12px; }
.cmd-item .cmd-name { font-weight: 600; color: var(--accent); white-space: nowrap; }
.cmd-item .grow { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* кнопки под сообщением бота */
.ikb { display: flex; flex-direction: column; gap: 4px; margin: 6px -4px 2px; min-width: 200px; }
.ikb-row { display: flex; gap: 4px; }
.ikb-btn { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background .15s, opacity .15s; }
.ikb-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ikb-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.ikb-btn.busy { opacity: .55; pointer-events: none; animation: ikb-pulse 1s ease-in-out infinite; }
@keyframes ikb-pulse { 50% { opacity: .3; } }
/* клавиатура бота над полем ввода */
.bot-kb { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 4px; background: var(--bg); border-top: 1px solid var(--line); max-height: 40vh; overflow-y: auto; }
.bkb-row { display: flex; gap: 6px; }
.bkb-btn { flex: 1 1 0; min-width: 0; padding: 11px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bubble); color: inherit; font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1.2; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bkb-btn:hover { border-color: var(--accent); color: var(--accent); }
/* «Мои боты» и документация */
.bot-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bot-row:hover { border-color: var(--accent); }
.bot-row-name { font-weight: 600; }
.bot-state { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--line); color: var(--muted, #8a8fa3); white-space: nowrap; }
.bot-state.on { background: #dcf5e3; color: #1f8a46; }
.warn-note { padding: 10px 12px; border-radius: 12px; background: #fff6dd; color: #7a5600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn-note { background: #3a3220; color: #f2c76b; } }
:root[data-theme="dark"] .warn-note { background: #3a3220; color: #f2c76b; }
.token-box input { font-size: 13px; }
.code-box { position: relative; border-radius: 12px; background: #1d2030; color: #e6e8f2; }
.code-box pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; white-space: pre; }
.code-box .code-copy { position: absolute; top: 6px; right: 6px; opacity: .85; }
.bot-docs h3 { margin: 10px 0 0; }
.docs-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.docs-methods { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.docs-methods code { font-weight: 600; color: var(--accent); }
.bot-warn { display: flex; gap: 6px; align-items: flex-start; }
.pre-wrap { white-space: pre-wrap; }
.bot-kb[hidden], .bot-menu-btn[hidden] { display: none !important; }

/* Реакции на новости */
.news-reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; position: relative; }
.nr-chip, .nr-add { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: inherit; font-family: inherit; font-size: 14px; cursor: pointer; transition: transform .12s, background .15s, border-color .15s; }
.nr-chip:active, .nr-opt:active { transform: scale(.92); }
.nr-chip.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.nr-e { font-size: 16px; line-height: 1; }
.nr-add { color: var(--muted); }
.nr-add:hover, .nr-chip:hover { border-color: var(--accent); }
.nr-pick { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; padding: 6px; border-radius: 14px; background: var(--bg-2); }
.nr-pick[hidden] { display: none; }
.nr-opt { width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; font-size: 22px; cursor: pointer; }
.nr-opt:hover { background: var(--bg); }
.nr-opt.mine { background: var(--accent-soft); }

/* ---------- Морской бой ---------- */
:root { --sea: #e7f0fb; --sea-line: #c6d8ee; --sea-ship: #2f3e64; --sea-hit: #ef4444; --sea-kill: #8f1d1d; --sea-dot: #5d7aa6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sea: #17223a; --sea-line: #2a3b5c; --sea-ship: #9fb3dc; --sea-dot: #8ea7cf; --sea-kill: #c03a3a; } }
:root[data-theme="dark"] { --sea: #17223a; --sea-line: #2a3b5c; --sea-ship: #9fb3dc; --sea-dot: #8ea7cf; --sea-kill: #c03a3a; }
.sea-board { --cell: 1fr; }
.sea-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 1px; padding: 1px; aspect-ratio: 1; background: var(--sea-line); border-radius: 8px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.sea-grid .sc { position: relative; display: block; min-width: 0; padding: 0; border: 0; border-radius: 0; background: var(--sea); font: inherit; color: inherit; }
.sea-grid .sc.ship { background: var(--sea-ship); }
.sea-grid .sc.ship.reveal { background: var(--sea); box-shadow: inset 0 0 0 2px var(--sea-ship); }
.sea-grid .sc::after { content: ''; position: absolute; inset: 0; margin: auto; }
.sea-grid .sc.s-m::after, .sea-grid .sc.s-a::after { width: 26%; height: 26%; border-radius: 50%; background: var(--sea-dot); }
.sea-grid .sc.s-a::after { opacity: .45; }
.sea-grid .sc.s-h, .sea-grid .sc.s-k { background: var(--sea-hit); }
.sea-grid .sc.s-k { background: var(--sea-kill); }
.sea-grid .sc.s-h::after, .sea-grid .sc.s-k::after { width: 62%; height: 62%; background:
  linear-gradient(45deg, transparent 42%, #fff 42%, #fff 58%, transparent 58%),
  linear-gradient(-45deg, transparent 42%, #fff 42%, #fff 58%, transparent 58%); }
.sea-grid .sc.ghost { background: color-mix(in srgb, #22c55e 55%, var(--sea)); }
.sea-grid .sc.ghost-bad { background: color-mix(in srgb, var(--sea-hit) 55%, var(--sea)); }
.sea-board.aim .sc:not(:disabled) { cursor: crosshair; }
.sea-board.aim .sc:not(:disabled):hover { background: color-mix(in srgb, var(--accent) 22%, var(--sea)); }
.sea-board.aim .sea-grid { box-shadow: 0 0 0 2px var(--accent); }
/* подписи А–К и 1–10 */
.sea-board.labeled { display: grid; grid-template-columns: 18px 1fr; grid-template-rows: 18px 1fr; }
.sea-cols { grid-column: 2; display: grid; grid-template-columns: repeat(10, 1fr); }
.sea-rows { grid-row: 2; display: grid; grid-template-rows: repeat(10, 1fr); }
.sea-cols span, .sea-rows span { display: grid; place-items: center; font-size: 10.5px; color: var(--muted); }
.sea-board.labeled .sea-grid { grid-column: 2; grid-row: 2; }
/* выстрел: брызги и взрыв */
.sea-grid .sc.fresh.fx-miss::before { content: ''; position: absolute; inset: 0; margin: auto; width: 30%; height: 30%; border-radius: 50%; border: 2px solid var(--sea-dot); animation: sea-splash .7s ease-out forwards; }
@keyframes sea-splash { to { width: 160%; height: 160%; opacity: 0; } }
.sea-grid .sc.fresh.fx-hit, .sea-grid .sc.fresh.fx-kill { animation: sea-boom .6s ease-out; z-index: 1; }
@keyframes sea-boom { 0% { transform: scale(1.6); background: #ffd34d; box-shadow: 0 0 18px 6px rgba(255, 170, 0, .8); } 100% { transform: scale(1); } }
.sea-grid.shake, .sea-board.shake .sea-grid { animation: sea-shake .3s; }
@keyframes sea-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
/* карточка в чате */
.sea-card { width: 260px; max-width: 100%; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.sea-card-head { display: flex; align-items: center; gap: 6px; }
.sea-logo { font-size: 18px; }
.sea-card-vs { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.sea-card-vs span:first-child, .sea-card-vs span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sea-card-vs span:last-child { text-align: right; }
.sea-score { font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: 8px; background: var(--bg-2); }
.sea-minis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sea-minis > div { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sea-minis .sea-board { width: 100%; }
.sea-board.mini .sea-grid { gap: 0.5px; padding: 0.5px; border-radius: 5px; }
.sea-status { font-size: 13.5px; text-align: center; color: var(--muted); }
.sea-status.my { color: var(--accent); font-weight: 700; }
.sea-card .btn { align-self: center; }
.sea-card.hot .sea-status.my { animation: sea-pulse 1.6s ease-in-out infinite; }
@keyframes sea-pulse { 50% { opacity: .55; } }
/* окно игры */
.modal.sea-modal { max-width: 880px; }
.sea-game { display: flex; flex-direction: column; gap: 14px; }
.sea-banner { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; padding: 10px 14px; border-radius: 14px; background: var(--bg-2); }
.sea-banner.my { background: var(--accent-soft); color: var(--accent); }
.sea-banner.won { background: #fff5d6; color: #8a6200; }
.sea-banner.lost { background: var(--bg-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sea-banner.won { background: #3a3220; color: #f2c76b; } }
:root[data-theme="dark"] .sea-banner.won { background: #3a3220; color: #f2c76b; }
.sea-boards { display: flex; gap: 22px; align-items: flex-start; justify-content: center; }
.sea-side { display: flex; flex-direction: column; gap: 8px; }
.enemy-side { width: min(440px, 100%); }
.own-side { width: min(320px, 100%); }
.sea-cap { font-size: 14px; }
.sea-setup { width: min(440px, 100%); margin: 0 auto; }
.sea-actions { justify-content: center; }
.sea-cancel { align-self: center; color: var(--muted); }
.sea-fleet { display: flex; flex-wrap: wrap; gap: 6px; }
.sea-fleet .sf { display: inline-flex; gap: 1px; }
.sea-fleet .sf i { width: 9px; height: 9px; border-radius: 2px; background: var(--sea-ship); }
.sea-fleet .sf.dead i { background: var(--sea-hit); opacity: .45; }
@media (max-width: 760px) {
  .sea-boards { flex-direction: column; align-items: center; gap: 14px; }
  .enemy-side { width: 100%; }
  .own-side { width: 66%; }
}
@media (prefers-reduced-motion: reduce) { .sea-grid .sc.fresh, .sea-grid .sc.fresh::before, .sea-card.hot .sea-status.my { animation: none !important; } }

/* ---------- Морской бой: тетрадный лист и кораблики ---------- */
:root {
  --paper: #fdfcf6; --pgrid: #bcd0ea; --ink: #2a4a8f; --pen-red: #d3322a;
  --hull: #75879f; --hull-dark: #34435c; --deck: #b9c6d8; --cabin: #f1f4f8;
  --pen-font: "Segoe Print", "Bradley Hand", "Marker Felt", "Comic Sans MS", "Chalkboard SE", cursive;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --paper: #1b2030; --pgrid: #2d3a56; --ink: #9db7ef; --pen-red: #ff6a60; --hull: #8a9bb6; --hull-dark: #1f293b; --deck: #55667f; --cabin: #cfd8e6; } }
:root[data-theme="dark"] { --paper: #1b2030; --pgrid: #2d3a56; --ink: #9db7ef; --pen-red: #ff6a60; --hull: #8a9bb6; --hull-dark: #1f293b; --deck: #55667f; --cabin: #cfd8e6; }
.sea-grid {
  gap: 0; padding: 0; border-radius: 2px; overflow: visible; position: relative;
  border: 2px solid var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(to right, var(--pgrid) 1px, transparent 1px), linear-gradient(to bottom, var(--pgrid) 1px, transparent 1px);
  background-size: 10% 10%;
}
.sea-board.mini .sea-grid { gap: 0; padding: 0; border-width: 1.5px; border-radius: 2px; }
.sea-grid .sc { background: transparent; z-index: 2; }
.sea-grid .sc.ship, .sea-grid .sc.ship.reveal { background: transparent; box-shadow: none; }
.sea-grid .sc.ghost, .sea-grid .sc.ghost-bad { background: transparent; }
/* отметки ручкой: точка — мимо, крестик — попал */
.sea-grid .sc.s-m::after { width: 24%; height: 24%; border-radius: 50%; background: var(--ink); opacity: .85; }
.sea-grid .sc.s-a::after { width: 16%; height: 16%; border-radius: 50%; background: var(--ink); opacity: .4; }
.sea-grid .sc.s-h, .sea-grid .sc.s-k { background: transparent; }
.sea-grid .sc.s-h::after, .sea-grid .sc.s-k::after {
  width: 84%; height: 84%; background: var(--pen-red);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3.6 3.8 Q9.8 10.6 16.6 16.4 M16.3 3.4 Q9.4 10.1 3.7 16.7' stroke='black' stroke-width='2.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3.6 3.8 Q9.8 10.6 16.6 16.4 M16.3 3.4 Q9.4 10.1 3.7 16.7' stroke='black' stroke-width='2.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.sea-board.aim .sc:not(:disabled):hover { background: color-mix(in srgb, var(--ink) 13%, transparent); }
.sea-board.aim .sea-grid { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
/* кораблики */
.sea-ships { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sea-ship { position: absolute; }
.sea-ship svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sea-ship .hull, .sea-fleet .hull { fill: var(--hull); stroke: var(--hull-dark); stroke-width: 1; stroke-linejoin: round; }
.sea-ship .deck, .sea-fleet .deck { fill: var(--deck); }
.sea-ship .cabin, .sea-fleet .cabin { fill: var(--cabin); stroke: var(--hull-dark); stroke-width: .6; }
.sea-ship .turret, .sea-ship .gun, .sea-fleet .turret, .sea-fleet .gun { fill: var(--hull-dark); }
.sea-ship .barrel, .sea-fleet .barrel { stroke: var(--hull-dark); stroke-width: 1.8; stroke-linecap: round; }
.sea-ship.sunk { opacity: .5; filter: grayscale(1); }
.sea-ship.sunk .hull { fill: #7c6a6a; }
.sea-ship.reveal { opacity: .55; }
.sea-ship.reveal .hull { stroke-dasharray: 2 1.5; }
.sea-ship.lifted { opacity: .2; }
.sea-ship.ghost { opacity: .75; }
.sea-ship.ghost .hull { fill: #3fae6a; stroke: #1f6b3e; }
.sea-ship.bad { opacity: .7; }
.sea-ship.bad .hull { fill: var(--pen-red); stroke: #7a1410; }
.sea-board.mini .sea-ship .hull { stroke-width: 1.4; }
/* подписи — «от руки» */
.sea-cols span, .sea-rows span { font-family: var(--pen-font); color: var(--ink); font-size: 12px; }
/* окно игры — тетрадный лист с полями */
.sea-game {
  padding: 14px 12px 16px 36px; border-radius: 14px;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 26px, rgba(214, 70, 70, .45) 26px, rgba(214, 70, 70, .45) 27.5px, transparent 27.5px),
    linear-gradient(to right, color-mix(in srgb, var(--pgrid) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--pgrid) 55%, transparent) 1px, transparent 1px);
  background-size: 100% 100%, 18px 18px, 18px 18px;
}
.sea-game .sea-banner { background: color-mix(in srgb, var(--bg) 82%, transparent); }
.sea-game .sea-banner.my { background: color-mix(in srgb, var(--accent-soft) 90%, transparent); }
.sea-cap b { font-family: var(--pen-font); color: var(--ink); font-size: 16px; }
.sea-fleet { gap: 8px; align-items: center; }
.sea-fleet .sf { display: inline-block; height: 13px; }
.sea-fleet .sf svg { display: block; width: 100%; height: 100%; }
.sea-fleet .sf.dead { opacity: .3; filter: grayscale(1); }
.sea-card .sea-card-head b { font-family: var(--pen-font); }
@media (max-width: 760px) { .sea-game { padding-left: 30px; background-size: 100% 100%, 16px 16px, 16px 16px; } .sea-game { background-image: linear-gradient(90deg, transparent 20px, rgba(214, 70, 70, .45) 20px, rgba(214, 70, 70, .45) 21.5px, transparent 21.5px), linear-gradient(to right, color-mix(in srgb, var(--pgrid) 55%, transparent) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in srgb, var(--pgrid) 55%, transparent) 1px, transparent 1px); } }

/* Клетки полей совпадают с клетками листа: размер клетки --q задаёт sea.js */
.sea-fleet .sf { width: calc(var(--len, 1) * 13px); }
.sea-game {
  --q: 32px;
  padding: 12px 12px 16px 30px;
  background-image:
    linear-gradient(90deg, transparent 21px, rgba(214, 70, 70, .45) 21px, rgba(214, 70, 70, .45) 22.5px, transparent 22.5px),
    linear-gradient(to right, var(--pgrid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--pgrid) 1px, transparent 1px);
  background-size: 100% 100%, var(--q) var(--q), var(--q) var(--q);
  background-position: 0 0, var(--qx, 0px) var(--qy, 0px), var(--qx, 0px) var(--qy, 0px);
}
.sea-game .sea-board.labeled { width: calc(var(--q) * 11); grid-template-columns: var(--q) calc(var(--q) * 10); grid-template-rows: var(--q) calc(var(--q) * 10); }
.sea-game .sea-grid { width: calc(var(--q) * 10); height: calc(var(--q) * 10); aspect-ratio: auto; border: 0; background: transparent; box-shadow: 0 0 0 2px var(--ink); }
.sea-game .sea-cols span, .sea-game .sea-rows span { font-size: calc(var(--q) * .4); }
.sea-game .sea-side, .sea-game .enemy-side, .sea-game .own-side, .sea-game .sea-setup { width: calc(var(--q) * 11); gap: 0; }
.sea-game .sea-boards { flex-direction: row; align-items: flex-start; justify-content: center; gap: var(--q); }
.sea-game.stacked .sea-boards { flex-direction: column; align-items: center; }
.sea-game .sea-cap { height: var(--q); line-height: var(--q); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sea-game .sea-fleet { height: var(--q); flex-wrap: nowrap; gap: calc(var(--q) * .18); overflow: hidden; padding-left: var(--q); }
.sea-game .sea-fleet .sf { width: calc(var(--len, 1) * var(--q) * .4); height: calc(var(--q) * .38); }
.sea-game .sea-board.aim .sea-grid { box-shadow: 0 0 0 2px var(--ink), 0 0 0 5px color-mix(in srgb, var(--accent) 30%, transparent); }

/* перемотка голосовых и аудио */
.abar-hit { padding: 9px 0; margin: -6px 0 -4px; cursor: pointer; touch-action: none; }
.abar-hit .abar { overflow: visible; }
.abar-hit .afill::after { content: ''; position: absolute; right: -6px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 3px rgb(0 0 0 / .3); transform: scale(0); transition: transform .15s; }
.abar-hit:hover .afill::after, .abar-hit.scrubbing .afill::after { transform: scale(1); }
.vwave { touch-action: none; }
.vwave.scrubbing span { transition: none; }
.gal-stage { overflow: hidden; }
.gal-stage img { will-change: transform; cursor: zoom-in; }
.gal-stage.zoomed img { cursor: grab; }
.mf-view-box { overflow: hidden; }

/* перемотка историй */
.sv-bars { padding: 8px 0; margin: -8px 0; cursor: pointer; touch-action: none; }
.sv-frame { touch-action: none; }
.sv-seek { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; padding: 8px 14px; border-radius: 999px; background: rgb(0 0 0 / .55); color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.sv-seek[hidden] { display: none; }

/* «Отправить позже» над кнопкой отправки */
.sched-chip { position: absolute; right: 10px; bottom: 72px; z-index: 6; display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 14px; padding: 10px 16px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow), 0 0 0 1px var(--line); animation: tin .15s; }
.sched-chip[hidden] { display: none; }
.sched-chip svg { color: var(--accent); }
.send-btn { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- Просмотр документов ---------- */
.docv { position: fixed; inset: 0; z-index: 1500; display: flex; flex-direction: column; background: var(--bg-2); padding-top: var(--safe-top); }
.docv.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.docv-top { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.docv-title { flex: 1; min-width: 0; }
.docv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docv-info { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docv-zoom { display: flex; align-items: center; gap: 2px; }
.docv-zoom[hidden] { display: none; }
.docv-zoom .icon-btn { font-size: 22px; font-weight: 500; }
.docv-zoom-val { min-width: 44px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.docv-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--safe-bottom); }
.docv-content { min-height: 100%; transform-origin: 0 0; }
.docv-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 60vh; padding: 24px; text-align: center; color: var(--muted); }
.docv-msg p { max-width: 420px; margin: 0; }
.docv-pad { padding: 8px 14px; }
/* PDF */
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; width: max-content; min-width: 100%; box-sizing: border-box; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .18); flex: none; }
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; background: #fff; }
.pdf-num { position: absolute; inset: 0; display: grid; place-items: center; color: #b8bcc8; font-size: 22px; }
/* Word */
.docx-page { max-width: 820px; margin: 12px auto; padding: 36px 40px; background: #fff; color: #1d2030; box-shadow: 0 1px 4px rgb(0 0 0 / .14); border-radius: 4px; line-height: 1.5; font-size: 15px; overflow-wrap: anywhere; }
@media (max-width: 760px) { .docx-page { margin: 0; padding: 18px 16px; border-radius: 0; box-shadow: none; } }
.docx-page .docx-p { margin: 0 0 .55em; }
.docx-page h1.docx-p, .docx-page h2.docx-p { font-size: 1.5em; margin: .6em 0 .4em; }
.docx-page h3.docx-p { font-size: 1.25em; margin: .6em 0 .35em; }
.docx-page h4.docx-p, .docx-page h5.docx-p, .docx-page h6.docx-p { font-size: 1.08em; margin: .5em 0 .3em; }
.docx-li { position: relative; }
.docx-li::before { content: attr(data-mark); position: absolute; margin-left: -1.3em; width: 1.2em; text-align: right; }
.docx-page a { color: #3b3fd8; }
.docx-img { max-width: 100%; height: auto; vertical-align: middle; }
.docx-pb { border: 0; border-top: 1px dashed #c9ccd6; margin: 18px 0; }
.docx-table-wrap { overflow-x: auto; margin: 0 0 .8em; }
.docx-table { border-collapse: collapse; min-width: 50%; }
.docx-table td { border: 1px solid #c9ccd6; padding: 4px 8px; vertical-align: top; }
.docx-table td .docx-p:last-child { margin-bottom: 0; }
/* Excel и CSV */
.xl-box { display: flex; flex-direction: column; min-height: 100%; }
.xl-view { flex: 1; }
/* таблица — как лист Excel: белая «бумага» и чёрный текст в любой теме, чтобы цвета заливки и шрифта были как в файле */
.xl-table { width: auto; table-layout: fixed; border-collapse: collapse; background: #fff; color: #000; font-family: Calibri, Carlito, Arial, sans-serif; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.xl-table th, .xl-table td { border: 1px solid #d9d9d9; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; vertical-align: bottom; }
.xl-table td.xl-hid, .xl-table th.xl-hid { opacity: .4; }
.xl-table td.xl-af { position: relative; padding-right: 22px; }
.xl-af-btn { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border: 1px solid #bbb; border-radius: 3px; background: #f3f3f3; color: #444; font-size: 10px; line-height: 14px; text-align: center; font-weight: 400; font-style: normal; }
.xl-af-btn.on { background: #dbe8ff; border-color: #6b8fd6; color: #1f4fb0; }
.xl-note { position: sticky; left: 0; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.xl-note span { flex: 1; }
.xl-table td.xn { text-align: right; }
.xl-table th { position: sticky; background: #f3f3f3; color: #555; font-weight: 500; font-size: 12px; text-align: center; z-index: 1; }
.xl-table thead th { top: 0; }
.xl-table tbody th { left: 0; }
.xl-table .xl-corner { left: 0; z-index: 2; }
.xl-tabs { position: sticky; bottom: 0; left: 0; display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px; background: var(--bg); border-top: 1px solid var(--line); }
.xl-tab { flex: none; border: 0; border-radius: 8px; padding: 6px 12px; background: none; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.xl-tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* PowerPoint */
.pptx-deck { display: flex; flex-direction: column; gap: 14px; max-width: 820px; margin: 0 auto; padding: 12px; }
.pptx-slide { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.pptx-num { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pptx-title { margin: 0 0 8px; font-size: 19px; }
.pptx-text { margin: 0 0 6px; }
.pptx-img { display: block; max-width: 100%; max-height: 420px; margin: 8px 0; border-radius: 6px; }
/* текст */
.docv-text { margin: 0; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: 13.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); }

/* Фото на весь экран вписывается целиком (высокие картинки не обрезаются) */
.gal-stage { display: flex; align-items: center; justify-content: center; }
.gal-stage > img, .gal-stage > video { flex: none; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }

/* Подсказки ника и сложности пароля */
.nick-hint { font-size: 12px; margin-top: -4px; color: var(--muted); }
.nick-hint:empty { display: none; }
.field .nick-hint { margin-top: 0; }
.nick-hint[data-state='bad'] { color: var(--danger); }
.nick-hint[data-state='ok'] { color: var(--online); }
.pass-meter { display: flex; align-items: center; gap: 10px; margin-top: -4px; }
.pass-cells { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pass-cell { height: 6px; border-radius: 3px; background: var(--line); transition: background .2s; }
.pass-label { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }
.pass-meter[data-level='0'] .pass-label { visibility: hidden; }
.pass-meter[data-level='1'] .pass-cell.on { background: var(--danger); }
.pass-meter[data-level='2'] .pass-cell.on { background: #e8a33a; }
.pass-meter[data-level='3'] .pass-cell.on { background: #8bc34a; }
.pass-meter[data-level='4'] .pass-cell.on { background: var(--online); }
/* самолётик тяжелее справа сверху: геометрический центр не совпадает с видимым — сдвигаем на глаз */
.send-btn:not(.mic) svg { transform: translate(-1px, 1px); }

/* Запись звонка */
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; display: inline-block; animation: rec-blink 1.6s ease-in-out infinite; }
@keyframes rec-blink { 50% { opacity: .35; } }
.cs-rec { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: rgb(255 255 255 / .85); background: rgb(239 68 68 / .18); border-radius: 999px; padding: 3px 9px 3px 7px; margin-right: 8px; white-space: nowrap; }
.call-incoming .inc-rec { color: rgb(255 255 255 / .7); margin-top: 4px; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

/* Звук сообщений */
.sound-row { gap: 8px; align-items: center; }
.sound-row select { flex: 1; min-width: 0; }

/* Аватарки прочитавших — в меню сообщения, пункт «Просмотрели» */
.views-item .grow { flex: 1; text-align: left; }
.readers { display: inline-flex; align-items: center; margin-left: 10px; }
.readers[hidden] { display: none; }
.readers .rd-av { display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); }
.readers .rd-av + .rd-av { margin-left: -7px; }

/* Реакции: аватарки в плашке и список «кто какую поставил» */
.react-avs { display: inline-flex; margin-left: 2px; }
.react-avs .rd-av { display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--bg-2); }
.react.on .react-avs .rd-av { box-shadow: 0 0 0 1.5px var(--accent); }
.react-avs .rd-av + .rd-av { margin-left: -6px; }
.react { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.react-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.rtab { border: 1px solid var(--line); background: var(--bg-2); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer; }
.rtab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.react-list .pick { cursor: pointer; }
.react-emo { font-size: 20px; }

/* Скачать документ прямо из сообщения */
.file-dl { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; padding: 0; line-height: 0; -webkit-appearance: none; appearance: none; border-radius: 50%; background: var(--bg-2); color: var(--accent); cursor: pointer; margin-left: 6px; }
.file-dl:hover { background: var(--accent); color: #fff; }
.docv-dl { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* Политика обработки персональных данных */
.policy-row { align-items: flex-start; text-align: left; font-size: 14px; line-height: 1.4; }
.policy-row input { margin-top: 2px; flex: none; }
.policy-row a, .profile-legal a { color: var(--accent); }
.profile-legal { text-align: center; padding: 6px 0 2px; }
.policy-gate { z-index: 2000; }
.policy-gate .btn.block { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
@media (max-width: 420px) { .docv-dl span { display: none; } }
.ctx-item.muted-item { color: var(--muted); }

/* ---------- Мультяшная аватарка ---------- */
.ct-pair { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ct-pair figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; max-width: 220px; }
.ct-pair figcaption { font-size: 13px; color: var(--muted); }
.ct-arrow { color: var(--muted); font-size: 22px; flex: none; }
.ct-pic { width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; background: var(--bg-2); display: grid; place-items: center; }
.ct-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ct-pick { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.ct-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: vcspin .9s linear infinite; }
.ct-fail { color: var(--muted); font-size: 28px; }
.ct-status { text-align: center; min-height: 18px; }
.ct-btns { justify-content: center; flex-wrap: wrap; gap: 8px; }
.ct-styles { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.ct-styles .chip { border: 1px solid var(--line); background: var(--bg-2); color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.ct-styles .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ct-note { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--bg-2); color: var(--muted); }
.ct-btns [hidden] { display: none; }
.ct-like { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ct-like[hidden] { display: none; }
.ct-like input { flex: 1; accent-color: var(--accent); }
.ct-who { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.ct-who[hidden] { display: none; }
.ct-who-l { font-size: 13px; color: var(--muted); margin-right: 2px; }
.ct-who .chip { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.ct-who .chip.on { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border-color: var(--accent); color: var(--accent); }

/* ---------- Фото профиля крупно ---------- */
.av-zoomable { cursor: zoom-in; }
.avatar-view { position: fixed; inset: 0; z-index: 1350; background: rgb(8 10 16 / 0); display: flex; align-items: center; justify-content: center;
  padding: calc(56px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)); transition: background .18s; cursor: zoom-out; }
.avatar-view.in { background: rgb(8 10 16 / .97); }
.avv-media { max-width: min(92vw, 640px); max-height: 100%; width: auto; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 18px;
  transform: scale(.92); opacity: 0; transition: transform .18s, opacity .18s; box-shadow: 0 10px 40px rgb(0 0 0 / .45); }
.avatar-view.in .avv-media { transform: none; opacity: 1; }
.avv-top { position: absolute; top: calc(10px + var(--safe-top)); left: 16px; right: 10px; display: flex; align-items: center; gap: 10px; color: #fff; }
.avv-name { flex: 1; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avv-top .icon-btn { color: #fff; background: rgb(255 255 255 / .14); border-radius: 50%; }
.ct-who .chip.auto { border-style: dashed; border-color: var(--accent); color: var(--accent); }

/* Пересылка: шаг подтверждения */
.fwd-to { align-items: center; gap: 12px; }
.fwd-prev { border-left: 3px solid var(--accent); background: var(--bg-2); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow: auto; font-size: 14px; }
.fwd-prev-item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-note { width: 100%; resize: vertical; min-height: 44px; font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: inherit; box-sizing: border-box; }

/* ===================== Шахматы ===================== */
.chess-board { --sq-light: #eedcb8; --sq-dark: #b58863; display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.chess-board .cq { position: relative; display: flex; align-items: center; justify-content: center; container-type: size; }
.chess-board .cq.light { background: var(--sq-light); }
.chess-board .cq.dark { background: var(--sq-dark); }
.chess-board .cq.last::before { content: ''; position: absolute; inset: 0; background: rgb(255 214 64 / .45); }
.chess-board .cq.sel::before { content: ''; position: absolute; inset: 0; background: rgb(98 160 255 / .55); }
.chess-board .cq.incheck::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgb(255 40 40 / .9) 0%, rgb(255 40 40 / .5) 45%, transparent 75%); }
.chess-board .cq.target::after { content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgb(20 40 80 / .35); pointer-events: none; }
.chess-board .cq.target.cap::after { width: 86%; height: 86%; background: none; border: 4px solid rgb(20 40 80 / .35); box-sizing: border-box; }
.chess-board .pc { position: relative; z-index: 1; font-size: 80cqh; line-height: 1; font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", "Noto Sans Symbols 2", "Noto Sans Symbols", serif; }
.pc.w { color: #fff; -webkit-text-stroke: 1.2px #222; paint-order: stroke fill; text-shadow: 0 1px 1px rgb(0 0 0 / .35); }
.pc.b { color: #1d1d1f; -webkit-text-stroke: .6px #000; text-shadow: 0 1px 1px rgb(255 255 255 / .25); }
.chess-board .pc.drag { z-index: 5; pointer-events: none; transition: none; filter: drop-shadow(0 4px 6px rgb(0 0 0 / .35)); }
.chess-board.live .cq { cursor: pointer; }
.cq-rank, .cq-file { position: absolute; font-style: normal; font-size: 22cqh; font-weight: 700; opacity: .75; pointer-events: none; }
.cq-rank { top: 3%; left: 5%; }
.cq-file { bottom: 2%; right: 6%; }
.cq.light .cq-rank, .cq.light .cq-file { color: var(--sq-dark); }
.cq.dark .cq-rank, .cq.dark .cq-file { color: var(--sq-light); }
/* карточка в чате */
.chess-card { width: 240px; max-width: 100%; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.chess-card .btn { align-self: center; }
.chess-card .chess-board.mini { width: 100%; pointer-events: none; }
.chess-card.hot .sea-status.my { animation: sea-pulse 1.6s ease-in-out infinite; }
.chess-card .ta-r { text-align: right; }
.chess-vs { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.chess-vs span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chess-dot { display: inline-block; flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #555; }
.chess-dot.w { background: #fff; }
.chess-dot.b { background: #222; border-color: #222; }
/* окно игры */
.chess-modal .modal-body, .chess-game { overflow-x: hidden; }
.chess-game { display: flex; flex-direction: column; gap: 12px; position: relative; }
.chess-main { display: flex; gap: 16px; align-items: flex-start; }
.chess-col { flex: 0 1 min(480px, 62vh); min-width: 0; width: min(480px, 62vh); display: flex; flex-direction: column; gap: 6px; }
.chess-col .chess-board { width: 100%; }
.chess-side { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 10px; }
.chess-player { display: flex; align-items: center; gap: 6px; font-size: 14px; min-height: 26px; padding: 2px 6px; border-radius: 8px; }
.chess-player.turn { background: var(--accent-soft); }
.chess-taken { display: inline-flex; flex-wrap: wrap; margin-left: 4px; }
.chess-taken .pc { font-size: 17px; line-height: 1; margin-right: -3px; }
.chess-moves { display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px 8px; align-content: start; max-height: min(360px, 40vh); overflow-y: auto; font-size: 14px; padding: 8px 10px; background: var(--bg-2); border-radius: 10px; }
.chess-moves .mv-n { color: var(--muted); }
.chess-moves .mv.cur { font-weight: 700; color: var(--accent); }
.chess-actions { gap: 8px; }
.chess-offer { gap: 8px; margin-top: 6px; }
.chess-promo { position: absolute; inset: 0; background: rgb(0 0 0 / .35); display: flex; align-items: center; justify-content: center; border-radius: 12px; z-index: 10; }
.chess-promo-box { background: var(--bg); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.chess-promo-btn { width: 60px; height: 60px; border-radius: 10px; border: 1px solid var(--line); background: #eedcb8; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chess-promo-btn .pc { font-size: 44px; line-height: 1; }
.chess-promo-btn:hover { background: #f6e7c8; }
@media (max-width: 700px) {
  .chess-main { flex-direction: column; align-items: stretch; }
  .chess-col { width: 100%; flex: none; }
  .chess-moves { max-height: 120px; }
}

/* фото «как файл» — миниатюра вместо значка */
.file-btn.has-thumb { border-radius: 10px; overflow: hidden; padding: 0; background: var(--bg-2, #eee); }
.file-btn .file-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Профиль → «Хранилище на устройстве» */
.storage-box { gap: 10px; }
.storage-total { font-size: 15px; }
.storage-row { align-items: center; gap: 10px; }

/* Плашка «Сейчас играет»: голосовое, аудиофайл или кружок — пауза, перемотка, скорость, закрыть */
.now-bar { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line); flex: none; z-index: 3; animation: nbIn .18s ease-out; }
@keyframes nbIn { from { opacity: 0; transform: translateY(-6px); } }
.now-bar .nb-play { width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent); color: #fff; cursor: pointer; flex: none; }
.now-bar.circle .nb-play { border-radius: 30%; box-shadow: 0 0 0 2px var(--accent-soft); }
.now-bar .nb-info { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.now-bar .nb-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-bar .nb-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.now-bar .rate-btn { padding: 4px 8px; }
.now-bar .rate-btn.on { background: var(--accent); color: #fff; }
.now-bar .nb-close { flex: none; }
/* полоса прогресса по нижнему краю; зона нажатия выше самой полосы — удобно мотать пальцем */
.now-bar .nb-prog { position: absolute; left: 0; right: 0; bottom: -7px; height: 16px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.now-bar .nb-track { position: relative; width: 100%; height: 3px; background: var(--line); transition: height .12s; }
.now-bar .nb-prog:hover .nb-track, .now-bar .nb-prog.scrubbing .nb-track { height: 5px; }
.now-bar .nb-fill { height: 100%; width: 0; background: var(--accent); }
.now-bar .nb-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .4); border-top-color: #fff; animation: nbSpin .8s linear infinite; }
@keyframes nbSpin { to { transform: rotate(360deg); } }

/* Ссылка-приглашение в открытую группу */
.join-link-box { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.join-link { font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; user-select: all; -webkit-user-select: all; }

/* Перетаскивание закреплённых чатов */
#chat-list.pin-dragging .chat-item.pinned:not(.dragging) { transition: transform .15s ease; }
#chat-list .chat-item.dragging { position: relative; z-index: 5; box-shadow: 0 8px 24px rgb(0 0 0 / .18); background: var(--bg); border-radius: 12px; cursor: grabbing; transition: none; }
#chat-list.pin-dragging { user-select: none; -webkit-user-select: none; }

/* Оформление текста: панель над полем ввода и вид в сообщениях */
.fmt-bar { gap: 2px; padding: 4px; cursor: default; }
.fmt-bar .fmt-btn { border: 0; background: none; color: inherit; font: inherit; font-size: 15px; min-width: 34px; height: 32px; padding: 0 8px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.fmt-bar .fmt-btn:hover { background: rgb(127 127 127 / .25); }
.fmt-bar .fmt-btn b, .fmt-bar .fmt-btn i, .fmt-bar .fmt-btn u, .fmt-bar .fmt-btn s { font-family: Georgia, 'Times New Roman', serif; font-size: 16px; }
.fmt-bar .fmt-spoiler { font-size: 13.5px; font-weight: 600; }
.fmt-bar .fmt-sep { width: 1px; height: 18px; background: currentColor; opacity: .3; margin: 0 2px; }
.msg .text b.fmt { font-weight: 700; }
.msg .text u.fmt { text-underline-offset: 2px; }

/* Фото в редакторе истории: двигать и увеличивать */
.story-frame.pz { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.story-frame.pz:active { cursor: grabbing; }
.story-frame.pz > .pz-img { inset: auto; left: 50%; top: 50%; width: auto; height: auto; max-width: none; object-fit: fill; transform-origin: center; will-change: transform; pointer-events: none; }
.pz-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; pointer-events: none; transition: opacity .3s; }
.pz-hint.gone { opacity: 0; }

/* Настройки группы и права администраторов */
.caps { text-transform: uppercase; letter-spacing: .04em; font-size: 12px; margin-top: 4px; }
.rights-list { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.right-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; cursor: pointer; }
.right-row + .right-row { border-top: 1px solid var(--line); }
.right-row.off { opacity: .5; cursor: default; }
input[type='checkbox'].switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: color-mix(in srgb, var(--muted) 40%, transparent); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
input[type='checkbox'].switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .15s; }
input[type='checkbox'].switch:checked { background: #34c759; }
input[type='checkbox'].switch:checked::after { transform: translateX(18px); }
input[type='checkbox'].switch:disabled { cursor: default; }
.settings-btn { justify-content: center; }
.group-settings select { max-width: 100%; }
.silenced-note { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 2px 0 6px; }

/* общие группы в профиле человека */
.common-box { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.common-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.common-head span:nth-child(2) { flex: 1; }
.common-head:hover, .common-item:hover { background: var(--hover, rgba(127,127,127,.08)); }
.common-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.common-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.common-text { min-width: 0; }
.common-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* удаление профиля */
.danger-link { color: var(--danger); }
.del-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.gal-reveal { border: 0; background: rgb(255 255 255 / .14); color: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.gal-reveal:hover { background: rgb(255 255 255 / .24); }
.gal-count { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gal-nav[hidden], .gal-reveal[hidden] { display: none; }
.draft-label { color: var(--danger); }
.chat-item.active .draft-label { color: #ffc9c9; }
/* «Избранное» */
.avatar.fav-av { background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.avatar.fav-av svg { width: 46%; height: 46%; }
.chat-item.active .avatar.fav-av { background: rgb(255 255 255 / .22); }
.caption-input { width: 100%; resize: none; min-height: 40px; line-height: 1.4; font: inherit; }
/* новая реакция на моё сообщение — значок в списке чатов */
.badge.react { background: #ffe1e6; box-shadow: inset 0 0 0 1.5px #ff8a99; padding: 0; min-width: 22px; font-size: 12px; line-height: 1; }
.badge.react.muted { background: color-mix(in srgb, var(--muted) 70%, transparent); }
/* ожидающее сообщение: загрузка файла с процентами, отмена */
.pending-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.pending-bar .pb-track { flex: 1 0 100%; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 18%, transparent); overflow: hidden; }
.pending-bar .pb-fill { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.pending-bar .pb-text { flex: 1; min-width: 0; }
.pending-bar .pb-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.file-dl svg, .file-btn svg { display: block; flex: none; }
/* дерево приглашений */
.it-tree { display: flex; flex-direction: column; gap: 2px; }
.it-node > summary { list-style: none; cursor: pointer; }
.it-node > summary::-webkit-details-marker { display: none; }
.it-node > summary .it-person::before { content: '▸'; color: var(--muted); width: 12px; flex: none; transition: transform .15s; }
.it-node[open] > summary .it-person::before { transform: rotate(90deg); }
.it-leaf .it-person::before { content: ''; width: 12px; flex: none; }
.it-person { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; }
.it-person:hover { background: var(--bg-2); }
.it-person.dim { opacity: .6; }
.it-kids { margin-left: 22px; padding-left: 10px; border-left: 2px solid var(--line); }
.it-count { flex: none; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.it-chain { padding-left: 56px; margin-top: -4px; }
.inv-tag.off { color: var(--danger); }
.invited-by { display: flex; align-items: center; gap: 4px; margin: -6px 0 4px; }
.kb-debug { position: fixed; top: env(safe-area-inset-top, 0); left: 0; right: 0; z-index: 99999; margin: 0; padding: 6px 8px; max-height: 42vh; overflow: hidden; background: rgb(0 0 0 / .78); color: #7CFC7C; font: 11px/1.35 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }
.ctx-note { display: flex; align-items: center; gap: 4px; padding: 8px 12px 4px; }

/* --- Кольца за приглашения --- */
@property --lv-a { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
.avatar.lv { overflow: visible; position: relative; }
.avatar.lv > img, .avatar.lv > .av-video { border-radius: 50%; }
.lv-bronze { --lv-g: conic-gradient(from 210deg, #7a4a20, #d99a5e, #f3c28e, #a8672f, #6e3f18, #c98a4f, #7a4a20); }
.lv-silver { --lv-g: conic-gradient(from 210deg, #8792a0, #e9eef3, #ffffff, #aab4c0, #7d8794, #d4dbe3, #8792a0); }
.lv-gold { --lv-g: conic-gradient(from 210deg, #a87a12, #f4cf5a, #fff1b0, #d9a72a, #8f6508, #f0c64a, #a87a12); }
.lv-plat { --lv-g: conic-gradient(from var(--lv-a), #7f93ad, #dfe9f5, #ffffff, #a9bdd6, #6f84a0, #cfdced, #7f93ad); }
.lv-legend { --lv-g: conic-gradient(from var(--lv-a), #b8860b, #ffd76a, #fff8dc, #ffb703, #9a6a00, #ffe9a8, #b8860b); }
/* крупная аватарка: кольцо снаружи, с зазором цвета фона (размер аватарки не меняется) */
.lv-ring { --w: 3.5px; position: absolute; inset: -7px; border-radius: 50%; background: var(--lv-g); pointer-events: none;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--w)), #000 calc(100% - var(--w) + .5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--w)), #000 calc(100% - var(--w) + .5px)); }
.lv-plat .lv-ring { animation: lv-spin 6s linear infinite; }
.lv-legend .lv-ring { animation: lv-spin 3.5s linear infinite; }
.lv-legend .lv-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; }
.lv-legend.lv-big { box-shadow: 0 0 14px 4px rgba(255, 190, 40, .5); animation: lv-glow 2.4s ease-in-out infinite; }
.lv-plat.lv-big::after { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%); background-size: 250% 100%; animation: lv-shine 3.2s ease-in-out infinite; z-index: 1; }
@keyframes lv-spin { to { --lv-a: 360deg; } }
@keyframes lv-glow { 50% { box-shadow: 0 0 24px 7px rgba(255, 190, 40, .75); } }
@keyframes lv-shine { 0% { background-position: 130% 0; } 60%, 100% { background-position: -130% 0; } }
.lv-spark { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff6c8; box-shadow: 0 0 6px 2px #ffd34d; top: 50%; left: 50%; margin: -3px;
  animation: lv-orbit 3.5s linear infinite; pointer-events: none; z-index: 2; }
.lv-spark.s2 { animation-delay: -1.75s; width: 4px; height: 4px; margin: -2px; }
@keyframes lv-orbit { from { transform: rotate(0deg) translateX(calc(var(--r) * 1px)) scale(1); } 50% { transform: rotate(180deg) translateX(calc(var(--r) * 1px)) scale(.6); } to { transform: rotate(360deg) translateX(calc(var(--r) * 1px)) scale(1); } }
/* маленькая аватарка: медалька в углу */
.lv-medal { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; background: var(--lv-g);
  box-shadow: 0 0 0 2px var(--bg); display: grid; place-items: center; z-index: 2; pointer-events: none; }
.lv-medal svg { width: 10px; height: 10px; }
.lv-medal.xs { width: 14px; height: 14px; right: -3px; bottom: -3px; }
.lv-medal.xs svg { width: 8px; height: 8px; }
.lv-plat .lv-medal, .lv-legend .lv-medal { animation: lv-spin 5s linear infinite; }
.chat-item.active .lv-medal { box-shadow: 0 0 0 2px var(--accent); }
/* вместе с историей: кольцо истории внутри, кольцо уровня снаружи */
.av-story > .avatar.lv-big .lv-ring { inset: -9px; --w: 3px; }
@media (prefers-reduced-motion: reduce) { .lv-ring, .lv-medal, .lv-spark, .lv-legend.lv-big, .lv-plat.lv-big::after { animation: none !important; } }
/* звание в профиле и прогресс */
.lv-title { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--bg-2, rgba(127,127,127,.12));
  border: 0; font: inherit; font-size: 13px; color: inherit; cursor: pointer; }
.lv-title .lv-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--lv-g); flex: none; }
.lv-progress { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.lv-progress .lv-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 4px; }
.lv-progress .lv-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #d9a72a, #f4cf5a); }
.lv-levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: 11.5px; }
.lv-levels > div { display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: .55; }
.lv-levels > div.got { opacity: 1; }
.lv-levels .lv-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--lv-g); }
.lv-people { display: flex; flex-direction: column; gap: 6px; }
.lv-people .row { display: flex; align-items: center; gap: 10px; }
.lv-people .row .muted { margin-left: auto; font-size: 12px; }
.lv-up { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 6px 6px; position: relative; overflow: hidden; }
.lv-up h3 { margin: 6px 0 0; font-size: 20px; }
.lv-confetti { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: lv-fall 2.6s ease-in forwards; pointer-events: none; }
@keyframes lv-fall { to { transform: translateY(380px) rotate(540deg); opacity: .2; } }
/* кнопка «Пригласить» рядом с «Новостями»: подпись видна всегда (у «Новостей» на узком экране остаётся значок) */
.news-btn.invite-top { margin-left: 6px; color: var(--accent); border-color: transparent; background: var(--accent-soft); }
.news-btn.invite-top:hover { border-color: var(--accent); }
/* на телефоне и в узкой боковой панели места на две подписи нет: у «Новостей» остаётся значок, «Пригласить» — с подписью;
   на совсем узком экране — оба значками */
@media (max-width: 560px) { .news-btn:not(.invite-top) span { display: none; } .news-btn:not(.invite-top) { padding: 0 7px; } .news-btn.invite-top span { display: inline; } .news-btn.invite-top { padding: 0 9px; } }
@container side (max-width: 480px) { .news-btn:not(.invite-top) span { display: none; } .news-btn:not(.invite-top) { padding: 0 7px; } .news-btn.invite-top span { display: inline; } .news-btn.invite-top { padding: 0 9px; } }
@media (max-width: 350px) { .news-btn.invite-top span { display: none; } .news-btn.invite-top { padding: 0 7px; } }
.brand .news-btn { flex: none; }
/* тесно — кнопки чуть компактнее, а на узком телефоне от названия остаётся «G» */
@media (max-width: 560px) { .brand .news-btn { margin-left: 6px; } .brand .news-btn.invite-top { margin-left: 5px; padding: 0 8px; font-size: 12px; gap: 4px; } }
@container side (max-width: 480px) { .brand .news-btn { margin-left: 6px; } .brand .news-btn.invite-top { margin-left: 5px; padding: 0 8px; font-size: 12px; gap: 4px; } }
@media (max-width: 400px) { .brand-rest { display: none; } }
.invite-top .lv-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lv-g); }
@container side (max-width: 420px) { .side-head .brand { font-size: 17px; } .brand .news-btn { margin-left: 5px; padding: 0 6px; } .brand .news-btn.invite-top { margin-left: 4px; padding: 0 7px; } .side-head { gap: 6px; } }
@container side (max-width: 330px) { .brand-rest { display: none; } }

/* загрузка истории: проценты и «Отменить» */
.story-upload { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.story-upload .su-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.story-upload .su-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.story-upload .su-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.story-trim { display: flex; flex-direction: column; gap: 6px; }
.story-trim input[type=range] { width: 100%; accent-color: var(--accent); }

/* своя история: кто посмотрел и реакции */
.sv-views { display: inline-flex; align-items: center; gap: 8px; }
.sv-faces { display: inline-flex; }
.sv-face { position: relative; margin-left: -8px; display: inline-flex; }
.sv-face:first-child { margin-left: 0; }
.sv-face .avatar { box-shadow: 0 0 0 2px rgba(0, 0, 0, .55); }
.sv-face-r { position: absolute; right: -5px; bottom: -5px; font-size: 13px; line-height: 1; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6)); }
.sv-react-sum { display: inline-flex; gap: 8px; margin-left: 2px; }
.sv-react-sum span { display: inline-flex; align-items: center; gap: 2px; }
.sv-react-sum b { font-size: 12px; font-weight: 600; }
.sv-react-sum.big { font-size: 20px; gap: 14px; flex-wrap: wrap; }
.sv-react-sum.big b { font-size: 14px; color: var(--muted); }
/* выбор кольца */
.lv-own { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lv-opts { display: flex; flex-direction: column; gap: 6px; }
.lv-opt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.lv-opt .lv-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--lv-g); flex: none; }
.lv-opt .lv-dot.none { background: var(--line); }
.lv-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.lv-opt.locked { opacity: .5; cursor: default; }
.lv-opt:not(.locked):hover { border-color: var(--accent); }
.sv-load-pct { position: absolute; left: 0; right: 0; top: calc(50% + 30px); text-align: center; color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); z-index: 1; }
.ci-up { color: var(--accent); font-weight: 600; }
.sv-who-btn { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sv-who-btn .grow { min-width: 0; }

/* видео по ссылке (YouTube, Instagram, Rutube, VK Видео) */
.vembed { position: relative; width: min(360px, 100%); aspect-ratio: 16 / 9; margin-top: 6px; border-radius: 12px; overflow: hidden; background: #111; }
.vembed.vertical { width: min(260px, 100%); aspect-ratio: 9 / 16; }
.vembed.instagram { aspect-ratio: 4 / 5.6; background: linear-gradient(135deg, #f58529, #dd2a7b 50%, #8134af); }
.vembed.rutube { background: linear-gradient(135deg, #0d1a2b, #1e3a5f); }
.vembed.vk { background: linear-gradient(135deg, #0077ff, #0050b3); }
.vembed.youtube { background: #000; }
.vembed .ve-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vembed .ve-play { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 0; background: rgba(0, 0, 0, .18); color: #fff; cursor: pointer; font: inherit; }
.vembed .ve-btn { width: 56px; height: 56px; border-radius: 50%; background: rgba(0, 0, 0, .6); display: grid; place-items: center; font-size: 22px; padding-left: 4px; }
.vembed.youtube .ve-btn { background: #ff0000; border-radius: 14px; width: 64px; height: 44px; }
.vembed .ve-kind { font-size: 12.5px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.vembed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bubble.has-embed { max-width: min(400px, 85%); }
/* плеер Instagram выше: у него сверху шапка автора, снизу подпись — иначе видео обрезается */
.vembed.instagram { width: min(340px, 100%); }
.vembed.instagram.playing { aspect-ratio: auto; height: min(620px, 78vh); background: #fff; }
.ve-open { display: inline-block; margin-top: 6px; font-size: 13px; }
.mention-all-ico { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.mention.all { font-weight: 600; }
/* шапка не помещается — убираем подписи по шагам (fitBrand) */
.brand.tight1 .brand-rest { display: none; }
.brand.tight1 .news-btn:not(.invite-top) span { display: none; }
.brand.tight1 .news-btn:not(.invite-top) { padding: 0 7px; }
.brand.tight2 .news-btn.invite-top span { display: none; }
.brand.tight2 .news-btn.invite-top { padding: 0 8px; }
/* баги и предложения (администрирование) */
.rep-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.rep-card.done { opacity: .6; }
.rep-text { white-space: pre-wrap; word-break: break-word; }
.rep-files { display: flex; flex-wrap: wrap; gap: 8px; }
.rep-files img, .rep-files video { width: 140px; height: 140px; object-fit: cover; border-radius: 8px; background: #000; }
a.btn.disabled { pointer-events: none; opacity: .5; }

/* окно отправки фото: убрать фото, «Добавить ещё» */
.photo-thumbs .thumb-wrap { position: relative; }
.thumb-del { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.thumb-del:hover { background: rgba(0, 0, 0, .8); }
.thumb-add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; background: none; color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; cursor: pointer; }
.thumb-add:hover { background: var(--accent-soft); }
.photo-thumbs.single .thumb-add { aspect-ratio: auto; flex-direction: row; padding: 8px; }
.rb-replace { flex: none; margin-right: 4px; }
.once-row[hidden] { display: none; }
/* правка сообщения: вложения с крестиком и «+» */
.reply-bar { flex-wrap: wrap; }
.rb-media { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px 30px; }
.rb-att { position: relative; width: 48px; height: 48px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; flex: none; }
.rb-att img { width: 100%; height: 100%; object-fit: cover; }
.rb-att-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; padding: 0; cursor: pointer; }
.rb-att.add { border: 2px dashed var(--line); background: none; color: var(--accent); cursor: pointer; }
.rb-att.busy { font-size: 20px; }
/* голосовое / кружок / видео: не прослушано — точка, прослушано — подпись у автора */
.meta .unplayed { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 5px; vertical-align: 1px; }
.meta .unplayed.mine { background: var(--muted); opacity: .6; }
.meta .played { margin-right: 5px; font-style: italic; }

/* маленькая аватарка (список чатов, сообщения): тонкое кольцо вплотную */
.lv-ring.sm { inset: -4px; --w: 2.5px; }
.lv-ring.xs { inset: -3px; --w: 2px; }

/* Настройки группы — списком, как в настройках телефона */
.gs { display: flex; flex-direction: column; gap: 6px; }
.gs-card { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-top: 10px; }
.gs-card > * + * { border-top: 1px solid var(--line); }
.gs-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 14px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.gs-row:hover { background: var(--bg-2); }
.gs-person { cursor: default; }
.gs-person:hover { background: none; }
.gs-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.gs-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gs-hint { color: var(--muted); font-size: 13px; }
.gs-val { color: var(--muted); white-space: nowrap; }
.gs-chev { color: var(--muted); display: flex; opacity: .7; }
.gs-check { color: var(--accent); width: 20px; display: flex; }
.gs-note { color: var(--muted); font-size: 13px; margin: 2px 14px 4px; }
.gs-caps { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 12px 14px 0; }
.gs-field { padding: 2px 14px; }
.gs-input { width: 100%; border: 0; background: none; padding: 12px 0; font: inherit; color: var(--text); resize: none; outline: none; box-shadow: none; }
.gs-input:focus { box-shadow: none; }
.gs-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 2px 0; }
.gs-save { margin-top: 14px; }
.gs-danger .gs-label { color: var(--danger); }
.gs-emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; max-height: 300px; overflow-y: auto; margin-top: 6px; }
.gs-emo { font-size: 24px; height: 42px; border: 0; border-radius: 10px; background: none; cursor: pointer; position: relative; opacity: .55; filter: grayscale(.4); }
.gs-emo.on { opacity: 1; filter: none; background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
/* реакции: «+» и все смайлики в меню сообщения */
.qr.more { color: var(--muted); display: grid; place-items: center; }
.quick-reacts.scroll { overflow-x: auto; max-width: min(360px, 92vw); scrollbar-width: none; }
.react-all { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 6px; max-height: 210px; overflow-y: auto; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow); }
.swatch.any { background: conic-gradient(#3b3fd8, #1f8a4c, #d9661a, #c8357a, #7a3bd1, #3b3fd8); color: #fff; font-weight: 700; font-size: 13px; }
.gs-swatches { padding: 4px 14px; flex-wrap: wrap; }
.gs .bg-preview { border-radius: 16px; margin-top: 6px; }
.gs .bg-tiles { margin-top: 6px; }

/* Темы в группе: список тем вместо переписки */
.topic-list { display: flex; flex-direction: column; gap: 2px; padding: 10px; max-width: 760px; width: 100%; margin: 0 auto; }
.topic-new { display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--accent); border-radius: 14px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.topic-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 14px; background: color-mix(in srgb, var(--bg) 92%, transparent); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.topic-item:hover { background: var(--bg); }
.topic-ic { flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 700; color: #fff; background: var(--tc); }
.topic-ic.general { background: var(--bg-2); color: var(--muted); font-size: 20px; }
.topic-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topic-top, .topic-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.topic-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.topic-lock { color: var(--muted); display: inline-flex; }
.topic-prev { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.topic-item .badge { flex: none; }
.chat.topics-mode .messages { padding-bottom: 16px; }
.topic-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.topic-icon-opt { height: 40px; border: 0; border-radius: 10px; background: var(--bg-2); font-size: 20px; cursor: pointer; color: var(--muted); font-weight: 600; }
.topic-icon-opt.on { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.tag.online { background: color-mix(in srgb, var(--online, #22c55e) 18%, transparent); color: #16a34a; }
.terminate-others { margin-top: 4px; }
/* Android: уведомления без задержек (работа в фоне) */
.bg-help p { margin: 0; }
.bg-step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg-2); }
.bg-step .bg-num { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; }
.bg-step.done .bg-num { background: #22c55e; border-color: #22c55e; }
.bg-step .bg-title { font-weight: 600; }
.bg-row { gap: 10px; margin-top: 6px; }
/* «Доступно обновление G-чата — обновить» */
.update-chip { position: fixed; z-index: 1400; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-size: 14px; box-shadow: var(--shadow); cursor: pointer; max-width: calc(100vw - 32px); }

/* Подпись администратора в сообщениях группы: «владелец», «админ» или тег */
.sender .staff-tag { margin-left: 8px; font-size: 11.5px; font-weight: 400; color: var(--muted); }
/* Поиск по участникам группы */
.member-search { width: 100%; margin: 4px 0 2px; }
/* Окно прав администратора */
.ar { gap: 6px; }
.ar-card { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.ar-person { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.ar-name { font-weight: 600; font-size: 17px; }
.ar-caps { margin: 12px 16px 2px; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ar-tag { width: 100%; border: 0 !important; background: transparent !important; padding: 13px 16px !important; font-size: 16px; box-shadow: none !important; }
.ar-note { margin: 2px 16px 4px; font-size: 13px; color: var(--muted); }
.ar-list .ar-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.ar-list .ar-row + .ar-row { border-top: 1px solid var(--line); }
.ar-row.off { cursor: default; }
.ar-row.off .ar-title, .ar-row.off .ar-hint { opacity: .55; }
.ar-title { font-size: 15.5px; }
.ar-hint { font-size: 12px; color: var(--muted); margin-top: 1px; }
input[type='checkbox'].switch.rights-switch { width: 50px; height: 30px; border-radius: 15px; background: var(--danger); }
input[type='checkbox'].switch.rights-switch::after { width: 24px; height: 24px; }
input[type='checkbox'].switch.rights-switch:checked { background: var(--accent); }
input[type='checkbox'].switch.rights-switch:checked::after { transform: translateX(20px); }
input[type='checkbox'].switch.rights-switch:disabled { opacity: .45; }
.ar-demote { display: flex; align-items: center; width: 100%; padding: 14px 16px; margin-top: 8px; color: var(--danger); font-size: 16px; text-align: left; cursor: pointer; font: inherit; }
.ar-demote .icon { color: var(--muted); }
.ar-save { margin-top: 10px; padding: 14px; border-radius: 16px; font-size: 16px; }
.ctx-menu.call-end-menu { z-index: 1300; }
/* поиск по участникам прячет строки атрибутом hidden — а у строк списка свой display */
.pick-list > [hidden] { display: none !important; }
/* телефон: долгое нажатие на сообщение открывает наше меню — без системного выделения текста и меню iPhone */
@media (pointer: coarse) {
  #messages .bubble, #messages .bubble * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
/* запись звонка: «Разобрать в G-роботе» и «Расшифровать» */
.rec-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rec-act { flex: 1 1 auto; padding: 7px 10px; border-radius: 10px; border: 0; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.rec-act:hover { filter: brightness(.97); }
/* редактор фото: рамка */
.pe-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pe-shapes { display: inline-flex; gap: 4px; background: rgb(255 255 255 / .08); border-radius: 10px; padding: 3px; }
.pe-shape { border: 0; background: transparent; color: inherit; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.pe-shape.on { background: rgb(255 255 255 / .2); font-weight: 600; }
.pe-dim { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* телефон, клавиатура открыта и перекрывает окно (класс ставит app.js): окно — только видимая часть над ней (иначе Safari сдвигает всё вверх) */
html.kb-open .layout { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); bottom: auto; height: var(--vv-h, 100%); }
html.kb-open { --safe-bottom: 0px; } /* полоска «домой» под клавиатурой — отступ не нужен */

/* Размер текста и углы сообщений (Настройки → Оформление) */
.sender { font-size: calc(var(--msg-fs, 15px) * .9); }
.text-preview { position: static !important; box-shadow: none; height: auto !important; min-height: 0; justify-content: flex-start; padding: 12px; }
.text-preview .pv { font-size: var(--msg-fs, 15px); border-radius: var(--bubble-r, 16px); }
.text-preview .pv.in { border-bottom-left-radius: min(4px, var(--bubble-r, 16px)); }
.text-preview .pv.out { border-bottom-right-radius: min(4px, var(--bubble-r, 16px)); }
.text-preview .pv-name { display: block; font-size: .9em; color: #e17076; margin-bottom: 1px; }
.pref-slider { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.pref-slider input[type=range] { width: 100%; accent-color: var(--accent); }
.pref-slider .range-val { color: var(--accent); font-weight: 600; }
/* панель стикеров: где взять анимированный набор за приложение Android */
.sticker-promo { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 18px 16px; }
.sticker-promo .sp-big { font-size: 44px; line-height: 1; }
/* «▶ Запустить» HTML-файл */
.run-frame { width: 100%; height: min(72vh, 760px); border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.run-frame:fullscreen { border: 0; border-radius: 0; }
