/* ==========================================================
   派拓枢衡 paitop · 视觉系统
   设计取向（来自开源实践与公开设计文档）：
   - team-play/pun-analysis-agent 的 Claude 风格规范：
     暖中性底、单一克制强调色、层级靠字重与透明度、居中阅读栏、
     用间距而非边框分隔、assistant 不用重气泡
   - assistant-ui / Vercel AI Elements：流程分区（步骤 / 思考 / 工具 / 交付）
   - Linear / Vercel 的中性表面：1px 细边、无渐变、无发光
   明确去掉：背景径向渐变、渐变文字、发光阴影、彩色胶囊堆叠
   ========================================================== */

@font-face {
  font-family: "Paitop Sans";
  src: url("/fonts/HarmonyOS-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Paitop Sans";
  src: url("/fonts/HarmonyOS-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --font: "Paitop Sans", "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, ui-monospace, monospace;

  /* 暖中性纸面 —— 与派拓智库主站同一套色板 */
  --bg: #F5F3EC;
  --surface: #FFFDF8;
  --surface-2: #EFEBE1;
  --sidebar: #F1EEE6;
  --bubble: #EAE5DA;
  --hover: rgba(29, 28, 26, .045);
  --code-bg: #1D1C1A;
  --code-fg: #E9E5DD;

  --text: #1D1C1A;
  --text-2: #5C5850;
  --text-3: #8A8578;

  --border: #E3DFD4;
  --border-2: #D2CCBE;

  /* 唯一强调色：主站赤陶橙，只用于主操作与选中态 */
  --accent: #C75B2A;
  --accent-soft: rgba(199, 91, 42, .09);
  --on-accent: #ffffff;

  --ok: #2e7052;
  --ok-soft: rgba(46, 112, 82, .09);
  --warn: #8f6a1e;
  --warn-soft: rgba(143, 106, 30, .09);
  --err: #a8403a;
  --err-soft: rgba(168, 64, 58, .08);

  --shadow-sm: 0 1px 2px rgba(25, 24, 23, .05);
  --shadow: 0 1px 2px rgba(25, 24, 23, .05), 0 12px 32px -12px rgba(25, 24, 23, .16);

  --radius: 12px;
  --radius-lg: 16px;

  --side-w: 260px;
  --thread-max: 1080px;
  --pad-x: clamp(16px, 3vw, 28px);
  --fs: clamp(14.5px, .2vw + 13.9px, 15.5px);
  --agent-indent: 0px;
}

[data-theme="dark"] {
  --bg: #171614;
  --surface: #201E1A;
  --surface-2: #292621;
  --sidebar: #1B1A16;
  --bubble: #2A2621;
  --hover: rgba(255, 255, 255, .055);
  --code-bg: #121110;
  --code-fg: #E9E5DD;

  --text: #EDEAE3;
  --text-2: #ADA79B;
  --text-3: #877F73;

  --border: #302D28;
  --border-2: #403B34;

  --accent: #DA7038;
  --accent-soft: rgba(218, 112, 56, .14);
  --on-accent: #1a120c;

  --ok: #6cb28d;
  --ok-soft: rgba(108, 178, 141, .12);
  --warn: #d0a24e;
  --warn-soft: rgba(208, 162, 78, .12);
  --err: #dc8078;
  --err-soft: rgba(220, 128, 120, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -12px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------------- 骨架 ---------------- */
.app { display: flex; height: 100vh; height: 100dvh; width: 100%; }

.sidebar {
  width: var(--side-w); flex: none; display: flex; flex-direction: column; gap: 10px;
  padding: 16px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 40;
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), margin .26s cubic-bezier(.2, .8, .2, 1);
}
.app.side-collapsed .sidebar { margin-left: calc(-1 * var(--side-w)); }

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px 8px; }
.mark { height: 28px; width: auto; flex: none; display: block; }
[data-theme="dark"] .mark { filter: invert(1) brightness(1.4); }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: .1px; }
.brand-name em { font-style: normal; font-weight: 400; color: var(--text-3); margin-left: 5px; font-size: 11.5px; }

.new-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 36px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: border-color .15s, color .15s, background .15s;
}
.new-btn:hover { border-color: var(--border-2); color: var(--text); background: var(--surface); }

.threads { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 2px 4px; }
.group-label {
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  padding: 14px 8px 6px; letter-spacing: .7px; text-transform: uppercase;
}
.t-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 8px; border-radius: 8px; font-size: 13px; color: var(--text-2);
  transition: background .12s, color .12s;
}
.t-item span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.t-item .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--border-2); flex: none; }
.t-item:hover { background: var(--hover); color: var(--text); }
.t-item.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }
.t-item.active .dot { background: var(--accent); }

