/* 手机端适配层：单独文件，出问题整段删掉即可回退。见 static/css/mobile.css */
@import url("/css/mobile.css");

/* ==========================================================================
   AI Hub 样式表
   关键设计决策：
   1. 一套 CSS 变量同时驱动浅色/深色主题（跟随系统），改色只改 :root。
   2. 移动端优先的响应式：<=860px 时侧栏变成抽屉，顶部导航收起为图标按钮。
   3. 无第三方 CSS 框架，体积小（<20KB），2G 服务器上首屏几乎瞬间完成。
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-soft: #f0f2f5;
  --text: #101828;
  --text-soft: #667085;
  --border: #e4e7ec;
  --brand: #0d9488;
  --brand-soft: #ccfbf1;
  --brand-strong: #0f766e;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-elev: #171a21;
    --bg-soft: #1e222b;
    --text: #e8eaed;
    --text-soft: #98a2b3;
    --border: #2a2f39;
    --brand: #14b8a6;
    --brand-soft: #123c39;
    --brand-strong: #2dd4bf;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--text-soft); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); }

/* ============================ 布局 ============================ */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  /* flex-wrap 是兜底：窄桌面（861~1100px）下顶栏那排按钮本来会溢出、
     右边几个被裁掉点不到。先靠下面的媒体查询收紧，真不够就允许换行，
     总之不能"右边按钮消失"。（手机端另有 overflow-x 滚动方案，见 mobile.css） */
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand-logo {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-size: 15px;
}
.brand-name { font-size: 16px; }

.topnav { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-link, .nav-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.nav-link:hover, .nav-btn:hover { background: var(--bg-soft); text-decoration: none; }
.nav-btn.primary { background: var(--brand); color: #fff; border-color: transparent; }

.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.layout { flex: 1; display: flex; min-height: 0; }

/* 窄桌面的兜底：861~1100px 这段宽度下，顶栏那排按钮本来会挤到溢出
   （右边几个被裁掉、点不到 —— 实测 861px 时溢出约 38px）。
   收紧药丸按钮的左右内边距与间距，让它仍是一行且完整显示。 */
@media (min-width: 861px) and (max-width: 1100px) {
  .topbar { gap: 8px; padding: 9px 12px; }
  .topnav { gap: 6px; }
  .nav-link, .nav-btn { padding: 6px 9px; font-size: 13px; }
  .user-chip { padding: 5px 9px; font-size: 12.5px; }
}

/* ============================ 侧边栏 ============================ */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.side-block { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-title {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-soft);
  margin-bottom: 8px;
  display: flex; justify-content: space-between;
}
.conv-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; }
.conv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  border: 1px solid transparent;
}
.conv-item:hover { background: var(--bg-soft); }
.conv-item.active { background: var(--brand-soft); border-color: var(--brand); font-weight: 600; }
.conv-item span.title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .del { opacity: 0; font-size: 14px; color: var(--text-soft); padding: 0 2px; }
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: var(--danger); }

.side-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-soft); font-weight: 600; margin-top: 4px; }

.select, .input, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}
.select:focus, .input:focus, .textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.textarea { font-family: var(--mono); font-size: 12.5px; min-height: 90px; resize: vertical; }

.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); cursor: pointer; user-select: none; }
.switch input { accent-color: var(--brand); width: 16px; height: 16px; }

/* ============================ 对话区 ============================ */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 22px 16px 8px; scroll-behavior: smooth; }
.messages .inner { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.welcome { text-align: center; padding: 48px 16px; color: var(--text-soft); }
.welcome h1 { font-size: 24px; color: var(--text); margin-bottom: 6px; }
.welcome .chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-elev);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

