/* ============================================================
   咕咕嘎嘎 · 财税知识助手
   单文件样式，无构建、无外部依赖。
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #6b7280;
  --faint: #9aa3af;
  --line: #e7eaef;
  --brand: #0f766e;
  --brand-soft: #e6f4f1;
  --brand-2: #14b8a6;
  --amber: #f59e0b;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --sidebar: #0b1524;
  --sidebar-2: #101f33;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 2px 6px rgba(15, 23, 42, .06), 0 18px 40px -24px rgba(15, 23, 42, .28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

svg.duck { flex: none; display: block; }
.duck-sm { width: 34px; height: 34px; }
.duck-lg { width: 44px; height: 44px; }
.duck-xl { width: 64px; height: 64px; }

/* ============================ 登录 ============================ */
.login-view {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}

.login-aside {
  position: relative;
  padding: 56px 64px;
  color: #e8eef7;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(20, 184, 166, .22), transparent 60%),
    radial-gradient(800px 400px at 110% 110%, rgba(245, 158, 11, .12), transparent 60%),
    linear-gradient(160deg, #0b1524 0%, #0e2135 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.login-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 30% 40%, #000 30%, transparent 75%);
  pointer-events: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.login-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.login-brand-text strong { font-size: 17px; letter-spacing: .5px; }
.login-brand-text span { font-size: 12px; color: #93a4b8; letter-spacing: 1.5px; }

.login-aside h1 {
  font-size: 34px;
  line-height: 1.35;
  margin: 0 0 18px;
  font-weight: 650;
  letter-spacing: -.5px;
}

.login-desc {
  color: #a9b8c9;
  max-width: 460px;
  margin: 0 0 36px;
  font-size: 14.5px;
}

.login-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
  max-width: 460px;
}

.login-points li {
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  display: grid;
  gap: 2px;
}

.login-points b { font-size: 13.5px; color: #f1f5f9; font-weight: 600; }
.login-points span { font-size: 12.5px; color: #93a4b8; }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 30px;
  box-shadow: var(--shadow);
}

.login-card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.3px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 13.5px; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfcfd;
  transition: border-color .15s, box-shadow .15s;
  color: var(--ink);
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  margin-top: 6px;
  transition: background .15s, transform .05s;
}

.btn-primary:hover { background: #0d6a63; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  border: 1px solid #f7c9c9;
}

.login-switch {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  padding: 0 2px;
}

.link-btn:hover { text-decoration: underline; }

/* ============================ 主布局 ============================ */
.app {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------------------------- 侧栏 ---------------------------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #dbe4ef;
  min-height: 0;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 12px;
}

.sidebar-brand { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand strong { font-size: 15px; color: #f1f5f9; letter-spacing: .4px; }
.sidebar-brand span { font-size: 11px; color: #7d8fa5; letter-spacing: 1px; }

.new-chat {
  margin: 8px 14px 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05);
  color: #e8eef7;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}

.new-chat:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .2); }
.new-chat .plus { font-size: 16px; line-height: 1; color: var(--brand-2); }

.conv-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 10px 10px; }
.conv-scroll::-webkit-scrollbar { width: 6px; }
.conv-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 6px; }

.conv-label {
  padding: 8px 10px 6px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #6d8096;
  text-transform: uppercase;
}

.conv-list { display: grid; gap: 2px; min-width: 0; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  color: #c3cede;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.conv-item:hover { background: rgba(255, 255, 255, .06); color: #eef4fb; }
.conv-item.active {
  background: rgba(20, 184, 166, .14);
  border-color: rgba(20, 184, 166, .25);
  color: #f1f5f9;
}

.conv-item .conv-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .conv-time { font-size: 10.5px; color: #6d8096; flex: none; }

.conv-item .conv-del {
  display: none;
  border: 0;
  background: none;
  color: #8ea3ba;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
}

.conv-item:hover .conv-del { display: block; }
.conv-item .conv-del:hover { background: rgba(239, 68, 68, .18); color: #fca5a5; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.user-chip { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong {
  font-size: 13px;
  color: #eef4fb;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta span { font-size: 11px; color: #7d8fa5; }

.icon-btn {
  border: 0;
  background: transparent;
  color: #8ea3ba;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
  flex: none;
}

.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #e8eef7; }

/* ---------------------------- 主区 ---------------------------- */
.main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(246, 247, 249, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.menu-btn { display: none; color: var(--ink-2); }

.title-block { min-width: 0; flex: 1; }
.title-block h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta { font-size: 11.5px; color: var(--muted); }

.how-link {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  text-decoration: none;
  white-space: nowrap;
}
.how-link:hover { color: var(--brand); border-color: var(--brand-2); background: var(--brand-soft); }

.kb-bar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.kb-chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  transition: all .15s;
}

.kb-chip.on {
  background: var(--brand-soft);
  border-color: #bfe3dc;
  color: var(--brand);
  font-weight: 600;
}

.tts-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 11.5px;
  color: var(--faint);
}

.tts-bar select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-family: inherit;
  max-width: 132px;
}

/* ---------------------------- 消息 ---------------------------- */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 24px 12px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #d8dee7; border-radius: 8px; }

.welcome {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px 0 60px;
}

.welcome-inner { max-width: 660px; text-align: center; }
.welcome-inner h2 { font-size: 22px; margin: 18px 0 6px; letter-spacing: -.3px; font-weight: 650; }
.welcome-inner > p { color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.suggestion {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.suggestion:hover {
  border-color: #c7ddd8;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.welcome-note { margin-top: 26px; font-size: 11.5px; color: var(--faint); }

.row {
  display: flex;
  gap: 10px;
  margin: 0 auto 22px;
  max-width: 820px;
  animation: rise .18s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.row.user { justify-content: flex-end; }

.row .avatar-bot {
  width: 30px;
  height: 30px;
  flex: none;
  margin-top: 2px;
}

.bubble {
  max-width: min(100%, 720px);
  border-radius: 14px;
  padding: 12px 15px;
  font-size: 14.2px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.row.user .bubble {
  background: var(--brand);
  color: #f0fdfa;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.row.bot .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3 { font-size: 14.6px; margin: 14px 0 6px; }
.bubble h4 { font-size: 14px; margin: 12px 0 5px; }
.bubble ul, .bubble ol { margin: 6px 0 10px; padding-left: 20px; }
.bubble li { margin: 3px 0; }
.bubble strong { font-weight: 650; color: #0b1524; }
.bubble code {
  background: #f1f4f8;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12.8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.bubble th, .bubble td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
}
.bubble th { background: #f7f9fb; font-weight: 600; }

.cite {
  border: 1px solid #bfe3dc;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 5px;
  margin: 0 1px;
  line-height: 17px;
  vertical-align: 1px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.cite:hover {
  background: #d3eee8;
  border-color: #7fc8bb;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .1);
}

.cite:active { transform: translateY(.5px); }

/* 生成中的状态 */
.stage {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  padding: 2px 0;
}

.stage .dots { display: inline-flex; gap: 3px; }
.stage .dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brand-2);
  animation: blink 1.2s infinite;
}
.stage .dots i:nth-child(2) { animation-delay: .2s; }
.stage .dots i:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 100% { opacity: .25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}

.cursor {
  display: inline-block;
  width: 6px;
  height: 15px;
  background: var(--brand-2);
  border-radius: 2px;
  vertical-align: -2px;
  animation: caret 1s steps(2) infinite;
  margin-left: 2px;
}

@keyframes caret { 50% { opacity: 0; } }

/* 引用区 */
.refs { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 11px; }

.refs-toggle {
  border: 1px solid #d9e7e3;
  background: #f4fbf9;
  border-radius: 999px;
  padding: 3px 11px;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.refs-toggle:hover { background: #e8f6f2; border-color: #bfe0d8; }

.refs-toggle .chev { color: var(--faint); font-weight: 400; }

.refs-body {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  /* 单列且允许收缩：否则长标题会把整张卡片顶出气泡 */
  grid-template-columns: minmax(0, 1fr);
}

.ref-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fbfcfd;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.ref-card.flash {
  border-color: var(--brand-2);
  background: #f2fbf9;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .14);
}

.ref-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }

.ref-num {
  width: 24px; height: 24px; flex: none;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 2px rgba(15, 118, 110, .28);
}

.ref-kind {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid #cfe9e4;
}
.ref-kind.web { background: #eef6ff; color: #1d4ed8; border-color: #d6e6fb; }
.ref-kind.summary { background: #fff7ed; color: #b45309; border-color: #fde3c4; }

.ref-spacer { flex: 1; min-width: 0; }

.ref-title {
  display: block;
  margin-top: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  /* 标题可能很长（文件名 + 副标题），允许换行，不要撑破卡片 */
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.ref-link:hover { color: var(--brand); }

.ref-source {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.ref-source-label {
  flex: none;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--muted);
  background: #eef2f7;
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
}
.ref-host { color: var(--brand); font-weight: 600; }
.ref-loc-inline { color: var(--muted); }

.ref-score { font-size: 10.5px; color: var(--faint); flex: none; }

.tool-trace {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
}

.tool-line {
  width: fit-content;
  max-width: 100%;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 8px;
}

.approval-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #92400e;
}

.approval-card span { flex: 1 1 100%; line-height: 1.55; white-space: pre-line; }

.approval-card button {
  border: 1px solid #f59e0b;
  background: #f59e0b;
  color: #fff;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
}

.approval-card button.ghost {
  background: #fff;
  color: #92400e;
  border-color: #fcd34d;
}

.approval-card button:disabled { opacity: .6; }

.exec-panel {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  overflow: hidden;
}

.exec-panel > summary {
  cursor: pointer;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--muted);
  background: #f6f8fa;
  user-select: none;
}

.exec-panel[open] > summary { border-bottom: 1px solid var(--line); }

.exec-body {
  max-height: 42vh;
  overflow-y: auto;
  padding: 6px 10px 8px;
  scroll-behavior: smooth;
}

.exec-body .tool-trace,
.exec-body .thinking { margin: 6px 0; }

.thinking {
  margin: 0 0 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 11.5px;
  color: var(--muted);
}

.thinking summary {
  cursor: pointer;
  padding: 4px 9px;
  color: var(--faint);
  user-select: none;
}

.thinking-body {
  padding: 0 10px 8px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.6;
}

.tool-detail {
  margin: -2px 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.tool-detail summary { cursor: pointer; color: var(--faint); }

.tool-detail pre {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

.tool-line.trace { background: transparent; color: var(--faint); padding-left: 0; }

.tool-line.ok { color: #0f766e; background: #ecfdf5; }
.tool-line.fail { color: #b91c1c; background: #fef2f2; }

.ref-link { color: var(--brand); text-decoration: none; }
.ref-link:hover { text-decoration: underline; }

.ref-tag {
  flex: none;
  font-size: 10px;
  line-height: 1.5;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 0 4px;
}

.ref-tag.web {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.ref-loc { font-size: 11px; color: var(--muted); margin: 3px 0 0 26px; overflow-wrap: anywhere; }
.ref-text {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 150px;
  overflow: hidden;
  position: relative;
}
.ref-card.open .ref-text { max-height: none; }
.ref-more {
  border: 0; background: none; color: var(--brand);
  font-size: 11.5px; padding: 4px 0 0; font-weight: 600;
}

.msg-link {
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 6px;
}
.msg-link:hover { color: var(--brand); background: var(--brand-soft); text-decoration: none; }

.msg-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--faint);
}

.msg-foot button {
  border: 0; background: none; color: var(--faint);
  font-size: 11px; padding: 0;
}
.msg-foot button:hover { color: var(--brand); }

.error-card {
  border: 1px solid #f5c2c0;
  background: var(--danger-soft);
  color: #8f1d14;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.error-card button {
  margin-left: auto;
  border: 1px solid #f0b4b0;
  background: #fff;
  color: #8f1d14;
  border-radius: 7px;
  font-size: 12px;
  padding: 3px 9px;
  flex: none;
}

/* ---------------------------- 输入区 ---------------------------- */
.approval-bar {
  max-width: 820px;
  margin: 0 auto 8px;
  background: #fffbeb;
  border: 1px solid #f3d9a4;
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: approval-in .16s ease-out;
}
.approval-bar.hidden { display: none; }
@keyframes approval-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.approval-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px 8px;
}
.approval-icon {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: #fde68a;
  color: #92400e;
  font-size: 13px;
  font-weight: 700;
}
.approval-copy { flex: 1; min-width: 0; }
.approval-title { font-size: 13px; font-weight: 600; color: #78350f; }
.approval-title .tool-chip {
  display: inline-block;
  margin-left: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  border: 1px solid #f3d9a4;
  border-radius: 6px;
  padding: 0 7px;
  color: #92400e;
}
.approval-reason {
  font-size: 12.5px;
  color: #92400e;
  margin-top: 3px;
  word-break: break-word;
}
.approval-args {
  font-size: 11.5px;
  color: #a16207;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255,255,255,.7);
  border-radius: 6px;
  padding: 3px 7px;
  word-break: break-word;
}
.approval-actions { display: flex; gap: 6px; flex: none; }
.approval-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.approval-actions button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.approval-actions button:hover:not(:disabled) { filter: brightness(.97); }
.approval-actions button:disabled { opacity: .55; cursor: default; }

.approval-progress {
  height: 3px;
  background: #f3d9a4;
  overflow: hidden;
}
.approval-progress span {
  display: block;
  height: 100%;
  background: #d97706;
  transition: width .9s linear;
}

.approval-bar.done { background: #f0fdf4; border-color: #bbf7d0; }
.approval-bar.done .approval-title { color: #166534; }
.approval-bar.done .approval-progress { display: none; }

@media (max-width: 720px) {
  .approval-main { flex-wrap: wrap; }
  .approval-actions { width: 100%; justify-content: flex-end; }
}

.composer {
  flex: none;
  padding: 10px 24px 16px;
  background: linear-gradient(180deg, rgba(246, 247, 249, 0), var(--bg) 30%);
}

.composer-box {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}

.composer-box:focus-within {
  border-color: #bcd9d3;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .08);
}

.composer textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  max-height: 168px;
  padding: 6px 0;
  color: var(--ink);
}

.composer textarea::placeholder { color: var(--faint); }

.send-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
  transition: background .15s, opacity .15s;
}

.send-btn:hover { background: #0d6a63; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn.stop { background: #334155; }

.composer-hint {
  max-width: 820px;
  margin: 7px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.composer-hint .dot { color: #d3d9e1; }

/* ---------------------------- 杂项 ---------------------------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 26, .45);
  z-index: 20;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f1f5f9;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  z-index: 60;
  box-shadow: var(--shadow);
}

/* ---------------------------- 响应式 ---------------------------- */
@media (max-width: 960px) {
  .login-view { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-panel { min-height: 100%; padding: 24px; }

  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .how-link { display: none; }
  .kb-bar { display: none; }
  .tts-bar span { display: none; }
  .tts-bar select { max-width: 92px; }
  .messages { padding: 18px 12px 8px; }
  .approval-bar {
  max-width: 820px;
  margin: 0 auto 8px;
  background: #fffbeb;
  border: 1px solid #f3d9a4;
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: approval-in .16s ease-out;
}
.approval-bar.hidden { display: none; }
@keyframes approval-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.approval-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px 8px;
}
.approval-icon {
  flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: #fde68a;
  color: #92400e;
  font-size: 13px;
  font-weight: 700;
}
.approval-copy { flex: 1; min-width: 0; }
.approval-title { font-size: 13px; font-weight: 600; color: #78350f; }
.approval-reason {
  font-size: 12.5px;
  color: #92400e;
  margin-top: 3px;
  word-break: break-word;
}
.approval-args {
  font-size: 11.5px;
  color: #a16207;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(255,255,255,.7);
  border-radius: 6px;
  padding: 3px 7px;
  word-break: break-word;
}
.approval-actions { display: flex; gap: 6px; flex: none; }
.approval-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.approval-actions button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.approval-actions button:hover:not(:disabled) { filter: brightness(.97); }
.approval-actions button:disabled { opacity: .55; cursor: default; }

.approval-progress {
  height: 3px;
  background: #f3d9a4;
  overflow: hidden;
}
.approval-progress span {
  display: block;
  height: 100%;
  background: #d97706;
  transition: width .9s linear;
}

.approval-bar.done { background: #f0fdf4; border-color: #bbf7d0; }
.approval-bar.done .approval-title { color: #166534; }
.approval-bar.done .approval-progress { display: none; }

@media (max-width: 720px) {
  .approval-main { flex-wrap: wrap; }
  .approval-actions { width: 100%; justify-content: flex-end; }
}

.composer { padding: 8px 12px 12px; }
  .bubble { font-size: 14px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { padding-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .messages { scroll-behavior: auto; }
}