.side-foot {
  border-top: 1px solid var(--border); padding: 10px 6px 2px;
  font-size: 11.5px; color: var(--text-3); line-height: 1.65;
}
.side-foot b { color: var(--text-2); font-weight: 500; }
.ell { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 8px; height: 52px; flex: none;
  padding: 0 var(--pad-x); padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border); background: var(--bg); z-index: 10;
}
.topbar h1 { font-size: 13.5px; font-weight: 550; margin: 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px;
  border-radius: 7px; font-size: 11.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid transparent;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
/* 就绪状态不占位：只在运行中或出错时出现 */
#statusChip:not(.run):not(.error) { display: none; }
.chip .live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.chip.run .live { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.chip.error { color: var(--err); background: var(--err-soft); }
.chip.error .live { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); flex: none; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------- 消息流 ---------------- */
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 24px; }
.inner {
  max-width: var(--thread-max); margin: 0 auto;
  padding: 30px var(--pad-x) 28px;
  min-height: 100%; display: flex; flex-direction: column; gap: 2px;
}

.msg { display: flex; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg + .msg { margin-top: 14px; }
.msg.user { justify-content: flex-end; margin: 18px 0 6px; }
.msg.user .col { max-width: min(80%, 560px); display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.bubble {
  background: var(--bubble); padding: 9px 14px; border-radius: 14px; border-bottom-right-radius: 5px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.agent .content { width: 100%; min-width: 0; }
.msg.agent.plain { padding-left: 0; }

.attach-row { display: flex; flex-wrap: wrap; gap: 7px; }
.attach-row img, .attach-row .vid {
  width: 62px; height: 62px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface);
}
.attach-row .vid { display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: var(--text-3); background: var(--surface-2); }
.composer .attach-row { padding: 10px 14px 0; }

.step {
  display: flex; align-items: center; gap: 10px;
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  letter-spacing: .7px; text-transform: uppercase;
  margin-top: 18px;
}
.step::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* 思考 */
.reason { border-radius: 8px; }
.reason-head {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 5px 0; border-radius: 6px; color: var(--text-2); font-size: 12.5px;
  text-align: left; min-width: 0;
}
.reason-head:hover { color: var(--text); }
.reason-head .lbl { font-weight: 500; color: var(--text-2); flex: none; }
.reason-head .dur { font-size: 11px; color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.reason-head .preview { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-3); }
.chev { transition: transform .2s; color: var(--text-3); width: 13px; height: 13px; }
[data-open="1"] > button .chev { transform: rotate(180deg); }
.reason-body {
  display: none; margin: 2px 0 6px 6px; padding: 2px 0 2px 12px;
  border-left: 1px solid var(--border-2);
  color: var(--text-2); font-size: 13.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.reason[data-open="1"] .reason-body { display: block; }

/* 工具卡 */
.tool {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; margin: 6px 0; transition: border-color .15s;
}
.tool:hover { border-color: var(--border-2); }
.tool-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 11px; text-align: left; min-width: 0; font-size: 12.5px; }
.tool-head .ico { color: var(--text-3); width: 14px; height: 14px; }
.tool-name { font-family: var(--mono); font-size: 12px; font-weight: 550; flex: none; color: var(--text); }
.tool-sum, .tool-err {
  flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
}
.tool-err { color: var(--err); }
.tool-state { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.tool-state .d { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.tool[data-status="running"] .tool-state { color: var(--warn); }
.tool[data-status="running"] .tool-state .d { background: var(--warn); animation: pulse 1.4s infinite; }
.tool[data-status="error"] { border-color: color-mix(in srgb, var(--err) 26%, var(--border)); box-shadow: inset 2px 0 0 var(--err); }
.tool[data-status="error"] .tool-state { color: var(--err); }
.tool[data-status="error"] .tool-state .d { background: var(--err); }
.tool[data-status="error"] .ico { color: var(--err); }

.tool-body { display: none; border-top: 1px solid var(--border); padding: 10px 12px 12px; }
.tool[data-open="1"] .tool-body { display: block; }
.tool-body .lbl { font-size: 10.5px; font-weight: 600; color: var(--text-3); letter-spacing: .6px; margin: 6px 0 5px; text-transform: uppercase; }
.tool-body pre {
  margin: 0; max-height: 320px; overflow: auto; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.shot { display: block; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 8px; cursor: zoom-in; }

.note { font-size: 12.5px; line-height: 1.65; padding: 8px 11px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); margin: 6px 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 2px 0 0 var(--warn); }
.note.err { background: var(--err-soft); color: var(--err); box-shadow: inset 2px 0 0 var(--err); }

/* 交付 */
.deliver-head {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  letter-spacing: .8px; text-transform: uppercase; margin: 4px 0 8px;
}
.deliver-head .ico { width: 13px; height: 13px; color: var(--ok); }

.metrics {
  display: flex; flex-direction: column; gap: 5px;
  margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--border);
  color: var(--text-3);
}
.metrics:empty { display: none; }
.mrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; }
.mrow + .mrow { margin-top: 1px; }
.metrics .m { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.metrics .k { font-size: 10.5px; color: var(--text-3); letter-spacing: .3px; }
.metrics .v {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.metrics .v b { font-weight: 600; color: var(--text); }
.metrics .v i { font-style: normal; color: var(--text-3); margin-left: 3px; }

/* 每次调用明细 */
.usage-detail { margin-top: 9px; }
.usage-detail summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-3);
}
.usage-detail summary::-webkit-details-marker { display: none; }
.usage-detail summary::before { content: "▸"; font-size: 9px; color: var(--text-3); }
.usage-detail[open] summary::before { content: "▾"; }
.usage-detail summary:hover { color: var(--text-2); }
.usage-table-wrap { overflow-x: auto; margin-top: 8px; }
.usage-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.usage-table th {
  font-weight: 500; color: var(--text-3); text-align: right;
  padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.usage-table td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.usage-table tr:last-child td { border-bottom: 0; }
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table td.tm { text-align: left; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-table td b { font-weight: 600; color: var(--text); }

/* Markdown */
.prose { word-break: break-word; font-size: 15px; line-height: 1.78; }
.prose p { margin: 0 0 .82em; }
.prose p:last-child { margin-bottom: 0; }
.prose h4 { font-size: 1.06em; margin: 1.2em 0 .5em; font-weight: 600; }
.prose h5 { font-size: 1em; margin: 1.05em 0 .4em; font-weight: 600; }
.prose ul { margin: 0 0 .82em; padding-left: 1.25em; }
.prose li { margin: .22em 0; }
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.prose blockquote { margin: 0 0 .82em; padding: 1px 14px; border-left: 2px solid var(--border-2); color: var(--text-2); }
.prose code {
  font-family: var(--mono); font-size: .87em; padding: .1em .38em; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
}
[data-theme="dark"] .prose code { border-color: transparent; background: #262320; }
.codeblock {
  margin: 0 0 .9em; padding: 13px 15px; border-radius: 10px;
  background: var(--code-bg); color: var(--code-fg); overflow-x: auto;
  font-family: var(--mono); font-size: 12.4px; line-height: 1.62;
}
.codeblock code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }

/* 流式 */
.thinking-state { display: inline-flex; align-items: center; gap: 9px; color: var(--text-3); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: bob 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { opacity: .22; } 40% { opacity: 1; } }
.live-text { white-space: pre-wrap; display: inline; color: var(--text-2); font-size: 14px; line-height: 1.78; }
.live.answer .live-text { color: var(--text); font-size: 15px; }
.caret {
  display: inline-block; width: 2px; height: 1.05em; vertical-align: -.18em;
  background: var(--accent); border-radius: 1px; margin-left: 2px;
  animation: blink 1.05s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 空态：垂直居中，与输入框同一列宽 */
.empty {
  margin: auto 0; padding: 8px 0;
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
}
.mark-lg { height: 42px; width: auto; display: block; margin-bottom: 18px; }
[data-theme="dark"] .mark-lg { filter: invert(1) brightness(1.4); }
.empty h2 { margin: 0 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.5px; color: var(--text); }
.empty p { margin: 0 0 22px; color: var(--text-2); font-size: 14px; }
.suggests { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }

/* 能力标签行 */
.cap-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; margin: -8px 0 20px; }
.cap-row span {
  font-size: 11.5px; color: var(--text-3); padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}

/* 欢迎页里的最近会话 */
.recent-block { width: 100%; margin-top: 26px; text-align: left; }
.recent-head { font-size: 11.5px; color: var(--text-3); letter-spacing: .04em; margin-bottom: 8px; }
.recent-row { display: flex; flex-wrap: wrap; gap: 6px; }
.recent-chip {
  font-size: 12.5px; color: var(--text-2); padding: 5px 11px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: border-color .15s, color .15s;
}
.recent-chip:hover { border-color: var(--border-2); color: var(--text); }
.sg {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; text-align: left;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s, background .15s;
}
.sg:hover { border-color: var(--border-2); background: var(--surface); }
.sg .ico { width: 15px; height: 15px; color: var(--text-3); margin-top: 2px; }
.sg:hover .ico { color: var(--accent); }
.sg b { display: block; font-size: 13px; font-weight: 550; margin-bottom: 1px; color: var(--text); }
.sg span { display: block; font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* 回到底部 */
.jump {
  position: absolute; left: 50%; bottom: 138px; transform: translate(-50%, 8px);
  opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 8px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow);
  transition: .18s; z-index: 5;
}
.jump.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }

/* ---------------- 弹窗（设置 / 首次选择目录） ---------------- */
.modal { position: fixed; inset: 0; z-index: 80; display: none; }
.modal.open { display: block; }
.modal-mask {
  position: absolute; inset: 0; background: rgba(20, 18, 16, .38);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative; z-index: 1; margin: 12vh auto 0;
  width: min(520px, calc(100% - 40px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 22px 24px 18px;
  animation: rise .18s ease both;
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.2px; flex: 1; }
.modal-sub { margin: 0 0 18px; font-size: 13px; color: var(--text-2); line-height: 1.65; }
.modal-label { display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }
.modal-row { display: flex; gap: 8px; }
.modal-row input {
  flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; font-family: var(--mono); outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.modal-row input:focus {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.btn {
  height: 40px; padding: 0 16px; border-radius: 9px; flex: none;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); font-size: 13px; transition: .12s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 550; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.modal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.modal-chip {
  font-size: 11.5px; font-family: var(--mono); color: var(--text-2);
  background: var(--surface-2); border: 1px solid transparent;
  padding: 4px 9px; border-radius: 7px; transition: .12s;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-chip:hover { border-color: var(--border-2); color: var(--text); }
.modal-msg { min-height: 16px; font-size: 12px; margin-top: 10px; color: var(--err); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal.first-run .modal-actions #wsLater { display: none; }

/* 模型选择 */
.model-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 8px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
}
.link-btn { font-size: 11.5px; color: var(--accent); padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }
.model-list {
  max-height: 208px; overflow-y: auto; margin: 0 -4px;
  display: flex; flex-direction: column; gap: 2px;
}
.model-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: 7px; text-align: left;
  border: 1px solid transparent; background: none; transition: .12s;
}
.model-item:hover { background: var(--surface-2); }
.model-item.on { border-color: color-mix(in srgb, var(--accent) 40%, transparent);
                 background: var(--accent-soft); }
.model-item .mi-name { font-size: 12.5px; color: var(--text); }
.model-item .mi-id { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }
.model-item .mi-meta { margin-left: auto; display: flex; align-items: center; gap: 6px;
                       font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }
.mi-tag { font-size: 10px; padding: 1px 5px; border-radius: 4px;
          background: var(--surface-2); color: var(--text-3); }
.mi-tag.new { background: var(--accent-soft); color: var(--accent); }
.mi-tag.vis { background: var(--ok-soft); color: var(--ok); }
.model-hint { font-size: 11px; color: var(--text-3); margin-top: 8px; line-height: 1.6; }
.badge-dot {
  position: absolute; top: 4px; right: 4px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent);
}

/* ---------------- 输入区 ---------------- */
.composer-wrap {
  position: relative; z-index: 6;
  padding: 0 var(--pad-x) 14px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.composer-shell {
  position: relative;
  max-width: var(--thread-max); margin: 0 auto;
  background: color-mix(in srgb, var(--surface-2) 88%, var(--text) 5%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 7px;
  transition: border-color .18s, box-shadow .18s;
}
.composer-shell:focus-within {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border-2));
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.12);
}
.composer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2px 2px 2px;
}
.composer-card textarea {
  display: block; width: 100%; min-height: 52px; max-height: 220px;
  padding: 13px 14px 4px; border: 0; background: none; resize: none;
  color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.6; outline: 0;
}
.composer-card textarea::placeholder { color: var(--text-3); opacity: .78; }
.attach-tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.attach-tray:not(:empty) { padding: 2px 12px 8px; }

.composer-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px 8px 9px;
}
.cbtn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 8px; border-radius: 999px;
  color: var(--text-2); font-size: 12px; white-space: nowrap;
  transition: background .12s, color .12s;
}
.cbtn:hover { background: var(--hover); color: var(--text); }
.cbtn svg { width: 15px; height: 15px; stroke-width: 1.8; }
.cbtn.pill { padding: 0 10px; background: var(--surface-2); }
.cbtn.pill:hover { background: var(--hover); }
.cbtn .chev { width: 12px; height: 12px; opacity: .55; stroke-width: 2; }
.cbtn.on svg:first-child { color: var(--ok); }
.model-pill { max-width: 240px; }
.model-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; transition: background .2s; box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 10%, transparent); }
.model-pill.ready .dot { background: var(--ok); }
.model-pill span:not(.dot) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px;
}
.grow { flex: 1; }
.cspin {
  width: 14px; height: 14px; margin: 0 4px; border-radius: 50%;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.send-round {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg);
  transition: transform .12s, filter .12s;
}
.send-round:hover { filter: brightness(1.12); }
.send-round:active { transform: scale(.94); }
.send-round svg { width: 16px; height: 16px; stroke-width: 2.2; }
.send-round.stop { background: var(--accent); color: #fff; }
.send-round.stop svg { fill: currentColor; stroke: none; }

.foot-hint {
  max-width: var(--thread-max); margin: 8px auto 0; padding: 0 12px;
  text-align: center; font-size: 11.5px; color: var(--text-3); line-height: 1.5;
}

.popover {
  position: absolute; bottom: calc(100% + 8px); z-index: 20;
  min-width: 240px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px;
}
.popover[hidden] { display: none; }
#permMenu { left: 44px; }
#modelMenu { right: 44px; }
.pop-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 8px 10px; border-radius: 8px; text-align: left;
}
.pop-item:hover { background: var(--surface-2); }
.pop-item .pi-t { font-size: 12.5px; color: var(--text); }
.pop-item .pi-d { font-size: 11px; color: var(--text-3); }
.pop-item.on .pi-t::after { content: " ✓"; color: var(--accent); }
.pop-head { display: flex; align-items: center; justify-content: space-between;
            padding: 4px 8px 6px; font-size: 11px; color: var(--text-3); }
