:root {
  --accent: #19D3C0;
  --accent-ink: #0a6f65;
  --accent-soft: #e3f9f6;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --line: #e4e8ea;
  --text: #1c2326;
  --muted: #6c777c;
  --in-bubble: #ffffff;
  --out-bubble: #d9f6f2;
  --danger: #d64545;
  --tg: #2AABEE;
  --avito: #97cf26;
  --wa: #25D366;
  --radius: 14px;
  color-scheme: light;
}
/* Тёмная тема: по системе (если не выбрана светлая) или выбрана вручную в меню */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-ink: #5fe6d8;
    --accent-soft: #123b38;
    --bg: #111618;
    --panel: #192023;
    --line: #2a3337;
    --text: #e8eef0;
    --muted: #93a0a5;
    --in-bubble: #222b2f;
    --out-bubble: #14423e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-ink: #5fe6d8;
  --accent-soft: #123b38;
  --bg: #111618;
  --panel: #192023;
  --line: #2a3337;
  --text: #e8eef0;
  --muted: #93a0a5;
  --in-bubble: #222b2f;
  --out-bubble: #14423e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

.btn {
  border: 1.5px solid var(--accent);
  background: var(--panel);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #14c2b0; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-small { padding: 5px 12px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; color: var(--muted);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* Вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); background: var(--panel); border-radius: 20px; padding: 28px 24px;
  display: grid; gap: 14px; box-shadow: 0 6px 30px rgba(0,0,0,.06);
}
.login-logo { width: 64px; height: 64px; justify-self: center; border-radius: 50%; }
.login-card h1 { margin: 0 0 4px; text-align: center; font-size: 22px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
.login-card input:focus, .filters input:focus, .reply textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Раскладка */
.app { height: 100dvh; display: grid; grid-template-columns: 360px 1fr; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; position: relative; }
.me { display: flex; align-items: center; gap: 10px; }
.me-logo { width: 36px; height: 36px; border-radius: 50%; }
.me-title { font-weight: 700; }
.me-name { font-size: 12px; color: var(--muted); }
.menu {
  position: absolute; right: 12px; top: 50px; z-index: 10; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.12); display: grid; min-width: 220px; overflow: hidden;
}
.menu button { border: 0; background: none; text-align: left; padding: 11px 16px; }
.menu button:hover { background: var(--accent-soft); }

