/* LocalMess — интерфейс в стиле Telegram Web. Светлая и тёмная темы. */
:root {
  --accent: #3390ec;
  --accent-hover: #2c80d6;
  --bg: #ffffff;
  --surface: #ffffff;
  --hover: #f4f4f5;
  --text: #000000;
  --text-2: #707579;
  --border: #dadce0;
  --input-bg: #f4f4f5;
  --danger: #e53935;
  --online: #4fbf4f;
  --away: #f5b82e;
  --offline: #a8adb2;
  --chat-bg: #a3be8c;
  --chat-pattern: radial-gradient(circle at 15% 20%, rgba(255,255,230,.55) 0, transparent 45%),
                  radial-gradient(circle at 85% 30%, rgba(200,230,170,.6) 0, transparent 40%),
                  radial-gradient(circle at 40% 85%, rgba(160,200,140,.6) 0, transparent 45%),
                  linear-gradient(160deg, #d4e2b6 0%, #a9c79a 50%, #8fb98b 100%);
  --bubble-in: #ffffff;
  --bubble-out: #e3fee0;
  --meta-in: #8d969c;
  --meta-out: #5ea35a;
  --tick: #8fa79a;
  --tick-read: #3390ec;
  --shadow: 0 1px 2px rgba(16,35,47,.15);
  --chat-active: #3390ec;
  --badge: #3390ec;
  --badge-muted: #c4c9cc;
  --date-chip: rgba(74,107,64,.45);
  --radius: 12px;
  --sidebar-w: 420px;
  color-scheme: light;
}
[data-theme="dark"] {
  --accent: #6ab3f3;
  --accent-hover: #5aa2e0;
  --bg: #212121;
  --surface: #212121;
  --hover: #2c2c2c;
  --text: #ffffff;
  --text-2: #aaaaaa;
  --border: #0f0f0f;
  --input-bg: #181818;
  --chat-bg: #0e1621;
  --chat-pattern: radial-gradient(circle at 20% 20%, rgba(40,70,100,.5) 0, transparent 45%),
                  radial-gradient(circle at 80% 70%, rgba(30,55,80,.55) 0, transparent 45%),
                  linear-gradient(160deg, #10202f 0%, #0e1621 60%, #0b131c 100%);
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --meta-in: #6d7f8f;
  --meta-out: #7da8d3;
  --tick: #7d97b0;
  --tick-read: #6ab3f3;
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --chat-active: #2b5278;
  --badge: #3e88c7;
  --badge-muted: #3d444b;
  --date-chip: rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Roboto, "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.hidden { display: none !important; }

/* ---------- Аватары ---------- */
.avatar {
  position: relative; flex: none; width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 500; font-size: 20px; text-transform: uppercase; user-select: none;
  background: linear-gradient(var(--c1), var(--c2));
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar.lg { width: 120px; height: 120px; font-size: 44px; }
.avatar .dot {
  position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid var(--surface); background: var(--offline);
}
.avatar.sm .dot { width: 12px; height: 12px; right: 0; bottom: 0; }
.dot.online { background: var(--online); }
.dot.away { background: var(--away); }
.dot.offline, .dot.never { background: var(--offline); }
.av-0 { --c1: #ff885e; --c2: #ff516a; }
.av-1 { --c1: #ffcd6a; --c2: #ffa85c; }
.av-2 { --c1: #82b1ff; --c2: #665fff; }
.av-3 { --c1: #a0de7e; --c2: #54cb68; }
.av-4 { --c1: #53edd6; --c2: #28c9b7; }
.av-5 { --c1: #72d5fd; --c2: #2a9ef1; }
.av-6 { --c1: #e0a2f3; --c2: #d669ed; }

/* ---------- Экраны входа ---------- */
.screen { height: 100%; }
.auth { display: flex; align-items: flex-start; justify-content: center; overflow: auto; background: var(--bg); }
.auth-card { width: 360px; max-width: calc(100% - 32px); margin: 8vh 0 32px; display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.auth-logo { width: 140px; height: 140px; align-self: center; margin-bottom: 24px; }
.auth-card h1 { font-size: 32px; font-weight: 500; margin: 0 0 8px; }
.auth-hint { color: var(--text-2); margin: 0 0 32px; font-size: 15px; line-height: 1.35; }
#reg-office-hint { margin: 12px 0 0; font-size: 13px; text-align: center; }
.field { position: relative; display: block; margin-bottom: 20px; text-align: left; }
.field input, .field select {
  width: 100%; height: 54px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent; outline: none; font-size: 16px;
  transition: border-color .15s;
}
[data-theme="dark"] .field input, [data-theme="dark"] .field select { border-color: #3a3a3a; }
.field input:hover { border-color: var(--accent); }
.field input:focus { border: 2px solid var(--accent); padding: 0 15px; }
.field span {
  position: absolute; left: 12px; top: 16px; padding: 0 4px; color: var(--text-2);
  background: var(--surface); pointer-events: none; transition: transform .15s, color .15s, font-size .15s;
  transform-origin: left;
}
.field input:focus + span, .field input:not(:placeholder-shown) + span {
  transform: translateY(-27px) scale(.8); color: var(--accent);
}
.field input:not(:focus):not(:placeholder-shown) + span { color: var(--text-2); }
.form-error { color: var(--danger); min-height: 20px; margin: -8px 0 12px; font-size: 14px; text-align: left; }
.btn-primary {
  height: 54px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 500; font-size: 16px; text-transform: uppercase; letter-spacing: .3px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-link { background: none; border: 0; color: var(--accent); margin-top: 16px; padding: 8px; }
.lang-switch { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.lang-switch button { background: none; border: 0; color: var(--accent); padding: 6px 10px; border-radius: 8px; }
.lang-switch button:hover { background: var(--hover); }
.lang-switch button.active { color: var(--text-2); cursor: default; background: none; }

/* ---------- Основная раскладка ---------- */
.main { display: flex; }
.sidebar {
  width: var(--sidebar-w); min-width: 300px; max-width: 40vw; height: 100%;
  display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--border); position: relative;
}
.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; height: 56px; position: relative; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; flex: none; transition: background .15s;
}
.icon-btn:hover { background: var(--hover); }
.search {
  flex: 1; height: 42px; border-radius: 22px; background: var(--input-bg); display: flex; align-items: center;
  padding: 0 14px; gap: 10px; color: var(--text-2); border: 2px solid transparent;
}
.search:focus-within { border-color: var(--accent); background: var(--surface); color: var(--accent); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); min-width: 0; }
.search svg { width: 22px; height: 22px; }

.dropdown {
  position: absolute; top: 52px; left: 8px; z-index: 30; min-width: 260px; padding: 6px 0;
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.04);
  animation: pop .12s ease-out;
}
[data-theme="dark"] .dropdown { background: #2a2a2a; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.dropdown button {
  width: calc(100% - 12px); margin: 0 6px; display: flex; align-items: center; gap: 18px; padding: 9px 12px;
  background: none; border: 0; border-radius: 8px; text-align: left; font-size: 15px; font-weight: 500;
}
.dropdown button:hover { background: var(--hover); }
.dropdown button svg { color: var(--text-2); width: 22px; height: 22px; }
.dropdown button.danger, .dropdown button.danger svg { color: var(--danger); }
.dropdown .menu-value { margin-left: auto; color: var(--text-2); font-weight: 400; font-size: 14px; }
.toggle { margin-left: auto; width: 34px; height: 14px; border-radius: 7px; background: var(--badge-muted); position: relative; }
.toggle::after { content: ""; position: absolute; left: -2px; top: -3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--badge-muted); transition: left .15s; box-sizing: border-box; }
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 16px; border-color: var(--accent); }
body:not(.is-admin) .admin-only { display: none !important; }

.notify-banner {
  margin: 4px 12px 8px; padding: 10px 12px; border-radius: 10px; background: var(--input-bg);
  font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 10px;
}
.notify-banner button { margin-left: auto; border: 0; background: var(--accent); color: #fff; border-radius: 8px; padding: 6px 12px; font-size: 14px; white-space: nowrap; }
.conn-state { text-align: center; font-size: 13px; color: var(--text-2); padding: 4px; }

/* ---------- Список чатов ---------- */
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.list-section { color: var(--text-2); font-size: 15px; font-weight: 500; padding: 12px 10px 6px; }
.list-empty { color: var(--text-2); font-size: 15px; text-align: center; padding: 40px 20px; line-height: 1.4; }
.chat-item {
  display: flex; align-items: center; gap: 12px; padding: 9px; border-radius: 12px; cursor: pointer;
  height: 72px; user-select: none;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--chat-active); color: #fff; }
.chat-item.active .ci-text, .chat-item.active .ci-time, .chat-item.active .ci-tick { color: #fff; }
.chat-item.active .avatar .dot { border-color: var(--chat-active); }
.chat-item.active .ci-badge { background: #fff; color: var(--chat-active); }
.ci-body { flex: 1; min-width: 0; }
.ci-row { display: flex; align-items: center; gap: 6px; }
.ci-name { flex: 1; font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--text-2); flex: none; }
.ci-text { flex: 1; color: var(--text-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.ci-text .ci-you { color: var(--accent); }
.chat-item.active .ci-text .ci-you { color: #fff; }
.ci-text.typing { color: var(--accent); }
.ci-badge {
  flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--badge);
  color: #fff; font-size: 13px; font-weight: 500; display: flex; align-items: center; justify-content: center; margin-top: 3px;
}
.ci-tick { color: var(--tick-read); display: inline-flex; }
.ci-tick svg { width: 18px; height: 18px; }
.ci-tick.sent, .ci-tick.delivered { color: var(--text-2); }
.ci-login { color: var(--text-2); font-size: 14px; }

/* ---------- Окно чата ---------- */
.chat { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; position: relative;
  background: var(--chat-bg); background-image: var(--chat-pattern); background-size: cover; }
.chat-placeholder { display: none; }
.chat.empty .chat-placeholder { display: flex; flex: 1; align-items: center; justify-content: center; }
.chat-placeholder span { background: var(--date-chip); color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 15px; font-weight: 500; }
.chat.empty .pin-bar, .chat.empty .chat-header, .chat.empty .messages, .chat.empty .composer, .chat.empty .scroll-down, .chat.empty .drop-overlay { display: none !important; }
.header-search { margin-left: auto; }

.chat-header {
  height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px 0 12px;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.06); z-index: 2;
}
.back-btn { display: none; }
.chat-header-info { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: default; }
.chat-header-text { min-width: 0; }
.chat-title { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { font-size: 14px; color: var(--text-2); }
.chat-status.online, .chat-status.typing { color: var(--accent); }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; }
.messages-inner { max-width: 728px; margin: 0 auto; padding: 8px 16px 8px; display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.load-more { align-self: center; color: #fff; background: var(--date-chip); border-radius: 12px; padding: 4px 12px; font-size: 13px; margin: 8px 0; }
.date-chip { align-self: center; position: sticky; top: 8px; z-index: 1; margin: 10px 0; padding: 4px 10px;
  border-radius: 14px; background: var(--date-chip); color: #fff; font-size: 14px; font-weight: 500; }

.msg { display: flex; margin-top: 2px; }
.msg.out { justify-content: flex-end; }
.msg.group-start { margin-top: 8px; }
.bubble {
  position: relative; max-width: min(480px, 85%); padding: 6px 9px 7px 11px; border-radius: 15px;
  background: var(--bubble-in); box-shadow: var(--shadow); font-size: 15.5px; line-height: 1.33;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.in.group-end .bubble { border-bottom-left-radius: 4px; }
.msg.out.group-end .bubble { border-bottom-right-radius: 4px; }
/* «хвостик» у последнего сообщения в группе */
.msg.group-end .bubble::before {
  content: ""; position: absolute; bottom: 0; width: 11px; height: 18px; background: inherit;
}
.msg.in.group-end .bubble::before { left: -6px; clip-path: path("M11 0v18H0c4-1.5 9-6 11-18z"); }
.msg.out.group-end .bubble::before { right: -6px; clip-path: path("M0 0v18h11C7 16.5 2 12 0 0z"); }
.bubble a { color: var(--accent); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
.meta {
  float: right; display: inline-flex; align-items: center; gap: 2px; margin: 8px -2px -4px 10px;
  font-size: 12px; color: var(--meta-in); white-space: nowrap; line-height: 1; user-select: none; position: relative; top: 3px;
}
.msg.out .meta { color: var(--meta-out); }
.tick { display: inline-flex; color: var(--tick); }
.tick svg { width: 19px; height: 19px; margin-left: 1px; }
.tick.read { color: var(--tick-read); }
.tick.pending svg { width: 14px; height: 14px; margin: 0 2px 0 3px; }
.tick.failed { color: var(--danger); }
.msg.failed .bubble { opacity: .8; }

.scroll-down {
  position: absolute; right: 20px; bottom: 80px; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--text-2); box-shadow: 0 1px 4px rgba(0,0,0,.2); display: flex;
  align-items: center; justify-content: center; z-index: 3;
}
.scroll-down .badge { position: absolute; top: -6px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--badge); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; }

.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; max-width: 760px; width: 100%; margin: 0 auto; padding: 6px 16px 16px; }
.composer-main { flex: 1; min-width: 0; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.composer-box { display: flex; align-items: flex-end; min-height: 54px; padding: 0 12px 0 4px; }
.attach-btn { margin-bottom: 7px; }
.attach-btn svg { transform: rotate(45deg); }
.composer-bar { display: flex; align-items: center; gap: 12px; padding: 6px 4px 0 14px; }
.cb-icon { color: var(--accent); }
.cb-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; }
.cb-title { color: var(--accent); font-size: 14px; font-weight: 500; }
.cb-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.send-btn .ic-save { display: none; }
.send-btn.editing .ic-send { display: none; }
.send-btn.editing .ic-save { display: block; }
.composer-box textarea {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none; font-size: 16px; line-height: 1.35;
  max-height: 260px; padding: 12px 0; overflow-y: auto;
}
.send-btn {
  width: 54px; height: 54px; flex: none; border-radius: 50%; border: 0; background: var(--surface);
  color: var(--accent); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.send-btn:hover { background: var(--accent); color: #fff; }
.send-btn svg { width: 26px; height: 26px; }

/* ---------- Ответ, вложения, правки ---------- */
.reply-quote {
  display: block; border-left: 3px solid var(--accent); border-radius: 4px; padding: 2px 8px 3px; margin: 2px 0 5px;
  background: rgba(51,144,236,.08); cursor: pointer; max-width: 100%; overflow: hidden; white-space: nowrap;
}
.msg.out .reply-quote { border-color: var(--meta-out); background: rgba(79,174,78,.12); }
[data-theme="dark"] .msg.out .reply-quote { background: rgba(255,255,255,.08); }
.rq-name { font-size: 13.5px; font-weight: 500; color: var(--accent); overflow: hidden; text-overflow: ellipsis; }
.msg.out .rq-name { color: var(--meta-out); }
.rq-text { font-size: 14px; overflow: hidden; text-overflow: ellipsis; color: var(--text); opacity: .85; }
.rq-text.muted { font-style: italic; opacity: .6; }
.meta .edited { margin-right: 4px; }

.bubble.media { padding: 0; overflow: hidden; }
.bubble.media.has-text { padding-bottom: 7px; }
.bubble.media .reply-quote { margin: 6px 8px 6px; width: calc(100% - 16px); }
.bubble.media .text { padding: 6px 9px 0 11px; display: block; }
.photo { display: block; position: relative; cursor: zoom-in; background: rgba(0,0,0,.08); max-width: 100%; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble.media:not(.has-text) .meta {
  position: absolute; right: 6px; bottom: 6px; margin: 0; top: auto; float: none; padding: 3px 6px; border-radius: 10px;
  background: rgba(0,0,0,.45); color: #fff;
}
.bubble.media:not(.has-text) .meta .tick { color: #fff; }
.bubble.media:not(.has-text) .meta .tick.read { color: #8fd0ff; }
.bubble.media:not(.has-text)::before { display: none; }
.file-card { display: flex; align-items: center; gap: 12px; padding: 4px 2px 2px 0; text-decoration: none; color: inherit; min-width: 220px; }
.file-icon {
  width: 48px; height: 48px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; text-transform: uppercase; background: #6c7a89;
}
.file-icon.pdf { background: #e5534b; } .file-icon.docx { background: #2b7cd3; } .file-icon.xlsx { background: #21a366; }
.file-icon.pptx { background: #d35230; } .file-icon.txt { background: #8a96a3; }
.file-info { min-width: 0; }
.file-name { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.file-size { font-size: 13px; color: var(--meta-in); margin-top: 2px; }
.msg.out .file-size { color: var(--meta-out); }
.bubble a.file-card { color: inherit; text-decoration: none; }
.file-card:hover .file-name { color: var(--accent); }
.removed-file { display: flex; align-items: center; gap: 8px; font-style: italic; color: var(--text-2); font-size: 14px; padding: 2px 0; }
.msg.flash .bubble { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }

.drop-overlay { position: absolute; inset: 56px 0 0 0; z-index: 4; background: rgba(51,144,236,.15); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay div { border: 3px dashed var(--accent); border-radius: 18px; padding: 40px 60px; background: var(--surface); color: var(--accent); font-size: 18px; font-weight: 500; }

.ctx { position: fixed; top: 0; left: 0; min-width: 200px; z-index: 40; }

.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 92vw; max-height: 84vh; object-fit: contain; box-shadow: 0 4px 30px rgba(0,0,0,.5); }
.viewer-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 4px; padding: 8px 12px; color: #fff; }
.viewer-name { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.12); }

.search-chip { display: inline-flex; align-items: center; gap: 4px; flex: none; max-width: 45%; background: var(--accent); color: #fff; border-radius: 12px; padding: 2px 4px 2px 10px; font-size: 13px; }
.search-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-chip button { border: 0; background: none; color: #fff; font-size: 16px; line-height: 1; padding: 0 4px; }
.found mark { background: none; color: var(--accent); font-weight: 500; }
.chat-item.active .found mark { color: #fff; text-decoration: underline; }

.send-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 46vh; overflow-y: auto; }
.send-item { display: flex; align-items: center; gap: 12px; }
.send-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.send-item .file-icon { width: 64px; height: 64px; }
.send-item .si-body { min-width: 0; flex: 1; }
.send-item .si-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-item .si-size { font-size: 13px; color: var(--text-2); }
.send-item .si-warn { font-size: 13px; color: #c98a00; }
.send-item .si-err { font-size: 13px; color: var(--danger); }
.progress { height: 4px; border-radius: 2px; background: var(--input-bg); overflow: hidden; margin: 6px 0 12px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- Группы и каналы ---------- */
.ci-name .kind-icon, .chat-title .kind-icon { width: 16px; height: 16px; vertical-align: -2px; margin-right: 4px; color: inherit; }
.msg.in.in-group { padding-left: 46px; position: relative; }
.msg.in.in-group .avatar { position: absolute; left: 0; bottom: 0; width: 38px; height: 38px; font-size: 15px; }
.sender-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; color: var(--name-c); }
.bubble.media .sender-name { padding: 6px 10px 0; }
.nc-0 { --name-c: #e17076; } .nc-1 { --name-c: #e8954c; } .nc-2 { --name-c: #8b72d8; } .nc-3 { --name-c: #4fae4e; }
.nc-4 { --name-c: #29a5ad; } .nc-5 { --name-c: #3d8fd6; } .nc-6 { --name-c: #d65db1; }
.service { align-self: center; margin: 6px 0; padding: 4px 12px; border-radius: 14px; background: var(--date-chip);
  color: #fff; font-size: 14px; font-weight: 500; max-width: 80%; text-align: center; line-height: 1.35; }
.chat-header-info.clickable { cursor: pointer; }
.readonly-bar { flex: 1; height: 54px; display: flex; align-items: center; justify-content: center; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--text-2); font-size: 15px; }
.composer.readonly .composer-main, .composer.readonly .send-btn { display: none; }
.composer.readonly .readonly-bar { display: flex !important; }

.info-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0 10px; text-align: center; }
.info-head .name { font-size: 20px; font-weight: 500; }
.info-head .sub { color: var(--text-2); font-size: 14px; }
.info-desc { white-space: pre-wrap; font-size: 15px; margin: 4px 0 8px; }
.member { display: flex; align-items: center; gap: 12px; padding: 7px 4px; border-radius: 10px; }
.member:hover { background: var(--hover); }
.member .m-body { flex: 1; min-width: 0; }
.member .m-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .m-sub { font-size: 13px; color: var(--text-2); }
.member .m-sub.online { color: var(--accent); }
.member .m-role { font-size: 12.5px; color: var(--accent); white-space: nowrap; }
.member .m-actions { display: none; gap: 4px; }
.member:hover .m-actions, .member:focus-within .m-actions { display: flex; }
.danger-zone { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pick-list { max-height: 44vh; overflow-y: auto; margin: 8px 0 12px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 6px 4px; border-radius: 10px; cursor: pointer; }
.pick:hover { background: var(--hover); }
.pick input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.pick .m-body { flex: 1; min-width: 0; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: 15px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.readers-list .member { cursor: default; }

/* Просмотры («глазик») вместо галочек */
.views { display: inline-flex; align-items: center; gap: 3px; margin-left: 5px; color: inherit; font-size: 12px;
  font-variant-numeric: tabular-nums; border-radius: 8px; padding: 0 3px; line-height: 1; }
.views svg { width: 15px; height: 15px; }
.views.clickable { cursor: pointer; }
.views.clickable:hover { background: rgba(127, 127, 127, .16); }
.bubble.media:not(.has-text) .meta .views, .bubble.emoji-only .views { color: #fff; }

/* Окно «Кто прочитал»: две колонки рядом */
.modal.modal-readers { width: 620px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; flex: none; }
.rd-summary { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.rd-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--input-bg); overflow: hidden; }
.rd-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.rd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rd-col { min-width: 0; border-radius: 10px; padding: 6px; }
.rd-col.is-read { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.rd-col.is-unread { background: var(--input-bg); }
.rd-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 6px; font-size: 13px; font-weight: 500; }
.rd-head svg { width: 16px; height: 16px; flex: none; }
.rd-head b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.is-read .rd-head { color: var(--accent); }
.is-unread .rd-head { color: var(--text-2); }
.rd-list { max-height: min(56vh, 460px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.rd-row { display: flex; align-items: center; gap: 7px; padding: 3px 4px; border-radius: 7px; min-width: 0; font-size: 13px; }
.rd-row .rd-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-row.is-read { color: var(--text); }
.rd-row.is-read .avatar { box-shadow: 0 0 0 2px var(--accent); }
.rd-row.is-unread { color: var(--text-2); }
.rd-row.is-unread .avatar { filter: grayscale(1); opacity: .55; }
.rd-empty { padding: 8px 4px; font-size: 12.5px; color: var(--text-2); }
@media (max-width: 560px) {
  .rd-cols { gap: 6px; }
  .rd-row { font-size: 12.5px; gap: 5px; }
}

/* ---------- Закреп, муты, упоминания ---------- */
.ci-badge.muted { background: var(--badge-muted); }
.ci-badge.mention { background: var(--badge); min-width: 22px; padding: 0; margin-right: 4px; font-weight: 700; }
.ci-badge.dot-only { min-width: 12px; width: 12px; height: 12px; padding: 0; margin-top: 8px; }
.ci-pin, .ci-muted { display: inline-flex; color: var(--text-2); margin-top: 3px; }
.ci-pin svg { width: 18px; height: 18px; transform: rotate(45deg); }
.ci-muted svg { width: 15px; height: 15px; margin-left: 4px; vertical-align: -2px; }
.chat-item.active .ci-pin, .chat-item.active .ci-muted { color: #fff; }
.chat-item.active .ci-badge.mention { background: #fff; color: var(--chat-active); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; opacity: .6; }
.mention { color: var(--accent); cursor: pointer; font-weight: 500; }
.msg.out .mention { color: var(--meta-out); }
.mention.me { background: rgba(51,144,236,.14); border-radius: 4px; padding: 0 2px; }
.mention.all { cursor: default; }
.composer-main { position: relative; }
.mention-box { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); max-height: 300px; overflow-y: auto;
  background: var(--surface); border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.18); padding: 6px; z-index: 6; }
.mb-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.mb-item.active, .mb-item:hover { background: var(--hover); }
.mention-jump { bottom: 140px; font-size: 22px; font-weight: 600; color: var(--accent); }
.online-text { color: var(--accent); }

/* ---------- Регистрация, заявки ---------- */
.auth-logo.small { width: 96px; height: 96px; margin-bottom: 16px; }
.menu-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
#menu-btn { position: relative; }
.menu-dot { position: absolute; top: 7px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.tabs .tab-count { display: inline-block; margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; }
.req-card { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
[data-theme="dark"] .req-card { border-color: #333; }
.req-card .m-body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.5; }
.req-card .m-name { font-size: 16px; }
.req-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Плашки уведомлений (правый нижний угол) ---------- */
.notify-stack { position: fixed; right: 18px; bottom: 18px; z-index: 75; display: flex; flex-direction: column-reverse; gap: 10px; pointer-events: none; }
.nt { pointer-events: auto; width: 340px; max-width: calc(100vw - 36px); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--surface); border-radius: 14px; box-shadow: 0 6px 28px rgba(0,0,0,.22); cursor: pointer; animation: ntIn .22s ease-out; border-left: 4px solid var(--accent); }
[data-theme="dark"] .nt { background: #2a2a2a; }
.nt.mention { border-left-color: #f5a623; }
.nt.admin { border-left-color: var(--danger); }
.nt.out { animation: ntOut .2s ease-in forwards; }
@keyframes ntIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes ntOut { to { opacity: 0; transform: translateX(40px); } }
.nt .nt-body { flex: 1; min-width: 0; }
.nt .nt-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt .nt-sub { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.nt .nt-close { border: 0; background: none; color: var(--text-2); font-size: 20px; line-height: 1; padding: 4px 6px; border-radius: 6px; align-self: flex-start; }
.nt .nt-close:hover { background: var(--hover); }

/* ---------- Модальные окна ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 480px; max-width: 100%; max-height: calc(100vh - 32px); background: var(--surface); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.3); animation: pop .15s ease-out; }
.modal.wide { width: 920px; }
.modal-header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 20px; }
.modal-header h2 { flex: 1; font-size: 20px; font-weight: 500; margin: 0; }
.modal-body { overflow-y: auto; padding: 6px 20px 20px; }
.modal-body .field { margin-bottom: 16px; }
.modal-body .btn-primary { width: 100%; height: 46px; font-size: 15px; }
.section-title { color: var(--accent); font-size: 15px; font-weight: 500; margin: 18px 0 12px; }
.settings-profile { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0 4px; }
.settings-profile .name { font-size: 20px; font-weight: 500; }
.settings-profile .login { color: var(--text-2); font-size: 14px; }
.row-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row-btns + .row-btns { margin-top: 8px; }
.btn { border: 0; border-radius: 8px; padding: 8px 14px; background: var(--input-bg); font-size: 14px; font-weight: 500; }
.btn:hover { filter: brightness(.96); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.seg { display: flex; background: var(--input-bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 8px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.hint { color: var(--text-2); font-size: 13px; line-height: 1.4; }
.temp-pw { margin: 12px 0; padding: 12px; border-radius: 10px; background: var(--input-bg); font-size: 14px; line-height: 1.5; }
.temp-pw code { font-size: 18px; font-weight: 600; letter-spacing: 1px; user-select: all; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 500; color: var(--text-2); border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr 180px auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.admin-grid .field { margin: 0; }
.admin-grid .field input, .admin-grid .field select { height: 46px; }
.admin-grid .field span { top: 12px; }
.admin-grid .btn-primary { height: 46px; padding: 0 16px; width: auto; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; color: var(--text-2); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
[data-theme="dark"] table.grid th, [data-theme="dark"] table.grid td { border-color: #333; }
table.grid .user-cell { display: flex; align-items: center; gap: 10px; }
table.grid .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--input-bg); color: var(--text-2); white-space: nowrap; }
.pill.ok { color: #2e9a3e; }
.pill.bad { color: var(--danger); }
.pill.warn { color: #c98a00; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }

.dialog-root { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: 380px; max-width: 100%; background: var(--surface); border-radius: 14px; padding: 20px 20px 10px; box-shadow: 0 8px 40px rgba(0,0,0,.35); animation: pop .12s ease-out; }
.dialog-text { font-size: 16px; line-height: 1.4; margin-bottom: 14px; }
.dialog-input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; background: transparent; outline: none; margin-bottom: 10px; }
.dialog-input:focus { border: 2px solid var(--accent); padding: 0 11px; }
.dialog-btns { display: flex; justify-content: flex-end; gap: 6px; }
.btn-flat { border: 0; background: none; padding: 9px 14px; border-radius: 8px; font-weight: 500; font-size: 15px; text-transform: uppercase; color: var(--accent); }
.btn-flat:hover { background: var(--hover); }
.btn-flat.danger { color: var(--danger); }
.btn-flat.danger:hover { background: rgba(229,57,53,.1); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; max-width: 90vw; }

/* ---------- Редактор аватара ---------- */
.editor-root { z-index: 85; background: rgba(0,0,0,.6); }
.avatar-editor { width: 360px; max-width: 100%; background: var(--surface); border-radius: 14px; padding: 16px 20px 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4); animation: pop .12s ease-out; display: flex; flex-direction: column; align-items: center; }
.ae-title { align-self: stretch; font-size: 18px; font-weight: 500; margin-bottom: 12px; }
.ae-stage { position: relative; border-radius: 6px; overflow: hidden; background: #111; cursor: grab; touch-action: none; user-select: none; }
.ae-stage.dragging { cursor: grabbing; }
.ae-stage canvas { display: block; }
/* затемнение вне круга: огромная тень у круглого блока */
.ae-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 400px rgba(0,0,0,.55); border: 2px solid rgba(255,255,255,.85); pointer-events: none; }
.ae-hint { font-size: 13px; color: var(--text-2); margin: 8px 0 4px; text-align: center; }
.ae-tools { display: flex; align-items: center; gap: 6px; align-self: stretch; margin-bottom: 6px; }
.ae-zoom { flex: 1; accent-color: var(--accent); }
.avatar-editor .dialog-btns { align-self: stretch; }

/* ---------- Пересылка ---------- */
.fwd-head { font-size: 14px; color: var(--accent); margin-bottom: 2px; line-height: 1.3; }
.msg.out .fwd-head { color: var(--meta-out); }
.fwd-name { font-weight: 500; }
.fwd-name[data-fwd-user] { cursor: pointer; }
.fwd-name[data-fwd-user]:hover { text-decoration: underline; }
.bubble.media .fwd-head { padding: 6px 10px 0; }
.bubble.media .fwd-head + .reply-quote, .bubble.media .fwd-head + a.photo { margin-top: 4px; }
.fwd-search { flex: none; margin-bottom: 8px; }
.fwd-list { max-height: 46vh; min-height: 120px; overflow-y: auto; margin: 0 -8px 14px; scrollbar-width: thin; }
.fwd-item { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 10px; cursor: pointer; user-select: none; }
.fwd-item:hover { background: var(--hover); }
.fwd-body { flex: 1; min-width: 0; }
.fwd-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fwd-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fwd-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; position: relative; }
.fwd-item.on .fwd-check { background: var(--accent); border-color: var(--accent); }
.fwd-item.on .fwd-check::after, .msg.selected .sel-check::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.fwd-comment { margin-bottom: 12px; }
.fwd-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fwd-foot .btn:disabled { opacity: .5; cursor: default; }

/* режим выбора сообщений */
.sel-check { display: none; }
.messages-inner.selecting .msg { position: relative; padding-left: 40px; cursor: pointer; }
.messages-inner.selecting .msg.in.in-group { padding-left: 86px; }
.messages-inner.selecting .msg.in.in-group .avatar { left: 40px; }
.messages-inner.selecting .sel-check { display: block; position: absolute; left: 4px; bottom: 6px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.12); box-shadow: 0 0 2px rgba(0,0,0,.3); }
.messages-inner.selecting .msg.selected .sel-check { background: var(--accent); border-color: #fff; }
.messages-inner.selecting .msg.selected .bubble { filter: brightness(.95); }
.messages-inner.selecting .bubble a { pointer-events: none; }
.select-bar { display: none; flex: 1; height: 54px; align-items: center; gap: 10px; padding: 0 8px 0 6px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); }
.sel-count { flex: 1; font-size: 16px; font-weight: 500; }
#sel-forward { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; }
#sel-forward svg { width: 20px; height: 20px; fill: currentColor; }
.composer.selecting .composer-main, .composer.selecting .send-btn { display: none; }
.composer.selecting .readonly-bar { display: none !important; }
.composer.selecting .select-bar { display: flex; }

/* ---------- Эмодзи ---------- */
.emoji-btn { margin-bottom: 7px; }
.emoji-btn.active { color: var(--accent); }
.emoji-panel { position: absolute; right: 0; bottom: calc(100% + 6px); width: 352px; max-width: calc(100vw - 24px); height: 330px;
  background: var(--surface); border-radius: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.2); z-index: 7; display: flex; flex-direction: column; overflow: hidden; }
.ep-title { font-size: 13px; font-weight: 500; color: var(--text-2); padding: 10px 12px 4px; }
.ep-grid { flex: 1; overflow-y: auto; padding: 0 6px 6px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-content: start; scrollbar-width: thin; scrollbar-gutter: stable; }
.ep-e { border: 0; background: none; height: 40px; padding: 0; border-radius: 8px; font-size: 24px; line-height: 1; cursor: pointer;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.ep-e:hover { background: var(--hover); }
.ep-empty { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; text-align: center; padding: 40px 16px; }
.ep-tabs { display: flex; justify-content: space-around; border-top: 1px solid var(--border); padding: 4px; }
.ep-tab { border: 0; background: none; width: 36px; height: 36px; border-radius: 8px; font-size: 20px; opacity: .55; cursor: pointer;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.ep-tab:hover { background: var(--hover); opacity: .85; }
.ep-tab.active { opacity: 1; background: var(--hover); }

/* сообщение из одних эмодзи */
.bubble.emoji-only { background: none !important; box-shadow: none; padding: 0 2px; }
.bubble.emoji-only::before { display: none; }
.bubble.emoji-only .sender-name { display: inline-block; margin-bottom: 2px; padding: 1px 8px; border-radius: 10px; background: var(--bubble-in); }
.bubble.emoji-only .text { display: block; line-height: 1.15; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.bubble.emoji-only.big-1 .text { font-size: 64px; }
.bubble.emoji-only.big-2 .text { font-size: 52px; }
.bubble.emoji-only.big-3 .text { font-size: 42px; }
.bubble.emoji-only .meta { float: none; display: inline-flex; margin: 2px 0 0; top: 0; padding: 3px 7px; border-radius: 10px;
  background: var(--date-chip); color: #fff; }
.msg.out .bubble.emoji-only { text-align: right; }
.bubble.emoji-only .tick, .bubble.emoji-only .tick.read { color: #fff; }

/* ---------- Форматирование текста ---------- */
.bubble code { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: 14px; background: rgba(0,0,0,.07);
  border-radius: 4px; padding: 0 4px; }
.bubble pre.code-block { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: 13.5px; background: rgba(0,0,0,.07);
  border-radius: 6px; padding: 6px 8px; margin: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid var(--accent); }
[data-theme="dark"] .bubble code, [data-theme="dark"] .bubble pre.code-block { background: rgba(255,255,255,.08); }
.msg.out .bubble pre.code-block { border-left-color: var(--meta-out); }

/* ---------- Избранное ---------- */
.saved-avatar { background: linear-gradient(160deg, #4fa8f5, #2f80d8) !important; color: #fff; display: flex; align-items: center; justify-content: center; }
.saved-avatar svg { width: 52%; height: 52%; fill: #fff; }

/* ---------- Закреплённые сообщения ---------- */
.pin-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 8px 0 16px; background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.08); position: relative; z-index: 2; cursor: pointer; }
.pin-lines { display: flex; flex-direction: column; gap: 2px; height: 36px; justify-content: center; }
.pin-lines span { width: 2px; flex: 1; max-height: 36px; border-radius: 1px; background: var(--accent); opacity: .35; }
.pin-lines span.on { opacity: 1; }
.pin-body { flex: 1; min-width: 0; }
.pin-title { color: var(--accent); font-size: 14px; font-weight: 500; }
.pin-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-x svg { width: 20px; height: 20px; }
.pin-mark { display: inline-flex; margin-right: 3px; color: inherit; }
.pin-mark svg { width: 14px; height: 14px; fill: currentColor; }
.service.clickable { cursor: pointer; }

/* ---------- Вкладки «Участники / Фото / Файлы» ---------- */
.info-tabs { margin: 14px 0 10px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 3px; }
.mg-item { aspect-ratio: 1; display: block; overflow: hidden; background: var(--input-bg); border-radius: 4px; }
.mg-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-item.removed { display: flex; align-items: center; justify-content: center; font-size: 28px; opacity: .5; }
.media-file { display: flex; align-items: center; gap: 12px; padding: 6px 4px; border-radius: 10px; cursor: pointer; }
.media-file:hover { background: var(--hover); }
.media-file.removed { opacity: .6; cursor: default; }
.media-file .file-icon { width: 44px; height: 44px; flex: none; }
.mf-body { flex: 1; min-width: 0; }
.mf-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Профиль, отделы ---------- */
.facts { border-radius: 12px; background: var(--input-bg); padding: 4px 0; margin: 6px 0 12px; }
.fact { padding: 7px 16px; }
.fact[data-copy] { cursor: pointer; }
.fact[data-copy]:hover { background: var(--hover); }
.fact-v { font-size: 15px; overflow-wrap: anywhere; }
.fact-k { font-size: 13px; color: var(--text-2); }
.facts.readonly { display: grid; grid-template-columns: 1fr 1fr; }
.dept-head { font-size: 13px; font-weight: 600; color: var(--accent); padding: 12px 8px 4px; text-transform: none; }
.dept-add { grid-template-columns: 1fr auto; }
.field .sel-label { position: absolute; left: 12px; top: -8px !important; transform: none !important; line-height: 1.2; padding: 0 4px; font-size: 12px; color: var(--text-2); background: var(--surface); pointer-events: none; }
.audit-filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.audit-filters .field { margin-bottom: 14px; min-width: 240px; }
.audit-filters .field.date { min-width: 160px; }
.audit-filters .field.date input { padding: 0 12px; }
.audit-filters .btn { height: 48px; display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Устройства ---------- */
.sess { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 10px; }
.sess.current { background: var(--input-bg); }
.sess-ic { width: 26px; height: 26px; fill: var(--text-2); flex: none; }
.sess-body { flex: 1; min-width: 0; }
.sess-name { font-weight: 500; }
.sess-sub { font-size: 13px; color: var(--text-2); }
.pill.ok { vertical-align: 1px; }

/* ---------- Мой профиль ---------- */
.modal { position: relative; }
.modal-actions { display: flex; align-items: center; gap: 2px; }
.modal-actions .icon-btn { width: 36px; height: 36px; }
.modal-actions .icon-btn svg { width: 20px; height: 20px; }
.modal-actions .icon-btn.active { color: var(--accent); background: var(--hover); }
.lang-btn { font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.my-head { margin-bottom: 6px; }
.my-avatar { position: relative; border-radius: 50%; }
.my-avatar.editable { cursor: pointer; }
.my-avatar .cam { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.38); display: flex; align-items: center; justify-content: center; transition: background .15s; }
.my-avatar.editable:hover .cam { background: rgba(0,0,0,.55); }
.my-avatar .cam svg { width: 36px; height: 36px; fill: #fff; }
.my-photo-btns { display: flex; gap: 16px; }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.muted { color: var(--text-2); font-style: italic; }
.profile-form { margin-top: 6px; }
.profile-form .field-hint, .sheet .field-hint { margin: -10px 0 14px 4px; }
.form-btns { display: flex; justify-content: flex-end; gap: 8px; }
.form-btns .btn { height: 40px; padding: 0 20px; }
.pw-bottom { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--border); text-align: center; }
.pw-bottom .link-btn { color: var(--text-2); }
.pw-bottom .link-btn:hover { color: var(--accent); }
.modal-notice { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 9px 16px 9px 12px; border-radius: 22px; background: #2e9e4f; color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); pointer-events: none; z-index: 3; white-space: nowrap; }
.modal-notice svg { width: 20px; height: 20px; fill: #fff; }
.modal-notice.show { animation: notice-in .2s ease-out; }
@keyframes notice-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.sheet { width: 400px; max-width: 100%; background: var(--surface); border-radius: 14px; padding: 18px 20px 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4); animation: pop .12s ease-out; }
.sheet-title { font-size: 18px; font-weight: 500; margin-bottom: 16px; }
.sheet .field { margin-bottom: 16px; }

/* ---------- Скроллбары ---------- */
.chat-list, .messages, .modal-body { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.2) transparent; }
[data-theme="dark"] .chat-list, [data-theme="dark"] .messages, [data-theme="dark"] .modal-body { scrollbar-color: rgba(255,255,255,.2) transparent; }

/* ---------- Папки чатов: вертикальное меню слева ---------- */
.folders { flex: none; width: 74px; height: 100%; display: flex; flex-direction: column; gap: 2px; padding: 6px 0;
  overflow-y: auto; scrollbar-width: none; background: var(--folders-bg); border-right: 1px solid var(--border); }
.folders::-webkit-scrollbar { display: none; }
.fold { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%;
  padding: 9px 4px 8px; border: 0; background: none; color: var(--text-2); cursor: pointer; font: inherit; }
.fold:hover { background: var(--hover); }
.fold.active { color: var(--accent); }
.fold.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.fold-ic { position: relative; display: flex; }
.fold-ic svg { width: 26px; height: 26px; fill: currentColor; }
.fold-name { font-size: 11px; line-height: 1.2; max-width: 66px; text-align: center; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.fold.active .fold-name { font-weight: 600; }
.fold-badge { position: absolute; top: -6px; left: 16px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--badge); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--folders-bg); }
.fold-edit { margin-top: auto; }
:root { --folders-bg: #f1f3f5; }
[data-theme="dark"] { --folders-bg: #181818; }

/* Окно «Папки» */
.fold-hint { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.fold-rows { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.fold-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; min-height: 38px; }
.fold-row:hover { background: var(--hover); }
.fold-row > svg { width: 20px; height: 20px; fill: var(--text-2); flex: none; }
.fold-row .fr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-count { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.fold-row.builtin { opacity: .8; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.fold-new { width: 100%; }
.fold-pick-head { display: flex; align-items: baseline; justify-content: space-between; }
.fold-search { margin: 4px 0 6px; }
.fold-pick { max-height: min(46vh, 380px); overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.fold-chat { display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.fold-chat:hover { background: var(--hover); }
.fold-chat input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.fold-chat .fc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.fold-chat .kind-icon { width: 15px; height: 15px; vertical-align: -2px; margin-right: 3px; fill: var(--text-2); }

/* ---------- Узкие экраны ---------- */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .folders { width: 100%; height: auto; flex-direction: row; padding: 0 6px; gap: 0; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid var(--border); }
  .fold { flex-direction: row; width: auto; flex: none; padding: 11px 10px; gap: 5px; }
  .fold-ic svg { width: 18px; height: 18px; }
  .fold-name { font-size: 13px; max-width: 140px; -webkit-line-clamp: 1; white-space: nowrap; display: block; }
  .fold.active::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .fold-badge { position: static; box-shadow: none; }
  .fold-edit { margin-top: 0; margin-left: auto; }
  .sidebar { flex: 1; min-height: 0; height: auto; }
  .sidebar { width: 100%; max-width: none; border-right: 0; }
  .chat { position: absolute; inset: 0; transform: translateX(100%); transition: transform .2s; z-index: 5; }
  .main.chat-open .chat { transform: none; }
  .back-btn { display: flex; }
  .admin-grid { grid-template-columns: 1fr; }
}

/* ---------- Этап Б-1: реакции ---------- */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; clear: both; }
.react { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px 0 6px; border-radius: 13px;
  border: 0; cursor: pointer; font: inherit; font-size: 13px; background: rgba(51,144,236,.12); color: var(--accent); }
.react .re { font-size: 15px; line-height: 1; }
.react .rc { font-weight: 500; }
.react:hover { background: rgba(51,144,236,.2); }
.react.mine { background: var(--accent); color: #fff; }
.msg.out .react { background: rgba(79,174,78,.16); color: var(--meta-out); }
.msg.out .react.mine { background: var(--meta-out); color: #fff; }
.bubble.emoji-only .reacts { justify-content: flex-end; }
.media-tail { padding: 0 8px 6px; }
.react-open { align-self: flex-end; flex: none; width: 30px; height: 30px; margin: 0 4px 2px; border: 0; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer; font-size: 16px; line-height: 1;
  opacity: 0; pointer-events: none; transition: opacity .12s; }
.msg.out .react-open { order: -1; }
.msg:hover .react-open { opacity: 1; pointer-events: auto; }
.messages-inner.selecting .react-open { display: none; }
[data-theme="dark"] .react-picker { background: #2a2a2a; }
@media (hover: none) { .react-open { display: none; } }
.react-row { display: flex; gap: 2px; padding: 4px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.react-row button, .react-picker .react-row button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: none;
  cursor: pointer; font-size: 20px; line-height: 1; padding: 0; transition: transform .1s; }
.react-row button:hover { transform: scale(1.2); background: var(--hover); }
.react-row button.mine { background: rgba(51,144,236,.18); }
.react-picker { position: fixed; z-index: 60; background: var(--surface); border-radius: 22px; box-shadow: 0 4px 18px rgba(0,0,0,.2); }
.react-picker .react-row { border: 0; margin: 0; padding: 4px 6px; }

/* ---------- Этап Б-1: «Важное — ознакомиться» ---------- */
.bubble.important { box-shadow: var(--shadow), inset 3px 0 0 #e8710a; }
.ack-head { color: #e8710a; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.bubble.media .ack-head { padding: 6px 9px 0 11px; }
.ack-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; clear: both; }
.ack-btn { border: 0; border-radius: 8px; padding: 6px 14px; background: #e8710a; color: #fff; font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer; }
.ack-btn:hover { filter: brightness(1.08); }
.ack-done { color: var(--meta-out); font-size: 13px; font-weight: 500; }
.ack-stat { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; }
.msg.out .ack-stat { color: var(--meta-out); }
.ack-stat:hover { text-decoration: underline; }
.ack-stat.full::before { content: "✓ "; }
.ack-bar { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px 6px 16px;
  background: #fff4e5; border-top: 1px solid var(--border); position: relative; z-index: 2; }
[data-theme="dark"] .ack-bar { background: #3a2c1a; }
.ack-bar-ic { font-size: 20px; }
.ack-bar-body { flex: 1; min-width: 0; cursor: pointer; }
.ack-bar-title { color: #e8710a; font-size: 14px; font-weight: 600; }
.ack-bar-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ack-bar .btn.sm { padding: 6px 12px; font-size: 13px; background: #e8710a; border-color: #e8710a; }
.ci-badge.ack { background: #e8710a; min-width: 22px; padding: 0; margin-right: 4px; font-weight: 700; }
.ack-toggle { font-size: 18px; opacity: .45; filter: grayscale(1); }
.ack-toggle:hover { opacity: .8; }
.ack-toggle.active { opacity: 1; filter: none; background: rgba(232,113,10,.15); }
.ack-summary { text-align: center; font-size: 15px; font-weight: 500; margin-bottom: 10px; }
.dropdown .react-row button { width: 34px; margin: 0; display: inline-flex; justify-content: center; gap: 0; padding: 0; font-size: 20px; }
.dropdown .react-row { justify-content: space-between; }

/* ---------- Этап Б-2: опросы ---------- */
.bubble.poll { min-width: 280px; max-width: 420px; width: 100%; }
.poll-card { margin-bottom: 2px; white-space: normal; }
.poll-q { font-weight: 600; font-size: 15px; line-height: 1.3; word-break: break-word; }
.poll-sub { color: var(--meta-in); font-size: 13px; margin: 3px 0 8px; }
.msg.out .poll-sub { color: var(--meta-out); }
.poll-opts { display: flex; flex-direction: column; gap: 4px; }
.po { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 6px 4px; border: 0; background: none;
  font: inherit; color: inherit; text-align: left; border-radius: 8px; cursor: default; }
.po.voting, .po[data-po-voters] { cursor: pointer; }
.po.voting:hover, .po[data-po-voters]:hover { background: rgba(0,0,0,.04); }
[data-theme="dark"] .po.voting:hover, [data-theme="dark"] .po[data-po-voters]:hover { background: rgba(255,255,255,.05); }
.po-radio, .po-box { flex: none; width: 20px; height: 20px; margin-top: 1px; border: 2px solid var(--meta-in); border-radius: 50%; }
.po-box { border-radius: 5px; position: relative; }
.po-box.on { background: var(--accent); border-color: var(--accent); }
.po-box.on::after { content: "✓"; position: absolute; inset: 0; color: #fff; font-size: 13px; line-height: 16px; text-align: center; }
.po-pct { flex: none; width: 38px; font-weight: 600; font-size: 14px; text-align: right; }
.po-body { flex: 1; min-width: 0; }
.po-text { display: block; font-size: 15px; line-height: 1.3; word-break: break-word; }
.po-check { color: var(--accent); font-weight: 700; }
.msg.out .po-check { color: var(--meta-out); }
.po-bar { display: block; height: 4px; margin-top: 5px; border-radius: 2px; background: rgba(51,144,236,.15); overflow: hidden; }
.po-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.msg.out .po-bar { background: rgba(79,174,78,.2); }
.msg.out .po-bar i { background: var(--meta-out); }
.po.mine .po-text { font-weight: 500; }
.po-n { flex: none; color: var(--meta-in); font-size: 13px; }
.po-submit { display: block; width: 100%; margin-top: 8px; padding: 8px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 500; }
.po-submit:disabled { opacity: .45; cursor: default; }
.poll-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 8px; color: var(--meta-in); font-size: 13px; clear: both; }
.msg.out .poll-foot { color: var(--meta-out); }
.po-link { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; }
.msg.out .po-link { color: var(--meta-out); }
.po-link:hover { text-decoration: underline; }
.poll-form { display: flex; flex-direction: column; gap: 6px; }
.poll-form textarea, .pf-opt input, .pf-date { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: inherit; font: inherit; font-size: 15px; outline: none; resize: vertical; }
.poll-form textarea:focus, .pf-opt input:focus, .pf-date:focus { border-color: var(--accent); }
.pf-label { font-size: 13px; color: var(--accent); font-weight: 500; margin-top: 6px; }
.pf-opts { display: flex; flex-direction: column; gap: 6px; }
.pf-opt { display: flex; gap: 6px; align-items: center; }
.pf-del { width: 32px; height: 32px; font-size: 20px; color: var(--text-2); }
#pf-add { align-self: flex-start; font-size: 14px; margin: 2px 0 4px; }
.pf-switches { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.pf-switches .check-row { margin: 0; display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; }
.pf-date { margin-left: 28px; width: auto; }

/* ---------- Окно группы (минималистично) ---------- */
.av-wrap { position: relative; }
.info-head .avatar img { cursor: zoom-in; }
.av-cam { position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface);
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.av-cam svg { width: 17px; height: 17px; fill: currentColor; }
.av-cam:hover { filter: brightness(1.08); }
.list-row { display: flex; align-items: center; gap: 18px; width: 100%; padding: 11px 10px; border: 0; background: none; border-radius: 10px;
  font: inherit; font-size: 15px; color: var(--accent); cursor: pointer; text-align: left; }
.list-row svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.list-row:hover { background: var(--hover); }
.list-row.danger { color: var(--danger); }
.info-bottom { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.info-bottom:empty { display: none; }
.member.clickable { cursor: pointer; }
.member.clickable:hover { background: var(--hover); }
.member .m-more { width: 32px; height: 32px; opacity: 0; transition: opacity .12s; flex: none; }
.member .m-more svg { width: 20px; height: 20px; }
.member:hover .m-more, .member .m-more:focus-visible { opacity: 1; }
@media (hover: none) { .member .m-more { opacity: 1; } }
.m-hint { text-align: center; margin-top: 8px; }
.ge-form { margin: 10px 0 6px; }
.ctx { z-index: 65; }

/* ---------- Меню скрепки ---------- */
.attach-menu { position: fixed; z-index: 45; min-width: 250px; padding: 6px; background: var(--surface); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.04); transform-origin: left bottom; }
[data-theme="dark"] .attach-menu { background: #2a2a2a; }
.attach-menu.show { animation: amPop .14s ease-out; }
@keyframes amPop { from { opacity: 0; transform: scale(.94) translateY(6px); } to { opacity: 1; transform: none; } }
.attach-menu button { display: flex; align-items: center; gap: 16px; width: 100%; padding: 9px 12px; border: 0; background: none;
  border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.attach-menu button:hover { background: var(--hover); }
.attach-menu button.hidden { display: none; }
.attach-menu svg { width: 22px; height: 22px; fill: currentColor; opacity: .55; flex: none; }
.am-text { display: flex; flex-direction: column; line-height: 1.25; }
.am-text > span:first-child { font-size: 15px; font-weight: 500; }
.am-sub { font-size: 12.5px; color: var(--text-2); }

/* ---------- Просмотр аватарки ---------- */
.av-viewer { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0); transition: background .28s; cursor: zoom-out; }
.av-viewer.open { background: rgba(0,0,0,.88); }
.av-big { position: fixed; object-fit: cover; transform-origin: 0 0; box-shadow: 0 8px 40px rgba(0,0,0,.45);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), border-radius .3s, opacity .25s; user-select: none; }
.member .m-more-ph { width: 32px; flex: none; }

/* Подсказка о требованиях к паролю: полупрозрачная, появляется при вводе нового пароля */
.pw-rules {
  font-size: 12.5px; line-height: 1.35; color: var(--text-2); text-align: left;
  opacity: 0; max-height: 0; overflow: hidden; margin: 0 4px;
  transition: opacity .2s, max-height .2s, margin .2s;
}
.field:focus-within + .pw-rules,
.field:has(input:not(:placeholder-shown)) + .pw-rules { opacity: .7; max-height: 60px; margin: -12px 4px 16px; }
