/* ============ 主题变量（浅色默认 + 深色 OLED 覆盖） ============ */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --surface-3: #e8eaef;
  --text: #1f2329;
  --text-2: #4e5969;
  --text-3: #8f959e;
  --border: #e5e6eb;
  --border-soft: #ececec;
  --primary: #1e6eff;
  --primary-hover: #0062e6;
  --primary-soft: #e8f0fe;
  --primary-soft-hover: #f5f9ff;
  --primary-text: #1a4ec9;
  --primary-disabled: #c5d3f5;
  --primary-shadow: rgba(30, 110, 255, 0.10);
  --brand: #1e3a8a;
  --ok: #2ba471;
  --err: #e53e3e;
  --mask: rgba(0, 0, 0, 0.40);
  --shadow-brand: 0 2px 8px rgba(37, 99, 235, 0.28);
  --shadow-brand-lg: 0 8px 24px rgba(37, 99, 235, 0.30);
  --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.18);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --toast-bg: #1f2329;
  --toast-text: #ffffff;
  --thumb-remove-bg: #333333;
  --watermark: #1f2329;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #1a1a1a;
  --surface-3: #2a2a2a;
  --text: #ffffff;
  --text-2: #a8a8a8;
  --text-3: #6e6e6e;
  --border: #2a2a2a;
  --border-soft: #1f1f1f;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: #0e1e3a;
  --primary-soft-hover: #14254a;
  --primary-text: #93c5fd;
  --primary-disabled: #1e3a5f;
  --primary-shadow: rgba(59, 130, 246, 0.20);
  --brand: #93c5fd;
  --ok: #4ade80;
  --err: #f87171;
  --mask: rgba(0, 0, 0, 0.65);
  --shadow-brand: 0 2px 8px rgba(59, 130, 246, 0.35);
  --shadow-brand-lg: 0 8px 24px rgba(59, 130, 246, 0.35);
  --shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.60);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.55);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
  --toast-bg: #ffffff;
  --toast-text: #000000;
  --thumb-remove-bg: #a8a8a8;
  --watermark: #ffffff;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============ 斜向水印 ============ */
.watermark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.watermark-inner {
  position: absolute;
  inset: -50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 80px 40px;
  transform: rotate(-22deg);
  opacity: 0.07;
}
.watermark-inner span {
  font-size: 18px;
  color: var(--watermark);
  white-space: nowrap;
  text-align: center;
  user-select: none;
}

/* ============ 顶部 header ============ */
.topbar {
  position: relative;
  z-index: 10;
  height: 52px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name {
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--brand);
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', 'Noto Sans SC', sans-serif;
  line-height: 1;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============ 主区域 ============ */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;   /* 动态视口：手机键盘弹起时自动缩小，输入框始终在可见区，避免整个页面被推上去；老浏览器回落 100vh */
}
.main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ============ Hero（启动态） ============ */
.hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow-y: auto;
  opacity: 0;            /* 默认未就绪隐藏，等 bootstrap 拿到完整内容后加 .ready 显示，避免启动三段跳变 */
  transition: opacity 0.25s;
}
.hero.ready { opacity: 1; }
.hero.hidden { opacity: 0; pointer-events: none; }