.msg { display: flex; gap: 10px; flex-wrap: wrap; }
.msg .avatar {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px; font-weight: 700; color: #fff;
}
.msg.user .avatar { background: #6366f1; }
.msg.assistant .avatar { background: linear-gradient(135deg, var(--brand), var(--brand-strong)); }
.msg .bubble {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg.user .bubble { background: var(--brand-soft); border-color: transparent; color: var(--text); }
.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble pre {
  background: var(--bg-soft); padding: 10px 12px; border-radius: 8px;
  overflow-x: auto; font-family: var(--mono); font-size: 12.5px; margin: 8px 0;
}
.msg .bubble code { font-family: var(--mono); font-size: 12.8px; background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; }
.msg .bubble pre code { background: none; padding: 0; }
.msg .bubble table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.msg .bubble th, .msg .bubble td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.msg .meta { font-size: 11.5px; color: var(--text-soft); margin-top: 6px; }

.typing::after {
  content: "▍"; animation: blink 1s steps(2, start) infinite; color: var(--brand);
}
@keyframes blink { to { visibility: hidden; } }

/* 工具调用卡片 */
.tool-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  margin: 8px 0;
  font-size: 13px;
  overflow: hidden;
}
.tool-card.ok { border-left-color: var(--ok); }
.tool-card.err { border-left-color: var(--danger); }
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; cursor: pointer; user-select: none;
  background: var(--bg-soft);
}
.tool-head .kind {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 6px; border-radius: 5px; background: var(--warn); color: #fff;
}
.tool-card.ok .kind { background: var(--ok); }
.tool-card.err .kind { background: var(--danger); }
.tool-head .name { font-family: var(--mono); font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-body { padding: 9px 11px; display: none; border-top: 1px dashed var(--border); }
.tool-card.open .tool-body { display: block; }
.tool-body h5 { margin: 6px 0 4px; font-size: 11.5px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.tool-body pre {
  margin: 0; background: var(--bg-soft); padding: 8px 10px; border-radius: 7px;
  max-height: 320px; overflow: auto; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
}

/* ============================ 输入区 ============================ */
.composer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}
.composer .box, .composer textarea {
  max-width: 820px; margin: 0 auto;
}
.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  line-height: 1.5;
}
.composer textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.composer-bar { max-width: 820px; margin: 8px auto 0; display: flex; align-items: center; gap: 8px; }

/* ============================ 按钮 ============================ */
.btn-primary, .btn-danger, .ghost-btn, .icon-btn, .mini-btn {
  font-family: inherit; cursor: pointer; border-radius: var(--radius-sm);
  transition: filter .15s, background .15s;
}
.btn-primary {
  background: var(--brand); color: #fff; border: none;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; padding: 11px; }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 9px 16px; font-size: 14px; font-weight: 600; }
.ghost-btn {
  background: transparent; color: var(--text-soft); border: 1px solid var(--border);
  padding: 7px 12px; font-size: 13px;
}
.ghost-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn {
  background: transparent; border: none; color: var(--text-soft);
  font-size: 17px; padding: 4px 8px; line-height: 1;
}
.icon-btn:hover { color: var(--text); }
.mini-btn {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  font-size: 12.5px; padding: 5px 10px;
}
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ============================ 设置面板 / 弹窗 ============================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 10, 14, .5);
  display: grid; place-items: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-panel {
  background: var(--bg-elev);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(940px, 100%);
  max-height: 92dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-panel.narrow { width: min(520px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tab {
  border: none; background: transparent; color: var(--text-soft);
  padding: 7px 13px; font-size: 13.5px; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.tab:hover { background: var(--bg-soft); color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }

/* ============================ 卡片 / 列表 ============================ */
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; background: var(--bg-elev);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head h4 { margin: 0; font-size: 15px; flex: 1; }
.card .row { display: flex; gap: 10px; flex-wrap: wrap; }
.card .row > * { flex: 1; min-width: 160px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-soft); font-weight: 600;
}
.badge.ok { background: rgba(22,163,74,.14); color: var(--ok); }
.badge.warn { background: rgba(217,119,6,.15); color: var(--warn); }
.badge.err { background: rgba(220,38,38,.14); color: var(--danger); }

.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-soft);
  margin: 18px 0 10px;
}
.section-title:first-child { margin-top: 0; }
.section-title .line { flex: 1; height: 1px; background: var(--border); }

.tool-list { display: flex; flex-direction: column; gap: 6px; }
.tool-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--bg);
}
.tool-row .tname { font-family: var(--mono); font-weight: 600; }
.tool-row .tdesc { color: var(--text-soft); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.env-hint { font-size: 12px; color: var(--text-soft); margin-top: 6px; }
.hint-box {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12.8px; color: var(--text-soft); margin-bottom: 12px;
}
.hint-box code { font-family: var(--mono); background: var(--bg-elev); padding: 1px 5px; border-radius: 5px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; background: var(--bg);
}
.stat .num { font-size: 22px; font-weight: 700; color: var(--brand-strong); }
.stat .lbl { font-size: 12px; color: var(--text-soft); }

/* ============================ Toast ============================ */
.toast-wrap {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; max-width: 90vw;
}
.toast {
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: slide-in .18s ease-out;
  max-width: 380px; overflow-wrap: anywhere;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } }

