/* Панель чат-агента. Спокойный светлый интерфейс: белые карточки на сером фоне,
   один тёмный акцент, никаких теней и рамок ради рамок. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f5f8; --card: #fff; --line: #e8eaf0; --line-soft: #f1f2f6;
  --text: #101828; --muted: #667085; --faint: #98a2b3;
  --dark: #131c2e; --blue: #2b6ef6; --blue-soft: #eef4ff;
  --green: #067647; --green-soft: #ecfdf3; --amber: #b54708; --amber-soft: #fffaeb;
  --red: #d92d20; --red-soft: #fef3f2;
  --r: 12px; --r-lg: 16px;
}
html, body { height: 100%; }
body { font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--blue); text-decoration: none; }
svg { flex: none; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dcdfe6; border-radius: 6px; border: 3px solid transparent;
  background-clip: content-box; }

/* ---------- вход ---------- */
#splash { min-height: 100vh; display: grid; place-items: center; color: var(--faint); }
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 28px; }
.login-card h1 { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- каркас ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
aside { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px 12px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 16px; font-weight: 600; }
.brand .mark { width: 28px; height: 28px; border-radius: 9px; background: var(--dark); color: #fff;
  display: grid; place-items: center; }

/* переключатель агента */
.agent-box { position: relative; margin-bottom: 14px; }
.agent-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card); text-align: left; }
.agent-btn:hover { background: var(--line-soft); }
.agent-btn .nm { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; }
.agent-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.agent-btn .dot.off { background: var(--faint); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: 5px; z-index: 30;
  box-shadow: 0 12px 32px rgba(16,24,40,.12); }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.menu button:hover { background: var(--line-soft); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu .muted { color: var(--muted); }

.nav { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); font-size: 14.5px; width: 100%; text-align: left; }
.nav:hover { background: var(--line-soft); color: var(--text); }
.nav.on { background: var(--dark); color: #fff; }
.nav.on svg { opacity: 1; }
.nav svg { opacity: .75; }
.nav .n { margin-left: auto; background: var(--blue); border-radius: 50%; width: 8px; height: 8px; }
.nav.on .n { background: rgba(255,255,255,.22); }

aside .foot { margin-top: auto; }
.spend { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; }
.spend .v { font-size: 15px; font-weight: 600; }
.spend .l { font-size: 11.5px; color: var(--faint); }
.who { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 12.5px;
  color: var(--muted); }
.who .ava { width: 24px; height: 24px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.who a { margin-left: auto; color: var(--faint); }

/* ---------- страница ---------- */
main { min-width: 0; display: flex; flex-direction: column; }
.page-head { position: sticky; top: 0; z-index: 20; background: rgba(244,245,248,.92);
  backdrop-filter: blur(6px); padding: 22px 30px 0; }
.page-head .line { display: flex; align-items: flex-start; gap: 16px; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-head .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 2px; margin-top: 16px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 9px 14px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); font-weight: 500; border-bottom-color: var(--dark); }
.body-wrap { padding: 22px 30px 48px; min-width: 0; }
.narrow { max-width: 760px; }

/* ---------- элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.card + .card { margin-top: 14px; }
.card > h3 { font-size: 15px; font-weight: 600; }
.card > h3 + .hint { margin-top: 3px; }
.hint { color: var(--muted); font-size: 13px; }
.card > .hint { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); outline: none; font-size: 14px; transition: border-color .15s; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); }
.field input[type=color] { padding: 3px; height: 38px; width: 84px; }
.field textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
.field .tip { font-size: 12px; color: var(--faint); margin-top: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.btn { background: var(--dark); color: #fff; padding: 9px 15px; border-radius: 10px; font-size: 14px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 7px; transition: opacity .15s; }
.btn:hover { opacity: .9; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--line-soft); opacity: 1; }
.btn.danger { background: var(--card); color: var(--red); border: 1px solid var(--line); }
.btn.danger:hover { background: var(--red-soft); opacity: 1; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bar .sp { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px; min-width: 0; }
.search input { border: none; outline: none; padding: 9px 0; background: none; width: 100%; font-size: 14px; }
.search svg { color: var(--faint); }

.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 7px; background: var(--line-soft);
  color: var(--muted); white-space: nowrap; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted);
  cursor: pointer; }
.toggle input { width: 36px; height: 21px; appearance: none; background: #d5d9e2; border-radius: 12px;
  position: relative; transition: background .18s; cursor: pointer; flex: none; }
.toggle input:checked { background: var(--green); }
.toggle input::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: left .18s; }
.toggle input:checked::after { left: 17px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }
.ok { color: var(--green); font-size: 13px; margin-top: 10px; }
.empty { color: var(--faint); font-size: 14px; padding: 40px 20px; text-align: center; }
.empty b { display: block; color: var(--muted); font-weight: 500; margin-bottom: 4px; }

/* ---------- списки ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft);
  cursor: pointer; min-width: 0; }
.item:first-child { border-top: none; }
.item:hover { background: #fafbfd; }
.item.on { background: var(--blue-soft); }
.item .txt { min-width: 0; flex: 1; }
.item .t { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; flex: none; }
.ava { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); color: var(--blue);
  display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.ava.gray { background: var(--line-soft); color: var(--muted); }

/* ---------- чаты ---------- */
.chats { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.chats .list { height: calc(100vh - 190px); overflow-y: auto; }
.chat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  display: flex; flex-direction: column; height: calc(100vh - 190px); min-width: 0;
  position: relative; }
#chat-jump { box-shadow: 0 6px 18px rgba(17,24,39,.18); }
.chat .top { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 12px; min-width: 0; }
.chat .top .who-t { min-width: 0; }
.chat .top b { font-size: 14.5px; }
.chat .top .s { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  background: #fbfcfd; }
.msg { max-width: 74%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.msg .who { display: block; font-size: 11px; margin-bottom: 3px; color: var(--faint); }
.msg.bot .who, .msg.operator .who { color: rgba(255,255,255,.8); }
.msg.user { align-self: flex-start; background: #fff; border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.operator { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 5px; }
.msg.fn { align-self: center; max-width: 88%; background: var(--green-soft); color: var(--green);
  border-radius: 10px; font-size: 12.5px; font-family: ui-monospace, Menlo, monospace;
  display: flex; align-items: center; gap: 7px; padding: 7px 12px; }
.dots { align-self: flex-end; background: var(--blue); border-radius: 14px;
  border-bottom-right-radius: 5px; padding: 13px 15px; display: flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.85);
  animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }
.drawer .top .st { color: var(--muted); font-size: 12.5px; }

.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 10px;
  align-items: flex-end; }
.composer textarea { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  resize: none; outline: none; max-height: 130px; font-size: 14px; }
.composer textarea:focus { border-color: var(--blue); }

/* ---------- разбор диалога ---------- */
.review { align-self: flex-end; width: 76%; margin: -4px 0 6px; }
.review textarea { width: 100%; border: 1px dashed var(--line); border-radius: 10px; padding: 7px 10px;
  font-size: 13px; resize: vertical; min-height: 34px; background: #fffdf5; outline: none;
  color: var(--text); }
.review textarea:focus { border-color: var(--amber); background: #fff; }
.review textarea.filled { border-style: solid; border-color: var(--amber); background: #fffaeb; }
.review-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-top: 1px solid var(--line); background: var(--amber-soft); font-size: 13.5px;
  color: var(--amber); }
.diff { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.diff b { font-size: 13.5px; }
.diff .was { color: var(--muted); font-size: 13px; text-decoration: line-through;
  margin: 6px 0; display: block; }
.diff .now { font-size: 13.5px; }
.dl { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--line); margin-top: 10px; max-height: 340px;
  overflow-y: auto; }
.dl div { padding: 2px 10px; white-space: pre-wrap; word-break: break-word; }
.dl .add { background: #ecfdf3; color: #067647; }
.dl .del { background: #fef3f2; color: #b42318; text-decoration: line-through; }
.dl .same { color: var(--faint); }
.dl .skip { background: var(--line-soft); color: var(--faint); text-align: center; font-size: 11px; }

/* ---------- код установки ---------- */
code.snippet { display: block; background: #0f1420; color: #e6e9ef; padding: 14px 16px; border-radius: 12px;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre; }

/* ---------- таблицы ---------- */
table.stat { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stat th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.stat td { padding: 10px; border-bottom: 1px solid var(--line-soft); }
table.stat tr:last-child td { border-bottom: none; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px;
  margin-bottom: 14px; }
.kpi .card { padding: 16px 18px; }
.kpi .card + .card { margin-top: 0; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- заглушки на время загрузки ---------- */
.sk { background: linear-gradient(90deg, #eceef2 25%, #f4f5f8 37%, #eceef2 63%);
  background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-top: 1px solid var(--line-soft); }
.sk-row:first-child { border-top: none; }
.sk-ava { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.sk-line { height: 11px; }

/* ---------- интервью мастера ---------- */
.wizard { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 70; display: grid;
  place-items: center; padding: 20px; animation: appear-soft .15s ease both; }
.wizard .box { background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 720px;
  height: min(88vh, 760px); display: flex; flex-direction: column; overflow: hidden;
  animation: pop-in .2s cubic-bezier(.2,.8,.3,1) both; }
.wizard .top { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 12px; }
.wizard .top b { font-size: 16px; }
.wizard .top .x { margin-left: auto; color: var(--faint); }
.wizard .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft); }
.wizard .meta input { width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; font-size: 13.5px; }
.wizard .talk { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column;
  gap: 10px; background: #fbfcfd; }
.wizard .bot, .wizard .me { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: 14.5px;
  white-space: pre-wrap; animation: appear .2s ease both; }
.wizard .bot { align-self: flex-start; background: #fff; border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.wizard .me { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 5px; }
.wizard .foot { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 8px;
  align-items: flex-end; }
.wizard .foot textarea { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  resize: none; max-height: 140px; outline: none; font-size: 14px; }
.wizard .actions { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex;
  gap: 10px; align-items: center; background: var(--card); }
.mic.on { background: var(--red-soft); color: var(--red); }

/* ---------- микроанимации ----------
   Короткие, 150-220 мс: интерфейс должен казаться живым, а не медленным. */
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }
@keyframes appear-soft { from { opacity: 0; } }
@keyframes gone {
  to { opacity: 0; transform: translateX(-8px); max-height: 0; padding-top: 0; padding-bottom: 0;
       margin-bottom: 0; border-width: 0; }
}
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }

.body-wrap > * { animation: appear-soft .18s ease both; }
.kpi .card, .list .item.fresh, #learn-list .card { animation: appear .2s ease both; }
.msgs > *:last-child { animation: appear .2s ease both; }
.gone { animation: gone .22s ease forwards; overflow: hidden; pointer-events: none; }
.modal { animation: appear-soft .15s ease both; }
.modal .box { animation: pop-in .2s cubic-bezier(.2, .8, .3, 1) both; }
.drawer { animation: slide-in .22s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.toast { animation: pop-in .2s ease both; }
.nav, .item, .btn, .tabs button { transition: background .15s ease, color .15s ease,
  opacity .15s ease, transform .12s ease; }
.btn:active { transform: scale(.97); }
.item:active { transform: scale(.995); }

/* ---------- модалка и ящик ---------- */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.42); display: grid; place-items: center;
  padding: 20px; z-index: 60; }
.modal .box { background: var(--card); border-radius: var(--r-lg); padding: 22px; width: 100%;
  max-width: 720px; max-height: 88vh; overflow-y: auto; overflow-x: hidden; }
.modal .box > * { min-width: 0; }
.change { display: block; background: var(--blue-soft); color: var(--blue); border-radius: 9px;
  padding: 8px 11px; margin: 8px 0; font-size: 13.5px; line-height: 1.45; white-space: normal;
  overflow-wrap: anywhere; }
.modal h3 { font-size: 16.5px; font-weight: 600; margin-bottom: 16px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; background: var(--card);
  border-left: 1px solid var(--line); z-index: 55; display: flex; flex-direction: column;
  box-shadow: -16px 0 40px rgba(16,24,40,.10); }
.drawer .top { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 10px; }
.drawer .top b { font-size: 15px; }
.drawer .top .x { margin-left: auto; color: var(--faint); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--dark);
  color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; }

/* ---------- студия виджета ---------- */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 16px; align-items: start; }
.stage { position: sticky; top: 92px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; }
.stage .head { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.stage .head .hint { font-size: 12px; }
.stage .head .sp { flex: 1; }
.stage iframe { width: 100%; height: 560px; border: none; display: block; background: #fff; }
@media (max-width: 1200px) { .studio { grid-template-columns: 1fr; } .stage { position: static; } }

/* ---------- предпросмотр виджета ---------- */

@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto;
    gap: 6px; padding: 10px; }
  aside .brand, aside .foot { display: none; }
  .agent-box { margin: 0; flex: 0 0 auto; }
  .agent-btn { padding: 7px 10px; }
  .agent-btn .nm { max-width: 110px; }
  .nav { width: auto; white-space: nowrap; }
  .chats { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .page-head, .body-wrap { padding-left: 16px; padding-right: 16px; }
}

/* ---------- телефон ----------
   Главная беда была в чатах: список и переписка стояли друг под другом, и до
   переписки надо было пролистать весь список. Теперь это два экрана с возвратом. */
.only-mob { display: none; }

@media (max-width: 820px) {
  body { -webkit-text-size-adjust: 100%; }
  .only-mob { display: inline-flex; }
  .page-head { padding-top: 14px; padding-bottom: 10px; }
  .page-head .line { flex-direction: column; gap: 8px; }
  .page-head .acts { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .page-head p { display: none; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .body-wrap { padding: 14px 12px 40px; }
  .card { padding: 14px; }

  /* чаты: сначала список, после нажатия сама переписка */
  .chats { gap: 0; }
  .chats .list { height: auto; max-height: none; overflow: visible; }
  .chats.show-chat > div:first-child { display: none; }
  .chats:not(.show-chat) > #chat-box { display: none; }
  .chat { height: calc(100dvh - 150px); min-height: 380px; }
  body.chat-open .page-head { display: none; }
  body.chat-open .body-wrap { padding-top: 8px; }
  body.chat-open .chat { height: calc(100dvh - 90px); }
  .chat .top { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .chat .top .bar { width: 100%; margin-left: 0 !important; }
  .composer { padding: 10px; }
  .composer textarea { font-size: 16px; }   /* меньше 16 и телефон приближает экран */

  /* таблицы аналитики шире экрана: пусть листаются вбок сами */
  table.stat { display: block; overflow-x: auto; white-space: nowrap; }

  /* окна правок не должны вылезать за экран */
  .modal { padding: 10px; align-items: flex-start; }
  .modal .box { width: 100%; max-height: 88dvh; overflow-y: auto; padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  textarea.mono { min-height: 240px !important; font-size: 13px; }
}

/* Прошлая переписка того же человека: видно, но не спорит с текущей */
.sep { text-align: center; font-size: 12px; color: var(--muted, #8b98a5); margin: 16px 0 8px;
  position: relative; }
.sep::before, .sep::after { content: ""; position: absolute; top: 50%; width: 26%; height: 1px;
  background: var(--line, #e5e9f0); }
.sep::before { left: 2%; }
.sep::after { right: 2%; }
.sep.now { color: var(--brand, #2f7de1); font-weight: 600; }
.msg.old { opacity: .6; }

/* Непрочитанные переписки: имя жирнее и точка справа, без цифр */
.list .item .t.unread { font-weight: 650; }
.dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); display: block;
  margin-top: 4px; margin-left: auto; }

/* Редкие настройки не должны пугать в первый заход */
details.more { margin-top: 4px; }
details.more > summary { cursor: pointer; color: var(--blue); font-size: 13.5px;
  padding: 6px 0; list-style: none; user-select: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

/* ---------- зона загрузки файла ---------- */
.drop { margin-top: 14px; border: 1px dashed var(--line); border-radius: var(--r);
  padding: 22px 16px; text-align: center; cursor: pointer; background: var(--line-soft);
  transition: border-color .15s ease, background .15s ease; }
.drop:hover, .drop.over { border-color: var(--blue); background: rgba(47,125,225,.06); }
.drop b { display: block; font-size: 14px; font-weight: 500; }
.drop span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.drop.has { border-style: solid; border-color: var(--blue); }
