:root {
  --bg: #212529;
  --side: #1b1e21;
  --head: #212529;
  --line: rgba(233, 236, 239, 0.1);
  --bubble-in: #2b3035;
  --bubble-out: #8338ec;
  --text: #e9ecef;
  --muted: rgba(233, 236, 239, 0.55);
  --accent: #fb5607;
  --purple: #8338ec;
  --danger: #ff7a5c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", Roboto, -apple-system, system-ui, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  width: 100%;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(233, 236, 239, 0.16); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- shared bits ---------- */

.round {
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.round.small { width: 40px; height: 40px; }
.round.big { width: 84px; height: 84px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); font-size: 13px; margin: 0; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  flex: none;
}

.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover { background: rgba(233, 236, 239, 0.08); color: var(--text); }
.icon-btn.danger { color: var(--danger); }

.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}

.primary:disabled { opacity: 0.5; }
.primary.wide { width: 100%; }

.ghost {
  background: none;
  border: 0;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 14px;
}

.ghost:hover { color: var(--text); background: rgba(233, 236, 239, 0.06); }

input, textarea, select {
  background: rgba(233, 236, 239, 0.06);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  width: 100%;
}

input:focus, textarea:focus, select:focus { border-color: var(--purple); }
select option { background: #26292e; color: var(--text); }

/* ---------- app shell ---------- */

.app {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: var(--app-height, 100dvh);
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  background: var(--side);
  border-right: 1px solid var(--line);
  min-width: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.side-actions { display: flex; gap: 2px; }

.search-wrap { padding: 4px 12px 8px; }

#search {
  background: rgba(233, 236, 239, 0.08);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}

#search::placeholder { color: var(--muted); }

.folders {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 12px 10px;
  scrollbar-width: none;
}

.folders::-webkit-scrollbar { display: none; }

.folder {
  border: 0;
  background: rgba(233, 236, 239, 0.08);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.folder .count {
  font-size: 11px;
  color: var(--muted);
}

.folder[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

.folder[aria-selected="true"] .count { color: rgba(255, 255, 255, 0.75); }

.chat-list-wrap {
  overflow-y: auto;
  min-height: 0;
  padding: 0 6px 6px;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.chat-list { list-style: none; margin: 0; padding: 0; }

.chat-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: 12px;
  padding: 8px;
  margin: 1px 0;
}

.chat-row:hover { background: rgba(233, 236, 239, 0.06); }
.chat-row.active { background: var(--purple); }
.chat-row.active .row-preview, .chat-row.active .row-time { color: rgba(255, 255, 255, 0.75); }

.row-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  flex: none;
}

.row-avatar.busy { padding: 2px; background: var(--accent); }

.row-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-preview {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.row-time { font-size: 11.5px; color: var(--muted); }

.pill {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.side-foot {
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-top: 1px solid var(--line);
}

.empty {
  margin: 20px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- chat ---------- */

.chat-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
  position: relative;
}

.chat-top {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
  min-height: 58px;
  min-width: 0;
  overflow: hidden;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  flex: none;
}

/* Кнопки над лентой: подгрузить ранние сообщения или вернуться к последним. */
.pager {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 6;
  max-width: 100%;
  padding: 0 8px;
}

/* Открыт поиск внутри чата — полоска под шапкой занимает эти 66 px. */
body[data-find="1"] .pager { top: 112px; }

.pager-btn {
  border: 1px solid var(--line);
  background: rgba(33, 37, 41, 0.92);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.pager-btn:hover { border-color: var(--purple); }
.pager-btn:disabled { opacity: 0.5; }

.chat-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
  overflow: hidden;
}

.chat-titles strong {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-titles .muted { font-size: 12.5px; }

.chat-titles .muted.working { color: var(--accent); }

/* Поиск внутри открытого чата: полоска под шапкой, над лентой. */
.chat-find {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}

.chat-find input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  padding: 7px 12px;
  background: rgba(233, 236, 239, 0.07);
}

.find-count {
  flex: none;
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.messages {
  overflow-y: auto;
  min-height: 0;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(131, 56, 236, 0.16), transparent 60%),
    radial-gradient(900px 400px at 0% 110%, rgba(251, 86, 7, 0.1), transparent 60%),
    var(--bg);
}

.chat-hint {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--muted);
  font-size: 13px;
}

.chat-hint[hidden] { display: none; }

.date-sep {
  align-self: center;
  margin: 10px 0 6px;
  background: rgba(33, 37, 41, 0.75);
  color: var(--muted);
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.msg {
  max-width: min(620px, 82%);
  min-width: 0;
  padding: 7px 11px 6px;
  border-radius: 14px;
  background: var(--bubble-in);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  position: relative;
}

.msg.in {
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.msg.out {
  align-self: flex-end;
  background: var(--bubble-out);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.msg.pending { opacity: 0.6; }

.msg + .msg.in, .msg + .msg.out { margin-top: 2px; }

.msg-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.msg p { margin: 0; }
.msg strong { font-weight: 600; }
.msg a { color: #ffd9c7; }

.msg code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 5px;
  padding: 0 4px;
}

.msg pre {
  margin: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 9px;
  overflow-x: auto;
  white-space: pre;
  max-width: 100%;
}

.msg pre code { background: none; padding: 0; }

.msg-time {
  align-self: flex-end;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.msg.out .msg-time { color: rgba(255, 255, 255, 0.72); }

/* Копирование: иконка у сообщения и подпись у блока кода. На мыши
   появляются при наведении, на телефоне видны всегда, но приглушённо. */
.msg-copy {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 26, 0.74);
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.msg-copy svg { width: 14px; height: 14px; fill: currentColor; }
.msg:hover .msg-copy, .msg-copy:focus-visible, .msg-copy.done { opacity: 1; }
.msg-copy.done { color: #51cf66; }

.msg pre { position: relative; }

.code-copy {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 8px;
  font-size: 11px;
  background: rgba(20, 22, 26, 0.85);
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.msg pre:hover .code-copy, .code-copy:focus-visible, .code-copy.done { opacity: 1; }
.code-copy.done { color: #51cf66; }

@media (hover: none) {
  .msg-copy { opacity: 0.5; }
  .code-copy { opacity: 0.62; }
}

/* Найденное поиском внутри чата. */
mark.find { background: rgba(255, 212, 59, 0.32); color: inherit; border-radius: 3px; padding: 0; }
mark.find.current { background: #ffd43b; color: #14161a; }

/* Плашка «новые сообщения»: висит над полем ввода и не сдвигает ленту. */
.pill-slot {
  position: relative;
  height: 0;
  display: flex;
  justify-content: center;
  z-index: 7;
}

.new-pill {
  position: relative;
  top: -46px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12.5px;
  background: var(--purple);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.new-pill:hover { filter: brightness(1.08); }

.actions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.action {
  display: flex;
  gap: 7px;
  align-items: baseline;
  font-size: 12.5px;
  color: rgba(233, 236, 239, 0.62);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 4px 8px;
}

.action .mark { color: var(--purple); font-size: 11px; }
.action strong { color: var(--text); font-weight: 500; }
.action.error .mark { color: var(--accent); }
.action-note { display: block; color: var(--danger); font-size: 12px; margin-top: 2px; white-space: pre-wrap; }

details { margin: 0; }

details summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  list-style: none;
}

details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--purple); }
details[open] summary::before { content: "▾ "; }

.thinking-body {
  margin-top: 5px;
  padding: 8px 10px;
  border-left: 2px solid var(--purple);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: rgba(233, 236, 239, 0.7);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.outcome {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(233, 236, 239, 0.35);
}

.notice {
  align-self: center;
  margin: 6px 0;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(33, 37, 41, 0.8);
  border-radius: 999px;
  padding: 4px 12px;
  max-width: 90%;
  text-align: center;
}

.notice.error { color: #ffb3a0; }

/* Предложение отправить сообщение заново после обрыва связи. */
.notice.retry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  border-radius: 14px;
  padding: 6px 12px;
}

.notice.retry button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- composer ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-top: 1px solid var(--line);
  background: var(--head);
}

.composer textarea {
  resize: none;
  max-height: 160px;
  border-radius: 18px;
  padding: 10px 14px;
  line-height: 1.4;
  background: rgba(233, 236, 239, 0.07);
}

.send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
}

.send svg { width: 20px; height: 20px; fill: #fff; }
.send:disabled { opacity: 0.4; }

/* ---------- cards / dialogs ---------- */

.center-card {
  height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.center-card h1 { margin: 4px 0 0; font-size: 22px; }
.center-card input { max-width: 340px; text-align: center; }
.center-card .primary { max-width: 340px; }

.dialog {
  border: 0;
  border-radius: 14px;
  background: #26292e;
  color: var(--text);
  padding: 0;
  width: min(460px, calc(100vw - 28px));
  max-height: calc(var(--app-height, 100dvh) - 40px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.dialog::backdrop { background: rgba(10, 11, 13, 0.7); }

.dialog form, .dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
}

.dialog h2 { margin: 0; font-size: 18px; font-weight: 600; }

.dialog label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.dialog textarea { resize: vertical; }

.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }

/* ---------- limits ---------- */

.limits-body { display: flex; flex-direction: column; gap: 16px; }

.pool { display: flex; flex-direction: column; gap: 8px; }

.pool-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pool-name { font-weight: 600; font-size: 14px; }
.pool-name span { color: var(--muted); font-weight: 400; font-size: 12px; }

.window { display: flex; flex-direction: column; gap: 4px; }

.window-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.window-head b { color: var(--text); font-weight: 600; }

.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(233, 236, 239, 0.1);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple), var(--accent));
}

.pool.core .bar > i { background: linear-gradient(90deg, var(--accent), var(--purple)); }

/* ---------- composer extras ---------- */

.composer-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  flex: none;
}

.composer-btn svg { width: 20px; height: 20px; fill: currentColor; }
.composer-btn:hover { background: rgba(233, 236, 239, 0.08); color: var(--text); }
.composer-btn:disabled { opacity: 0.4; }

.composer-btn.rec {
  background: var(--danger);
  color: #fff;
  animation: rec-pulse 1.3s ease-in-out infinite;
}

@keyframes rec-pulse {
  50% { opacity: 0.55; }
}

#chat-title { cursor: pointer; }

/* ---------- chat row menu ---------- */

.chat-list li { position: relative; }
.chat-row { padding-right: 30px; }

.row-menu {
  position: absolute;
  top: 10px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.row-menu:hover { background: rgba(233, 236, 239, 0.14); color: var(--text); }
.chat-row.active ~ .row-menu { color: rgba(255, 255, 255, 0.85); }

.row-pin { color: var(--accent); font-size: 11px; margin-right: 4px; }

/* ---------- pickers ---------- */

.dialog .row input { flex: 1; min-width: 0; }

.dialog label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.dialog label.check input { width: auto; }

.dir-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 46vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dir-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  padding: 10px;
  font-size: 14px;
  text-align: left;
}

.dir-list button:hover { background: rgba(233, 236, 239, 0.08); }
.dir-list .size { color: var(--muted); font-size: 12px; flex: none; }
.dir-list .empty { padding: 10px; color: var(--muted); font-size: 13px; }
.dir-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-body { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.status-row { display: flex; justify-content: space-between; gap: 12px; }
.status-row b { font-weight: 600; }
.status-body .ok { color: #51cf66; }
.status-body .bad { color: var(--danger); }

/* Журнал событий на экране состояния: перезапуски, ошибки, медленные запросы. */
.journal-wrap { margin-top: 12px; }
.journal-title { margin: 0 0 4px; }

.journal {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 170px;
  overflow-y: auto;
  font-size: 12.5px;
}

.journal li { display: flex; gap: 8px; align-items: baseline; }
.journal time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.journal .kind { flex: none; color: var(--muted); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.05em; }
.journal .kind.error, .journal .kind.slow { color: #ffb3a0; }
.journal .kind.start, .journal .kind.restart { color: var(--accent); }
.journal .text { min-width: 0; overflow-wrap: anywhere; }


/* ---------- message search ---------- */

.found { padding: 0 6px 8px; }

.found-head {
  margin: 0 8px 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.found-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 42vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.found-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  padding: 8px 10px;
}

.found-row:hover { background: rgba(233, 236, 239, 0.06); }
.found-row.active { background: var(--purple); }
.found-row.active .found-snippet { color: rgba(255, 255, 255, 0.78); }

.found-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.found-snippet {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.found-snippet mark {
  background: rgba(251, 86, 7, 0.32);
  color: var(--text);
  border-radius: 3px;
  padding: 0 1px;
}

.found-note { margin: 4px 10px 0; font-size: 11.5px; color: var(--muted); }

/* ---------- unread ---------- */

.row-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.row-badge.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }
.chat-row.unread .row-name { color: #fff; }

/* ---------- image previews ---------- */

.shot {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  max-width: 100%;
}

.shot img {
  display: block;
  max-width: min(220px, 100%);
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.msg.hit { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 14px; }

.image-dialog {
  border: 0;
  background: transparent;
  padding: 0;
  max-width: 94vw;
  max-height: 88vh;
}

.image-dialog::backdrop { background: rgba(10, 11, 13, 0.86); }
.image-dialog img { display: block; max-width: 94vw; max-height: 88vh; border-radius: 10px; }

/* ---------- mobile ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  body[data-view="list"] .chat-pane { display: none; }
  body[data-view="chat"] .sidebar { display: none; }

  .chat-pane { border: 0; }
  #back { display: grid; }
  /* В шапке есть кнопка поиска: на узком экране отступы плотнее. */
  .chat-head { gap: 6px; padding: 8px 8px; }
  .chat-find { padding: 6px 8px; }

  .msg { max-width: 88%; }
  .messages { padding: 10px 10px 4px; }

  /* Safari zooms the whole page when a control smaller than 16px gets focus. */
  input, textarea, select { font-size: 16px; }

  .composer textarea { padding: 9px 14px; }
  .composer { gap: 4px; padding-left: 8px; padding-right: 10px; }
  .composer-btn { width: 30px; }
}

@media (min-width: 901px) {
  #back { display: none; }
}
