/* ---------- цвет: акцент выбирается в «Оформлении», остальное выводится из него ---------- */
:root {
  --a-l: #1d7f6a; --a-d: #3cbf9e; --ink-l: #ffffff; --ink-d: #08130f;
}
:root[data-accent="ocean"]    { --a-l: #2563eb; --a-d: #5b8def; --ink-l: #ffffff; --ink-d: #ffffff; }
:root[data-accent="sunset"]   { --a-l: #d9472d; --a-d: #ff7a5c; --ink-l: #ffffff; --ink-d: #1a0a05; }
:root[data-accent="lavender"] { --a-l: #6d4ae6; --a-d: #9b85ff; --ink-l: #ffffff; --ink-d: #120a2a; }
:root[data-accent="cherry"]   { --a-l: #c2255c; --a-d: #f06595; --ink-l: #ffffff; --ink-d: #2a0612; }
:root[data-accent="graphite"] { --a-l: #3d4652; --a-d: #c9d1d9; --ink-l: #ffffff; --ink-d: #111418; }

:root {
  --bg: #ffffff;
  --bg-2: #f3f5f7;
  --line: #e3e7ea;
  --text: #121417;
  --muted: #6b737c;
  --accent: var(--a-l);
  --accent-text: var(--ink-l);
  --accent-2: color-mix(in srgb, var(--accent) 12%, #ffffff);
  --chat-bg: color-mix(in srgb, var(--accent) 7%, #eef1f3);
  --mine: color-mix(in srgb, var(--accent) 17%, #ffffff);
  --mine-text: #10161a;
  --theirs: #ffffff;
  --wall-ink: rgba(20, 30, 40, .07);
  --danger: #d23b3b;
  --green: #22a36b;
  --shadow: 0 1px 1px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .06);
  --glass-body: 40%; --glass-hi: .85; --glass-contrast: .6; --glass-bright: 1.2; --glass-halo: 2px; --glass-hair: rgba(16, 24, 32, .13);      /* «жидкое стекло» нижней панели: плотность, блик, контраст и яркость подложки (чтобы значки читались и над чёрным, и над белым), ореол, внешний контур */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --r: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-mode="dark"] {
  --bg: #14171c; --bg-2: #1c2026; --line: #262b33; --text: #e8ebee; --muted: #8b949e;
  --accent: var(--a-d); --accent-text: var(--ink-d);
  --accent-2: color-mix(in srgb, var(--accent) 18%, #14171c);
  --chat-bg: color-mix(in srgb, var(--accent) 5%, #0e1114);
  --mine: color-mix(in srgb, var(--accent) 32%, #161a1f); --mine-text: #eef2f1;
  --theirs: #1d2229; --wall-ink: rgba(255, 255, 255, .05);
  --danger: #f06363; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --glass-body: 50%; --glass-hi: .3; --glass-contrast: .6; --glass-bright: .8; --glass-halo: 2px; --glass-hair: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #14171c; --bg-2: #1c2026; --line: #262b33; --text: #e8ebee; --muted: #8b949e;
    --accent: var(--a-d); --accent-text: var(--ink-d);
    --accent-2: color-mix(in srgb, var(--accent) 18%, #14171c);
    --chat-bg: color-mix(in srgb, var(--accent) 5%, #0e1114);
    --mine: color-mix(in srgb, var(--accent) 32%, #161a1f); --mine-text: #eef2f1;
    --theirs: #1d2229; --wall-ink: rgba(255, 255, 255, .05);
    --danger: #f06363; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --glass-body: 50%; --glass-hi: .3; --glass-contrast: .6; --glass-bright: .8; --glass-halo: 2px; --glass-hair: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
/* плавная смена темы (класс ставится на 320 мс, только при выборе темы) */
html.theming, html.theming * {
  transition: background-color 250ms ease, color 250ms ease, border-color 250ms ease, fill 250ms ease, stroke 250ms ease !important;
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  height: 100%;
}
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}
#app { height: 100dvh; overflow: hidden; overflow: clip; }   /* clip: браузер не может сдвинуть экран сам (фокус, scrollIntoView) */
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button, a, [role="button"], .row { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
input, textarea, select { font: inherit; font-size: 16px; color: inherit; }
h1, h2, h3, p { margin: 0; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; display: flex; align-items: center; gap: 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent) !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
[hidden] { display: none !important; }

.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 17px; height: 17px; vertical-align: -3px; }
.ic.tick { width: 16px; height: 16px; stroke-width: 2; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--bg-2); font-weight: 600;
  transition: transform 140ms var(--ease-out), background-color 140ms;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; color: var(--accent); }
.btn.wide { width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .6; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--accent);
  transition: transform 140ms var(--ease-out), background-color 140ms;
}
.icon-btn:active { transform: scale(0.92); background: var(--bg-2); }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted);
  transition: transform 140ms var(--ease-out);
}
.round-btn:active { transform: scale(0.9); }
.round-btn.send { background: var(--accent); color: var(--accent-text); }
.link { color: var(--accent); padding: 10px; font-size: 14px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(0.97); }
  .icon-btn:hover { background: var(--bg-2); }
  .row:hover { background: var(--bg-2); }
  .menu-item:hover { background: var(--bg-2); }
}

/* ---------- вход ---------- */
.center-screen {
  /* своя прокрутка: #app не прокручивается, а форма на телефоне бывает выше экрана */
  height: 100dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
  padding: calc(24px + var(--safe-t)) 16px calc(32px + var(--safe-b));
}
.center-screen > * { margin-block: auto; flex: none; }   /* по центру, если влезает; иначе — сверху и листается */
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.brand { text-align: center; margin-bottom: 12px; display: grid; justify-items: center; gap: 8px; }
.brand h1 { font-size: 28px; letter-spacing: -0.02em; }
.brand p { max-width: 300px; }
.brand-mark { width: 72px; height: 72px; border-radius: 22%; box-shadow: 0 6px 20px rgba(15, 107, 90, .28); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); outline: none; transition: border-color 140ms;
}
.input:focus { border-color: var(--accent); }
.pw { position: relative; display: block; }
.pw .input { padding-right: 52px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; color: var(--muted); }
.eye.on { color: var(--accent); }
.center { text-align: center; }
.admin-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.note { font-size: 13px; color: var(--muted); background: var(--bg-2); padding: 10px 12px; border-radius: 12px; }
.error { color: var(--danger); font-size: 14px; min-height: 0; }
.error:empty { display: none; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- раскладка ---------- */
.shell { display: grid; grid-template-columns: 360px 1fr; height: 100dvh; overflow: hidden; overflow: clip; }
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; min-height: 0; background: var(--bg); }
.chat-pane { min-width: 0; min-height: 0; background: var(--chat-bg); display: flex; flex-direction: column; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 50% 50%; width: 200%; transition: transform 320ms var(--ease-drawer); }
  .shell.in-chat { transform: translateX(-50%); }
  .list-pane { border-right: 0; }
}
@media (min-width: 761px) { .back { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .shell { transition: none; } }

.bar {
  display: flex; align-items: center; gap: 4px; min-height: 56px;
  padding: var(--safe-t) 8px 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); flex: none;
}
.bar-title { flex: 1; font-size: 22px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.net-badge { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.banner {
  display: flex; align-items: center; gap: 10px; margin: 10px 12px 0; padding: 10px 12px;
  border-radius: 14px; background: var(--accent-2); font-size: 14px;
}
.banner span { flex: 1; }

/* ---------- список ---------- */
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 6px calc(6px + var(--safe-b)); }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; text-align: left;
  transition: background-color 120ms;
}
.row:active { background: var(--bg-2); }
.row.active { background: var(--accent-2); }
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; align-items: baseline; gap: 8px; }
.row-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12px; color: var(--muted); flex: none; display: inline-flex; align-items: center; gap: 3px; }
.row-time .ticks { display: inline-flex; }
.row-seen { margin-top: 1px; font-size: 12px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-seen.on { color: var(--accent); }
.row-preview { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.badge { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.list-empty { padding: 48px 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }

.av {
  --hue: 160; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 600; font-size: 17px; color: #fff;
  background: linear-gradient(160deg, hsl(var(--hue) 55% 58%), hsl(calc(var(--hue) + 25) 55% 46%));
}
.av.sm { width: 38px; height: 38px; font-size: 14px; }
.av.xl { width: 88px; height: 88px; font-size: 30px; }
.av-wrap { position: relative; flex: none; }
.dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }

/* ---------- чат ---------- */
.empty-chat { margin: auto; text-align: center; display: grid; gap: 8px; justify-items: center; padding: 24px; max-width: 360px; }
.empty-badge { width: 56px; height: 56px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; color: var(--accent); margin-bottom: 4px; }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-bar { padding-left: 4px; }
.chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px; border-radius: 12px; }
.who-text { display: grid; min-width: 0; }
.who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.e2e-note { align-self: center; max-width: 320px; text-align: center; font-size: 12.5px; color: var(--muted); background: var(--bg); padding: 8px 12px; border-radius: 12px; margin: 8px 0 4px; }
.day { align-self: center; margin: 10px 0 6px; }
.day span { font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 85%, transparent); color: var(--muted); backdrop-filter: blur(6px); }
.msg { display: flex; margin-top: 5px; }
.msg.grouped { margin-top: 0; }
.msg.mine { justify-content: flex-end; }
.bubble {
  max-width: min(78%, 520px); padding: 7px 10px 6px 12px; border-radius: var(--r); background: var(--theirs);
  box-shadow: var(--shadow); position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px 10px;
  overflow-wrap: anywhere; user-select: text; -webkit-user-select: text;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); }
.msg:not(.grouped):not(.mine) .bubble { border-bottom-left-radius: 6px; }
.msg.mine:not(.grouped) .bubble { border-bottom-right-radius: 6px; }
.text { white-space: pre-wrap; flex: 1 1 auto; }
.meta { margin-left: auto; font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; transform: translateY(2px); }
.msg.mine .meta { color: color-mix(in srgb, var(--mine-text) 60%, transparent); }
.ticks.read { color: var(--accent); }
.msg.pending .bubble { opacity: .7; }
.retry { color: var(--danger); font-size: 13px; font-weight: 600; }
.bubble.media { padding: 3px; flex-direction: column; align-items: stretch; gap: 0; }
.bubble.media .meta { position: absolute; right: 9px; bottom: 7px; color: #fff; background: rgba(0, 0, 0, .4); padding: 1px 6px; border-radius: 9px; }
.bubble.media .text.cap { padding: 6px 8px 18px; }
.bubble.media .text.cap ~ .meta { position: static; background: none; color: var(--muted); padding: 0 6px 4px; align-self: flex-end; }
.bare { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.bare .meta { background: color-mix(in srgb, var(--bg) 80%, transparent); padding: 1px 7px; border-radius: 9px; }

.photo { display: block; border-radius: 15px; overflow: hidden; background: var(--bg-2); max-width: 100%; position: relative; }
.photo img, .photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.loading::after, .circle-msg.loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255,255,255,.5); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.photo[data-gone]::after { content: "Файл удалён с сервера" !important; }
.photo.broken::after { content: "Не загрузилось"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

/* Голосовое — строка как в Telegram iOS (скрин Ивана 24.10): круглая кнопка слева, волна и под ней длительность, «→А» справа сверху; расшифровка — на обе колонки.
   Сетка, а не flex-wrap: при wrap волна, не влезшая рядом с кнопкой, падала под неё (регресс 23.10). Ширина растёт с длительностью (--vd: 0…1 за 90 с), как у Telegram. */
.voice { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; width: calc(min(66vw, 236px) + (min(82vw, 380px) - min(66vw, 236px)) * var(--vd, 0)); }
.v-tr { position: relative; flex: none; align-self: start; min-width: 44px; height: 32px; padding: 0 8px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 1px; font-weight: 600; font-size: 16px; line-height: 1;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); transition: transform 140ms var(--ease-out), background-color 140ms, color 140ms; touch-action: manipulation; }
.v-tr::before { content: ''; position: absolute; inset: -12px -8px; }                      /* область нажатия — с палец, а не с букву */
.v-tr:active { transform: scale(0.92); }
.v-tr.has { box-shadow: inset 0 0 0 1.5px var(--accent); }
.v-tr.on { background: var(--accent); color: var(--accent-text); }
.v-tr.busy { opacity: .6; }
.v-text { grid-column: 1 / -1; min-width: 0; font-size: 15px; line-height: 1.38; padding-top: 6px; margin-top: 2px; border-top: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.v-text[hidden] { display: none; }
.v-text.working { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.v-text.err { color: var(--danger); }
.v-dots { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ai-dot 1.2s ease-in-out infinite; }
.v-retry { color: var(--accent); font-weight: 600; padding: 2px 4px; }
@media (prefers-reduced-motion: reduce) { .v-tr { transition: none; } .v-dots { animation: none; opacity: .6; } }
.v-play { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; touch-action: manipulation; transition: transform 140ms var(--ease-out); }
.v-play:active { transform: scale(0.92); }
.v-play.busy { opacity: .6; }
.v-play .ic { fill: currentColor; stroke: none; width: 22px; height: 22px; }
.v-body { display: grid; gap: 3px; min-width: 0; }
.wave { display: flex; align-items: center; justify-content: space-between; gap: 1px; height: 26px; cursor: pointer; }
.wave i { flex: 1 1 0; min-width: 1px; max-width: 3px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.wave i.on { background: var(--accent); }
.v-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.v-arr { font-weight: 500; opacity: .85; }

.circle-msg { position: relative; width: 220px; height: 220px; border-radius: 50%; overflow: hidden; background: #1b1f24 center / cover no-repeat; display: block; transition: transform 160ms var(--ease-out); }
.circle-msg:active { transform: scale(0.98); }
.circle-msg video { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.c-ring circle { fill: none; stroke: rgba(255, 255, 255, .9); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 250ms linear; }
.c-play { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; transition: opacity 160ms; }
.c-play .ic { fill: currentColor; stroke: none; }
.circle-msg.playing .c-play { opacity: 0; }
.c-dur { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 12px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 7px; border-radius: 9px; }

.file { display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0; }
.file-ic { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.file-text { display: grid; min-width: 0; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.call-line { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.call-line.bad { color: var(--danger); }

/* ---------- ввод ---------- */
.composer { flex: none; background: var(--bg); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); position: relative; }
.compose-row { display: flex; align-items: flex-end; gap: 4px; }
.compose-input {
  flex: 1; resize: none; border: 0; outline: none; background: var(--bg-2); border-radius: 22px;
  padding: 11px 14px; min-height: 44px; max-height: 160px; line-height: 1.35;
}
.compose-actions { display: flex; gap: 2px; }
/* Диктовка голосом (web/js/features/dictate): кнопка внутри поля справа; слова появляются в поле по ходу речи, красный круг дышит от громкости */
.compose-field { flex: 1; min-width: 0; position: relative; display: flex; }
.compose-field > .compose-input { min-width: 0; }
.compose-field.has-dict > .compose-input { padding-right: 46px; }
.dict-btn {
  position: absolute; right: 2px; bottom: 2px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted);
  transition: transform 140ms var(--ease-out), color 140ms, background-color 140ms; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.dict-btn[hidden] { display: none; }
.dict-btn:active { transform: scale(0.92); }
.dict-btn > .ic { position: relative; width: 22px; height: 22px; }
.dict-ring { position: absolute; inset: 4px; border-radius: 50%; background: var(--danger); opacity: 0; transform: scale(1); transition: opacity 140ms var(--ease-out), transform 90ms linear; }
.dict-btn.on { color: #fff; }
.dict-btn.on .dict-ring { opacity: 1; }
.dict-btn.on.fin, .dict-btn.refine { animation: dict-fin 900ms ease-in-out infinite; }      /* .refine — итог точной модели дослушивается в фоне */
@keyframes dict-fin { 50% { opacity: .55; } }
@media (hover: hover) and (pointer: fine) { .dict-btn:not(.on):hover { background: var(--bg); color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .dict-btn, .dict-ring { transition: none; } .dict-btn.on.fin, .dict-btn.refine { animation: none; opacity: .7; } }
/* Панель записи — как в Telegram Web K: [корзина] [поле: точка · таймер · волна] [часы] [отправить] */
.rec-bar { display: flex; align-items: center; gap: 4px; min-height: 44px; animation: rec-in 160ms var(--ease-out); }
@keyframes rec-in { from { opacity: 0; transform: translateY(6px); } }
.rec-trash { color: var(--danger); touch-action: manipulation; }
.rec-main { flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 22px; background: var(--bg-2); font-variant-numeric: tabular-nums; }
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-blink 1.25s ease-in-out infinite; }
@keyframes rec-blink { 50% { opacity: .3; } }
.rec-time { flex: none; font-weight: 600; min-width: 4.2ch; }
.rec-kind { font-size: 14px; }
.rec-wave { flex: 1; min-width: 0; height: 26px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.rec-wave i { flex: 1 1 0; min-width: 0; max-width: 3px; height: 100%; border-radius: 2px; background: var(--accent); transform: scaleY(.1); transition: transform 100ms linear; }
@media (prefers-reduced-motion: reduce) { .rec-bar { animation: none; } .rec-dot { animation: none; } .rec-wave i { transition: none; } }
.rec-circle-wrap {
  /* у камеры — сверху экрана, как в Телеграме; смотришь в камеру, а не вниз */
  position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 64px); z-index: 45;
  display: grid; justify-items: center; gap: 12px; pointer-events: none;
  animation: rise-in 220ms var(--ease-out);
}
.rec-circle-wrap.closing { opacity: 0; transform: scale(0.96); transition: opacity 160ms ease, transform 160ms ease; }
.rec-preview { width: min(78vw, 340px); aspect-ratio: 1; border-radius: 50%; box-shadow: 0 10px 40px rgba(0,0,0,.35); border: 3px solid var(--accent); background: #000; }
.rec-tools { display: flex; gap: 14px; pointer-events: auto; }
.rec-tool { width: 48px; height: 48px; border-radius: 50%; background: rgba(20, 23, 28, .72); color: #fff; display: grid; place-items: center; backdrop-filter: blur(10px); transition: transform 140ms var(--ease-out), background-color 160ms ease; }
.rec-tool:active { transform: scale(0.92); }
.rec-tool.on { background: var(--accent); color: var(--accent-text); }
@keyframes rise-in { from { opacity: 0; transform: scale(0.95); } }
@media (prefers-reduced-motion: reduce) { .rec-circle-wrap { animation-duration: 1ms; } }

/* ---------- шторки, меню, тосты ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 16, .42); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 200ms var(--ease-out);
}
.sheet {
  width: 100%; max-width: 480px; max-height: 90dvh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b);
  animation: rise 300ms var(--ease-drawer);
}
@media (min-width: 761px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; animation: pop 200ms var(--ease-out); }
}
.sheet-wrap.closing { opacity: 0; transition: opacity 180ms; }
.sheet-head { display: flex; align-items: center; padding: 10px 8px 4px 20px; }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; display: grid; gap: 12px; align-content: start; grid-auto-rows: max-content; }
.sheet-body h3 { margin-bottom: 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }
.stack { display: grid; gap: 10px; }
.profile { display: flex; align-items: center; gap: 16px; }
.code { font-size: 17px; letter-spacing: .05em; line-height: 1.7; background: var(--bg-2); padding: 10px 14px; border-radius: 12px; word-spacing: .3em; user-select: text; }
/* код безопасности: в самом низу карточки, свёрнут гармошкой; внутри по умолчанию скрыт глазком, цифр на странице нет, пока не нажали (web/js/features/safety) */
.sc { display: grid; margin-top: 8px; border-radius: 14px; background: var(--bg-2); overflow: hidden; }
.sc-h { margin: 0; font-size: inherit; }
.sc-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px; color: inherit; text-align: left; font-size: 15px; font-weight: 600; touch-action: manipulation; transition: background-color 140ms; }
.sc-head:active { background: rgba(127, 127, 127, .12); }
.sc-head > .ic:first-child { color: var(--muted); flex: none; }
.sc-title { flex: 1; min-width: 0; }
.sc-head > .ic:last-child { flex: none; width: 18px; height: 18px; color: var(--muted); transition: transform 220ms var(--ease-drawer); }
.sc.open .sc-head > .ic:last-child { transform: rotate(90deg); }
/* гармошка: высота панели 0 → по содержимому (grid 0fr → 1fr); закрытая панель вне порядка табуляции и чтения с экрана */
.sc-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 240ms var(--ease-drawer); }
.sc.open .sc-panel { grid-template-rows: 1fr; }
.sc-inner { min-height: 0; overflow: hidden; display: grid; gap: 8px; padding: 0 14px; visibility: hidden; opacity: 0; transition: visibility 0s linear 240ms, opacity 160ms var(--ease-out), padding 240ms var(--ease-drawer); }
.sc.open .sc-inner { visibility: visible; opacity: 1; padding: 2px 14px 14px; transition-delay: 0s; }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@media (prefers-reduced-motion: reduce) { .sc-panel, .sc-inner, .sc-head > .ic:last-child { transition-duration: 1ms; transition-delay: 0s; } }
.sc-eye { color: var(--muted); flex: none; }
.sc-eye[aria-pressed="true"] { color: var(--accent); }
.sc-code { margin: 0; }
.sc .code { background: var(--bg); }
.sc-code.sc-hidden { color: var(--muted); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sc-note { margin: 0; color: var(--danger); }
.sc-note:empty { display: none; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 12px; text-align: left; font-weight: 500; }
.menu-item:active { background: var(--bg-2); }
.menu-item.danger { color: var(--danger); }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }

.toasts { position: fixed; left: 0; right: 0; top: calc(12px + var(--safe-t)); z-index: 90; display: grid; justify-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { background: #22272e; color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: drop 220ms var(--ease-out); transition: opacity 180ms, transform 180ms; max-width: 420px; }
.toast.out { opacity: 0; transform: translateY(-6px); }
.toast.has-act { display: flex; align-items: center; gap: 14px; pointer-events: auto; padding-right: 8px; }
.toast-act { flex-shrink: 0; min-height: 44px; margin: -10px 0; padding: 0 12px; border: 0; background: none; color: #ff8a8a; font: inherit; font-weight: 600; }
.toast-act:active { opacity: .6; }

.viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; animation: fade 180ms var(--ease-out); }
.viewer img { max-width: 100%; max-height: 100dvh; object-fit: contain; }
.viewer-close { position: absolute; top: calc(8px + var(--safe-t)); right: 8px; color: #fff; z-index: 2; }
/* Просмотр фото на весь экран (chat/viewer.js): чёрный фон без просвета, фото вписано в экран целиком и приближается щипком */
.photo-viewer { display: block; overflow: hidden; touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.photo-viewer img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; transform-origin: 50% 50%; will-change: transform; pointer-events: none; }
.photo-viewer .viewer-close { background: rgba(0, 0, 0, .35); border-radius: 50%; touch-action: manipulation; }
.viewer.closing { opacity: 0; transition: opacity 160ms; }

/* ---------- звонок ---------- */
.call {
  position: fixed; inset: 0; z-index: 70; background: radial-gradient(120% 90% at 50% 20%, #24332f, #0b0f0e);
  color: #fff; animation: fade 220ms var(--ease-out); overflow: hidden;
}
.call.closing { opacity: 0; transition: opacity 180ms; }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call video.remote.contain { object-fit: contain; }
.call-face { position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 80px; background: radial-gradient(120% 90% at 50% 20%, #24332f, #0b0f0e); }
.voice-ring {
  position: absolute; left: 50%; top: calc(50% - 40px); width: 128px; height: 128px; margin: -64px 0 0 -64px; border-radius: 50%;
  background: var(--accent); opacity: 0; transform: scale(1); transition: transform 120ms linear, opacity 160ms ease; pointer-events: none;
}
.tap-sound {
  position: absolute; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-radius: 28px; background: #fff; color: #111; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); transition: transform 140ms var(--ease-out);
}
.tap-sound:active { transform: translateX(-50%) scale(0.97); }
.call-face .av { position: relative; width: 128px; height: 128px; font-size: 44px; box-shadow: 0 0 0 10px rgba(255,255,255,.06), 0 0 0 22px rgba(255,255,255,.03); }
.call-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(28px + var(--safe-t)) 16px 40px; text-align: center; background: linear-gradient(rgba(0,0,0,.45), transparent); }
.call-name { font-size: 24px; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
.call-status { margin-top: 4px; opacity: .85; font-variant-numeric: tabular-nums; }
.call-e2e { margin-top: 6px; font-size: 12.5px; opacity: .75; }
.call-away { margin: 8px auto 0; max-width: 320px; font-size: 13px; padding: 6px 12px; border-radius: 12px; background: rgba(255, 209, 102, .18); color: #ffd166; }
.call-e2e .net.good { color: #7ee2b0; }
.call-e2e .net.mid { color: #ffd166; }
.call-e2e .net.bad { color: #ff8a8a; }
.call video.local {
  position: absolute; right: 12px; top: calc(168px + var(--safe-t));   /* ниже имени в две строки и строки «связь …» */ width: 108px; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 14px; background: #111; box-shadow: 0 6px 24px rgba(0,0,0,.45); z-index: 2;
}
.call video.local.mirror { transform: scaleX(-1); }
.call-controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 24px 12px calc(28px + var(--safe-b)); background: linear-gradient(transparent, rgba(0,0,0,.55));
}
.call-btn { display: grid; justify-items: center; gap: 6px; width: 64px; font-size: 12px; color: rgba(255,255,255,.9); }
.call-btn .ic { width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: rgba(255,255,255,.16); backdrop-filter: blur(8px); transition: transform 140ms var(--ease-out), background-color 140ms; }
.call-btn:active .ic { transform: scale(0.92); }
.call-btn.off .ic { background: #fff; color: #111; }
.call-btn.on .ic { background: var(--accent); }
.call-btn.red .ic { background: #e5484d; color: #fff; }
.call-btn.green .ic { background: #2fb36d; color: #fff; }

/* ---------- конференция: плитки людей ---------- */
.conf {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1b2724, #0b0f0e); color: #fff; animation: fade 200ms var(--ease-out);
}
.conf.closing { opacity: 0; transition: opacity 180ms; }
.conf-top { flex: none; padding: calc(12px + var(--safe-t)) 16px 8px; text-align: center; min-width: 0; }
.conf-title { font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf-sub { margin-top: 2px; font-size: 14px; opacity: .8; font-variant-numeric: tabular-nums; }
.conf-top .call-e2e { margin-top: 2px; }
.conf-grid {
  flex: 1; min-height: 0; display: grid; gap: 6px; padding: 4px 6px 0;
  grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr);
}
.conf-grid[data-n="3"], .conf-grid[data-n="4"], .conf-grid[data-n="5"], .conf-grid[data-n="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (orientation: landscape) {
  .conf-grid[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conf-grid[data-n="5"], .conf-grid[data-n="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ctile {
  position: relative; min-width: 0; overflow: hidden; border-radius: 16px; background: #151b19;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.ctile.enter { opacity: 0; transform: scale(0.95); }
.ctile.leave { opacity: 0; transform: scale(0.97); transition-duration: 140ms; }
.ctile::after {                          /* кольцо «говорит»: только прозрачность — без перерисовки раскладки */
  content: ''; position: absolute; inset: 0; border-radius: inherit; border: 3px solid var(--accent);
  opacity: 0; transition: opacity 140ms var(--ease-out); pointer-events: none;
}
.ctile.speaking::after { opacity: 1; }
.ctile-v { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.ctile-v.mirror { transform: scaleX(-1); }
.ctile-face { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 20%, #24332f, #0b0f0e); }
.ctile-face .av { width: 72px; height: 72px; font-size: 26px; }
.conf-grid[data-n="1"] .ctile-face .av, .conf-grid[data-n="2"] .ctile-face .av { width: 96px; height: 96px; font-size: 34px; }
.ctile-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 22px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .62));
}
.ctile-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.ctile-mic { flex: none; display: inline-flex; color: #ff8a8a; }
.ctile-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #7ee2b0; }
.ctile-dot.mid { background: #ffd166; }
.ctile-dot.bad { background: #ff8a8a; }
.ctile-state {
  position: absolute; left: 8px; right: 8px; top: 8px; padding: 4px 10px; border-radius: 10px; text-align: center;
  background: rgba(0, 0, 0, .55); font-size: 12.5px; overflow-wrap: anywhere;
}
.conf-controls { flex: none; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 12px 12px calc(14px + var(--safe-b)); }
.conf .tap-sound { bottom: calc(120px + var(--safe-b)); }
.cinvite .cinvite-people { max-width: 320px; margin-inline: auto; overflow-wrap: anywhere; }
.cinvite .call-name { overflow-wrap: anywhere; padding: 0 12px; }
.conf-banner {
  position: fixed; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; z-index: 80; display: flex; align-items: center; gap: 8px;
  max-width: 520px; margin: 0 auto; padding: 10px 10px 10px 14px; border-radius: 16px; background: var(--bg); color: var(--text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .28); animation: drop 200ms var(--ease-out);
}
.conf-banner-text { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.conf-banner .btn { flex: none; }
.conf-head { display: grid; gap: 8px; }
.conf-head:not(:empty) { margin: 0 0 6px; }
.conf-head .list-head { padding: 10px 14px 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.conf-row { padding: 0 2px 0 0; }
.conf-row .row-name, .conf-row .row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf-row .conf-join { flex: none; margin-right: 8px; }
.conf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.conf-chip { padding: 8px 12px; border-radius: 14px; background: var(--bg-2); font-size: 14px; font-weight: 600; transition: transform 140ms var(--ease-out); }
.conf-chip:active { transform: scale(0.97); }
.conf-when { display: flex; align-items: center; gap: 4px; font-weight: 600; overflow-wrap: anywhere; }
.conf-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.conf-grid[data-n="3"] .ctile:last-child, .conf-grid[data-n="5"] .ctile:last-child { grid-column: 1 / -1; }   /* нечётная последняя плитка — на всю ширину */
@media (orientation: landscape) { .conf-grid[data-n="5"] .ctile:last-child { grid-column: auto; } }
body:has(.conf) .sheet-wrap { z-index: 75; }          /* шторка «Позвать ещё» поверх комнаты */
.conf-pick { max-height: 38dvh; overflow-y: auto; overscroll-behavior: contain; }
@media (hover: hover) and (pointer: fine) { .conf-chip:hover { background: var(--line); } }
@media (prefers-reduced-motion: reduce) {
  .conf, .conf-banner { animation-duration: 1ms; }
  .ctile, .ctile.enter, .ctile.leave { transition: none; transform: none; }
}

/* ---------- проверка связи ---------- */
.nc-list:empty { display: none; }
.nc-row { animation: fade 160ms var(--ease-out); }
.nc-state { flex: none; width: 24px; display: inline-grid; place-items: center; color: var(--muted); font-weight: 700; }
.nc-ok .nc-state { color: var(--green); }
.nc-bad .nc-state { color: var(--danger); }
.nc-verdict { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--bg-2); font-weight: 600; overflow-wrap: anywhere; }
.nc-verdict.bad { color: var(--danger); }

/* ---------- запасной адрес: плашка ---------- */
.addr-banner {
  flex: none; display: grid; gap: 10px; margin: 8px 8px 0; padding: 12px 14px; border-radius: 16px; background: var(--bg-2); color: var(--text);
  animation: pop 200ms var(--ease-out);
}
.addr-banner-text { display: grid; gap: 4px; overflow-wrap: anywhere; min-width: 0; }
.addr-banner-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.addr-rows { display: grid; gap: 6px; }
.addr-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.addr-row .addr-host { flex: 1; font-weight: 600; }
.addr-row .btn { flex: none; }
.addr-host { overflow-wrap: anywhere; min-width: 0; }
.addr-list .set-row { gap: 8px; }
@media (prefers-reduced-motion: reduce) { .addr-banner { animation-duration: 1ms; } }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-wrap, .toast, .call, .viewer { animation-duration: 1ms; }
}

/* ---------- фон чата ---------- */
.chat-pane { position: relative; isolation: isolate; }
.chat-pane::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
:root[data-wall="pattern"] .chat-pane::before {
  background-color: var(--wall-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat;
          mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat;
}
:root[data-wall="gradient"] .chat-pane {
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent) 24%, var(--chat-bg)) 0%,
    var(--chat-bg) 55%,
    color-mix(in srgb, var(--accent) 14%, var(--chat-bg)) 100%);
}

/* ---------- фото профиля ---------- */
.av { position: relative; overflow: hidden; }
.av-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  opacity: 0; transition: opacity 200ms var(--ease-out);
}
.av-img.ready { opacity: 1; }
.av-edit { position: relative; border-radius: 50%; transition: transform 140ms var(--ease-out); }
.av-edit:active { transform: scale(0.96); }
.av-edit .cam {
  position: absolute; right: -2px; bottom: -2px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); display: grid; place-items: center; border: 3px solid var(--bg);
}
.av-edit .cam .ic { width: 16px; height: 16px; }

.cropper {
  position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 4px auto 0; border-radius: 16px; overflow: hidden;
  background: #000; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.cropper:active { cursor: grabbing; }
.cropper img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; will-change: transform; }
.cropper::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .5); outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -2px;
}
.zoom { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.zoom input { flex: 1; accent-color: var(--accent); }

/* ---------- оформление ---------- */
.preview {
  border-radius: 18px; overflow: hidden; border: 1px solid var(--line); position: relative; isolation: isolate;
  background: var(--chat-bg); padding: 14px 12px; display: grid; gap: 6px;
}
.preview::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
:root[data-wall="pattern"] .preview::before { background-color: var(--wall-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat; }
:root[data-wall="gradient"] .preview { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 24%, var(--chat-bg)), var(--chat-bg) 55%, color-mix(in srgb, var(--accent) 14%, var(--chat-bg))); }
.preview .msg { margin: 0; }
.preview .bubble { font-size: 14px; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%; background: var(--sw); display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); transition: transform 140ms var(--ease-out);
}
.swatch:active { transform: scale(0.92); }
.swatch .ic { width: 20px; height: 20px; stroke-width: 2.6; opacity: 0; transform: scale(0.9); transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sw); }
.swatch[aria-checked="true"] .ic { opacity: 1; transform: scale(1); }

.segmented { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg-2); border-radius: 12px; padding: 3px; }
.segmented .thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3); border-radius: 10px;
  background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.12); transition: transform 220ms var(--ease-out);
}
.segmented button { position: relative; min-height: 38px; font-size: 14px; font-weight: 600; color: var(--muted); transition: color 160ms ease; }
.segmented button[aria-checked="true"], .segmented button[aria-selected="true"] { color: var(--text); }

.walls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wall {
  height: 72px; border-radius: 14px; position: relative; overflow: hidden; isolation: isolate; border: 2px solid transparent;
  background: var(--chat-bg); background-origin: border-box; transition: transform 140ms var(--ease-out), border-color 160ms ease;
}
.wall:active { transform: scale(0.96); }
.wall[aria-checked="true"] { border-color: var(--accent); }
.wall span { position: absolute; left: 8px; bottom: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.wall.pattern::before { content: ""; position: absolute; inset: 0; z-index: -1; background-color: var(--wall-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 120px 120px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 120px 120px repeat; }
.wall.gradient { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 30%, var(--chat-bg)), var(--chat-bg) 60%, color-mix(in srgb, var(--accent) 16%, var(--chat-bg))); }
@media (prefers-reduced-motion: reduce) {
  .segmented .thumb, .swatch .ic, .av-img { transition-duration: 1ms; }
}

/* ---------- настройки: строки, переключатели, звуки, память ---------- */
.set-group { border-radius: 14px; background: var(--bg-2); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; width: 100%; text-align: left; background: var(--bg-2); }
.set-group .set-row + .set-row { border-top: 1px solid var(--line); }
.set-row > .ic { color: var(--muted); }
.set-label { flex: 1; display: grid; gap: 2px; }
button.set-row:active { background: var(--line); }
.sw-input {
  appearance: none; -webkit-appearance: none; flex: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line);
  position: relative; cursor: pointer; transition: background-color 200ms ease;
}
.sw-input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 220ms var(--ease-out);
}
.sw-input:checked { background: var(--accent); }
.sw-input:checked::after { transform: translateX(20px); }
.sound-list { display: grid; gap: 2px; }
.sound-item { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 12px; border-radius: 12px; text-align: left; }
.sound-item:active { background: var(--bg-2); }
.sound-item .ic { color: var(--accent); opacity: 0; transform: scale(0.9); transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
.sound-item[aria-checked="true"] { font-weight: 700; }
.sound-item[aria-checked="true"] .ic { opacity: 1; transform: scale(1); }
.meter { height: 10px; border-radius: 5px; background: var(--bg-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 400ms var(--ease-out); }
.gone { font-style: italic; }
@media (hover: hover) and (pointer: fine) { button.set-row:hover, .sound-item:hover { background: var(--line); } }
@media (prefers-reduced-motion: reduce) { .sw-input, .sw-input::after, .meter span { transition-duration: 1ms; } }

/* ---------- меню настроек ---------- */
.me-card { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: var(--bg-2); text-align: left; width: 100%; transition: transform 140ms var(--ease-out); }
.me-card:active { transform: scale(0.98); }
.me-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.av.lg { width: 60px; height: 60px; font-size: 22px; }
.set-row.nav { min-height: 60px; }
.set-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.set-ic .ic { width: 18px; height: 18px; }
.unavailable { text-align: center; padding: 24px 8px; display: grid; gap: 6px; }

.video-box { background: #1b1f24 center / cover no-repeat; }
.v-label { position: absolute; left: 10px; bottom: 10px; font-size: 12.5px; color: #fff; background: rgba(0,0,0,.5); padding: 3px 8px; border-radius: 10px; pointer-events: none; }

/* ---------- фон «Смайлики»: силуэты системных эмодзи (маской — одним бледным цветом) ---------- */
:root[data-wall="emoji"] .chat-pane::before, :root[data-wall="emoji"] .preview::before {
  background-color: var(--wall-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 200px 200px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 200px 200px repeat;
}
.wall.emoji::before { content: ""; position: absolute; inset: 0; z-index: -1; background-color: var(--wall-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 130px 130px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 130px 130px repeat; }

/* ---------- главный экран: не белый, а тот же фон, что в чате, но бледнее — чтобы не мешал читать ---------- */
.list-pane { position: relative; isolation: isolate; background: color-mix(in srgb, var(--chat-bg) 55%, var(--bg)); }
.list-pane::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .7; }
:root[data-wall="pattern"] .list-pane::before { background-color: var(--wall-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22180%22%20height=%22180%22%20viewBox=%220%200%20180%20180%22%20fill=%22none%22%20stroke=%22%23000%22%20stroke-width=%222.2%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%20%3Cpath%20d=%22M18%2022h30a8%208%200%200%201%208%208v14a8%208%200%200%201-8%208H32l-9%207v-7h-5a8%208%200%200%201-8-8V30a8%208%200%200%201%208-8z%22/%3E%20%3Cpath%20d=%22M120%2030c0-6%208-9%2012-3%204-6%2012-3%2012%203%200%208-12%2014-12%2014s-12-6-12-14z%22/%3E%20%3Cpath%20d=%22M84%2078l3%207%207%201-5%205%201%207-6-3-6%203%201-7-5-5%207-1z%22/%3E%20%3Cpath%20d=%22M30%20112a10%2010%200%201%200%2020%200%2010%2010%200%201%200-20%200zM40%2098v-4M40%20130v-4M26%20112h-4M58%20112h-4%22/%3E%20%3Cpath%20d=%22M130%20100h22a6%206%200%200%201%206%206v18a6%206%200%200%201-6%206h-22a6%206%200%200%201-6-6v-18a6%206%200%200%201%206-6zM158%20110l10-6v22l-10-6%22/%3E%20%3Cpath%20d=%22M78%20150c6-10%2018-10%2024%200M84%20142v.5M96%20142v.5%22/%3E%20%3Cpath%20d=%22M150%20160l3-6%203%206-3%206zM14%20160l2-4%202%204-2%204z%22/%3E%20%3Cpath%20d=%22M104%2052a6%206%200%201%200%2012%200%206%206%200%201%200-12%200z%22/%3E%20%3C/svg%3E") 0 0 / 180px 180px repeat; }
:root[data-wall="emoji"] .list-pane::before { background-color: var(--wall-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 200px 200px repeat; mask: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22200%22%20height=%22200%22%20viewBox=%220%200%20200%20200%22%20font-family=%22Apple%20Color%20Emoji,Segoe%20UI%20Emoji,Noto%20Color%20Emoji,sans-serif%22%3E%3Ctext%20x=%2214%22%20y=%2226%22%20font-size=%2222%22%20transform=%22rotate(0%2014%2026)%22%3E%F0%9F%98%8A%3C/text%3E%3Ctext%20x=%2284%22%20y=%2218%22%20font-size=%2222%22%20transform=%22rotate(7%2084%2018)%22%3E%E2%9D%A4%EF%B8%8F%3C/text%3E%3Ctext%20x=%22150%22%20y=%2234%22%20font-size=%2222%22%20transform=%22rotate(14%20150%2034)%22%3E%E2%AD%90%3C/text%3E%3Ctext%20x=%2240%22%20y=%2278%22%20font-size=%2222%22%20transform=%22rotate(-9%2040%2078)%22%3E%F0%9F%8C%B8%3C/text%3E%3Ctext%20x=%22118%22%20y=%2272%22%20font-size=%2222%22%20transform=%22rotate(-2%20118%2072)%22%3E%F0%9F%8E%88%3C/text%3E%3Ctext%20x=%22176%22%20y=%2296%22%20font-size=%2222%22%20transform=%22rotate(5%20176%2096)%22%3E%E2%98%95%3C/text%3E%3Ctext%20x=%2220%22%20y=%22130%22%20font-size=%2222%22%20transform=%22rotate(12%2020%20130)%22%3E%F0%9F%8E%B5%3C/text%3E%3Ctext%20x=%2286%22%20y=%22124%22%20font-size=%2222%22%20transform=%22rotate(-11%2086%20124)%22%3E%F0%9F%8C%99%3C/text%3E%3Ctext%20x=%22150%22%20y=%22150%22%20font-size=%2222%22%20transform=%22rotate(-4%20150%20150)%22%3E%F0%9F%90%B1%3C/text%3E%3Ctext%20x=%2256%22%20y=%22176%22%20font-size=%2222%22%20transform=%22rotate(3%2056%20176)%22%3E%F0%9F%8D%80%3C/text%3E%3Ctext%20x=%22122%22%20y=%22190%22%20font-size=%2222%22%20transform=%22rotate(10%20122%20190)%22%3E%E2%9C%A8%3C/text%3E%3Ctext%20x=%22186%22%20y=%22178%22%20font-size=%2222%22%20transform=%22rotate(-13%20186%20178)%22%3E%F0%9F%8E%81%3C/text%3E%3C/svg%3E") 0 0 / 200px 200px repeat; }
:root[data-wall="gradient"] .list-pane { background: linear-gradient(170deg, color-mix(in srgb, var(--accent) 12%, var(--bg)) 0%, var(--bg) 45%, color-mix(in srgb, var(--accent) 7%, var(--bg)) 100%); }
.list-pane .bar { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); }
.list .row { background: color-mix(in srgb, var(--bg) 62%, transparent); margin-bottom: 4px; }
.list .row.active { background: var(--accent-2); }
@media (prefers-reduced-transparency: reduce) { .list-pane .bar { background: var(--bg); backdrop-filter: none; } .list .row { background: var(--bg); } }

/* «День и ночь»: четыре варианта в переключателе */
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented.four .thumb { width: calc((100% - 6px) / 4); }
.segmented.four button { font-size: 13px; padding: 0 2px; line-height: 1.15; }
.walls { grid-template-columns: repeat(4, 1fr); }
.wall { height: 64px; }

/* ---------- кабинет владельца: плитки, столбики, люди ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }              /* «Память сервера»: четыре плитки — по две в ряд */
.tile { background: var(--bg-2); border-radius: 14px; padding: 10px 10px 9px; display: grid; gap: 1px; min-width: 0; }
.tile-v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.tile-l { font-size: 12.5px; color: var(--muted); line-height: 1.2; }
.tile-h { font-size: 11.5px; color: var(--muted); opacity: .85; line-height: 1.2; }
.chart { background: var(--bg-2); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.chart-title { font-size: 14px; font-weight: 600; }
.cbars { display: grid; grid-template-columns: repeat(14, 1fr); align-items: end; height: 120px; gap: 2px;
  background: linear-gradient(var(--line), var(--line)) bottom / 100% 1px no-repeat; }
.cbar-hit { height: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; }
.cbar { display: block; width: 100%; max-width: 18px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; transition: opacity 120ms ease; }
.cbar-hit.on .cbar { opacity: 1; box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px color-mix(in srgb, var(--accent) 40%, transparent); }
@media (hover: hover) and (pointer: fine) { .cbar-hit:hover .cbar { opacity: 1; } }
.cbars-axis { display: flex; justify-content: space-between; }
.chart-tip { font-size: 13px; color: var(--text); min-height: 18px; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 16px; background: var(--bg-2); font-size: 13.5px; font-weight: 600; color: var(--muted); transition: background-color 160ms ease, color 160ms ease; }
.chip[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.set-row.member { min-height: 58px; }
.rel { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 9px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.rel.me { background: var(--accent-2); color: var(--accent); }
.rel.contact { background: var(--accent-2); color: var(--accent); }
.rel.member { background: color-mix(in srgb, #8b5cf6 16%, var(--bg)); color: color-mix(in srgb, #8b5cf6 80%, var(--text)); }
.rel.blocked { background: color-mix(in srgb, var(--danger) 16%, var(--bg)); color: var(--danger); }
@media (max-width: 360px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

/* ---------- нижняя панель вкладок (как в Телеграме) ---------- */
.bar-actions { display: flex; align-items: center; }
.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.tab-pane { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 6px calc(96px + var(--safe-b)); }
section.tab-pane { display: grid; align-content: start; gap: 10px; padding: 8px 12px calc(96px + var(--safe-b)); }
.pad { padding: 20px 12px; }

/* «Жидкое стекло» (как в iOS 26): корпус почти прозрачный, под ним видны обои и список, размытые и яркие;
   рамка — блик по кромке (свет сверху-слева и снизу-справа), значки и подписи полной плотности. Всё из переменных --glass-* темы. */
.tabbar {
  position: absolute; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 4;
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px; border-radius: 30px; --i: 2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, calc(var(--glass-hi) * .45)) 0%, rgba(255, 255, 255, 0) 60%),
    color-mix(in srgb, var(--bg) var(--glass-body), transparent);
  -webkit-backdrop-filter: blur(16px) saturate(190%); backdrop-filter: blur(16px) saturate(190%);
  border: 1px solid transparent;
  box-shadow:
    0 0 0 .5px var(--glass-hair),
    0 12px 32px rgba(8, 12, 16, .18), 0 2px 8px rgba(8, 12, 16, .08),
    inset 0 1px 0 rgba(255, 255, 255, var(--glass-hi)),
    inset 0 -1px 0 rgba(255, 255, 255, calc(var(--glass-hi) * .35)),
    inset 0 0 14px rgba(255, 255, 255, calc(var(--glass-hi) * .2));
}
.tabbar::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, var(--glass-hi)) 0%, rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 68%, rgba(255, 255, 255, calc(var(--glass-hi) * .75)) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
.tab-glass {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 4); border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, calc(var(--glass-hi) * .4)), rgba(255, 255, 255, 0) 70%),
    color-mix(in srgb, var(--text) 9%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, var(--glass-hi)), inset 0 -1px 0 rgba(255, 255, 255, calc(var(--glass-hi) * .4)),
    0 0 0 .5px color-mix(in srgb, var(--text) 8%, transparent), 0 3px 10px rgba(8, 12, 16, .1);
  transform: translateX(calc(var(--i) * 100%)); transition: transform 320ms var(--ease-drawer);
}
.tab {
  position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; padding: 7px 0 6px; min-width: 0;
  font-size: 11px; font-weight: 600; color: var(--text);
  transition: color 160ms ease;
}
.tab[aria-current] { color: var(--accent); }
.tab-ic { width: 28px; height: 28px; display: grid; place-items: center; transition: transform 140ms var(--ease-out); }
.tab:active .tab-ic { transform: scale(0.9); }
.tab-ic .ic { width: 26px; height: 26px; stroke-width: 2; filter: drop-shadow(0 0 var(--glass-halo) color-mix(in srgb, var(--bg) 85%, transparent)); }
.tab-label { text-shadow: 0 0 var(--glass-halo) color-mix(in srgb, var(--bg) 85%, transparent); }
.tab[aria-current] .tab-ic .ic { stroke-width: 2.3; }
.av.tab-av { width: 28px; height: 28px; font-size: 11px; }
.tab[aria-current] .av.tab-av { box-shadow: 0 0 0 2px var(--accent); }
.tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab-badge {
  position: absolute; top: 2px; left: calc(50% + 4px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid color-mix(in srgb, var(--bg) 85%, transparent); box-sizing: content-box; transform: translate(-2px, 0);
}
@supports ((-webkit-backdrop-filter: contrast(.6)) or (backdrop-filter: contrast(.6))) {
  .tabbar {
    -webkit-backdrop-filter: blur(16px) saturate(190%) contrast(var(--glass-contrast)) brightness(var(--glass-bright));
    backdrop-filter: blur(16px) saturate(190%) contrast(var(--glass-contrast)) brightness(var(--glass-bright));
  }
}
@media (prefers-reduced-motion: reduce) { .tab-glass { transition-duration: 1ms; } }
/* без прозрачности (настройка «уменьшить прозрачность», «повысить контраст», старый браузер без backdrop-filter) — плотная панель с рамкой */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .tabbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: 0 0 0 1px var(--text), 0 8px 24px rgba(8, 12, 16, .16); }
  .tabbar::before { display: none; }
  .tab-glass { background: color-mix(in srgb, var(--text) 14%, transparent); box-shadow: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: color-mix(in srgb, var(--bg) 94%, transparent); }
}

/* ---------- «Контакты» и «Звонки» ---------- */
.search-wrap { padding: 0 2px; }
.search {
  width: 100%; min-height: 40px; padding: 0 14px; border: 0; outline: none; border-radius: 12px;
  background: color-mix(in srgb, var(--bg-2) 85%, transparent); -webkit-appearance: none; appearance: none;
}
.search::placeholder { color: var(--muted); }
.people { display: grid; gap: 4px; }
.person {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; text-align: left;
  background: color-mix(in srgb, var(--bg) 62%, transparent); transition: background-color 120ms;
}
.person:active { background: var(--bg-2); }
.person .row-main { min-width: 0; }
.person .row-name, .person .row-preview { display: block; }
.invite-row .set-ic { width: 48px; height: 48px; border-radius: 50%; }
.invite-row .set-ic .ic { width: 22px; height: 22px; }
.call-item { padding: 0 2px 0 0; }
.call-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 9px 4px 9px 10px; text-align: left; border-radius: 14px; }
.call-main:active { background: var(--bg-2); }
.call-info { color: var(--muted); flex: none; }
.row-name.bad, .call-sub.bad { color: var(--danger); }
.call-sub .ic { stroke-width: 2.2; }
@media (hover: hover) and (pointer: fine) { .person:hover, .call-main:hover { background: var(--bg-2); } }

/* ---------- страница человека и страницы разделов настроек ---------- */
.me-card.me-hero {
  display: grid; justify-items: center; gap: 2px; padding: 20px 12px 16px; text-align: center; border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
}
.av.huge { width: 104px; height: 104px; font-size: 36px; }
.me-name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 10px; max-width: 100%; overflow-wrap: anywhere; }
.me-edit { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--accent); }
.set-ic { background: var(--tint, var(--accent)); }
.set-ic[style*="--tint"] { color: #fff; }
.set-group { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.set-row { background: transparent; }

.page {
  position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; background: var(--bg);
  transform: translateX(100%); transition: transform 300ms var(--ease-drawer);
}
.page.in { transform: none; }
.page.out { transform: translateX(100%); transition-duration: 240ms; }
.page .bar { padding-left: 4px; }
.page-title { flex: 1; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px calc(28px + var(--safe-b)); display: grid; align-content: start; gap: 12px; }
.page-scroll h3 { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .page { transform: none; opacity: 0; transition: opacity 160ms ease; } .page.in { opacity: 1; } .page.out { opacity: 0; } }

/* ---------- главный экран без шапки: сразу список; «Соединение…» — плашка только при обрыве связи ---------- */
.list-pane { padding-top: var(--safe-t); }
.net-pill {
  position: absolute; top: calc(var(--safe-t) + 8px); left: 50%; transform: translateX(-50%); z-index: 6;
  padding: 5px 12px; border-radius: 14px; font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap;
  background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 2px 10px rgba(8, 12, 16, .14);
}

/* ---------- худшие данные (break-ui): длинные имена не раздвигают экран ---------- */
section.tab-pane, .page-scroll, .people, .stack { grid-template-columns: minmax(0, 1fr); }
/* Строки сетки — по содержимому, а не по высоте экрана: карточка с overflow:hidden (группа настроек) иначе сжимается до нуля,
   прокручивать нечего и нижние пункты обрезаны (iPhone, 23.10: «Настройки не листаются»). */
section.tab-pane, .page-scroll, .near-body { grid-auto-rows: max-content; }
.profile > div { min-width: 0; }
.profile .who-name { white-space: normal; overflow-wrap: anywhere; }

/* ---------- ответ на сообщение и реакции ---------- */
.msg-col { display: flex; flex-direction: column; max-width: min(78%, 520px); min-width: 0; }
.msg.mine .msg-col { align-items: flex-end; }
.msg-col .bubble { max-width: 100%; }
.quote {
  display: grid; width: 100%; flex-basis: 100%; text-align: left; padding: 4px 8px; margin: 1px 0 4px; border-radius: 8px; min-width: 0;
  border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.quote-who { font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quote-text { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.react-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 8px; border-radius: 13px; font-size: 14px;
  background: var(--bg); box-shadow: var(--shadow); transition: transform 120ms var(--ease-out);
}
.react-chip span { font-size: 12px; font-weight: 700; color: var(--muted); }
.react-chip.mine { background: var(--accent-2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.react-chip:active { transform: scale(0.94); }
.react-pick { display: flex; justify-content: space-between; gap: 4px; padding: 4px 0 8px; }
.react-btn { width: 48px; height: 48px; border-radius: 50%; font-size: 26px; display: grid; place-items: center; transition: transform 140ms var(--ease-out), background-color 140ms; }
.react-btn:active { transform: scale(0.88); }
.react-btn.on { background: var(--accent-2); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px 10px; color: var(--accent); }
.reply-main { flex: 1; min-width: 0; display: grid; border-left: 3px solid var(--accent); padding-left: 8px; }
.msg.flash .bubble { animation: msg-flash 1.2s var(--ease-out); }
@keyframes msg-flash { 0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: var(--shadow); } }
@media (hover: hover) and (pointer: fine) { .react-btn:hover { background: var(--bg-2); } }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation-duration: 1ms; } }

/* ---------- QR-коды, сканер, «Связь рядом» ---------- */
.qr-card { display: grid; justify-items: center; gap: 8px; padding: 14px; border-radius: 18px; background: #fff; }
.qr-card .muted { color: #5b636c; }
canvas.qr { display: block; image-rendering: pixelated; }
.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border-radius: 14px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--bg) 62%, transparent); transition: transform 140ms var(--ease-out); }
.quick:active { transform: scale(0.97); }
.quick .ic { width: 20px; height: 20px; }
.scan { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; animation: fade 200ms var(--ease-out); }
.scan.closing { opacity: 0; transition: opacity 160ms; }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 50%; top: 50%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 24px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); outline: 3px solid rgba(255, 255, 255, .9); }
.scan-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--safe-t) + 18px) 20px 0; text-align: center; display: grid; gap: 6px; }
.scan-top h2 { font-size: 18px; }
.scan-hint { font-size: 14px; opacity: .85; }
.scan-cancel { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 28px); transform: translateX(-50%); background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(10px); }
.near { position: fixed; inset: 0; z-index: 75; display: flex; flex-direction: column; background: var(--bg); animation: fade 200ms var(--ease-out); }
.near.closing { opacity: 0; transition: opacity 180ms; }
.near-bar { padding-left: 4px; }
.near-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px 16px calc(20px + var(--safe-b)); }
.near-hero { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 8px 0; }
.near-step { font-weight: 600; }
.near-who { padding: 10px 12px; border-radius: 14px; background: var(--accent-2); }
.near-who.warn { background: color-mix(in srgb, #f59e0b 18%, var(--bg)); }
.near-msgs { min-height: 200px; max-height: 50dvh; border-radius: 14px; background: var(--chat-bg); }
.near-compose { gap: 6px; }
.near-offline { text-align: center; justify-items: center; display: grid; }
@media (prefers-reduced-motion: reduce) { .scan, .near { animation-duration: 1ms; } }

/* ---------- «Отправить позже» ---------- */
.sched-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sched-opt {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left;
  padding: 12px; border-radius: 16px; background: var(--bg-2); transition: transform 140ms var(--ease-out), background-color 140ms;
}
.sched-opt:active { transform: scale(0.97); }
.sched-ic { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-2); color: var(--accent); }
.sched-t { font-weight: 600; font-size: 15px; }
.sched-s { font-size: 12.5px; color: var(--muted); }
.sched-opt:last-child:nth-child(odd) { grid-column: 1 / -1; }
.sched-input { -webkit-appearance: none; appearance: none; min-height: 48px; }
.sched-input.bad { border-color: var(--danger); }
.sched-day span { display: inline-flex; align-items: center; gap: 4px; }
.msg.scheduled .bubble { opacity: .82; outline: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -1.5px; }
.msg.scheduled .meta { color: var(--accent); font-weight: 600; }
.msg.scheduled { cursor: pointer; }
.rec-later { color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .sched-opt:hover { background: var(--line); } }

/* ---------- ИИ-помощник ---------- */
.airow {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; text-align: left; margin-bottom: 4px;
  background: linear-gradient(100deg, color-mix(in srgb, #7c5cff 14%, var(--bg)), color-mix(in srgb, #2f7bff 10%, var(--bg)));
  transition: background-color 120ms, transform 140ms var(--ease-out);
}
.airow:active { transform: scale(0.99); }
.airow.active { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, #7c5cff 60%, transparent); }
.av.ai-av { background: linear-gradient(140deg, #8b5cf6, #3b82f6 60%, #06b6d4); color: #fff; }
.av.ai-av .ic { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.av.sm.ai-av .ic { width: 20px; height: 20px; }
.airow.supportrow { background: linear-gradient(100deg, color-mix(in srgb, #0ea5e9 13%, var(--bg)), color-mix(in srgb, #22a36b 10%, var(--bg))); position: relative; }
.airow.supportrow.active { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, #0ea5e9 60%, transparent); }
.av.ai-av.sup-av { background: linear-gradient(140deg, #0ea5e9, #22a36b); }
.av.ai-av.sup-av .ic, .av.sm.ai-av.sup-av .ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-hero.sup-hero { background: linear-gradient(140deg, #0ea5e9, #22a36b); box-shadow: 0 14px 40px rgba(14, 165, 233, .3); }
.ai-hero.sup-hero .ic { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.airow.supportrow .badge { flex: none; }
.sup-hint { text-align: center; padding: 0 12px 4px; margin: 0; background: var(--bg); }
.sup-diag { padding: 4px 14px; background: var(--bg); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sup-diag:empty { display: none; }
.sup-inbox { overflow-y: auto; flex: 1; }
.ai-start { margin: auto; display: grid; justify-items: center; gap: 10px; text-align: center; padding: 24px 20px; max-width: 360px; }
.ai-hero { width: 84px; height: 84px; border-radius: 28px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #8b5cf6, #3b82f6 60%, #06b6d4); box-shadow: 0 14px 40px rgba(76, 82, 255, .35); }
.ai-hero .ic { width: 44px; height: 44px; fill: currentColor; stroke: none; }
.ai-start h2 { font-size: 22px; letter-spacing: -0.02em; }
.ai-start .btn { min-width: 160px; }
.ai-note { display: flex; gap: 6px; align-items: flex-start; text-align: left; background: var(--bg); padding: 10px 12px; border-radius: 12px; }
.ai-bubble .md { display: grid; gap: 6px; min-width: 0; flex: 1 1 auto; }
.md p { margin: 0; }
.md .md-h { font-weight: 700; }
.md ul { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.md code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg-2); padding: 1px 5px; border-radius: 6px; }
.md pre { margin: 0; padding: 10px; border-radius: 10px; background: var(--bg-2); overflow-x: auto; font-size: 13px; white-space: pre; }
.ai-photo { display: block; max-width: 100%; border-radius: 14px; margin-bottom: 4px; }
.ai-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }
.ai-ideas { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 2px; }
.ai-typing { display: inline-flex; gap: 5px; padding: 12px 14px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-dot 1.2s ease-in-out infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-typing i { animation: none; opacity: .6; } }
.ai-main { flex: 1; min-width: 0; display: grid; }
.ai-top { display: flex; align-items: baseline; gap: 8px; }
.ai-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-time { font-size: 12px; color: var(--muted); flex: none; }
.ai-preview { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

/* ---------- «О приложении» ---------- */
.about-hero { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0 2px; }
.about-logo { width: 72px; height: 72px; border-radius: 22px; box-shadow: 0 8px 24px rgba(15, 107, 90, .28); }
.about-hero h2 { font-size: 24px; letter-spacing: -0.02em; }
.how { display: grid; gap: 10px; }
.how-step { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--bg-2); }
.how-ic { width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); }
.how-text { display: grid; gap: 2px; min-width: 0; }
.feat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.feat { display: grid; gap: 2px; padding: 12px; border-radius: 16px; background: var(--bg-2); min-width: 0; }
.feat-ic { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-2); color: var(--accent); margin-bottom: 4px; }
.feat-ic .ic[class] { width: 17px; height: 17px; }

/* ---------- группы ---------- */
.quick-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quick-row.three .quick { flex-direction: column; gap: 4px; min-height: 64px; font-size: 13px; text-align: center; }
.grow {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; text-align: left; margin-bottom: 4px;
  background: color-mix(in srgb, var(--bg) 62%, transparent); transition: background-color 120ms;
}
.grow:active { background: var(--bg-2); }
.grow.active { background: var(--accent-2); }
.grow .ai-top .badge { margin-left: auto; }
.av.g-av { border-radius: 16px; overflow: visible; }
.g-badge { position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); color: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.g-badge .ic.sm { width: 13px; height: 13px; vertical-align: 0; }
.av.sm.g-av .g-badge { width: 16px; height: 16px; }
.g-from { display: block; width: 100%; flex-basis: 100%; font-size: 13px; font-weight: 700; color: hsl(var(--hue) 55% 42%); margin-bottom: 1px; }
.bubble.media .g-from { flex-basis: auto; padding: 4px 8px 3px; }
:root[data-mode="dark"] .g-from { color: hsl(var(--hue) 60% 68%); }
.g-pick { cursor: pointer; }
.g-check { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* ---------- фото профиля на весь экран: листать, смахнуть вниз — закрыть ---------- */
.pv { --pv-dim: 1; position: fixed; inset: 0; z-index: 65; color: #fff; overflow: hidden; overscroll-behavior: contain;
  animation: pv-in 220ms var(--ease-out); }
.pv::before { content: ''; position: absolute; inset: 0; background: #000; opacity: var(--pv-dim); }
@keyframes pv-in { from { opacity: 0; } }
.pv.closing { opacity: 0; transition: opacity 180ms var(--ease-out); }
.pv.gone-down { opacity: 0; transition: opacity 200ms var(--ease-out); }
.pv.gone-down .pv-stage { transform: translate3d(0, 40%, 0) scale(.9) !important; transition: transform 220ms var(--ease-out) !important; }
.pv-stage { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
/* Слайды стоят рядом по номеру (left = номер × ширина), но в странице живут только показанный и соседние: архив на сотни файлов иначе держал сотни узлов, слоёв и крутящихся индикаторов — на iPhone страницу выгружало из памяти (23.10.2026) */
.pv-track { position: relative; width: 100%; height: 100%; will-change: transform; }
.pv-slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: grid; place-items: center; }
.pv-slide img { width: min(100vw, 100dvh); aspect-ratio: 1; object-fit: cover; -webkit-touch-callout: none; pointer-events: none;
  opacity: 1; transition: opacity 200ms var(--ease-out); }
.pv-slide.loading img { opacity: 0; }
.pv-slide.loading::after { content: ''; position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff; animation: spin 800ms linear infinite; }
.pv-slide.broken::after { content: 'Фото не открылось'; position: absolute; color: rgba(255,255,255,.7); font-size: 15px; }
.pv-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(8px + var(--safe-t)) 10px 26px;
  background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); transition: opacity 180ms var(--ease-out); }
.pv-bars { display: flex; gap: 4px; padding: 0 4px 8px; }
.pv-bars:empty { display: none; }
.pv-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); transition: background-color 200ms var(--ease-out); }
.pv-bars i.on { background: #fff; }
.pv-head { display: flex; align-items: center; gap: 6px; }
.pv-close { color: #fff; flex-shrink: 0; }
.pv-title { display: grid; min-width: 0; line-height: 1.25; }
.pv-title b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-count { font-size: 13px; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }
.pv-actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 26px 12px calc(14px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.55)); transition: opacity 180ms var(--ease-out); }
.pv-act { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 22px; color: #fff; font-size: 15px;
  background: rgba(255,255,255,.16); -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 120ms var(--ease-out), background-color 120ms; }
.pv-act:active { transform: scale(.96); background: rgba(255,255,255,.26); }
.pv-act.danger { color: #ff8a8a; }
.pv-act .ic { width: 18px; height: 18px; }
.pv.bare .pv-top, .pv.bare .pv-actions { opacity: 0; pointer-events: none; }
.pv ~ .sheet-wrap { z-index: 66; }                 /* шторка, открытая из просмотра (обрезка, «Удалить?»), — поверх него */
.av-open { border-radius: 50%; flex-shrink: 0; transition: transform 140ms var(--ease-out); }
.av-open:active { transform: scale(.96); }
.av-count { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .pv, .pv.closing, .pv.gone-down, .pv.gone-down .pv-stage { animation-duration: 1ms; transition-duration: 1ms !important; }
}
@media (prefers-reduced-transparency: reduce) { .pv-act { background: rgba(60,60,60,.95); backdrop-filter: none; -webkit-backdrop-filter: none; } }

/* ---------- истории: полоса кружков над чатами и просмотр на весь экран ---------- */
.st-strip { display: flex; gap: 12px; padding: 6px 8px 8px; margin-bottom: 2px; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.st-strip::-webkit-scrollbar { display: none; }
.st-item { position: relative; flex: 0 0 74px; display: grid; justify-items: center; gap: 5px; min-width: 0; border-radius: 14px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform 140ms var(--ease-out); }
.st-item:active { transform: scale(.95); }
.st-ring { padding: 4px; border-radius: 50%; background: conic-gradient(from 210deg, var(--accent), #34c7a5, #f5b942, #f2716a, var(--accent)); }
.st-ring.seen { background: var(--line); }
.st-ring.none { background: transparent; }
.st-ring { position: relative; }
/* отправка истории: кружок пульсирует цветом темы, дуга — сколько уже ушло (web/js/features/stories) */
.st-ring.sending { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.st-ring.sending::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2.5px solid var(--accent); opacity: 0; pointer-events: none;
  animation: st-pulse 1.5s var(--ease-out) infinite; }
@keyframes st-pulse { 0% { transform: scale(.92); opacity: .8; } 100% { transform: scale(1.17); opacity: 0; } }
.st-prog { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.st-prog circle { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 188.5; transition: stroke-dashoffset 220ms linear; }
.st-ring.fail { background: color-mix(in srgb, var(--danger) 85%, transparent); }
@media (prefers-reduced-motion: reduce) {
  .st-ring.sending::after { animation: st-breathe 1.8s ease-in-out infinite alternate; transform: none; inset: -1px; }
  @keyframes st-breathe { from { opacity: .15; } to { opacity: .8; } }
  .st-prog circle { transition: none; }
}
.st-ring .av { width: 56px; height: 56px; font-size: 20px; box-shadow: 0 0 0 2px var(--bg); flex-shrink: 0; }
/* свежая чужая история: кольцо пульсирует несколько секунд (web/js/features/stories: fresh) — только transform и opacity */
.st-ring.fresh::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2.5px solid var(--accent); opacity: 0; pointer-events: none;
  animation: st-pulse 1.5s var(--ease-out) 4; }
/* кольцо историй вокруг аватарки в списке чатов и в шапке чата — как у Telegram; цвета те же, что у полосы над чатами */
.av-wrap.sring::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 210deg, var(--accent), #34c7a5, #f5b942, #f2716a, var(--accent)); }
.av-wrap.sring.seen::before { background: var(--line); }
.av-wrap.sring > .av { box-shadow: 0 0 0 2px var(--bg); }
.av-wrap.sring.fresh::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 2.5px solid var(--accent); opacity: 0; pointer-events: none;
  animation: st-pulse 1.5s var(--ease-out) 4; }
@media (prefers-reduced-motion: reduce) { .st-ring.fresh::after, .av-wrap.sring.fresh::after { animation: none; } }
.st-plus { position: absolute; top: 44px; left: 49px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: 0 0 0 2.5px var(--bg); }
.st-plus .ic { width: 14px; height: 14px; }
.st-name { max-width: 74px; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-name.ok { color: var(--accent); font-weight: 600; }

.sv { position: fixed; inset: 0; z-index: 66; background: #000; color: #fff; overflow: hidden; overscroll-behavior: contain;
  animation: sv-in 220ms var(--ease-out); }
@keyframes sv-in { from { opacity: 0; transform: scale(.97); } }
.sv.closing { opacity: 0; transform: scale(.97); transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.sv.gone-down { opacity: 0; transition: opacity 200ms var(--ease-out); }
.sv.gone-down .sv-stage { transform: translate3d(0, 40%, 0) scale(.9) !important; transition: transform 220ms var(--ease-out) !important; }
.sv-stage { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sv-media { position: absolute; inset: 0; display: grid; place-items: center; }
.sv-media img, .sv-media video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sv-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 800ms linear infinite; }
.sv-gone { color: rgba(255,255,255,.75); }
/* Заглушка, пока файл идёт (как у Telegram: размытый первый кадр): тот же кадр, что будет, только размытый и чуть крупнее — края размытия не видны */
.sv-poster { position: absolute; inset: 0; background-size: contain; background-position: center; background-repeat: no-repeat; filter: blur(14px) saturate(1.1); transform: scale(1.08); animation: sv-poster-in 160ms ease-out both; }
@keyframes sv-poster-in { from { opacity: 0; } }
.sv-wait { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; pointer-events: none; }
.sv-pct { min-height: 1em; font: 600 13px/1 system-ui, -apple-system, sans-serif; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
/* Видео ждёт данные посреди просмотра: кружок поверх кадра, полоска времени стоит */
.sv.buffering .sv-media::after { content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 800ms linear infinite; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .sv-poster { animation: none; } }
.sv-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(8px + var(--safe-t)) 10px 28px;
  background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,0)); transition: opacity 160ms var(--ease-out); }
.sv-bars { display: flex; gap: 3px; padding: 0 2px 10px; }
.sv-bars i { flex: 1; height: 2.5px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.sv-bars b { display: block; height: 100%; background: #fff; transform-origin: left center; transform: scaleX(0); }
.sv-who { display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 4px; }
.sv-who .av { flex-shrink: 0; }
.sv-name { display: grid; min-width: 0; line-height: 1.25; }
.sv-name b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-name span { font-size: 12px; color: rgba(255,255,255,.75); }
.sv-close { margin-left: auto; color: #fff; flex-shrink: 0; }
.sv-caption { position: absolute; left: 16px; right: 16px; bottom: calc(84px + var(--safe-b)); margin: 0 auto; width: fit-content; max-width: 100%;
  padding: 8px 14px; border-radius: 14px; background: rgba(0,0,0,.45); font-size: 16px; line-height: 1.35; white-space: pre-wrap;
  overflow-wrap: anywhere; text-align: center; transition: opacity 160ms var(--ease-out); }
.sv-foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px;
  padding: 24px 12px calc(14px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.5)); transition: opacity 160ms var(--ease-out); }
.sv-foot:empty { display: none; }
.sv-act { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; min-width: 44px; justify-content: center; padding: 0 14px;
  border-radius: 22px; color: #fff; font-size: 15px; background: rgba(255,255,255,.16);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 120ms var(--ease-out), background-color 120ms; }
.sv-act:active { transform: scale(.96); background: rgba(255,255,255,.26); }
.sv-act.danger { color: #ff8a8a; }
.sv-act .ic { width: 18px; height: 18px; }
.sv.holding .sv-top, .sv.holding .sv-caption, .sv.holding .sv-foot { opacity: 0; }
.sv ~ .sheet-wrap { z-index: 67; }
.sv-compose { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; gap: 10px;
  padding: 24px 12px calc(12px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6)); }
.sv-text { flex: 1; min-width: 0; resize: none; border: 0; border-radius: 20px; padding: 10px 14px; font: inherit; font-size: 16px; line-height: 1.3;
  color: #fff; background: rgba(255,255,255,.16); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.sv-text::placeholder { color: rgba(255,255,255,.6); }
.sv-compose { flex-wrap: wrap; }
.sv-err { flex: 0 0 100%; order: -1; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.35; color: #fff;
  background: rgba(168,34,34,.88); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.sv-err[hidden] { display: none; }
.sv-compose .btn { flex-shrink: 0; min-height: 44px; }
/* камера историй: видео снимается внутри приложения (web/js/features/stories/camera.js) */
.svc-view { width: 100%; height: 100%; object-fit: cover; background: #000; pointer-events: none; }      /* кадр во весь экран, как у Telegram: вертикально */
.sv-media .svc-view { object-fit: cover; }      /* перебивает общее «contain» для .sv-media video: камера — во весь экран, вертикально */
.svc-view.mirror { transform: scaleX(-1); }
.svc-time { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.svc.recording .svc-time::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #ff453a; }
.svc-foot { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 28px 20px calc(18px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.55)); }
.svc-foot > :first-child { justify-self: start; }
.svc-foot > :last-child { justify-self: end; }
.svc-side { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.18);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); transition: transform 120ms var(--ease-out), opacity 160ms; }
.svc-side:active { transform: scale(.94); }
.svc-side:disabled { opacity: .35; }
.svc-rec { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; padding: 0; background: transparent; display: grid; place-items: center;
  transition: transform 120ms var(--ease-out), opacity 160ms; }
.svc-rec:active { transform: scale(.95); }
.svc-rec:disabled { opacity: .45; }
.svc-rec i { width: 56px; height: 56px; border-radius: 50%; background: #ff453a; transition: transform 160ms var(--ease-out), border-radius 160ms var(--ease-out); }
.svc-rec.on i { transform: scale(.55); border-radius: 30%; }
.svc-msg { position: absolute; left: 16px; right: 16px; bottom: calc(132px + var(--safe-b)); margin: 0 auto; max-width: 420px; display: grid; gap: 10px; justify-items: start;
  padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; color: #fff; background: rgba(0,0,0,.62);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.svc-msg p { margin: 0; }
.svc-msg .btn { background: #fff; color: #111; }
.svc-msg[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .svc-rec i, .svc-rec, .svc-side { transition: none; } }
.grow-1 { flex: 1; min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  .sv, .sv.closing, .sv.gone-down, .sv.gone-down .sv-stage, .st-item { animation-duration: 1ms; transition-duration: 1ms !important; }
}
@media (prefers-reduced-transparency: reduce) { .sv-act, .sv-text { background: rgba(60,60,60,.95); backdrop-filter: none; -webkit-backdrop-filter: none; } }
/* ---------- ИИ: диктовка голосом (запись — волна и таймер; микрофон ↔ «Спросить» в одном слоте) ---------- */
.ai-act { position: relative; width: 44px; height: 44px; flex: none; }
.ai-act > .round-btn {
  position: absolute; inset: 0;
  transition: transform 140ms var(--ease-out), opacity 140ms var(--ease-out), visibility 0s;
}
.ai-act[data-mode="mic"] > .ai-send, .ai-act[data-mode="send"] > .ai-mic {
  opacity: 0; transform: scale(0.85); pointer-events: none; visibility: hidden;
  transition: transform 140ms var(--ease-out), opacity 140ms var(--ease-out), visibility 0s 140ms;
}
.ai-composer .compose-row { transition: opacity 120ms var(--ease-out); }
.ai-composer[data-rec] .compose-row { opacity: 0; pointer-events: none; }
.ai-rec {
  position: absolute; inset: 6px 6px calc(6px + var(--safe-b)); display: flex; align-items: center; gap: 8px; background: var(--bg);
  opacity: 0; transform: translateY(6px); pointer-events: none; visibility: hidden;
  transition: opacity 120ms var(--ease-out), transform 160ms var(--ease-out), visibility 0s 160ms;
}
.ai-composer[data-rec] .ai-rec {
  opacity: 1; transform: none; pointer-events: auto; visibility: visible;
  transition: opacity 160ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s;
}
.ai-rec-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; padding-left: 4px; }
.ai-rec-main .rec-dot { flex: none; }
.ai-rec-main .rec-time { flex: none; min-width: 2.6ch; }
.ai-rec-main.warn .rec-time, .ai-rec-main.warn .ai-rec-left { color: var(--danger); }
.ai-rec-left { flex: none; white-space: nowrap; }
.ai-wave { flex: 1; min-width: 0; height: 32px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.ai-wave i {
  flex: none; width: 3px; height: 28px; border-radius: 2px; background: var(--accent);
  transform: scaleY(0.12); transform-origin: center; transition: transform 90ms linear;
}
.ai-rec-stop .ic { fill: currentColor; width: 18px; height: 18px; }
.ai-rec-cancel { color: var(--danger); }
.ai-transcribing { display: inline-flex; align-items: center; gap: 8px; opacity: 0.85; }
.ai-transcribing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ai-dot 1.2s ease-in-out infinite; }
.ai-transcribing i:nth-child(2) { animation-delay: .15s; } .ai-transcribing i:nth-child(3) { animation-delay: .3s; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-voice-mark .ic { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
@media (prefers-reduced-motion: reduce) {
  .ai-act > .round-btn, .ai-act[data-mode="mic"] > .ai-send, .ai-act[data-mode="send"] > .ai-mic { transform: none; transition: opacity 120ms linear; }
  .ai-rec, .ai-composer[data-rec] .ai-rec { transform: none; }
  .ai-wave i { transition: none; }
  .ai-transcribing i { animation: none; opacity: .6; }
}

/* ---------- «глазок»: скрыть все фото, видео и кругляшки (web/js/features/spoiler) ---------- */
/* Как «скрытое медиа» в Телеграме: размытый слой, одно нажатие открывает. Закрытое — размыто, сдвинуто и без обложки; открытое возвращается за 240 мс. */
.photo > :is(img, video), .circle-msg > video, .lib-tile > img { transition: filter 240ms var(--ease-out), transform 240ms var(--ease-out), opacity 200ms; }
html[data-hide-photos] :is(.photo, .circle-msg, .lib-tile):not(.revealed) { background-image: none !important; }
html[data-hide-photos] :is(.photo, .circle-msg, .lib-tile):not(.revealed) > :is(img, video) {
  filter: blur(var(--shield-blur, 36px)) saturate(.7) brightness(.88); transform: scale(1.2); pointer-events: none;
}
html[data-hide-photos] :is(.photo, .circle-msg, .lib-tile):not(.revealed)::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E") center / 28px 28px no-repeat,
    radial-gradient(closest-side, rgba(8, 12, 16, .5) 94%, transparent) center / 52px 52px no-repeat;
}
.lib-tile { --shield-blur: 18px; }
.eye-toggle[aria-pressed="true"] { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .photo > :is(img, video), .circle-msg > video, .lib-tile > img { transition: opacity 1ms; }
}

/* ---------- «Фото из переписок» в профиле ---------- */
.lib-holder { margin-top: 8px; }
.lib { display: grid; gap: 4px; }
.lib-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lib-head h3 { margin: 0 0 2px; font-size: 17px; }
.lib-head p { margin: 0; }
.lib-month { margin: 14px 2px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.lib-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; border-radius: 14px; overflow: hidden; }
.lib-tile { position: relative; display: block; aspect-ratio: 1; padding: 0; border: 0; background: var(--bg-2); overflow: hidden; touch-action: manipulation; }
.lib-tile > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 1; }
.lib-tile.loading > img { opacity: 0; }
.lib-tile:active { opacity: .85; }
.lib-status:empty, .lib-sentinel { min-height: 1px; }
.lib-sentinel { height: 1px; }

/* ---------- карточка человека: ник, телефон, «о себе» ---------- */
.card-rows { display: grid; background: var(--bg-2); border-radius: 16px; padding: 2px 14px; margin: 4px 0; }
.card-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-row:first-child { border-top: 0; }
.card-main { flex: 1; min-width: 0; }
.card-label { font-size: 12px; color: var(--muted); }
.card-value { font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.card-value a { color: var(--accent); text-decoration: none; }
.card-about { white-space: pre-wrap; }
.card-form h3 { margin: 6px 0 0; font-size: 17px; }
.card-form textarea.input { resize: none; min-height: 76px; line-height: 1.4; font: inherit; font-size: 16px; }

/* ---------- «Медиа и файлы»: вкладки, видео, файлы, голосовые ---------- */
.lib-tabs { margin: 12px 0 2px; }
.lib-pane[hidden] { display: none; }
.lib-tile.video > img { opacity: 1; }
.lib-tile.no-thumb { background: #1b1f24; }
.lib-play { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(8, 12, 16, .5); color: #fff; display: grid; place-items: center; pointer-events: none; }
.lib-play .ic { width: 16px; height: 16px; fill: currentColor; stroke: none; margin-left: 2px; }
.lib-dur { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 8px; background: rgba(8, 12, 16, .55); color: #fff; font-size: 11px; font-weight: 600; pointer-events: none; }
html[data-hide-photos] .lib-tile:not(.revealed) .lib-play { display: none; }
.lib-rows { display: grid; gap: 8px; }
.lib-row { display: grid; gap: 6px; padding: 10px 12px; background: var(--bg-2); border-radius: 14px; min-width: 0; }
.lib-row .file-name { max-width: 100%; }
.lib-row .voice { width: 100%; }
.lib-meta { overflow-wrap: anywhere; }
.viewer video { max-width: 100%; max-height: 100dvh; }
.viewer.loading::after { content: ""; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .8s linear infinite; }

/* ---------- «Архив»: общий альбом двоих у них в профиле (плитки — те же lib-*, «глазок» на них действует) ---------- */
.arch-block { margin: 18px 0 4px; }
.arch-block h3 { margin: 0 0 6px; font-size: 17px; }
.arch-hint { margin: 0 0 10px; }
.arch-row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; margin: 0 0 8px; padding: 10px 12px; border-radius: 14px; background: var(--bg-2); color: inherit; text-align: left;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 140ms var(--ease-out); }
.arch-row:active { transform: scale(.98); }
.arch-av { flex: none; display: grid; }
.arch-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.arch-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-sub { font-size: 13px; color: var(--muted); }
.arch-row > .ic { color: var(--muted); }

.arch { position: fixed; inset: 0; z-index: 48; display: flex; flex-direction: column; height: 100dvh; background: var(--bg);
  transition: transform 220ms var(--ease-drawer), opacity 180ms var(--ease-out); }
@starting-style { .arch { opacity: 0; transform: translate3d(0, 20px, 0); } }
.arch.closing { opacity: 0; transform: translate3d(0, 20px, 0); transition-duration: 160ms, 140ms; }
@media (prefers-reduced-motion: reduce) { .arch, .arch.closing { transform: none; transition: opacity 1ms; } }
.arch-head { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 8px) 10px 8px; border-bottom: 1px solid var(--line); }
.arch-title { flex: 1; min-width: 0; display: grid; }
.arch-title > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-add { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 38px; padding: 0 14px; white-space: nowrap; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.arch-add:disabled { opacity: .5; }
.arch-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 8px calc(var(--safe-b) + 28px); }
.arch-status:empty { display: none; }
.arch-empty { display: grid; justify-items: center; gap: 4px; padding: 56px 24px; text-align: center; color: var(--muted); }
.arch-empty .ic { width: 38px; height: 38px; margin-bottom: 8px; }
.arch-empty p { margin: 0; }
.arch-tile { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.arch-tile.broken::after { content: "Не загрузилось"; position: absolute; inset: 0; display: grid; place-items: center; padding: 4px; color: var(--muted); font-size: 11px; text-align: center; }
.arch-tile[data-gone]::after { content: "Файл убран"; }
.pv-slide.fit img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: contain; }
.pv-slide video { width: 100%; height: 100%; object-fit: contain; background: #000; -webkit-touch-callout: none; }
.pv-video.broken::after { content: 'Видео не открылось'; }
/* свои кнопки видео (gallery.js: videoControls): большая «Играть» по центру — стекло; снизу кнопка, время и перемотка */
.pv-vplay { position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%; color: #fff; display: grid; place-items: center; touch-action: manipulation;
  background: rgba(28, 28, 30, .55); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8);
  box-shadow: inset 0 .5px 0 rgba(255, 255, 255, .28), 0 6px 24px rgba(0, 0, 0, .35);
  transition: transform 140ms var(--ease-out), opacity 160ms var(--ease-out); }
.pv-vplay .ic, .pv-vbtn .ic { fill: currentColor; stroke: none; }
.pv-vplay .ic { width: 32px; height: 32px; margin-left: 4px; }
.pv-vplay:active { transform: scale(.94); }
.pv-slide.playing .pv-vplay { opacity: 0; pointer-events: none; }
.pv-slide.loading .pv-vplay, .pv-slide.broken .pv-vplay, .pv-slide.vfail .pv-vplay { display: none; }
.pv-vbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 22px 12px calc(8px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0)); touch-action: manipulation; }
.pv-slide.loading .pv-vbar, .pv-slide.broken .pv-vbar { display: none; }
.pv-vbtn { flex: none; width: 44px; height: 44px; border-radius: 50%; color: #fff; display: grid; place-items: center; touch-action: manipulation; transition: transform 140ms var(--ease-out), background-color 140ms; }
.pv-vbtn .ic { width: 22px; height: 22px; }
.pv-vbtn:active { transform: scale(.94); background: rgba(255, 255, 255, .18); }
.pv-vtime { flex: none; min-width: 34px; font-size: 13px; color: rgba(255, 255, 255, .85); font-variant-numeric: tabular-nums; text-align: center; }
.pv-vrange { --p: 0%; flex: 1 1 auto; min-width: 0; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; touch-action: pan-x; cursor: pointer; }
.pv-vrange::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, #fff var(--p), rgba(255, 255, 255, .32) var(--p)); }
.pv-vrange::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.pv-vrange::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, #fff var(--p), rgba(255, 255, 255, .32) var(--p)); }
.pv-vrange::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; }
.pv-vnote { position: absolute; left: 16px; right: 16px; bottom: calc(68px + var(--safe-b)); padding: 10px 14px; border-radius: 14px; text-align: center; font-size: 14px; color: #fff;
  background: rgba(28, 28, 30, .72); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.pv-vnote:empty { display: none; }
@media (prefers-reduced-transparency: reduce) { .pv-vplay, .pv-vnote { background: rgba(40, 40, 42, .96); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-reduced-motion: reduce) { .pv-vplay, .pv-vbtn { transition: opacity 1ms; } }

/* предпросмотр архива в карточке контакта; страница архива над карточкой-шторкой (z 50), а шторки из неё — над страницей */
.arch { z-index: 51; }
.arch ~ .sheet-wrap { z-index: 52; }

/* вкладка «Архив»: подписанная плашка вместо выставленных напоказ фото */
.arch-tab { margin-top: 10px; }
.arch-lock { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-2); color: var(--accent); }
.arch-entry { margin-bottom: 8px; }

/* «Моя история»: кружок (смотреть) и отдельный «+» (снимать сразу); зона нажатия «+» шире значка */
.st-cell { position: relative; flex: 0 0 74px; display: grid; min-width: 0; }
.st-cell > .st-item { width: 100%; }
button.st-plus { padding: 0; border: 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 140ms var(--ease-out); }
button.st-plus::after { content: ''; position: absolute; inset: -11px; }
button.st-plus:active { transform: scale(.9); }

/* камера историй: горизонтальный кадр переведён в вертикальный холст — исходное видео остаётся живым, но невидимым; «↻» — повернуть, если картинка легла набок */
.svc-src { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.svc-rotate { flex: none; min-width: 44px; min-height: 44px; border-radius: 50%; color: #fff; font-size: 22px; line-height: 1; background: rgba(255,255,255,.18);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 120ms var(--ease-out); }
.svc-rotate:active { transform: scale(.94); }
.svc-rotate[hidden] { display: none; }

/* зум камеры историй: 0,5× / 1× / 2×, как у iPhone; нет зума у камеры — панели нет; сообщение поднимается над ней */
.svc-zoom { position: absolute; left: 50%; bottom: calc(132px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.38); z-index: 2; }
.svc-zoom[hidden] { display: none; }
.svc-z { min-width: 46px; height: 38px; padding: 0 8px; border-radius: 19px; color: #fff; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background-color 140ms, color 140ms, transform 120ms var(--ease-out); }
.svc-z:active { transform: scale(.94); }
.svc-z[aria-pressed="true"] { background: rgba(255,255,255,.92); color: #111; }
.svc.has-zoom .svc-msg { bottom: calc(184px + var(--safe-b)); }
@media (prefers-reduced-motion: reduce) { .svc-z { transition: none; } }

/* «Камера iPhone» в камере историй: запасной ход — системная камера (плавно, вертикаль, стабилизация; качество среднее) */
.svc-sys { flex: none; margin-left: auto; min-height: 44px; padding: 0 14px; border-radius: 22px; color: #fff; font-size: 14px; font-weight: 600; background: rgba(255,255,255,.18);
  white-space: nowrap; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform 120ms var(--ease-out); }
.svc-sys:active { transform: scale(.95); }
.svc-sys[hidden] { display: none; }
.svc-sys:not([hidden]) + .sv-close { margin-left: 0; }          /* «Камера iPhone» уже прижата вправо — крестик сразу за ней */

/* Меню сообщения «как в Telegram iOS» (скрин Ивана 24.10): размытый экран, сообщение поднято, над ним реакции, под ним карточка действий (features/chat/ctxmenu.js).
   Материалы — «стекло» (apple-design §12): полупрозрачный фон, размытие с насыщением, светлая кромка сверху (свет на краю), мягкая тень: чем больше поверхность, тем глубже тень. */
.ctx-wrap { position: fixed; inset: 0; z-index: 70; -webkit-tap-highlight-color: transparent; }
.ctx-bg { position: fixed; inset: 0; opacity: 0; transition: opacity 200ms var(--ease-out);
  background: color-mix(in srgb, var(--bg) 14%, transparent); -webkit-backdrop-filter: blur(26px) saturate(1.5); backdrop-filter: blur(26px) saturate(1.5); }
.ctx-wrap.ready .ctx-bg { opacity: 1; }
.ctx-wrap.closing .ctx-bg { opacity: 0; transition-duration: 120ms; }
.ctx-wrap.closing { pointer-events: none; }
.ctx-wrap.scroll { overflow-y: auto; overscroll-behavior: contain; padding: calc(var(--safe-t) + 12px) 12px calc(var(--safe-b) + 12px); }
.ctx-flow { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ctx-flow.mine { align-items: flex-end; }
.ctx-lift { position: fixed; margin: 0; display: block; pointer-events: none; z-index: 1; will-change: transform; scale: 1; transition: scale 340ms var(--ease-drawer); filter: drop-shadow(0 10px 26px rgba(20, 30, 40, .22)); }
.ctx-wrap.ready .ctx-lift { scale: 1.025; }                 /* «подъём» сообщения — как в Telegram */
.ctx-wrap.closing .ctx-lift { scale: 1; transition-duration: 120ms; }
.ctx-lift .msg-col { max-width: none; width: 100%; }
.ctx-lift .bubble, .ctx-lift .bare { max-width: 100%; }
.ctx-glass { position: absolute; z-index: 2; opacity: 0; transform: scale(.86); transition: transform 340ms var(--ease-drawer), opacity 180ms var(--ease-out);
  background: color-mix(in srgb, var(--bg) 66%, transparent); -webkit-backdrop-filter: blur(34px) saturate(1.9); backdrop-filter: blur(34px) saturate(1.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 0 0 .5px rgba(255, 255, 255, .5), 0 22px 56px rgba(20, 30, 40, .24), 0 3px 10px rgba(20, 30, 40, .10); }
.ctx-pill { display: flex; gap: 0; padding: 6px 8px; border-radius: 32px; transform-origin: bottom left; }
.ctx-pill.mine { transform-origin: bottom right; }
.ctx-pill::before, .ctx-pill::after { content: ''; position: absolute; border-radius: 50%; background: color-mix(in srgb, var(--bg) 66%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 2px 8px rgba(20, 30, 40, .12); }
.ctx-pill::before { width: 15px; height: 15px; left: 14px; bottom: -10px; }
.ctx-pill::after { width: 8px; height: 8px; left: 7px; bottom: -18px; }
.ctx-pill.mine::before { left: auto; right: 14px; } .ctx-pill.mine::after { left: auto; right: 7px; }
.ctx-react { width: 46px; height: 46px; border-radius: 50%; font-size: 29px; line-height: 1; display: grid; place-items: center; touch-action: manipulation; transition: transform 160ms var(--ease-out), background-color 160ms; }
.ctx-react:active { transform: scale(0.84); }
.ctx-react.on { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.ctx-menu { width: min(276px, calc(100vw - 24px)); padding: 6px 0; border-radius: 30px; transform-origin: top left; transition-delay: 40ms, 40ms; }
.ctx-menu.mine { transform-origin: top right; }
.ctx-wrap.ready .ctx-glass { opacity: 1; transform: none; }
.ctx-wrap.closing .ctx-glass { opacity: 0; transform: scale(.94); transition-duration: 120ms; transition-delay: 0s; }
.ctx-flow .ctx-glass { position: relative; }
.ctx-info { display: flex; align-items: center; gap: 14px; height: 48px; padding: 0 22px; font-size: 16px; font-weight: 500; letter-spacing: -.01em; color: var(--text); }
.ctx-info .ic { width: 20px; height: 20px; color: var(--accent); }
.ctx-item { display: flex; align-items: center; gap: 16px; width: 100%; height: 52px; padding: 0 22px; font-size: 17px; letter-spacing: -.022em; text-align: left; color: var(--text); touch-action: manipulation; transition: background-color 100ms; }
.ctx-item .ic { width: 24px; height: 24px; stroke-width: 1.5; }
.ctx-item:active { background: color-mix(in srgb, var(--text) 10%, transparent); transition-duration: 0s; }
.ctx-item.danger { color: var(--danger); }
.ctx-sep { height: 1px; margin: 5px 22px; background: color-mix(in srgb, var(--text) 13%, transparent); }
.ctx-wrap:not(.live) .ctx-item, .ctx-wrap:not(.live) .ctx-react { pointer-events: none; }
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) { .ctx-glass { background: var(--bg); } .ctx-bg { background: color-mix(in srgb, var(--bg) 60%, transparent); } }
@media (prefers-reduced-transparency: reduce) { .ctx-glass { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; } .ctx-bg { background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-reduced-motion: reduce) { .ctx-bg, .ctx-glass { transition: opacity 120ms linear; transform: none !important; } .ctx-lift { transition: none; scale: 1 !important; } }
:root[data-mode="dark"] .ctx-glass { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 0 0 .5px rgba(255, 255, 255, .1), 0 22px 56px rgba(0, 0, 0, .5); }
/* долгое нажатие на сообщении — наше меню, а не выделение текста и подсказки iOS */
@media (pointer: coarse) { .msg .bubble, .msg .bare { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } .msg .bubble .v-text, .msg .bubble .v-text * { -webkit-user-select: text; user-select: text; } }