.pop-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.pop-model {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 9px; border-radius: 8px; text-align: left;
}
.pop-model:hover { background: var(--surface-2); }
.pop-model.on { background: var(--accent-soft); }
.pop-model .pm-n { font-size: 12px; color: var(--text); }
.pop-model .pm-m { margin-left: auto; font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }

/* ==========================================================
   响应式
   ========================================================== */
@media (min-width: 1600px) { :root { --side-w: 288px; --thread-max: 1180px; } }

@media (max-width: 1180px) { .suggests { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 1023px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); box-shadow: var(--shadow); background: var(--sidebar); }
  .app.side-open .sidebar { transform: none; }
  .app.side-collapsed .sidebar { margin-left: 0; }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 18, 16, .35); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30; }
  .app.side-open .backdrop { opacity: 1; pointer-events: auto; }
  #usageChip { display: none !important; }
}

@media (max-width: 639px) {
  .topbar { height: 50px; gap: 5px; }
  .topbar h1 { font-size: 13px; }
  #stepChip { display: none !important; }
  .chip { height: 24px; padding: 0 8px; }
  .inner { padding-top: 20px; }
  .msg.user .col { max-width: 88%; }
  .suggests { grid-template-columns: 1fr; }
  .empty h2 { font-size: 22px; }
  .exec-note { display: none; }
  .foot-hint { display: none; }
  .composer-card textarea { font-size: 16px; }
  .tool-sum { display: none; }
  .jump { bottom: 116px; }
}