/* ============================ 登录页 ============================ */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: min(420px, 100%);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 9px; }
.auth-card .sub { color: var(--text-soft); font-size: 13.5px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 13px; }
.auth-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
.auth-foot { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; font-size: 13px; }
.err-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* 验证码输入行：输入框占满剩余宽度，"获取验证码"按钮不被挤压换行 */
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row .input { flex: 1 1 auto; min-width: 0; }
.code-row .code-btn { flex: 0 0 auto; white-space: nowrap; padding: 0 14px; }

/* ============================ 帮助页 ============================ */
.help-layout { display: flex; min-height: 100dvh; }
.help-nav {
  width: 270px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--bg-elev); padding: 18px 14px; overflow-y: auto;
  position: sticky; top: 0; height: 100dvh;
}
.help-nav a.doc-link {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; margin-bottom: 2px;
}
.help-nav a.doc-link:hover { background: var(--bg-soft); text-decoration: none; }
.help-nav a.doc-link.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.help-content { flex: 1; min-width: 0; padding: 30px 34px 80px; }
.help-content .doc { max-width: 800px; margin: 0 auto; }
.help-content h1 { font-size: 26px; margin-top: 0; }
.help-content h2 { font-size: 20px; margin-top: 32px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.help-content h3 { font-size: 16.5px; margin-top: 24px; }
.help-content pre {
  background: var(--bg-soft); padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; font-family: var(--mono); font-size: 12.8px; line-height: 1.55;
}
.help-content code { font-family: var(--mono); font-size: 12.8px; background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; }
.help-content pre code { background: none; padding: 0; }
.help-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; }
.help-content th, .help-content td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; }
.help-content th { background: var(--bg-soft); }
.help-content blockquote {
  margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--brand);
  background: var(--bg-soft); border-radius: 0 8px 8px 0; color: var(--text-soft);
}
.help-content img { max-width: 100%; border-radius: 8px; }

/* ============================ 响应式 ============================ */
.only-mobile { display: none; }

