:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --hover: #ebeae6;
  --active: #dceafb;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #2a78d6;
  --accent-ink: #fff;
  --mine: #dceafb;
  --mine-ink: #0d366b;
  --theirs: #f0efec;
  --danger: #e34948;
  --ok: #2eaa4f;
  --chat-bg: #f7f7f5;
  --mark: #ffe58a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --hover: #262624;
    --active: #183a63;
    --border: #2f2f2c;
    --text: #fff;
    --text-2: #c3c2b7;
    --muted: #8e8d86;
    --accent: #3987e5;
    --mine: #184f95;
    --mine-ink: #eaf2fd;
    --theirs: #2a2a28;
    --chat-bg: #141413;
    --mark: rgba(255, 196, 0, .32);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
button { font: inherit; color: inherit; }
input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:disabled { opacity: .6; cursor: default; }

.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  display: inline-grid; place-items: center; flex: none; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* ---------- вход ---------- */
.login-wrap { height: 100%; display: grid; place-items: center; padding: 16px; overflow: auto; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: -6px 0 6px; }
.login-card label { display: grid; gap: 5px; color: var(--text-2); }
.login-server { margin-top: 10px; text-align: center; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.login-server b { color: var(--text); font-weight: 600; }
.logo img { width: 56px; height: 56px; }

/* ---------- раскладка ---------- */
.layout { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; height: 100%; }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 14px; position: relative; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600;
  margin: -4px 0 -4px -6px; padding: 4px 6px; border-radius: 10px; cursor: pointer; outline-offset: 2px; }