.banner {
  margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft);
  font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between;
}
.banner-warn { background: #fff1d6; color: #7a5200; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner-warn { background: #3d3115; color: #f3d38a; } }
:root[data-theme="dark"] .banner-warn { background: #3d3115; color: #f3d38a; }

.filters { padding: 0 12px 8px; display: grid; gap: 8px; }
.filters input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 12px;
}
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tab {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 700; min-width: 18px; text-align: center; }

/* Значки каналов */
.ch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background-size: 62%; background-repeat: no-repeat; background-position: center; flex: none; }
.ch-telegram { background-color: var(--tg); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M2.5 11.3 20.6 4.3c.8-.3 1.6.2 1.3 1.5l-3.1 14.5c-.2 1-.8 1.3-1.7.8l-4.6-3.4-2.2 2.1c-.3.3-.5.5-1 .5l.3-4.7 8.6-7.8c.4-.3-.1-.5-.6-.2L6.9 14.3 2.4 12.9c-1-.3-1-1 .1-1.6z'/%3E%3C/svg%3E"); }
.ch-avito { background-color: #fff; border: 1px solid var(--line); background-size: 78%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='16' cy='16' r='5.5' fill='%2397cf26'/%3E%3Ccircle cx='7' cy='16' r='3.5' fill='%23ff6163'/%3E%3Ccircle cx='16' cy='7' r='3' fill='%230af'/%3E%3Ccircle cx='7.5' cy='7.5' r='2' fill='%23965eeb'/%3E%3C/svg%3E"); }
.ch-app { background-color: #14c0c9; background-size: cover; background-image: url("/app-logo.png"); }
.ch-whatsapp { background-color: var(--wa); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M12 2.5a9.4 9.4 0 0 0-8.1 14.2L2.5 21.5l5-1.3A9.4 9.4 0 1 0 12 2.5zm5.4 13.3c-.2.6-1.3 1.2-1.8 1.2-.5.1-1 .2-3.4-.7-2.8-1.1-4.6-4-4.8-4.2-.1-.2-1.1-1.5-1.1-2.9s.7-2 1-2.3c.3-.3.6-.3.8-.3h.6c.2 0 .4 0 .7.5l.9 2.2c.1.2.1.4 0 .6l-.4.6-.4.4c-.1.2-.3.3-.1.6.2.3.8 1.3 1.7 2.1 1.2 1 2.1 1.3 2.4 1.5.3.1.5.1.7-.1l.9-1.1c.2-.3.4-.2.7-.1l2.1 1c.3.1.5.2.5.4.1.1.1.7-.1 1.2z'/%3E%3C/svg%3E"); }
.ch-test { background-color: var(--muted); }

/* Список чатов */
.chat-list { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; }
.chat {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 12px; cursor: pointer;
}
.chat:hover { background: var(--bg); }
.chat.active { background: var(--accent-soft); }
.avatar {
  position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 17px; flex: none;
}
.avatar .ch { position: absolute; right: -2px; bottom: -2px; border: 2px solid var(--panel); width: 20px; height: 20px; box-sizing: content-box; }
.chat-main { min-width: 0; }
.chat-top { display: flex; gap: 6px; align-items: baseline; }
.chat-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-last { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat.unread .chat-name { font-weight: 800; }
.chat.unread .chat-last { color: var(--text); font-weight: 500; }
.chat-side { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.chat.unread .chat-side time { color: var(--accent-ink); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 16px; }

/* Диалог */
.dialog { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.dialog-empty { margin: auto; text-align: center; color: var(--muted); }
.dialog-empty img { width: 64px; opacity: .5; }
.dialog-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.dialog-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.dialog-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.dialog-title { flex: 1; min-width: 0; }
.dialog-title > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dialog-name { font-weight: 700; }
.back { display: none; font-size: 30px; }

.contact-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.contact-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.contact-form input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 11px; font-size: 16px; }
.contact-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.contact-form .muted, .contact-actions { grid-column: 1 / -1; margin: 0; }
.contact-actions { display: flex; gap: 8px; justify-content: flex-end; }
.contact-status { margin: 0; padding: 7px 16px; font-size: 13px; background: var(--accent-soft); color: var(--accent-ink); }
.contact-status.warn { background: #fff1d6; color: #7a5200; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .contact-status.warn { background: #3d3115; color: #f3d38a; } }
:root[data-theme="dark"] .contact-status.warn { background: #3d3115; color: #f3d38a; }
.noname { font-size: 11px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.short { display: none; }
@media (max-width: 760px) { .dialog-head .short { display: inline; } }
.menu .dev { color: var(--muted); font-size: 13px; }

.messages { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 4vw, 48px); display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 999px; padding: 3px 10px; margin: 10px 0 6px; }
.msg {
  max-width: min(620px, 82%); padding: 7px 11px 5px; border-radius: 16px; background: var(--in-bubble);
  align-self: flex-start; box-shadow: 0 1px 1px rgba(0,0,0,.05); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.out { align-self: flex-end; background: var(--out-bubble); }
.msg-meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; }
.msg.failed { outline: 1.5px solid var(--danger); }
.msg.failed .msg-meta { color: var(--danger); }
.msg-who { font-size: 11px; color: var(--accent-ink); font-weight: 600; margin-bottom: 1px; }

.reply {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.reply textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg); border-radius: 20px;
  padding: 10px 14px; max-height: 160px; font-size: 16px;
}
.reply .btn-primary { width: 44px; height: 44px; padding: 0; font-size: 18px; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c2326; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px);
}

/* Телефон: одна колонка */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .app.open .sidebar { display: none; }
  .app:not(.open) .dialog { display: none; }
  .back { display: grid; place-items: center; }
  .dialog-head { padding: 8px 10px; }
  .msg { max-width: 88%; }
  .contact-form { grid-template-columns: 1fr; }
  .dialog-head .full { display: none; }
  .dialog-head .btn-small { width: 34px; height: 34px; padding: 0; }
}

/* Карточки клиентов */
.count-muted { background: var(--muted); }
.chat-chs { display: inline-flex; gap: 3px; margin-left: auto; flex: none; }
.chat-chs .ch { width: 14px; height: 14px; }
.chat-phone { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chat-phone b { color: var(--text); font-weight: 700; }
.dialog-head { position: relative; }
.menu-right { right: 12px; top: 54px; }
.contact-form .wide { grid-column: 1 / -1; }
.merge-panel { padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.merge-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.merge-panel input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 11px; font-size: 16px; }
.merge-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.merge-list li { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.merge-list li:hover { background: var(--accent-soft); }
.merge-list .avatar { width: 34px; height: 34px; font-size: 13px; }
.merge-list .avatar .ch { width: 14px; height: 14px; }
.avito-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; font-size: 13px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.avito-bar span { margin-right: auto; }
.msg-ch { display: inline-flex; align-items: center; gap: 4px; }
.msg-ch .ch { width: 12px; height: 12px; }
.reply-to {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 12px 0; background: var(--panel);
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.reply-to + .reply { border-top: 0; }
.reply-to .tab { padding: 3px 9px; font-size: 12px; }

/* Автосообщения: серые и свёрнутые */
.auto-group {
  align-self: center; max-width: min(620px, 92%); display: flex; align-items: center; gap: 8px;
  border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; margin: 4px 0; cursor: pointer; font: inherit; font-size: 12px;
}
.auto-group:hover { background: var(--panel); }
.auto-group .auto-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.msg.auto { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.msg.auto .msg-who { color: var(--muted); }
.waiting-bar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 6px 16px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; border-top: 1px solid var(--line);
}
.chat.waiting .chat-name::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.templates-dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); width: min(520px, calc(100% - 32px)); padding: 20px; }
.templates-dialog::backdrop { background: rgb(0 0 0 / 35%); }
.templates-dialog h2 { margin: 0 0 6px; font-size: 18px; }
.templates-dialog textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 10px; font: inherit; font-size: 15px; margin: 10px 0; resize: vertical; }

.conn { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; display: grid; gap: 8px; }
.conn-head { display: flex; align-items: center; gap: 8px; }
.conn p { margin: 0; }
.conn-form { display: flex; gap: 8px; }
.conn-form input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 16px; }
.conn .ok { color: var(--accent-ink); }
.conn-qr { width: 240px; height: 240px; justify-self: center; background: #fff; padding: 8px; border-radius: 12px; image-rendering: pixelated; }
.chat-name.chat-phone { font-size: 15px; color: var(--text); font-weight: 600; }
.chat-name.chat-phone b { font-weight: 800; }

.conn-form select { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 9px; font-size: 15px; }
.invite-result { display: grid; gap: 6px; }
.invite-result input { font-size: 13px !important; }
.staff-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.staff-list li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.staff-list .who { flex: 1; min-width: 0; display: grid; }
.staff-list .who span { font-size: 12px; color: var(--muted); }
.staff-list li.off { opacity: .55; }
.staff-list h3 { margin: 8px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
body:not(.is-owner) .owner-only { display: none !important; }

/* YCLIENTS в карточке клиента */
.yc-bar { padding: 8px 16px; font-size: 13px; border-bottom: 1px solid var(--line, #e5e5e5); background: var(--panel, transparent); }
.yc-bar .yc-recs { margin: 4px 0 0; padding-left: 18px; }
.yc-bar .yc-recs li { margin: 2px 0; }
.yc-bar .yc-recs .btn { margin-left: 6px; }


/* Выбор темы в меню */
.theme-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 11px 16px; cursor: default; }
.theme-row:hover { background: var(--accent-soft); }
.theme-row b { font-weight: 500; }
/* Варианты раскрываются при наведении (на компьютере); на телефоне видны сразу */
.theme-row .theme-seg { display: none; width: 100%; }
.theme-row:hover .theme-seg, .theme-row:focus-within .theme-seg { display: flex; }
@media (hover: none) { .theme-row .theme-seg { display: flex; } }

.theme-row > span { color: var(--text); }
.theme-seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.menu .theme-seg button { flex: 1; text-align: center; border: 0; background: transparent; padding: 6px 9px; border-radius: 8px; white-space: nowrap; font-size: 13px; width: auto; }
.menu .theme-seg button.active { background: var(--accent); color: #06302c; font-weight: 600; }

.banner-danger { background: #fde2e2; color: #8a1c1c; display: block; line-height: 1.45; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner-danger { background: #451a1a; color: #ffb4b4; } }
:root[data-theme="dark"] .banner-danger { background: #451a1a; color: #ffb4b4; }

/* Быстрые ответы */
.quick-btn { width: 44px; height: 44px; flex: none; font-size: 20px; }
.quick-btn.on { background: var(--accent-soft); color: var(--accent-ink); }
.quick-panel {
  background: var(--panel); border-top: 1px solid var(--line); max-height: min(46vh, 380px);
  display: flex; flex-direction: column; min-height: 0;
}
.quick-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px 6px; }
.quick-head input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.quick-list { overflow-y: auto; padding: 0 12px 10px; display: grid; gap: 4px; }
.quick-sec { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 8px 2px 2px; }
.quick-item {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 12px; padding: 6px 8px; cursor: pointer;
}
.quick-item:hover, .quick-item:focus-visible { background: var(--accent-soft); outline: none; }
.quick-item .q-main { flex: 1; min-width: 0; }
.quick-item .q-title { font-weight: 600; font-size: 14px; }
.quick-item .q-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-thumbs { display: flex; gap: 4px; flex: none; }
.q-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; }
.attach-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 12px 0; background: var(--panel); border-top: 1px solid var(--line); }
.attach-bar + .reply, .reply-to + .attach-bar { border-top: 0; }
.attach { position: relative; }
.attach .q-thumb { width: 56px; height: 56px; }
.attach button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: var(--text); color: var(--panel); font-size: 13px; line-height: 20px; padding: 0; cursor: pointer;
}
.attach-note { font-size: 12px; color: var(--muted); }
.msg-files { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 4px; }
.msg-files img, .msg-files video { display: block; max-width: min(260px, 100%); max-height: 260px; border-radius: 10px; background: var(--bg); }
.msg-files a { color: var(--accent-ink); }
.quick-editor { display: grid; gap: 10px; }
.quick-editor label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.quick-editor input, .quick-editor select { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 15px; }
.qe-list { display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; margin: 8px 0; }
.qe-row { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.qe-row:hover { background: var(--accent-soft); }
.qe-files { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick-editor label.btn { display: inline-flex; justify-self: start; color: var(--accent-ink); }
#quick-dialog:has(#qe-form:not([hidden])) #qe-new, #quick-dialog:has(#qe-form:not([hidden])) #qe-close { display: none; }
#contact-hint { white-space: pre-line; line-height: 1.5; }

/* Реакции */
.msg.can-react { position: relative; }
.react-bar {
  position: absolute; top: -34px; left: 6px; z-index: 3; display: none; gap: 2px; padding: 3px 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 4px 14px rgb(0 0 0 / 12%);
  white-space: nowrap;
}
.msg.out .react-bar { left: auto; right: 6px; }
.react-bar button { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 4px; border-radius: 50%; cursor: pointer; transition: transform .12s; }
.react-bar button:hover, .react-bar button:focus-visible { transform: scale(1.25); background: var(--accent-soft); outline: none; }
.react-bar button.on { background: var(--accent-soft); }
@media (hover: hover) { .msg.can-react:hover .react-bar, .msg.can-react:focus-within .react-bar { display: flex; } }
.msg.show-react .react-bar { display: flex; }
.msg-reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react-chip { font: inherit; font-size: 14px; line-height: 1; padding: 3px 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
button.react-chip.ours { background: var(--accent-soft); border-color: var(--accent); cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .react-bar button { transition: none; } }

/* Ответ на сообщение */
.react-bar .react-reply { font-size: 13px; border-radius: 999px; padding: 4px 10px; color: var(--accent-ink); font-weight: 600; }
.react-bar .react-reply:hover { transform: none; }
.msg-quote {
  display: grid; gap: 1px; text-align: left; width: 100%; font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  border: 0; border-left: 3px solid var(--accent); background: rgb(0 0 0 / 4%); border-radius: 8px; padding: 4px 8px; margin: 2px 0 4px;
}
.msg-quote b { font-size: 12px; color: var(--accent-ink); }
.msg-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replying-bar { display: flex; gap: 10px; align-items: center; padding: 8px 12px 0; background: var(--panel); border-top: 1px solid var(--line); }
.replying-bar + .attach-bar, .replying-bar + .attach-bar[hidden] + .reply { border-top: 0; }
.replying-info { flex: 1; min-width: 0; display: grid; border-left: 3px solid var(--accent); padding-left: 8px; font-size: 13px; }
.replying-info b { color: var(--accent-ink); font-size: 12px; }
.replying-info span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .msg.flash { animation: none; outline: 3px solid var(--accent); } }
.menu a.menu-link { display: block; padding: 11px 16px; color: var(--text); text-decoration: none; }
.menu a.menu-link:hover, .menu a.menu-link:focus-visible { background: var(--accent-soft); outline: none; }
