:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --line: #e4e6ee;
  --text: #17181c;
  --muted: #737889;
  --accent: #3a63e6;
  --accent-2: #5a45d8;
  --accent-soft: #e8eeff;
  --out: #dfe8ff;
  --out-text: #17181c;
  --in: #ffffff;
  --danger: #e0434b;
  --green: #22a85a;
  --chat-bg: #e9ecf4;
  --shadow: 0 6px 30px rgba(20, 24, 40, .16);
  --radius: 14px;
  color-scheme: light;
}
/* Тёмная тема: data-theme ставит js/theme.js (выбор в настройках или «как в системе»). */
:root[data-theme="dark"] {
  --bg: #0f1116;
  --panel: #171a21;
  --panel-2: #1d212a;
  --line: #2a2f3a;
  --text: #e9ebf1;
  --muted: #8d93a3;
  --accent: #6d8dff;
  --accent-2: #8a76ff;
  --accent-soft: #232b45;
  --out: #2e3d78;
  --out-text: #eef1ff;
  --in: #1f232c;
  --chat-bg: #0d0f14;
  --shadow: 0 6px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 10px 4px; }
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }

#app { height: 100%; }

/* ------------------------------------------------------------- кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  padding: 9px 16px; font-weight: 600; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.field input, .modal input[type=text], .modal input[type=search], .modal input[type=password] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); outline: none;
}
.field input:focus, .modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; margin: 4px 0 10px; }
.form-error:empty { margin: 0; }

.avatar {
  border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex: none; user-select: none; letter-spacing: .3px;
}
.avatar.group { border-radius: 30%; }

/* ------------------------------------------------------------- вход */
.setup { height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto;
  background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 50%), var(--bg); }
