/* Панель ботов.
   Светлая тема: белые панели на мягком сером фоне. Тёмная: спокойный графит.
   Цвет только там, где он что-то значит: бот (точка, аватар, подпись), теги,
   непрочитанные и ответы оператора. Тему выбирают внизу слева: светлая / тёмная / авто. */

/* ---------- светлая тема ---------- */
:root {
  --bg: #f4f6f8;            /* фон переписки */
  --side: #fafbfc;          /* левая колонка */
  --pane: #ffffff;          /* панели */
  --raised: #ffffff;        /* всплывающее, выбранный пункт переключателя */
  --soft: #eff2f5;          /* мягкие заливки: поиск, поле ответа, карточка анкеты */
  --bubble-in: #ffffff;     /* сообщение человека */
  --bubble-bot: #ebeef2;    /* сообщение бота */
  --input: #ffffff;
  --ink: #1f2630;
  --ink-2: #434d59;
  --muted: #636d79;
  --faint: #a7afb8;
  --placeholder: #8b949f;
  --line: #e4e8ec;
  --line-2: #eef0f3;
  --line-strong: #d3d9df;
  --accent: #2f7f85;        /* кнопки, непрочитанные, выбранное */
  --accent-hover: #29727a;
  --accent-text: #2a7178;   /* ссылки и подписи цветом */
  --accent-soft: #e4f0f0;   /* ответы оператора, выбранный бот */
  --accent-faint: #f0f6f6;  /* открытая переписка в списке */
  --on-accent: #ffffff;
  --focus: #2f7f85;
  --danger: #b4463a;
  --danger-solid: #b4463a;
  --warn-ink: #7d5210;
  --warn-soft: #fbf1dc;
  --ring: rgba(47, 127, 133, .22);
  --scroll: #d5dae0;
  --scrim: rgba(24, 32, 42, .3);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .07);
  --shadow-pop: 0 1px 3px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .12);
  --tint-chip: 12%;         /* насколько заметен цвет тега или бота в заливке */
  --tint-chip-on: 24%;
  --tint-avatar: 16%;
  --hover: color-mix(in srgb, var(--ink) 5%, transparent);
  --muted-strong: color-mix(in srgb, var(--muted) 70%, var(--ink));  /* мелкий серый текст на цветных заливках */
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  color-scheme: light;
}

/* ---------- тёмная тема: по системе (если не выбрана светлая) и по кнопке ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --side: #181b20;
    --pane: #1c2026;
    --raised: #2d333b;
    --soft: #252a31;
    --bubble-in: #232830;
    --bubble-bot: #1f2329;
    --input: #16191e;
    --ink: #e3e7ec;
    --ink-2: #c3c9d1;
    --muted: #9aa3ae;
    --faint: #5f6873;
    --placeholder: #6f7884;
    --line: #2b3038;
    --line-2: #242930;
    --line-strong: #3a414b;
    --accent: #2f7f85;
    --accent-hover: #37909a;
    --accent-text: #7fc4c7;
    --accent-soft: #1f3a3d;
    --accent-faint: #1c2b2e;
    --on-accent: #ffffff;
    --focus: #7fc4c7;
    --danger: #e58276;
    --danger-solid: #b4463a;
    --warn-ink: #e6c27a;
    --warn-soft: #3a301a;
    --ring: rgba(127, 196, 199, .28);
    --scroll: #363c45;
    --scrim: rgba(0, 0, 0, .55);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-pop: 0 1px 3px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .5);
    --tint-chip: 20%;
    --tint-chip-on: 34%;
    --tint-avatar: 26%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181c;
  --side: #181b20;
  --pane: #1c2026;
  --raised: #2d333b;
  --soft: #252a31;
  --bubble-in: #232830;
  --bubble-bot: #1f2329;
  --input: #16191e;
  --ink: #e3e7ec;
  --ink-2: #c3c9d1;
  --muted: #9aa3ae;
  --faint: #5f6873;
  --placeholder: #6f7884;
  --line: #2b3038;
  --line-2: #242930;
  --line-strong: #3a414b;
  --accent: #2f7f85;
  --accent-hover: #37909a;
  --accent-text: #7fc4c7;
  --accent-soft: #1f3a3d;
  --accent-faint: #1c2b2e;
  --on-accent: #ffffff;
  --focus: #7fc4c7;
  --danger: #e58276;
  --danger-solid: #b4463a;
  --warn-ink: #e6c27a;
  --warn-soft: #3a301a;
  --ring: rgba(127, 196, 199, .28);
  --scroll: #363c45;
  --scrim: rgba(0, 0, 0, .55);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-pop: 0 1px 3px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .5);
  --tint-chip: 20%;
  --tint-chip-on: 34%;
  --tint-avatar: 26%;
  color-scheme: dark;
}

/* ---------- основа ---------- */
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
::placeholder { color: var(--placeholder); opacity: 1; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent-text); text-underline-offset: 2px; text-decoration-thickness: 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- кнопки и поля ---------- */
.btn {
  border: 1px solid var(--line); background: var(--pane); color: var(--ink-2);
  border-radius: var(--radius-s); padding: 7px 12px; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 8px; }
