/* =====================================================================
   2dodo — оформление в духе современных приложений
   Главный цвет (--accent) выбирает пользователь в «Оформлении», остальные оттенки считаются из него.
   Тёмная тема по умолчанию, светлая — data-theme="light"; фон чата — data-wallpaper.
   ===================================================================== */
:root {
  --accent: #8774e1;
  --accent-hover: color-mix(in srgb, var(--accent) 86%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 62%, #fff);
  --app-bg:
    radial-gradient(at 0 0, color-mix(in srgb, var(--accent) 16%, transparent) 0, transparent 45%),
    radial-gradient(at 100% 100%, color-mix(in srgb, var(--accent) 10%, transparent) 0, transparent 40%),
    #0b0b0e;
  --surface: #16171b;          /* боковая панель, шапка, окна */
  --surface-2: #202228;        /* поля ввода, наведение */
  --surface-3: #2a2d35;        /* нажатие, разделители */
  --border: rgba(255, 255, 255, .06);
  --text: #f1f2f5;
  --muted: #8b909c;
  --danger: #ff5c5c;
  --success: #4fce5d;
  --bubble-in: #202228;
  --bubble-out: linear-gradient(140deg, color-mix(in srgb, var(--accent) 75%, #fff) 0%, var(--accent) 55%, color-mix(in srgb, var(--accent) 82%, #000) 100%);
  --bubble-out-solid: color-mix(in srgb, var(--accent) 82%, #000); /* цвет «хвостика» исходящего сообщения */
  --text-out: #fff;
  --meta-in: #858a96;
  --meta-out: rgba(255, 255, 255, .72);
  --link-out: #fff;
  --out-chip: rgba(255, 255, 255, .2);  /* реакции, цитаты внутри своих сообщений */
  --out-strong: #fff;
  --out-strong-text: var(--bubble-out-solid);
  --quote-bg: var(--accent-soft);
  --glass: rgba(22, 23, 27, .76);
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .22);
  --chip-bg: rgba(0, 0, 0, .3);
  --chat-bg:
    radial-gradient(at 12% 18%, #2a1f4d 0, transparent 55%),
    radial-gradient(at 88% 12%, #12324a 0, transparent 50%),
    radial-gradient(at 78% 88%, #3a1d3f 0, transparent 55%),
    radial-gradient(at 18% 92%, #102f2c 0, transparent 50%),
    #121218;
  --pattern-opacity: .05;
  --pattern-invert: 1;
  --radius: 20px;
  --fs: 15px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --accent-text: color-mix(in srgb, var(--accent) 90%, #000);
  --app-bg:
    radial-gradient(at 0 0, color-mix(in srgb, var(--accent) 14%, transparent) 0, transparent 45%),
    radial-gradient(at 100% 100%, color-mix(in srgb, var(--accent) 10%, transparent) 0, transparent 40%),
    #e9ebf0;
  --surface: #ffffff;
  --surface-2: #f1f2f6;
  --surface-3: #e5e7ed;
  --border: rgba(0, 0, 0, .07);
  --text: #0f1419;
  --muted: #6f7680;
  --danger: #e53935;
  --bubble-in: #ffffff;
  --bubble-out: color-mix(in srgb, var(--accent) 16%, #fff);
  --bubble-out-solid: color-mix(in srgb, var(--accent) 16%, #fff);
  --text-out: #0f1419;
  --meta-in: #8a96a3;
  --meta-out: color-mix(in srgb, var(--accent) 85%, #000);
  --link-out: color-mix(in srgb, var(--accent) 85%, #000);
  --out-chip: color-mix(in srgb, var(--accent) 14%, transparent);
  --out-strong: var(--accent);
  --out-strong-text: #fff;
  --glass: rgba(255, 255, 255, .8);
  --shadow: 0 12px 40px rgba(17, 24, 39, .14);
  --shadow-sm: 0 1px 6px rgba(17, 24, 39, .09);
  --chip-bg: rgba(40, 60, 40, .3);
  --chat-bg:
    radial-gradient(at 10% 20%, #dcebb4 0, transparent 55%),
    radial-gradient(at 90% 15%, #9fd3b5 0, transparent 50%),
    radial-gradient(at 80% 90%, #c6dfa0 0, transparent 55%),
    radial-gradient(at 15% 85%, #a6cfc7 0, transparent 50%),
    #c9dea6;
  --pattern-opacity: .09;
  --pattern-invert: 0;
  color-scheme: light;
}

/* ----- Фоны чата (выбираются в «Оформлении»). Атрибут стоит и на <html>, и на плитках-превью ----- */
[data-wallpaper="ocean"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #0f3b57 0, transparent 55%),
    radial-gradient(at 85% 20%, #1a2b5c 0, transparent 50%),
    radial-gradient(at 70% 90%, #0c4a4a 0, transparent 55%),
    #0b1520;
}
[data-wallpaper="sunset"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #5a2440 0, transparent 55%),
    radial-gradient(at 85% 25%, #5f3418 0, transparent 50%),
    radial-gradient(at 60% 90%, #2f2160 0, transparent 55%),
    #170f17;
  --chip-bg: rgba(0, 0, 0, .3);
}
[data-wallpaper="mono"] {
  --chat-bg: radial-gradient(at 50% 0, color-mix(in srgb, var(--accent) 18%, transparent) 0, transparent 60%), #111115;
  --pattern-opacity: .035;
}
[data-theme="light"][data-wallpaper="ocean"], [data-theme="light"] [data-wallpaper="ocean"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #bfe3f2 0, transparent 55%),
    radial-gradient(at 85% 20%, #b6c9f2 0, transparent 50%),
    radial-gradient(at 70% 90%, #b3e5df 0, transparent 55%),
    #c7dcef;
  --chip-bg: rgba(30, 60, 90, .3);
}
[data-theme="light"][data-wallpaper="sunset"], [data-theme="light"] [data-wallpaper="sunset"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #f8d3c0 0, transparent 55%),
    radial-gradient(at 85% 20%, #f2c1d6 0, transparent 50%),
    radial-gradient(at 60% 90%, #f9e4b5 0, transparent 55%),
    #f2d4c9;
  --chip-bg: rgba(120, 60, 40, .3);
}
[data-theme="light"][data-wallpaper="mono"], [data-theme="light"] [data-wallpaper="mono"] {
  --chat-bg: radial-gradient(at 50% 0, color-mix(in srgb, var(--accent) 14%, transparent) 0, transparent 60%), #eef0f4;
  --chip-bg: rgba(0, 0, 0, .28);
  --pattern-opacity: .05;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--app-bg);
  color: var(--text);
  font: var(--fs)/1.42 "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ----- Иконки ----- */
.ico { width: 24px; height: 24px; display: inline-grid; place-items: center; flex-shrink: 0; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico.filled svg { fill: currentColor; stroke: none; }

/* ----- Кнопки и поля ----- */
.btn {
  border: 0; border-radius: 12px; padding: 13px 18px; background: var(--accent); color: #fff; font-weight: 600;
  transition: background .15s, transform .1s; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--accent-text); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: rgba(255, 92, 92, .1); }
.btn.with-icon { justify-content: flex-start; padding: 12px 14px; font-weight: 500; }
.btn.with-icon.btn:not(.ghost):not(.danger) { justify-content: center; }
.icon-btn {
  background: none; border: 0; color: var(--muted); border-radius: 50%; display: grid; place-items: center;
  width: 40px; height: 40px; flex-shrink: 0; transition: background .15s, color .15s; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--surface-3); }
.link-btn { background: none; border: 0; color: var(--accent-text); padding: 4px; font-size: 14px; }
input:not([type=checkbox]), textarea {
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px; padding: 12px 14px; outline: none; width: 100%;
  transition: border-color .15s, background .15s;
}
input:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }

/* ----- Плашка связи и подсказки ----- */
.conn {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100; text-align: center; padding: 7px;
  padding-top: calc(7px + env(safe-area-inset-top)); background: var(--danger); color: #fff; font-size: 14px; font-weight: 500;
}
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 95;
  background: rgba(20, 20, 24, .92); color: #fff; padding: 10px 18px; border-radius: 14px; font-size: 14px; max-width: 90vw;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ===================== Экран входа ===================== */
.auth {
  height: 100%; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: var(--chat-bg); position: relative;
}
.auth::before, .chat::before {
  /* узор поверх градиента, как обои в Telegram */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: var(--pattern-opacity);
  background-image: url("pattern.svg"); background-size: 360px; filter: invert(var(--pattern-invert));
}
.auth-card {
  position: relative; width: 100%; max-width: 380px; background: var(--glass); backdrop-filter: blur(24px);
  padding: 36px 28px 28px; border-radius: 28px; display: flex; flex-direction: column; gap: 12px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid var(--border); animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.logo {
  width: 104px; height: 104px; margin: 0 auto 6px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 65%, #fff), var(--accent)); box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 45%, transparent);
}
.logo .ico { width: 52px; height: 52px; margin-left: -4px; }
.auth-card h1 { margin: 0; font-size: 26px; letter-spacing: -.3px; }
.auth-card p { margin: 0 0 8px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ===================== Раскладка ===================== */
.app { display: flex; height: 100%; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w, 380px); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: relative;
}
.chat { flex: 1; display: flex; min-width: 0; background: var(--chat-bg); position: relative; }
.chat > * { position: relative; }
.sidebar-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px 6px; padding-top: calc(10px + env(safe-area-inset-top)); }
.search-box { flex: 1; position: relative; }
.search-box .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
#search { border-radius: 22px; padding: 10px 16px 10px 42px; }

/* ----- Папки (вкладки над списком чатов) ----- */
.folders { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.folders::-webkit-scrollbar { display: none; }
.folder-tab {
  position: relative; background: none; border: 0; padding: 11px 12px 12px; color: var(--muted); font-weight: 500; font-size: 14px;
  white-space: nowrap; border-radius: 10px 10px 0 0; transition: color .15s, background .15s; display: flex; gap: 6px; align-items: center;
}
.folder-tab:hover { background: var(--surface-2); }
.folder-tab.active { color: var(--accent-text); }
.folder-tab.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent);
}
.folder-tab .count { background: var(--muted); color: var(--surface); border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 700; line-height: 17px; }
.folder-tab.active .count { background: var(--accent); color: #fff; }

/* ===================== Аватары ===================== */
.avatar {
  flex-shrink: 0; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 600; font-size: 21px; color: #fff; position: relative; user-select: none; text-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.avatar.sm { width: 42px; height: 42px; font-size: 17px; }
.avatar.xs { width: 34px; height: 34px; font-size: 14px; }
.avatar.lg { width: 66px; height: 66px; font-size: 26px; }
.avatar.xl { width: 120px; height: 120px; font-size: 46px; }
.avatar .ico { width: 55%; height: 55%; }
.avatar.online::after {
  content: ""; position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px;
  background: var(--success); border: 3px solid var(--surface); border-radius: 50%;
}
.avatar.sm.online::after, .avatar.xs.online::after { width: 11px; height: 11px; border-width: 2px; }

/* ===================== Список чатов ===================== */
.chat-list { list-style: none; margin: 0; padding: 6px 8px 96px; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; gap: 12px; padding: 9px 10px; border-radius: 14px; cursor: pointer; align-items: center; user-select: none;
  transition: background .12s;
}
@keyframes fade-in { from { opacity: 0; } }
/* плавно появляется только новая строка, а не весь список при каждом обновлении */
.chat-item.appear { animation: fade-in .2s ease; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent); color: #fff; }
.chat-item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item .name .ico { width: 16px; height: 16px; }
/* своё имя человека в 2dodo рядом с именем из «Контактов»: тем же размером, но бледнее и не жирным */
.name .alias, #chatTitle .alias { font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; min-width: 0; }
.name .alias::before, #chatTitle .alias::before { content: "·"; margin: 0 5px 0 2px; }
.chat-item .time { color: var(--muted); font-size: 12.5px; flex-shrink: 0; display: flex; align-items: center; gap: 2px; }
.chat-item .time .ico { width: 17px; height: 17px; color: var(--accent-text); }
.chat-item .preview { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.chat-item .preview .typing { color: var(--accent-text); }
.chat-item .preview b { color: var(--text); font-weight: 500; }
.chat-item.active .preview, .chat-item.active .time, .chat-item.active .preview b,
.chat-item.active .preview .typing, .chat-item.active .time .ico, .chat-item.active .ic { color: rgba(255, 255, 255, .85); }
.badge {
  background: var(--success); color: #fff; border-radius: 12px; font-size: 12px; padding: 0 7px; font-weight: 700;
  flex-shrink: 0; min-width: 22px; height: 22px; line-height: 22px; text-align: center;
}
.badge.muted { background: var(--muted); }
.badge.at { background: var(--accent); }
.chat-item.active .badge { background: #fff; color: var(--accent); }
.ic { color: var(--muted); display: inline-flex; }
.ic .ico { width: 17px; height: 17px; }
.section-title { color: var(--muted); font-size: 13px; font-weight: 600; padding: 14px 12px 6px; list-style: none; }
.fab {
  position: absolute; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px;
  border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .15s, background .15s;
}
.fab:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ===================== Окно чата ===================== */
.empty { margin: auto; }
.empty > span { background: rgba(0, 0, 0, .28); padding: 6px 14px; border-radius: 16px; color: #fff; font-size: 14px; backdrop-filter: blur(8px); }
.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
/* выбор модели и кнопка «Выложить» в шапке чата «Claude» */
.chat-head-model { display: inline-flex; align-items: center; gap: 2px; height: 34px; padding: 0 8px 0 12px; border: 1px solid var(--border, rgba(255,255,255,.12)); border-radius: 17px; background: transparent; color: inherit; font: inherit; font-size: 13.5px; cursor: pointer; flex-shrink: 0; white-space: nowrap; }
.chat-head-model .ico { width: 16px; height: 16px; }
@media (max-width: 700px) { .chat-head-model { font-size: 12.5px; padding: 0 6px 0 10px; } }
.chat-head-action { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: 17px; background: var(--accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.chat-head-action .ico { width: 16px; height: 16px; }
.chat-head-action:disabled { opacity: .5; cursor: default; }
@media (max-width: 700px) { .chat-head-action .label { display: none; } .chat-head-action { padding: 0 9px; } }
.chat-header {
  display: flex; align-items: center; gap: 4px; padding: 8px 12px 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.4); border-bottom: 1px solid var(--border); min-height: 60px; z-index: 3;
}
.chat-head-info { display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; flex: 1; padding: 2px 0; }
.chat-head-text { min-width: 0; }
.chat-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 4px; align-items: center; }
.chat-title .ico { width: 16px; height: 16px; color: var(--muted); }
.chat-status { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status.online, .chat-status.typing { color: var(--accent-text); }
.back { display: none; }

.pinned-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; background: var(--glass); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); cursor: pointer; z-index: 2;
}
.pinned-text { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; border-radius: 2px; }
.pinned-title { color: var(--accent-text); font-size: 13px; font-weight: 600; }
.pinned-body { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 12px max(14px, calc((100% - 740px) / 2)) 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.date-sep, .unread-sep {
  align-self: center; background: rgba(0, 0, 0, .28); color: #fff; padding: 4px 12px; border-radius: 14px;
  font-size: 13px; font-weight: 500; margin: 12px 0 8px; backdrop-filter: blur(10px);
}
.date-sep { position: sticky; top: 6px; z-index: 1; }
.unread-sep { background: var(--accent); }

/* ----- Сообщения ----- */
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.msg-row.cont { margin-top: 0; }
.msg-row.out { justify-content: flex-end; }
.msg-row.new { animation: msg-in .22s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.msg-row .avatar { margin-bottom: 1px; cursor: pointer; }
.msg-row .avatar-spacer { width: 34px; flex-shrink: 0; }
.msg {
  max-width: min(500px, 78%); padding: 7px 11px 7px 12px; border-radius: var(--radius); background: var(--bubble-in);
  white-space: pre-wrap; overflow-wrap: anywhere; position: relative; box-shadow: var(--shadow-sm); user-select: text;
}
.msg-row.out .msg { background: var(--bubble-out); color: var(--text-out); }
/* «хвостик» у последнего сообщения в пачке, как в Telegram */
.msg.tail::before {
  /* прямоугольник у нижнего угла, из которого вырезан эллипс — получается изогнутый хвостик */
  content: ""; position: absolute; bottom: 0; width: 10px; height: 17px; background: var(--bubble-in);
  -webkit-mask: radial-gradient(10px 15px at var(--tail-x) 0, transparent 98%, #000 100%);
  mask: radial-gradient(10px 15px at var(--tail-x) 0, transparent 98%, #000 100%);
}
.msg-row:not(.out) .msg.tail { border-bottom-left-radius: 0; }
.msg-row:not(.out) .msg.tail::before { left: -9px; --tail-x: 0; }
.msg-row.out .msg.tail { border-bottom-right-radius: 0; }
.msg-row.out .msg.tail::before { right: -9px; --tail-x: 100%; background: var(--bubble-out-solid); }
.msg-row:not(.out) .msg.grouped { border-bottom-left-radius: 6px; }
.msg-row:not(.out).cont .msg { border-top-left-radius: 6px; }
.msg-row.out .msg.grouped { border-bottom-right-radius: 6px; }
.msg-row.out.cont .msg { border-top-right-radius: 6px; }
/* фото и видео — на всю ширину пузыря, без рамки; углы фото повторяют углы пузыря */
.msg.has-image { padding: 0; }
.msg.has-image > .img, .msg.has-image > .album, .msg.has-image > .video { border-radius: inherit; width: 100%; }
.msg.has-image > :is(.img, .album, .video):not(:first-child) { border-top-left-radius: 0; border-top-right-radius: 0; }
.msg.has-image > :is(.img, .album, .video):not(:last-child):not(:has(+ .meta.over)) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.msg.has-image > :is(.author, .forwarded, .quote) { margin-left: 10px; margin-right: 10px; }
.msg.has-image > :is(.author, .forwarded):first-child { margin-top: 6px; }
.msg.has-image > .quote { margin-top: 6px; margin-bottom: 6px; }
.msg.has-image > .meta:not(.over) { margin: 4px 10px 6px 12px; }
.msg.has-image > .reactions, .msg.has-image > .remind-open { margin: 4px 8px 6px; }
.msg.has-image .caption { padding: 6px 11px 7px 12px; }
.msg.has-image .caption .meta { margin-right: -3px; }
/* время поверх фото без подписи — на тёмной полупрозрачной плашке */
.msg .meta.over {
  position: absolute; right: 6px; bottom: 6px; float: none; margin: 0; padding: 3px 7px; border-radius: 10px;
  background: rgba(0, 0, 0, .45); color: #fff !important; pointer-events: none;
}
.msg-row.out .msg .meta.over { color: #fff; }
.msg .meta.over .ticks { color: #fff; }
.msg.highlight { animation: flash 1.4s; }
@keyframes flash { 0%, 50% { filter: brightness(1.45); transform: scale(1.02); } }
.msg .author { font-weight: 600; font-size: 14px; margin-bottom: 2px; cursor: pointer; }
.msg .meta {
  float: right; font-size: 12px; color: var(--meta-in); margin: 8px -3px -5px 12px; white-space: nowrap; user-select: none;
  display: inline-flex; align-items: center; gap: 2px; line-height: 1;
}
.msg-row.out .msg .meta { color: var(--meta-out); }
.ticks { display: inline-flex; }
.ticks .ico { width: 17px; height: 17px; }
.msg .img {
  display: block; max-width: 100%; max-height: 380px; border-radius: 14px; cursor: zoom-in; min-width: 140px; object-fit: cover;
}
.quote {
  border-left: 3px solid var(--accent-text); padding: 4px 9px; margin: 2px 0 5px; border-radius: 6px;
  background: var(--quote-bg); cursor: pointer; font-size: 14px; overflow: hidden; transition: filter .15s;
}
.quote:hover { filter: brightness(1.1); }
.msg-row.out .quote { border-color: var(--meta-out); background: rgba(255, 255, 255, .14); }
.quote-author { font-weight: 600; color: var(--accent-text); font-size: 13px; }
.msg-row.out .quote-author { color: inherit; }
.quote-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg code { font-family: "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace; font-size: 13.5px; background: rgba(127, 127, 127, .18); padding: 1px 5px; border-radius: 5px; }
.msg pre {
  font-family: "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace; font-size: 13px; background: rgba(0, 0, 0, .25); padding: 10px 12px;
  border-radius: 10px; margin: 4px 0; overflow-x: auto; white-space: pre; border-left: 3px solid var(--accent-text);
}
:root[data-theme="light"] .msg pre { background: rgba(0, 0, 0, .05); }
.msg a { color: var(--accent-text); }
.msg-row.out .msg a { color: var(--link-out); text-decoration: underline; }
.spoiler { background: var(--muted); color: transparent; border-radius: 5px; cursor: pointer; transition: .25s; user-select: none; filter: blur(.3px); }
.spoiler.revealed { background: rgba(127, 127, 127, .2); color: inherit; filter: none; }
.mention { color: var(--accent-text); cursor: pointer; font-weight: 500; }
.msg-row.out .mention { color: inherit; text-decoration: underline; }
.mention.me { background: var(--accent-soft); border-radius: 5px; padding: 0 3px; }
.msg.mentions-me { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
.forwarded { color: var(--accent-text); font-size: 13px; margin-bottom: 3px; font-weight: 500; }
.msg-row.out .forwarded { color: inherit; opacity: .85; }
.forwarded b { cursor: pointer; }
.to-bottom {
  position: absolute; right: 18px; bottom: 90px; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow); z-index: 3;
  animation: pop .15s ease;
}
.to-bottom:hover { color: var(--text); }
.empty-chat {
  margin: auto; text-align: center; background: rgba(0, 0, 0, .28); color: #fff; padding: 18px 22px; border-radius: 20px;
  font-size: 14.5px; max-width: 320px; backdrop-filter: blur(10px);
}

/* ----- Вложения ----- */
.msg .video { display: block; max-width: 100%; max-height: 380px; border-radius: 14px; background: #000; }
.file-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; padding: 3px 0; min-width: 210px; }
.file-icon {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0;
}
.msg-row.out .file-icon { background: rgba(255, 255, 255, .22); }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { color: var(--meta-in); font-size: 13px; }
.msg-row.out .file-size { color: var(--meta-out); }
.voice { display: flex; align-items: center; gap: 12px; min-width: 230px; padding: 3px 0; }
.voice-play {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0; transition: transform .1s;
}
.voice-play:active { transform: scale(.93); }
.voice-play .ico { width: 20px; height: 20px; }
.msg-row.out .voice-play { background: #fff; color: var(--bubble-out-solid); }
.voice-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.voice-track { height: 4px; border-radius: 2px; background: rgba(127, 127, 127, .35); cursor: pointer; position: relative; }
.voice-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-text); border-radius: 2px; }
.msg-row.out .voice-fill { background: currentColor; }
.voice-time { font-size: 12px; color: var(--meta-in); }
.msg-row.out .voice-time { color: var(--meta-out); }
.call-msg { display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 190px; padding: 2px 0; }
.call-msg .call-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.msg-row.out .call-msg .call-icon { background: rgba(255, 255, 255, .2); color: inherit; }
.call-msg .missed { color: var(--danger); }
.call-msg .sub { font-size: 13px; color: var(--meta-in); }
.msg-row.out .call-msg .sub { color: var(--meta-out); }

/* ----- Опрос ----- */
.poll { min-width: 250px; display: flex; flex-direction: column; gap: 7px; padding: 2px 0; }
.poll-q { font-weight: 700; font-size: 15.5px; }
.poll-kind { font-size: 13px; color: var(--meta-in); margin-top: -5px; }
.msg-row.out .poll-kind, .msg-row.out .poll-total { color: var(--meta-out); }
.poll-opt {
  position: relative; text-align: left; border: 0; background: rgba(127, 127, 127, .13); border-radius: 10px; padding: 9px 12px;
  overflow: hidden; display: flex; gap: 8px; align-items: center; transition: background .15s;
}
.poll-opt:hover { background: rgba(127, 127, 127, .2); }
.poll-opt .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .3; transition: width .35s ease; }
.msg-row.out .poll-opt .bar { background: #fff; }
.poll-opt span { position: relative; }
.poll-opt .pct { margin-left: auto; font-weight: 700; font-size: 13px; }
.poll-opt.mine { box-shadow: inset 0 0 0 2px var(--accent-text); }
.msg-row.out .poll-opt.mine { box-shadow: inset 0 0 0 2px currentColor; }
.poll-total { font-size: 13px; color: var(--meta-in); }
.poll-options-edit { display: flex; flex-direction: column; gap: 8px; }
.poll-options-edit .opt-row { display: flex; gap: 6px; align-items: center; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14.5px; cursor: pointer; }
.check input { width: 19px; height: 19px; accent-color: var(--accent); }

/* ----- Реакции ----- */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; clear: both; }
.reaction {
  border: 0; border-radius: 16px; padding: 3px 9px 3px 7px; font-size: 14px; background: var(--accent-soft); color: var(--accent-text);
  display: flex; gap: 5px; align-items: center; font-weight: 600; transition: transform .1s; animation: pop .2s ease;
}
.reaction:active { transform: scale(.92); }
.reaction.mine { background: var(--accent); color: #fff; }
.msg-row.out .reaction { background: rgba(255, 255, 255, .2); color: inherit; }
.msg-row.out .reaction.mine { background: #fff; color: var(--bubble-out-solid); }

/* ===================== Поле ввода ===================== */
.composer-wrap {
  padding: 6px max(14px, calc((100% - 740px) / 2)) 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 2;
}
.composer { display: flex; align-items: flex-end; gap: 8px; }
.input-box {
  flex: 1; min-width: 0; background: var(--surface); border-radius: 18px 18px 0 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; position: relative;
}
.input-box::after {
  /* хвостик у поля ввода */
  content: ""; position: absolute; right: -9px; bottom: 0; width: 10px; height: 17px; background: var(--surface);
  -webkit-mask: radial-gradient(10px 15px at 100% 0, transparent 98%, #000 100%);
  mask: radial-gradient(10px 15px at 100% 0, transparent 98%, #000 100%);
}
.input-row { display: flex; align-items: flex-end; gap: 2px; padding: 4px 6px; }
.input-row .icon-btn { width: 42px; height: 42px; }
.composer textarea {
  flex: 1; resize: none; border: 0; background: none; padding: 11px 4px; max-height: 180px; line-height: 1.38; border-radius: 0;
}
.composer textarea:focus { border: 0; background: none; }
.round-btn {
  width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--surface); color: var(--muted);
  display: grid; place-items: center; flex-shrink: 0; box-shadow: var(--shadow-sm); transition: background .15s, color .15s, transform .1s;
}
.round-btn:hover { color: var(--accent-text); }
.round-btn:active { transform: scale(.94); }
.round-btn.primary { background: var(--accent); color: #fff; }
.round-btn.primary:hover { background: var(--accent-hover); color: #fff; }
.round-btn .ico { width: 26px; height: 26px; }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 6px 2px 14px; animation: fade-in .15s; }
.reply-bar-icon { color: var(--accent-text); display: grid; }
.reply-bar-text { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding: 1px 0 1px 9px; border-radius: 2px; }
.reply-bar-title { color: var(--accent-text); font-weight: 600; font-size: 14px; }
.reply-bar-body { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emoji-panel, .suggest-box, .upload-bar {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 8px; animation: pop .15s ease;
}
.emoji-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; max-height: 240px; overflow-y: auto; padding: 10px; }
.emoji-panel button { background: none; border: 0; font-size: 26px; padding: 4px; border-radius: 10px; transition: transform .1s; }
.emoji-panel button:hover { background: var(--surface-2); transform: scale(1.15); }
.suggest-box { list-style: none; padding: 6px; max-height: 280px; overflow-y: auto; margin-top: 0; }
.suggest-box li { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 12px; cursor: pointer; }
.suggest-box li.selected, .suggest-box li:hover { background: var(--surface-2); }
.suggest-box .sub { color: var(--muted); font-size: 13px; }
.suggest-box .cmd { font-weight: 700; color: var(--accent-text); min-width: 78px; }
.upload-bar { position: relative; padding: 10px 16px; font-size: 14px; overflow: hidden; }
.upload-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .22; width: 0; transition: width .2s; }
.upload-bar span { position: relative; }
.record-bar { align-items: center; }
.record-bar .input-box { flex-direction: row; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; min-height: 52px; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 42px; font-weight: 600; }
.rec-hint { flex: 1; font-size: 14px; }
.channel-bar { display: flex; justify-content: center; }
.channel-bar .btn { width: 100%; max-width: 420px; background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.channel-bar .btn:hover { background: var(--surface-2); }

/* ===================== Боковое меню ===================== */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; animation: fade-in .2s; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 85vw; background: var(--surface); z-index: 41;
  transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
  box-shadow: var(--shadow); padding: env(safe-area-inset-top) 8px 8px;
}
.drawer.open { transform: none; }
.drawer-head { padding: 22px 14px 16px; display: flex; flex-direction: column; gap: 3px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.drawer-head .avatar { margin-bottom: 10px; }
.drawer-name { font-weight: 700; font-size: 17px; }
.drawer-item {
  background: none; border: 0; text-align: left; padding: 12px 14px; font-size: 15px; display: flex; gap: 18px; align-items: center;
  border-radius: 12px; font-weight: 500; transition: background .12s;
}
.drawer-item .ico { color: var(--muted); }
.drawer-item:hover { background: var(--surface-2); }
.drawer-item.danger, .drawer-item.danger .ico { color: var(--danger); }
.drawer-foot { margin-top: auto; padding: 12px 14px; color: var(--muted); font-size: 12px; }

/* ===================== Окна ===================== */
.modal-overlay { display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal {
  width: 100%; max-width: 420px; max-height: 90dvh; overflow-y: auto; background: var(--surface); border-radius: 24px;
  padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes modal-in { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 19px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field textarea { color: var(--text); font-size: 15px; resize: none; font-weight: 400; }
/* выпадающий список в поле формы — тем же шрифтом, что и поля ввода (иначе он брал мелкий жирный шрифт подписи) */
.field select { color: var(--text); font-size: 15px; font-weight: 400; padding: 12px 14px; }
.avatar-edit { align-self: center; position: relative; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.avatar-edit .avatar::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: rgba(0, 0, 0, .35) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E") center/40px no-repeat;
  opacity: 0; transition: opacity .15s;
}
.avatar-edit:hover .avatar::before { opacity: 1; }
.avatar-edit-hint { color: var(--accent-text); font-size: 14px; font-weight: 500; }
#avatarRemove, #groupAvatarRemove { align-self: center; margin-top: -10px; color: var(--muted); }
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-picker button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s; }
.color-picker button.selected { box-shadow: 0 0 0 2px var(--text); }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.pick-list label { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; cursor: pointer; }
.pick-list label:hover { background: var(--surface-2); }
.pick-list .pick-name { flex: 1; }
.pick-list input { width: 21px; height: 21px; accent-color: var(--accent); }
.info-top { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 4px 0 6px; }
.info-top .avatar { margin-bottom: 10px; cursor: zoom-in; box-shadow: var(--shadow-sm); }
.info-name { font-size: 21px; font-weight: 700; }
.info-rows { display: flex; flex-direction: column; gap: 2px; }
.info-row { padding: 9px 10px; border-radius: 12px; }
.info-row:hover { background: var(--surface-2); }
.info-row .label { font-size: 13px; color: var(--muted); }
.info-row .value { white-space: pre-wrap; overflow-wrap: anywhere; }
.info-member { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 12px; cursor: pointer; }
.info-member:hover { background: var(--surface-2); }
.info-member .who { flex: 1; min-width: 0; }
.info-member .tag { font-size: 12px; color: var(--accent-text); font-weight: 600; }
.info-member .remove { color: var(--danger); }
.info-actions { display: flex; flex-direction: column; gap: 2px; }
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.segmented button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; display: flex; gap: 8px; justify-content: center; align-items: center; color: var(--muted); transition: .15s; }
.segmented button .ico { width: 20px; height: 20px; }
.segmented button.selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.help h3 { margin: 16px 0 4px; font-size: 15px; }
.help h3:first-child { margin-top: 0; }
.help p { margin: 4px 0; font-size: 14px; line-height: 1.55; }
.help code, kbd { font-family: "JetBrains Mono", Consolas, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ===================== Меню ===================== */
.ctx-menu {
  position: fixed; z-index: 60; background: var(--glass); backdrop-filter: blur(24px) saturate(1.6); border-radius: 16px;
  padding: 6px; min-width: 210px; max-width: calc(100vw - 16px); box-shadow: var(--shadow); border: 1px solid var(--border);
  max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  animation: pop .14s ease; transform-origin: top left;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.ctx-menu > button {
  display: flex; gap: 14px; align-items: center; width: 100%; background: none; border: 0; text-align: left; padding: 9px 12px;
  font-size: 14.5px; border-radius: 10px; font-weight: 500;
}
.ctx-menu > button .ico { width: 21px; height: 21px; color: var(--muted); }
.ctx-menu > button:hover { background: var(--surface-2); }
.ctx-menu > button.danger, .ctx-menu > button.danger .ico { color: var(--danger); }
.ctx-reactions { display: flex; gap: 0; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.ctx-reactions button {
  font-size: 22px; border: 0; background: none; border-radius: 50%; width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center; transition: transform .12s, background .12s;
}
.ctx-reactions button:hover { transform: scale(1.25); background: var(--surface-2); }

/* ===================== Просмотр фото ===================== */
.viewer {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .88); display: grid; place-items: center; cursor: zoom-out;
  animation: fade-in .2s; backdrop-filter: blur(6px);
}
.viewer img { max-width: 96vw; max-height: 92dvh; border-radius: 10px; animation: modal-in .25s ease; }

/* ===================== Звонок ===================== */
.call-screen {
  position: fixed; inset: 0; z-index: 80; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background: radial-gradient(at 30% 20%, #4b3a9e 0, transparent 60%), radial-gradient(at 70% 80%, #1d4f7a 0, transparent 60%), #14141c;
  animation: fade-in .25s;
}
.remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.remote-video.no-video { opacity: 0; }
.local-video {
  position: absolute; right: 16px; top: calc(16px + env(safe-area-inset-top)); width: 28vw; max-width: 220px; border-radius: 16px;
  background: #222; transform: scaleX(-1); box-shadow: var(--shadow); z-index: 2;
}
.call-info { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.call-info.over-video { position: absolute; top: calc(20px + env(safe-area-inset-top)); left: 20px; align-items: flex-start; text-shadow: 0 1px 4px #000; }
.call-info.over-video .avatar { display: none; }
.call-name { font-size: 28px; font-weight: 700; }
.call-status { color: rgba(255, 255, 255, .7); font-variant-numeric: tabular-nums; }
.call-actions {
  position: absolute; bottom: calc(44px + env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: center; gap: 26px; z-index: 2;
}
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; color: #fff; font-size: 13px; }
.call-btn .circle {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .16);
  backdrop-filter: blur(10px); transition: transform .1s, background .15s;
}
.call-btn .circle .ico { width: 28px; height: 28px; }
.call-btn:hover .circle { background: rgba(255, 255, 255, .26); }
.call-btn:active .circle { transform: scale(.92); }
.call-btn.off .circle { background: #fff; color: #111; }
.call-btn.red .circle { background: #f04848; }
.call-btn.green .circle { background: #3fbf5a; }
.call-screen .avatar.ringing { animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(135, 116, 225, .7); } 70% { box-shadow: 0 0 0 30px rgba(135, 116, 225, 0); } }

/* ===================== Телефон ===================== */
@media (max-width: 760px) {
  .sidebar { width: 100%; border: 0; }
  .chat { display: none; }
  .app.in-chat .sidebar { display: none; }
  .app.in-chat .chat { display: flex; }
  .back { display: grid; }
  .chat-header { padding-left: 4px; gap: 0; }
  .chat-header .icon-btn { width: 38px; }
  .msg { max-width: 86%; }
  .to-bottom { right: 12px; }
  .composer-wrap { padding-left: 8px; padding-right: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .round-btn { width: 50px; height: 50px; }
  /* 16px в полях — иначе iPhone приближает страницу при вводе */
  input:not([type=checkbox]), textarea, .composer textarea { font-size: 16px; }
  /* окна выезжают снизу, как на телефоне */
  .modal-overlay { place-items: end center; padding: 0; }
  .modal {
    max-width: none; border-radius: 24px 24px 0 0; max-height: 92dvh;
    padding-bottom: calc(22px + env(safe-area-inset-bottom)); animation: slide-up .25s cubic-bezier(.2, .9, .3, 1);
  }
  @keyframes slide-up { from { transform: translateY(60%); opacity: .4; } }
  .poll, .voice, .file-card { min-width: 0; }
  .folder-tab { padding: 10px 10px 11px; }
}
@media (hover: none) {
  .icon-btn:hover, .chat-item:hover, .drawer-item:hover, .emoji-panel button:hover { background: none; transform: none; }
  /* долгое нажатие открывает наше меню, а не системное выделение текста */
  .msg { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* =====================================================================
   Версия 2: «плавающие» панели, оформление, приветствие, быстрые действия
   ===================================================================== */

/* ----- Плавающие панели на широком экране ----- */
@media (min-width: 900px) {
  .app { padding: 10px; gap: 10px; }
  .sidebar, .chat { border-radius: 24px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
  .sidebar { width: var(--sidebar-w, 370px); }
}

/* ----- Активный чат: мягкая подсветка вместо сплошной заливки ----- */
.chat-item.active { background: var(--accent-soft); color: var(--text); position: relative; }
.chat-item.active::before {
  content: ""; position: absolute; left: -8px; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.chat-item.active .preview, .chat-item.active .time, .chat-item.active .ic { color: var(--muted); }
.chat-item.active .preview b { color: var(--text); }
.chat-item.active .preview .typing, .chat-item.active .time .ico { color: var(--accent-text); }
.chat-item.active .badge { background: var(--success); color: #fff; }
.chat-item.active .badge.muted { background: var(--muted); }
.chat-item.active .badge.at { background: var(--accent); }
.chat-item .name { font-size: 15.5px; }

/* ----- Свои сообщения: элементы внутри пузыря ----- */
.msg-row.out .quote, .msg-row.out .reaction, .msg-row.out .call-msg .call-icon, .msg-row.out .file-icon { background: var(--out-chip); }
.msg-row.out .reaction { color: inherit; }
.msg-row.out .reaction.mine, .msg-row.out .voice-play { background: var(--out-strong); color: var(--out-strong-text); }
.msg-row.out .poll-opt .bar { background: var(--out-strong); }
.date-sep, .unread-sep, .empty > span, .empty-chat { background: var(--chip-bg); }
.unread-sep { background: var(--accent); }
.msg { font-size: var(--fs); }
.ticks .ico { color: inherit; }

/* ----- Анимированные точки «печатает…» ----- */
.dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ----- «Скелетон» пока грузится переписка ----- */
.skeleton { display: flex; flex-direction: column; gap: 10px; padding-top: 20px; }
.skeleton div {
  height: 42px; border-radius: 18px; background: var(--bubble-in); opacity: .55; position: relative; overflow: hidden;
}
.skeleton div::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent); animation: shimmer 1.2s infinite;
}
.skeleton .r { align-self: flex-end; background: var(--bubble-out-solid); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ----- Быстрые действия при наведении на сообщение ----- */
.msg-actions {
  display: flex; gap: 2px; align-self: center; opacity: 0; transform: scale(.9); transition: opacity .12s, transform .12s;
  background: var(--glass); backdrop-filter: blur(16px); border-radius: 14px; padding: 3px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border); pointer-events: none;
}
.msg-actions button {
  width: 32px; height: 32px; border: 0; background: none; border-radius: 10px; color: var(--muted); display: grid; place-items: center; font-size: 17px;
}
.msg-actions button:hover { background: var(--surface-2); color: var(--text); }
.msg-actions .ico { width: 19px; height: 19px; }
.msg-row:hover .msg-actions { opacity: 1; transform: none; pointer-events: auto; }
.msg-row.out .msg-actions { order: -1; }

/* ----- Экран приветствия ----- */
.welcome {
  margin: auto; text-align: center; max-width: 440px; padding: 34px 28px 28px; border-radius: 28px;
  background: var(--glass); backdrop-filter: blur(24px); box-shadow: var(--shadow); border: 1px solid var(--border); animation: rise .35s ease;
}
.welcome .logo { width: 88px; height: 88px; margin-bottom: 14px; background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent)); box-shadow: 0 12px 30px var(--accent-soft); }
.welcome .logo .ico { width: 44px; height: 44px; }
.welcome h2 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.3px; }
.welcome p { margin: 0 0 22px; color: var(--muted); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-actions button {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; border-radius: 18px; border: 1px solid var(--border);
  background: var(--surface-2); font-weight: 600; font-size: 14px; transition: transform .12s, background .12s;
}
.quick-actions button:hover { background: var(--accent-soft); transform: translateY(-2px); }
.quick-actions .ico { width: 26px; height: 26px; color: var(--accent-text); }
.empty { display: flex; width: 100%; padding: 16px; }

/* ----- Шапка бокового меню: кнопка ночного режима ----- */
.drawer-head { position: relative; }
.drawer-head .theme-toggle { position: absolute; right: 8px; top: 18px; }

/* ----- Окно «Оформление» ----- */
.accent-picker { display: flex; gap: 12px; flex-wrap: wrap; }
.accent-picker button {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px transparent; transition: transform .12s, box-shadow .15s;
  display: grid; place-items: center; color: #fff;
}
.accent-picker button:hover { transform: scale(1.08); }
.accent-picker button.selected { box-shadow: 0 0 0 2px var(--text); }
.accent-picker .ico { width: 20px; height: 20px; opacity: 0; }
.accent-picker button.selected .ico { opacity: 1; }
.wallpaper-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.wp-tile {
  position: relative; width: 100%; height: 92px; border-radius: 16px; border: 0; background: var(--chat-bg); overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border); padding: 10px 8px; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px;
}
.wp-tile.selected { box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 1px var(--border); }
.wp-tile .b { height: 12px; border-radius: 7px; background: var(--bubble-in); width: 70%; }
.wp-tile .b.o { align-self: flex-end; background: var(--bubble-out); width: 55%; }
.wp-label { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 4px; }
.segmented.three button { font-size: 14px; }
.preview-chat { border-radius: 18px; padding: 14px; background: var(--chat-bg); display: flex; flex-direction: column; gap: 6px; box-shadow: inset 0 0 0 1px var(--border); }
.preview-chat .msg { max-width: 85%; font-size: var(--fs); }
.preview-chat .msg-row { margin: 0; }

/* ----- Телефон: плавные переходы между списком и чатом ----- */
@media (max-width: 760px) {
  .app.in-chat .chat { animation: slide-in .26s cubic-bezier(.2, .8, .2, 1); }
  .app:not(.in-chat) .sidebar { animation: slide-back .26s cubic-bezier(.2, .8, .2, 1); }
  @keyframes slide-in { from { transform: translateX(40%); opacity: .3; } }
  @keyframes slide-back { from { transform: translateX(-20%); opacity: .5; } }
  .msg-actions { display: none; }
  .quick-actions button { padding: 14px 8px; }
  .chat-item.active { background: none; }
  .chat-item.active::before { display: none; }
  .wallpaper-picker { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   Версия 3: инструменты для компьютера
   ===================================================================== */

/* ----- Поиск внутри чата ----- */
.chat-search {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 16px; background: var(--glass); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); z-index: 3; animation: fade-in .15s;
}
.chat-search > .ico { color: var(--muted); width: 20px; height: 20px; }
.chat-search input { flex: 1; background: none; border: 0; padding: 8px 4px; }
.chat-search input:focus { background: none; border: 0; }
.chat-search-count { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg.found { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }

/* ----- Выделение нескольких сообщений ----- */
.select-bar {
  display: flex; align-items: center; gap: 4px; padding: 6px 12px; background: var(--glass); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); z-index: 3; animation: fade-in .15s;
}
.select-count { flex: 1; font-weight: 600; padding-left: 4px; }
.select-bar .btn { padding: 8px 12px; }
.select-bar .btn .ico { width: 20px; height: 20px; }
.selecting .msg-row { cursor: pointer; padding-left: 34px; position: relative; }
.selecting .msg-row::before {
  content: ""; position: absolute; left: 4px; bottom: 6px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--muted); background: var(--surface); transition: .12s;
}
.selecting .msg-row.selected::before {
  border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center/14px no-repeat;
}
.selecting .msg-row.selected .msg { filter: brightness(1.12); }
.selecting .msg-actions { display: none; }

/* ----- Отложенные сообщения ----- */
.scheduled-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--glass); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); cursor: pointer; color: var(--accent-text); font-weight: 500; font-size: 14px; z-index: 2;
}
.scheduled-bar .ico { width: 19px; height: 19px; }
.schedule-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.schedule-quick button {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 12px; text-align: left; font-weight: 500;
  display: flex; flex-direction: column; gap: 2px; transition: background .12s;
}
.schedule-quick button:hover { background: var(--accent-soft); }
.schedule-quick small { color: var(--muted); font-weight: 400; }
.scheduled-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.scheduled-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.scheduled-list .when { font-size: 13px; color: var(--accent-text); font-weight: 600; }
.scheduled-list .what { flex: 1; min-width: 0; }
.scheduled-list .what div:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----- Кнопка «вниз» со счётчиком новых сообщений ----- */
.to-bottom { overflow: visible; }
.new-below {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center; padding: 0 6px;
}
.history-loader { align-self: center; color: var(--muted); font-size: 13px; padding: 8px; display: flex; gap: 8px; align-items: center; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Перетаскиваемая граница панели чатов ----- */
.resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; }
.resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.resizer:hover::after, body.resizing .resizer::after { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
@media (max-width: 760px) { .resizer { display: none; } }

/* ----- Черновик в списке чатов ----- */
.chat-item .draft { color: var(--danger); font-weight: 500; }

/* ----- Медиа в профиле ----- */
.media-section { border-top: 1px solid var(--border); padding-top: 6px; }
.media-tabs { display: flex; gap: 2px; }
.media-tabs button {
  flex: 1; border: 0; background: none; padding: 10px 4px 12px; color: var(--muted); font-weight: 600; font-size: 14px; position: relative;
  border-radius: 10px 10px 0 0;
}
.media-tabs button:hover { background: var(--surface-2); }
.media-tabs button.active { color: var(--accent-text); }
.media-tabs button.active::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.media-body { min-height: 120px; padding-top: 10px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid .cell { aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); position: relative; }
.media-grid img, .media-grid video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid .cell .ico { position: absolute; inset: 0; margin: auto; width: 32px; height: 32px; color: #fff; filter: drop-shadow(0 1px 3px #000); }
.media-list { display: flex; flex-direction: column; gap: 4px; }
.media-list .item { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; cursor: pointer; text-decoration: none; color: inherit; }
.media-list .item:hover { background: var(--surface-2); }
.media-list .item .sub { color: var(--muted); font-size: 13px; }
.media-list .item .main { flex: 1; min-width: 0; }
.media-list .item .main > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.media-list .file-icon { width: 42px; height: 42px; }
.media-list a.url { color: var(--accent-text); overflow-wrap: anywhere; }
.media-empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* ----- Участники: роли и ссылка-приглашение ----- */
.info-member .tag.admin { color: var(--success); }
.invite-box {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); margin: 4px 0;
}
.invite-box .ico { color: var(--accent-text); }
.invite-box .link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* =====================================================================
   Версия 4: удобства
   ===================================================================== */

/* ----- Плашка с кнопкой «Отменить» ----- */
.toast { display: flex; align-items: center; gap: 14px; }
.toast-action { background: none; border: 0; color: var(--accent-text); font-weight: 700; padding: 2px 4px; text-transform: uppercase; font-size: 13px; letter-spacing: .3px; }
:root[data-theme="light"] .toast-action { color: color-mix(in srgb, var(--accent) 60%, #fff); }

/* ----- Предпросмотр перед отправкой ----- */
.send-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; }
.send-items.single { grid-template-columns: 1fr; }
.send-item { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; display: grid; place-items: center; }
.send-items.single .send-item { aspect-ratio: auto; max-height: 340px; }
.send-item img, .send-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.send-items.single .send-item img { object-fit: contain; max-height: 340px; }
.send-item .file-info { padding: 10px; text-align: center; font-size: 13px; display: flex; flex-direction: column; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.send-item .file-info .ico { width: 34px; height: 34px; color: var(--accent-text); }
.send-item .remove {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff;
  display: grid; place-items: center;
}
.send-item .remove .ico { width: 16px; height: 16px; }
.send-actions { display: flex; gap: 8px; justify-content: space-between; }
.send-actions .btn:last-child { flex: 1; }

/* ----- Альбом в сообщении ----- */
.album { display: grid; gap: 3px; border-radius: 14px; overflow: hidden; min-width: 240px; }
.album.n2 { grid-template-columns: 1fr 1fr; }
.album.n3 { grid-template-columns: 1fr 1fr; }
.album.n3 > :first-child { grid-column: span 2; }
.album.n4 { grid-template-columns: 1fr 1fr; }
.album.many { grid-template-columns: repeat(3, 1fr); }
.album img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.album.n3 > :first-child { aspect-ratio: 2 / 1; }

/* ----- Полноэкранный просмотр фото ----- */
.viewer { display: block; cursor: default; }
.viewer-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff; z-index: 2;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.viewer-top .icon-btn { color: #fff; }
.viewer-top .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.viewer-caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.viewer-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.viewer-stage img { max-width: 92vw; max-height: 86dvh; border-radius: 8px; transition: transform .12s; cursor: grab; user-select: none; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; z-index: 2;
  background: rgba(255, 255, 255, .12); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px);
}
.viewer-nav:hover { background: rgba(255, 255, 255, .25); }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }
.viewer-hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .5); font-size: 12.5px; }

/* ----- Панель форматирования ----- */
.fmt-bar { display: flex; gap: 2px; padding: 6px 8px 0; animation: fade-in .12s; }
.fmt-bar button {
  min-width: 34px; height: 30px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; font-size: 14px;
}
.fmt-bar button:hover { background: var(--accent-soft); color: var(--accent-text); }
.fmt-bar .ico { width: 17px; height: 17px; }
.fmt-bar code { font-size: 12px; }

/* ----- Цитата выделенного фрагмента ----- */
.quote.partial .quote-text { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; font-style: italic; }

/* ----- Подсветка кода ----- */
.code-block { margin: 4px 0; border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, .28); border-left: 3px solid var(--accent-text); white-space: normal; }
:root[data-theme="light"] .code-block { background: rgba(0, 0, 0, .05); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--accent-text); background: rgba(127, 127, 127, .1); }
.msg-row.out .code-head { color: inherit; }
.code-copy { background: none; border: 0; color: inherit; font-size: 12px; opacity: .8; padding: 0; }
.code-copy:hover { opacity: 1; text-decoration: underline; }
.code-block pre { margin: 0; border: 0; border-radius: 0; background: none; padding: 9px 12px; }
.tok-keyword { color: #c792ea; }
.tok-string { color: #c3e88d; }
.tok-number { color: #f78c6c; }
.tok-comment { color: #7f8b97; font-style: italic; }
.tok-func { color: #82aaff; }
:root[data-theme="light"] .tok-keyword { color: #8e24aa; }
:root[data-theme="light"] .tok-string { color: #2e7d32; }
:root[data-theme="light"] .tok-number { color: #d84315; }
:root[data-theme="light"] .tok-func { color: #1565c0; }
.msg-row.out .tok-keyword, .msg-row.out .tok-string, .msg-row.out .tok-number, .msg-row.out .tok-func { filter: brightness(1.35); }
:root[data-theme="light"] .msg-row.out .tok-keyword, :root[data-theme="light"] .msg-row.out .tok-string,
:root[data-theme="light"] .msg-row.out .tok-number, :root[data-theme="light"] .msg-row.out .tok-func { filter: none; }

/* ----- Голосовые: волна и скорость ----- */
.voice-wave { display: flex; align-items: center; gap: 2px; height: 26px; cursor: pointer; }
.voice-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: rgba(127, 127, 127, .45); transition: background .1s; }
.voice-wave i.played { background: var(--accent-text); }
.msg-row.out .voice-wave i { background: color-mix(in srgb, currentColor 35%, transparent); }
.msg-row.out .voice-wave i.played { background: currentColor; }
.voice-meta { display: flex; align-items: center; gap: 8px; }
.voice-speed {
  border: 0; border-radius: 8px; padding: 1px 6px; font-size: 11.5px; font-weight: 700; background: var(--accent-soft); color: var(--accent-text);
}
.msg-row.out .voice-speed { background: var(--out-chip); color: inherit; }

/* ----- Реакция из всех эмодзи ----- */
.ctx-reactions .more { font-size: 18px !important; color: var(--muted); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; padding: 2px; max-height: 260px; overflow-y: auto; }
.emoji-grid button { font-size: 22px; border: 0; background: none; border-radius: 8px; height: 36px; }
.emoji-grid button:hover { background: var(--surface-2); }

/* ----- Архив, папки, «непрочитано» вручную ----- */
.chat-item.archive-row .avatar { background: var(--surface-3) !important; color: var(--muted); }
.badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.folder-tab.add { color: var(--muted); padding: 11px 8px 12px; }
.folder-tab.add .ico { width: 18px; height: 18px; }
.archive-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: var(--muted); font-weight: 600; font-size: 14px; }
.archive-head .icon-btn { width: 34px; height: 34px; }

/* ----- Аккаунты, «не беспокоить» ----- */
.accounts-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.accounts-list .drawer-item .avatar { width: 28px; height: 28px; font-size: 12px; }
.accounts-list .drawer-item .sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.dnd-badge { color: var(--accent-text) !important; }

/* ----- История правок, горячие клавиши ----- */
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-list .when { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.history-list li.current { box-shadow: inset 0 0 0 2px var(--accent); }
.shortcuts { width: 100%; border-collapse: collapse; font-size: 14px; }
.shortcuts td { padding: 7px 4px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { white-space: nowrap; width: 45%; }
.shortcuts kbd { font-size: 12px; }

/* =====================================================================
   Версия 2.0: разделы — почта, задачи, бизнес, древо, админка
   ===================================================================== */

/* ----- Экран входа ----- */
.auth-tabs { margin: 4px 0 2px; }
.auth-hint { margin: 0 !important; font-size: 14px; min-height: 40px; }
.auth-card .field { text-align: left; }
.pass-wrap { position: relative; display: block; }
.pass-wrap input { padding-right: 46px; }
.pass-wrap .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; }
.auth-card .check { justify-content: flex-start; font-size: 14px; }

/* ----- Панель разделов ----- */
.rail {
  width: 76px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.rail-btn {
  position: relative; width: 64px; border: 0; background: none; color: var(--muted); border-radius: 16px; padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; transition: background .12s, color .12s;
}
.rail-btn .ico { width: 24px; height: 24px; }
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn.active { color: var(--accent-text); background: var(--accent-soft); }
.rail-badge {
  position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
}
.rail-spacer { flex: 1; }
.app.in-module .sidebar, .app.in-module .chat { display: none !important; }
.module-view { flex: 1; min-width: 0; display: flex; background: var(--surface); position: relative; }
.mod { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 900px) {
  .app { padding-left: 0; }
  .module-view { border-radius: 24px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
}

/* ----- Общие элементы разделов ----- */
.mod-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.mod-head h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.mod-head input[type=search] { width: 220px; border-radius: 20px; padding: 8px 14px; }
.mod-body { flex: 1; overflow: auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.mod-tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.mod-tabs::-webkit-scrollbar { display: none; }
.mod-tab {
  position: relative; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 12px 12px 13px; white-space: nowrap;
  border-radius: 10px 10px 0 0; display: flex; gap: 6px; align-items: center;
}
.mod-tab:hover { background: var(--surface-2); }
.mod-tab.active { color: var(--accent-text); }
.mod-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.count { background: var(--surface-3); color: var(--text); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 19px; min-width: 20px; text-align: center; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 8px 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 300px; border-radius: 20px; padding: 9px 14px; }
.toolbar select, .mod-head select { width: auto; }
select {
  background: var(--surface-2); color: var(--text); border: 1.5px solid transparent; border-radius: 12px; padding: 10px 12px; font: inherit; outline: none; width: 100%;
}
select:focus { border-color: var(--accent); }
.card { background: var(--surface-2); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
:root[data-theme="light"] .card { background: var(--surface-2); }
.card h3 { margin: 0; font-size: 16px; }
.form-card { max-width: 560px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.empty-state { color: var(--muted); text-align: center; padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state.big { margin: auto; max-width: 480px; }
.empty-state.big h2 { margin: 0; color: var(--text); }
.empty-icon { width: 76px; height: 76px; border-radius: 24px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.empty-icon .ico { width: 38px; height: 38px; }
.pill { display: inline-block; border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--surface-3); white-space: nowrap; }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); }
.pill-green { background: rgba(79, 206, 93, .16); color: #3fb950; }
.pill-red { background: rgba(255, 92, 92, .15); color: var(--danger); }
.pill-gray { color: var(--muted); }
.small-pill { font-size: 11px; padding: 0 7px; }
.big-code { font: 700 26px/1.2 "JetBrains Mono", Consolas, monospace; letter-spacing: 2px; background: var(--surface-2); border-radius: 14px; padding: 14px; text-align: center; user-select: all; }
.error.ok { color: var(--accent-text); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost.with-icon, .btn.danger.with-icon { justify-content: center; }

/* ----- Показатели ----- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.kpi { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: 18px; padding: 14px 16px; min-width: 0; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { background: var(--surface-3); }
.kpi-icon { width: 42px; height: 42px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex-shrink: 0; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin: 2px 0; white-space: nowrap; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.kpi-green .kpi-value { color: #3fb950; }
.kpi-red .kpi-value { color: var(--danger); }
.account-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.onboarding ol { margin: 0; padding-left: 20px; line-height: 1.8; }

/* ----- Таблицы ----- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 10px 12px; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.data-table td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--accent-soft); }
.data-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table tfoot td { font-weight: 700; background: var(--surface-2); }
.data-table .avatar.xs { width: 30px; height: 30px; font-size: 13px; }
.pos { color: #3fb950; }
.neg { color: var(--danger); }
.warn { color: #e0a030; }

/* ----- Формы ----- */
.ui-modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal.wide { max-width: 860px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full, .form-grid .check.full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-weight: 700; margin-top: 6px; }
.field .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 4px; }
.form-actions.wrap { flex-wrap: wrap; }
.ui-form { display: flex; flex-direction: column; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 18px; padding: 5px 12px 5px 6px; font-size: 13.5px; display: inline-flex;
  align-items: center; gap: 6px; font-weight: 500; min-height: 32px;
}
.chip .avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip:hover { background: var(--surface-3); }
.add-chip { padding: 5px 12px 5px 8px; color: var(--accent-text); }
.add-chip .ico { width: 16px; height: 16px; }
.label-chip { min-width: 44px; width: auto; height: 30px; padding: 0 10px; justify-content: center; color: #fff; font-size: 12px; border: 2px solid transparent; }
.label-chip.on { border-color: var(--text); color: #fff; }
.label-chip.green, .klabel.green, .board-dot.green { background: #3fb950; }
.label-chip.yellow, .klabel.yellow, .board-dot.yellow { background: #e3b341; }
.label-chip.orange, .klabel.orange, .board-dot.orange { background: #f08a3e; }
.label-chip.red, .klabel.red, .board-dot.red { background: #f85149; }
.label-chip.purple, .klabel.purple, .board-dot.purple { background: #a371f7; }
.label-chip.blue, .klabel.blue, .board-dot.blue { background: #3390ec; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); width: 26px; height: 26px; font-size: 11px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.small-icon { width: 28px; height: 28px; }
.small-icon .ico { width: 16px; height: 16px; }
.small-seg button { padding: 6px 12px; font-size: 13px; }

/* ----- Раздел с колонкой слева (задачи) ----- */
.mod-split { flex: 1; display: flex; min-height: 0; }
.mod-side { width: 250px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 12px 10px; padding-top: calc(12px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.mod-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-size: 18px; }
.side-title { color: var(--muted); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 14px 10px 6px; }
.side-item {
  border: 0; background: none; text-align: left; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; font-weight: 500; font-size: 14.5px; width: 100%;
}
.side-item .ico { width: 20px; height: 20px; color: var(--muted); }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent-text); }
.side-item.active .ico { color: var(--accent-text); }
.board-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.board-dot.big { width: 18px; height: 18px; border-radius: 6px; }

/* ----- Канбан ----- */
.kanban { flex: 1; display: flex; gap: 12px; padding: 16px; overflow-x: auto; align-items: flex-start; }
.kanban-col { width: 290px; flex-shrink: 0; background: var(--surface-2); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 100%; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.kcol-head .icon-btn { width: 30px; height: 30px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; overflow-y: auto; padding: 2px; }
.kcard {
  background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab; display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); transition: transform .1s, box-shadow .1s;
}
.kcard:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.kcard.dragging { opacity: .45; transform: rotate(2deg); }
.klabels { display: flex; flex-wrap: wrap; gap: 4px; }
.klabel { min-width: 32px; height: 8px; border-radius: 4px; font-size: 0; }
.klabel:not(:empty) { height: auto; font-size: 11px; color: #fff; padding: 1px 7px; font-weight: 600; }
.ktitle { font-weight: 500; font-size: 14.5px; overflow-wrap: anywhere; }
.kmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kbadge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); border-radius: 6px; padding: 1px 4px; }
.kbadge .ico { width: 14px; height: 14px; }
.kbadge.overdue { background: rgba(248, 81, 73, .18); color: #f85149; }
.kbadge.soon { background: rgba(227, 179, 65, .2); color: #d29922; }
.kbadge.done { background: rgba(63, 185, 80, .18); color: #3fb950; }
.kadd-btn { border: 0; background: none; color: var(--muted); text-align: left; padding: 8px; border-radius: 10px; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.kadd-btn:hover { background: var(--surface-3); color: var(--text); }
.kadd-btn .ico { width: 18px; height: 18px; }
.kadd-input { resize: none; }
.kanban-add { flex-shrink: 0; width: 220px; }
.card-modal { display: grid; grid-template-columns: 1fr 260px; gap: 18px; }
.card-main, .card-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-title-input { font-size: 18px; font-weight: 600; }
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: #3fb950; transition: width .2s; }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.check-item:hover { background: var(--surface-2); }
.check-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.check-item span { flex: 1; color: var(--text); font-size: 14.5px; }
.check-item span.done { text-decoration: line-through; color: var(--muted); }
.comments { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.comment { display: flex; gap: 10px; }
.comment-text { color: var(--text); font-size: 14.5px; white-space: pre-wrap; }
.comment-add { display: flex; gap: 8px; align-items: flex-end; }
.mine-list { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }
.mine-item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.mine-item:hover { background: var(--surface-3); }
.mod-main > .mod-head + .side-title { padding-left: 26px; }

/* ----- Семейное древо ----- */
.tree-select { width: auto; max-width: 260px; font-weight: 600; }
.tree-wrap { flex: 1; display: flex; min-height: 0; position: relative; }
.tree-canvas {
  flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 1px 1px, var(--surface-3) 1px, transparent 0) 0 0 / 22px 22px;
}
.tree-canvas.grabbing { cursor: grabbing; }
.tree-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-lines { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.tree-lines .child-line { fill: none; stroke: var(--muted); stroke-width: 1.6; opacity: .7; }
.tree-lines .spouse-line { fill: none; stroke: #e8578d; stroke-width: 2; stroke-dasharray: 5 4; }
.tcard {
  position: absolute; width: 176px; height: 76px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; transition: box-shadow .12s, border-color .12s;
}
.tcard:hover { border-color: var(--accent); }
.tcard.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm); }
.tcard.deceased { opacity: .8; }
.tcard.deceased .tcard-photo { filter: grayscale(.6); }
.tcard-photo {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: 19px; color: #fff;
  background: center / cover no-repeat, linear-gradient(160deg, #9aa4b2, #6b7280);
}
.tcard-photo.m { background-color: #3390ec; background-image: linear-gradient(160deg, #6fb1f5, #2f7fd6); }
.tcard-photo.f { background-image: linear-gradient(160deg, #f59ac0, #d6487f); }
.tcard-photo[style*="url"] { background-size: cover; }
.tcard-photo.small { width: 32px; height: 32px; font-size: 13px; }
.tcard-text { min-width: 0; flex: 1; position: relative; }
.tcard-label { font-size: 11px; color: var(--accent-text); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.tcard-name { font-weight: 600; font-size: 14px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tcard-years { font-size: 12.5px; color: var(--muted); }
.tcard-root { position: absolute; top: -4px; right: -2px; color: #e3b341; font-size: 13px; }
.tree-controls { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.tree-controls .icon-btn { background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.tree-details {
  width: 340px; flex-shrink: 0; border-left: 1px solid var(--border); padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--surface);
}
.tree-details h2 { margin: 4px 0 0; font-size: 19px; }
.tdetail-photo {
  flex-shrink: 0; align-self: flex-start;
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; font-weight: 700; color: #fff;
  background: center / cover no-repeat, linear-gradient(160deg, #9aa4b2, #6b7280);
}
.tdetail-photo.m { background-image: linear-gradient(160deg, #6fb1f5, #2f7fd6); }
.tdetail-photo.f { background-image: linear-gradient(160deg, #f59ac0, #d6487f); }
.tdetail-photo[style*="url"] { background-size: cover; }
.tdetail-bio { background: var(--surface-2); border-radius: 14px; padding: 12px; white-space: pre-wrap; font-size: 14.5px; }
.rel-group .label, .tree-details .label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.photo-pick { display: flex; align-items: center; gap: 12px; }
.share-row { display: flex; align-items: center; gap: 10px; }
.share-row select { width: auto; }

/* ----- Почта ----- */
.mail-layout { flex: 1; display: grid; grid-template-columns: minmax(170px, 220px) minmax(250px, 360px) minmax(0, 1fr); min-height: 0; }
@media (max-width: 1100px) and (min-width: 761px) { .mail-layout { grid-template-columns: 170px 260px minmax(0, 1fr); } .mail-from { flex-wrap: wrap; } }
.mail-folders { border-right: 1px solid var(--border); padding: 12px 10px; padding-top: calc(12px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.compose-btn { margin-bottom: 10px; }
.mail-account { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: flex-start; gap: 2px; word-break: break-all; }
.mail-list { border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.mail-list-head { display: flex; gap: 6px; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mail-list-head input { border-radius: 20px; padding: 8px 14px; }
.mail-item { padding: 10px 12px 10px 8px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 6px; position: relative; user-select: none; }
.mail-item:hover { background: var(--surface-2); }
.mail-item.active { background: var(--accent-soft); }
.mail-item.unread .mail-item-top b { font-weight: 800; }
.mail-item.unread { box-shadow: inset 3px 0 0 var(--accent); }
.mail-item-top { display: flex; gap: 8px; align-items: baseline; }
.mail-item-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.mail-subject { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item.unread .mail-subject { color: var(--text); }
/* непрочитанное письмо в списке — заметно: точка у даты, жирная тема, лёгкая подсветка строки */
.mail-item.unread .mail-subject { font-weight: 600; }
.mail-item.unread { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.mail-item.unread:hover { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.mail-item.unread.active { background: var(--accent-soft); }
.mail-item.unread.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.mail-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; align-self: center; margin-left: 2px; }
.mail-list > .btn { margin: 10px; }
.mail-reader { overflow-y: auto; min-width: 0; display: flex; flex-direction: column; }
.mail-message { display: flex; flex-direction: column; gap: 12px; padding: 14px 20px 30px; }
.mail-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; position: sticky; top: 0; background: var(--surface); padding: 6px 0; z-index: 1; }
.mail-actions .btn { padding: 8px 12px; }
.mail-back { display: none; }
.mail-title { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.mail-from { display: flex; gap: 10px; align-items: center; }
.mail-from .avatar { color: #fff; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 6px 10px; color: var(--text); text-decoration: none; font-size: 14px; max-width: 100%; }
.file-chip span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .ico { width: 18px; height: 18px; color: var(--accent-text); }
.mail-images-note { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; color: var(--muted); }
.mail-frame { width: 100%; min-height: 300px; border: 0; border-radius: 14px; background: #fff; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55; }
.mail-setup { margin: auto; max-width: 480px; width: 100%; padding: 30px 20px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; overflow-y: auto; }
.mail-setup .empty-icon { align-self: center; }
.mail-setup h2 { margin: 0; }
.mail-setup .field { text-align: left; }
.provider-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.provider-tile { border: 1.5px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 12px 6px; font-weight: 600; }
.provider-tile.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.mail-note { text-align: left; font-size: 13.5px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.mail-note a { color: var(--accent-text); }

/* ----- Бизнес: документ ----- */
.doc-form { display: flex; flex-direction: column; gap: 12px; }
.items-table td { padding: 6px 8px; }
.items-table input { padding: 8px 10px; }
.items-table td:nth-child(2) { min-width: 240px; }
.items-table td:nth-child(3), .items-table td:nth-child(5) { width: 110px; }
.doc-total { text-align: right; font-size: 17px; }
.field .inline select { flex: 1; }

/* ----- Плашка «Включить уведомления» ----- */
.push-banner {
  display: flex; align-items: center; gap: 10px; margin: 6px 10px 2px; padding: 10px 10px 10px 14px; border-radius: 16px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.push-banner > .ico { color: var(--accent-text); }
.push-text { flex: 1; min-width: 0; font-size: 14px; }
.push-banner .btn { padding: 8px 12px; }

/* ===================== Телефон ===================== */
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .rail {
    width: 100%; height: calc(62px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; gap: 0; padding: 4px 4px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); overflow-x: auto;
  }
  .rail-btn { width: auto; flex: 1 1 0; min-width: 0; padding: 6px 0 4px; border-radius: 12px; font-size: 10px; }
  .rail-btn .rail-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail-badge { right: 4px; }
  .rail-spacer { display: none; }
  .app.in-chat .rail { display: none; }
  .sidebar, .chat, .module-view { flex: 1; min-height: 0; }
  .fab { bottom: 18px; }
  .mod-head { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .mod-head h1 { font-size: 19px; }
  .mod-head input[type=search] { width: 100%; order: 10; }
  .mod-body { padding: 12px; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px; flex-direction: column; gap: 6px; }
  .kpi-value { font-size: 17px; }
  .kpi-icon { width: 34px; height: 34px; }
  .mod-split { flex-direction: column; }
  .mod-side { width: 100%; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 6px; }
  .mod-side .side-head, .mod-side .side-title, .mod-side > .btn { display: none; }
  .mod-side .side-item { width: auto; white-space: nowrap; background: var(--surface-2); flex-shrink: 0; }
  .kanban { scroll-snap-type: x mandatory; padding: 12px; }
  .kanban-col { width: 85vw; scroll-snap-align: center; }
  .card-modal { grid-template-columns: 1fr; }
  .tree-wrap { flex-direction: column; }
  .tree-canvas { min-height: 55vh; }
  .tree-details { width: 100%; border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
  .mail-layout { grid-template-columns: 1fr; }
  .mail-folders { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; gap: 6px; align-items: center; }
  .mail-folders .side-item { width: auto; white-space: nowrap; background: var(--surface-2); flex-shrink: 0; }
  .mail-folders .grow, .mail-account { display: none; }
  .compose-btn { margin: 0; flex-shrink: 0; }
  .mail-reader { display: none; }
  .mail-layout.reading .mail-folders, .mail-layout.reading .mail-list { display: none; }
  .mail-layout.reading .mail-reader { display: flex; }
  .mail-back { display: grid; }
  .provider-tiles { grid-template-columns: repeat(2, 1fr); }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 8px; }
  .push-banner .muted { display: none; }
}
@media (hover: none) {
  .rail-btn:hover { background: none; color: var(--muted); }
  .rail-btn.active:hover { color: var(--accent-text); background: var(--accent-soft); }
}

/* ---------- вход в почту через Яндекс ---------- */
.yandex-btn { background: #fc3f1d; color: #fff; width: 100%; justify-content: center; font-weight: 600; }
.yandex-btn:hover { background: #e5361a; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0 2px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.oauth-steps { margin: 0; padding-left: 20px; line-height: 1.6; }
.oauth-steps code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; word-break: break-all; }

/* ---------- настройки звуков ---------- */
.sounds-settings h3 { margin: 14px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sound-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.sound-label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.sound-picker { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sound-picker select { min-width: 170px; }
.sound-picker input[type=range] { width: 170px; accent-color: var(--accent); }
.sound-vol { width: 42px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.sound-custom { display: flex; flex-direction: column; gap: 4px; }
.sound-custom-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); }
.sound-custom-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) {
  .sound-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .sound-picker select { flex: 1; min-width: 0; }
  .sound-picker input[type=range] { flex: 1; width: auto; }
}

/* ---------- управление письмами: галочки, быстрые кнопки, фильтры ---------- */
.mail-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mail-check { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; cursor: pointer; border-radius: 8px; }
.mail-check:hover { background: var(--surface-2); }
.mail-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
/* галочка у письма видна при наведении, у выбранных и в режиме выбора */
@media (hover: hover) {
  .mail-item .mail-check { opacity: 0; transition: opacity .12s; }
  .mail-item:hover .mail-check, .mail-item.selected .mail-check, .mail-layout.selecting .mail-item .mail-check { opacity: 1; }
}
@media (hover: none) {
  .mail-item .mail-check { display: none; }
  .mail-layout.selecting .mail-item .mail-check { display: grid; }
}
.mail-item.selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.mail-attach-ico { color: var(--muted); display: inline-flex; }
.mail-attach-ico svg { width: 14px; height: 14px; }
.mail-date { flex-shrink: 0; }
.mail-flag { border: 0; background: none; padding: 4px; border-radius: 8px; color: var(--muted); opacity: 0; cursor: pointer; display: inline-flex; flex-shrink: 0; }
.mail-flag svg { width: 16px; height: 16px; }
.mail-item:hover .mail-flag { opacity: .7; }
.mail-flag:hover { background: var(--surface-2); opacity: 1 !important; }
.mail-flag.on { opacity: 1; color: #e5484d; }
.mail-flag.on svg { fill: currentColor; }
.flag-on { color: #e5484d; }
.flag-on svg { fill: currentColor; }
/* быстрые кнопки при наведении — поверх даты */
.mail-hover { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.mail-hover .icon-btn { width: 32px; height: 32px; }
.mail-hover .icon-btn svg { width: 17px; height: 17px; }
@media (hover: hover) { .mail-item:hover .mail-hover { display: flex; } }
.mail-layout.selecting .mail-item:hover .mail-hover { display: none; }
.mail-chips { display: flex; gap: 6px; padding: 0 10px 8px; overflow-x: auto; position: sticky; top: 56px; background: var(--surface); z-index: 1; }
.mail-chip { border: 1px solid var(--border); background: none; color: var(--text); border-radius: 16px; padding: 4px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.mail-chip:hover { background: var(--surface-2); }
.mail-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.mail-list-head { align-items: center; }
.mail-list-head input[type=search] { flex: 1; min-width: 0; }
.mail-bulk { background: var(--accent-soft); min-height: 56px; }
.mail-bulk-count { font-weight: 600; white-space: nowrap; }
.mail-bulk .icon-btn { flex-shrink: 0; }
.keys-table { border-collapse: collapse; width: 100%; }
.keys-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.keys-table td:first-child { white-space: nowrap; width: 1%; }
.mail-list > * { flex-shrink: 0; }
.mail-bulk { flex-wrap: wrap; row-gap: 2px; column-gap: 2px; }
.mail-bulk .icon-btn { width: 34px; height: 34px; }
.mail-bulk .icon-btn svg { width: 18px; height: 18px; }
.mail-bulk .grow { flex: 1 0 4px; }

/* ---------- раздел «Claude» ---------- */
.cl-center { display: grid; place-items: center; min-height: 100%; }
.cl-setup { max-width: 520px; width: 100%; text-align: left; }
.cl-setup .empty-icon { margin: 0 auto 6px; }
.cl-setup h2 { text-align: center; }
.cl-list { margin: 0; padding-left: 20px; line-height: 1.6; }
.cl-key { font-size: 15px; word-break: break-all; letter-spacing: 0; }
.cl-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cl-head { flex-wrap: wrap; gap: 8px; }
.cl-pill { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.cl-pill::before { content: "●"; margin-right: 5px; color: #e5484d; }
.cl-pill.on::before { color: #30a46c; }
.cl-banner { display: flex; gap: 8px; align-items: center; margin: 0 16px 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, #f5a524 16%, transparent); font-size: 13.5px; }
.cl-feed { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.cl-feed > * { flex-shrink: 0; }
.cl-user, .cl-assistant { display: flex; flex-direction: column; max-width: min(760px, 88%); }
.cl-user { align-self: flex-end; align-items: flex-end; }
.cl-assistant { align-self: flex-start; }
.cl-bubble { padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.cl-user .cl-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.cl-assistant .cl-bubble { background: var(--surface-2); border-bottom-left-radius: 5px; }
.cl-time { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
.cl-tool { font-size: 12.5px; color: var(--muted); padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-log { font: 12.5px/1.5 Consolas, "JetBrains Mono", monospace; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow-y: auto; }
.cl-error { color: #e5484d; background: color-mix(in srgb, #e5484d 10%, transparent); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; font-size: 13.5px; }
.cl-done { color: #30a46c; font-size: 13px; padding: 0 6px; }
.cl-system { text-align: center; color: var(--muted); font-size: 12.5px; }
.cl-hint { margin: auto; text-align: center; max-width: 460px; }
.cl-working { display: flex; align-items: center; gap: 8px; padding: 4px 18px; font-size: 13px; }
.cl-dots { display: inline-flex; gap: 3px; }
.cl-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: cl-blink 1.2s infinite; }
.cl-dots i:nth-child(2) { animation-delay: .2s; }
.cl-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes cl-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.cl-composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.cl-composer textarea { flex: 1; resize: none; max-height: 200px; border-radius: 16px; padding: 10px 14px; }
.cl-composer .icon-btn { margin-bottom: 4px; }
.cl-shots { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 16px 0; }
.cl-shot { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.cl-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cl-shot .icon-btn { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.cl-shot .icon-btn .ico { width: 13px; height: 13px; }
@media (max-width: 760px) { .cl-head .btn.ghost { display: none; } }
.cl-access { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.cl-access-row { padding: 8px 6px; border-radius: 10px; }
.cl-access-row:hover { background: var(--surface-2); }

/* ---------- плашка «Вышло обновление» ---------- */
.update-banner { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.25); font-weight: 500; max-width: calc(100vw - 32px); }
.update-banner .btn { padding: 7px 14px; }
@media (max-width: 760px) { .update-banner { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- безопасность и устройства ---------- */
.sec { gap: 12px; }
.sec-card { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.sec-card h3 { margin: 0; font-size: 15px; }
.sec-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sec-row input { flex: 1; min-width: 160px; }
.sec-note { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; }
.ok-text { color: #30a46c; }
.danger-text { color: #e5484d; }
.sec-devices { display: flex; flex-direction: column; gap: 4px; }
.sec-device { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--border); }
.sec-device:first-child { border-top: 0; }
.sec-device .pill { margin-left: 6px; }
.sec-dev-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.auth-2fa { display: flex; flex-direction: column; gap: 8px; }
.auth-2fa input { font-size: 22px; letter-spacing: 6px; text-align: center; }
#authForgot { align-self: center; }
.ticks.pending svg { opacity: .7; animation: pend-pulse 1.6s ease-in-out infinite; }
@keyframes pend-pulse { 50% { opacity: .3; } }

/* ---------- вкладки поиска ---------- */
.search-kinds { display: flex; gap: 6px; padding: 6px 10px 8px; overflow-x: auto; list-style: none; }
.search-kind { border: 1px solid var(--border); background: none; color: var(--text); border-radius: 16px; padding: 4px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.search-kind:hover { background: var(--surface-2); }
.search-kind.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.search-more { list-style: none; display: flex; justify-content: center; padding: 8px; }
.search-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.remind-open { display: flex; margin: 8px 0 2px; width: 100%; justify-content: center; }

/* ---------- импорт из Telegram ---------- */
.tg-chats { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.tg-chat { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.voice-text { font-size: 13.5px; line-height: 1.4; margin-top: 4px; max-width: 320px; white-space: pre-wrap; }
.voice-text:empty { display: none; }

/* ---------- новые фоны чата ---------- */
[data-wallpaper="forest"] {
  --chat-bg:
    radial-gradient(at 15% 20%, #1d3b2a 0, transparent 55%),
    radial-gradient(at 85% 15%, #2a3f1c 0, transparent 50%),
    radial-gradient(at 70% 90%, #12352f 0, transparent 55%),
    #0d1a14;
}
[data-wallpaper="lavender"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #3a2a5c 0, transparent 55%),
    radial-gradient(at 85% 25%, #4a2a4f 0, transparent 50%),
    radial-gradient(at 60% 90%, #2a2f5f 0, transparent 55%),
    #15121f;
}
[data-wallpaper="graphite"] { --chat-bg: linear-gradient(180deg, #1c1d21, #121316); --pattern-opacity: .03; }
[data-wallpaper="amoled"] { --chat-bg: #000; --pattern-opacity: 0; }
[data-wallpaper="custom"] { --chat-bg: var(--custom-bg); --pattern-opacity: 0; }
[data-theme="light"][data-wallpaper="forest"], [data-theme="light"] [data-wallpaper="forest"] {
  --chat-bg:
    radial-gradient(at 15% 20%, #cfe8c8 0, transparent 55%),
    radial-gradient(at 85% 15%, #e3eebd 0, transparent 50%),
    radial-gradient(at 70% 90%, #b9e0d3 0, transparent 55%),
    #d3e6c6;
  --chip-bg: rgba(30, 70, 40, .3);
}
[data-theme="light"][data-wallpaper="lavender"], [data-theme="light"] [data-wallpaper="lavender"] {
  --chat-bg:
    radial-gradient(at 15% 15%, #e3d7fb 0, transparent 55%),
    radial-gradient(at 85% 25%, #f6d9ee 0, transparent 50%),
    radial-gradient(at 60% 90%, #d4dcfb 0, transparent 55%),
    #e6defa;
  --chip-bg: rgba(70, 40, 110, .3);
}
[data-theme="light"][data-wallpaper="graphite"], [data-theme="light"] [data-wallpaper="graphite"] { --chat-bg: linear-gradient(180deg, #f4f5f7, #e9ebef); --chip-bg: rgba(0, 0, 0, .28); }
[data-theme="light"][data-wallpaper="amoled"], [data-theme="light"] [data-wallpaper="amoled"] { --chat-bg: #fff; --chip-bg: rgba(0, 0, 0, .28); }
/* «Тёмная ночь»: чистый чёрный и для панелей — экономит заряд на телефонах с OLED-экраном */
html.amoled { --app-bg: #000; --surface: #000; --surface-2: #121212; --border: #1f1f1f; }
.wp-tile[data-wallpaper="custom"] { background: var(--custom-bg); display: grid; place-items: center; color: var(--muted); }
/* готовые темы */
.preset-picker { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; }
.preset { flex-shrink: 0; width: 84px; border: 2px solid transparent; border-radius: 14px; padding: 0; background: var(--chat-bg); cursor: pointer; display: flex; flex-direction: column; align-items: stretch; overflow: hidden; }
.preset.selected { border-color: var(--accent); }
.preset-bubble { height: 46px; position: relative; }
.preset-bubble::after { content: ""; position: absolute; right: 10px; bottom: 9px; width: 34px; height: 14px; border-radius: 8px; background: var(--accent); }
.preset-bubble::before { content: ""; position: absolute; left: 10px; top: 9px; width: 30px; height: 12px; border-radius: 8px; background: rgba(255,255,255,.85); }
.preset[data-theme="dark"] .preset-bubble::before { background: rgba(40,42,48,.95); }
.preset-name { font-size: 12px; padding: 4px 0 5px; background: var(--surface); color: var(--text); }
/* анимация переключения папки свайпом */
.chat-list.swipe-left { animation: swipe-in-left .22s ease-out; }
.chat-list.swipe-right { animation: swipe-in-right .22s ease-out; }
@keyframes swipe-in-left { from { transform: translateX(24px); opacity: .4; } }
@keyframes swipe-in-right { from { transform: translateX(-24px); opacity: .4; } }

/* ---------- компактное меню и окно «Настройки» ---------- */
.drawer-sep { height: 1px; background: var(--border); margin: 6px 14px; }
.settings-modal { max-width: 440px; }
.settings-group { display: flex; flex-direction: column; padding: 4px 0; }
.settings-group + .settings-group { border-top: 1px solid var(--border); }
.settings-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 14px 4px; }
.settings-modal .drawer-item { border-radius: 10px; }

/* ---------- программа 2dodo для Windows: своя шапка окна вместо белой рамки ---------- */
.desktop-titlebar { display: none; }
html.desktop-app .desktop-titlebar { display: flex !important; }
html.desktop-app .desktop-titlebar {
  display: flex; align-items: center; gap: 8px; position: fixed; inset: 0 0 auto 0; height: 34px; z-index: 2000;
  padding-left: 12px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600;
  -webkit-app-region: drag; user-select: none;
}
html.desktop-app .desktop-titlebar img { width: 16px; height: 16px; border-radius: 4px; }
html.desktop-app body { padding-top: 34px; box-sizing: border-box; }
html.desktop-app .app { height: calc(100dvh - 34px); }
html.desktop-app .auth { min-height: calc(100dvh - 34px); }

/* ===== Почта: удобнее читать и отвечать ===== */
.mail-pick { position: relative; width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; }
.mail-ava { width: 36px; height: 36px; font-size: 15px; color: #fff; }
.mail-pick .mail-check { position: absolute; inset: 0; width: auto; height: auto; }
@media (hover: hover) {
  .mail-item:hover .mail-ava, .mail-item.selected .mail-ava, .mail-layout.selecting .mail-ava { visibility: hidden; }
}
.mail-layout.selecting .mail-ava { visibility: hidden; }
.mail-item { padding: 10px 12px; gap: 10px; align-items: flex-start; }
.mail-item .mail-pick { margin-top: 2px; }
.mail-snippet { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.mail-day { padding: 12px 14px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mail-more { padding: 14px; text-align: center; }
.mail-message { max-width: 980px; }
.mail-frame { min-height: 120px; display: block; }
.mail-loading { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 14px; background: var(--surface-2); }
.mail-loading div { height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--text) 10%, transparent); animation: pulse 1.2s ease-in-out infinite alternate; }
.mail-loading .short { width: 55%; }
@keyframes pulse { from { opacity: .5; } to { opacity: 1; } }
.mail-more-btn { align-self: flex-start; margin: 8px 0; padding: 0 8px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-weight: 700; letter-spacing: 1px; cursor: pointer; }
.mail-more-btn:hover { color: var(--text); }
.mail-quote { margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--muted); }
/* быстрый ответ под письмом */
.mail-quick { display: flex; gap: 10px; align-items: flex-start; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); transition: box-shadow .15s, border-color .15s; }
.mail-quick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mail-quick .avatar { width: 32px; height: 32px; font-size: 14px; color: #fff; flex-shrink: 0; }
.mail-quick textarea { width: 100%; border: 0; background: none; resize: none; padding: 6px 2px; font: inherit; font-size: 15px; color: var(--text); outline: none; box-shadow: none; min-height: 32px; }
.mail-quick-actions { display: none; align-items: center; gap: 8px; padding-top: 6px; }
.mail-quick.open .mail-quick-actions { display: flex; }
.mail-compose-tools { display: flex; flex-direction: column; gap: 8px; }
.mail-compose-tools .row { display: flex; align-items: center; gap: 8px; }
form.ui-form.drop { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 12px; }
@media (max-width: 760px) {
  .mail-hint { display: none; }
  .mail-message { padding: 10px 12px 24px; }
  .mail-title { font-size: 19px; }
  .mail-actions .btn { padding: 7px 10px; }
  .mail-actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 6px 12px; }
  .mail-actions::-webkit-scrollbar { display: none; }
  .mail-actions > * { flex-shrink: 0; }
  .mail-from .muted:not(.small) { display: none; }
  .mail-quick { position: sticky; bottom: 0; }
}
/* переключатель ящиков вверху списка папок */
.mail-acc { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 12px; background: none; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.mail-acc:hover { background: var(--surface-2); }
.mail-acc-ava { width: 26px; height: 26px; font-size: 12px; color: #fff; flex-shrink: 0; }
.mail-acc-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.mail-acc svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.mail-setup-back { align-self: flex-start; }
.mail-account { gap: 4px; }
@media (max-width: 760px) {
  .mail-acc { width: auto; max-width: 60vw; margin: 0; flex-shrink: 0; }
}
/* «Важное» со всех ящиков */
.mail-imp .ico, .mail-imp svg { color: #f5b301; }
.mail-side-title { padding: 12px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mail-side-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-tags { display: flex; gap: 6px; margin-top: 3px; min-width: 0; overflow: hidden; }
.mail-tag:first-child { flex-shrink: 0; }
.mail-tag { font-size: 11.5px; padding: 1px 7px; border-radius: 8px; background: var(--surface-2); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-tag.why { background: color-mix(in srgb, #f5b301 18%, transparent); color: color-mix(in srgb, #f5b301 75%, var(--text)); }
.mail-imp-title { font-size: 15px; }
@media (max-width: 760px) {
  .mail-side-title { display: none; }
  .mail-folders .mail-imp .muted { display: none; }
}

.mail-rule { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.mail-rule .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- окно «Настройки почты»: слева разделы, справа настройки ----- */
.mail-set { display: flex; gap: 16px; align-items: flex-start; }
.mail-set-nav { flex: 0 0 196px; display: flex; flex-direction: column; gap: 2px; padding-right: 12px; border-right: 1px solid var(--border); }
.mail-set-body { flex: 1; min-width: 0; max-height: min(62vh, 560px); overflow-y: auto; padding-right: 4px; }
.mail-set-body .form-section:first-child { margin-top: 0; }
.mail-set-acc { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.mail-set-acc-top { display: flex; align-items: center; gap: 10px; }
.mail-set-acc-top .grow { min-width: 0; overflow: hidden; }
.mail-set-acc-top b { overflow-wrap: anywhere; }
.mail-set-check { align-items: flex-start; }
.mail-rule-on { flex-shrink: 0; }
.mail-rule-edit { border: 1px solid var(--accent); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.mail-rule-edit .row { gap: 8px; }
.mail-set-check .hint { display: block; }
.mail-set-btn { align-self: stretch; justify-content: center; }
@media (max-width: 760px) {
  .mail-set { flex-direction: column; }
  .mail-set-nav { flex: none; width: 100%; flex-direction: row; overflow-x: auto; padding: 0 0 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .mail-set-nav .side-item { white-space: nowrap; width: auto; flex: 0 0 auto; }
  .mail-set-body { max-height: none; width: 100%; }
}
/* компактный вид списка писем */
.mail-layout.compact .mail-item { padding: 6px 12px; }
.mail-layout.compact .mail-snippet { display: none; }
.mail-layout.compact .mail-day { padding: 8px 14px 2px; }
.mail-layout.compact .mail-ava { width: 28px; height: 28px; font-size: 12px; }
/* письмо со скрытыми картинками */
.mail-images-bar { display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }

/* ----- фото и файлы в процессе отправки: круг с процентом, «отменить», ошибка с «Отправить ещё раз» ----- */
.msg.uploading { position: relative; }
.msg-row:has(.msg.uploading) .msg-actions { display: none; }
.upload-ov { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(0, 0, 0, .28); border-radius: inherit; color: #fff; z-index: 2; }
.upload-ov.file { position: static; flex-direction: row; justify-content: flex-start; background: none; color: inherit; padding: 6px 2px 0; }
.upload-ring { width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .45); cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.upload-ov.file .upload-ring { width: 40px; height: 40px; background: var(--accent); }
.upload-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.upload-ring circle { fill: none; stroke-width: 3; }
.upload-ring .bg { stroke: rgba(255, 255, 255, .25); }
.upload-ring .fg { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .25s ease; }
.upload-ring path { stroke: #fff; stroke-width: 2.6; stroke-linecap: round; transform: rotate(90deg); transform-origin: 24px 24px; }
.upload-ring.spin svg { animation: upload-spin 1s linear infinite; }
@keyframes upload-spin { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
.upload-pct { font-size: 12.5px; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.upload-ov.file .upload-pct { text-shadow: none; color: var(--meta-out); }
.upload-ov.failed { background: rgba(0, 0, 0, .5); padding: 8px; text-align: center; }
.upload-ov.file.failed { background: none; flex-wrap: wrap; }
.upload-bang { width: 40px; height: 40px; border-radius: 50%; background: #e5484d; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; flex-shrink: 0; }
.upload-err { font-size: 12.5px; max-width: 220px; }
.upload-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.upload-actions .btn { padding: 6px 12px; font-size: 13px; }
.upload-ov:not(.file) .upload-actions .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }

/* ----- мини-чат задачи ----- */
.tchat { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); overflow: hidden; min-height: 260px; }
.tchat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tchat-head svg { width: 18px; height: 18px; color: var(--accent-text); }
.tchat-head .count:empty { display: none; }
.tchat-list { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; max-height: 340px; min-height: 160px; overflow-y: auto; }
.tchat-empty { margin: auto; text-align: center; font-size: 13.5px; max-width: 300px; }
.tchat-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.tchat-row.cont { margin-top: 2px; }
.tchat-row.out { justify-content: flex-end; }
.tchat-row .avatar, .tchat-ava-space { width: 28px; height: 28px; flex-shrink: 0; font-size: 12px; }
.tchat-bubble { max-width: 78%; padding: 6px 10px 6px 11px; border-radius: 14px; background: var(--bubble-in); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.4; }
.tchat-row.out .tchat-bubble { background: var(--bubble-out); color: var(--text-out); }
.tchat-author { font-size: 12.5px; font-weight: 600; color: var(--accent-text); margin-bottom: 1px; }
.tchat-time { float: right; font-size: 11px; margin: 6px -2px -3px 10px; color: var(--meta-in); }
.tchat-row.out .tchat-time { color: var(--meta-out); }
.tchat-del { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 8px; cursor: pointer; opacity: 0; display: inline-flex; align-self: center; }
.tchat-del svg { width: 15px; height: 15px; }
.tchat-row:hover .tchat-del { opacity: .7; }
.tchat-del:hover { opacity: 1 !important; background: var(--surface); }
.tchat-typing { min-height: 18px; padding: 0 14px; }
.tchat-input { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.tchat-input textarea { flex: 1; resize: none; border: 0; background: none; padding: 7px 2px; font: inherit; font-size: 14.5px; color: var(--text); outline: none; box-shadow: none; min-height: 34px; max-height: 140px; }
.tchat-send { color: var(--accent-text); }
.kbadge.unread { background: var(--accent); color: #fff; }
@media (hover: none) { .tchat-del { opacity: .6; } }
.tchat-list > :first-child { margin-top: auto; }

/* ----- приглашения в задачи ----- */
.invite-card { margin: 4px 6px 8px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; line-height: 1.4; }
.invite-actions { display: flex; gap: 6px; }
.invite-actions .btn { padding: 6px 12px; font-size: 13px; }
.chip.pending { opacity: .75; border-style: dashed; }
.chip-note { font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.chip.add-chip { border-style: dashed; color: var(--accent-text); }
.assign-pick { margin-top: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.assign-pick input { width: 100%; }
.assign-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.assign-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.assign-row:hover { background: var(--surface); }
.assign-row .avatar { width: 28px; height: 28px; font-size: 12px; }

/* логотип 2dodo — перо павлина: белый круг с картинкой */
.logo { background: #fff !important; overflow: hidden; box-shadow: 0 12px 30px rgba(0, 0, 0, .35) !important; }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ----- предпросмотр ссылки в сообщении (как в Telegram) ----- */
.link-preview { display: block; margin: 6px 0 2px; padding: 6px 10px 8px; border-left: 3px solid var(--accent); border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 9%, transparent); color: inherit; text-decoration: none; max-width: 420px; overflow: hidden; }
.link-preview:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.lp-site { font-size: 13px; font-weight: 600; color: var(--accent-text); }
.lp-title { font-weight: 600; font-size: 14px; margin-top: 1px; overflow-wrap: anywhere; }
.lp-desc { font-size: 13.5px; opacity: .85; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lp-img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 6px; margin-top: 6px; }
.msg-row.out .link-preview, .msg.out .link-preview { border-left-color: currentColor; background: rgba(255, 255, 255, .14); }
.msg-row.out .lp-site { color: inherit; }

/* ----- вложения в задаче ----- */
.task-files { display: flex; flex-direction: column; gap: 6px; }
.task-file { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.task-file.loading { opacity: .6; }
.task-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: inherit; }
.task-file-ico { width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.task-thumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.task-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.task-files .row { gap: 10px; align-items: center; flex-wrap: wrap; }
.card-modal.drop { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 12px; }

/* ----- раздел «Контакты» (контрагенты) ----- */
.ct-chips { padding: 0 20px 4px; }
.ct-list { flex: 1; overflow-y: auto; padding: 8px 20px 40px; display: flex; flex-direction: column; gap: 8px; }
.ct-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; }
.ct-card:hover { background: var(--surface-2); }
.ct-ava { width: 42px; height: 42px; font-size: 16px; flex-shrink: 0; }
.ct-ava.big { width: 56px; height: 56px; font-size: 21px; }
.ct-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ct-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ct-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ct-person { display: flex; align-items: center; gap: 5px; }
.ct-person .ico { width: 14px; height: 14px; }
.ct-contacts { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; max-width: 40%; }
.ct-link { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); text-decoration: none; max-width: 100%; }
.ct-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-link:hover { color: var(--accent-text); }
.ct-link .ico { width: 15px; height: 15px; flex-shrink: 0; }
.ct-view-top { align-items: center; gap: 14px; }
.ct-view-top h3 { margin: 0 0 4px; }
.ct-actions { gap: 8px; flex-wrap: wrap; }
.ct-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.ct-row .grow { overflow-wrap: anywhere; }
.ct-label { flex: 0 0 150px; }
.ct-comment { white-space: pre-wrap; margin: 0; }
.ct-people { gap: 8px; }
.ct-person-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.2fr auto; gap: 6px; align-items: center; }
.ct-foot { padding-top: 10px; }
.ct-chips { align-items: center; flex-wrap: wrap; }
.ct-gtag { cursor: pointer; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); }
.ct-gtag:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.ct-groups { flex-wrap: wrap; margin: 4px 0 6px; }
.ct-group-add { gap: 8px; align-items: center; }
.ct-group-add input { flex: 1; min-width: 0; }
.ct-sort-box { display: flex; align-items: center; gap: 6px; }
.ct-sort { width: auto; padding: 5px 8px; border-radius: 10px; font-size: 13.5px; }
.ct-group { padding: 14px 4px 2px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ct-group .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.ct-peer .ct-ava { width: 42px; height: 42px; }
.ct-peer-actions { gap: 6px; flex-shrink: 0; }
@media (max-width: 760px) { .ct-peer-actions .btn span { display: none; } }
@media (max-width: 760px) {
  .ct-contacts { display: none; }
  .ct-person-row { grid-template-columns: 1fr 1fr; }
  .ct-label { flex-basis: 110px; }
  .ct-list, .ct-chips { padding-left: 12px; padding-right: 12px; }
}

/* кнопка «Сфотографировать» — только на телефонах и планшетах (там, где есть камера и сенсорный экран) */
.camera-btn { display: none; }
@media (hover: none) and (pointer: coarse) { .camera-btn { display: grid; } }

/* переводчик раскладки в «Бизнесе»: результат — как текст, его можно выделить и скопировать */
.translator-out { min-height: 80px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; user-select: text; }

/* свои папки в списке чатов: строка с «+ / −»; открытая папка вместе со своими чатами обведена рамкой цвета папки */
.folder-toggle { font-size: 20px; line-height: 1; font-weight: 600; color: var(--muted); width: 22px; text-align: center; flex-shrink: 0; }
.chat-item.fgroup { --fc: var(--accent); border: 2.5px solid color-mix(in srgb, var(--fc) 80%, transparent); border-top-width: 0; border-bottom-width: 0; border-radius: 0; }
.chat-item.fgroup.first { border-top-width: 2.5px; border-radius: 14px 14px 0 0; margin-top: 4px; }
.chat-item.fgroup.last { border-bottom-width: 2.5px; border-radius: 0 0 14px 14px; margin-bottom: 4px; }
.chat-item.fgroup.first.last { border-radius: 14px; }
.chat-item.fgroup.in-folder { padding-left: 22px; }

/* значок папки в окне папки: картинка с устройства, фото из чатов, цвет */
.folder-look { display: flex; align-items: center; gap: 16px; }
.folder-look-btns { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.folder-look-btns label.link-btn { cursor: pointer; }
.folder-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; }
.folder-photo { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--surface-2) center / cover no-repeat; cursor: pointer; }
.folder-photo:hover { outline: 2px solid var(--accent); }
.folder-palette { gap: 8px; }
.folder-palette button { width: 30px; height: 30px; }
.folder-own-color { display: inline-block; margin-top: 8px; cursor: pointer; }

/* архив-папка: в кружке «Арх.» — помельче, чтобы влезло */
.chat-item.folder-row .avatar.arch, .avatar.arch { font-size: 15px; letter-spacing: -.3px; }
.avatar.xl.arch { font-size: 26px; }

/* «Производительность сервера» в «Бизнесе» — как «Быстродействие» в диспетчере задач Windows */
.perf { display: flex; flex-direction: column; gap: 10px; }
.perf-row { display: flex; gap: 10px; }
.perf-row.perf-tables { flex-wrap: wrap; }
.perf-box { border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.perf-box.grow { flex: 1; }
.perf-title { font-size: 12.5px; color: var(--muted); }
.perf-gauge { width: 84px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.perf-gauge-bar { width: 100%; height: 120px; background: #000; border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden;
  background-image: repeating-linear-gradient(0deg, #0a3d1c 0 2px, transparent 2px 4px); }
.perf-gauge-fill { width: 100%; background: repeating-linear-gradient(0deg, #3cff6e 0 2px, #000 2px 4px); transition: height .4s; }
.perf-gauge-label { font-size: 12px; color: #3cff6e; font-weight: 600; }
.perf-cores { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.perf-chart { width: 100%; height: 120px; display: block; border-radius: 4px; }
.perf-cores .perf-chart { height: 120px; }
.perf-kv { border-collapse: collapse; font-size: 13px; }
.perf-kv td { padding: 2px 10px 2px 0; }
.perf-kv td:last-child { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .perf-row { flex-wrap: wrap; } .perf-gauge { width: 64px; } }

/* Настройки почты → «Очистка папок» */
.mail-clean-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border, rgba(127,127,127,.2)); }
.mail-clean-row .row { display: flex; align-items: center; gap: 8px; }
.mail-clean-ctl select { width: auto; padding: 6px 10px; }

/* панель папок почты узкая — подписи не наезжают: название сокращается с «…», а пояснение «все ящики» прячется */
.side-item > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item > .muted, .side-item > .count { flex-shrink: 0; }
.mail-folders { container-type: inline-size; }
@container (max-width: 240px) { .mail-imp .muted { display: none; } }

/* дерево почты слева: группы-хосты («Наш хост», «Beget»…), в них «Все папки» и ящики с папками */
.mail-node .mail-chevron { width: 12px; flex-shrink: 0; color: var(--muted); font-size: 11px; }
.side-item.mail-host { font-weight: 700; text-transform: uppercase; letter-spacing: .4px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.side-item.mail-host .ico { width: 17px; height: 17px; }
.mail-tree-sub { padding-left: 14px; display: flex; flex-direction: column; gap: 2px; }
.mail-tree-note { padding: 0 10px 4px 32px; }
/* на телефоне панель папок — строка с прокруткой: дерево разворачиваем в одну ленту */
@media (max-width: 760px) {
  .mail-tree-sub { display: contents; }
  .mail-tree-note { display: none; }
  .side-item.mail-host { margin-top: 0; }
}
/* «Почта» → выбор контакта, к которому присоединить ящик */
.mail-pick { max-height: 50vh; overflow-y: auto; gap: 4px; }
.mail-pick-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 10px; background: none; border: 1px solid var(--border, rgba(127,127,127,.25)); color: inherit; cursor: pointer; }
.mail-pick-row:hover { background: rgba(127,127,127,.12); }
/* «Почта» → «Добавить в контакты?»: кнопки одна под другой во всю ширину */
.mail-choice { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.mail-choice .btn { width: 100%; justify-content: center; }
.mail-choice .link-btn { align-self: center; padding: 6px 12px; }
/* сворачиваемый раздел формы: заголовок-кнопка «▸ Реквизиты» */
.form-fold { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-align: left; padding: 4px 0; cursor: pointer; }
.form-fold:hover { color: var(--accent, inherit); }
.form-grid > [hidden] { display: none !important; }
.ct-fold-body[hidden] { display: none !important; }
/* «Контакты» → папки, как у чатов: строка папки с «+ / −», раскрытая — в рамке цвета папки вместе с контактами */
.ct-fgroup { --fc: var(--accent); display: flex; flex-direction: column; gap: 6px; }
.ct-fgroup.open { border: 2.5px solid color-mix(in srgb, var(--fc) 80%, transparent); border-radius: 16px; padding: 6px; }
.ct-fgroup.open > .ct-card:not(.ct-folder) { margin-left: 14px; }
.ct-folder .folder-toggle { margin-left: auto; }
.ct-fcolors { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-fcolor { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.ct-fcolor.on { border-color: var(--text, #fff); box-shadow: 0 0 0 2px var(--surface, #000) inset; }
.ct-fpicks { max-height: 40vh; overflow-y: auto; gap: 4px; }

/* ----- письмо в почтовом чате: компактная карточка, по нажатию — целиком ----- */
.mail-card { margin: 2px 0 4px; padding: 8px 10px 6px; border-left: 3px solid var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--accent) 9%, transparent); cursor: pointer; max-width: 460px; }
.mail-card:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.mail-card-head { display: flex; align-items: center; gap: 6px; font-size: 14.5px; }
.mail-card-head .ico { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent-text); }
.mail-card-head b { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mail-card-snip { margin-top: 3px; font-size: 13.5px; opacity: .8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mail-card-full { display: none; margin-top: 6px; overflow-wrap: anywhere; cursor: text; }
.mail-card-full .text { white-space: pre-wrap; }
.mail-card.open .mail-card-snip { display: none; }
/* превью письма в свёрнутой карточке: уменьшенная копия (как в «Почте», только мельче), нажатия проходят на карточку */
.mail-card-thumb { display: none; position: relative; height: 130px; margin-top: 6px; overflow: hidden; border-radius: 6px; background: var(--surface); pointer-events: none; }
.mail-card.has-thumb:not(.open) .mail-card-thumb { display: block; }
/* с превью: тема, одна строка начала письма (как в списке «Почты») и под ними кусочек самого письма */
.mail-card.has-thumb .mail-card-snip { -webkit-line-clamp: 1; }
.mail-card-thumb .mail-from, .mail-card-thumb .mail-attachments { display: none; } /* в превью — только само письмо, без шапки */
.mail-card-scale { width: 250%; transform: scale(.4); transform-origin: 0 0; }
.mail-card-thumb::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(transparent, color-mix(in srgb, var(--surface) 85%, transparent)); }
.mail-card.open .mail-card-full { display: block; }
/* развёрнутое письмо — шире и на светлом фоне, как в «Почте» */
.mail-card.open { max-width: none; width: min(680px, 72vw); cursor: default; }
.mail-card.open .mail-card-head, .mail-card.open .mail-card-foot { cursor: pointer; }
.mail-inline { padding: 0; gap: 8px; }
.mail-inline .mail-frame { width: 100%; border-radius: 8px; background: #fff; }
@media (max-width: 760px) { .mail-card.open { width: 100%; } }
.mail-card-foot { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 12.5px; }
.mail-card-toggle { color: var(--accent-text); font-weight: 600; }
.mail-card-foot .link-btn { font-size: 12.5px; padding: 0; }

/* «Новое сообщение…»: список людей с поиском */
.people-pick { display: flex; flex-direction: column; gap: 2px; max-height: 55vh; overflow-y: auto; }
.people-row { display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; background: none; border-radius: 12px; text-align: left; color: inherit; cursor: pointer; width: 100%; }
.people-row:hover { background: var(--surface-2); }
.people-row .avatar { width: 42px; height: 42px; flex-shrink: 0; }
.people-row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
