:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --panel: #fbfaf7;
  --surface: #ffffff;
  --line: #e2ded5;
  --text: #1d2420;
  --muted: #6c746f;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe8;
  --out: #1f6f5c;
  --out-ink: #f2fbf7;
  --in: #ffffff;
  --danger: #b4372f;
  --danger-soft: #fbe9e6;
  --ok: #2a8a5b;
  --warn: #c48a1b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 6px 24px rgba(20, 30, 25, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
/* Тёмная тема: выбрана в настройках или «как в системе» при тёмной системе (атрибут ставит theme.js) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --panel: #161b19;
  --surface: #1c2220;
  --line: #2a322f;
  --text: #e6ece9;
  --muted: #8d9894;
  --accent: #3fae8c;
  --accent-ink: #08130f;
  --accent-soft: #1b3a31;
  --out: #2a7d66;
  --out-ink: #eefbf6;
  --in: #212926;
  --danger: #e0685e;
  --danger-soft: #3a1f1c;
  --ok: #4cc28a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
}

/* Стиль «sdsds» — как на sdsds.top, qr.sdsds.top и share.sdsds.top: тёплая бумага и графит,
   оранжевый акцент, тонкие рамки (атрибут data-palette ставит theme.js) */
:root[data-palette="sdsds"] {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --surface: #ffffff;
  --line: #e2ddd2;
  --text: #16161a;
  --muted: #6b675f;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --accent-soft: #fde5da;
  --out: #ff5a1f;
  --out-ink: #ffffff;
  --in: #fffdf8;
  --danger: #c8321e;
  --danger-soft: #fbe4df;
  --ok: #1f8a4c;
  --warn: #b4540a;
  --shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 12px 32px -12px rgba(40, 30, 10, .18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
:root[data-palette="sdsds"][data-theme="dark"] {
  --bg: #16161a;
  --panel: #1e1e23;
  --surface: #141418;
  --line: #2e2e35;
  --text: #f1efe9;
  --muted: #9a978f;
  --accent: #ff5a1f;
  --accent-ink: #ffffff;
  --accent-soft: #3a2117;
  --out: #ff5a1f;
  --out-ink: #ffffff;
  --in: #1e1e23;
  --danger: #ff6b55;
  --danger-soft: #3a1d18;
  --ok: #4fc483;
  --warn: #f0a050;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* Интерфейс не масштабируется: без двойного касания и без подстройки шрифта браузером */
html, body, button, a, input, textarea, label, .msg, .contacts li { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* iPhone увеличивает страницу при фокусе на поле со шрифтом меньше 16px — на телефонах 16px */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px !important; }
}
/* iPhone в альбомной ориентации: не залезать под «чёлку» */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.ios-install {
  display: block; margin-top: 12px; padding: 10px 12px; border-radius: 12px; text-align: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none;
}
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0 0 .25em; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; }
.fine { margin-top: 14px; }
.error { color: var(--danger); font-size: 13.5px; min-height: 1em; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover:not(:disabled) { filter: brightness(1.07); }
.ghost { border: 1px solid var(--line); background: var(--surface); }
.ghost:hover { border-color: var(--muted); }
.danger-btn { background: var(--danger); color: #fff; font-weight: 600; }
.icon-btn { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 20px; border-radius: 10px; }
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn.accent { background: var(--accent); color: var(--accent-ink); }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
}

.screen { height: 100%; }
.center { display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
}
.auth-card label { display: block; font-weight: 600; margin: 18px 0 6px; }
.auth-card .primary.wide { margin-top: 14px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand p { margin: 0; font-size: 13.5px; }

/* ---------- Приложение ---------- */
#app { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px; }
.me { display: flex; gap: 10px; align-items: center; min-width: 0; background: none; border: 0; padding: 4px 8px 4px 4px; margin: -4px; border-radius: 12px; text-align: left; color: inherit; cursor: pointer; }
.me:hover { background: var(--accent-soft); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.me-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-caret { color: var(--muted); font-size: 11px; }
.accounts-badge {
  position: absolute; top: -4px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--panel);
}
.account-list li { cursor: pointer; }
.account-list li.active { border-color: var(--accent); cursor: default; }
.account-list li:not(.active):hover { border-color: var(--accent); }
.account-list .badge { margin-left: auto; }
.account-list .a-state { font-size: 12px; color: var(--accent); font-weight: 600; margin-left: auto; white-space: nowrap; }
#auth-extra { margin: 0 0 10px; }
#auth-cancel { margin-top: 12px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--ok); }
.dot.connecting { background: var(--warn); }
.dot.offline, .dot.replaced { background: var(--danger); }

.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  color: #fff;
  text-transform: uppercase;
}
/* Фото профиля (подписка Премиум) */
.avatar.photo { background-size: cover; background-position: center; background-repeat: no-repeat; }
.premium-star { color: #f5b942; margin-left: .25em; font-size: .9em; flex: none; }
.prof-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 16px; }
.prof-photo-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.prem-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin: 6px 0 16px; }
.prem-hero b { font-size: 18px; }
.prem-star { font-size: 40px; line-height: 1; }
.prem-plan .set-value { color: var(--accent); font-weight: 600; }
.prem-curs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 2px 10px; }
.prem-cur { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: inherit; font-weight: 600; font-size: 13px; }
.prem-cur.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.prem-for { margin-top: 14px; }
.prem-gift { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; }
.prem-gift[hidden] { display: none; }
.prem-gift p { margin: 0; }
.msg.sys.gift .bubble { background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13.5px; border-radius: 14px; padding: 7px 14px; }
.prem-real { color: inherit; }
.prem-link { display: inline-block; text-decoration: none; padding: 8px 16px; border-radius: 10px; }

.add-form { display: flex; gap: 8px; padding: 0 14px; }
.add-form input { padding: 8px 12px; flex: 1 1 auto; min-width: 0; width: auto; }
.add-form > button { flex: none; }
#add-form { gap: 4px; }
#add-form .icon-btn { width: 36px; }
#add-error { padding: 2px 16px 0; margin: 0; }