@media (max-width: 480px) {
  .cap-row { display: none; }
  .empty h2 { font-size: 20px; }
  .empty p { font-size: 13px; margin-bottom: 16px; }
  .mark-lg { height: 34px; margin-bottom: 12px; }
  .sg { padding: 10px 11px; }
  .sg b { font-size: 12.5px; }
  .sg span { font-size: 11.5px; }
  .recent-block { margin-top: 18px; }
  .recent-chip { font-size: 12px; max-width: 100%; }
  .composer-card textarea { font-size: 16px; }
  .foot-hint, #usageChip, #statusChip { display: none !important; }
  .inner { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 380px) {
  .attach-btn { font-size: 0; gap: 0; width: 30px; padding: 0; justify-content: center; }
  .attach-btn.comp.on::before { display: none; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar { height: 44px; }
  .empty { padding: 8px 0; }
  .mark-lg { display: none; }
  .composer-card textarea { max-height: 88px; padding-top: 8px; }
  .foot-hint { display: none; }
}

@media (hover: none) { .sg:hover { border-color: var(--border); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .composer-wrap, .jump { display: none !important; }
  body { overflow: visible; }
}
/* ==========================================================
   精修：聚焦光晕 / 侧栏活跃态 / 气泡层次
   （追加层，覆盖前面的同名属性，不动结构）
   ========================================================== */
.composer-card { transition: box-shadow .22s ease, border-color .22s ease; }
.composer-card:focus-within {
  border-color: var(--border-2);
  box-shadow: 0 1px 2px rgba(29, 28, 26, .05), 0 0 0 3px rgba(199, 91, 42, .10),
              0 18px 42px -26px rgba(29, 28, 26, .28);
}

.t-item { position: relative; transition: background .16s ease, color .16s ease; }
.t-item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2.5px;
  border-radius: 2px; background: var(--accent);
}

.bubble { box-shadow: 0 1px 1px rgba(29, 28, 26, .035); }

.send-round { transition: transform .16s cubic-bezier(.22,1,.36,1), box-shadow .2s, background .2s; }
.send-round:not(.stop):hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(199, 91, 42, .7); }

.icon-btn { transition: background .14s ease, color .14s ease, transform .14s ease; }
.icon-btn:active { transform: scale(.94); }

/* 图片不再撑满屏幕 */
.attach-row img, .attach-row .vid { width: 62px !important; height: 62px !important; max-width: 62px; flex: none; }
.attach-row img { cursor: zoom-in; }
.msg img, .prose img { max-width: min(100%, 320px); max-height: 320px; height: auto; object-fit: contain; border-radius: 10px; }
.img-lightbox { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.82); display: grid; place-items: center; cursor: zoom-out; }
.img-lightbox img { max-width: 94vw; max-height: 90vh; object-fit: contain; border-radius: 8px; }
/* 任务队列 */
.queue-chip { display: none; flex-direction: column; gap: 4px; margin: 0 auto 6px; width: 100%; max-width: 760px; }
.queue-chip .q-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 5px 10px; }
.queue-chip .q-n { color: var(--text-3); font-weight: 600; flex: none; }
.queue-chip .q-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-chip button { flex: none; width: 18px; height: 18px; border-radius: 50%; color: var(--text-3); }

