:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --sidebar-bg: #f8fafc;
  --primary: #0067c0;
  --primary-hover: #005299;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Экран входа */
#login-screen {
  margin: auto;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
}
#login-screen h1 { font-size: 22px; margin-bottom: 6px; color: var(--primary); }
#login-screen p { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input,
.field select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

/* Основной интерфейс */
#app-screen { display: none; flex-direction: column; height: 100vh; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.brand { font-weight: 700; font-size: 18px; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.nav-tabs { display: flex; gap: 8px; }
.tab-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

/* Рабочая область чата с боковой панелью Группы -> Чаты */
#chat-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  width: 100%;
}

.chat-sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-actions {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.sidebar-actions .btn { flex: 1; padding: 8px 10px; font-size: 12.5px; }

.chat-tree-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.group-header {
  padding: 7px 10px;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.group-header-actions { display: flex; gap: 4px; }
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
}
.icon-btn:hover { background: #e2e8f0; color: var(--text); }
.icon-btn.del:hover { background: #fee2e2; color: var(--danger); }

.session-list { display: flex; flex-direction: column; }
.session-item {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.session-item:hover { background: #f8fafc; }
.session-item.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.session-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-actions { display: flex; gap: 2px; opacity: 0.65; }
.session-item:hover .session-actions { opacity: 1; }
/* Правая область диалога (широкая колонка без лишних пустых полей) */
#chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 28px;
  overflow: hidden;
}
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.chat-topbar > div:first-child {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-topbar > div:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chat-topbar select {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}
.chat-topbar .btn-sm {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
}
#active-chat-title { font-weight: 700; color: var(--text); font-size: 14.5px; }

#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 6px;
  padding-bottom: 16px;
}
.msg {
  padding: 16px 20px;
  border-radius: var(--radius);
  line-height: 1.55;
  max-width: 100%;
  font-size: 14.5px;
  overflow: visible;
  overflow-wrap: break-word;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  max-width: 78%;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.msg.ai {
  align-self: flex-start;
  width: 100%;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  border-bottom-left-radius: 2px;
}
.mode-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: #e0f2fe;
  color: #0369a1;
  margin-bottom: 10px;
}

.markdown-body { overflow: visible; }
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.markdown-body pre {
  max-width: 100%;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.markdown-body th { background: #f8fafc; font-weight: 600; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 14px 0 8px; line-height: 1.35; }
.markdown-body p { margin-bottom: 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 20px; }

/* Внутритекстовые ссылки на источники (/files/{id}/download) мелким шрифтом как отдельный бейдж */
.markdown-body a[href^="/files/"] {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0, 103, 192, 0.08);
  border: 1px solid rgba(0, 103, 192, 0.28);
  border-radius: 6px;
  padding: 2px 7px;
  margin: 2px 2px;
  text-decoration: none;
  vertical-align: baseline;
}
.markdown-body a[href^="/files/"]:hover {
  background: rgba(0, 103, 192, 0.16);
  border-color: var(--primary);
}

/* Кнопки скачивания сформированных документов (/exports/...) внутри ответа ИИ */
.markdown-body a[href^="/exports/"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 7px 13px;
  background: var(--primary);
  color: #ffffff !important;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.markdown-body a[href^="/exports/"]:hover { background: var(--primary-hover); }

/* Источники под ответом */
.sources-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.sources-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.sources-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.source-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.source-card:hover { background: #eff6ff; border-color: #93c5fd; }
.fmt-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
}
.fmt-pill.src { background: #dcfce7; color: #166534; }
.fmt-pill.pdf { background: #dbeafe; color: #1e40af; }
.type-pill {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}
.sql-box {
  margin-top: 10px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
}

/* Спойлер рассуждений модели */
details.thinking-box {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(127, 127, 127, 0.06);
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
details.thinking-box summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
details.thinking-box .thinking-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 260px;
  overflow-y: auto;
}

/* Панель ввода */
.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}
.composer.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 103, 192, 0.18);
}
.composer-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.composer-top label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.composer-top select {
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  outline: none;
}
.composer-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}
#attach-btn,
#mic-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 17px;
  transition: all 0.15s;
}
#attach-btn:hover,
#mic-btn:hover {
  border-color: var(--primary);
  background: var(--surface);
}
#mic-btn.recording {
  background: var(--danger) !important;
  color: #ffffff !important;
  border-color: var(--danger) !important;
  animation: pulse-mic 1.1s infinite;
}
@keyframes pulse-mic {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.composer-bottom textarea {
  flex: 1;
  height: 44px;
  min-height: 44px;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  overflow-y: auto;
  outline: none;
}
.composer-bottom textarea:focus { border-color: var(--primary); }
#send-btn {
  height: 44px;
  padding: 0 20px;
  flex-shrink: 0;
  border-radius: 9px;
  font-size: 13.5px;
}

/* Плашки прикреплённых локальных файлов над полем ввода */
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
}
.att-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  padding: 0 2px;
}
/* Админ-панель */
#admin-view {
  display: none;
  flex: 1;
  overflow-y: auto;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
  flex-direction: column;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2 { font-size: 16px; margin-bottom: 14px; color: var(--text); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.form-row .field { margin-bottom: 0; flex: 1; min-width: 160px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
table.data-table th, table.data-table td { border-bottom: 1px solid var(--border); padding: 9px 8px; text-align: left; }
table.data-table th { color: var(--muted); font-weight: 600; }
table.data-table select,
table.data-table input {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--surface);
  color: var(--text);
}
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.stat-box .stat-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-box .stat-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-box.warn .stat-val { color: var(--danger); }
.stat-box.ok .stat-val { color: var(--success); }

/* =====================================================================
   Темы оформления чата (ChatGPT / Claude / Hermes)
   ===================================================================== */

/* 1. Стиль ChatGPT */
body[data-theme="chatgpt"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --sidebar-bg: #f9f9f9;
  --primary: #10a37f;
  --primary-hover: #0d8a6a;
  --text: #0d0d0d;
  --muted: #676767;
  --border: #e5e5e5;
}
body[data-theme="chatgpt"] .msg.user {
  background: #f4f4f4;
  color: #0d0d0d;
  border-radius: 18px;
  padding: 12px 18px;
}
body[data-theme="chatgpt"] .msg.ai {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 10px 4px;
}
body[data-theme="chatgpt"] .composer {
  border-radius: 18px;
  border-color: #d9d9e3;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* 2. Стиль Claude */
body[data-theme="claude"] {
  --bg: #f5f4ef;
  --surface: #faf9f5;
  --sidebar-bg: #efeee8;
  --primary: #d97757;
  --primary-hover: #c26344;
  --text: #2c2b28;
  --muted: #737068;
  --border: #e2dfd5;
}
body[data-theme="claude"] .msg.user {
  background: #e8e5dc;
  color: #2c2b28;
  border-radius: 14px;
}
body[data-theme="claude"] .msg.ai {
  background: #faf9f5;
  border: 1px solid #e5e2d9;
  box-shadow: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15.5px;
  line-height: 1.65;
}
body[data-theme="claude"] .mode-badge {
  background: #f3e4dc;
  color: #b5583a;
  font-family: -apple-system, sans-serif;
}

/* 3. Стиль Hermes (тёмный инженерный интерфейс) */
body[data-theme="hermes"] {
  --bg: #0d1117;
  --surface: #161b22;
  --sidebar-bg: #090c10;
  --primary: #2ea043;
  --primary-hover: #3fb950;
  --text: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
}
body[data-theme="hermes"] .tab-btn.active {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border-color: #2ea043;
}
body[data-theme="hermes"] .group-header { background: #1c2128; color: #c9d1d9; }
body[data-theme="hermes"] .session-item { border-top-color: #21262d; }
body[data-theme="hermes"] .session-item:hover { background: #1c2128; }
body[data-theme="hermes"] .session-item.active {
  background: rgba(46, 160, 67, 0.14);
  color: #3fb950;
}
body[data-theme="hermes"] .msg.user {
  background: #1f6feb;
  color: #ffffff;
  border: 1px solid #388bfd;
}
body[data-theme="hermes"] .msg.ai {
  background: #161b22;
  border: 1px solid #30363d;
  box-shadow: none;
}
body[data-theme="hermes"] .mode-badge {
  background: rgba(56, 139, 253, 0.15);
  color: #58a6ff;
  font-family: monospace;
}
body[data-theme="hermes"] .markdown-body th { background: #1c2128; }
body[data-theme="hermes"] .markdown-body a[href^="/files/"] {
  color: #58a6ff;
  background: rgba(56, 139, 253, 0.12);
  border-color: rgba(56, 139, 253, 0.35);
}
body[data-theme="hermes"] .att-chip {
  background: rgba(56, 139, 253, 0.14);
  color: #58a6ff;
  border-color: #30363d;
}
body[data-theme="hermes"] .source-card {
  background: #0d1117;
  border-color: #30363d;
  color: #58a6ff;
}
body[data-theme="hermes"] .source-card:hover { background: #1c2128; border-color: #58a6ff; }
body[data-theme="hermes"] .composer-top select,
body[data-theme="hermes"] .composer-bottom textarea,
body[data-theme="hermes"] .chat-topbar select,
body[data-theme="hermes"] .field input,
body[data-theme="hermes"] .field select {
  background: #0d1117;
  color: #e6edf3;
  border-color: #30363d;
}
body[data-theme="hermes"] .stat-box { background: #0d1117; }

/* Адаптация под iPad в портретной ориентации */
@media (max-width: 960px) {
  .chat-sidebar { width: 225px; }
  #chat-view { padding: 12px 14px; }
  .chat-topbar { flex-wrap: wrap; }
}
/* =====================================================================
   Тема Nextcloud Talk (фирменный стиль облака Nextcloud по умолчанию)
   ===================================================================== */
body:not([data-theme]),
body[data-theme="classic"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --sidebar-bg: #f5f5f5;
  --primary: #0082c9;
  --primary-hover: #006aa3;
  --text: #222222;
  --muted: #767676;
  --border: #ebebeb;
  --radius: 14px;
}

/* Фирменная синяя верхняя панель в стиле Nextcloud */
body:not([data-theme]) header,
body[data-theme="classic"] header {
  background: #0082c9;
  border-bottom: none;
  color: #ffffff;
  height: 50px;
  padding: 0 18px;
}
body:not([data-theme]) .brand,
body[data-theme="classic"] .brand {
  color: #ffffff;
  font-size: 16px;
}
body:not([data-theme]) .tab-btn,
body[data-theme="classic"] .tab-btn {
  color: rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  padding: 5px 13px;
}
body:not([data-theme]) .tab-btn:hover,
body[data-theme="classic"] .tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}
body:not([data-theme]) .tab-btn.active,
body[data-theme="classic"] .tab-btn.active {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-color: transparent;
}
body:not([data-theme]) .user-info,
body[data-theme="classic"] .user-info {
  color: rgba(255, 255, 255, 0.92);
}
body:not([data-theme]) header .btn-sm,
body[data-theme="classic"] header .btn-sm {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
}

/* Светлый минималистичный сайдбар слева (как список бесед Nextcloud Talk) */
body:not([data-theme]) .chat-sidebar,
body[data-theme="classic"] .chat-sidebar {
  background: #f5f5f5;
  border-right: 1px solid #e6e6e6;
}
body:not([data-theme]) .group-block,
body[data-theme="classic"] .group-block {
  background: transparent;
  border: none;
}
body:not([data-theme]) .group-header,
body[data-theme="classic"] .group-header {
  background: transparent;
  color: #555555;
  font-size: 12px;
  padding: 6px 8px;
}
body:not([data-theme]) .session-item,
body[data-theme="classic"] .session-item {
  border-top: none;
  border-radius: 10px;
  margin-bottom: 2px;
  padding: 8px 10px;
}
body:not([data-theme]) .session-item:hover,
body[data-theme="classic"] .session-item:hover {
  background: #eaeaea;
}
body:not([data-theme]) .session-item.active,
body[data-theme="classic"] .session-item.active {
  background: #e3f2fd;
  color: #006aa3;
}

/* Облачка сообщений: светло-серые слева у ИИ, нежно-голубые справа у пользователя */
body:not([data-theme]) #messages,
body[data-theme="classic"] #messages {
  gap: 10px;
  padding: 8px 12px 16px;
}
body:not([data-theme]) .msg.ai,
body[data-theme="classic"] .msg.ai {
  align-self: flex-start;
  width: auto;
  max-width: 84%;
  background: #f5f5f5;
  border: none;
  box-shadow: none;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 12px 16px;
  color: #222222;
}
body:not([data-theme]) .msg.user,
body[data-theme="classic"] .msg.user {
  align-self: flex-end;
  max-width: 72%;
  background: #e1f1fb;
  color: #162b3a;
  border-radius: 14px;
  border-top-right-radius: 4px;
  padding: 10px 15px;
}
body:not([data-theme]) .mode-badge,
body[data-theme="classic"] .mode-badge {
  background: #e6eef4;
  color: #006aa3;
  font-size: 10.5px;
  border-radius: 10px;
  margin-bottom: 6px;
}

/* Нижняя капсула ввода сообщения в стиле Nextcloud Talk */
body:not([data-theme]) .composer,
body[data-theme="classic"] .composer {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 22px;
  padding: 8px 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  gap: 6px;
}
body:not([data-theme]) .composer-top,
body[data-theme="classic"] .composer-top {
  padding-bottom: 4px;
  border-bottom: 1px solid #f2f2f2;
}
body:not([data-theme]) .composer-top select,
body[data-theme="classic"] .composer-top select {
  height: 26px;
  font-size: 12px;
  border-radius: 12px;
  background: #f5f5f5;
  border-color: transparent;
}
body:not([data-theme]) .composer-bottom textarea,
body[data-theme="classic"] .composer-bottom textarea {
  border: none;
  background: transparent;
  height: 38px;
  min-height: 38px;
  padding: 8px 6px;
}
body:not([data-theme]) #attach-btn,
body:not([data-theme]) #mic-btn,
body[data-theme="classic"] #attach-btn,
body[data-theme="classic"] #mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #555555;
}
body:not([data-theme]) #attach-btn:hover,
body:not([data-theme]) #mic-btn:hover,
body[data-theme="classic"] #attach-btn:hover,
body[data-theme="classic"] #mic-btn:hover {
  background: #f0f0f0;
  color: #0082c9;
}
body:not([data-theme]) #send-btn,
body[data-theme="classic"] #send-btn {
  height: 36px;
  border-radius: 18px;
  padding: 0 18px;
  background: #0082c9;
}
body:not([data-theme]) #send-btn:hover,
body[data-theme="classic"] #send-btn:hover {
  background: #006aa3;
}
/* =====================================================================
   Сворачиваемый сайдбар (как в Nextcloud Talk), подвал группы и селектор в шапке
   ===================================================================== */

/* Селектор темы в верхней синей панели */
.header-theme-select {
  height: 30px;
  padding: 0 10px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
body:not([data-theme]) .header-theme-select,
body[data-theme="classic"] .header-theme-select {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
}
body:not([data-theme]) .header-theme-select option,
body[data-theme="classic"] .header-theme-select option {
  background: #ffffff;
  color: #222222;
}

/* Плавное сворачивание левой панели чатов */
.chat-sidebar {
  transition: width 0.2s ease, min-width 0.2s ease, opacity 0.15s ease;
  overflow: hidden;
}
.chat-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Кнопка-гамбургер ☰ рядом с заголовком диалога (в стиле Nextcloud Talk) */
.sidebar-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.sidebar-toggle-btn:hover {
  background: rgba(127, 127, 127, 0.12);
}

/* Нижний блок выбора группы в левом столбце */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.sidebar-footer label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.sidebar-footer select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

/* =====================================================================
   Вертикальный рейл 48px при сворачивании левого столбца с чатами
   ===================================================================== */
.sidebar-actions {
  padding: 10px 10px;
  gap: 6px;
  align-items: center;
}

.chat-sidebar.collapsed {
  width: 48px !important;
  min-width: 48px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  border-right: 1px solid var(--border) !important;
  background: var(--sidebar-bg) !important;
}

.chat-sidebar.collapsed .sidebar-actions {
  padding: 10px 7px;
  justify-content: center;
  border-bottom: none;
}

.chat-sidebar.collapsed .sidebar-actions > button:not(#sidebar-toggle-btn),
.chat-sidebar.collapsed .chat-tree-list,
.chat-sidebar.collapsed .sidebar-footer {
  display: none !important;
}
/* Сворачиваемый блок использованных документов под ответом */
details.sources-wrap summary.sources-title {
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
details.sources-wrap[open] summary.sources-title {
  margin-bottom: 10px;
}
details.sources-wrap summary.sources-title:hover {
  color: var(--primary);
}
