/* Relay — мессенджер в духе Telegram. Тема: авто по системе, либо data-theme="light|dark" на <html>. */
:root {
  --bg: #f4f4f5; --panel: #ffffff; --line: #e4e4e7; --text: #0f1419; --muted: #707579;
  --accent: #3390ec; --accent-soft: #e8f2fd; --ok: #2e9e4f; --ok-soft: #e6f6eb;
  --warn: #d48a00; --warn-soft: #fff5df; --bad: #e0393e; --bad-soft: #fdecec;
  --run: #0e7fa0; --run-soft: #e2f4f9; --radius: 12px;
  --chat-bg: #dfe6ea; --in: #ffffff; --out: #e1fec6; --hover: #f1f1f2; --search: #f1f1f2; --pill: rgba(60, 80, 90, .45);
  --shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1621; --panel: #17212b; --line: #0b1219; --text: #f5f5f5; --muted: #8b98a5;
  --accent: #5eb5f7; --accent-soft: #1f3447; --ok: #57c27a; --ok-soft: #173325;
  --warn: #f2b33d; --warn-soft: #3a2d12; --bad: #f06b6f; --bad-soft: #3b1a1c;
  --run: #6cd3ee; --run-soft: #12313a;
  --chat-bg: #0e1621; --in: #182533; --out: #2b5278; --hover: #202b36; --search: #242f3d; --pill: rgba(40, 55, 70, .8);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1621; --panel: #17212b; --line: #0b1219; --text: #f5f5f5; --muted: #8b98a5;
    --accent: #5eb5f7; --accent-soft: #1f3447; --ok: #57c27a; --ok-soft: #173325;
    --warn: #f2b33d; --warn-soft: #3a2d12; --bad: #f06b6f; --bad-soft: #3b1a1c;
    --run: #6cd3ee; --run-soft: #12313a;
    --chat-bg: #0e1621; --in: #182533; --out: #2b5278; --hover: #202b36; --search: #242f3d; --pill: rgba(40, 55, 70, .8);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--panel); color: var(--text); overflow: hidden;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
[hidden] { display: none !important; }

/* ---------- каркас: список чатов | лента ---------- */
.tg { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; height: 100vh; height: 100dvh; }
.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.list-head { display: flex; gap: 8px; align-items: center; padding: calc(8px + var(--safe-top)) 10px 8px; }
.search { flex: 1; min-width: 0; border: 0; outline: none; background: var(--search); border-radius: 22px; padding: 9px 16px; }
.search:focus { box-shadow: 0 0 0 2px var(--accent) inset; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.chat-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--accent); color: #fff; }
.chat-item.active .ci-time, .chat-item.active .ci-preview, .chat-item.active .typing { color: rgba(255, 255, 255, .85); }
.chat-item.active .unread { background: #fff; color: var(--accent); }
.chat-item.pinned { margin-bottom: 2px; }
.ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ci-top, .ci-bottom { display: flex; gap: 6px; align-items: center; }
.ci-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.ci-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-preview .who { color: var(--text); }
.chat-item.active .ci-preview .who { color: #fff; }
.typing { color: var(--accent); }
.unread { flex: none; background: var(--accent); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 7px;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.unread.warn { background: var(--warn); color: #fff; }

.ava { width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 18px; user-select: none; overflow: hidden; }
.ava.sm { width: 36px; height: 36px; font-size: 14px; }
.ava.warn { background: var(--warn); font-size: 22px; font-weight: 800; }
.ava.pair { display: flex; background: transparent; }
.ava.pair .ava.half { width: 50%; height: 100%; border-radius: 0; font-size: 13px; }
.ava.pair.sm .ava.half { font-size: 11px; }
.ava-space { width: 36px; flex: none; }

.round { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; font-size: 20px; line-height: 1; }
.round:hover { background: var(--hover); color: var(--text); }
.round.on { color: var(--warn); }
.pause-ico { font-size: 12px; letter-spacing: -1px; }
.round.send { background: var(--accent); color: #fff; font-size: 17px; }
.round.send:hover { filter: brightness(1.08); background: var(--accent); color: #fff; }
.back { display: none; }

.pane { display: flex; min-width: 0; min-height: 0; background: var(--chat-bg); }
/* Обои чата как в Telegram: мягкий градиент и узор из мелких значков поверх. */
.pane:has(.feed) {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23000' stroke-opacity='.07' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='24' cy='26' r='9'/%3E%3Cpath d='M70 14l6 12 13 2-9 9 2 13-12-6-12 6 2-13-9-9 13-2z'/%3E%3Cpath d='M120 30c8-10 22-2 14 8l-14 14-14-14c-8-10 6-18 14-8z'/%3E%3Crect x='14' y='84' width='26' height='18' rx='4'/%3E%3Cpath d='M18 84v-5h18v5'/%3E%3Cpath d='M78 80q10-14 20 0t20 0'/%3E%3Ccircle cx='136' cy='96' r='5'/%3E%3Cpath d='M128 110l16 0'/%3E%3Cpath d='M30 134l10 10 18-20'/%3E%3Cpath d='M90 124a12 12 0 1 0 0 24a12 12 0 1 0 0-24zm0 6v6l4 3'/%3E%3Cpath d='M140 134l8 14h-16z'/%3E%3C/svg%3E") repeat,
    linear-gradient(160deg, #d0e4a8 0%, #a8cf8e 45%, #87b97a 100%);
}
:root[data-theme="dark"] .pane:has(.feed) {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23fff' stroke-opacity='.04' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='24' cy='26' r='9'/%3E%3Cpath d='M70 14l6 12 13 2-9 9 2 13-12-6-12 6 2-13-9-9 13-2z'/%3E%3Cpath d='M120 30c8-10 22-2 14 8l-14 14-14-14c-8-10 6-18 14-8z'/%3E%3Crect x='14' y='84' width='26' height='18' rx='4'/%3E%3Cpath d='M78 80q10-14 20 0t20 0'/%3E%3Cpath d='M30 134l10 10 18-20'/%3E%3C/svg%3E") repeat, #0e1621;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pane:has(.feed) {
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%23fff' stroke-opacity='.04' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='24' cy='26' r='9'/%3E%3Cpath d='M70 14l6 12 13 2-9 9 2 13-12-6-12 6 2-13-9-9 13-2z'/%3E%3Cpath d='M120 30c8-10 22-2 14 8l-14 14-14-14c-8-10 6-18 14-8z'/%3E%3Crect x='14' y='84' width='26' height='18' rx='4'/%3E%3Cpath d='M78 80q10-14 20 0t20 0'/%3E%3Cpath d='M30 134l10 10 18-20'/%3E%3C/svg%3E") repeat, #0e1621;
  }
}
.pane-col { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 12px 8px; min-height: 58px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.pane-head .ttl { flex: 1; min-width: 0; }
.pane-head .ttl b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.pane-head .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; font-size: 14px; text-align: center; border-bottom: 1px solid var(--line); }
.empty-pane { flex: 1; display: grid; place-items: center; }
.empty-pane span { background: var(--pill); color: #fff; padding: 4px 14px; border-radius: 14px; font-size: 14px; }
.page { flex: 1; overflow-y: auto; padding: 16px 20px calc(32px + var(--safe-bottom)); background: var(--bg); }
.page > * { max-width: 900px; margin-left: auto; margin-right: auto; }

/* ---------- лента ---------- */
.feed { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 0 12px; }
.feed-inner { max-width: 760px; margin: 0 auto; padding: 0 12px; display: flex; flex-direction: column; gap: 3px; }
.day, .unread-mark { align-self: stretch; text-align: center; margin: 10px 0 6px; }
.day span { display: inline-block; background: rgba(0, 0, 0, .22); color: #fff; font-size: 13px; font-weight: 500; padding: 3px 11px; border-radius: 14px; }
.unread-mark span { display: block; background: var(--panel); color: var(--muted); font-size: 13px; padding: 4px; opacity: .9; }
.sys { align-self: center; max-width: 90%; text-align: center; font-size: 13px; color: #fff; background: var(--pill);
  padding: 3px 11px; border-radius: 14px; margin: 3px 0; overflow-wrap: anywhere; }
.sys a { color: #fff; font-weight: 600; }

.m { display: flex; align-items: flex-end; gap: 8px; max-width: min(88%, 620px); position: relative; }
.m.in { align-self: flex-start; }
.m.out { align-self: flex-end; flex-direction: row-reverse; }
.m.last { margin-bottom: 6px; }
.m.flash .bubble { animation: flash 1.4s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } }
.bubble { position: relative; background: var(--in); padding: 6px 10px 7px; border-radius: 15px; box-shadow: var(--shadow);
  min-width: 64px; max-width: 100%; overflow-wrap: anywhere; }
.m.out .bubble { background: var(--out); }
.m.in.last .bubble { border-bottom-left-radius: 0; }
.m.out.last .bubble { border-bottom-right-radius: 0; }
/* «Хвостик» последнего пузыря в серии, как в Telegram. */
.m.last .bubble:not(.photo)::after { content: ''; position: absolute; bottom: 0; width: 10px; height: 14px; background: inherit; }
.m.in.last .bubble:not(.photo)::after { left: -7px; clip-path: path('M10 0 C10 8 6 12 0 14 L10 14 Z'); }
.m.out.last .bubble:not(.photo)::after { right: -7px; clip-path: path('M0 0 C0 8 4 12 10 14 L0 14 Z'); }
/* Галочки «отправлено» у своих сообщений. */
.m.out .bubble .meta::after { content: ' ✓✓'; color: #4fae4e; letter-spacing: -3px; padding-right: 3px; }
:root[data-theme="dark"] .m.out .bubble .meta::after { color: #6ab3f3; }
.bubble .name { font-weight: 600; font-size: 14px; margin-bottom: 1px; }
.bubble .text { white-space: pre-wrap; }
.bubble .meta { float: right; font-size: 11px; color: var(--muted); margin: 7px 0 -5px 10px; line-height: 1; user-select: none; }
.bubble.photo { padding: 3px; }
.bubble.photo .name, .bubble.photo .task-ref { padding: 3px 7px 0; }
.bubble.photo .meta { position: absolute; right: 9px; bottom: 9px; margin: 0; color: #fff; background: rgba(0, 0, 0, .45); padding: 3px 6px; border-radius: 9px; }
.bubble.photo .media img { margin: 0; border-radius: 12px; }
.task-ref { display: block; font-size: 12px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 5px; margin: 2px 0 4px; font-size: 13px; cursor: pointer; }
.m.out .quote { background: rgba(255, 255, 255, .35); }
:root[data-theme="dark"] .m.out .quote { background: rgba(255, 255, 255, .08); }
.quote b { color: var(--accent); font-weight: 600; }
.quote div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention { color: var(--accent); font-weight: 600; }
.media { display: block; }
.media img, video.media { display: block; max-width: min(380px, 100%); max-height: 400px; border-radius: 10px; margin: 3px 0; background: var(--hover); }
video.media { width: 380px; max-width: 100%; }
.media-audio { width: 260px; max-width: 100%; margin: 4px 0; }
.reply-btn { position: absolute; top: 50%; right: -38px; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: var(--pill); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; }
.m.out .reply-btn { right: auto; left: -38px; }
.m:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; }
@media (hover: none) { .reply-btn { opacity: .55; } }

.filechip { display: flex; gap: 10px; align-items: center; color: var(--text); padding: 4px 0; min-width: 200px; }
.filechip .fi { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase; flex: none; }
.filechip .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* карточка задачи в ленте */
.taskcard { align-self: center; width: min(540px, 100%); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 12px 14px; margin: 8px 0; border-left: 4px solid var(--accent); }
.taskcard.st-in_progress { border-left-color: var(--run); }
.taskcard.st-awaiting_approval { border-left-color: var(--warn); }
.taskcard.st-done { border-left-color: var(--ok); }
.taskcard.st-failed { border-left-color: var(--bad); }
.taskcard.st-cancelled { border-left-color: var(--muted); }
.tc-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.tc-title { display: block; font-weight: 700; font-size: 16px; margin: 4px 0 2px; color: var(--text); overflow-wrap: anywhere; }
.tc-meta { font-size: 13px; color: var(--muted); }
.tc-meta b { color: var(--text); font-weight: 600; }
.tc-desc { font-size: 14px; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tc-note, .tc-result { font-size: 14px; margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.st-done .tc-result { background: var(--ok-soft); }
.st-failed .tc-result { background: var(--bad-soft); }
.tc-approval { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: 14px; }
.tc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tc-revise { margin-top: 10px; }
.tc-revise textarea { min-height: 60px; }
.tc-files { margin-top: 6px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 104px; height: 104px; object-fit: cover; border-radius: 10px; display: block; background: var(--hover); }
.approval-bubble { min-width: 260px; }
.approval-bubble .desc { margin: 4px 0; }

/* поле ввода */
.composer-wrap { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px calc(8px + var(--safe-bottom)); }
.composer { max-width: 760px; margin: 0 auto; display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: var(--search); border-radius: 21px;
  padding: 10px 16px; min-height: 42px; height: 42px; max-height: 160px; line-height: 1.35; }
.replybar { max-width: 760px; margin: 0 auto 6px; display: flex; gap: 8px; align-items: center; border-left: 3px solid var(--accent); padding-left: 10px; }
.replybar b { color: var(--accent); font-size: 14px; }

/* меню */
.drawer { position: fixed; inset: 0 auto 0 0; width: 300px; max-width: 86%; background: var(--panel); z-index: 40; transform: translateX(-104%);
  transition: transform .2s; padding: calc(16px + var(--safe-top)) 12px calc(16px + var(--safe-bottom)); overflow-y: auto; box-shadow: none; }
.drawer.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
.scrim { display: none; }
.scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; font-weight: 700; font-size: 18px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 8px 6px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a:hover { background: var(--hover); }
.segs { display: flex; gap: 4px; padding: 0 8px; }
.seg { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 4px; cursor: pointer; font-size: 13px; }
.seg.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* телефон: список → чат → назад */
@media (max-width: 760px) {
  .tg { grid-template-columns: minmax(0, 1fr); }
  .list-pane, .pane { min-width: 0; }
  .tg.at-pane .list-pane { display: none; }
  .tg.at-list .pane { display: none; }
  .list-pane { border-right: 0; }
  .back { display: grid; font-size: 22px; color: var(--text); }
  .pane-head { padding-left: 4px; gap: 6px; }
  .pane-head .btn.small { display: none; }
  .m { max-width: 90%; }
  .reply-btn { display: none; }
  .page { padding: 14px 14px calc(28px + var(--safe-bottom)); }
}

/* ---------- элементы старых разделов ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--text); }
.item:hover { border-color: var(--accent); }
.item .head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 6px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; white-space: nowrap;
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
label.f { display: block; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; background: var(--panel); cursor: pointer; }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-queued { background: var(--accent-soft); color: var(--accent); }
.s-in_progress { background: var(--run-soft); color: var(--run); }
.s-awaiting_approval { background: var(--warn-soft); color: var(--warn); }
.s-done { background: var(--ok-soft); color: var(--ok); }
.s-failed { background: var(--bad-soft); color: var(--bad); }
.s-cancelled { background: var(--hover); color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.err { color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: var(--panel);
  padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90%; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.approval { border-color: var(--warn); background: var(--warn-soft); }
.files .file { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.files .file:first-child { border-top: 0; }
.files .thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tag.result { color: var(--ok); font-weight: 700; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: none; }
.msg.owner { align-self: flex-end; } .msg.owner .bubble { background: var(--accent-soft); border-color: transparent; }
.msg.system { align-self: center; max-width: 100%; text-align: center; }
.msg.system .bubble { background: transparent; border: 0; color: var(--muted); font-size: 13px; padding: 0 8px; }
.page .composer { margin-top: 14px; max-width: none; }
.page .composer textarea { min-height: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; }
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.login .brand { justify-content: center; font-size: 24px; }
.conns { border-top: 1px solid var(--line); }
.conn { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
body.oauth { overflow: auto; background: var(--bg); }
body.oauth .login { margin-top: 8vh; padding-bottom: 32px; }