.queue-chip button[disabled] { opacity: .3; cursor: default; }
.queue-chip .q-steer { width: auto; padding: 0 8px; border-radius: 9px; font-size: 12px; color: var(--accent, #4f7cff); border: 1px solid currentColor; }

/* 全端实时同步：其他设备正在执行的会话 */
.t-item .live-tag{display:none;margin-left:auto;font-size:11px;padding:1px 6px;border-radius:8px;background:rgba(34,197,94,.15);color:#16a34a;flex-shrink:0}
.t-item.is-live .live-tag{display:inline-block}
.t-item.is-live .dot{background:#22c55e;animation:livepulse 1.2s ease-in-out infinite}
@keyframes livepulse{0%,100%{opacity:1}50%{opacity:.3}}

/* ===== 3.2 可读性重做（与 APP 对齐） ===== */
:root, [data-theme="light"] { --text-2: #3F3B35; --text-3: #6A655B; --border: #DAD5C9; }
[data-theme="dark"] { --text-2: #D6D1C6; --text-3: #A9A296; --border: #45403A; }
.prose { font-size: 16px; line-height: 1.8; }
.prose h4 { font-size: 1.15em; margin: 1.4em 0 .55em; }
.prose h5 { font-size: 1.05em; margin: 1.2em 0 .45em; }
.prose .list { margin: 0 0 .9em; }
.prose .li { display: flex; gap: 8px; margin: .3em 0; }
.prose .li .lm { flex: none; min-width: 1.5em; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.prose .li .lt { flex: 1; min-width: 0; }
.prose .li.lv1 { padding-left: 1.4em; } .prose .li.lv2 { padding-left: 2.8em; } .prose .li.lv3 { padding-left: 4.2em; }
.prose .tbl-wrap { overflow-x: auto; margin: 0 0 .9em; border: 1px solid var(--border); border-radius: 8px; }
.prose table { border-collapse: collapse; font-size: 14.5px; min-width: 100%; }
.prose th, .prose td { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose .code { margin: 0 0 .9em; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.prose .code-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; font-size: 12.5px; color: var(--text-3); background: var(--surface-2); font-family: var(--mono); }
.prose .code-copy { font-size: 12.5px; color: var(--text-2); padding: 2px 6px; border-radius: 5px; }
.prose .code-copy:hover { background: var(--hover); }
.prose .code .codeblock { margin: 0; border: 0; border-radius: 0; font-size: 13.5px; overflow-x: auto; }
.prose.folded { max-height: 520px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.fold-btn { margin-top: 6px; font-size: 13.5px; color: var(--accent); padding: 4px 0; }
.deliver-head { display: none; }
.acts, .uacts { display: flex; align-items: center; gap: 2px; margin-top: 8px; }
.uacts { justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.msg.user:hover .uacts, .msg.user:last-of-type .uacts { opacity: 1; }
.act { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.act:hover { background: var(--hover); color: var(--text); }
.act svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.running .acts .act, body.running .uacts { display: none; }
.acts .metrics { margin: 0 0 0 auto; padding: 0; border: 0; }
.bubble { font-size: 16px; line-height: 1.7; }
.tool { background: transparent; border-color: transparent; }
.tool:hover { border-color: var(--border); }
.tool[data-open="1"] { background: var(--surface); border-color: var(--border); }
.tool-head { font-size: 14px; padding: 7px 8px; }
.tool-name { font-family: inherit; font-size: 14px; }
.tool-sum { font-size: 13px; }
.tool-state { font-size: 12.5px; }
.tool-body pre { font-size: 13px; }
.tool-body .lbl, .step, .group-label { font-size: 12px; }
.reason-head { font-size: 14px; } .reason-head .dur { font-size: 12.5px; }
.reason-body { font-size: 14.5px; }
.note { font-size: 14px; }
.live-text { font-size: 15px; } .live.answer .live-text { font-size: 16px; }
.metrics .k { font-size: 12px; } .metrics .v { font-size: 12.5px; }
.usage-detail summary { font-size: 12.5px; }
.t-search { margin: 0 0 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; outline: 0; width: 100%; box-sizing: border-box; }
.t-search:focus { border-color: var(--border-2); }
.group-label { padding-top: 14px; color: var(--text-2); }
.t-item { font-size: 14.5px; padding: 9px 9px; }
.new-btn { font-size: 14px; }
.topbar h1 { font-size: 15px; }
.chip { font-size: 12.5px; }
.composer-card textarea { font-size: 16px; line-height: 1.65; }
.side-foot { font-size: 12.5px; }
.edit-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; }
.edit-bar[hidden] { display: none; }
.edit-bar button { color: var(--accent); font-size: 13.5px; }

#micBtn.rec { background: #EE4A0A; color: #fff; animation: micp 1.2s infinite; }
@keyframes micp { 50% { opacity: .65; } }

/* 代码高亮 */
.codeblock .tk-c { color: #8b949e; font-style: italic; }
.codeblock .tk-s { color: #a5d6ff; }
.codeblock .tk-n { color: #f2cc60; }
.codeblock .tk-k { color: #ff7b72; }

/* ==========================================================
   UI 2.0 重构层（3.10）：设计令牌 / 全尺寸响应式 / 流畅动画
   加载在 styles.css 之后；删掉 <link> 即可回滚
   ========================================================== */
:root {
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 140ms; --t-mid: 240ms; --t-slow: 360ms;
  --side-w: clamp(248px, 22vw, 300px);
  --thread-max: clamp(320px, 92vw, 800px);
  --pad-x: clamp(14px, 3.2vw, 28px);
  --fs-body: clamp(15px, .3vw + 14px, 16.5px);
  --shadow-1: 0 1px 2px rgba(20,18,15,.06);
  --shadow-2: 0 8px 28px -12px rgba(20,18,15,.22), 0 2px 6px -2px rgba(20,18,15,.08);
}

/* ---------- 基础：稳定布局，不抖动 ---------- */
html, body { height: 100%; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -webkit-tap-highlight-color: transparent; }
.app { height: 100vh; height: 100dvh; overflow: hidden; }
.scroll {
  scrollbar-gutter: stable; scroll-behavior: auto;
  -webkit-overflow-scrolling: touch; contain: content;
}
.inner { contain: layout style; }
.msg { contain: layout style; }
.prose, .bubble { font-size: var(--fs-body); }
button, .t-item, .pop-item { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- 顶栏：毛玻璃 + 滚动分隔 ---------- */
.topbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  min-height: 52px; height: auto; gap: var(--s2);
  padding-left: max(var(--pad-x), env(safe-area-inset-left));
  padding-right: max(var(--pad-x), env(safe-area-inset-right));
}
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: .1px; }
.scroll { mask-image: linear-gradient(to bottom, transparent 0, #000 14px); -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px); }

/* ---------- 侧栏：transform 动画，GPU 合成 ---------- */
.sidebar {
  width: var(--side-w); flex: none;
  transition: transform var(--t-slow) var(--ease), margin var(--t-slow) var(--ease), opacity var(--t-mid) var(--ease);
  will-change: transform;
}
.app.side-collapsed .sidebar { margin-left: calc(-1 * var(--side-w)); opacity: 0; pointer-events: none; }
.t-item { border-radius: var(--r-sm); transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.t-item:active { transform: scale(.985); }
.new-btn { border-radius: var(--r-md); transition: background var(--t-fast), box-shadow var(--t-mid) var(--ease), transform var(--t-fast); }
.new-btn:active { transform: scale(.97); }
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10,10,10,.38);
  opacity: 0; pointer-events: none; transition: opacity var(--t-mid) var(--ease);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}

/* ---------- 消息：进入动画只用 opacity/transform ---------- */
.msg { animation: ui-in var(--t-mid) var(--ease) both; }
@keyframes ui-in { from { opacity: 0; transform: translate3d(0, 6px, 0); } to { opacity: 1; transform: none; } }
.bubble { border-radius: var(--r-lg); border-bottom-right-radius: 6px; padding: 10px 15px; box-shadow: var(--shadow-1); }
.msg.user .col { max-width: min(82%, 620px); }
.tool, .prose .code, .prose .tbl-wrap, .note { border-radius: var(--r-md); }
.tool-body { animation: ui-fade var(--t-mid) var(--ease); }
.reason-body { animation: ui-fade var(--t-mid) var(--ease); }
@keyframes ui-fade { from { opacity: 0; transform: translate3d(0, -3px, 0); } to { opacity: 1; transform: none; } }
.act { transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease); }
.act:active { transform: scale(.9); }
.uacts { transition: opacity var(--t-mid) var(--ease); }

/* 流式光标与思考动画 */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; color: var(--text-3); font-size: 14px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ui-dot 1.2s var(--ease-io) infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; } .typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ui-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 输入区 ---------- */
.composer-wrap {
  padding: 0 max(var(--pad-x), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(var(--pad-x), env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.composer-shell { max-width: var(--thread-max); margin: 0 auto; position: relative; }
.composer-card { border-radius: var(--r-xl); box-shadow: var(--shadow-2); }
.composer-card textarea { transition: height var(--t-fast) var(--ease); }
.send-round { transition: transform var(--t-fast) var(--ease), background var(--t-mid), opacity var(--t-mid); }
.send-round:active { transform: scale(.9); }
.send-round:disabled { opacity: .4; }
.cbtn { border-radius: 999px; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease); }
.cbtn:active { transform: scale(.94); }
.foot-hint { text-align: center; font-size: 11.5px; color: var(--text-3); padding-top: 6px; }

/* 弹层：缩放淡入 */
.popover { border-radius: var(--r-md); box-shadow: var(--shadow-2); transform-origin: bottom left; animation: ui-pop var(--t-mid) var(--ease); }
@keyframes ui-pop { from { opacity: 0; transform: scale(.96) translateY(4px); } to { opacity: 1; transform: none; } }
.modal-card { border-radius: var(--r-lg); animation: ui-pop var(--t-mid) var(--ease); max-height: calc(100dvh - 32px); overflow: auto; }
.jump { border-radius: 999px; box-shadow: var(--shadow-2); transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease); }

/* ==========================================================
   断点：手机 <600 / 竖平板 600-1023 / 桌面 ≥1024 / 宽屏 ≥1440
   ========================================================== */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(86vw, 320px); margin: 0 !important; opacity: 1 !important;
    transform: translate3d(-102%, 0, 0); box-shadow: var(--shadow-2);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
  }
  .app.side-open .sidebar { transform: none; pointer-events: auto; }
  .app.side-open .backdrop { opacity: 1; pointer-events: auto; }
}
@media (max-width: 599px) {
  :root { --pad-x: 12px; }
  .topbar { min-height: 48px; }
  #usageChip, #stepChip { display: none !important; }
  .msg.user .col { max-width: 88%; }
  .prose th, .prose td { white-space: normal; }
  .cbtn.pill #compLabel { display: none; }
  .model-pill #modelPillText { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
  .composer-card { border-radius: var(--r-lg); }
  .modal-card { width: 100vw; max-width: 100vw; border-radius: var(--r-lg) var(--r-lg) 0 0; align-self: end; }
  .popover { left: 0; right: 0; }
  .act { width: 36px; height: 36px; }          /* 触控目标 ≥36px */
  .uacts { opacity: 1; }
}
@media (min-width: 1440px) { :root { --thread-max: 880px; } }
@media (min-width: 1920px) { :root { --thread-max: 960px; --fs-body: 17px; } }
@media (max-height: 520px) and (orientation: landscape) {
  .foot-hint { display: none; }
  .composer-card textarea { max-height: 72px; }
}
@media (hover: none) { .msg.user .uacts { opacity: 1; } .t-item:hover { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

.act.on{color:var(--accent,#4f46e5)}
.act.on svg{fill:currentColor;fill-opacity:.18}

/* 数学公式（轻量渲染） */
.math{font-family:"Cambria Math","STIX Two Math","Latin Modern Math",serif;font-style:italic;padding:0 .15em;white-space:nowrap}
.math-block{display:block;text-align:center;margin:.6em 0;font-size:1.08em;overflow-x:auto}
.mfrac{display:inline-flex;flex-direction:column;vertical-align:middle;text-align:center;font-size:.9em;line-height:1.15}
.mfrac>span:first-child{border-bottom:1px solid currentColor;padding:0 .2em}
.msqrt{border-top:1px solid currentColor;padding:0 .1em}

/* 生成产物卡片 */
.artifact{margin:8px 0 4px;border:1px solid var(--line,rgba(127,127,127,.25));border-radius:14px;overflow:hidden;max-width:min(520px,100%);background:var(--panel,transparent);animation:ui2-fade .24s ease both}
.artifact img,.artifact video{display:block;width:100%;max-height:360px;object-fit:contain;background:rgba(127,127,127,.08);cursor:zoom-in}
.artifact video{cursor:auto}
.artifact-bar{display:flex;align-items:center;gap:8px;padding:8px 10px}
.artifact-name{flex:1;min-width:0;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.8}
.artifact-btn{font-size:13px;padding:4px 12px;border-radius:999px;border:1px solid currentColor;text-decoration:none;color:inherit;opacity:.85;transition:opacity .14s,transform .14s}
.artifact-btn:hover{opacity:1}.artifact-btn:active{transform:scale(.96)}
@media (prefers-reduced-motion:reduce){.artifact{animation:none}}

@keyframes ui2-fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