@media (max-width: 860px) {
  .only-mobile { display: inline-block; }
  .brand-name { font-size: 15px; }
  .topnav .nav-btn { padding: 6px 10px; font-size: 12.5px; }
  .topnav .nav-link { padding: 6px 10px; font-size: 12.5px; }
  .user-chip { padding: 5px 10px; font-size: 12px; }
  .user-chip span { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .sidebar {
    position: fixed; z-index: 40; top: var(--topbar-h, 51px); bottom: 0; left: 0;
    width: min(84vw, 320px);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 会话区永远留出足够高度。
     坑：抽屉是 flex column，.side-block 原本 flex:1 + min-height:0 —— 一旦
     下面的服务区（svc-grid + 两个下拉 + 开关 + 链接）占了大部分高度，
     它就、能被挤到 0：结果是“会话记录看不见、也没东西可滚”（整块刚好占满抽屉）。
     给个 vh 兼底：就算顶栏高估了，列表也会把抽屉撑出滚动条，不会消失。 */
  .side-block { flex: 1 1 auto; min-height: 220px; min-height: max(220px, 46vh); }
  .conv-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .side-footer { flex: 0 0 auto; }
  .sidebar.open { transform: translateX(0); }
  .messages { padding: 16px 12px 8px; }
  .composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .modal { padding: 0; }
  .modal-panel { border-radius: 14px 14px 0 0; max-height: 94dvh; width: 100%; align-self: end; }
  .modal { align-items: end; }

  .help-nav {
    position: static; width: 100%; height: auto; border-right: none;
    border-bottom: 1px solid var(--border); max-height: 38dvh;
  }
  .help-layout { flex-direction: column; }
  .help-content { padding: 20px 16px 60px; }
}


/* ================= 高风险工具确认卡片 / 被挡工具卡片 =================
   会话里 AI 提出"下单/支付"这类调用时展示：参数摊开给你看，点同意才执行。 */
.approval-card { border-color: var(--warn); background: rgba(217, 119, 6, .07); }
.approval-card .tool-head { display: flex; align-items: center; gap: 8px; }
.approval-card .tool-name { color: var(--warn); font-weight: 700; }
.approval-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.approval-tool { font-size: 13px; font-weight: 600; }
.approval-args {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 4px 0 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.approval-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.approval-actions .btn-primary, .approval-actions .ghost-btn { padding: 8px 16px; font-size: 13px; }

.dropped-card { border-color: var(--border); background: var(--bg-soft); }
.dropped-card summary { cursor: pointer; font-size: 12px; color: var(--text-soft); }
.dropped-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.dropped-row { font-size: 12px; line-height: 1.5; }


/* ==================== 深度思考：思考过程折叠块 ==================== */
.reasoning-card { border-color: var(--border); background: var(--bg-soft); }
.reasoning-card summary { cursor: pointer; font-size: 12px; color: var(--text-soft); }
.reasoning-text {
  margin: 8px 0 0;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-soft);
}

/* ==================== 附件（图片 / 文本 / 文档） ==================== */
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 0; }
.attach-chips.hidden { display: none; }
.attach-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-soft); font-size: 12px; max-width: 100%;
}
.attach-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.attach-del { border: none; background: none; cursor: pointer; color: var(--text-soft); font-size: 15px; line-height: 1; }
.attach-del:hover { color: var(--danger); }
.composer.dragging { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: 12px; }
.msg-image { display: block; max-width: 240px; max-height: 240px; border-radius: 10px; margin-bottom: 6px; }
.msg-text { white-space: pre-wrap; }

/* ==================== 会话里的支付卡片（二维码 / 深链） ==================== */
.pay-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 10px 0 4px; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft);
}
.pay-card-title { font-weight: 700; font-size: 13px; }
.pay-card .pay-deeplink { display: inline-block; padding: 9px 16px; border-radius: 10px; text-decoration: none; }
.pay-card .qr-holder { display: flex; align-items: center; justify-content: center; min-height: 40px; }
.pay-card .qr-canvas { width: 200px; height: 200px; image-rendering: pixelated; }
@media (max-width: 480px) {
  .pay-card .qr-canvas { width: 170px; height: 170px; }
}

/* ==================== 页脚（备案信息） ==================== */
.site-footer {
  flex: 0 0 auto;
  padding: 7px 12px;
  text-align: center;
  /* 13.5px：比原来（12.5）大一档。原因见下面 .beian-* 注释 ——
     ICP 各号里带了拉丁字母（ICP），同等字号下拉丁字母天然比中文矮一截，
     整体调大一档后两条观感才真的一致。 */
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--text-soft); }
.site-footer a:hover { color: var(--brand); }