.hero-avatar {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  box-shadow: var(--shadow-brand-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.hero-avatar svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero-name {
  font-size: 1.4em;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.hero-greeting {
  max-width: 560px;
  text-align: center;
  color: var(--text-2);
  font-size: 1em;
  line-height: 1.7;
  margin-bottom: 28px;
  white-space: pre-wrap;
}

.examples {
  list-style: none;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.example-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
}
.example-item:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.example-item:active {
  transform: scale(0.99);
}
.example-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 4px;
  background: linear-gradient(135deg, #b8c5ff 0%, #8b9eff 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.example-text {
  flex: 1;
  color: var(--text);
  font-size: 1em;
  line-height: 1.5;
}
.example-arrow {
  color: var(--text-3);
  font-size: 1em;
  flex-shrink: 0;
}

/* ============ Chat（对话态） ============ */
.chat {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
.chat.active { display: flex; }

.chat-header {
  display: none; /* 顶栏已有「泰帮帮」图标+名称，对话态不再重复显示标题栏 */
}
.chat-header .mini-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E") center/16px no-repeat, linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  flex-shrink: 0;
}
.chat-header .mini-name {
  font-size: 1em;
  font-weight: 500;
  color: var(--text);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;   /* 兜底：禁止横向滚动条，内容在 .content 内自适应换行 */
  padding: 24px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.msg {
  margin-bottom: 22px;
  animation: fadein 0.3s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  display: flex;
  justify-content: flex-end;
}
.msg.user .bubble {
  background: var(--primary-soft);
  color: var(--primary-text);
  padding: 10px 14px;
  border-radius: 14px 14px 2px 14px;
  max-width: 78%;
  word-wrap: break-word;
  overflow-wrap: anywhere; /* 同 AI 回复，防止用户粘贴长串/表格撑宽 */
  font-size: 1em;
  box-shadow: var(--shadow-sm);
}
.msg.user .bubble .q-text { display: block; }
.msg.user .bubble .thumb {
  margin-top: 8px;
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}

.msg.ai {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg.ai .avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E") center/16px no-repeat, linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  flex-shrink: 0;
}
.msg.ai .content {
  flex: 1;
  min-width: 0;            /* 解除 flex 子项 min-width:auto 限制，允许收缩到 flex:1 宽度 */
  color: var(--text);
  font-size: 1em;
  padding: 12px 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere; /* 能在任意不可断串（表格分隔行 |---|、===== 等）处换行，避免撑宽溢出 */
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 4px 14px 14px 14px;
  box-shadow: var(--shadow-sm);
}
.msg.ai .content .cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--primary);
  vertical-align: middle;
  animation: blink 1s infinite;
  margin-left: 2px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.status-line {
  font-size: 0.75em;
  color: var(--text-3);
  padding: 2px 0 6px 40px;
  font-family: "Consolas", monospace;
}
.status-line.err { color: var(--err); }

/* 状态块：回答过程逐步展示进度（已建立连接/调用知识库…），完成后折叠，点击标题展开 */
.status-block { padding-left: 40px; margin: 2px 0 8px; font-family: "Consolas", monospace; font-size: 0.75em; }
.status-head { color: var(--text); cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.status-head::before { content: "▸"; color: var(--text-3); font-size: 14px; transition: transform .2s; }
.status-block:not(.collapsed) .status-head::before { transform: rotate(90deg); }
.status-list { margin-top: 3px; }
.status-list .status-line { padding: 1px 0; }
.status-list .status-line.ok { color: var(--ok); }
.status-block.collapsed .status-list { display: none; }
.status-line.ok { color: var(--ok); }

/* ============ 参考来源（AI 回答引用的知识库文档）============ */
.refs-box { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.refs-title { font-size: 0.75em; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.refs-list { display: flex; flex-direction: column; gap: 3px; }
.ref-item { font-size: 0.75em; color: var(--primary); text-decoration: none; line-height: 1.5; }
.ref-item:hover { text-decoration: underline; }
.ref-item.no-link { color: var(--text-3); cursor: default; }
.ref-item.no-link:hover { text-decoration: none; }

/* ============ 推荐问题（💡 猜你想问）============ */
.recm-box { margin-top: 14px; padding-top: 10px; }
.recm-title { font-size: 0.75em; color: var(--text-2); font-weight: 600; margin-bottom: 8px; }
.recm-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recm-item { font-family: inherit; font-size: 0.8em; color: var(--primary); background: var(--primary-soft, rgba(59,130,246,.08)); border: 1px solid var(--primary); border-radius: 16px; padding: 6px 14px; cursor: pointer; line-height: 1.4; transition: background .15s, color .15s; }
.recm-item:hover { background: var(--primary); color: #fff; }

/* ============ AI 回答 markdown 渲染（表格/列表/标题/粗体）============ */
.msg.ai .content { overflow-x: auto; }
/* marked 渲染后切 normal：marked 输出的 HTML 标签间含字面 \n，pre-wrap 下会变成可见空行
   （finishAiMessage 完成渲染时加 .rendered）；流式纯文本阶段仍用默认 pre-wrap 显示 \n 换行 */
.msg.ai .content.rendered { white-space: normal; }
.msg.ai .content table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 0.8em; }
.msg.ai .content th, .msg.ai .content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg.ai .content th { background: var(--surface-2, rgba(0,0,0,.04)); font-weight: 600; }
.msg.ai .content h1, .msg.ai .content h2, .msg.ai .content h3, .msg.ai .content h4 { font-size: 0.95em; font-weight: 700; margin: 12px 0 6px; line-height: 1.4; }
.msg.ai .content ul, .msg.ai .content ol { padding-left: 22px; margin: 6px 0; }
.msg.ai .content li { margin: 3px 0; line-height: 1.6; }
.msg.ai .content strong { font-weight: 700; }
.msg.ai .content code { background: var(--surface-2, rgba(0,0,0,.05)); padding: 1px 5px; border-radius: 3px; font-family: "Consolas", monospace; font-size: 0.75em; }
.msg.ai .content pre { background: var(--surface-2, rgba(0,0,0,.05)); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.msg.ai .content pre code { background: transparent; padding: 0; }
.msg.ai .content p { margin: 6px 0; line-height: 1.7; }
.msg.ai .content blockquote { border-left: 3px solid var(--border); padding-left: 12px; margin: 8px 0; color: var(--text-2); }

/* ============ 底部 composer ============ */
.composer-toolbar { display:flex; align-items:center; gap:6px; padding:0 6px 8px; max-width:820px; margin:0 auto; }
.mode-dropdown { position:relative; }
.mode-btn { display:inline-flex; align-items:center; gap:4px; padding:5px 10px 5px 8px; background:transparent; border:none; border-radius:12px; font-size:0.9em; color:var(--text); cursor:pointer; font-family:inherit; transition:background .15s,color .15s; }
.mode-btn:hover { background:var(--surface-2); }
.mode-btn .caret { opacity:0.5; margin-left:3px; flex-shrink:0; }
.mode-menu { position:absolute; bottom:calc(100% + 6px); left:0; min-width:220px; background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:0 8px 24px rgba(0,0,0,0.12); padding:6px; z-index:30; }
.mode-option { display:flex; flex-direction:column; padding:8px 12px; border-radius:10px; cursor:pointer; transition:background .12s; }
.mode-option:hover { background:var(--surface-2); }
.mode-option.active { background:rgba(0,102,255,0.06); }
.mode-option.active b { color:rgb(0,102,255); }
.mode-option b { font-size:0.9em; font-weight:400; color:var(--text); }
.mode-option span { font-size:0.78em; color:var(--text-3); margin-top:2px; }
.chip-btn { padding:5px 12px; background:transparent; border:none; border-radius:12px; font-size:0.9em; font-weight:400; color:var(--text-2); cursor:pointer; font-family:inherit; transition:background .15s,color .15s; }
.chip-btn:hover { background:var(--surface-2); }
.chip-btn.active { background:rgba(0,102,255,0.06); color:rgb(0,102,255); cursor:default; }

/* ===== 思考状态指示器 + 思考面板 ===== */
.thought-wrapper {
  max-width: 820px;
  margin: 12px auto 4px;
  padding: 0 24px;
}
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 14px;
}
.thinking-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  flex-shrink: 0;
}
.thinking-wave span {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 3px;
  background: var(--primary, #3b82f6);
  animation: thinking-wave 2s ease-in-out infinite;
}
.thinking-wave span:nth-child(1) { animation-delay: 0s; }
.thinking-wave span:nth-child(2) { animation-delay: 0.25s; }
.thinking-wave span:nth-child(3) { animation-delay: 0.5s; }
@keyframes thinking-wave {
  0%, 100% { height: 8px; opacity: 0.3; }
  50% { height: 28px; opacity: 1; }
}
.thinking-body { display: flex; align-items: center; }
.thinking-text {
  font-size: 0.9em;
  color: var(--text-2);
  transition: opacity .3s;
}

/* 思考面板（折叠展开） */
.thought-panel {
  margin-top: 8px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.thought-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.82em;
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.thought-panel-head:hover { background: var(--surface-3); }
.thought-panel-icon { font-size: 14px; }
.thought-panel-title { font-weight: 500; }
.thought-panel-toggle {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  opacity: 0.6;
}
.thought-panel-body {
  padding: 6px 14px 12px;
  font-size: 0.82em;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
}
.thought-agent-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #3b82f6);
  margin: 8px 0 4px;
}
.thought-tool {
  display: inline-block;
  padding: 2px 8px;
  margin: 4px 4px 0 0;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 6px;
}

.composer-area {
  flex-shrink: 0;
  padding: 12px 24px 12px;
  background: transparent;
}
.composer-box {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow);
}

.composer-thumb {
  position: relative;
  margin-right: 4px;
}
.composer-thumb img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.composer-thumb .remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--thumb-remove-bg);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.upload-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.upload-btn:hover { background: var(--surface-2); color: var(--text); }
.upload-btn svg { width: 20px; height: 20px; }

textarea#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 1em;
  line-height: 1.6;
  max-height: 120px;
  padding: 7px 4px;
  background: transparent;
  color: var(--text);
}
textarea#input::placeholder { color: var(--text-3); }

.send-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.send-btn:hover:not(:disabled) { background: var(--primary-hover); }
.send-btn:disabled { background: var(--primary-disabled); cursor: not-allowed; }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn svg { width: 18px; height: 18px; }

.composer-footer {
  max-width: 820px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}
.composer-footer a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
.composer-footer a:hover { text-decoration: underline; }

/* ============ 响应式适配 ============ */
/* 平板 (768-1024px)：紧凑间距 */
@media (max-width: 1024px) {
  .topbar { padding: 0 16px; height: 48px; }
  .brand-name { font-size: 1.05em; }
  .brand-mark { width: 27px; height: 27px; }
  .composer-area { padding: 10px 16px 10px; }
  .messages { padding: 20px 18px; }
}

/* 手机 (≤767px)：单列紧凑布局 */
@media (max-width: 767px) {
  body { font-size: var(--fs); }
  .topbar { padding: 0 12px; height: 44px; }
  .brand-name { font-size: 1em; letter-spacing: 1.5px; }
  .brand-mark { width: 26px; height: 26px; border-radius: 7px; }
  .brand-mark svg { width: 16px; height: 16px; }

  /* hero：紧凑 */
  .hero { padding: 16px; }
  .hero-avatar { width: 60px; height: 60px; margin-bottom: 14px; }
  .hero-avatar svg { width: 32px; height: 32px; }
  .hero-name { font-size: 1.25em; margin-bottom: 8px; }
  .hero-greeting { font-size: 1em; line-height: 1.65; margin-bottom: 20px; }
  .examples { gap: 8px; }
  .example-item { padding: 10px 12px; gap: 10px; }
  .example-text { font-size: 1em; line-height: 1.45; }
  .example-icon { width: 20px; height: 20px; font-size: 11px; }

  /* chat 态：紧凑 */
  .chat-header { padding: 10px 14px; }
  .chat-header .mini-avatar { width: 26px; height: 26px; }
  .chat-header .mini-name { font-size: 1em; }
  .messages { padding: 14px 12px; }
  .msg.user .bubble { font-size: 1em; padding: 8px 12px; max-width: 85%; }
  .msg.ai .avatar { width: 26px; height: 26px; }
  .msg.ai .content { font-size: 1em; }
  .status-line { padding-left: 36px; font-size: 0.7em; }

  /* composer：紧凑 */
  .composer-area { padding: 8px 10px 8px; }
  .composer-box { border-radius: 14px; padding: 6px 6px 6px 10px; }
  textarea#input { font-size: 1em; max-height: 100px; }
  .composer-footer { font-size: 0.7em; margin-top: 6px; padding: 0 4px; }

  /* 水印：字号小一点，密度稀一点，避免在小屏太挤 */
  .watermark-inner { gap: 60px 24px; }
  .watermark-inner span { font-size: 1em; }
}

/* 极窄屏 (≤360px)：进一步压缩 */
@media (max-width: 360px) {
  .hero-name { font-size: 1em; }
  .example-text { font-size: 12px; }
  .messages { padding: 10px 8px; }
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 999;
}
.toast.show { opacity: 1; }

/* ============ 顶部 pill（角色栏 / 主题按钮通用） ============ */
.role-pill {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); font-size: 13px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.role-pill:hover { border-color: var(--primary); background: var(--primary-soft-hover); }
.role-pill-icon { font-size: 1em; }
.role-pill-arrow { color: var(--text-3); font-size: 11px; margin-left: 2px; }

/* ============ 设置面板（主题/字号分段控件 + 角色入口） ============ */
.theme-switcher { position: relative; }
.theme-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  padding: 14px;
  min-width: 264px;
  z-index: 1001;
}
.theme-menu.show { display: block; }
.set-section { margin-bottom: 14px; }
.set-section:last-child { margin-bottom: 0; }
.set-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
  font-weight: 500;
}
.theme-segments {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.theme-seg {
  flex: 1;
  padding: 7px 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  white-space: nowrap;
  font-family: inherit;
}
.theme-seg:hover { color: var(--text); }
.theme-seg.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.set-role-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.set-role-btn:hover { border-color: var(--primary); background: var(--primary-soft-hover); }
.set-role-cur { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-role-arrow { color: var(--primary); font-size: 12px; margin-left: 8px; flex-shrink: 0; }

/* ============ 字号（只调文字大小，布局/输入框位置不变，三档） ============ */
:root { --fs: 16px; }
:root[data-fontsize="small"] { --fs: 13px; }
:root[data-fontsize="large"] { --fs: 22px; }

/* ============ 角色选择弹层 ============ */
.role-modal { position: fixed; inset: 0; z-index: 1000; display: none; }
.role-modal.show { display: block; }
.role-modal-mask { position: absolute; inset: 0; background: var(--mask); }
.role-modal-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow-modal);
}
.role-modal-title { font-size: 1em; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.role-sec { margin-bottom: 14px; }
.role-sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.role-sec-name { font-size: 1em; color: var(--text); font-weight: 500; }
.role-sec-toggle { font-size: 12px; color: var(--primary); background: none; border: none; cursor: pointer; padding: 2px 4px; }
.role-sec-toggle:hover { text-decoration: underline; }
.role-checks { display: flex; flex-wrap: wrap; gap: 6px 8px; max-height: 124px; overflow-y: auto; padding: 2px; }
.role-check { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 14px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; transition: all 0.15s; }
.role-check:hover { border-color: var(--primary); }
.role-check input { margin: 0; accent-color: var(--primary); }
.role-check:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.role-modal-hint { font-size: 12px; color: var(--text-3); line-height: 1.5; margin: 4px 0 18px; }
.role-modal-btns { display: flex; justify-content: flex-end; gap: 10px; }
.role-btn { height: 34px; padding: 0 18px; border-radius: 8px; font-size: 1em; cursor: pointer; border: none; }
.role-btn-cancel { background: var(--surface-2); color: var(--text-2); }
.role-btn-ok { background: var(--primary); color: #fff; }
.role-btn-ok:hover { background: var(--primary-hover); }

/* 调试日志面板（🪵 按钮触发）*/
.log-panel { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(.96);
  width: min(92vw, 640px); max-height: 80vh; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); z-index: 1000; font-size: 0.82em; }
.log-panel.show { display: flex; transform: translate(-50%, -50%) scale(1); }
.log-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); }
.log-head-btns button { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; cursor: pointer; color: var(--text-2); font-size: .95em; margin-left: 4px; }
.log-head-btns button:hover { border-color: var(--primary); color: var(--primary); }
.log-body { overflow-y: auto; padding: 8px 14px; }
.log-row { padding: 6px 0; border-bottom: 1px dashed var(--border-soft); white-space: pre-wrap; word-break: break-word; color: var(--text-2); line-height: 1.6; }
.log-row.warn { color: #DC2626; background: rgba(220,38,38,.05); padding: 8px; border-radius: 6px; }
.log-empty { padding: 24px; text-align: center; color: var(--text-3); }