.contacts { list-style: none; margin: 4px 0 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.contacts li button {
  width: 100%;
  display: flex; gap: 10px; align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: 12px;
}
.contacts li button:hover { background: var(--accent-soft); }
.contacts li button.active { background: var(--accent-soft); }
.c-body { flex: 1; min-width: 0; }
.c-top { display: flex; align-items: center; gap: 6px; }
.c-name { font-weight: 600; }
/* Официальная галочка */
.official { width: 1.05em; height: 1.05em; min-width: 1.05em; aspect-ratio: 1; flex: none; display: inline-block; vertical-align: -.17em; margin-left: .25em; }
.official-bg { fill: #3d95e6; }
.official-check { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.me-name, .peer-name, .c-name { display: inline-flex; align-items: center; min-width: 0; }
.c-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.shield { font-size: 12px; color: var(--ok); }
.shield.warn { color: var(--danger); }
.empty-side { padding: 8px 18px; font-size: 13.5px; }

#chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-empty { margin: auto; text-align: center; max-width: 340px; padding: 16px; }
.lock-big { font-size: 42px; }

.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.chat-head .back { display: none; }
.peer { flex: 1; min-width: 0; }
.peer-name { font-weight: 650; }
.peer-verify { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#safety-btn .ico { display: none; }
.peer-verify.ok { color: var(--ok); }
.peer-verify.bad { color: var(--danger); }
.chat-head .ghost { padding: 7px 12px; font-size: 13.5px; }

.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; font-size: 13.5px; }
.banner.danger { background: var(--danger-soft); border-bottom: 1px solid var(--danger); }
.banner-actions { display: flex; gap: 8px; }
.banner-actions button { padding: 7px 12px; font-size: 13px; }

.messages {
  list-style: none;
  margin: 0;
  padding: 16px clamp(12px, 4vw, 40px);
  overflow-y: auto;
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.msg { max-width: min(560px, 80%); display: flex; flex-direction: column; }
.msg .bubble {
  max-width: 100%; min-width: 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.msg .meta { font-size: 11px; color: var(--muted); margin: 2px 6px 6px; display: flex; gap: 6px; }
.msg.in { align-self: flex-start; }
.msg.in .bubble { background: var(--in); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble { background: var(--out); color: var(--out-ink); border-bottom-right-radius: 4px; }
.msg.out.failed .bubble { background: var(--danger); }
.msg.sys { align-self: center; max-width: 90%; }
.msg.sys .bubble { background: transparent; color: var(--muted); font-size: 12.5px; text-align: center; box-shadow: none; padding: 4px 8px; }
.msg.sys.bad .bubble { color: var(--danger); }
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.e2e-note { align-self: center; font-size: 12px; color: var(--muted); background: var(--accent-soft); padding: 6px 12px; border-radius: 10px; margin-bottom: 8px; text-align: center; }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.composer textarea { resize: none; max-height: 160px; line-height: 1.4; }
.send { width: 44px; height: 42px; padding: 0; font-size: 17px; flex: none; }

/* ---------- Диалоги ---------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  width: min(460px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(10, 15, 12, .45); }
.dialog-body { padding: 22px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.safety-code {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px;
  font: 600 19px/1.3 var(--mono);
  letter-spacing: .04em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  text-align: center;
}
.fp {
  display: block; font: 12.5px/1.5 var(--mono);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; word-break: break-all;
}
.inline-code { font: 12.5px var(--mono); word-break: break-all; }
h3 { font-size: 15px; margin: 18px 0 4px; }
.wide { width: 100%; padding: 12px; margin-top: 10px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 18px 0 4px; }
.tab { flex: 1; padding: 8px 10px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.tab.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.link-box { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 14px; }
.qr { background: #fff; padding: 6px; border-radius: 12px; border: 1px solid var(--line); line-height: 0; }
.qr svg { width: 220px; height: 220px; display: block; }
.link-code { display: grid; grid-template-columns: repeat(4, auto); gap: 2px 14px; font: 600 15px/1.6 var(--mono); letter-spacing: .04em; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; user-select: all; }
.device-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.device-list li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.device-list .d-body { flex: 1; min-width: 0; }
.device-list .d-name { font-weight: 600; }
.device-list .d-meta { font-size: 12.5px; color: var(--muted); }
.device-list .d-ico { font-size: 20px; }
.device-list .d-ip { font-family: var(--mono); font-size: 12px; }
.device-list .d-ver { font-variant-numeric: tabular-nums; }
.device-list button { padding: 6px 10px; font-size: 13px; }
.add-form.flush { padding: 0; margin-top: 8px; }
.add-form.flush .primary { padding: 8px 14px; }

#scan-btn { margin-top: 8px; }

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

/* ---------- Мобильная раскладка ---------- */
@media (max-width: 720px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #app.in-chat #sidebar { display: none; }
  #app:not(.in-chat) #chat { display: none; }
  .chat-head .back { display: grid; }
  .chat-head { padding: 8px 10px; gap: 8px; }
  #safety-btn { padding: 6px 10px; }
  #safety-btn .lbl { display: none; }
  #safety-btn .ico { display: inline; }
  .safety-code { font-size: 16px; grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Звонки ---------- */
.call-btn svg { width: 20px; height: 20px; fill: var(--accent); }
.call-btn:disabled svg { fill: var(--muted); }

.call-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: #0d1210; color: #eef5f2;
  display: flex; flex-direction: column;
}
.call-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.remote-main { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.remote-main.cover { object-fit: cover; }
.remote-main.cover.mismatch { object-fit: contain; }
.pip.contain { object-fit: contain; background: #000; }
.pip {
  width: clamp(120px, 22vw, 260px); aspect-ratio: 16 / 10; max-height: 38vh;
  object-fit: cover; border-radius: 14px; background: #1a221f;
  box-shadow: 0 6px 24px rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.12);
}
/* Вертикальное видео (камера телефона) — уже, чтобы не занимало пол-экрана */
.pip.portrait { width: clamp(84px, 12vw, 150px); }
.remote-pip { position: absolute; left: 16px; bottom: 16px; cursor: pointer; z-index: 2; }
.local-previews {
  position: absolute; right: 16px; bottom: 16px; z-index: 2;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.local-pip { transform: scaleX(-1); }
/* Свой экран — целиком, без обрезки и без зеркала */
.local-screen { object-fit: contain; background: #000; outline: 2px solid #c0392b; outline-offset: -2px; }
.call-corner {
  position: absolute; top: 10px; z-index: 3; width: 42px; height: 42px; padding: 9px;
  border-radius: 50%; background: rgba(0,0,0,.45); backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.call-corner svg { width: 24px; height: 24px; fill: #eef5f2; }
.call-corner:hover { background: rgba(0,0,0,.65); }
.call-corner.left { left: 12px; }
.call-corner.right { right: 12px; }
.call-overlay:fullscreen .call-controls { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.call-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px;
  background: radial-gradient(circle at 50% 35%, #1d3a31 0%, #0d1210 70%);
}
.call-avatar { width: 112px; height: 112px; font-size: 44px; }
.call-name { font-size: 26px; font-weight: 650; }
.call-status { color: #a9bdb5; font-size: 15px; min-height: 1.2em; }
.call-e2e { margin-top: 6px; font-size: 12.5px; color: #8fcfb6; background: rgba(63,174,140,.12); padding: 5px 12px; border-radius: 20px; }
.call-topbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); padding: 6px 14px; border-radius: 20px; font-size: 14px;
  backdrop-filter: blur(6px); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.call-e2e-mini { margin-left: 4px; }
.sharing-badge { background: #c0392b; color: #fff; font-size: 13px; padding: 5px 12px; border-radius: 20px; }
.call-controls {
  display: flex; justify-content: center; gap: clamp(10px, 3vw, 22px);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: #0d1210;
}
.call-ctl {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: #dfeae6; font-size: 12px; padding: 0; background: none;
}
.call-ctl svg {
  width: 56px; height: 56px; padding: 15px; border-radius: 50%;
  background: #24302c; fill: #eef5f2; box-sizing: border-box; transition: background .15s;
}
.call-ctl:hover svg { background: #2f3e39; }
.call-ctl.off svg { background: #eef5f2; fill: #0d1210; }
.call-ctl.on svg { background: var(--accent); }
.call-ctl.danger svg { background: #d64541; }
.call-ctl.danger:hover svg { background: #e2534f; }
.call-ctl.ok svg { background: #2a9d6a; }
.call-ctl.ok:hover svg { background: #31b179; }
#call-decline svg, #call-hangup svg { transform: rotate(0deg); }
/* Выбор микрофона и динамика */
.dev-select { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; }
.mic-meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: -2px 0 12px; }
.mic-meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.call-dev-menu {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 5;
  width: min(360px, calc(100% - 32px)); max-height: calc(100% - 140px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  background: #1a2421; color: #eef5f2; padding: 14px; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.call-dev-menu label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #b9c9c3; }
.call-dev-menu .dev-select { background: #24302c; border-color: #34443f; color: #eef5f2; }
#call-devices.on svg { background: var(--accent); }
.px-addr { display: flex; gap: 10px; }
.px-addr .set-field { flex: 1; min-width: 0; }
.px-addr .px-port { flex: 0 0 96px; }
#px-status.ok { color: var(--ok); }
#px-status.bad { color: var(--danger); }
.pick-list { list-style: none; margin: 4px 0 10px; padding: 0; max-height: 40vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick-list li { border-bottom: 1px solid var(--line); }
.pick-list li:last-child { border-bottom: 0; }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.pick-list .p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-list .p-user { color: var(--muted); font-size: 12px; }
#ng-name { width: 100%; margin-bottom: 4px; }
.gd-members { list-style: none; padding: 0; }
.gd-members li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.gd-members li:last-child { border-bottom: 0; }
.gd-members .m-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gd-members .m-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-members .m-sub { color: var(--muted); font-size: 12px; }
.gd-members .m-acts { display: flex; gap: 4px; }
.gd-members .m-acts button { padding: 4px 8px; font-size: 12px; }
.msg .from { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 2px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.msg.sys.group .bubble { font-size: 13px; }
.g-ico { margin-right: 4px; font-size: .9em; }
.vol-range { width: 100%; accent-color: var(--accent); margin: 2px 0; }
.vol-val { float: right; font-weight: 600; font-variant-numeric: tabular-nums; color: inherit; }
.call-dev-menu .vol-val { color: #eef5f2; }
.vol-field { margin-bottom: 4px; }

.msg.sys.call .bubble { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.msg.sys.call.missed .bubble { color: var(--danger); }

.screen-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; max-height: 60vh; overflow: auto; }
.screen-sources button { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.screen-sources button:hover { border-color: var(--accent); }
.screen-sources img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 6px; }
.screen-sources span { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 720px) {
  .call-ctl svg { width: 52px; height: 52px; padding: 14px; }
  .call-ctl span { display: none; }
  #call-incoming .call-ctl span { display: block; }
  .pip { width: 110px; }
  .pip.portrait { width: 76px; }
  .local-previews { right: 10px; bottom: 10px; }
  .remote-pip { left: 10px; bottom: 10px; }
}

/* Свёрнутый звонок */
.call-mini {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: 44px;
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 0;
  background: var(--out); color: var(--out-ink); box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.call-mini-open {
  flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 8px;
  padding: 0 14px; background: none; color: inherit; font-size: 14px; text-align: left;
}
.call-mini-open b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-mini-status { font-variant-numeric: tabular-nums; opacity: .9; white-space: nowrap; }
.call-mini-hint { opacity: .7; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-mini-dot { width: 8px; height: 8px; border-radius: 50%; background: #7ff0c2; flex: none; animation: call-pulse 1.6s ease-in-out infinite; }
@keyframes call-pulse { 50% { opacity: .35; } }
.call-mini-btn { width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.call-mini-btn svg { width: 20px; height: 20px; fill: #fff; }
.call-mini-btn.off { background: #eef5f2; }
.call-mini-btn.off svg { fill: #0d1210; }
.call-mini-btn.danger { background: #d64541; }
body.call-min #app { height: calc(100% - 44px); margin-top: 44px; }
.call-float {
  position: fixed; z-index: 45; right: 16px; bottom: 96px; width: clamp(150px, 24vw, 300px);
  aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; background: #000; cursor: grab;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12); touch-action: none;
}
.call-float.portrait { width: clamp(96px, 14vw, 170px); }
.call-float video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.call-float.dragging { cursor: grabbing; }
@media (max-width: 720px) {
  .call-mini-hint { display: none; }
  .call-float { width: 132px; bottom: 84px; }
  .call-float.portrait { width: 92px; }
}

/* ---------- Статус, ответы, меню сообщения ---------- */
.peer-sub { display: flex; gap: 6px; align-items: baseline; min-width: 0; font-size: 12.5px; color: var(--muted); }
.peer-sub .peer-verify { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-presence { white-space: nowrap; }
.peer-presence.online { color: var(--ok); font-weight: 600; }
.peer-presence:not(:empty)::after { content: '·'; margin-left: 6px; color: var(--muted); font-weight: 400; }
.avatar-wrap { position: relative; flex: none; }
.online-dot { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }

.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 14px 0 4px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; accent-color: var(--accent); }

.msg { position: relative; }
.msg .bubble { cursor: default; }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 1px 1px rgba(0,0,0,.04); } }
.quote {
  display: block; border-left: 3px solid var(--accent); background: rgba(31,111,92,.08);
  border-radius: 6px; padding: 3px 8px; margin: 0 0 5px; cursor: pointer; text-align: left;
  max-width: 100%; font-size: 13px; line-height: 1.35; color: inherit; width: 100%;
  min-width: 0;
}
.quote b { display: block; color: var(--accent); font-size: 12.5px; }
.quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.msg.out .quote { border-left-color: rgba(255,255,255,.8); background: rgba(255,255,255,.14); }
.msg.out .quote b { color: inherit; }
.msg-actions { position: absolute; top: 2px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.msg.in .msg-actions { left: calc(100% + 4px); }
.msg.out .msg-actions { right: calc(100% + 4px); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-actions button { width: 28px; height: 28px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 15px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.msg-actions button:hover { color: var(--accent); }

.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.rb-icon { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.rb-body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; }
.rb-name { color: var(--accent); font-weight: 600; font-size: 13px; }
.rb-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar + .composer { border-top: 0; }

.msg-menu {
  position: fixed; z-index: 40; min-width: 170px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.msg-menu button { text-align: left; padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.msg-menu button:hover, .msg-menu button:focus-visible { background: var(--accent-soft); }
.msg-menu .danger { color: var(--danger); }

@media (hover: none) { .msg-actions { display: none; } }

/* Уведомления */
.notif-offer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft, rgba(31, 111, 92, .1)); font-size: 13.5px; }
.notif-offer-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.notif-offer-actions .primary { padding: 6px 12px; font-size: 13px; }

/* Обновления приложения */
.upd-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 8px; }
.upd-actions button { padding: 7px 14px; font-size: 14px; }
.ghost-link { font-size: 14px; color: var(--accent); }
.upd-banner { background: var(--accent-soft); }

/* ---------- Вложения ---------- */
.composer .attach { flex: none; height: 42px; width: 40px; color: var(--muted); }
.composer .attach svg { width: 22px; height: 22px; fill: currentColor; }
.composer .attach:hover:not(:disabled) { color: var(--accent); }
.composer .attach:disabled { opacity: .4; }
#chat-view { position: relative; }
.drop-hint {
  position: absolute; inset: 8px; z-index: 5; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--accent); font-weight: 600; font-size: 17px; pointer-events: none;
}

.msg .bubble.has-media { padding: 4px; white-space: normal; }
.msg .bubble.has-media .quote { margin: 4px 4px 6px; }
.bubble .caption { padding: 6px 8px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.media {
  position: relative; display: block; padding: 0; overflow: hidden; border-radius: 11px;
  width: 260px; max-width: 100%; aspect-ratio: 4 / 3; background: var(--line); cursor: pointer;
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media .thumb { filter: blur(8px); transform: scale(1.08); }
.media.loaded .thumb { display: none; }
.media .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 22px; padding-left: 4px;
}
.media .media-meta {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 8px;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 12px;
}
.media.broken::after { content: '⚠'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; color: var(--muted); }
.file-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; min-width: 200px; max-width: 320px;
  text-align: left; border-radius: 11px; position: relative; color: inherit;
}
button.file-card:hover { background: rgba(127, 127, 127, .12); }
.file-icon {
  width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: var(--accent-soft);
}
.msg.out .file-icon { background: rgba(255, 255, 255, .18); }
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12.5px; opacity: .75; }

/* Ход скачивания: кольцо поверх превью или значка */
.ring { display: none; }
.loading > .ring, .viewer-wait .ring {
  display: block; width: 44px; height: 44px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), rgba(127, 127, 127, .25) 0);
  -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px); mask: radial-gradient(circle, transparent 15px, #000 16px);
}
.media.loading > .ring { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.media.loading .play { display: none; }
.file-card.loading > .ring { position: absolute; left: 7px; top: 50%; transform: translateY(-50%); }
.file-card.loading .file-icon { visibility: hidden; }

/* Загрузка своего файла */
.msg.uploading .media { cursor: default; }
.msg.uploading .media img { opacity: .6; }
.up-bar { height: 4px; margin: 6px 6px 2px; border-radius: 2px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.up-fill { display: block; height: 100%; width: 0; background: currentColor; transition: width .2s; }
.up-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px 0 6px; font-size: 12px; }
.up-cancel { width: 26px; height: 26px; padding: 0; border-radius: 50%; color: inherit; font-size: 13px; }
.up-cancel:hover { background: rgba(255, 255, 255, .2); }

/* Окно отправки */
.attach-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; }
.attach-item { display: flex; align-items: center; gap: 10px; }
.attach-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex: none; }
#attach-caption { width: 100%; resize: vertical; }

/* Просмотр */
dialog.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  border: 0; border-radius: 0; background: #0c0f0e; color: #fff; display: none; flex-direction: column;
}
dialog.viewer[open] { display: flex; }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.viewer-name { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body audio { width: min(480px, 100%); }
.viewer-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: .85; }
.viewer-error { max-width: 420px; text-align: center; opacity: .85; }

/* Блокировка */
.blocked-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 14px;
}
.blocked-bar .ghost { padding: 7px 14px; font-size: 14px; color: var(--accent); font-weight: 600; }
#chat-menu-btn { font-size: 22px; }
.blocked-list { list-style: none; padding: 0; }
.blocked-item { display: flex; align-items: center; gap: 10px; }
.blocked-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.blocked-item .ghost { padding: 6px 12px; font-size: 13.5px; }

/* ---------- Настройки (как в Telegram: главный экран и разделы) ---------- */
dialog.settings { width: min(440px, calc(100% - 32px)); height: min(680px, calc(100dvh - 32px)); max-height: none; overflow: hidden; background: var(--bg); }
dialog.settings[open] { display: flex; }
.settings-form { display: flex; flex-direction: column; width: 100%; height: 100%; overflow-y: auto; }
.set-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.set-head h2 { flex: 1; margin: 0; font-size: 17px; }
.set-head #set-back { margin-left: -8px; }
.set-page { padding: 14px 14px 22px; }
.set-profile { display: flex; align-items: center; gap: 14px; padding: 6px 4px 16px; }
.avatar.big { width: 64px; height: 64px; font-size: 26px; }
.set-name { font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.set-group {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  margin: 0 0 14px; padding: 0; list-style: none;
}
.set-group.set-pad { padding: 4px 14px; }
.set-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 14px;
  background: none; border: 0; border-radius: 0; text-align: left; color: var(--text); font: inherit; font-size: 15px;
  text-decoration: none; cursor: pointer;
}
.set-row + .set-row, .set-group > li + li { border-top: 1px solid var(--line); }
.set-row:hover { background: var(--accent-soft); }
.set-row.danger { color: var(--danger); }
.set-ico { width: 28px; flex: none; text-align: center; font-size: 19px; }
.set-label { flex: 1; min-width: 0; }
.set-value { color: var(--muted); font-size: 14px; white-space: nowrap; }
.set-chev { color: var(--muted); font-size: 20px; line-height: 1; }
.set-check { color: var(--accent); font-weight: 700; }
.set-toggle input { width: auto; flex: none; margin: 0; }
/* Переключатель вместо галочки */
.set-toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 12px;
  background: var(--line); position: relative; cursor: pointer; transition: background .15s; border: 0; padding: 0;
}
.set-toggle input[type="checkbox"]::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s;
}
.set-toggle input[type="checkbox"]:checked { background: var(--accent); }
.set-toggle input[type="checkbox"]:checked::after { transform: translateX(18px); }
.set-toggle input[type="checkbox"]:disabled { opacity: .45; cursor: default; }
.set-note { color: var(--muted); font-size: 12.5px; margin: -8px 6px 14px; }
.set-sub { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 6px 6px 6px; }
.set-group .fp { display: block; margin: 8px 0; }
.set-group .upd-actions { margin: 4px 0 10px; }
.set-group .blocked-item { padding: 8px 14px; }
@media (max-width: 600px) {
  dialog.settings { width: 100vw; height: 100dvh; max-width: none; margin: 0; border: 0; border-radius: 0; }
  .set-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .set-page { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}

/* Сканер QR-кода */
dialog.scanner {
  width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden;
  background: #0c0f0e; color: #fff; border: 0;
}
dialog.scanner[open] { display: flex; flex-direction: column; }
.scanner-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 16px; }
.scanner-bar .icon-btn { color: #fff; }
.scanner-bar .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.scanner-view { position: relative; aspect-ratio: 4 / 3; background: #000; overflow: hidden; flex: none; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-view video.mirror { transform: scaleX(-1); }
.scanner-frame {
  position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); border: 3px solid rgba(255, 255, 255, .9);
}
.scanner-status { position: absolute; left: 12px; right: 12px; bottom: 10px; margin: 0; text-align: center; font-size: 13.5px; text-shadow: 0 1px 3px #000; }
.scanner-status:empty { display: none; }
.scanner-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 12px; }
.scanner-actions .ghost { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); }
@media (max-width: 600px) {
  dialog.scanner { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; }
  .scanner-bar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .scanner-view { flex: 1; aspect-ratio: auto; }
  .scanner-actions { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* Свой профиль в настройках */
.set-profile { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 10px 16px; margin: 0; background: none; border: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; border-radius: 14px; }
.set-profile:hover { background: var(--accent-soft); }
.set-profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.set-username { color: var(--accent); font-size: 14px; }
.set-field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.set-field input, .set-field textarea { font: inherit; font-size: 15px; color: var(--text); resize: vertical; }
.set-count { float: right; font-style: normal; }
.set-static { cursor: default; }
.set-static:hover { background: none; }
#prof-save { margin: 0 0 14px; }

/* Профиль собеседника */
#peer-open, #peer-avatar { cursor: pointer; }
.avatar.huge { width: 96px; height: 96px; font-size: 38px; }
.pf-top { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 16px; text-align: center; }
.pf-name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.pf-status { color: var(--muted); font-size: 14px; }
.pf-status.online { color: var(--accent); }
.pf-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.pf-actions button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); color: var(--accent); font-size: 13px; font-weight: 600;
}
.pf-actions button span { font-size: 20px; }
.pf-actions button:hover:not(:disabled) { background: var(--accent-soft); }
.pf-actions button:disabled { opacity: .45; }
.pf-info { align-items: center; }
.pf-info-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pf-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.pf-tabs { display: flex; gap: 4px; margin: 0 0 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.pf-tab { flex: 1; padding: 7px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.pf-tab.active { background: var(--accent-soft); color: var(--accent); }
.pf-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-bottom: 14px; border-radius: 12px; overflow: hidden; }
.pf-media:empty { display: none; }
.pf-thumb { position: relative; aspect-ratio: 1; padding: 0; border-radius: 0; background: var(--line); overflow: hidden; }
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-thumb img.blur { filter: blur(3px); transform: scale(1.1); }
.pf-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.pf-files .set-row { gap: 10px; }
.avatar.clickable { cursor: pointer; }
.pick-list input[type=checkbox] { width: auto; flex: none; margin: 0; }

/* ---------- Голосовые и видеосообщения ---------- */
.composer .rec-btn { flex: none; height: 42px; width: 40px; color: var(--muted); }
.composer .rec-btn:disabled { opacity: .4; }
.composer .rec-btn svg { width: 23px; height: 23px; fill: currentColor; }
.composer .rec-btn:hover:not(:disabled) { color: var(--accent); }
/* Запись: удержание кнопки, вверх — закрепить, влево — отменить */
.composer { position: relative; }
.composer .rec-btn { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rec-info, .rec-send, .rec-lock { display: none; }
.composer.recording > #attach-btn, .composer.recording > textarea, .composer.recording > #send-btn,
.composer.recording > .rec-btn:not(.active), .composer.recording.locked > .rec-btn.active { display: none !important; }
.composer.recording > .rec-btn.active { display: grid !important; background: var(--danger); color: #fff; border-radius: 50%; transform: scale(1.25); }
.composer.recording > .rec-btn.active, .composer.recording > .rec-send { order: 2; }
.composer.recording .rec-info { display: flex; flex: 1; min-width: 0; align-items: center; gap: 10px; height: 42px; }
.composer.recording.locked .rec-send { display: block; }
.composer.recording:not(.locked) .rec-lock { display: flex; }
#rec-cancel { display: none; }
.composer.recording.locked #rec-cancel { display: grid; }
.rec-hint { flex: 1; text-align: center; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer.locked .rec-hint { display: none; }
.composer:not(.locked) .rec-wave, .composer.rec-note .rec-wave { display: none; }
.rec-lock {
  position: absolute; bottom: calc(100% + 14px); width: 40px; padding: 8px 0 6px; flex-direction: column; align-items: center; gap: 2px;
  border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 16px; pointer-events: none;
  transform: translateY(calc(var(--dy, 0) * -1px)); z-index: 7;
}
.rec-lock .ar { color: var(--muted); font-size: 18px; line-height: 1; animation: rec-up 1.2s ease-in-out infinite; }
@keyframes rec-up { 50% { transform: translateY(-4px); } }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: rec-blink 1s ease-in-out infinite; }
@keyframes rec-blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 42px; }
.rec-wave { flex: 1; min-width: 0; height: 36px; color: var(--accent); }
.composer.starting .rec-dot { animation: none; background: var(--muted); }
.note-preview {
  position: absolute; z-index: 6; left: 50%; bottom: 76px; transform: translateX(-50%);
  width: min(300px, 70vw); aspect-ratio: 1; border-radius: 22px; overflow: hidden;
  background: #000; box-shadow: var(--shadow);
}
.note-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-preview.mirror video { transform: scaleX(-1); }
.note-flip {
  position: absolute; right: 10px; bottom: 10px; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, .5); color: #fff;
}
.note-flip svg { width: 22px; height: 22px; fill: currentColor; }
.note-flip:disabled { opacity: .5; }
.note-progress { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.note-progress rect { fill: none; stroke: var(--danger); stroke-width: 3; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0)); }

.voice { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; min-width: 220px; max-width: 300px; }
.vplay {
  width: 42px; height: 42px; flex: none; border-radius: 50%; padding: 0 0 0 3px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 16px; position: relative;
}
.msg.out .vplay { background: var(--out-ink); color: var(--out); }
.voice.playing .vplay { padding-left: 0; }
.voice.loading .vplay { color: transparent; }
.voice.loading .vplay::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(currentColor calc(var(--p, 0) * 1%), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px); mask: radial-gradient(circle, transparent 15px, #000 16px);
}
.msg.in .voice.loading .vplay::after { background: conic-gradient(var(--accent-ink) calc(var(--p, 0) * 1%), rgba(255, 255, 255, .3) 0); }
.msg.out .voice.loading .vplay::after { background: conic-gradient(var(--out) calc(var(--p, 0) * 1%), rgba(0, 0, 0, .15) 0); }
.vbody { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.vwave { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; touch-action: pan-y; }
.vwave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: currentColor; opacity: .35; }
.vwave i.on { opacity: 1; }
.msg.in .vwave i.on { background: var(--accent); }
.vtime { font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }
/* Расшифровка голосового */
.vstt {
  flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: transparent; color: inherit; opacity: .7; cursor: pointer;
}
.vstt:hover, .vstt.on { opacity: 1; background: rgba(127, 127, 127, .16); }
.vstt .ic { width: 18px; height: 18px; }
.bubble .tr.stt { margin: 2px 6px 2px; max-width: 300px; }

.msg .bubble.has-note { background: transparent; border: none; box-shadow: none; padding: 0; }
.msg .bubble.has-note .quote { background: var(--panel); border-radius: 10px; }
.media.note { width: 240px; aspect-ratio: 1; border-radius: 20px; }
.media.note video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media.note .thumb { filter: none; transform: none; }
.media.note.playing .play, .media.note.playing .thumb { display: none; }
.media.note.playing.paused .play { display: grid; }
.media.note .note-seek { position: absolute; left: 0; right: 0; bottom: 0; height: 30px; display: none; touch-action: pan-y; cursor: pointer; }
.media.note.playing .note-seek { display: block; }
.media.note .note-seek::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255, 255, 255, .3); }
.media.note .note-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: calc(var(--pos, 0) * 1%); background: var(--accent); }
.media.note .note-bar::after { content: ''; position: absolute; right: -6px; bottom: -3.5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 0 3px rgba(0, 0, 0, .5); }

/* Фото профиля на весь экран */
.avatar.zoomable { cursor: zoom-in; }
.viewer-body .viewer-photo { width: min(92vw, calc(92vh - 60px), 640px); height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.coins-balance { font-size: 30px; font-variant-numeric: tabular-nums; }

/* ---------- Каналы ---------- */
#channel-new .prem-curs { margin: 4px 0 12px; }
.cn-create { display: flex; flex-direction: column; gap: 10px; }
.cn-create textarea { resize: vertical; min-height: 56px; }
.cn-handle { display: flex; align-items: center; gap: 6px; }
.cn-handle span { color: var(--muted); font-weight: 600; }
.cn-handle input { flex: 1; }
.cn-preview { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 8px; }
.cn-head { display: flex; align-items: center; gap: 12px; }
.cn-head-text { display: flex; flex-direction: column; min-width: 0; }
.cn-head-text b { font-size: 16px; overflow-wrap: anywhere; }
.cn-about { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cn-posts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cn-posts li { font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--accent-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cn-posts:empty { display: none; }
.ci-link { overflow-wrap: anywhere; font-size: 13.5px; }
.ci-edit { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; }
.ci-edit textarea { resize: vertical; }
.msg.post { max-width: min(560px, 85%); }

/* ---------- Скрепка: меню вложений (снизу, как в Telegram) ---------- */
dialog.sheet {
  margin: auto auto 0; width: min(560px, 100%); max-width: 100%; max-height: min(80vh, 640px);
  border-radius: 18px 18px 0 0; border-bottom: none; padding: 0;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); }
dialog.sheet[open] { animation: sheet-up .18s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .5; } }
.sheet-body { display: flex; flex-direction: column; height: min(80vh, 640px); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 6px; flex: none; }
.as-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.as-page[hidden] { display: none; }
.as-grid { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 3px; padding: 0 3px 3px; align-content: start; touch-action: pan-y; }
.as-grid[hidden] { display: none; }
/* Квадратные плитки одного размера: высота = ширина (padding-трюк — надёжнее aspect-ratio в
   WebView, где сетка внутри панели сжимала все снимки в один экран) */
.as-cell { position: relative; display: block; width: 100%; height: 0; min-height: 0; padding: 0 0 100%; border-radius: 4px; overflow: hidden; background: var(--line); flex: none; }
.as-cell > * { position: absolute; }
.as-cell img { inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .12s; }
.as-cell.selected img { transform: scale(.88); border-radius: 6px; }
.as-check {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0, 0, 0, .25); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 3px rgba(0, 0, 0, .4);
}
.as-cell.selected .as-check { background: var(--accent); border-color: #fff; }
.as-dur { position: absolute; left: 5px; bottom: 5px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11.5px; }
.as-action { background: var(--accent-soft); color: var(--accent); }
.as-action-ico { top: 30%; left: 0; right: 0; text-align: center; }
.as-action-label { top: 62%; left: 0; right: 0; text-align: center; }
.as-action-ico { font-size: 26px; }
.as-action-label { font-size: 12.5px; font-weight: 600; }
.as-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; }
.as-empty[hidden] { display: none; }
.as-empty-ico { font-size: 40px; }
.as-empty button { min-width: 220px; }
.as-send-bar { padding: 8px 12px; border-top: 1px solid var(--line); }
.as-send-bar[hidden] { display: none; }
.as-send-bar button { width: 100%; }
.as-tabs { display: flex; border-top: 1px solid var(--line); padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); flex: none; }
.as-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 12px; color: var(--muted); border-radius: 10px; }
.as-tab span { font-size: 22px; }
.as-tab.active { color: var(--accent); font-weight: 600; }

/* ---------- Пересылка и закреплённое ---------- */
.bubble .fwd { font-size: 12.5px; font-weight: 600; opacity: .8; margin-bottom: 2px; }
.msg.out .bubble .fwd { color: inherit; }
.msg.in .bubble .fwd { color: var(--accent); }
.bubble.has-media .fwd { padding: 4px 6px 2px; }
.pin-bar { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.pin-bar[hidden] { display: none; }
.pin-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 0; text-align: left; color: inherit; }
.pin-ico { font-size: 16px; }
.pin-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; border-left: 2px solid var(--accent); padding-left: 8px; }
.pin-text b { color: var(--accent); font-size: 12.5px; }
.pin-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
#fw-search { margin: 4px 0 10px; }
.fw-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 4px; text-align: left; color: inherit; border-radius: 10px; }
.fw-item:hover { background: var(--accent-soft); }
a.lnk { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; word-break: break-word; }
.msg.out .bubble a.lnk { color: inherit; }
.set-note.error { color: var(--danger); }
/* Архив чатов */
.contacts .archive-row .archive-av { background: var(--line); color: var(--muted); font-size: 20px; }
.contacts .archive-row .c-top { font-weight: 600; }
.badge.muted-badge { background: var(--muted); }
.contacts .archive-head .archive-row { padding: 8px 12px; gap: 10px; font-weight: 600; }
.archive-ico { font-size: 18px; color: var(--muted); }
/* Папки: вкладки под поиском, в одну строку с прокруткой */
.folder-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 12px 8px; scrollbar-width: none; flex: none; }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tabs[hidden] { display: none; }
.folder-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 16px; font-size: 13.5px; font-weight: 600; color: var(--muted); background: var(--line); white-space: nowrap; }
.folder-tab.on { background: var(--accent); color: var(--accent-ink); }
.folder-tab.on .badge { background: var(--accent-ink); color: var(--accent); }
.folder-tab .badge { font-size: 11px; padding: 0 6px; }
.folder-tab.add { padding: 6px 10px; }
.c-pin { margin-left: auto; font-size: 12px; opacity: .7; }
.danger-text { color: var(--danger); margin-right: auto; }
#fd-name { width: 100%; }
/* Иконки интерфейса (свои SVG из /icons.json, см. client/icons.js) */
.ic { display: inline-flex; flex: none; width: 1.2em; height: 1.2em; vertical-align: -0.22em; line-height: 1; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ic { margin-right: .45em; } /* иконка перед текстом */
/* Иконка без текста рядом — без отступа */
.icon-btn .ic, .set-ico .ic, .send .ic, .st .ic, .lock-big .ic, .vplay .ic, .file-icon.ic, .archive-av .ic, .as-action-ico.ic,
.set-chev .ic, .set-check .ic, .premium-star .ic, .pin-ico .ic, .rec-lock .ic, .msg-actions .ic, .up-cancel .ic, .ico .ic, .d-ico.ic,
.folder-tab.add .ic, button.rec-send .ic, .prem-star .ic, .shop-prem .ic, .shop-none.ic, .shop-coins .ic { margin-right: 0; }
.c-pin.ic { margin-right: 0; width: 1em; height: 1em; }
.set-ico .ic { width: 22px; height: 22px; }
.icon-btn .ic { width: 22px; height: 22px; }
.send .ic { width: 22px; height: 22px; }
.premium-star .ic { width: .95em; height: .95em; }
.premium-star .ic svg { fill: currentColor; }
.st .ic { width: 1.35em; height: 1.35em; vertical-align: -0.32em; }
.lock-big .ic { width: 56px; height: 56px; }
.lock-big .ic svg { stroke-width: 1.4; }
.vplay .ic { width: 18px; height: 18px; }
.file-icon.ic { width: 28px; height: 28px; }
.archive-av .ic { width: 24px; height: 24px; }
.as-action-ico.ic { width: 28px; height: 28px; margin: 0; }
.g-ico.ic { color: var(--muted); width: 1em; height: 1em; margin-right: .3em; }

/* ---------- Рамки и фоны профиля (магазин) ---------- */
/* Рамка — квадратная картинка поверх аватара: фото занимает её середину (около 76%). */
.avatar { position: relative; }
.avatar > .av-frame {
  position: absolute; left: -16%; top: -16%; width: 132%; height: 132%;
  object-fit: contain; pointer-events: none; user-select: none; max-width: none;
}
/* Обложка профиля: своё видео или фон из магазина за аватаром и именем */
.pf-top, .prof-photo { position: relative; isolation: isolate; }
.pf-cover {
  position: absolute; inset: 0; z-index: -1; overflow: hidden; border-radius: var(--radius);
  background: #000;
}
.pf-cover video, .pf-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .05), rgba(0, 0, 0, .45));
}
.pf-top.has-cover, .prof-photo.has-cover { padding: 26px 12px 16px; margin-bottom: 14px; min-height: 180px; justify-content: center; }
.pf-top.has-cover .pf-name, .pf-top.has-cover .pf-status { color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .55); }
.prof-photo.has-cover .ghost, .prof-photo.has-cover .ghost-link { background: rgba(0, 0, 0, .4); color: #fff; border-color: transparent; }

/* Магазин */
.shop-preview { margin-bottom: 10px; }
.shop-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 12px; }
.shop-coins { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; }
.shop-coins .ic { color: #d79b22; }
.shop-tabs { justify-content: center; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-bottom: 14px; }
.shop-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px 10px;
  border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: inherit; text-align: center; min-width: 0;
}
.shop-item:hover { background: var(--accent-soft); }
.shop-item.worn { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.shop-pv { position: relative; display: grid; place-items: center; width: 84px; height: 84px; }
.shop-pv .avatar.big { width: 58px; height: 58px; }
.shop-pv.bg { width: 100%; height: 96px; }
.shop-bg { display: block; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; background: var(--line); }
.shop-bg video, .shop-bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-none { width: 30px; height: 30px; color: var(--muted); }
.shop-prem { position: absolute; top: 7px; right: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #f5b942; color: #fff; }
.shop-prem .ic { width: 14px; height: 14px; vertical-align: 0; transform: translateY(.5px); } /* звезда в наборе чуть выше середины */
.shop-prem .ic svg { fill: currentColor; }
.shop-name { font-weight: 600; font-size: 13.5px; max-width: 100%; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; line-height: 1.25; }
.shop-state { font-size: 12px; color: var(--muted); }
.shop-item.worn .shop-state { color: var(--accent); font-weight: 600; }

/* Сумма в монетах: число и иконка монеты на одной линии */
.coin-amt { display: inline-flex; align-items: center; gap: .25em; white-space: nowrap; vertical-align: bottom; }
.coin-amt .ic.coin-ico { margin: 0; width: 1.05em; height: 1.05em; vertical-align: 0; color: #d79b22; }
.coin-amt .coin-ico svg { stroke-width: 2.2; }
.prem-cur .ic.coin-ico { margin-right: .3em; width: 1.1em; height: 1.1em; vertical-align: -0.2em; }

/* Оформление: образцы тем */
.theme-swatch { display: block; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); }
.theme-swatch.light { background: linear-gradient(135deg, #fbfaf7 50%, #1f6f5c 50%); }
.theme-swatch.dark { background: linear-gradient(135deg, #161b19 50%, #3fae8c 50%); }
.theme-swatch.system { background: linear-gradient(135deg, #fbfaf7 50%, #161b19 50%); }
.muted-row .set-label { color: var(--muted); }

/* Своё имя для собеседника: как он подписан сам */
.pf-realname { font-size: 13px; color: var(--muted); margin-top: -4px; }
.pf-top.has-cover .pf-realname { color: rgba(255, 255, 255, .85); text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.al-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 12px; }
#al-name { width: 100%; }

/* Оформление: выбор стиля (палитры) */
.palette-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.palette-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel); color: inherit; text-align: left; font-weight: 600; }
.palette-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.palette-prev { display: grid; grid-template-columns: 1fr 1fr; height: 54px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.palette-prev span { display: flex; align-items: flex-end; justify-content: flex-end; padding: 6px; }
.palette-prev i { width: 26px; height: 12px; border-radius: 6px; }
:root[data-palette="sdsds"] .theme-swatch.light { background: linear-gradient(135deg, #fffdf8 50%, #ff5a1f 50%); }
:root[data-palette="sdsds"] .theme-swatch.dark { background: linear-gradient(135deg, #1e1e23 50%, #ff5a1f 50%); }
:root[data-palette="sdsds"] .theme-swatch.system { background: linear-gradient(135deg, #fffdf8 50%, #1e1e23 50%); }

/* Запрет копирования: сообщения собеседника без выделения и сохранения */
.msg.protected .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.msg.protected img, .msg.protected video, #viewer.protected img, #viewer.protected video { -webkit-user-drag: none; -webkit-touch-callout: none; pointer-events: auto; }
#viewer.protected #viewer-body { -webkit-user-select: none; user-select: none; }
.set-sublabel { display: block; font-weight: 400; margin-top: 2px; }

/* «Печатает…» */
.peer-presence.typing, .c-preview.typing { color: var(--accent); font-style: italic; }
.set-value.prof-link { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; }

/* Перевод сообщения — под текстом */
.bubble .tr { margin-top: 6px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, currentColor 30%, transparent); }
.bubble .tr-head { display: flex; align-items: center; gap: 4px; font-size: 11.5px; opacity: .7; margin-bottom: 2px; }
.bubble .tr-head .ic { width: 1.05em; height: 1.05em; margin-right: 0; }
.bubble .tr-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .tr.loading .tr-head { opacity: .55; }

/* Озвучка сообщения: громкость и «стоп» над полем ввода */
.tts-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 12px 6px; padding: 6px 6px 6px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 14px;
}
.tts-bar[hidden] { display: none; }
.tts-bar > .ic { color: var(--accent); flex: none; }
.tts-bar .tts-title { flex: none; }
.tts-bar .vol-range { flex: 1; min-width: 60px; max-width: 260px; }
.tts-bar .vol-val { flex: none; min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.tts-bar .icon-btn { flex: none; margin-left: auto; }

/* Сервер: текущий адрес */
.srv-now { margin: 0 0 10px; overflow-wrap: anywhere; }

/* ===================================================================================
   Анимации интерактивного: отклик кнопок, появление окон, меню, сообщений и страниц.
   Длительности умножаются на --motion: 0 — без анимаций (Настройки → «Оформление» →
   «Анимации» или «Уменьшить движение» в системе). Нажатие — свойством scale, а не transform,
   чтобы не сбивать уже заданные сдвиги и повороты.
   =================================================================================== */
:root { --motion: 1; --ease: cubic-bezier(.2, .8, .2, 1); --ease-out: cubic-bezier(.16, 1, .3, 1); --t-fast: calc(.12s * var(--motion)); --t: calc(.2s * var(--motion)); --t-slow: calc(.28s * var(--motion)); }
:root[data-motion="off"] { --motion: 0; }
@media (prefers-reduced-motion: reduce) { :root { --motion: 0; } }

/* Кнопки, строки, ссылки, поля: плавная смена цвета, рамки и тени */
button, a, .set-row, .contacts li button, .msg-menu button, .tab, .palette-card, .shop-item, .file-card {
  transition: background-color var(--t), color var(--t), border-color var(--t), box-shadow var(--t), filter var(--t), opacity var(--t), scale var(--t-fast) var(--ease);
}
input, textarea, select { transition: border-color var(--t), box-shadow var(--t), background-color var(--t); }
.ic, svg { transition: color var(--t), fill var(--t); }

/* Нажатие: кнопка чуть «вдавливается» */
button:active:not(:disabled), a.set-row:active, .palette-card:active, .shop-item:active { scale: .96; }
.contacts li button:active, .set-row:active, .msg-menu button:active, .file-card:active { scale: .985; }
.icon-btn:active:not(:disabled), .send:active:not(:disabled), .vplay:active, .vstt:active { scale: .9; }
.composer .rec-btn:active, .composer .rec-btn.active { scale: 1; } /* запись держат пальцем — без отклика */
.icon-btn:hover:not(:disabled) .ic { scale: 1.06; }
.icon-btn .ic { transition: scale var(--t-fast) var(--ease); }

/* Переключатели и ползунки */
.set-toggle input[type="checkbox"] { transition: background-color var(--t); }
.set-toggle input[type="checkbox"]::after { transition: transform var(--t) var(--ease-out), width var(--t-fast); }
.set-toggle input[type="checkbox"]:active::after { width: 22px; }
.set-toggle input[type="checkbox"]:checked:active::after { transform: translateX(14px); }

/* Окна: появляются и исчезают плавно (исчезание — в браузерах с @starting-style) */
dialog {
  transition: opacity var(--t) var(--ease), translate var(--t) var(--ease-out), scale var(--t) var(--ease-out), overlay var(--t) allow-discrete, display var(--t) allow-discrete;
}
dialog:not([open]) { opacity: 0; translate: 0 10px; scale: .97; }
@starting-style { dialog[open] { opacity: 0; translate: 0 14px; scale: .96; } }
dialog::backdrop { transition: background-color var(--t), backdrop-filter var(--t), overlay var(--t) allow-discrete, display var(--t) allow-discrete; }
dialog:not([open])::backdrop { background-color: transparent; }
@starting-style { dialog[open]::backdrop { background-color: transparent; } }
dialog.viewer:not([open]) { translate: none; scale: 1; }
@starting-style { dialog.viewer[open] { translate: none; scale: 1.02; } }
dialog.sheet[open] { animation: sheet-up var(--t) var(--ease-out); }

/* Меню сообщения и прочие всплывающие панели */
@keyframes pop-in { from { opacity: 0; scale: .92; } }
@keyframes fade-up { from { opacity: 0; translate: 0 8px; } }
@keyframes fade-in { from { opacity: 0; } }
.msg-menu:not([hidden]) { animation: pop-in var(--t) var(--ease-out); transform-origin: top left; }
.msg-menu button:not([hidden]) { animation: fade-in var(--t) var(--ease); }
.tts-bar:not([hidden]), #notif-offer:not([hidden]), .blocked-bar:not([hidden]) { animation: fade-up var(--t) var(--ease-out); }

/* Всплывающее сообщение внизу: выезжает, уходит, на новый текст — лёгкий толчок */
@keyframes toast-in { from { opacity: 0; translate: 0 14px; scale: .96; } }
@keyframes toast-bump { 40% { scale: 1.04; } }
.toast:not([hidden]) { animation: toast-in var(--t) var(--ease-out); }
.toast.again { animation: toast-bump var(--t) var(--ease); }
.toast.leaving { opacity: 0; translate: 0 10px; transition: opacity var(--t), translate var(--t); }

/* Сообщения: новые въезжают снизу (свои — справа, чужие — слева) */
@keyframes msg-in { from { opacity: 0; translate: -10px 8px; scale: .97; } }
@keyframes msg-out { from { opacity: 0; translate: 10px 8px; scale: .97; } }
.msg.appear.in { animation: msg-in var(--t-slow) var(--ease-out); transform-origin: bottom left; }
.msg.appear.out { animation: msg-out var(--t-slow) var(--ease-out); transform-origin: bottom right; }
.msg-actions { transition: opacity var(--t-fast), translate var(--t-fast) var(--ease); }
.tr.loading .tr-head { animation: breathe calc(1.4s * var(--motion) + .001s) ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .3; } }

/* Открытый чат: переписка проявляется */
#chat-view.enter { animation: fade-in var(--t) var(--ease); }
#chat-view.enter .messages, #chat-view.enter #messages { animation: fade-up var(--t-slow) var(--ease-out); }

/* Телефон: чат въезжает справа, список чатов — при возврате слева */
@keyframes slide-from-right { from { opacity: .4; translate: 28% 0; } }
@keyframes slide-from-left { from { opacity: .4; translate: -18% 0; } }
@media (max-width: 720px) {
  #app.in-chat #chat { animation: slide-from-right var(--t-slow) var(--ease-out); }
  #app:not(.in-chat) #sidebar { animation: slide-from-left var(--t-slow) var(--ease-out); }
}

/* Настройки: разделы въезжают вглубь справа, назад — слева */
@keyframes page-fwd { from { opacity: 0; translate: 24px 0; } }
@keyframes page-back { from { opacity: 0; translate: -24px 0; } }
.set-page.enter-fwd { animation: page-fwd var(--t) var(--ease-out); }
.set-page.enter-back { animation: page-back var(--t) var(--ease-out); }

/* Вкладки, выбор, отметки */
.set-radio[aria-checked="true"] .set-check .ic, .palette-card.on { animation: pop-in var(--t) var(--ease-out); }

/* «Печатает…» — мягко пульсирует */
.peer-presence.typing, .c-preview.typing { animation: breathe calc(1.6s * var(--motion) + .001s) ease-in-out infinite; }

/* Кнопки поля ввода: отправить ↔ микрофон сменяются с «прыжком» */
@keyframes btn-swap { from { opacity: 0; scale: .6; } }
.composer .send:not([hidden]), .composer .rec-btn:not([hidden]) { animation: btn-swap var(--t) var(--ease-out); }

/* Звонок, просмотр фото, карточки магазина */
.call-overlay:not([hidden]) { animation: fade-in var(--t-slow) var(--ease); }
.shop-item:hover, .palette-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }
.avatar.with-frame, .avatar { transition: scale var(--t) var(--ease); }
.set-profile:hover .avatar { scale: 1.04; }

/* Полностью без движения: бесконечные «дыхания» тоже останавливаются */
:root[data-motion="off"] .peer-presence.typing, :root[data-motion="off"] .c-preview.typing, :root[data-motion="off"] .tr.loading .tr-head { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .peer-presence.typing, .c-preview.typing, .tr.loading .tr-head { animation: none; }
}

/* ---------- Групповой звонок ---------- */
.gcall-bar { background: var(--accent-soft); border-bottom: 1px solid var(--accent); padding: 8px 16px; }
.gcall-bar-text { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.gcall-bar-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcall-bar button { padding: 7px 14px; font-size: 13px; }
.call-grid {
  position: absolute; inset: 0; padding: 56px 12px 12px; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); grid-auto-rows: minmax(0, 1fr);
  background: #0d1210; align-content: stretch;
}
.call-grid[data-n="1"] { grid-template-columns: 1fr; }
.call-grid[data-n="2"] { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.gtile {
  position: relative; min-height: 120px; border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #1d3a31 0%, #111916 75%);
  border: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center;
}
.gtile.waiting { opacity: .7; }
.gtile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.gtile video.contain { object-fit: contain; }
.gtile-avatar { width: 72px; height: 72px; font-size: 30px; }
.gtile-name {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 14px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gtile-name .ic { width: 15px; height: 15px; color: #ff8a80; flex: none; }
.gtile-state { color: #a9bdb5; }

/* Значок идущего звонка в списке чатов и «кто говорит» */
.call-dot {
  position: absolute; right: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ok); color: #fff; border: 2px solid var(--panel);
}
.call-dot .ic { width: 11px; height: 11px; }
.call-dot.mine { animation: call-pulse 1.6s ease-in-out infinite; }
.call-avatar { transition: box-shadow .15s; }
.call-avatar.speaking { box-shadow: 0 0 0 4px #3fd39a, 0 0 24px 4px rgba(63, 211, 154, .45); }
.gtile { transition: box-shadow .15s, border-color .15s; }
.gtile.speaking { border-color: #3fd39a; box-shadow: inset 0 0 0 3px #3fd39a; }
.gtile-talk {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 5px; border-radius: 50%;
  background: #3fd39a; color: #0d1210;
}
.call-ctl.speaking svg { box-shadow: 0 0 0 3px #3fd39a; }
.call-mini-btn.speaking { box-shadow: 0 0 0 2px #3fd39a; }
.call-mini.speaking .call-mini-dot { background: #3fd39a; animation-duration: .5s; }

/* Фото группы и канала */
.chat-photo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-photo-row button { display: inline-flex; align-items: center; gap: 6px; }
.chat-photo-row .ic { width: 16px; height: 16px; }
.chat-photo p { margin: 8px 0 0; }

/* ---------- Сообщества: каналы ---------- */
.comm-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.comm-bar::-webkit-scrollbar { display: none; }
.comm-head { display: none; }
.comm-chans { display: flex; gap: 6px; align-items: center; }
.comm-chan {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; flex: none;
  background: none; color: var(--muted); font-size: 14px; white-space: nowrap; position: relative;
}
.comm-chan .ic { width: 16px; height: 16px; flex: none; }
.comm-chan:hover { background: var(--hover, rgba(127,127,127,.12)); color: inherit; }
.comm-chan.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.comm-chan.in { color: var(--ok); font-weight: 600; }
.comm-name { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.comm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.comm-count { font-size: 11.5px; background: var(--ok); color: #fff; border-radius: 9px; padding: 1px 6px; font-weight: 600; }
.comm-voice-users { display: none; }
.comm-invite { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; margin-left: auto; }
.comm-invite .ic { width: 15px; height: 15px; }
/* Широкий экран: каналы — колонкой слева, как в Discord */
@media (min-width: 900px) {
  #chat-view.community { padding-left: 232px; }
  #chat-view.community .chat-head { margin-left: -232px; }
  #chat-view.community .comm-bar {
    position: absolute; left: 0; top: var(--head-h, 61px); bottom: 0; width: 232px; z-index: 2;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 12px 8px; overflow-y: auto; overflow-x: hidden;
    border-bottom: 0; border-right: 1px solid var(--line);
  }
  #chat-view.community .comm-head { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 2px 10px 6px; }
  #chat-view.community .comm-chans { flex-direction: column; align-items: stretch; gap: 2px; }
  #chat-view.community .comm-chan { width: 100%; justify-content: flex-start; }
  #chat-view.community .comm-name { max-width: none; flex: 1; text-align: left; }
  #chat-view.community .comm-count { display: none; }
  #chat-view.community .comm-voice-users { display: flex; flex-direction: column; gap: 2px; padding: 0 0 6px 30px; }
  #chat-view.community .comm-invite { margin: 10px 0 0; justify-content: center; }
}
.comm-voice-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 2px 0; min-width: 0; }
.comm-voice-user .avatar { width: 22px; height: 22px; font-size: 11px; flex: none; }
.comm-voice-user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-ico { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.chan-ico .ic { width: 20px; height: 20px; }
.gd-invites { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gd-invite { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gd-invite code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.gd-invite button { padding: 5px 10px; font-size: 12.5px; }
#gd-chan-type { width: auto; }
/* Иконки без отступа справа: одни в кружке или рядом с текстом уже через gap */
.call-dot .ic, .chan-ico .ic, .gtile-talk.ic, .gtile-name .ic, .comm-chan .ic, .comm-invite .ic,
.chat-photo-row .ic, .gcall-bar-text .ic { margin-right: 0; }