/* 备案条目：公安（徽标 + 编号）与 ICP 并排，中间用间距隔开。
   格式要求是"图标在前、编号在右"，所以用 inline-flex 把两者垂直居中对齐；
   white-space:nowrap 保证编号不会在中间折行（折了就不像局里要求的样式了）。

   关于"两条看起来不一样大"：实测两条的 font-size 完全相同，差异来自
   ①ICP 各号里的拉丁字母（ICP）在同等字号下天然比中文矮一截；
   ②公安那条旁边有个徽标，行高更高、显得更突出。
   所以这里把整个页脚调大一档，并让徽标与文字保持比例，两条就齐了。 */
.site-footer .beian-gongan,
.site-footer .beian-icp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 7px;
  /* 显式写死同一个字号：不依赖继承，以后谁改了父级也不会把两条弄成不一样大 */
  font-size: 13.5px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.site-footer .beian-gongan img {
  display: block;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

/* 窄屏：页脚也相应小一档，但两条仍然严格同号 */
@media (max-width: 640px) {
  .site-footer { font-size: 12.5px; padding: 6px 10px; }
  .site-footer .beian-gongan,
  .site-footer .beian-icp { font-size: 12.5px; margin: 0 5px; }
  .site-footer .beian-gongan img { width: 15px; height: 15px; }
}

/* ==================== 新版本提示条（更新后无需强刷） ==================== */
#http-notice,
#update-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 9999; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--brand, #0f766e); color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
#http-notice button,
#update-bar button {
  border: none; border-radius: 8px; padding: 5px 10px; cursor: pointer;
  font-size: 12px; font-weight: 600;
}
#http-notice .update-now,
#update-bar .update-now { background: #fff; color: var(--brand, #0f766e); }
#http-notice .update-later,
#update-bar .update-later { background: rgba(255, 255, 255, 0.18); color: #fff; }
@media (max-width: 480px) {
  #update-bar { left: 12px; right: 12px; bottom: 12px; transform: none; font-size: 12px; }
}

/* ==================== 交互卡片（定时任务 / 执行模式 / 取消确认） ====================
   这些卡片的字段与选项都来自后端 tool spec，前端只负责画 ——
   所以样式要通用，不能针对某个具体业务写死。 */
.interactive-card { max-width: 520px; }
.interactive-card .tool-head { align-items: center; }
.interactive-body { display: flex; flex-direction: column; gap: 10px; padding: 8px 2px; }
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-row > label { font-size: 12px; color: var(--text-soft); }
.field-row input, .field-row textarea, .field-row select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); color: var(--text); font-size: 14px; font-family: inherit;
}
.field-row textarea { resize: vertical; }
.choice-row {
  display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-soft); cursor: pointer;
}
.choice-row:hover:not(:disabled) { border-color: var(--accent); }
.choice-row:disabled { opacity: .55; cursor: default; }
.choice-row.danger { border-color: rgba(220, 38, 38, .45); }
.choice-row.danger .choice-label { color: var(--danger); }
.choice-label { font-weight: 600; font-size: 14px; }
.choice-desc { font-size: 12px; color: var(--text-soft); line-height: 1.5; }
.confirm-line { font-size: 14px; padding: 2px 0; }
.interactive-actions { display: flex; gap: 8px; padding-top: 8px; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-soft);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-soft); }

