:root {
  --bg: #f6f7fb;
  --bg-soft: #eef1f8;
  --panel: #ffffff;
  --panel-muted: #fafbfe;
  --border: #e7eaf1;
  --border-strong: #d6dbea;
  --text: #202434;
  --muted: #7c8494;
  --primary: #5b5ce2;
  --primary-dark: #34359a;
  --primary-soft: #eef0ff;
  --shadow-sm: 0 1px 3px rgba(30, 36, 54, .06);
  --shadow-md: 0 12px 32px rgba(30, 36, 54, .10);
  --danger: #e5484d;
  --success: #179b61;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; flex-direction: column; height: 100vh; }

/* 顶部导航 */
.topbar {
  height: 62px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; background: #f8f8ff; border-bottom: 1px solid rgba(91, 92, 226, .10); color: #172033;
  box-shadow: var(--shadow-sm);
}
.topbar-brand { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-logo {
  width: 38px; height: 38px; flex: none; display: block; object-fit: cover;
  border-radius: 10px; background: #6554e8;
  box-shadow: 0 7px 18px rgba(91, 92, 226, .20);
}
.topbar-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topbar-title strong { font-size: 19px; line-height: 1.2; color: var(--primary-dark); letter-spacing: .2px; }
.topbar-title span { color: #697286; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell { flex: 1; min-height: 0; display: flex; }

/* 侧边导航 */
.sidebar {
  width: 220px;
  background: #fbfcff;
  border-right: 1px solid rgba(214, 219, 234, .70);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 20px;
}
.nav { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border: none; background: transparent; padding: 5px 8px; cursor: pointer;
  color: #a5adbc; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em;
}
.nav-group-toggle:hover { color: #7e8798; }
.nav-group-arrow { font-size: 12px; transition: transform .15s; }
.nav-group-items { display: flex; flex-direction: column; gap: 4px; }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group.collapsed .nav-group-arrow { transform: rotate(-90deg); }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 11px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.nav-icon {
  width: 26px; height: 26px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: #f0f2f8; color: #7c8494; font-size: 16px;
}
.nav-item:hover { background: #f1f3fa; color: var(--text); }
.nav-item.active {
  background: #ffffff;
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.nav-item.active .nav-icon { background: var(--primary-soft); color: var(--primary); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-todo {
  color: #a0a8b7;
  cursor: default;
}
.nav-todo:hover {
  background: transparent;
  color: #8d96a6;
  box-shadow: none;
}
.nav-todo .nav-icon {
  opacity: .72;
}
.todo-badge {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: #f1f3f8;
  color: #a0a8b7;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.topbar-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.language-select {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid rgba(214, 219, 234, .95);
  border-radius: 9px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}
.language-mark {
  flex: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.language-select select {
  width: auto;
  min-width: 88px;
  padding: 0 22px 0 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 13px;
}
.language-select select:focus { box-shadow: none; }
.account-switch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-login-btn,
.account-logout-btn {
  height: 36px;
  border: 1px solid rgba(214, 219, 234, .95);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.account-login-btn {
  border-color: rgba(91, 92, 226, .28);
  color: var(--primary);
  background: var(--primary-soft);
}
.account-login-btn:hover,
.account-logout-btn:hover {
  border-color: rgba(91, 92, 226, .36);
  color: var(--primary);
}

@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-title span { display: none; }
  .topbar-logo { width: 34px; height: 34px; border-radius: 9px; }
  .language-select select { min-width: 58px; }
  .account-login-btn,
  .account-logout-btn { padding: 0 10px; }
}
.app-shell.auth-locked { display: none; }
.auth-screen {
  flex: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.auth-screen.active { display: flex; }
.auth-card {
  width: 360px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 24px;
}
.auth-card h2 { margin-bottom: 18px; }
.auth-card .form-grid { gap: 14px; }
.auth-error { min-height: 18px; color: var(--danger); font-size: 12px; }

/* 内容区 */
.content { flex: 1; overflow: hidden; }
.page { display: none; height: 100%; }
.page.active { display: flex; }

/* 通用元素 */
h2 { margin: 0 0 14px; font-size: 18px; }
button { font-family: inherit; }
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 1px 1px rgba(30, 36, 54, .03);
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .15s;
}
.btn:hover { border-color: #c9cee0; color: var(--primary); background: #fbfcff; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 8px 18px rgba(91, 92, 226, .22); }
.btn-primary:hover { background: #4f50d4; color: #fff; border-color: #4f50d4; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); color: inherit; }

table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm);
}
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfcff; }
th { color: #687286; font-weight: 600; background: var(--panel-muted); }
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.tag-published { background: #e8f7ef; color: var(--success); }
.tag-draft { background: #f0f1f3; color: var(--muted); }
.tag-danger { background: #fff0f0; color: var(--danger); }
.tag-soft { background: var(--primary-soft); color: var(--primary); }

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(91, 92, 226, .55);
  box-shadow: 0 0 0 3px rgba(91, 92, 226, .12);
}
textarea { resize: vertical; min-height: 60px; }

/* 列表型页面 */
.list-page { width: 100%; padding: 26px 30px; overflow: auto; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.row-actions { display: flex; gap: 6px; }
.row-actions input { min-width: 0; }
.cell-title { font-weight: 600; }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.knowledge-table { table-layout: fixed; }
.knowledge-table th:nth-child(1) { width: 34%; }
.knowledge-table th:nth-child(2) { width: 20%; }
.knowledge-table th:nth-child(3) { width: 9%; }
.knowledge-table th:nth-child(4) { width: 12%; }
.knowledge-table th:nth-child(5) { width: 11%; }
.knowledge-table th:nth-child(6) { width: 14%; }
.knowledge-name-cell { max-width: 340px; min-width: 0; }
.knowledge-name-cell .cell-title,
.knowledge-name-cell .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }

/* 弹窗表单 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(22, 27, 40, .42);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--panel); border-radius: 14px;
  width: 560px; max-height: 86vh; overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid rgba(255,255,255,.70);
  box-shadow: var(--shadow-md);
}
.modal h2 { padding: 22px 24px 0; font-size: 18px; }
.modal-body { overflow: auto; padding: 0 24px 4px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field label { display: block; font-size: 12px; color: #687286; margin-bottom: 5px; font-weight: 600; }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px 18px; border-top: 1px solid var(--border); background: var(--panel-muted);
}
.form-error { border: 1px solid #ffd2d2; background: #fff7f7; color: var(--danger); border-radius: 7px; padding: 8px 10px; font-size: 12px; }

/* 对话页 */
.chat-page { width: 100%; display: flex; }
.chat-sessions {
  width: 308px; border-right: 1px solid rgba(214, 219, 234, .75); background: #fbfcff;
  display: flex; flex-direction: column;
}
.chat-sessions .sessions-head { padding: 16px; border-bottom: 1px solid rgba(214, 219, 234, .70); }
.session-list { flex: 1; overflow: auto; }
.session-item {
  position: relative;
  margin: 8px 10px; padding: 12px 12px; border: 1px solid #edf0f6; border-radius: 11px; cursor: pointer;
  background: #ffffff;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.session-item:hover { background: #ffffff; border-color: rgba(91, 92, 226, .20); box-shadow: 0 6px 16px rgba(30, 36, 54, .07); }
.session-item.active { background: #f7f8ff; border-color: rgba(91, 92, 226, .35); box-shadow: 0 8px 20px rgba(91, 92, 226, .12); }
.session-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--primary);
}
.session-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.session-item .title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-session-head { min-width: 0; display: flex; flex-wrap: nowrap; align-items: baseline; gap: 4px; white-space: nowrap; }
.group-session-head .title {
  flex: 0 0 auto; min-width: 0; font-weight: 700;
  overflow: visible; text-overflow: clip; white-space: nowrap;
}
.group-session-members {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #8f97a8; font-size: 11px; font-weight: 400;
}
.session-item .del {
  width: 24px; height: 24px; color: #a1a8b7; border: none; border-radius: 7px;
  background: transparent; cursor: pointer; font-size: 15px; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.session-item:hover .del { opacity: 1; }
.session-item .del:hover { background: #fff1f1; color: var(--danger); }
.session-item.is-running { border-color: rgba(35, 134, 90, .35); }
.session-running {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px; color: #23865a; background: rgba(35, 134, 90, .08);
}
.running-spinner {
  width: 13px; height: 13px; border-radius: 999px; border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: running-spin .8s linear infinite;
}
.chat-running-indicator {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  color: #23865a; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.group-running { display: contents; }
.group-run-row .group-sender { color: #23865a; }
.group-run-empty { color: var(--muted); font-size: 12px; padding: 6px 0; }
@keyframes running-spin { to { transform: rotate(360deg); } }

.chat-header {
  display: flex; align-items: baseline; gap: 10px;
  padding: 15px 24px; border-bottom: 1px solid rgba(214, 219, 234, .75); background: rgba(255, 255, 255, .86);
}
.chat-header-name { font-size: 15px; font-weight: 700; }
.chat-header-model { font-size: 12px; color: var(--muted); }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow: auto; padding: 26px 28px; display: flex; flex-direction: column; gap: 14px; }
.msg-wrap { max-width: 76%; display: flex; flex-direction: column; align-self: flex-start; align-items: flex-start; }
.msg { max-width: 76%; padding: 11px 15px; border-radius: 14px; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 8px 18px rgba(91, 92, 226, .18); }
.msg.assistant { width: 100%; max-width: none; background: var(--panel); border: 1px solid rgba(214, 219, 234, .88); border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); }
.msg-actions { margin-top: 6px; display: flex; justify-content: flex-start; }
.msg-copy,
.msg-resend {
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  border-radius: 5px; padding: 2px 7px; font-size: 12px; cursor: pointer;
}
.msg-copy:hover,
.msg-resend:hover { color: var(--primary); border-color: var(--primary); }
.msg.user .msg-content { white-space: pre-wrap; }
.msg-content p { margin: 0 0 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 {
  margin: 0 0 8px; font-size: 15px; line-height: 1.5;
}
.msg-content ul, .msg-content ol { margin: 0 0 10px; padding-left: 20px; }
.msg-content li { margin: 2px 0; }
.msg-content code {
  padding: 1px 4px; border-radius: 4px; background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px;
}
.msg-content { overflow-x: auto; }
.msg-content table {
  width: 100%; min-width: 520px; border-collapse: collapse;
  table-layout: auto; font-size: 13px; background: var(--panel); margin: 8px 0 12px;
}
.msg-content th, .msg-content td {
  padding: 6px 8px; border: 1px solid var(--border);
  vertical-align: top; word-break: break-word;
}
.msg-content th { background: var(--bg); color: var(--text); font-weight: 600; }
.chat-empty {
  margin: auto; color: var(--muted); padding: 28px 34px; border: 1px dashed var(--border-strong);
  border-radius: 14px; background: rgba(255,255,255,.65);
}
.chat-input-bar { display: flex; gap: 10px; padding: 16px 24px; border-top: 1px solid rgba(214, 219, 234, .75); background: rgba(255, 255, 255, .92); }
.chat-input-bar textarea { flex: 1; min-height: 44px; max-height: 140px; }
.chat-stop-btn { flex: 0 0 auto; align-self: flex-end; }

.new-session-form { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.muted { color: var(--muted); font-size: 12px; }

/* 知识库页 */
.k-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.k-toolbar input { flex: 0 0 260px; }
.k-toolbar select { flex: 1; min-width: 180px; }
.k-empty { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
.k-empty-title { font-weight: 600; color: var(--text); }
.k-run-panel { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.k-run-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgba(91, 92, 226, .18); border-radius: 10px; background: #f7f8ff; }
.k-run-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.k-run-title { min-width: 0; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.k-run-title span { color: var(--muted); flex: 0 0 auto; }
.k-run-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.k-run-bar { height: 5px; overflow: hidden; border-radius: 999px; background: rgba(91, 92, 226, .13); }
.k-run-bar span { display: block; height: 100%; min-width: 16px; border-radius: inherit; background: var(--primary); transition: width .2s; }
.k-run-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.k-run-cancel { flex: 0 0 auto; }

/* RAG 数字员工配置区 */
.rag-section { border: 1px solid rgba(91, 92, 226, .16); border-radius: 11px; padding: 13px; background: #f7f8ff; }

/* 复选框组（标签选择） */
.chk-group { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }

/* 标签多选下拉 */
.tag-multiselect { position: relative; }
.multi-trigger {
  width: 100%; min-height: 40px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--panel);
  text-align: left; font-size: 13px; color: var(--text); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.multi-trigger span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-trigger::after { content: "⌄"; float: right; color: var(--muted); }
.tag-multiselect.open .multi-trigger,
.multi-trigger:hover { border-color: rgba(91, 92, 226, .45); box-shadow: 0 0 0 3px rgba(91, 92, 226, .10); }
.multi-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 180px; overflow: auto; z-index: 3;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md);
}
.tag-multiselect.open .multi-menu { display: block; }
.multi-option { display: flex; align-items: center; gap: 8px; padding: 9px 11px; font-size: 13px; cursor: pointer; }
.multi-option:hover { background: var(--primary-soft); }
.multi-option input { width: auto; }

/* 分块预览 */
.chunk-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chunk-item {
  font-size: 12px; padding: 9px 10px; background: var(--panel-muted);
  border: 1px solid var(--border); border-radius: 9px;
  white-space: pre-wrap; word-break: break-word;
}
.chunk-title { display: block; font-weight: 600; color: var(--primary); margin-bottom: 4px; font-size: 11px; }

/* 检索调试结果 */
.search-results { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.search-hit { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: #ffffff; box-shadow: var(--shadow-sm); }
.hit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 10px; background: var(--panel-muted); font-size: 12px; font-weight: 600; }
.hit-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hit-title span, .hit-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit-title small { color: var(--muted); font-size: 11px; font-weight: 400; }
.hit-score { color: var(--primary); font-size: 11px; }
.hit-body { padding: 8px 10px; font-size: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }

/* 对话引用片段 */
.sources { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; font-size: 12px; }
.sources summary { cursor: pointer; color: var(--muted); font-weight: 500; user-select: none; }
.src-item { margin-top: 8px; padding: 9px; background: var(--panel-muted); border: 1px solid var(--border); border-radius: 9px; }
.src-label { display: block; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.src-doc { display: block; color: var(--muted); margin-bottom: 6px; }
.src-item p { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--text); line-height: 1.5; }

/* 标签管理 */
.tag-manage-list { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.tag-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--panel-muted); border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }

@media (max-width: 900px) {
  .list-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .k-toolbar { align-items: stretch; flex-direction: column; }
  .k-toolbar input { flex: none; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }
}


/* 多 Agent teamwork */
.group-chat-page { width: 100%; display: flex; min-width: 0; }
.group-list-panel { width: 308px; border-right: 1px solid rgba(214, 219, 234, .75); background: #fbfcff; display: flex; flex-direction: column; }
.group-main { flex: 1; min-width: 0; display: flex; }
.group-workspace { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.group-workspace.side-collapsed { grid-template-columns: minmax(0, 1fr) 44px; }
.group-chat-main { min-width: 0; display: flex; flex-direction: column; }
.group-main > .new-session-form { flex: 1; }
.group-chat-header { align-items: center; }
.group-chat-header .chat-header-model { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-messages { min-height: 0; }
.group-msg-row { max-width: 76%; display: flex; flex-direction: column; gap: 4px; align-self: flex-start; align-items: flex-start; }
.group-msg-row.user { align-self: flex-end; align-items: flex-end; }
.group-msg-row .msg { max-width: 100%; }
.group-sender { font-size: 12px; color: #7c8494; padding: 0 4px; font-weight: 500; }
.group-sender span { margin-left: 6px; }
.group-side { border-left: 1px solid rgba(214, 219, 234, .70); background: #fbfcff; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.group-side-head { height: 50px; padding: 0 12px 0 16px; border-bottom: 1px solid rgba(214, 219, 234, .65); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.group-side-head strong { min-width: 0; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-toggle {
  width: 28px; height: 28px; flex: none; border: 1px solid var(--border); border-radius: 8px;
  background: #ffffff; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1;
  box-shadow: var(--shadow-sm);
}
.side-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.group-side-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.group-side.collapsed .group-side-head { height: 100%; padding: 8px 7px; align-items: flex-start; justify-content: center; border-bottom: none; }
.group-side.collapsed .group-side-head strong,
.group-side.collapsed .group-side-body { display: none; }
.env-section { border-bottom: 1px solid rgba(214, 219, 234, .70); padding-bottom: 16px; margin-bottom: 16px; }
.env-section:last-child { border-bottom: none; margin-bottom: 0; }
.env-section h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; }
.env-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.env-section-head h3 { margin: 0; }
.btn-symbol { display: inline-block; margin-right: 4px; font-weight: 700; line-height: 1; }
.env-row, .env-add-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 9px; background: #ffffff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); }
.env-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-agent-row { gap: 6px; font-size: 12px; }
.env-agent-row .agent-icon {
  flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: var(--primary-soft); color: var(--primary); font-size: 13px;
}
.env-agent-row .btn-sm { padding: 3px 8px; font-size: 11px; }
.env-add-row select { min-width: 0; }
.env-card { border: 1px solid var(--border); border-radius: 10px; padding: 9px; margin-bottom: 8px; background: #ffffff; box-shadow: var(--shadow-sm); }
.env-title { font-weight: 600; font-size: 12px; margin-bottom: 4px; }
.env-content { font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.env-add-memory { display: grid; gap: 8px; }
.env-tree { font-size: 12px; }
.env-folder { color: var(--text); font-weight: 600; margin-bottom: 8px; }
.env-file { border: 1px solid var(--border); border-radius: 10px; padding: 9px; margin-bottom: 8px; background: #ffffff; box-shadow: var(--shadow-sm); }
.env-file summary { cursor: pointer; word-break: break-all; }
.env-file summary span { color: var(--muted); font-size: 11px; margin-left: 4px; }
.env-file pre { max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.group-attachments { min-height: 0; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px 8px; background: var(--panel); }
.attach-chip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 4px 9px; font-size: 12px; }
.group-agent-checks { display: flex; flex-direction: column; align-items: flex-start; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 7px; padding: 8px; }

@media (max-width: 1100px) {
  .group-workspace { grid-template-columns: 1fr; }
  .group-side { display: none; }
}


.group-agent-modal { width: 460px; }
.agent-picker-list { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.agent-picker-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 8px; padding: 10px 11px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}
.agent-picker-item:hover { background: var(--primary-soft); border-color: rgba(91, 92, 226, .24); }
.agent-picker-item input { width: auto; }
.agent-picker-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.agent-picker-item small { color: var(--muted); font-size: 11px; }


.group-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.group-input-wrap textarea { flex: 1; }
.mention-menu {
  display: none; position: absolute; left: 0; bottom: calc(100% + 8px);
  width: min(280px, 90vw); max-height: 220px; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow-md); padding: 6px; z-index: 6;
}
.mention-menu.show { display: flex; flex-direction: column; gap: 4px; }
.mention-item {
  border: none; background: transparent; border-radius: 8px; padding: 9px 10px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  text-align: left; cursor: pointer; font-family: inherit;
}
.mention-item:hover { background: var(--primary-soft); }
.mention-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text); }
.mention-item small { color: var(--muted); font-size: 11px; }

.mention-item.active { background: var(--primary-soft); color: var(--primary); }
.mention-item.active span { color: var(--primary); font-weight: 600; }


/* Scroll containment for chat layouts */
.chat-page,
.group-chat-page,
.group-main,
.group-workspace,
.chat-main,
.group-chat-main {
  min-height: 0;
}

.chat-page,
.group-chat-page,
.group-main,
.group-workspace {
  height: 100%;
}

.chat-messages,
.group-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.group-input-wrap textarea,
.chat-input-bar textarea {
  overflow-y: auto;
}