.setup-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); margin: auto; }
.setup-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 6px; }
.setup-logo img { width: 72px; height: 72px; border-radius: 18px; }
.setup-logo h1 { margin: 0; font-size: 26px; }
.server-line { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 16px; word-break: break-all; }
.tabs { display: flex; background: var(--panel-2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ------------------------------------------------------------- раскладка */
.layout { display: flex; height: 100%; }
.sidebar { width: 340px; min-width: 280px; max-width: 420px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg); position: relative; }

.side-head { display: flex; align-items: center; gap: 4px; padding: 10px 8px 6px 12px; }
.me-box { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; border-radius: 12px; padding: 4px; }
.me-box:hover { background: var(--panel-2); }
.me-text { min-width: 0; }
.me-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { margin: 4px 12px 8px; display: flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 12px; padding: 0 10px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; padding: 9px 0; outline: none; min-width: 0; }
.conn-banner { margin: 0 12px 8px; padding: 8px 10px; border-radius: 10px; background: #fff3cd; color: #6b5200; font-size: 13px; }
:root[data-theme="dark"] .conn-banner { background: #3a3218; color: #f3d98b; }

.chat-list { flex: 1; overflow-y: auto; padding: 0 6px 10px; }
.chat-item { display: flex; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; align-items: center; }
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-soft); }
.avatar-wrap { position: relative; flex: none; }
.online-dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--green); border: 2px solid var(--panel); }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; gap: 6px; }
.chat-item-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item-last { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft { color: var(--danger); }
.badge { background: var(--accent); color: #fff; border-radius: 11px; min-width: 22px; height: 22px; padding: 0 6px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.empty-pane { margin: auto; text-align: center; color: var(--muted); max-width: 360px; padding: 20px; }
.empty-logo { width: 88px; height: 88px; margin: 0 auto 10px; border-radius: 50%; background: var(--panel); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.empty-pane h3 { color: var(--text); margin: 6px 0; }

/* ------------------------------------------------------------- чат */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 60px; }
.back-btn { display: none; }
.chat-head-avatar { cursor: pointer; }
.chat-head-text { flex: 1; min-width: 0; cursor: pointer; }
.chat-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.verified { color: var(--green); }
.chat-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub.accent { color: var(--accent); }
.chat-head-actions { display: flex; }

.messages-wrap { flex: 1; position: relative; min-height: 0; }
.messages { position: absolute; inset: 0; overflow-y: auto; padding: 12px 4% 8px; display: flex; flex-direction: column; gap: 2px; }
.to-bottom { position: absolute; right: 18px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--panel); color: var(--muted); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.e2e-note { align-self: center; margin: 6px 0 14px; padding: 8px 14px; border-radius: 12px; background: var(--panel); color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; max-width: 90%; text-align: center; }
.day-sep { align-self: center; margin: 10px 0 6px; }
.day-sep span { background: rgba(0,0,0,.28); color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 13px; }
.to-bottom .unread-count { position: absolute; top: -7px; right: -3px; min-width: 19px; padding: 1px 5px; border-radius: 12px; background: var(--accent); color: white; font: 600 12px/17px sans-serif; }
.unread-sep { display: flex; flex: none; align-items: center; gap: 10px; margin: 9px 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.unread-sep::before, .unread-sep::after { content: ""; flex: 1; height: 1px; background: var(--accent); opacity: .45; }
.unread-sep span { padding: 3px 10px; border-radius: 12px; background: var(--panel); text-align: center; }
.sys-msg { align-self: center; text-align: center; margin: 6px 0; max-width: 80%; }
.sys-msg span { display: inline-block; background: rgba(0,0,0,.22); color: #fff; padding: 4px 12px; border-radius: 12px; font-size: 13px; }
.sys-msg.warn span { background: #b5781f; }

.msg-row { display: flex; margin-top: 2px; }
.msg-row.first { margin-top: 8px; }
.msg-row.out { justify-content: flex-end; }
.bubble { max-width: min(560px, 78%); background: var(--in); border-radius: 16px; padding: 6px 10px 6px; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.06); word-wrap: break-word; overflow-wrap: anywhere; }
.out .bubble { background: var(--out); color: var(--out-text); }
.in .bubble { border-bottom-left-radius: 6px; }
.out .bubble { border-bottom-right-radius: 6px; }
.sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.text { white-space: pre-wrap; }
.bubble.deleted .text { font-style: italic; color: var(--muted); }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: 11.5px; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; user-select: none; position: relative; top: 2px; }
.ticks { letter-spacing: -3px; padding-right: 3px; font-size: 12px; }
.ticks.read { color: var(--accent); }
.ticks.failed { color: var(--danger); cursor: pointer; letter-spacing: 0; }
.err-line { clear: both; color: var(--danger); font-size: 12px; }
.bubble.kind-call .text { font-weight: 500; }

.photo-box { position: relative; margin: -2px -6px 4px; border-radius: 12px; overflow: hidden; cursor: zoom-in; line-height: 0; }
.photo { display: block; max-width: 100%; height: auto; object-fit: cover; background: rgba(127,127,127,.2); }
.progress { height: 4px; background: rgba(127,127,127,.25); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.photo-transfer { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2;
  display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%;
  padding: 0; color: #fff; background: rgba(0,0,0,.68); }
.photo-upload { pointer-events: none; }
.photo-transfer-ring { position: absolute; inset: 3px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(#fff calc(var(--load-fraction,var(--p,0)) * 1turn), rgba(255,255,255,.28) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px)); }
.photo-transfer.indeterminate .photo-transfer-ring {
  background: conic-gradient(rgba(255,255,255,.25) 70%, #fff);
  animation: spin .85s linear infinite;
}
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

.file-box { display: flex; gap: 10px; align-items: center; cursor: pointer; min-width: 200px; padding: 2px 0; }
.file-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: #fff; position: relative; display: flex; align-items: center; justify-content: center; flex: none; }
.file-icon .ext { display: none; }
.file-info { min-width: 0; flex: 1; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 13px; color: var(--muted); }

.voice-box { display: flex; gap: 10px; align-items: center; min-width: 220px; flex-wrap: wrap; }
.voice-play { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.voice-main { flex: 1; min-width: 120px; }
.voice-time { font-size: 12px; color: var(--muted); }
.voice-box .progress { flex-basis: 100%; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; resize: none; overflow-y: hidden; scrollbar-width: thin; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px; background: var(--panel-2); outline: none; max-height: 180px; line-height: 1.35; }
.composer textarea:focus { border-color: var(--accent); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.attach-btn { margin-bottom: 2px; }
.composer-locked { flex: 1; text-align: center; color: var(--muted); padding: 10px; }
.composer.recording { align-items: center; }
.rec-main { flex: 1; display: flex; align-items: center; gap: 10px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 44px; }
.rec-level { flex: 1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.rec-level > div { height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(.05); transition: transform .08s; }
.rec-cancel { color: var(--danger); }
.drop-hint { position: absolute; inset: 0; background: rgba(58, 99, 230, .15); border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; color: var(--accent); z-index: 5; pointer-events: none; }

/* ------------------------------------------------------------- окна */
.backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 18px; width: 100%; max-width: 440px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { max-width: 560px; }
.modal-head { display: flex; align-items: center; padding: 14px 10px 6px 20px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { padding: 6px 20px 18px; overflow-y: auto; }
.modal-body h4 { margin: 18px 0 8px; display: flex; align-items: center; gap: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }

.picker input { width: 100%; }
.pick-results { margin-top: 6px; max-height: 300px; overflow-y: auto; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; width: 100%; border: 0; background: transparent; text-align: left; }
button.user-row:hover { background: var(--panel-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 14px; padding: 4px 6px 4px 12px; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; }
.chip button { border: 0; background: transparent; color: inherit; font-size: 16px; padding: 0 4px; }

.info-top { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.info-name { font-size: 20px; font-weight: 700; }
.inline-form { display: flex; gap: 8px; margin-bottom: 4px; }
.inline-form input { flex: 1; min-width: 0; }
.safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 6px; font: 600 17px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--panel-2); border-radius: 12px; padding: 14px; text-align: center; margin-bottom: 10px; letter-spacing: 1px; }
.info .btn { margin-top: 4px; }
.info-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.members { max-height: 280px; overflow-y: auto; }
.device-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tag { margin-left: 8px; font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 2px 8px; font-weight: 600; }
.switch-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.pw-form { display: grid; gap: 0; }
.paste-preview img { max-width: 100%; max-height: 50vh; border-radius: 10px; display: block; margin: 0 auto 8px; }
.file-line { display: flex; align-items: center; gap: 4px; padding: 4px 0; }

.toast-root, #toast-root { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: #23262f; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 90vw; transition: opacity .4s; font-size: 14px; }
.toast.error { background: var(--danger); }
.toast.hide { opacity: 0; }

.ctx-menu { position: fixed; z-index: 120; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 190px; display: flex; flex-direction: column; border: 1px solid var(--line); }
.ctx-menu button { border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 8px; }
.ctx-menu button:hover { background: var(--panel-2); }
.ctx-menu button.danger { color: var(--danger); }

.viewer { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.photo-viewer { overflow: hidden; }
.photo-stage img { display: block; user-select: none; }
.photo-viewer.zoomed .photo-stage img { cursor: grab; }
.photo-viewer.zoomed .photo-stage img:active { cursor: grabbing; }
.photo-viewer .viewer-bar, .photo-viewer .viewer-nav { z-index: 1; }
.viewer-bar { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.viewer-bar .icon-btn { color: #fff; background: rgba(255,255,255,.12); }

/* ------------------------------------------------------------- звонок */
.call-overlay { position: fixed; inset: 0; z-index: 80; background: linear-gradient(160deg, #1d2b5c, #3a2466 60%, #14121f); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 40px 20px max(30px, env(safe-area-inset-bottom)); animation: fade .2s; }
.remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; }
.call-overlay.has-video .remote-video { display: block; }
.call-overlay.has-video .call-center .avatar { display: none; }
.call-center { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8vh; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
.call-name { font-size: 26px; font-weight: 700; }
.call-status { font-size: 16px; opacity: .85; font-variant-numeric: tabular-nums; }
.local-video { position: absolute; right: 16px; top: 16px; width: 28vw; max-width: 220px; border-radius: 14px; background: #000; transform: scaleX(-1); box-shadow: var(--shadow); }
.call-controls { position: relative; display: flex; gap: 28px; }
.call-btn-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; opacity: .95; max-width: 90px; text-align: center; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-btn:hover { filter: brightness(1.1); }
.call-btn.red { background: var(--danger); }
.call-btn.green { background: var(--green); animation: ring 1.4s infinite; }
.call-btn.on { background: #fff; color: #222; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } 50% { transform: rotate(0); } }
.call-overlay.ended .call-status { color: #ffb4b4; }

/* ------------------------------------------------------------- почта */
.side-tabs { display: flex; gap: 4px; margin: 2px 12px 8px; background: var(--panel-2); border-radius: 12px; padding: 4px; }
.side-tabs button { flex: 1; border: 0; background: transparent; padding: 7px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.side-tabs button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.side-tabs .badge { min-width: 18px; height: 18px; font-size: 11px; }
.mail-list-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; }
.mail-dot { position: absolute; right: -2px; bottom: -2px; font-size: 13px; background: var(--panel); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.bulk-toggle { margin: 10px 8px; font-size: 13px; color: var(--muted); }
.empty-logo.small { width: 64px; height: 64px; font-size: 28px; }
.spin .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bubble.mail { max-width: min(640px, 82%); }
.mail-subject { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.more-link { margin-top: 4px; }
.mail-att { margin-top: 6px; background: rgba(127,127,127,.08); border-radius: 10px; padding: 6px; }
.mail-photo { max-width: 300px; max-height: 320px; width: auto; height: auto; }
.mail-composer { flex-direction: column; align-items: stretch; gap: 6px; }
.mail-compose-top { display: flex; gap: 6px; align-items: center; }
.mail-subject-input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; background: var(--panel-2); outline: none; font-size: 14px; min-width: 0; }
.mail-subject-input:disabled { color: var(--muted); font-style: italic; }
.mail-compose-main { display: flex; align-items: flex-end; gap: 6px; }
.mail-compose-main textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 16px; padding: 9px 14px; background: var(--panel-2); outline: none; max-height: 220px; line-height: 1.35; }
.mail-files { display: flex; flex-wrap: wrap; gap: 6px; }
.mail-files:empty { display: none; }
.lock-btn { color: var(--muted); }
.lock-btn.on { color: var(--green); background: rgba(34,168,90,.12); }
.mail-banner { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: #fff3cd; color: #6b5200; font-size: 14px; }
:root[data-theme="dark"] .mail-banner { background: #3a3218; color: #f3d98b; }
.mail-connect ol.steps { padding-left: 20px; margin: 8px 0 14px; }
.mail-connect ol.steps li { margin-bottom: 6px; }
.mail-connect input[type=email] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); outline: none; }
.mail-settings { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.modal input[type=email] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); outline: none; }

/* ------------------------------------------------------------- узкий экран (телефон) */
@media (max-width: 760px) {
  .sidebar { width: 100%; max-width: none; border-right: 0; }
  .chat-pane { display: none; }
  body.in-chat .sidebar { display: none; }
  body.in-chat .chat-pane { display: flex; }
  .back-btn { display: inline-flex; }
  .chat-head { padding: 6px 4px; gap: 6px; }
  .messages { padding: 10px 8px 6px; }
  .bubble { max-width: 86%; }
  .modal { max-height: 96vh; border-radius: 16px; }
  .backdrop { padding: 8px; align-items: flex-end; }
  .safety { font-size: 15px; }
  .call-controls { gap: 18px; }
}

/* ------------------------------------------------------------- профиль */
.avatar.has-photo { background-size: cover !important; background-position: center !important; background-repeat: no-repeat !important; color: transparent; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-top { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.profile-photo { position: relative; cursor: pointer; flex: none; border-radius: 50%; }
.profile-photo .photo-edit { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; border: 3px solid var(--panel); }
.profile-photo.small .photo-edit { width: 26px; height: 26px; }
.profile-photo:hover .avatar { filter: brightness(.9); }
.profile-photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.at-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); padding-left: 12px; }
.at-input span { color: var(--muted); }
.at-input input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding-left: 2px !important; }
.profile-edit .field-label { display: flex; justify-content: space-between; }
.profile-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin: 4px 0 8px; }
.profile-card-photo { cursor: zoom-in; margin-bottom: 6px; }
.profile-status { margin-top: 6px; padding: 8px 14px; background: var(--panel-2); border-radius: 12px; max-width: 100%; overflow-wrap: anywhere; }
.crop { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.crop-canvas { border-radius: 12px; touch-action: none; cursor: grab; background: #000; }
.crop-row { display: flex; align-items: center; gap: 10px; width: 300px; color: var(--muted); font-weight: 700; }
.crop-zoom { flex: 1; accent-color: var(--accent); }

/* ------------------------------------------------------------- обновления */
.update-banner { display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 14px; }
.update-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10,12,20,.55); display: flex; align-items: center; justify-content: center; }
.update-box { background: var(--panel); border-radius: 16px; padding: 24px 32px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.updates { display: flex; flex-direction: column; gap: 6px; }
.update-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.update-row input[type=text] { margin-top: 6px; width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); outline: none; }

/* ---- реакции, изменение, роли ---- */
.meta .edited { font-style: italic; margin-right: 2px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; clear: both; }
.reaction { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 1px 8px; font-size: 14px; line-height: 20px; }
.out .reaction { background: rgba(255,255,255,.35); border-color: transparent; }
:root[data-theme="dark"] .out .reaction { background: rgba(255,255,255,.1); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction .r-count { font-size: 12px; color: var(--muted); font-weight: 600; }
.reaction:disabled { cursor: default; }
.react-pick { display: flex; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.react-pick button { border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 6px; border-radius: 10px; }
.react-pick button:hover { background: var(--panel-2); transform: scale(1.15); }
.react-pick button.on { background: var(--accent-soft); }
.composer.has-link { flex-wrap: wrap; }
.draft-preview { flex: 0 0 100%; min-width: 0; }
.draft-preview:empty { display: none; }
.draft-preview .link-card { max-width: 100%; margin: 0; overflow-wrap: anywhere; }
.composer.editing { flex-wrap: wrap; }
.edit-bar { flex-basis: 100%; display: flex; align-items: center; gap: 10px; color: var(--accent); padding: 0 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.edit-bar .edit-title { font-weight: 600; font-size: 13px; }
.edit-bar .edit-orig { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.role-tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.role-tag.owner { background: var(--accent-soft); color: var(--accent); }
table.perms { width: 100%; border-collapse: collapse; font-size: 14px; }
table.perms th { font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 4px; }
table.perms td { padding: 6px 4px; border-top: 1px solid var(--line); }
table.perms input { width: 18px; height: 18px; accent-color: var(--accent); }
.theme-pick { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.theme-pick button { border: 0; background: none; color: var(--muted); border-radius: 9px; padding: 6px 12px; display: flex; align-items: center; gap: 7px; font-size: 14px; transition: background .15s, color .15s; }
.theme-pick button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.theme-pick .swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(127,127,127,.45); display: inline-block; padding: 0; }
.theme-pick .swatch i { display: none; }
.theme-pick .sw-light { background: #f4f5f9; }
.theme-pick .sw-dark { background: #171a21; }
.theme-pick .sw-dark i { background: #6d8dff; }
.theme-pick .sw-auto { background: linear-gradient(135deg, #f4f5f9 50%, #171a21 50%); }
.local-video.rear { transform: none; }
.call-btn.busy { opacity: .5; pointer-events: none; }
.bg-note { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin: 6px 0 10px; }

/* ---- свёрнутый звонок ---- */
.call-min { position: absolute; left: 12px; top: max(12px, env(safe-area-inset-top)); z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.28); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-min:hover { background: rgba(0,0,0,.45); }
.mini-name { display: none; }
.call-overlay.no-mini .call-min, .call-overlay.pip .call-min { display: none; }
.call-overlay.mini { inset: auto 16px 90px auto; width: max-content; max-width: calc(100vw - 24px); height: auto; min-height: 64px; padding: 10px 12px; border-radius: 16px; flex-direction: row; justify-content: flex-start; gap: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.45); cursor: pointer; touch-action: none; animation: none; overflow: hidden; }
.call-overlay.mini.has-video { align-items: flex-end; justify-content: flex-end; }
.call-overlay.mini .call-min, .call-overlay.mini .local-video { display: none; }
.call-overlay.mini .call-center { margin: 0; flex-direction: row; gap: 8px; min-width: 0; text-align: left; }
.call-overlay.mini .call-center .avatar { width: 40px !important; height: 40px !important; font-size: 16px !important; flex: none; }
.call-overlay.mini .call-name { display: none; }
.call-overlay.mini .call-status { min-width: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-overlay.mini.has-video .call-center { position: absolute; left: 10px; top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.call-overlay.mini.has-video .call-center .avatar { display: none; }
.call-overlay.mini .call-controls { gap: 8px; flex: none; }
.call-btn.small { width: 38px; height: 38px; }
.call-overlay.mini .remote-video { object-fit: cover; }
@media (max-width: 760px) { .call-overlay.mini { inset: auto 10px 84px auto; } }
/* Android «картинка в картинке»: только видео/аватар и время */
.call-overlay.pip { padding: 8px; justify-content: center; }
.call-overlay.pip .call-controls, .call-overlay.pip .local-video, .call-overlay.pip .call-min { display: none; }
.call-overlay.pip .call-center { margin: 0; gap: 4px; }
.call-overlay.pip .call-center .avatar { width: 56px !important; height: 56px !important; font-size: 22px !important; }
.call-overlay.pip .call-name { font-size: 15px; }
.call-overlay.pip .call-status { font-size: 12px; }
.call-overlay.pip.has-video .call-center { position: absolute; bottom: 6px; left: 8px; margin: 0; align-items: flex-start; }
.call-overlay.pip.has-video .call-name { display: none; }
.update-check { margin-top: 8px; }
.icon-btn.has-update { position: relative; }
.icon-btn.has-update::after { content: ''; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--panel); }
.call-overlay.pip .remote-video { object-fit: cover; }
.update-banner.in-settings { margin: 8px 0 4px; }
.update-banner .progress { margin-top: 6px; }

/* ---- ответ, пересылка, ссылки ---- */
.fwd { font-size: 12.5px; color: var(--accent); font-style: italic; margin-bottom: 2px; }
.quote { border-left: 3px solid var(--accent); background: rgba(127,127,127,.12); border-radius: 6px; padding: 4px 8px; margin: 2px 0 4px; cursor: pointer; max-width: 100%; }
.quote-name { font-size: 12.5px; font-weight: 600; }
.quote-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out .quote-text { color: inherit; opacity: .75; }
.link-card { display: flex; gap: 10px; margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--accent); background: rgba(127,127,127,.1); border-radius: 6px; color: inherit; text-decoration: none; clear: both; max-width: 420px; }
.link-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.lc-body { min-width: 0; }
.lc-site { font-size: 12px; color: var(--accent); font-weight: 600; }
.lc-title { font-weight: 600; font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lc-desc { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.out .lc-desc { color: inherit; opacity: .75; }
.mention { color: var(--accent); font-weight: 600; }
.mention.me { background: var(--accent-soft); border-radius: 4px; padding: 0 2px; }
.bubble.mentioned { box-shadow: 0 0 0 2px var(--accent) inset; }
.meta .exp { font-size: 11px; margin-right: 2px; }
.msg-row.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: none; } }

/* ---- альбом ---- */
.album { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; width: min(320px, 70vw); position: relative; margin-bottom: 2px; }
.album.n2 { grid-template-columns: 1fr 1fr; }
.album.n3 { grid-template-columns: 1fr 1fr; }
.album.n3 .album-cell:first-child { grid-column: span 2; }
.album.n4 { grid-template-columns: 1fr 1fr; }
.album-cell { position: relative; aspect-ratio: 1; cursor: zoom-in; background: rgba(127,127,127,.2); }
.album.n3 .album-cell:first-child { aspect-ratio: 2 / 1; }
.album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-more { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 12px; background: rgba(0,0,0,.35); color: #fff; font-size: 34px; }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-count { color: #fff; margin-right: 8px; font-size: 14px; }

/* ---- опрос ---- */
.poll { min-width: min(300px, 66vw); display: flex; flex-direction: column; gap: 6px; padding: 2px 0 4px; }
.poll-q { font-weight: 600; }
.poll-opt { position: relative; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 10px; padding: 8px 10px; overflow: hidden; text-align: left; }
.poll-opt:disabled { cursor: default; }
.poll-opt.on { border-color: var(--accent); }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); transition: width .3s; }
.poll-check, .poll-text, .poll-pct { position: relative; }
.poll-check { width: 16px; color: var(--accent); font-weight: 700; }
.poll-text { flex: 1; }
.poll-pct { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.poll-form { display: flex; flex-direction: column; gap: 8px; }
.poll-form input[type=text] { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.poll-opts { display: flex; flex-direction: column; gap: 6px; }

/* ---- закреплённое, упоминания, поиск ---- */
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--accent); cursor: pointer; }
.pin-title { font-size: 12.5px; font-weight: 600; }
.pin-text { color: var(--text); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { position: relative; }
.mention-pop { position: absolute; left: 50px; bottom: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; z-index: 20; min-width: 220px; }
.mention-pop .user-row.sel { background: var(--accent-soft); }
.list-section { padding: 10px 16px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.search-row { width: 100%; text-align: left; }
.sr-top { display: flex; justify-content: space-between; gap: 8px; }
.sr-text { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-text mark { background: #ffe58a; color: #222; border-radius: 3px; padding: 0 1px; }
.search-results { max-height: 60vh; overflow: auto; }
.badge.mention { background: var(--accent); margin-left: 4px; }
.badge.grey { background: var(--muted); }
.muted-ic, .pin-ic { color: var(--muted); margin-left: 4px; display: inline-flex; vertical-align: -2px; }
.pin-ic { margin: 0 4px 0 0; }
.avatar.saved { background: linear-gradient(135deg, #2346D8, #5a7bff) !important; color: #fff; display: flex; align-items: center; justify-content: center; border-radius: 50%; flex: none; }
.chat-settings { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.set-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row select { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 6px 8px; font: inherit; max-width: 200px; }
.set-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.fwd-list { max-height: 55vh; overflow: auto; }

/* ---- приглашения и администрирование ---- */
.invite-box { margin-top: 6px; }
.invite-link { display: flex; gap: 8px; }
.invite-link input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 13px; }
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.join-info { margin-top: 10px; }
.admin-tabs { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat-n { font-size: 24px; font-weight: 700; }
.admin-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; margin: 8px 0; }
.admin-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 9px 0; }
.admin-row + .admin-row { border-top: 1px solid var(--line); }
.admin-row.dead { opacity: .55; }
.admin-row code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; font-weight: 600; }
.admin-users { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 60vh; overflow: auto; }
.admin-users input { width: 100%; }
.admin-user { border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; }
.admin-user.blocked { background: rgba(224,67,75,.06); }
.role-tag.blocked { background: rgba(224,67,75,.15); color: var(--danger); margin-left: 6px; }
.admin-user .role-tag.owner { margin-left: 6px; }
.admin-devs { padding: 0 0 8px 50px; }
.admin-dev { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.invite-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.invite-form input { flex: 1; min-width: 160px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.invite-form select, .admin-users + * select { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 7px 8px; font: inherit; }
.admin .admin-body > input[type=search] { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.local-video.screen { transform: none; object-fit: contain; background: #111; }

/* ---- блокировка ---- */
body.app-locked > *:not(.lock-screen):not(#toast-root) { filter: blur(16px); pointer-events: none; }
.lock-screen { position: fixed; inset: 0; z-index: 200; background: rgba(15,17,22,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lock-card { background: var(--panel); border-radius: 22px; padding: 26px 26px 18px; width: min(340px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.lock-card.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.lock-logo { width: 56px; height: 56px; border-radius: 14px; }
.lock-title { font-size: 18px; font-weight: 700; }
.lock-msg { color: var(--muted); font-size: 14px; min-height: 20px; }
.lock-dots { display: flex; gap: 12px; margin: 6px 0 10px; }
.lock-dots span { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--accent); }
.lock-dots span.on { background: var(--accent); }
.lock-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; }
.lock-key { height: 60px; border-radius: 50%; border: 0; background: var(--panel-2); font-size: 24px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
.lock-key:active { background: var(--accent-soft); }
.lock-key.fn { background: transparent; color: var(--muted); }
.lock-ok { width: 100%; margin-top: 8px; }
.lock-forgot { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 6px; }
.lock-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.pin-form { display: flex; flex-direction: column; gap: 8px; }
.pin-form input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 18px; letter-spacing: 4px; }
.call-overlay .remote-video.screen { object-fit: contain; }
.local-video { cursor: grab; touch-action: none; transition: top .2s ease, left .2s ease, right .2s ease, bottom .2s ease; z-index: 2; }
.local-video.dragging { cursor: grabbing; transition: none; box-shadow: 0 12px 40px rgba(0,0,0,.5); }

/* Тонкие полосы прокрутки без стрелок (на Windows стрелки выглядели чужеродно). */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
.new-chat-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.new-chat-actions .btn { justify-content: flex-start; gap: 10px; padding: 11px 14px; }

.day-float { position: absolute; top: 8px; left: 50%; transform: translate(-50%, -6px); background: rgba(0,0,0,.38); color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .2s, transform .2s; z-index: 3; white-space: nowrap; }
.day-float.show { opacity: 1; transform: translate(-50%, 0); }

/* Телефон: никакого выделения текста — меню сообщения по нажатию. */
body.platform-android, body.platform-android * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.platform-android input, body.platform-android textarea, body.platform-android [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
body.platform-android .bubble { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.set-link { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: var(--text); font: inherit; cursor: pointer; }
.set-link:hover { filter: brightness(.98); }
.set-link .chev { font-size: 22px; color: var(--muted); line-height: 1; }
.set-link svg { color: var(--accent); flex: none; }
.notify-settings h4 { margin: 14px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Видеосообщения («кружки») */
.round-stage { position: fixed; left: 0; right: 0; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); pointer-events: none; animation: fade-in .2s ease; }
.round-stage.paused .round-preview { filter: grayscale(.7) brightness(.8); }
.round-preview { position: relative; width: min(72vw, 320px, var(--avail, 320px)); aspect-ratio: 1; border-radius: 50%; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.4); background: #000; }
.round-preview canvas { width: 100%; height: 100%; display: block; }
.round-ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px)); }
.composer.recording .rec-flip { flex: none; }
.bubble.kind-round { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.bubble.kind-round .meta { float: none; display: inline-flex; margin: 4px 6px 0; background: rgba(0,0,0,.35); color: #fff; padding: 1px 7px; border-radius: 10px; }
.bubble.kind-round .meta .ticks { color: #fff; }
.round-box { position: relative; width: 220px; height: 220px; border-radius: 50%; overflow: hidden; cursor: pointer; background: #000 linear-gradient(135deg, var(--accent), var(--accent-2)); }
.round-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.round-dur { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0,0,0,.45); color: #fff; font-size: 12px; padding: 1px 8px; border-radius: 10px; pointer-events: none; }
.round-box:not(.playing)::after { content: '🔇'; position: absolute; right: 18px; bottom: 30px; font-size: 13px; opacity: .85; pointer-events: none; }
.round-box .progress { position: absolute; left: 20%; right: 20%; top: 50%; }
@media (max-width: 760px) { .round-box { width: 200px; height: 200px; } }
.set-links { display: flex; flex-direction: column; gap: 8px; }
.set-link.warn { border-color: var(--danger); }
.set-link.warn .muted { color: var(--danger); }
.reliability h4 { margin: 16px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.rel-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rel-mark { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--panel-2); color: var(--muted); }
.rel-row.ok .rel-mark { background: #2fae61; color: #fff; }
.rel-row.bad .rel-mark { background: var(--danger); color: #fff; }
.rel-tip { padding: 4px 0 4px 34px; }

/* Узкие экраны (320–360 точек): подпись слева не обрезается выпадающим списком. */
.set-row > :first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.set-row select { flex: 0 0 auto; min-width: 0; max-width: 50%; }
@media (max-width: 380px) {
  .modal-body { padding-left: 14px; padding-right: 14px; }
  .composer { gap: 4px; }
}

/* Голосовые: «эквалайзер» вместо линии, круговая загрузка вокруг кнопки */
.voice-play { position: relative; }
.ring-progress { position: absolute; inset: -4px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: conic-gradient(var(--accent) calc(var(--load-fraction,var(--p,0)) * 360deg), color-mix(in srgb, var(--accent) 22%, transparent) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px)); }
.loading > .ring-progress { opacity: 1; }
.voice-play.loading > .ring-progress, .round-box.loading > .ring-progress { animation: ring-spin 1.2s linear infinite; }
@keyframes ring-spin { to { transform: rotate(360deg); } }
.out .voice-play { background: var(--accent); }
.wave { --wave-idle: #8397ac; display: flex; align-items: center; justify-content: space-between;
  gap: min(1px, .35%); min-width: 0; height: 16px; cursor: pointer; touch-action: none; }
:root[data-theme="dark"] .wave { --wave-idle: #3a4d61; }
:root[data-theme="dark"] .out .wave { --wave-idle: #7084a7; }
.wave i { flex: 1; min-width: 0; max-width: 2px; border-radius: .5px;
  background: var(--wave-idle); transition: background .15s; }
.wave i.on { background: var(--accent); }
.rec-wave { flex: 1; cursor: default; }
.rec-wave i { transition: height .08s ease-out; }
.composer.rec-paused .rec-dot { animation: none; opacity: .4; }
.composer.rec-paused .rec-wave i { background: var(--muted); }
.rec-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

/* Плашка проигрывателя голосовых */
.player-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); animation: slide-down .2s ease; }
.player-bar.hidden { display: none; }
.pb-play { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.pb-main { flex: 1; min-width: 0; cursor: pointer; }
.pb-title { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-line { height: 3px; background: var(--line); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.pb-line > div { height: 100%; background: var(--accent); }
.pb-speed { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 12px; padding: 3px 9px; font-weight: 700; font-size: 13px; flex: none; min-width: 46px; }
.pb-close { border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 4px; flex: none; }
.pb-time { flex: none; }
@media (max-width: 420px) { .pb-time { display: none; } }
@keyframes slide-down { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.voice-box { flex-wrap: nowrap; min-width: 210px; }
.round-box > .ring-progress { inset: 0; -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Свёрнутый звонок: два места (левый/правый нижний угол), размер по экрану */
.call-overlay.mini { transition: left .2s ease, right .2s ease, bottom .2s ease, top .2s ease; }
.call-overlay.mini.dragging { transition: none; opacity: .9; }
.call-overlay.mini.has-video { height: min(240px, 38vh); width: min(240px, 60vw); }
@media (max-width: 760px) { .call-overlay.mini.has-video { height: min(240px, 36vh); width: calc(min(240px, 36vh) * .62); } }
@media (max-height: 480px) { .call-overlay.mini.has-video { height: 46vh; width: calc(46vh * 1.3); } }
.call-overlay.mini .call-controls .call-btn.small { width: 36px; height: 36px; }
.ctx-head { font-size: 12px; color: var(--muted); padding: 8px 12px 4px; text-transform: uppercase; letter-spacing: .3px; }

/* Видео в переписке */
.video-box { position: relative; cursor: pointer; background: #000; border-radius: 12px; overflow: hidden; }
.video-box.no-thumb { min-width: 200px; min-height: 120px; background: linear-gradient(135deg, #2b2f3a, #14161c); }
.video-box .photo { display: block; }
.video-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; pointer-events: none; }
.video-dur { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; padding: 1px 7px; border-radius: 10px; pointer-events: none; }
.video-viewer video { max-width: 100vw; max-height: calc(100vh - 70px); background: #000; }

/* Вложения перед отправкой */
.send-preview { position: relative; display: flex; flex-direction: column; gap: 12px; }
.sp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sp-toolbar .btn, .ed-tools .btn { display: inline-flex; align-items: center; gap: 5px; }
.sp-summary { margin-inline-start: auto; white-space: nowrap; }
.sp-list { display: grid; gap: 6px; list-style: none; padding: 0; margin: 0; max-height: 48vh; overflow-y: auto; overscroll-behavior: contain; }
.sp-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center;
  gap: 9px; min-width: 0; padding: 6px 8px; border-radius: 12px; background: var(--panel-2); }
.sp-thumb { display: grid; place-items: center; width: 48px; aspect-ratio: 1; position: relative;
  overflow: hidden; border-radius: 8px; color: var(--muted); background: var(--panel); }
.sp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-video-icon { position: absolute; display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; color: #fff; background: rgba(0,0,0,.55); pointer-events: none; }
.sp-info { display: grid; gap: 2px; min-width: 0; }
.sp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-actions { display: flex; align-items: center; gap: 2px; }
.sp-actions .icon-btn { width: 34px; height: 34px; }
.sp-actions .sp-up .icon { transform: rotate(180deg); }
.sp-actions button:disabled, .ed-tool:disabled { opacity: .36; cursor: default; }
.sp-empty { margin: 0; padding: 20px 8px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.sp-caption { border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; background: var(--panel-2); color: var(--text); font: inherit; resize: vertical; outline: none; }
.sp-caption:focus { border-color: var(--accent); }
.sp-drop-hint { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; pointer-events: none;
  color: var(--accent); background: var(--panel); border: 2px dashed var(--accent); border-radius: 12px; font-weight: 600; }
@media (max-width: 430px) {
  .sp-row { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 9px; }
  .sp-thumb { width: 44px; grid-row: span 2; }
  .sp-actions { grid-column: 2; justify-content: flex-end; }
  .sp-actions .icon-btn { width: 36px; height: 36px; }
}

/* Редактор фото */
.modal:has(.editor) { max-width: 820px; }
.editor { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.ed-stage { display: grid; place-items: center; width: 100%; padding: 6px; border-radius: 12px; overflow: hidden;
  background: repeating-conic-gradient(#0000 0 25%, #8882 0 50%) 0 / 16px 16px, var(--panel-2); }
.ed-canvas { display: block; max-width: 100%; touch-action: none; }
.ed-canvas:focus { outline: none; }
.ed-stage.drawing .ed-canvas { cursor: crosshair; }
.ed-tools, .ed-crop-tools, .ed-palette { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.ed-tool.on { background: var(--accent); color: #fff; }
.ed-redo .icon { transform: scaleX(-1); }
.ed-crop-tools select { color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font: inherit; }
.ed-colors, .ed-width { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 7px; }
.ed-width { color: var(--muted); font-size: 13px; }
.ed-width input { width: 100px; accent-color: var(--accent); }
.ed-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); }
.ed-color[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.ctx-menu button svg { vertical-align: -5px; margin-right: 4px; color: var(--accent); }

/* Свайп для ответа */
.msg-row { position: relative; will-change: transform; }
.msg-row.swiping::after { content: '↩'; position: absolute; right: -34px; top: 50%; transform: translateY(-50%) scale(.6); width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); color: var(--muted); display: grid; place-items: center; font-size: 16px; opacity: .5; transition: transform .15s, opacity .15s, background .15s; }
.msg-row.swipe-ready::after { transform: translateY(-50%) scale(1); opacity: 1; background: var(--accent); color: #fff; }
.messages { overflow-x: hidden; }

/* Стикеры */
.bubble.kind-sticker { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.sticker { width: 150px; height: 150px; display: block; object-fit: contain; animation: pop-in .25s ease; }
.sticker-fallback { font-size: 64px; line-height: 1.1; }
.bubble.kind-sticker .meta { float: none; display: inline-flex; margin: 2px 4px 0; background: rgba(0,0,0,.3); color: #fff; padding: 1px 7px; border-radius: 10px; }

/* Меню сообщения */
.ctx-menu { animation: menu-in .14s ease-out; }
@keyframes menu-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.msg-menu { min-width: 210px; max-width: min(330px, calc(100vw - 16px)); padding: 6px; border-radius: 16px; }
.ctx-menu button { display: flex; align-items: center; gap: 12px; }
.ctx-menu button svg { flex: none; color: var(--muted); margin: 0; vertical-align: 0; }
.ctx-menu button.danger svg { color: var(--danger); }
.msg-menu .react-pick { display: flex; flex-wrap: nowrap; gap: 0; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.msg-menu .react-pick button { font-size: 22px; padding: 4px; width: 36px; height: 36px; flex: none; justify-content: center; border-radius: 50%; transition: transform .12s; }
.msg-menu .react-pick button:active { transform: scale(1.25); }
.msg-menu .react-pick .react-more { background: var(--panel-2); color: var(--muted); }

/* Панель эмодзи / стикеров / GIF */
.pk-backdrop { position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.18); display: flex; align-items: flex-end; justify-content: center; animation: fade-in .15s; }
.emo-panel { background: var(--panel); width: 100%; height: min(52vh, 420px); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: sheet-up .2s ease; }
.emo-panel.floating { position: fixed; width: 360px; height: 400px; border-radius: 16px; animation: menu-in .15s ease-out; }
@keyframes sheet-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.pk-tabs { display: flex; gap: 4px; padding: 8px 8px 0; }
.pk-tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px; border-radius: 10px; font-weight: 600; }
.pk-tabs button.on { background: var(--panel-2); color: var(--text); }
.pk-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pk-search { margin: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; outline: none; }
.pk-grid { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.pk-h { font-size: 12px; color: var(--muted); padding: 8px 4px 4px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.pk-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.pk-e { font-size: 24px; height: 40px; border: 0; background: none; border-radius: 8px; padding: 0; line-height: 1; }
.pk-e:hover { background: var(--panel-2); }
.pk-cells.st { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; }
.pk-st { border: 0; background: none; padding: 4px; border-radius: 10px; aspect-ratio: 1; }
.pk-st:hover { background: var(--panel-2); }
.pk-st img { width: 100%; height: 100%; object-fit: contain; }
.pk-backdrop.pk-docked { position: static; flex: 0 1 auto; min-height: 0; background: var(--panel); z-index: auto; }
.pk-docked .emo-panel { height: min(36dvh, 350px); max-height: 100%; border-radius: 0; box-shadow: none; }
.pk-grid.gifs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(104px, 100%), 1fr)); grid-auto-rows: clamp(80px, 24vw, 112px); gap: 6px; align-content: start; min-height: 0; overflow-x: hidden; touch-action: pan-y; overscroll-behavior: contain; }
.pk-gif { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; border: 0; padding: 0; margin: 0; border-radius: 8px; overflow: hidden; background: var(--panel-2); break-inside: avoid; }
.pk-gif img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pk-nav { display: flex; justify-content: space-around; border-top: 1px solid var(--line); padding: 4px; }
.pk-nav button { border: 0; background: none; font-size: 18px; padding: 6px; border-radius: 8px; }
.pk-empty { padding: 30px 10px; text-align: center; }
.pk-credit { text-align: right; padding: 2px 10px 6px; }
.emoji-btn { flex: none; }

/* Фон чата */
.messages-wrap { background-color: var(--chat-bg, transparent); background-size: cover; background-position: center; }
.messages-wrap.has-wall { background-image: var(--chat-wall); }
.messages-wrap.has-wall .day-sep span, .messages-wrap.has-wall .e2e-note, .messages-wrap.has-wall .sys-msg span { backdrop-filter: blur(6px); }
.wall-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.wall-pick button { aspect-ratio: 3 / 4; border-radius: 10px; border: 2px solid var(--line); background-size: cover; background-position: center; position: relative; }
.wall-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.wall-pick button.add { display: grid; place-items: center; color: var(--muted); background: var(--panel-2); font-size: 13px; }
.wall-pick button .wl { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 10px; color: var(--muted); text-align: center; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-edit textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--panel-2); color: var(--text); font: inherit; resize: vertical; }
.profile-details { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; background: var(--panel-2); border-radius: 12px; margin: 10px 0; }
.pd-bio { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Плавные анимации */
.modal { animation: modal-in .2s cubic-bezier(.2,.8,.3,1); }
@keyframes modal-in { from { transform: translateY(12px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) {
  .backdrop { align-items: flex-end; padding: 0; }
  .backdrop .modal { border-radius: 18px 18px 0 0; max-height: 94vh; animation: sheet-up .22s cubic-bezier(.2,.8,.3,1); padding-bottom: env(safe-area-inset-bottom); }
  body.in-chat .chat-pane { animation: pane-in .22s cubic-bezier(.2,.8,.3,1); }
  body:not(.in-chat) .sidebar { animation: fade-in .18s ease; }
}
@keyframes pane-in { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
.msg-row.appear { animation: msg-in .22s cubic-bezier(.2,.8,.3,1); }
.msg-row.out.appear { transform-origin: right bottom; }
@keyframes msg-in { from { transform: translateY(10px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { animation: slide-down .2s ease; }
.icon-btn, .btn, .send-btn, .call-btn { transition: transform .12s ease, filter .15s, background .15s; }
.icon-btn:active, .btn:active, .send-btn:active, .call-btn:active { transform: scale(.93); }
.chat-item { transition: background .15s; }
.composer .reply-bar, .composer .edit-bar { animation: slide-down .18s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.lock-btn svg { width: 20px; height: 20px; }
.report { display: flex; flex-direction: column; gap: 10px; }
.report textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); color: var(--text); font: inherit; resize: vertical; min-height: 120px; }
.rep-shots { display: flex; gap: 8px; flex-wrap: wrap; }
.rep-shot, .rep-add { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; position: relative; }
.rep-shot img { width: 100%; height: 100%; object-fit: cover; }
.rep-shot button { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.rep-add { border: 2px dashed var(--line); background: var(--panel-2); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; }
/* Узкий экран: кнопки звонка помещаются в ширину */
.call-overlay:not(.mini) .call-controls { flex-wrap: wrap; justify-content: center; row-gap: 12px; max-width: 100%; }
@media (max-width: 400px) {
  .call-overlay:not(.mini) .call-controls { gap: 10px; }
  .call-overlay:not(.mini) .call-btn { width: 52px; height: 52px; }
  .call-overlay:not(.mini) .call-btn-wrap { width: 60px; }
  .call-overlay:not(.mini) .call-btn-wrap span { font-size: 11px; }
}

/* 1.8.1: голосовое компактнее */
.voice-box { width: min(350px, calc(78vw - 44px)); max-width: 100%; min-width: 0; gap: 8px; }
.voice-play { width: 36px; height: 36px; }
.voice-main { min-width: 110px; }

/* 1.8.1: меню сообщения — уже, раскрывается из точки вызова, пункты появляются по очереди */
.ctx-menu { overflow-y: auto; animation: menu-open .2s cubic-bezier(.2,.9,.3,1.15); }
@keyframes menu-open { from { transform: scale(.55); opacity: 0; } to { transform: none; opacity: 1; } }
.ctx-menu > * { animation: menu-item .22s ease both; animation-delay: calc(var(--i, 0) * 22ms + 40ms); }
@keyframes menu-item { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.msg-menu { min-width: 0; width: 236px; max-width: calc(100vw - 16px); padding: 5px; }
.msg-menu > button { padding: 8px 10px; font-size: 14.5px; gap: 10px; }
.msg-menu .react-pick { justify-content: space-between; overflow: visible; padding: 2px 0 5px; }
.msg-menu .react-pick button { width: 31px; height: 31px; font-size: 20px; padding: 0; display: grid; place-items: center; }

/* 1.8.2 */
/* Ответ/правка: длинный текст обрезается многоточием и не раздвигает экран */
.edit-bar { min-width: 0; max-width: 100%; }
.edit-bar .grow { flex: 1 1 0; min-width: 0; overflow: hidden; }
.edit-bar .edit-title, .edit-bar .edit-orig { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar > svg, .edit-bar > .icon-btn { flex: none; }
.chat-pane, .composer { min-width: 0; max-width: 100vw; }
.composer textarea { min-width: 0; }
/* Строка ввода ниже и плотнее, значки меньше на 30% */
.composer { padding: 4px 8px; padding-bottom: max(4px, env(safe-area-inset-bottom)); gap: 4px; }
.composer textarea { padding: 7px 12px; }
.composer .send-btn { width: 32px; height: 32px; margin-bottom: 2px; }
.composer .send-btn svg { width: 18px; height: 18px; }
.composer .attach-btn, .composer .emoji-btn { width: 30px; height: 30px; margin: 0 0 3px; }
.composer .attach-btn svg, .composer .emoji-btn svg { width: 17px; height: 17px; }
/* Видео качается — на превью крутится индикатор */
.video-box.fetching .video-play { background: rgba(0,0,0,.65); }
.video-box.fetching .video-play svg { opacity: 0; }
.video-box.fetching .video-play::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin .8s linear infinite; }
.video-box .progress { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; }

/* 1.8.3 */
/* Шапка чата — по высоте аватара */
.chat-head { min-height: 0; padding: 4px 8px; }
.chat-head .icon-btn { width: 36px; height: 36px; }
.chat-title { font-size: 15px; line-height: 1.2; }
.chat-sub { font-size: 12px; line-height: 1.2; }
@media (max-width: 760px) { .chat-head { padding: 3px 4px; } }
/* Голосовое: эквалайзер на одной линии с кнопкой, время — справа */
.voice-main { display: flex; align-items: center; gap: 8px; }
.voice-main .wave { flex: 1; }
.voice-time { flex: none; white-space: nowrap; }
/* Загрузка — круг заполняется по мере скачивания, без вращения */
.voice-play.loading > .ring-progress, .round-box.loading > .ring-progress { animation: none; }
.ring-progress { transform: rotate(0); transition: opacity .2s; }
.video-play > .ring-progress { inset: 0; background: conic-gradient(#fff calc(var(--load-fraction,var(--p,0)) * 360deg), rgba(255,255,255,.25) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); }
.video-play.loading svg { opacity: 0; }
.video-play.loading { background: rgba(0,0,0,.65); }
.video-box.fetching .video-play::after { display: none; }
/* Кружок: исходное видео камеры стоит на странице, но не видно */
.round-src { position: absolute; width: 2px; height: 2px; opacity: .01; pointer-events: none; left: 0; top: 0; }
.round-wait { position: absolute; inset: 0; display: none; place-items: center; color: #fff; font-size: 14px; background: #111; }
.round-stage.starting .round-wait { display: grid; }
/* Проигрыватель видео */
.video-viewer { flex-direction: column; background: #000; }
.vp-stage { position: relative; flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.vp-stage video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; background: #000; }
.vp-big { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); transition: opacity .2s, transform .2s; }
.vp-big.hidden { display: grid; opacity: 0; pointer-events: none; transform: translate(-50%, -50%) scale(1.3); }
.vp-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 26px 10px max(10px, env(safe-area-inset-bottom)); color: #fff; font-size: 13px; background: linear-gradient(transparent, rgba(0,0,0,.75)); transition: opacity .25s; font-variant-numeric: tabular-nums; }
.vp-btn { color: #fff; width: 36px; height: 36px; }
.vp-btn.off { opacity: .45; }
.vp-seek { flex: 1; min-width: 0; height: 22px; -webkit-appearance: none; appearance: none; background: transparent; }
.vp-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p, 0%), rgba(255,255,255,.3) var(--p, 0%)); }
.vp-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; }
.video-viewer .viewer-bar { transition: opacity .25s; }
.viewer.controls-hidden :is(.viewer-bar,.viewer-nav,.vp-bar,.vp-big,.photo-download) { opacity:0;visibility:hidden;pointer-events:none }
.vp-error { position: absolute; left: 20px; right: 20px; top: 50%; transform: translateY(-50%); color: #fff; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.vp-error.hidden { display: none; }
.vp-stage video { position: absolute; inset: 0; max-width: none; max-height: none; }

/* 1.8.5 */
/* Масштабирование двумя пальцами отключено (кроме редактора фото и просмотра картинок) */
html, body { touch-action: pan-x pan-y; }
/* Миниатюры в ответах и в списке чатов */
.quote { display: flex; align-items: center; gap: 8px; }
.quote-body { min-width: 0; flex: 1; }
.quote-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; }
.quote-thumb.hidden { display: none; }
.last-with-thumb { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; vertical-align: bottom; }
.last-with-thumb > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-thumb { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; flex: none; }
/* Кружок со звуком — крупнее */
.round-box { transition: width .25s cubic-bezier(.2,.8,.3,1), height .25s cubic-bezier(.2,.8,.3,1); }
.round-box.playing { width: min(78vw, 340px); height: min(78vw, 340px); }

/* 1.8.6: исправления отображения */
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-title > svg, .chat-title > .verified, .chat-item-title > svg, .chat-item-title > .muted-ic { flex: none; }
.chat-head-text { overflow: hidden; }
.pk-grid.gifs .pk-empty { grid-column: 1 / -1; }
.set-row:has(.theme-pick) > :first-child { flex: none; overflow-wrap: normal; }
.set-row:has(.theme-pick) { flex-wrap: wrap; }
@media (max-width: 400px) { .theme-pick button { padding: 6px 9px; font-size: 13.5px; } }
.switch-row > span { min-width: 0; flex: 1; }
.call-overlay.mini.has-video .call-center { max-width: calc(100% - 20px); }

/* 1.8.8 — цитата по ширине своего содержимого, а не всего сообщения; миниатюра отделена от текста */
.bubble .quote { width: fit-content; max-width: 100%; min-width: 120px; box-sizing: border-box; padding: 4px 10px 4px 4px; gap: 9px; }
.bubble .quote:not(:has(.quote-thumb:not(.hidden))) { padding-left: 8px; }
.bubble .quote .quote-thumb { width: 40px; height: 40px; border-radius: 5px; }

/* 1.9.0 — отмена загрузки видео: крестик внутри кольца; просмотр закрывается смахиванием */
.video-play.loading::before { content: ''; position: absolute; z-index: 1; width: 18px; height: 18px;
  background: linear-gradient(45deg, transparent 44%, #fff 44%, #fff 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, #fff 44%, #fff 56%, transparent 56%); }
.viewer { touch-action: none; overscroll-behavior: contain; }
.viewer img, .vp-stage { will-change: transform; }

/* 1.9.1 — качество видео */
.video-q { position: absolute; right: 6px; top: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; pointer-events: none; }
.video-q.busy { opacity: .8; font-weight: 500; }
.vp-quality { border: 0; border-radius: 16px; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; font-size: 13px; padding: 0 12px; height: 36px; min-width: 56px; align-self: center; }
.vp-quality.busy { background: rgba(255,255,255,.25); }

/* 1.9.2 — фото/видео с подписью: сообщение по ширине фото, подпись переносится под ним */
.bubble.kind-image:has(> .photo-box), .bubble.kind-album:has(> .album) { width: min-content; }
.bubble.kind-image > .photo-box > .photo { min-width: 190px; max-width: min(320px, 72vw); }
.bubble.kind-image > .text, .bubble.kind-album > .text { display: block; padding-top: 2px; }
.bubble.kind-image > .sender, .bubble.kind-album > .sender { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emo-panel.compact .pk-search:not(.pk-gif-search) { display: none; }
.emo-panel.compact .pk-tabs button { padding-top: 5px; padding-bottom: 5px; }

/* 1.9.3 — «Что нового» */
.changelog { display: flex; flex-direction: column; gap: 16px; }
.cl-ver { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; font-size: 15px; }
.cl-kind { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 2px; color: var(--muted); }
.cl-kind.added { color: #2e9e5b; } .cl-kind.changed { color: var(--accent); } .cl-kind.fixed { color: #d98a1f; }
.changelog ul { margin: 0; padding-left: 18px; }
.changelog li { margin: 3px 0; line-height: 1.35; }

/* 1.9.4 — ниже полоса разделов смайликов; резервная копия */
.pk-nav { padding: 0 4px; }
.pk-nav button { font-size: 16px; padding: 3px 6px; line-height: 1.15; }
.bk-form { display: flex; flex-direction: column; gap: 10px; }
.bk-form input[type=password] { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; }
.bk-progress { display: flex; flex-direction: column; gap: 4px; }
.bk-progress.hidden { display: none; }

.viewer .viewer-bar .icon-btn, .viewer .viewer-nav, .viewer .vp-big, .viewer .vp-btn {
  color:#fff;background:rgba(18,20,27,.85);border:1px solid rgba(255,255,255,.62);
  box-shadow:0 2px 8px rgba(0,0,0,.36);
}
.viewer-count:not(:empty) {align-self:center;border-radius:16px;padding:4px 9px;background:rgba(18,20,27,.85)}
.viewer .vp-bar {background:linear-gradient(transparent,rgba(0,0,0,.88) 55%)}
.viewer .vp-btn.off {opacity:1;color:#ccc}

.member-avatar { background:transparent;border:0;padding:0;cursor:pointer }
.member-directory input[type=search] { width:100%;padding:10px;border-radius:12px;background:var(--panel-2);color:var(--text);border:1px solid var(--line) }
.fm-file { display:flex;align-items:center;gap:10px;min-width:0;cursor:pointer }
.fm .set-row > .fm-thumb { flex:none;object-fit:contain;background:var(--panel-2) }
.filename-line {display:block;overflow-wrap:anywhere}
.fm-filename, .sp-info .sp-name {display:block;white-space:normal;overflow-wrap:anywhere}
.fm > *, .fm-file > .grow {min-width:0}
.fm .set-row > .icon-btn, .fm input[type=checkbox] {flex:none}
.fm .fm-list > .set-row {display:grid;grid-template-columns:minmax(0,1fr) 40px}
.fm > strong, .fm .set-link {overflow-wrap:anywhere}
.settings-choice + .settings-choice {margin-top:8px}
.settings-choice > .icon {color:var(--accent)}
.fm-thumb { width:52px;height:52px;object-fit:cover;border-radius:9px }
.camera-stage { width:fit-content;max-width:100%;margin:auto;position:relative;background:#111;line-height:0;text-align:center }
.camera-stage video,.camera-stage img { max-width:100%;max-height:56vh;width:auto;height:auto }
.camera-focus { position:absolute;width:44px;height:44px;border:2px solid white;border-radius:8px;transform:translate(-50%,-50%);pointer-events:none }
.camera-controls {display:flex;justify-content:center;align-items:center;gap:8px;flex-wrap:wrap;padding:14px 0 6px}
.camera-shutter {border-radius:50%;background:white;border:4px solid #292c37;outline:2px solid #9599a6;width:60px;height:60px;cursor:pointer}
.photo-viewer .photo-stage { width:100%;height:100%; }
.photo-viewer .photo-stage img { width:100%;height:100%;max-width:none;max-height:none;object-fit:cover; }
.video-viewer .vp-stage video {object-fit:cover}
.media-fit.photo-viewer .photo-stage img,.media-fit.video-viewer video {object-fit:contain}
@property --load-fraction {syntax:'<number>';inherits:false;initial-value:0}
.ring-progress {--load-fraction:var(--p,0);transition:opacity .2s,--load-fraction .25s linear}
.photo-transfer-ring {--load-fraction:var(--p,0);transition:--load-fraction .25s linear}
.progress > div {transition:width .25s linear}
.voice-main {min-width:0}
.voice-main .voice-time {font-variant-numeric:tabular-nums}
@media(max-width:480px){.voice-main {flex-wrap:wrap}.voice-main .wave {flex-basis:100%}}
.fm { display:grid; grid-template-columns:minmax(0,1fr); gap:14px; min-width:0; max-width:100%; }
.fm input[type=search], .settings-category input[type=search] { width:100%; border:1px solid var(--line); border-radius:14px; padding:12px; background:var(--panel-2); color:var(--text); }
.fm-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.fm-actions button { display:grid; justify-items:center; text-align:center; gap:12px; padding:14px; border-radius:14px; background:color-mix(in srgb,var(--accent) 12%,var(--panel)); }
.fm-tabs { display:flex; gap:4px; flex-wrap:wrap; }
.fm-tabs [aria-pressed=true] {background:var(--accent);color:white}
.fm small {display:block}
.fm-type {padding:10px;border-radius:8px;background:var(--panel-2);font-size:12px}
.fm .grow {overflow-wrap:anywhere}
.fm .set-row {gap:10px;justify-content:space-between}
.fm h4 {margin:0}
.fm-footer {flex:none;align-items:center;border-top:1px solid var(--line);padding:12px 16px}
.fm-footer .btn {flex:1;min-width:0;min-height:44px}
.settings-category { border-bottom: 1px solid var(--line); }
.settings-category > summary { padding: 14px 4px; cursor: pointer; font-weight: 600; }
.settings-items { padding: 0 4px 14px; }
.settings-items .set-row select { max-width: 48%; }

.ve-editor { display:grid;gap:14px }
.ve-stage { display:grid;place-items:center;background:#101116;border-radius:14px;overflow:hidden;height:min(33dvh,330px) }
.ve-stage canvas { display:block;max-width:100%;max-height:100%;min-height:0;object-fit:contain }
.ve-controls { display:grid;gap:12px;border:0;padding:0;margin:0;min-width:0 }
.ve-actions,.ve-format,.ve-foot { display:flex;gap:8px;align-items:center;flex-wrap:wrap }
.ve-format,.ve-foot { justify-content:space-between }
.ve-actions .btn { display:inline-flex;align-items:center;gap:5px }
.ve-controls input { accent-color:var(--accent) }
.ve-format select { font:inherit;background:var(--panel-2);color:var(--text);border:1px solid var(--line);border-radius:10px;padding:7px }
.ve-trim { display:grid;grid-template-columns:1fr auto;align-items:center;font-size:14px }
.ve-trim output,.ve-status { color:var(--muted);font-variant-numeric:tabular-nums }
.ve-trim input { grid-column:1/-1;width:100%;height:28px;margin:0 }

.lc-initial {width:64px;height:64px;border-radius:6px;display:grid;place-items:center;flex:none;background:var(--accent-soft);color:var(--accent);font-size:26px;font-weight:700}
.youtube-message { cursor:pointer }
.viewer.yt-view { align-items:stretch; flex-direction:column; background:#000 }
.yt-toolbar { display:flex; align-items:center; justify-content:space-between; padding:max(4px,env(safe-area-inset-top)) 12px 4px; }
.yt-toolbar .icon-btn, .yt-toolbar a { color:#fff }
.yt-frame { flex:1; width:100%; min-height:0; border:0; background:#000 }

.link-card.lc-youtube { display:grid; gap:8px; width:min(320px,100%); padding:0 0 8px; overflow:hidden }
.lc-youtube .lc-body { padding:0 10px }
.lc-video-cover { position:relative; display:grid; place-items:center; aspect-ratio:16/9; background:#191b24 }
.lc-youtube .lc-video-cover img { position:absolute; inset:0; width:100%; height:100%; border-radius:0 }
.lc-video-play { position:relative; display:grid; place-items:center; width:44px; height:44px; border-radius:50%; background:rgba(0,0,0,.7); color:#fff }
.draft-preview .lc-youtube { display:flex; align-items:center; width:100%; padding:5px 8px }
.draft-preview .lc-video-cover { width:92px; flex:none; border-radius:5px; overflow:hidden }
.draft-preview .lc-video-play { width:30px; height:30px }

.fm-audio-thumb {display:grid;place-items:center;width:52px;height:52px;flex:none;overflow:hidden;border-radius:9px}
.fm-audio-thumb .fm-type {padding:6px;font-size:10px}
.file-audio-cover {width:48px;height:48px;object-fit:cover;border-radius:8px;flex:none}
.ae-editor,.ae-controls {display:grid;gap:12px}
.ae-controls {min-width:0;border:0;margin:0;padding:0}
.ae-controls input {accent-color:var(--accent)}
.ae-header {display:flex;gap:12px;align-items:center;min-width:0}
.ae-cover {width:58px;height:58px;object-fit:cover;border-radius:10px}
.ae-name {overflow-wrap:anywhere}

.fm-audio-thumb > * {grid-area:1/1}
.fm-audio-thumb > img:not([src]), .fm-audio-thumb > img[src]:not([hidden]) + .fm-type {display:none}

.ve-size {margin:0;font-variant-numeric:tabular-nums}