/* 体验模式提示条：必须一眼看到（用户要清楚"这里的东西都是假的"） */
.demo-banner {
  background: linear-gradient(90deg, #7c3aed22, #06b6d422);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 14px;
  text-align: center;
}
.demo-banner b { color: #7c3aed; }
/* 体验模式提示条里的【退出体验模式】按钮：要显眼、要一眼能找到 */
.demo-exit {
  margin-left: 10px;
  padding: 4px 12px;
  border: 1px solid #7c3aed;
  border-radius: 999px;
  background: #7c3aed;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.demo-exit:hover { background: #6d28d9; }

/* 联网模式开着的时候，顶部按钮要有明显状态（不然用户不知道开没开） */
.nav-btn.on {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

/* ==================== 通知中心（顶部 🔔 展开的面板） ==================== */
.nc-panel {
  position: fixed; right: 14px; top: 56px; z-index: 60;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100vh - 90px); overflow: auto;
  background: var(--bg, #fff); color: var(--text, #111);
  border: 1px solid var(--border, #ddd); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 14px;
}
.nc-head { display: flex; justify-content: space-between; align-items: center; }
.nc-head h4 { margin: 0; }
.nc-sec { border-top: 1px solid var(--border, #eee); margin-top: 10px; padding-top: 10px; }
.nc-title { font-weight: 600; margin-bottom: 6px; }
.nc-steps { margin: 6px 0 6px 18px; padding: 0; font-size: 13px; line-height: 1.7; }
.nc-hook {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  border: 1px solid var(--border, #eee); border-radius: 8px; padding: 6px 8px; margin: 6px 0;
  font-size: 13px;
}
.nc-panel .row { display: flex; gap: 6px; margin-top: 8px; }
.nc-panel .input, .nc-panel .select { flex: 1; min-width: 0; }

/* ===================== 启动失败时的友好提示（app.js showBootError） =====================
   为什么要有它：以前初始化失败是**默默 return**，页面只剩一个毫无反应的空壳。
   现在至少把原因和"重新连接"按钮摆在对话区正中央。 */
/* ===================== 发信记录表（管理后台） =====================
   后台原本没有表格样式，这里单独补一小段：小字、紧凑、窄屏可横向滑动。 */
.mail-log-wrap { overflow-x: auto; margin-top: 8px; }
.mail-log { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.mail-log th, .mail-log td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border, #e5e7eb);
  white-space: nowrap;
}
.mail-log th { color: var(--text-soft, #888); font-size: 12px; font-weight: 600; }
.mail-log td.mail-log-email { font-family: ui-monospace, Consolas, monospace; }
.mail-log .st-sent { color: var(--ok, #0f9d76); }
.mail-log .st-failed { color: var(--danger, #d64545); }
.mail-log .st-rejected { color: var(--warn, #c07d00); }

.boot-error {
  max-width: 520px; margin: 8vh auto 0; padding: 24px;
  background: var(--bg-elev, #fff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px; box-shadow: var(--shadow, 0 6px 24px rgba(0, 0, 0, .06));
  text-align: center; line-height: 1.75;
}
.boot-error-icon { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.boot-error h3 { margin: 6px 0 10px; font-size: 17px; }
.boot-error p { margin: 8px 0; font-size: 13.5px; color: var(--text-soft, #666); }
.boot-error code, .boot-error .muted { word-break: break-all; }
.boot-error .btn-primary { margin-top: 14px; }

/* ================= 车次卡片（铁路 / 行程规划结果） ================= */
.train-card {
  margin-top: 10px; border-radius: var(--radius, 12px);
  border: 1px solid var(--border, rgba(0,0,0,.08));
  background: var(--bg-elev, #fff);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(16,24,40,.08));
  overflow: hidden; padding: 0 0 10px;
}
.train-title {
  padding: 9px 12px; margin-bottom: 8px; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--brand-strong, #0f766e), var(--brand, #0d9488));
}
.train-hubs, .train-section-head, .train-section-text, .train-group, .train-footer {
  margin-left: 12px; margin-right: 12px;
}
.train-hubs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.train-hubs-label { font-size: 12px; color: var(--text-soft, #666); }
.train-hub { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: rgba(43,108,176,.10); color: #2b6cb0; }
.train-section-head { font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
.train-section-text { font-size: 12px; color: var(--text-soft, #666); white-space: pre-wrap; }
.train-group { margin-bottom: 4px; }
.train-group-label { font-size: 12.5px; color: var(--text-soft, #666); margin: 8px 0 2px; }
.train-row { padding: 6px 0; border-top: 1px dashed var(--border, rgba(0,0,0,.08)); }
.train-row:first-of-type { border-top: none; }
.tr-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; }
.tr-code { font-weight: 600; color: #0a7d5a; min-width: 52px; }
.tr-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-station { color: var(--text-soft, #555); }
.tr-arrow { color: #bbb; }
.tr-dur { font-size: 12px; color: #999; }
.tr-seats { font-size: 12px; color: var(--text-soft, #666); margin-top: 2px; }
.train-footer { font-size: 11.5px; color: #999; margin-top: 8px; }
/* 合规：来源说明 + 官方购票出口 */
.train-note { font-size: 11.5px; color: #999; margin-top: 4px; }
.train-official {
  display: inline-block; margin-top: 8px; padding: 6px 12px; border-radius: 8px;
  background: var(--brand, #0d9488); color: #fff; font-size: 12.5px; text-decoration: none;
}
.train-official:hover { filter: brightness(1.06); }
.conn-row { padding: 7px 0; border-top: 1px dashed var(--border, rgba(0,0,0,.08)); }
.conn-row:first-child { border-top: none; }
.conn-head { font-size: 12px; font-weight: 600; color: var(--brand-strong, #0f766e); margin-bottom: 3px; }
.train-more {
  margin: 6px 0 2px; padding: 5px 10px; font-size: 12px; cursor: pointer;
  border: 1px dashed var(--border, #e4e7ec); border-radius: 8px;
  background: transparent; color: var(--text-soft, #667085);
}
.train-more:hover { color: var(--brand-strong, #0f766e); border-color: var(--brand, #0d9488); }
@media (max-width: 560px) {
  .tr-line { gap: 6px; font-size: 12.5px; }
  .tr-code { min-width: 44px; }
}

/* ================= 音乐卡片（网易云，内嵌官方外链播放器） ================= */
.music-card {
  margin-top: 10px; border-radius: var(--radius, 12px);
  border: 1px solid var(--border, rgba(0,0,0,.08));
  background: var(--bg-elev, #fff);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(16,24,40,.08));
  overflow: hidden; padding: 0 0 10px;
}
.music-title {
  padding: 9px 12px; margin-bottom: 8px; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #c20c0c, #e23b3b);
}
.music-song { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.music-cover { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.music-meta { min-width: 0; flex: 1 1 auto; }
.music-name {
  font-size: 14px; font-weight: 600; color: var(--text, #101828);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-sub {
  font-size: 12px; color: var(--text-soft, #667085); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-player { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 8px 10px; }
.music-play {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--brand, #0d9488); background: var(--brand, #0d9488);
  color: #fff; font-size: 12.5px;
}
.music-play:disabled { opacity: .75; cursor: default; background: #98a2b3; border-color: #98a2b3; }
.music-audio { flex: 1 1 auto; height: 36px; min-width: 0; }
.music-embed { display: block; width: 100%; height: 86px; border: 0; margin: 6px 0 0; }
/* 举报入口（AI 回复下方）：.msg 已允许换行，这里占满一行，不会被 flex 挤掉 */
.msg-acts { flex-basis: 100%; display: flex; gap: 6px; margin: 2px 0 0 44px; opacity: .55; }
.msg-acts:hover { opacity: 1; }
.msg-acts .mini-btn { font-size: 11.5px; padding: 1px 8px; }
/* 侧边栏底部：用户协议入口 */
.side-link {
  font-size: 12px; color: var(--text-soft); text-decoration: none;
  margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border);
}
.side-link:hover { color: var(--brand, #0d9488); text-decoration: underline; }
/* 登录/注册页：同意协议勾选 */
.agree-row {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 4px; font-size: 13px; color: var(--text-soft); line-height: 1.5;
}
.agree-row input { margin-top: 3px; flex-shrink: 0; }
.agree-row a { color: var(--brand, #0d9488); }
/* 「连接网易云」：两种方式各一个卡片 */
.netease-opt { margin-bottom: 12px; }
.netease-opt .input { width: 100%; margin: 6px 0 8px; }
.music-open {
  display: inline-block; margin: 0 12px 8px; padding: 5px 12px; font-size: 12px;
  border: 1px solid var(--border, #e4e7ec); border-radius: 8px;
  color: var(--brand-strong, #0f766e); text-decoration: none;
}
.music-open:hover { border-color: var(--brand, #0d9488); }
.music-footer { font-size: 11.5px; color: #999; margin: 4px 12px 0; }
@media (max-width: 560px) {
  .music-cover { width: 40px; height: 40px; }
}

/* ================= 侧栏「服务框」（MCP 服务器 / CLI 工具 / 连接网易云） ================= */
.svc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  margin: 2px 0 12px;
}
.svc-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 9px 6px; cursor: pointer; text-align: center;
  border: 1px solid var(--border, rgba(0,0,0,.08)); border-radius: 10px;
  background: var(--bg-elev, #fff); color: var(--text, #101828);
  font: inherit; line-height: 1.2; transition: border-color .15s, background .15s;
}
.svc-box:hover { border-color: var(--brand, #0d9488); background: rgba(13,148,136,.05); }
.svc-box .svc-ico { font-size: 16px; }
.svc-box .svc-name { font-size: 11.5px; color: var(--text-soft, #667085); }
#svc-netease { grid-column: 1 / -1; flex-direction: row; gap: 8px; }
#svc-netease { border-color: rgba(194,12,12,.35); }
#svc-netease:hover { border-color: #c20c0c; background: rgba(194,12,12,.06); }

/* 连接网易云：二维码区 */
.netease-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 12px; }
.netease-qr .qr-canvas { width: 200px; height: 200px; image-rendering: pixelated; }
.netease-manual {
  margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border, #e4e7ec);
  display: flex; flex-direction: column; gap: 6px;
}
.netease-manual .input { width: 100%; }
.netease-adv { margin-top: 14px; }
.netease-adv > summary { cursor: pointer; font-size: 12px; color: var(--text-soft, #667085); }
.netease-adv > summary:hover { color: var(--brand, #0d9488); }
.netease-login-link {
  display: inline-block; margin: 4px 0 6px; padding: 10px 18px;
  background: var(--brand, #0d9488); color: #fff; border-radius: 10px;
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.netease-login-link:hover { filter: brightness(1.06); }
/* 原始登录链接：直接摆出来给用户自己点/复制 */
.netease-url {
  width: min(100%, 420px); margin: 2px 0 8px; font-size: 12px;
  text-align: center; color: var(--text-soft, #667085);
}
@media (max-width: 560px) {
  .netease-qr .qr-canvas { width: 170px; height: 170px; }
}

/* 欢迎文档（登录后弹一次，可关闭） */
.welcome-doc { font-size: 13.5px; line-height: 1.7; }
.welcome-doc h4 { margin: 14px 0 6px; font-size: 13.5px; }
.welcome-doc ul, .welcome-doc ol { margin: 6px 0; padding-left: 20px; }
.welcome-doc li { margin: 4px 0; }
.welcome-doc a { color: var(--brand, #0d9488); }
/* 欢迎文档末尾：警示语 + 署名 */
.welcome-warn {
  margin: 14px 0 0; padding: 8px 10px; border-radius: 8px;
  background: rgba(220, 140, 0, .10); border: 1px solid rgba(220, 140, 0, .30);
  color: var(--text-soft, #667085); font-size: 12.5px; line-height: 1.6;
}
.welcome-sign {
  margin: 10px 0 0; text-align: right;
  color: var(--text-soft, #98a2b3); font-size: 12px; line-height: 1.6;
}
/* 欢迎文档：不再显示勾选 */
.welcome-no {
  margin: 12px 0 0; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-soft, rgba(127, 127, 127, .08)); font-size: 12.5px;
}
.welcome-no input { margin-right: 6px; vertical-align: middle; }
.welcome-no .muted { display: block; margin-top: 2px; font-size: 11.5px; }