.me:hover { background: var(--hover); }
.me.active { background: var(--active); }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu {
  position: absolute; right: 10px; top: 52px; z-index: 10; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 4px; min-width: 210px;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.conn { margin: 0 12px 6px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.search-box { padding: 4px 12px 8px; }
.search-box input { background: var(--surface-2); border-color: transparent; padding: 8px 12px; }
.contacts { overflow-y: auto; flex: 1; }

.contact { display: flex; gap: 12px; align-items: center; padding: 9px 14px; cursor: pointer; }
.contact:hover { background: var(--hover); }
.contact.active { background: var(--active); }
.contact .body { flex: 1; min-width: 0; }
.contact .row { display: flex; align-items: baseline; gap: 8px; }
.contact .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .time { font-size: 12px; color: var(--muted); flex: none; }
.contact .preview { flex: 1; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.contact .preview:empty::before { content: '\00a0'; } /* пустое превью держит высоту строки */
.contact.inactive .name { color: var(--muted); }
.badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }

.avatar {
  position: relative; flex: none; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 600; user-select: none;
}
.avatar.dim { background: #9e9d98 !important; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.has-img img[src] + .ini { visibility: hidden; }
.avatar.dim img { filter: grayscale(1) opacity(.6); }
.avatar .online { position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }

/* ---------- чат ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); position: relative; }
.empty-chat { margin: auto; text-align: center; color: var(--muted); }
.empty-chat img { width: 72px; opacity: .5; }
.chat-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.chat-head .back { display: none; }
.peer-info { flex: 1; min-width: 0; }
.peer-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-status { font-size: 12px; color: var(--muted); }
.peer-status.online { color: var(--ok); }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 3px; }
/* фон-тема компании: переменные ставит applyTheme() в app.js; без темы — прежний вид */
.messages.themed {
  background-color: var(--chat-theme-bg);
  background-image: var(--chat-pattern, none);
  background-size: var(--chat-pattern-size, 256px);
  background-repeat: repeat;
}
/* темы светлые — плашки дат/системные строки всегда в светлом стиле, и в тёмном режиме тоже */
.messages.themed .day { background: rgba(255, 255, 255, .88); color: #52514e; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.messages.themed .pending .err { background: rgba(255, 255, 255, .85); border-radius: 6px; padding: 1px 6px; }
.messages .spacer { flex: 1; }
.day { align-self: center; margin: 10px 0 6px; padding: 3px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.bubble {
  max-width: min(560px, 75%); padding: 7px 11px 5px; border-radius: 16px 16px 16px 4px;
  background: var(--theirs); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-ink); border-radius: 16px 16px 4px 16px; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.meta svg { width: 15px; height: 15px; fill: currentColor; }
.meta .read { color: var(--accent); }
.bubble a { color: inherit; }
.file { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 3px 0; }
.file .ic { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; flex: none; }
.file .ic svg { width: 20px; height: 20px; fill: #fff; }
.file .fname { font-weight: 600; word-break: break-all; }
.file .fsize { font-size: 12px; color: var(--muted); }
.img-prev { display: block; max-width: 320px; max-height: 320px; border-radius: 10px; cursor: zoom-in; margin: 2px 0; background: var(--surface-2); min-width: 120px; min-height: 80px; object-fit: cover; }
.callrec { display: flex; align-items: center; gap: 8px; }
.callrec svg { width: 20px; height: 20px; fill: var(--accent); }
.callrec.missed svg { fill: var(--danger); }
.callrec b { font-weight: 600; }
.pending .bubble { opacity: .75; }
.pending.failed .bubble { opacity: 1; outline: 1px solid var(--danger); }
.pending .err { color: var(--danger); font-size: 12px; margin-top: 3px; }
.pending .err button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0 0 0 8px; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { resize: none; max-height: 180px; border-radius: 20px; background: var(--surface-2); border-color: transparent; padding: 10px 14px; line-height: 1.4; }
.composer .send { color: var(--accent); }
/* запись голосового */
.composer.recording > :not(.rec-bar) { display: none; }
.rec-bar { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; }
.rec-hint { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

/* голосовое сообщение в чате */
.msg.voice-msg .bubble { min-width: min(260px, 100%); }
.voice { display: flex; align-items: center; gap: 10px; padding: 3px 0; white-space: normal; }
.vplay { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; cursor: pointer; padding: 0; }
.vplay svg { width: 22px; height: 22px; fill: currentColor; }
.voice.loading .vplay { opacity: .6; cursor: progress; }
.vmain { flex: 1; min-width: 0; }
.vseek { padding: 8px 0; cursor: pointer; }
.vbar { height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.vfill { height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.vtime { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vtr-note { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: normal; }
.vtr-note.busy { font-style: italic; }
.vtr-text { margin-top: 4px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6; overflow: hidden; user-select: text; }
.vtr-text.open { display: block; -webkit-line-clamp: unset; line-clamp: none; }
.vtr-more { display: block; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 0 0; font-size: 12px; }
/* расшифровка звонка под пузырём звонка */
.ctr-note { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: normal; }
.ctr-note.busy { font-style: italic; }
.ctr-toggle { display: block; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0 0; font-size: 12px; }
.ctr-lines { margin-top: 6px; display: grid; gap: 4px; white-space: normal; user-select: text; cursor: text; }
.ctr-line b { font-weight: 600; }
.ctr-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.blocked { padding: 14px; text-align: center; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.drop-hint {
  position: absolute; inset: 60px 12px 12px; border: 2px dashed var(--accent); border-radius: 16px;
  display: grid; place-items: center; background: color-mix(in srgb, var(--chat-bg) 85%, transparent);
  color: var(--accent); font-size: 18px; font-weight: 600; pointer-events: none; z-index: 5;
}

/* ---------- звонок ---------- */
.call { position: fixed; inset: 0; z-index: 50; background: #101418; color: #fff; display: flex; flex-direction: column; align-items: center; }
#remote-video { display: none; }
.call.has-video #remote-video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#local-video { position: absolute; right: 20px; top: 20px; width: 220px; max-width: 30vw; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: #222; transform: scaleX(-1); z-index: 2; }
.call-info { position: relative; z-index: 1; margin-top: 12vh; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.call.has-video .call-info { margin-top: 20px; }
.call.has-video #call-avatar { display: none; }
.call-name { font-size: 28px; font-weight: 600; margin-top: 18px; }
.call-status { opacity: .8; font-size: 16px; margin-top: 4px; }
.call-rec { display: inline-block; margin-top: 10px; padding: 3px 12px; border-radius: 12px; background: rgba(227, 73, 72, .85); font-size: 13px; text-shadow: none; }
.call-controls { position: relative; z-index: 1; margin-top: auto; margin-bottom: 48px; display: flex; gap: 22px; align-items: flex-end; }
.cbtn { display: grid; justify-items: center; gap: 8px; font-size: 13px; color: rgba(255,255,255,.85); }
.cbtn button { width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: rgba(255,255,255,.16); color: #fff; }
.cbtn button:hover { filter: brightness(1.15); }
.cbtn button.on { background: #fff; color: #101418; }
.cbtn button.red { background: #e34948; width: 68px; height: 68px; }
.cbtn button.green { background: #2eaa4f; width: 68px; height: 68px; }
.cbtn svg { width: 28px; height: 28px; fill: currentColor; }

/* ---------- групповой звонок ---------- */
.gc-ring { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; }
.gc-ring-from { opacity: .8; font-size: 14px; margin-top: 2px; }
.gc-room { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.gc-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex: none; }
.gc-head-info { flex: 1; min-width: 0; }
.gc-title { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-sub { font-size: 13px; opacity: .75; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-rec { margin-top: 0; flex: none; white-space: nowrap; }
.gc-min { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; display: grid; place-items: center; }
.gc-min:hover { background: rgba(255,255,255,.22); }
.gc-min svg { width: 24px; height: 24px; fill: currentColor; }
.gc-audio-unlock { align-self: center; flex: none; margin: 0 0 8px; border: 0; border-radius: 18px; padding: 7px 16px; background: #fff; color: #101418; font-weight: 600; cursor: pointer; }
.gc-grid {
  flex: 1; min-height: 0; width: 100%; padding: 0 12px; display: grid; gap: 8px; overflow-y: auto;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(110px, 1fr));
}
.gc-tile { position: relative; min-width: 0; min-height: 0; border-radius: 12px; overflow: hidden; background: #1c242c; display: grid; place-items: center; }
.gc-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
.gc-tile.has-video video { display: block; }
.gc-tile.has-video .gc-ava { visibility: hidden; }
.gc-tile.screen video { object-fit: contain; }
.gc-tile video.mirror { transform: scaleX(-1); }
.gc-tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; transition: box-shadow .15s; }
.gc-tile.speaking::after { box-shadow: inset 0 0 0 3px #2eaa4f; }
.gc-name { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; background: rgba(0,0,0,.5); font-size: 13px; }
.gc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-mic { display: none; flex: none; }
.gc-mic svg { width: 15px; height: 15px; fill: #ff8a8a; display: block; }
.gc-tile.muted:not(.screen) .gc-mic { display: block; }
.gc-controls { margin: 14px 0 28px; align-self: center; }
.cbtn button:disabled { opacity: .45; cursor: default; filter: none; }
.gcall.ended .gc-grid { visibility: hidden; }
/* плашка «Идёт звонок» под шапкой группы и «Вернуться к звонку» поверх интерфейса */
.gc-banner { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-bottom: 1px solid var(--border); font-size: 13.5px; }
.gcb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; animation: rec-pulse 1.6s ease-in-out infinite; }
.gcb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-banner .btn { padding: 6px 14px; flex: none; background: var(--ok); }
.gc-pill { position: fixed; z-index: 45; right: 16px; bottom: 16px; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 8px; border: 0; border-radius: 22px; padding: 9px 16px; background: #101418; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: pointer; font-size: 13.5px; }
.gc-pill .gcp-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gc-pill b { flex: none; color: #7fd69a; }
@media (prefers-reduced-motion: reduce) { .gcb-dot { animation: none; } }
@media (max-width: 720px) {
  .gc-head { padding: 10px 12px; gap: 8px; }
  .gc-rec { font-size: 11.5px; padding: 2px 8px; }
  .gc-grid { padding: 0 8px; gap: 6px; grid-template-rows: repeat(var(--rows, 1), minmax(96px, 1fr)); }
  .gc-controls { gap: 14px; margin: 10px 0 18px; }
  .gc-controls .cbtn button { width: 52px; height: 52px; }
  .gc-controls .cbtn button.red { width: 58px; height: 58px; }
  .gc-controls .cbtn { font-size: 12px; }
  .gc-pill { left: 12px; right: 12px; bottom: 12px; justify-content: center; }
}

.about { border: 0; border-radius: 16px; padding: 28px 28px 22px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); text-align: center; box-shadow: 0 16px 48px rgba(0,0,0,.25); }
.about::backdrop { background: rgba(0,0,0,.45); }
.about h2 { margin: 10px 0 4px; font-size: 22px; }
.about .muted { margin: 0 0 18px; }
.about-logo { width: 64px; height: 64px; }
.about dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; text-align: left; margin: 0 0 18px; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; }
.about dt { color: var(--text-2); }
.about dd { margin: 0; font-weight: 600; word-break: break-word; }
.about dd small { display: block; font-weight: 400; color: var(--muted); }
.about-copy { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.about .btn { width: 100%; }
.about .btn:disabled { opacity: .6; cursor: default; }
.about-log { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.about-log.err { color: var(--danger); }
.about .btn + .btn { margin-top: 8px; }

.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.85); display: grid; place-items: center; cursor: zoom-out; }
.viewer img { max-width: 95vw; max-height: 95vh; }

/* ---------- узкое окно ---------- */
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .layout.chat-open .sidebar { display: none; }
  .layout:not(.chat-open) .chat { display: none; }
  .chat-head .back { display: inline-grid; }
  .bubble { max-width: 85%; }
  .rec-hint { visibility: hidden; }
}

/* обновление программы для Windows */
.about-update { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); text-align: left; display: grid; gap: 10px; }
.about-update-text { font-size: 14px; color: var(--text-2); }
.about-update-text.err { color: #d14343; }
.about-update progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 4px; overflow: hidden; background: var(--line, #ddd); }
.about-update progress::-webkit-progress-bar { background: var(--line, #ddd); border-radius: 4px; }
.about-update progress::-webkit-progress-value { background: #2a7ad6; border-radius: 4px; transition: width .3s; }
.update-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: var(--bg, #f4f4f2); color: var(--text); text-align: center; padding: 24px; }
.update-overlay[hidden] { display: none; }
.update-overlay img { width: 72px; height: 72px; }
.update-overlay h2 { margin: 8px 0 0; font-size: 22px; }
.update-overlay p { margin: 0; }
.update-indeterminate { width: min(320px, 80vw); height: 8px; border-radius: 4px; background: var(--line, #ddd); overflow: hidden; position: relative; margin: 8px 0; }
.update-indeterminate span { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 4px; background: #2a7ad6; animation: upd-slide 1.1s ease-in-out infinite; }
@keyframes upd-slide { from { left: -35%; } to { left: 100%; } }

/* «О программе» — компактная версия: шапка в строку, середина прокручивается, «Закрыть» всегда видна */
.about { padding: 18px 20px 16px; width: min(400px, calc(100vw - 24px)); max-height: calc(100vh - 32px); text-align: left; }
.about[open] { display: flex; flex-direction: column; }
.about-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.about-head .about-logo { width: 44px; height: 44px; flex: none; }
.about-head h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.about-head .muted { margin: 2px 0 0; font-size: 12.5px; }
.about-body { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.about dl { gap: 4px 14px; margin: 0 0 10px; padding: 10px 12px; font-size: 13.5px; }
.about-update { margin: 0 0 10px; padding: 10px 12px; gap: 8px; }
.about-update .btn { padding-top: 8px; padding-bottom: 8px; }
.about-actions { display: flex; gap: 8px; }
.about-actions .btn { flex: 1 1 0; padding-top: 8px; padding-bottom: 8px; font-size: 13px; }
.about-actions:not(:has(.btn:not([hidden]))) { display: none; }
.about-log { margin: 0 0 8px; font-size: 13px; }
.about-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.about-foot .about-copy { margin: 0; font-size: 11.5px; }
.about-foot .btn { min-width: 110px; }
.about-actions { align-items: stretch; }
.about-actions .btn, .about-foot .btn { margin: 0; width: auto; }
.about-foot .btn { flex: none; padding-left: 28px; padding-right: 28px; }
.about-foot .about-copy { white-space: nowrap; }
.about .about-actions .btn, .about .about-foot .btn { margin: 0; }

/* ---------- группы ---------- */
.avatar .grp {
  position: absolute; right: -2px; bottom: -2px; width: 40%; height: 40%; min-width: 16px; min-height: 16px;
  border-radius: 50%; background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  box-shadow: 0 0 0 1.5px var(--surface);
}
.avatar .grp svg { width: 72%; height: 72%; fill: currentColor; }
.contact.active .avatar .grp { background: var(--active); box-shadow: 0 0 0 1.5px var(--active); }
.chat-head.is-group #peer-avatar, .chat-head.is-group .peer-info { cursor: pointer; }
/* имя отправителя над пузырём */
.msg.with-sender { flex-direction: column; align-items: flex-start; margin-top: 6px; }
.msg .sender { font-size: 12.5px; font-weight: 600; margin: 0 0 2px 11px; max-width: min(560px, 75%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .messages:not(.themed) .msg .sender { filter: brightness(1.45); } }
/* системные записи группы */
.msg.sys { justify-content: center; margin: 6px 0; }
.sys-chip { max-width: min(560px, 85%); padding: 3px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 12px; text-align: center; overflow-wrap: anywhere; }
.messages.themed .sys-chip { background: rgba(255, 255, 255, .88); color: #52514e; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.messages.themed .msg .sender { text-shadow: 0 0 3px rgba(255, 255, 255, .9); }

/* окна групп */
.dlg { border: 0; border-radius: 16px; padding: 18px 20px 16px; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgba(0,0,0,.25); }
.dlg[open] { display: flex; flex-direction: column; gap: 10px; }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg-title { margin: 0; font-size: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.btn.danger { color: var(--danger); }
.dlg-foot .btn.danger { margin-right: auto; }
.btn:disabled { opacity: .6; cursor: default; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0; font-size: 13px; }
.link-btn.danger { color: var(--danger); }
.gd-head { display: flex; align-items: center; gap: 12px; }
.gd-photo-wrap { position: relative; flex: none; }
.gd-photo { width: 56px; height: 56px; border-radius: 50%; border: 1px dashed var(--border); background: var(--surface-2); color: var(--muted);
  cursor: pointer; padding: 0; display: grid; place-items: center; overflow: hidden; }
.gd-photo svg { width: 28px; height: 28px; fill: currentColor; }
.gd-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gd-photo-clear { position: absolute; right: -4px; top: -4px; width: 22px; height: 22px; border-radius: 50%; border: 0; padding: 0;
  background: var(--text-2); color: var(--surface); cursor: pointer; line-height: 22px; font-size: 16px; }
.gd-search { background: var(--surface-2); border-color: transparent; padding: 8px 12px; }
.gd-count { font-size: 12px; color: var(--muted); }
.pick-list { overflow-y: auto; min-height: 120px; max-height: 46vh; margin: 0 -8px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
label.pick-row { cursor: pointer; }
label.pick-row:hover { background: var(--hover); }
.pick-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-empty { padding: 24px; text-align: center; }
.owner-badge { flex: none; font-size: 11.5px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 1px 8px; border-radius: 10px; }
.gi-remove { width: 32px; height: 32px; }
.gi-remove svg { width: 18px; height: 18px; }
.gi-head { display: flex; align-items: center; gap: 14px; }
.gi-title-box { flex: 1; min-width: 0; }
.gi-name { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.gi-rename { display: flex; gap: 8px; }
.gi-rename input { padding: 8px 10px; min-width: 0; }
.gi-rename .btn { flex: none; padding: 8px 12px; }
.gi-photo-actions { display: flex; gap: 16px; }
.gi-sec { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 10px; }

/* иконки групп — квадрат со скруглёнными углами (у сотрудников — круг) */
.avatar.group, .avatar.group img { border-radius: 22%; }
.gd-photo { border-radius: 22%; overflow: hidden; }

/* поиск по переписке */
.hits-head { padding: 14px 14px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hits-note { padding: 10px 14px 16px; color: var(--muted); font-size: 13px; }
.contact.hit { align-items: flex-start; }
.contact.hit .avatar { margin-top: 2px; }
.hit-src { font-size: 12px; color: var(--muted); margin-top: 1px; }
.hit-quote {
  color: var(--text-2); font-size: 13px; margin-top: 2px; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.hit-quote mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.msg.flash .bubble, .ctr-line.flash { animation: hit-flash 2.2s ease-out; }
@keyframes hit-flash { 0%, 35% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.ctr-line { border-radius: 4px; }
.to-latest {
  position: absolute; right: 18px; bottom: 76px; z-index: 5; border: 0; border-radius: 18px; padding: 8px 14px;
  background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); cursor: pointer;
}

/* меню сообщения, ответ на сообщение */
.msg[data-id] .bubble { cursor: default; }
.msg-menu {
  position: fixed; z-index: 60; min-width: 160px; padding: 4px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); display: grid;
}
.msg-menu[hidden] { display: none; }
.msg-menu button { border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.msg-menu button:hover { background: var(--hover); }
.reply {
  display: block; margin: 1px 0 5px; padding: 3px 8px; border-left: 3px solid var(--accent); border-radius: 4px;
  background: rgba(127, 127, 127, .1); cursor: pointer; white-space: normal; max-width: 100%; overflow: hidden;
}
.reply b { display: block; font-size: 12px; font-weight: 600; }
.reply span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--text-2); }
.msg.mine .reply span { color: inherit; opacity: .8; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; background: var(--surface); border-top: 1px solid var(--border); }
.reply-bar[hidden] { display: none; }
.reply-bar .rb-body { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; }
.reply-bar b { display: block; font-size: 12px; }
.reply-bar span { display: block; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 70; padding: 8px 16px; border-radius: 18px;
  background: rgba(30, 30, 30, .9); color: #fff; font-size: 14px; pointer-events: none;
}
.toast[hidden] { display: none; }
