/* ============================================================
   LogicStorm Agent · 视觉系统 v2（精致质感）
   ============================================================ */
:root {
  /* 层级表面 · 暖橙编辑 */
  --bg: #fbf7f0;
  --panel: #fffdf9;
  --panel-2: #fffaf2;
  --border: #e8ddca;
  --border-strong: #e0cfb2;
  /* 文字 */
  --text: #2b2620;
  --text-2: #4a4339;
  --muted: #a08c72;
  /* 主题色 · 陶土橙 */
  --accent: #d9622b;
  --accent-2: #e07b45;
  --accent-soft: #fdf0e8;
  --accent-grad: linear-gradient(135deg, #e07b45 0%, #d9622b 100%);
  --accent-grad-rev: linear-gradient(135deg, #d9622b 0%, #e07b45 100%);
  /* 状态 */
  --ok: #2a8a5e; --warn: #c78c0c; --err: #c94045;
  /* 阴影层级 · 暖调 */
  --shadow-xs: 0 1px 2px rgba(80, 60, 30, .04);
  --shadow-sm: 0 1px 3px rgba(80, 60, 30, .06), 0 1px 2px rgba(80, 60, 30, .04);
  --shadow-md: 0 6px 22px rgba(80, 60, 30, .10), 0 2px 6px rgba(80, 60, 30, .05);
  --shadow-lg: 0 20px 56px rgba(80, 60, 30, .18), 0 4px 14px rgba(80, 60, 30, .10);
  --shadow-accent: 0 6px 18px rgba(217, 98, 43, .32);
  /* 形状 · 杂志风小圆角 */
  --r-sm: 6px; --r: 7px; --r-lg: 10px; --r-pill: 999px;
  /* 玻璃 */
  --glass: rgba(255, 253, 249, .78);
  --glass-border: rgba(255, 253, 249, .60);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: .1px;
}

/* 杂志风衬线标题 */
.brand-text b,
.nav-sub,
.hist-head,
.tab-label,
.welcome h2,
.proj-chip,
.reasoning-hd,
.side-foot .brand-mini,
.composer-footer a,
.model-dropdown .panel-head,
.toolbar button,
.empty-state h3 {
  font-family: Georgia, "Times New Roman", "Songti SC", "STSong", serif;
}

/* 滚动条（精致极简） */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(120, 122, 135, .28); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(120, 122, 135, .5); background-clip: padding-box; }

/* 布局 */
.app { display: grid; grid-template-columns: 252px 1fr 252px; height: 100vh; background: var(--bg); }

/* ===== 左侧栏 ===== */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 8px; position: relative;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 12px; }
.brand-logo { display: inline-flex; align-items: center; filter: drop-shadow(0 3px 8px rgba(217, 98, 43, .28)); }
.brand-logo img { height: 32px; width: auto; border-radius: 6px; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--muted); margin-top: 1.5px; letter-spacing: .3px; }