.btn-quiet:hover { color: var(--ink); background: var(--hover); border-color: transparent; }
.btn-danger, .btn-danger:hover { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: var(--input); color: var(--ink);
  border-radius: var(--radius-s); padding: 8px 10px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.textarea { resize: vertical; min-height: 64px; }
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
label.field > span { color: var(--muted); }

/* ---------- вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card {
  width: min(380px, 100%); background: var(--pane); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 28px 26px 24px; box-shadow: var(--shadow-pop); display: grid; gap: 14px;
}
.login-card .brand-mark { width: 36px; height: 36px; border-radius: 10px; margin-bottom: 2px; }
.login-card h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.login-card p { margin: -8px 0 4px; color: var(--muted); }
.login-error { color: var(--danger); min-height: 20px; font-size: 13px; }

/* ---------- каркас ---------- */
.shell {
  height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: 256px minmax(300px, 360px) minmax(0, 1fr);
}
.side {
  background: var(--side); color: var(--ink-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { padding: 16px 16px 8px; display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 600; font-size: 15px; color: var(--ink); letter-spacing: -.01em; flex: 1; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark i {
  display: block; width: 14px; height: 12px;
  background:
    linear-gradient(var(--on-accent), var(--on-accent)) 0 0 / 14px 2px no-repeat,
    linear-gradient(var(--on-accent), var(--on-accent)) 0 5px / 10px 2px no-repeat,
    linear-gradient(var(--on-accent), var(--on-accent)) 0 10px / 6px 2px no-repeat;
}
.side-scroll { overflow: auto; flex: 1; padding: 2px 10px 12px; }
.side h2 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 8px 6px; }
.bot-item {
  width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 10px; border: 0; background: transparent; color: var(--ink-2); border-radius: var(--radius-s);
  text-align: left; transition: background-color .15s;
}
.bot-item:hover { background: var(--hover); }
.bot-item[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.bot-item[aria-pressed="true"] .bot-name { font-weight: 600; }
.bot-item[aria-pressed="true"] .bot-sub { color: var(--accent-text); }
.bot-dot { width: 9px; height: 9px; border-radius: 50%; justify-self: center; }
.bot-dot.off { opacity: .35; }
.bot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; line-height: 19px; text-align: center; }
.count.lamp { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.side .switch { display: flex; align-items: center; gap: 9px; padding: 6px 8px; cursor: pointer; color: var(--ink-2); }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 6px; }
.tag-filter .chip { cursor: pointer; transition: background-color .15s, border-color .15s; }
.tag-filter .chip:hover { border-color: color-mix(in srgb, var(--tag, #8a94a0) 45%, transparent); }
.tag-filter .chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tag, #8a94a0) var(--tint-chip-on), transparent);
  border-color: color-mix(in srgb, var(--tag, #8a94a0) 65%, transparent);
  color: var(--ink); font-weight: 500;
}
.tag-filter .chip .num { color: var(--muted-strong); margin-left: 2px; }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 10px; }
.side-foot .who { font-size: 13px; font-weight: 500; color: var(--ink); }
.side-foot .who small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.side-foot .row { display: flex; gap: 6px; flex-wrap: wrap; }
.side .link-btn { background: none; border: 0; color: var(--accent-text); padding: 6px 8px 2px; font-size: 13px; }
.side .link-btn:hover { text-decoration: underline; }
.side-head .link-btn { color: var(--muted); font-size: 16px; padding: 2px 6px; }

/* переключатель темы */
.seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 3px;
  background: var(--soft); border-radius: 10px;
}
.seg-btn {
  border: 0; background: transparent; color: var(--muted); padding: 5px 4px; border-radius: 7px;
  font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color .15s, color .15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--raised); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-1); }

/* ---------- список переписок ---------- */
.list { background: var(--pane); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.list-head .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.list-head h1 { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head .input { background: var(--soft); border-color: transparent; }
.list-head .input:focus { background: var(--input); border-color: var(--accent); }
.list-scroll { overflow: auto; flex: 1; }
.conv {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 3px 12px;
  width: 100%; padding: 11px 14px; border: 0; background: transparent; color: var(--ink); text-align: left;
  transition: background-color .15s;
}
.conv::after { content: ""; position: absolute; left: 66px; right: 0; bottom: 0; height: 1px; background: var(--line-2); }
.conv:hover { background: var(--hover); }
.conv[aria-current="true"] { background: var(--accent-faint); box-shadow: inset 3px 0 0 var(--accent); }
.avatar {
  grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 600; font-size: 14px;
  color: color-mix(in srgb, var(--bot-color, #8a94a0) 62%, var(--ink));
  background: color-mix(in srgb, var(--bot-color, #8a94a0) var(--tint-avatar), var(--pane));
}
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--muted); }
.conv-last { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conv-meta { display: flex; gap: 4px; flex-wrap: wrap; grid-column: 2 / 4; margin-top: 3px; }
.conv-meta:empty { display: none; }
.conv .count.lamp { align-self: center; justify-self: end; }
.bot-pill {
  font-size: 11.5px; line-height: 17px; padding: 1px 8px; border-radius: 9px; white-space: nowrap; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
  color: color-mix(in srgb, var(--bot-color, #8a94a0) 62%, var(--ink));
  background: color-mix(in srgb, var(--bot-color, #8a94a0) var(--tint-chip), transparent);
}
/* человек заполняет анкету: пометка в списке и шапке, предупреждение над полем ответа */
.form-pill {
  font-size: 11.5px; line-height: 17px; padding: 1px 8px; border-radius: 9px; white-space: nowrap;
  color: var(--warn-ink); background: var(--warn-soft);
}
.form-note { font-size: 13px; color: var(--warn-ink); background: var(--warn-soft); border-radius: var(--radius-s); padding: 7px 10px; }
.empty { padding: 40px 24px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.more { width: 100%; border: 0; background: none; padding: 12px; color: var(--accent-text); }
.more:hover { background: var(--hover); }

/* ---------- теги ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 17px; max-width: 100%; color: var(--ink-2);
  background: color-mix(in srgb, var(--tag, #8a94a0) var(--tint-chip), transparent);
  border: 1px solid transparent;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--tag, #8a94a0); flex: none; }
.chip .x { border: 0; background: none; padding: 0 0 0 2px; color: var(--muted-strong); line-height: 1; font-size: 14px; }
.chip .x:hover { color: var(--danger); }

/* ---------- чат ---------- */
.chat { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; background: var(--bg); }
.chat.is-empty { grid-template-rows: 1fr; }
.chat-empty { display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.chat-empty strong { display: block; color: var(--ink); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.chat-head { background: var(--pane); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.chat-head .who { min-width: 0; flex: 1; }
.chat-head .name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.chat-head .meta a { text-decoration: none; }
.chat-head .meta a:hover { text-decoration: underline; }
.chat-head .btn[aria-pressed="true"] { background: var(--soft); border-color: var(--line); color: var(--ink); }
.chat-tags {
  background: var(--pane); border-bottom: 1px solid var(--line); padding: 8px 16px;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; position: relative;
}
.add-tag {
  border: 1px dashed var(--line-strong); background: none; border-radius: 10px; padding: 0 9px;
  font-size: 12px; line-height: 19px; color: var(--muted);
}
.add-tag:hover { border-color: var(--accent); color: var(--accent-text); }
.chat-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.chat-body.no-card { grid-template-columns: minmax(0, 1fr); }
.msgs { overflow: auto; padding: 18px 20px 10px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.day {
  align-self: center; font-size: 12px; color: var(--muted); background: var(--pane); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 1px 10px; margin: 10px 0 4px;
}
.msg { max-width: min(560px, 82%); padding: 8px 12px 6px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .t { display: block; text-align: right; font-size: 11px; line-height: 1.2; color: var(--muted); margin-top: 2px; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.op { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 6px; }
.msg.out { align-self: flex-end; background: var(--bubble-bot); border-bottom-right-radius: 6px; color: var(--ink-2); font-size: 13px; }
.msg .by { display: block; font-size: 12px; font-weight: 600; color: var(--accent-text); margin-bottom: 2px; }
.msg.out .by { color: var(--muted); font-weight: 500; }
.msg .err { display: block; color: var(--danger); font-size: 12px; margin-top: 3px; }
.msg.button { font-size: 13px; }
.msg.button::before { content: "Нажал кнопку: "; color: var(--muted); }
.msg img.media { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin: 2px 0 4px; cursor: zoom-in; background: var(--soft); }
.msg video.media { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin: 2px 0 4px; background: #000; }
.msg audio { display: block; max-width: 100%; }
.sys {
  align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--ink-2);
  background: var(--pane); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px 12px; margin: 2px 0;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.sys .t { color: var(--muted); font-size: 11px; margin-left: 6px; }
.card { border-left: 1px solid var(--line); background: var(--pane); overflow: auto; padding: 16px; display: grid; gap: 18px; align-content: start; }
.card h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.card dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.app-row { background: var(--soft); border-radius: var(--radius-s); padding: 9px 11px; font-size: 13px; display: grid; gap: 2px; }
.app-row b { font-weight: 600; }
.note-saved { font-size: 12px; color: var(--muted); }
.composer { background: var(--pane); border-top: 1px solid var(--line); padding: 10px 16px 12px; display: grid; gap: 6px; }
.composer .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.composer .textarea { min-height: 42px; max-height: 200px; border-radius: var(--radius-m); background: var(--soft); border-color: transparent; }
.composer .textarea:focus { background: var(--input); border-color: var(--accent); }
.composer .btn-primary { padding: 10px 16px; border-radius: var(--radius-m); }
.composer .hint { font-size: 12px; color: var(--muted); }
.readonly { padding: 12px 16px; background: var(--pane); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------- всплывающие окна ---------- */
.pop {
  position: absolute; z-index: 20; top: calc(100% - 2px); left: 16px; width: 280px; background: var(--raised);
  border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow-pop); padding: 8px; display: grid; gap: 6px;
}
.pop-list { max-height: 220px; overflow: auto; display: grid; gap: 2px; }
.pop-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px;
  border: 0; background: none; border-radius: var(--radius-s); text-align: left; color: var(--ink-2);
}
.pop-item:hover { background: var(--hover); }
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--pane);
  border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-pop);
}
.modal-head {
  position: sticky; top: 0; z-index: 1; background: var(--pane); display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 16px 18px 20px; display: grid; gap: 20px; }
.modal-body h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.modal-body section + section { margin-top: 22px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table .select, .table .input { padding: 5px 8px; }
.table .select { min-width: 136px; }
.bot-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.bot-checks label { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tag-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.tag-row input[type="color"], .grid-form input[type="color"] {
  width: 34px; height: 30px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2px;
  background: var(--input); cursor: pointer;
}
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; }
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--pane);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; }
#toast.bad { background: var(--danger-solid); color: #fff; }

/* ---------- добавки ---------- */
.lang-wrap { padding: 4px 8px; }
.side-note { padding: 4px 8px; }
.apps { display: grid; gap: 6px; }
.note-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.field-hint { font-size: 12px; }

/* ---------- узкие экраны ---------- */
.only-narrow { display: none; }
@media (max-width: 1180px) {
  .chat-body { grid-template-columns: minmax(0, 1fr); position: relative; }
  .chat-body .card { position: absolute; right: 0; top: 0; bottom: 0; width: min(320px, 90%); box-shadow: var(--shadow-pop); z-index: 15; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86%); z-index: 40;
    transform: translateX(-102%); transition: transform .2s;
  }
  .shell.side-open .side { transform: none; box-shadow: var(--shadow-pop); }
  /* затемнение под меню: нажатие мимо меню закрывает его */
  .shell.side-open::before { content: ""; position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
  .shell[data-view="chat"] .list { display: none; }
  .shell[data-view="list"] .chat { display: none; }
  .list { border-right: 0; }
  .only-narrow { display: inline-flex; }
  /* телефон: колонка не шире экрана, шапка чата компактнее */
  .chat-head { gap: 8px; padding: 8px 10px; }
  .chat-head .avatar { display: none; }
  .chat-head .meta { gap: 6px; font-size: 12px; }
  .chat-tags { padding: 6px 10px; }
  .msgs { padding: 12px 10px 8px; }
  .msg { max-width: 88%; }
  .composer { padding: 8px 10px 10px; }
  .composer .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