.newchat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent-grad); color: #fff; border: none; border-radius: var(--r-sm);
  padding: 10px 14px; cursor: pointer; font: inherit; font-weight: 560; font-size: 14px;
  box-shadow: var(--shadow-accent); transition: filter .15s, transform .06s, box-shadow .15s;
}
.newchat:hover { filter: brightness(1.07); box-shadow: 0 8px 22px rgba(217, 98, 43, .42); }
.newchat:active { transform: translateY(1px); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13.5px; color: var(--text-2); font-weight: 500;
  transition: background .14s, color .14s; position: relative;
}
.nav-item .ico { width: 18px; height: 18px; color: var(--muted); display: inline-flex; flex: 0 0 auto; transition: color .14s; }
.nav-item .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: #f3f3f6; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item.active .ico { color: var(--accent); }
.nav-item.sub { padding-left: 23px; font-size: 13px; font-weight: 500; color: var(--muted); }
.nav-sub { display: flex; align-items: center; gap: 9px; padding: 14px 11px 5px; font-size: 11px; font-weight: 650; letter-spacing: .6px; color: #a7a9b2; text-transform: uppercase; }
.nav-sub .ico { width: 15px; height: 15px; }
.nav-sub .ico svg { width: 15px; height: 15px; stroke-width: 1.6; }
.libentry { display: flex; flex-direction: column; gap: 2px; }

.hist-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-top: 8px; }
.hist-head { font-size: 11.5px; font-weight: 600; letter-spacing: .5px; color: #a7a9b2; padding: 8px 11px 6px; cursor: pointer; user-select: none; display: flex; gap: 6px; align-items: center; text-transform: uppercase; }
.hist-count { background: #ecedf1; color: #797c87; border-radius: var(--r-pill); padding: 0 7px; font-size: 10.5px; font-weight: 600; }
.hist { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.hist-item { padding: 8px 11px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; color: var(--text-2); transition: background .12s; display: flex; align-items: center; gap: 6px; }
.hist-item .ht-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-item:hover { background: #f3f3f6; }
.hist-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.hist-item.hidden-by-search { display: none; }
.hist-item .hi-edit, .hist-item .hi-del { opacity: 0; border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 12px; padding: 2px 5px; border-radius: 6px; transition: opacity .12s, background .12s, color .12s; }
.hist-item:hover .hi-edit, .hist-item:hover .hi-del { opacity: .8; }
.hist-item .hi-del:hover { color: var(--err); background: #fdeaea; }

.hist-search { margin: 0 6px 8px; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; font-size: 13px; background: var(--panel-2); color: var(--text); transition: border-color .14s, box-shadow .14s; }
.hist-search::placeholder { color: #b3b5bd; }
.hist-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }

.side-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }
.brand-mini { font-size: 12px; font-weight: 650; color: #a7a9b2; letter-spacing: .5px; }
.foot-actions { display: flex; gap: 2px; }
.foot-btn { border: none; background: transparent; cursor: pointer; padding: 7px; border-radius: 9px; color: var(--muted); display: inline-flex; position: relative; transition: background .14s, color .14s; }
.foot-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.foot-btn:hover { background: #f3f3f6; color: var(--accent); }

/* ===== 中间区 ===== */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; background: var(--bg); }
.topbar {
  height: 56px; border-bottom: 1px solid var(--border);
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.tab-label { font-weight: 620; font-size: 15px; letter-spacing: .2px; }
.proj-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); border-radius: var(--r-pill); padding: 5px 12px; font-weight: 500; }
.proj-chip.hidden { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-btn { border: 1px solid var(--border); background: var(--panel); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); transition: color .14s, border-color .14s, background .14s, transform .1s; }
.top-btn:hover { color: var(--accent); border-color: var(--border-strong); background: var(--panel-2); }
.top-btn:active { transform: scale(.94); }
.top-btn svg { width: 18px; height: 18px; }

.pane { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; animation: fadeIn .25s ease; position: relative; }
.pane.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 对话 */
.log { flex: 1; overflow: auto; min-height: 0; padding: 32px 24px 24px; display: flex; flex-direction: column; gap: 18px; max-width: 880px; width: 100%; margin: 0 auto; }
.welcome { margin: auto; text-align: center; color: var(--muted); max-width: 460px; padding: 28px; }
.welcome .w-logo { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 18px; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-accent); }
.welcome .w-logo svg { width: 30px; height: 30px; fill: #fff; }
.welcome h2 { font-size: 20px; color: var(--text); margin: 0 0 8px; font-weight: 650; letter-spacing: .2px; }
.welcome p { font-size: 14px; margin: 0 0 20px; line-height: 1.6; }
.w-sugs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.w-sugs button { border: 1px solid var(--border); background: var(--panel); border-radius: var(--r-pill); padding: 9px 16px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-2); transition: border-color .14s, background .14s, color .14s, transform .08s; box-shadow: var(--shadow-xs); }
.w-sugs button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }

.msg-row { display: flex; gap: 12px; max-width: 92%; align-items: flex-start; animation: msgIn .32s cubic-bezier(.22, .61, .36, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; box-shadow: 0 2px 6px rgba(17, 24, 39, .12); border: 2px solid #fff; }
.avatar.ai { background: var(--accent-grad); color: #fff; }
.avatar.user { background: linear-gradient(135deg, #ced2dc, #b6bccb); color: #4d5360; }
.msg { padding: 12px 15px; border-radius: var(--r-lg); line-height: 1.66; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; color: var(--text-2); }
.msg.user { background: var(--accent-grad); color: #fff; border-bottom-right-radius: 6px; box-shadow: var(--shadow-accent); }
.msg.ai { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow-xs); }
.msg.tool { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid #d8a93a; font-size: 12.5px; color: #8a6d23; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; align-self: stretch; max-width: 92%; border-radius: 10px; box-shadow: none; }
.msg.tool b { color: #9a7418; }
.msg.role { background: var(--accent-soft); border: 1px solid #f5e6da; color: var(--accent); font-size: 12.5px; font-weight: 500; align-self: center; max-width: 80%; border-radius: var(--r-pill); padding: 6px 15px; box-shadow: none; }

.reasoning { border: 1px solid var(--border); border-radius: var(--r); background: var(--panel-2); margin: 0 0 12px; overflow: hidden; align-self: stretch; max-width: 92%; box-shadow: var(--shadow-xs); }
.reasoning-hd { padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 550; display: flex; align-items: center; gap: 7px; user-select: none; }
.reasoning-hd::before { content: "▾"; font-size: 10px; color: var(--accent); transition: transform .18s; }
.reasoning.collapsed .reasoning-hd::before { transform: rotate(-90deg); }
.reasoning-bd { padding: 0 15px 13px; font-size: 13px; color: #5b606b; line-height: 1.72; white-space: pre-wrap; word-break: break-word; border-top: 1px dashed var(--border); padding-top: 11px; }
.reasoning.collapsed .reasoning-bd { display: none; }

/* 思考中进度条（WorkBuddy 风：消息底部显示动态步骤） */
.thinking-progress { display: inline-flex; align-items: center; gap: 9px; padding-top: 2px; color: var(--muted); font-size: 13px; font-weight: 500; }
.thinking-progress .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: thinkingDot 1.3s ease-in-out infinite; }
@keyframes thinkingDot { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 8px var(--accent); } }
.thinking-progress .step { transition: opacity .2s ease; }

/* 消息操作 */
.msg-actions { display: flex; gap: 6px; margin-top: 7px; }
.msg-act { border: 1px solid var(--border); background: var(--panel); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; transition: color .12s, border-color .12s, background .12s; }
.msg-act:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ===== 输入栏 ===== */
.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 14px 20px 11px; display: flex; flex-direction: column; gap: 9px; flex-shrink: 0; }
.input-wrap { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); display: flex; flex-direction: column; transition: border-color .16s, box-shadow .16s; box-shadow: var(--shadow-xs); }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }
.composer #input { flex: 1; min-height: 46px; max-height: 150px; padding: 14px 17px 7px; border: none; border-radius: var(--r-lg) var(--r-lg) 0 0; background: transparent; font: inherit; font-size: 15px; line-height: 1.5; outline: none; color: var(--text); overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.composer #input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.composer #input .attach-chip { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; padding: 3px 8px 3px 8px; margin: 0 3px; background: rgba(0,0,0,.06); border: 1px solid rgba(0,0,0,.05); border-radius: 999px; color: var(--text-2); font-size: 13px; line-height: 1.35; cursor: default; user-select: none; position: relative; }
.attach-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.chip-name { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.chip-del { margin-left: 4px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; vertical-align: middle; }
.chip-del:hover { background: rgba(0,0,0,.08); color: var(--text); }
.chip-preview { position: fixed; z-index: 100; padding: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; transform: scale(.95); transform-origin: bottom center; display: flex; align-items: center; justify-content: center; }
.chip-preview.visible { opacity: 1; transform: scale(1); }
.chip-preview img { max-width: 220px; max-height: 220px; border-radius: 8px; object-fit: contain; display: block; }
.composer-tools { display: flex; align-items: center; justify-content: space-between; padding: 6px 9px 9px; gap: 8px; }
.tools-left, .tools-right { display: flex; align-items: center; gap: 4px; }
.tools-right { position: relative; }
.tool-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: none; background: transparent; color: #6b6e78; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; padding: 6px 9px; border-radius: 9px; transition: background .14s, color .14s, transform .08s; }
.tool-btn:hover { background: #f1f1f5; color: var(--text); }
.tool-btn:active { transform: scale(.94); }
.tool-btn.attach { width: 30px; height: 30px; padding: 0; color: #5b5f6a; }
.tool-btn.access { color: #a8443f; font-weight: 550; }
.tool-btn.access:hover { background: #fdeeee; color: #c0392b; }
.tool-btn.reasoning-toggle { gap: 5px; color: #5b5f6a; border: 1px solid transparent; }
.tool-btn.reasoning-toggle.active { color: var(--accent); background: var(--accent-soft); border-color: #f5e6da; }
.tool-btn .caret { font-size: 10px; opacity: .7; }
.tool-btn.sparkle { width: 30px; height: 30px; padding: 0; color: #c9a227; }
.tool-btn.sparkle svg { width: 16px; height: 16px; }
.tool-btn.mic { width: 30px; height: 30px; padding: 0; }
.tool-btn.mic svg { width: 17px; height: 17px; }
.tool-btn.mic.active { background: #fdeaea; color: var(--err); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.tool-btn.model-chip { border: 1px solid var(--border); background: var(--panel-2); padding: 5px 11px; border-radius: var(--r-pill); font-weight: 550; color: var(--text-2); }
.tool-btn.model-chip:hover { background: #f1f1f5; border-color: var(--border-strong); }
.tool-btn.spinner { width: 30px; height: 30px; padding: 0; cursor: default; }
.tool-btn.spinner .spin { width: 15px; height: 15px; border: 2px solid rgba(217, 98, 43, .25); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.send-dark { width: 34px; height: 34px; flex: 0 0 auto; border: none; border-radius: 50%; background: var(--accent-grad); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: opacity .15s, transform .08s, filter .15s; box-shadow: var(--shadow-accent); }
.send-dark:hover { filter: brightness(1.08); }
.send-dark:active { transform: scale(.92); }
.send-dark:disabled { opacity: .35; cursor: default; transform: none; }
.send-dark svg { width: 17px; height: 17px; }

.composer-footer { text-align: center; font-size: 11.5px; color: #a7a9b2; letter-spacing: .2px; }

/* 弹出菜单（权限 / 媒体 / 模型） */
.popmenu { position: absolute; bottom: 40px; left: 0; min-width: 230px; background: var(--glass); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%); border: 1px solid var(--glass-border); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; animation: popIn .16s ease; }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.popitem { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); transition: background .12s, color .12s; }
.popitem:hover { background: rgba(217, 98, 43, .10); color: var(--accent); }
.popcheck { color: var(--accent); font-weight: 700; margin-left: auto; }
.pi-ico { width: 17px; height: 17px; color: var(--muted); display: inline-flex; flex: 0 0 auto; }
.pi-ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* 模型下拉面板 */
.model-dropdown { position: absolute; bottom: calc(100% + 10px); right: 0; width: 330px; max-height: 70vh; overflow: auto; background: var(--glass); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%); border: 1px solid var(--glass-border); border-radius: var(--r); padding: 8px; box-shadow: var(--shadow-lg); z-index: 50; animation: popIn .16s ease; }
.model-dropdown.hidden { display: none; }
.panel-head { padding: 10px 12px; font-weight: 620; font-size: 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; color: var(--text); }
.mi { display: flex; align-items: center; padding: 11px 12px; border-radius: 11px; cursor: pointer; gap: 12px; transition: background .12s; }
.mi:hover { background: rgba(217, 98, 43, .08); }
.mi .dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border-strong); flex: 0 0 auto; transition: border-color .12s; }
.mi.sel .dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px #fff; }
.mi .name { font-weight: 550; color: var(--text); }
.mi .rate { margin-left: auto; font-size: 12px; color: var(--muted); }
.mi.custom { border-top: 1px solid var(--border); margin-top: 6px; color: var(--accent); font-weight: 550; }
.mi.custom .ico { width: 18px; height: 18px; color: var(--accent); }
.mi.custom .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.form { padding: 12px; display: none; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); }
.form.open { display: flex; }
.form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--panel); color: var(--text); transition: border-color .14s, box-shadow .14s; }
.form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }
.form button { padding: 10px; border: none; border-radius: 10px; background: var(--accent-grad); color: #fff; font: inherit; font-weight: 550; cursor: pointer; transition: filter .14s; }
.form button:hover { filter: brightness(1.07); }

/* 菜单/汉堡 */
.menu-toggle { display: none; }
.hidden { display: none !important; }

/* ===== 工具条（项目/笔记） ===== */
.toolbar { display: flex; gap: 10px; padding: 22px 24px 8px; flex-wrap: wrap; }
.toolbar input { padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; min-width: 180px; background: var(--panel); color: var(--text); transition: border-color .14s, box-shadow .14s; }
.toolbar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }
.toolbar input#projName, .toolbar input#noteTitle { min-width: 220px; }
.toolbar button { padding: 10px 18px; border: none; border-radius: var(--r-sm); background: var(--accent-grad); color: #fff; font: inherit; font-weight: 550; cursor: pointer; transition: filter .14s, transform .06s; box-shadow: var(--shadow-accent); }
.toolbar button:hover { filter: brightness(1.07); }
.toolbar button:active { transform: translateY(1px); }
.toolbar.note-tools { padding-bottom: 10px; }
#noteBody { margin: 0 24px 14px; height: 90px; resize: none; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); font: inherit; background: var(--panel); color: var(--text); }
#noteBody:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }

/* 网格卡片 */
.grid { flex: 1; overflow: auto; padding: 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-content: start; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 17px; cursor: pointer; transition: border-color .16s, box-shadow .16s, transform .08s; box-shadow: var(--shadow-xs); position: relative; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card h4 { margin: 0 0 7px; font-size: 15px; font-weight: 600; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.card .tag { display: inline-block; font-size: 11.5px; color: var(--accent); background: var(--accent-soft); border-radius: 7px; padding: 3px 10px; margin-top: 11px; font-weight: 500; }
.card .del { position: absolute; top: 12px; right: 12px; color: #c0392b; cursor: pointer; font-size: 12px; opacity: 0; transition: opacity .14s; }
.card:hover .del { opacity: .7; }
.card .del:hover { opacity: 1; }
.card .open-link { font-size: 12.5px; color: var(--accent); margin-top: 11px; display: inline-block; font-weight: 550; }
.card.add { border-style: dashed; color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 550; }
.card.add:hover { background: var(--accent-soft); }
.card.add.hidden { display: none; }

/* hub tabs */
.hub-tabs { display: flex; gap: 6px; padding: 20px 24px 0; }
.htab { border: 1px solid var(--border); background: var(--panel); border-radius: var(--r-sm); padding: 7px 16px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); transition: all .14s; }
.htab.active { background: var(--accent-grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-accent); }

/* 自动化表单 */
.auto-form { padding: 22px 24px 8px; display: flex; flex-direction: column; gap: 11px; max-width: 560px; }
.auto-form input { padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; background: var(--panel); color: var(--text); transition: border-color .14s, box-shadow .14s; }
.auto-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }
.auto-form button { padding: 11px; border: none; border-radius: var(--r-sm); background: var(--accent-grad); color: #fff; font: inherit; font-weight: 550; cursor: pointer; transition: filter .14s; box-shadow: var(--shadow-accent); }
.auto-form button:hover { filter: brightness(1.07); }
.auto-form p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }

/* 设置 */
.settings { padding: 26px; max-width: 640px; line-height: 1.7; overflow: auto; flex: 1; }
.settings h3 { margin: 22px 0 5px; font-size: 15px; font-weight: 600; }
.settings h3:first-child { margin-top: 0; }
.settings p { color: var(--text-2); font-size: 14px; }
.settings code { background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; font-size: 13px; color: var(--accent); font-family: ui-monospace, Menlo, monospace; }

/* ===== 右侧上下文 ===== */
.context { background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px; min-width: 0; }
.ctx-tabs { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; margin-bottom: 14px; }
.ctab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; transition: background .14s, color .14s; font-weight: 500; }
.ctab.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow-xs); }
.ctx-badge { background: var(--accent); color: #fff; border-radius: var(--r-pill); padding: 0 6px; font-size: 10.5px; min-width: 16px; text-align: center; font-weight: 600; }
.ctx-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ctx-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.ctx-actions button { flex: 1; padding: 9px; border: 1px solid var(--border); background: var(--panel-2); border-radius: var(--r-sm); cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text-2); transition: border-color .14s, color .14s; font-weight: 500; }
.ctx-actions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ctx-body { flex: 1; overflow: auto; font-size: 13px; color: var(--muted); white-space: pre-wrap; line-height: 1.65; }

/* 文件 / 代码制品面板 */
.file-list { display: flex; flex-direction: column; gap: 5px; overflow: auto; flex: 1; min-height: 0; }
.file-empty { font-size: 12.5px; color: var(--muted); padding: 18px 6px; line-height: 1.65; }
.file-item { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; background: var(--panel-2); transition: border-color .14s, background .14s, transform .06s; color: var(--text-2); }
.file-item:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateX(1px); }
.file-item.sel { border-color: var(--accent); background: var(--accent-soft); }
.file-item .fi-ico { width: 16px; height: 16px; color: var(--accent); flex: 0 0 auto; }
.file-item .fi-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.file-item .fi-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-tag { font-size: 10.5px; padding: 1px 7px; border-radius: 6px; flex: 0 0 auto; font-weight: 600; }
.fi-tag.gen { background: #e6f7ee; color: var(--ok); }
.fi-tag.ref { background: var(--accent-soft); color: var(--accent); }
.file-view { flex: 1; display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--panel-2); }
.file-view-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text); background: var(--panel); font-weight: 500; }
.file-view-head button { border: 1px solid var(--border); background: var(--panel-2); border-radius: 7px; padding: 4px 11px; cursor: pointer; font: inherit; font-size: 12px; color: var(--text-2); transition: border-color .14s, color .14s; }
.file-view-head button:hover { border-color: var(--accent); color: var(--accent); }
.code { margin: 0; flex: 1; overflow: auto; padding: 11px 0; font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.65; background: var(--panel-2); }
.code .ln { display: flex; }
.code .ln .num { flex: 0 0 auto; width: 40px; text-align: right; padding-right: 13px; color: #b6b6bd; user-select: none; }
.code .ln .src { flex: 1; white-space: pre; padding-right: 13px; color: #2b2f36; }
.c-com { color: #9aa0a6; font-style: italic; }
.c-str { color: #1f9d55; }
.c-kw { color: #8a3ffc; font-weight: 500; }
.c-num { color: #c2410c; }

/* 通知中心 */
.notif-badge { position: absolute; top: 2px; right: 2px; background: var(--err); color: #fff; border-radius: var(--r-pill); min-width: 15px; height: 15px; font-size: 10px; line-height: 15px; text-align: center; padding: 0 4px; box-shadow: 0 1px 3px rgba(229, 72, 77, .5); }
.notif-panel { position: absolute; bottom: 56px; left: 12px; right: 12px; max-height: 330px; overflow: auto; background: var(--glass); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%); border: 1px solid var(--glass-border); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 8px; z-index: 90; animation: popIn .16s ease; }
.notif-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; padding: 4px 6px 9px; border-bottom: 1px solid var(--border); color: var(--text); }
.link-btn { border: none; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; font-weight: 500; }
.notif-list { display: flex; flex-direction: column; gap: 5px; padding-top: 6px; }
.notif-empty { font-size: 12.5px; color: var(--muted); padding: 12px 6px; }
.notif-item { font-size: 12.5px; padding: 9px 10px; border-radius: 10px; background: var(--panel-2); line-height: 1.55; border: 1px solid var(--border); }
.notif-item .nt { font-weight: 600; color: var(--text); }
.notif-item.err { background: #fdeaea; border-color: #f6d4d4; }
.notif-item.err .nt { color: var(--err); }
.notif-item .tm { color: var(--muted); font-size: 11px; }

/* 连接器表单 */
.conn-form { display: none; flex-direction: column; gap: 11px; padding: 18px 24px; }
.conn-form:not(.hidden) { display: flex; }
.conn-form input { padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--r-sm); font: inherit; background: var(--panel); color: var(--text); transition: border-color .14s, box-shadow .14s; }
.conn-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 98, 43, .12); }
.conn-form button { padding: 10px 18px; border: none; border-radius: var(--r-sm); background: var(--accent-grad); color: #fff; font: inherit; font-weight: 550; cursor: pointer; align-self: flex-start; box-shadow: var(--shadow-accent); transition: filter .14s; }
.conn-form button:hover { filter: brightness(1.07); }

/* ===== 深色模式 ===== */
[data-theme="dark"] {
  --bg: #0d0e12;
  --panel: #16181e;
  --panel-2: #1c1f26;
  --border: #262a33;
  --border-strong: #343943;
  --text: #eceef3;
  --text-2: #c4c7d1;
  --muted: #8b909d;
  --accent: #7c8aff;
  --accent-2: #9aa6ff;
  --accent-soft: #21243a;
  --accent-grad: linear-gradient(135deg, #8a96ff 0%, #6d7bf0 100%);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-accent: 0 6px 18px rgba(124, 138, 255, .35);
  --glass: rgba(22, 24, 30, .72);
  --glass-border: rgba(255, 255, 255, .08);
}
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .avatar.user { background: linear-gradient(135deg, #3a3f4d, #2c313c); color: #c4c7d1; }
[data-theme="dark"] .msg.ai { background: var(--panel); }
[data-theme="dark"] .avatar { border-color: var(--panel); }
[data-theme="dark"] .input-wrap, [data-theme="dark"] .file-view, [data-theme="dark"] .code { background: var(--panel-2); }
[data-theme="dark"] .tool-btn:hover { background: #262a33; color: #e6e8ee; }
[data-theme="dark"] .popitem:hover, [data-theme="dark"] .mi:hover { background: rgba(124, 138, 255, .14); }
[data-theme="dark"] .file-item, [data-theme="dark"] .ctx-actions button { background: var(--panel-2); }
[data-theme="dark"] .hist-item { color: var(--text-2); }
[data-theme="dark"] .nav-item:hover, [data-theme="dark"] .hist-item:hover, [data-theme="dark"] .w-sugs button { background: #20242c; }
[data-theme="dark"] .tool-btn.model-chip, [data-theme="dark"] .toolbar input, [data-theme="dark"] .auto-form input, [data-theme="dark"] .conn-form input, [data-theme="dark"] .form input, [data-theme="dark"] #noteBody { background: var(--panel-2); }
[data-theme="dark"] .ctab { color: var(--muted); }

/* ===== 小屏 / 移动端 ===== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .sidebar { position: fixed; z-index: 80; top: 0; bottom: 0; left: 0; width: 256px; transform: translateX(-100%); transition: transform .24s cubic-bezier(.4, 0, .2, 1); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .context { position: fixed; z-index: 70; top: 0; bottom: 0; right: 0; width: 270px; transform: translateX(100%); transition: transform .24s cubic-bezier(.4, 0, .2, 1); box-shadow: var(--shadow-lg); }
  .context.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; cursor: pointer; color: var(--muted); }
  .grid { grid-template-columns: 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 65; backdrop-filter: blur(2px); }
}
@media (max-width: 540px) {
  .composer-tools { flex-wrap: wrap; }
  .tool-btn.access { font-size: 12px; }
  .composer-footer { font-size: 11px; }
}

/* 回到最新按钮：仅 AI 说话且用户不在底部时浮现 */
.jump-bottom {
  position: absolute;
  left: 50%;
  bottom: 124px;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .14s, box-shadow .14s, opacity .2s;
  animation: jumpPop .22s ease;
}
.jump-bottom:hover { transform: translateX(-50%) translateY(-2px); box-shadow: var(--shadow-lg); }
.jump-bottom:active { transform: translateX(-50%) translateY(0); }
.jump-bottom svg { width: 20px; height: 20px; }
.jump-bottom.hidden { display: none; }
@keyframes jumpPop { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
