/* AI 对话工作区：内容优先，保留工作台的暖灰、炭黑与棕色焦点。 */
.content.ai-workspace-view { padding: 0; overflow: hidden; min-height: 0; background: var(--card); }
.ai-workspace { --ai-muted: #686660; --ai-line: #e9e7e2; --ai-soft: #f6f5f2; --ai-measure: 780px; --ai-gutter: max(28px, calc((100% - var(--ai-measure)) / 2)); height: 100%; min-height: 0; display: flex; flex-direction: column; color: var(--text); }
.ai-workspace [hidden] { display: none !important; }
.ai-workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex: 0 0 auto; min-height: 65px; padding: 10px 24px; }
.ai-workspace-name { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.ai-workspace-heading h1 { font-size: 18px; line-height: 1.4; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.ai-workspace-heading p { color: var(--ai-muted); font-size: 13px; }
.ai-workspace-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ai-workspace-actions .btn { background: transparent; border-color: transparent; box-shadow: none; min-height: 40px; padding: 8px 12px; border-radius: 10px; }
.ai-workspace-actions .btn:hover { background: var(--ai-soft); }
.ai-workspace .ai-history-toggle { display: none; }
.ai-workspace-layout { position: relative; display: grid; grid-template-columns: 208px minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; background: var(--card); border-top: 1px solid var(--ai-line); }
.ai-conversations { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #f8f7f5; }
.ai-conversations-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 22px 20px 12px; }
.ai-conversations-heading h2 { color: var(--ai-muted); font-size: 12px; font-weight: 500; }
.ai-conversation-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 12px; }
.ai-conversation-item { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px; padding: 11px 12px; cursor: pointer; color: var(--text); font: inherit; margin-bottom: 4px; transition: background .16s; }
.ai-conversation-item span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ai-conversation-item small { color: var(--ai-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ai-conversation-item:hover { background: #efeeea; }
.ai-conversation-item.active { background: #eae7e1; }
.ai-conversation-item.active span { font-weight: 550; }
.ai-history-empty { padding: 14px 12px; color: var(--ai-muted); font-size: 13px; line-height: 1.8; }
.ai-history-note { padding: 16px 20px; color: var(--ai-muted); font-size: 11px; line-height: 1.6; }
.ai-history-error { padding: 12px 16px; color: #9a342d; font-size: 13px; }
.ai-history-error .btn { margin-top: 8px; }
.ai-conversation-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ai-conversation-toolbar { display: flex; align-items: center; gap: 12px; min-height: 54px; flex-shrink: 0; padding: 8px var(--ai-gutter); }
.ai-conversation-toolbar h2 { font-size: 13px; font-weight: 500; color: var(--ai-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conversation-toolbar .icon-btn { color: var(--ai-muted); }
.ai-save-status { color: var(--ai-muted); font-size: 11px; white-space: nowrap; }
.ai-save-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 24px; background: #fff3e4; color: #775123; font-size: 13px; flex-shrink: 0; }
.ai-save-error > span { flex: 1 1 220px; overflow-wrap: anywhere; }
.ai-save-error > div { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-conversation-notice { padding: 4px var(--ai-gutter) 10px; color: var(--ai-muted); font-size: 11px; flex-shrink: 0; }
.ai-chat-suggestions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin: 28px auto 0; max-width: 650px; }
.ai-chat-suggestions button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; font: inherit; font-size: 12px; padding: 8px 13px; border: 1px solid var(--ai-line); border-radius: 20px; color: #56534d; background: var(--card); cursor: pointer; transition: background .16s, border-color .16s; }
.ai-chat-suggestions button .icon { width: 15px; height: 15px; color: #746b5b; }
.ai-chat-suggestions button:hover { border-color: #c9c0b2; background: var(--ai-soft); color: var(--text); }
.ai-conversation-main > .ai-chat-suggestions { display: none; }
.ai-conversation-chat { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.ai-workspace .ai-chat-host.ai-chat-embedded { position: relative; inset: auto; z-index: auto; height: 100%; min-height: 0; width: 100%; }
.ai-workspace .ai-chat-win { position: relative; inset: auto; width: 100%; height: 100%; min-width: 0; max-width: none; max-height: none; border: 0; border-radius: 0; background: var(--card); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; overflow: hidden; }
.ai-workspace .ai-chat-body { padding: 20px var(--ai-gutter) 28px; gap: 28px; overscroll-behavior: contain; scrollbar-color: #b9b4ac transparent; scroll-padding: 24px; overflow-x: hidden; }
.ai-workspace .ai-chat-host.is-empty .ai-chat-body { justify-content: center; padding-top: 24px; padding-bottom: 64px; }
.ai-chat-welcome { width: 100%; margin: auto 0; text-align: center; }
.ai-chat-welcome h2 { font-size: clamp(23px, 2.2vw, 30px); font-weight: 600; line-height: 1.45; letter-spacing: -.025em; text-wrap: balance; }
.ai-chat-welcome p { color: var(--ai-muted); font-size: 14px; line-height: 1.8; max-width: 28em; margin: 12px auto 0; text-wrap: pretty; }
.ai-workspace .ai-msg { max-width: 100%; flex-shrink: 0; font-size: 15px; line-height: 1.85; word-break: normal; overflow-wrap: anywhere; }
.ai-workspace .ai-msg-user { max-width: min(82%, 620px); padding: 11px 18px; border-radius: 20px; color: var(--text); background: #f0eeea; align-self: flex-end; }
.ai-workspace .ai-msg-bot { width: 100%; padding: 0; border: 0; background: transparent; border-radius: 0; }
.ai-workspace .ai-msg-err { color: #a9362e; background: #fdf3f1; border-radius: 12px; padding: 14px 16px; }
.ai-turn { width: 100%; min-width: 0; flex-shrink: 0; display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.ai-turn .ai-unified-quote { width: 100%; min-width: 0; }
.ai-message-content { white-space: normal; }
.ai-message-content > :first-child { margin-top: 0; }
.ai-message-content > :last-child { margin-bottom: 0; }
.ai-message-content p { margin: 0 0 14px; }
.ai-message-content h1, .ai-message-content h2, .ai-message-content h3, .ai-message-content h4 { font-size: 17px; line-height: 1.6; font-weight: 650; margin: 22px 0 10px; }
.ai-message-content h1 { font-size: 21px; }
.ai-message-content h2 { font-size: 19px; }
.ai-message-content ul, .ai-message-content ol { padding-left: 24px; margin: 10px 0 16px; }
.ai-message-content li { padding-left: 3px; margin: 5px 0; }
.ai-message-content strong { font-weight: 650; }
.ai-message-content code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; padding: 2px 5px; border-radius: 4px; background: var(--ai-soft); }
.ai-message-content pre { max-width: 100%; padding: 14px 16px; margin: 14px 0; overflow-x: auto; background: var(--ai-soft); border-radius: 12px; line-height: 1.6; white-space: pre; }
.ai-message-content pre code { padding: 0; background: transparent; }
.ai-message-content a { text-decoration: underline; text-underline-offset: 3px; color: #6e5634; }
.ai-message-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.ai-message-copy { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; border-radius: 8px; padding: 6px 8px; min-height: 32px; color: var(--ai-muted); font: inherit; font-size: 12px; cursor: pointer; }
.ai-message-copy:hover { background: var(--ai-soft); color: var(--text); }
.ai-message-copy .icon { width: 15px; height: 15px; }
.ai-activity { color: var(--ai-muted); font-size: 13px; line-height: 1.6; width: fit-content; max-width: 100%; white-space: normal; }
.ai-activity-summary { display: flex; align-items: center; gap: 8px; list-style: none; min-height: 36px; cursor: pointer; border-radius: 8px; padding: 3px 4px; margin-left: -4px; }
.ai-activity-summary::-webkit-details-marker { display: none; }
.ai-activity-summary:hover { color: var(--text); }
.ai-activity-summary::before { content: ''; width: 7px; height: 7px; flex: 0 0 auto; border: 1.5px solid currentColor; border-radius: 50%; }
.ai-activity[data-state="running"] .ai-activity-summary::before { background: #8a6d43; border-color: #8a6d43; animation: ai-progress-breathe 1.6s ease-in-out infinite; }
.ai-activity-summary::after { content: ''; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); margin: 0 3px 0 2px; transition: transform .16s; }
.ai-activity[open] .ai-activity-summary::after { transform: rotate(45deg) translateY(-2px); }
.ai-activity-label { min-width: 0; overflow-wrap: anywhere; }
.ai-activity-time { color: var(--ai-muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-activity-steps { list-style: none; margin: 8px 0 4px 3px; padding: 0 0 0 18px; border-left: 1px solid #dedbd4; }
.ai-activity-steps li { display: flex; align-items: baseline; gap: 20px; position: relative; padding: 6px 0; }
.ai-activity-steps li::before { content: ''; position: absolute; left: -21px; top: 14px; width: 5px; height: 5px; border-radius: 50%; background: #a39e94; }
.ai-activity-steps li[data-state="running"] { color: #725a37; }
.ai-activity-steps li[data-state="running"]::before { background: #8a6d43; animation: ai-progress-breathe 1.6s ease-in-out infinite; }
.ai-activity-steps li[data-state="error"] { color: #a9362e; }
.ai-activity-steps li[data-state="error"]::before { background: currentColor; }
.ai-step-label { min-width: 0; overflow-wrap: anywhere; }
.ai-step-time { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ai-muted); }
.ai-workspace .ai-chat-composer { flex-shrink: 0; width: calc(100% - 56px); max-width: var(--ai-measure); margin: 0 auto 14px; border: 1px solid #dedbd5; border-radius: 24px; background: #f8f7f5; transition: border-color .18s; }
.ai-workspace .ai-chat-composer:focus-within { border-color: #9a8b73; }
.ai-workspace .ai-chat-input { display: flex; gap: 7px; align-items: flex-end; padding: 10px 12px 6px; background: transparent; border: 0; }
.ai-workspace .ai-chat-input textarea { min-width: 0; min-height: 48px; max-height: 160px; border: 0; border-radius: 0; background: transparent; padding: 10px 4px; font-size: 15px; line-height: 1.7; color: var(--text); caret-color: var(--primary); box-shadow: none; }
.ai-workspace .ai-chat-input textarea:focus { border: 0; outline: 0; box-shadow: none; }
.ai-workspace .ai-chat-input textarea::placeholder { color: #706d66; }
.ai-workspace .ai-chat-attach { width: 40px; height: 44px; border: 0; border-radius: 12px; padding: 10px; color: #68645d; }
.ai-workspace .ai-chat-attach:hover { color: var(--text); background: #eae7e0; }
.ai-workspace .ai-chat-send { width: 38px; height: 38px; padding: 9px; margin: 3px 0; border-radius: 50%; background: #242422; }
.ai-workspace .ai-chat-send .icon { width: 18px; height: 18px; }
.ai-workspace .ai-chat-send.is-stopping { background: #242422; opacity: 1; }
.ai-composer-hint { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0 16px 10px; color: var(--ai-muted); font-size: 11px; line-height: 1.5; }
.ai-workspace .ai-chat-pending { border: 0; padding: 4px 28px 10px; text-align: center; background: transparent; color: var(--ai-muted); }
.ai-workspace .ai-chat-attach-list { max-height: 110px; overflow-y: auto; border: 0; background: transparent; padding: 12px 16px 0; gap: 6px; }
.ai-workspace .ai-attach-item { min-width: 0; max-width: 100%; color: #5e5547; background: #eae6de; border-radius: 10px; }
.ai-workspace .ai-attach-item > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-workspace .ai-attach-item .icon-btn { min-width: 28px; min-height: 28px; color: #5e5547; }
.ai-workspace .ai-chat-attach-list:not([hidden]) + .ai-chat-input { padding-top: 8px; }
.ai-jump-latest { position: absolute; z-index: 2; bottom: 128px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 7px 12px; border: 1px solid #dad7d0; border-radius: 20px; background: #fff; color: #56534c; cursor: pointer; font: inherit; font-size: 12px; }
.ai-jump-latest:hover { background: var(--ai-soft); }
.ai-jump-latest .icon { width: 16px; height: 16px; }
.ai-workspace .ai-draft { width: 100%; max-width: 100%; flex-shrink: 0; border: 1px solid #dfdbd2; border-radius: 14px; background: #fdfcf9; padding: 20px; box-shadow: none; gap: 10px; }
.ai-workspace .ai-draft-title { font-size: 16px; line-height: 1.6; font-weight: 600; }
.ai-workspace .ai-draft-price { font-size: 13px; color: #57534c; line-height: 1.8; }
.ai-workspace .ai-draft-price b { font-size: 26px; color: var(--text); font-weight: 600; letter-spacing: -.025em; }
.ai-workspace .ai-draft-warn { border-radius: 8px; color: #775123; }
.ai-workspace .ai-draft .btn { border-radius: 9px; min-height: 38px; }
.ai-workspace .ai-draft small, .ai-workspace .ai-draft .form-hint { color: var(--ai-muted); }
.ai-workspace .ai-fill-btn { margin-top: 0; }
.ai-workspace .ai-chat-warn { margin: 0 20px 8px; padding: 10px 14px; border: 0; border-radius: 10px; color: #775123; background: #fff3e4; flex-shrink: 0; }
.ai-workspace .ai-chat-drop { border-color: #9b8058; background: rgba(248, 245, 239, .97); color: #755c37; }
.ai-workspace button:disabled { opacity: .5; cursor: default; }
.ai-workspace button:focus-visible, .ai-workspace a:focus-visible, .ai-workspace summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.ai-workspace ::selection { background: #e7ddcb; color: var(--text); }
.ai-workspace * { scrollbar-color: #b9b4ac transparent; }
@keyframes ai-progress-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

@media (max-width: 1100px) {
  .ai-workspace { --ai-gutter: 24px; }
  .ai-workspace-layout { grid-template-columns: 188px minmax(0, 1fr); }
  .ai-workspace-heading { padding-inline: 20px; }
  .ai-workspace .ai-chat-body { padding-inline: 24px; }
  .ai-workspace .ai-chat-composer { width: calc(100% - 48px); }
}
@media (max-width: 900px) {
  .ai-workspace .ai-history-toggle { display: inline-flex; }
  .ai-workspace-layout { grid-template-columns: minmax(0, 1fr); }
  .ai-conversations { position: absolute; inset: 0; z-index: 20; border-right: 0; }
  .ai-history-open .ai-conversation-main { visibility: hidden; }
  .ai-conversations-heading { padding: 12px 20px; }
  .ai-conversation-item { flex-direction: row; align-items: center; gap: 16px; min-height: 52px; }
  .ai-conversation-item span { font-size: 14px; }
  .ai-conversation-item small { flex-shrink: 0; }
}
@media (max-width: 720px) {
  .ai-workspace { --ai-gutter: 18px; }
  .content.ai-workspace-view { padding: 0 0 var(--mobile-nav-h); }
  .ai-workspace-heading { min-height: 55px; padding: 5px 12px; gap: 8px; }
  .ai-workspace-heading h1 { font-size: 17px; }
  .ai-workspace-heading p { display: none; }
  .ai-workspace-actions { gap: 0; }
  .ai-workspace-actions .btn { min-height: 44px; padding: 8px 10px; font-size: 13px; }
  .ai-workspace .icon-btn { min-width: 44px; min-height: 44px; }
  .ai-conversation-toolbar { min-height: 44px; padding: 0 var(--ai-gutter); gap: 8px; }
  .ai-conversation-toolbar h2 { font-size: 12px; }
  .ai-save-status { font-size: 10px; }
  .ai-conversation-notice { padding: 2px var(--ai-gutter) 8px; font-size: 10px; }
  .ai-workspace .ai-chat-body { padding: 16px 18px 24px; gap: 24px; }
  .ai-workspace .ai-chat-host.is-empty .ai-chat-body { padding-top: 12px; padding-bottom: 20px; }
  .ai-chat-welcome h2 { font-size: 23px; max-width: 12em; margin: 0 auto; }
  .ai-chat-welcome p { font-size: 13px; max-width: 23em; margin-top: 12px; }
  .ai-chat-suggestions { gap: 8px; margin-top: 22px; }
  .ai-chat-suggestions button { min-height: 44px; padding: 8px 12px; font-size: 12px; }
  .ai-workspace .ai-msg { font-size: 15px; line-height: 1.85; }
  .ai-workspace .ai-msg-user { max-width: 88%; padding: 10px 15px; border-radius: 18px; }
  .ai-turn { gap: 12px; }
  .ai-message-copy { min-width: 44px; min-height: 44px; }
  .ai-activity-summary { min-height: 44px; }
  .ai-activity-steps li { gap: 12px; }
  .ai-workspace .ai-chat-composer { width: calc(100% - 24px); border-radius: 22px; margin-bottom: 9px; }
  .ai-workspace .ai-chat-input { padding: 7px 7px 3px; gap: 4px; }
  .ai-workspace .ai-chat-input textarea { font-size: 16px; line-height: 1.6; padding: 10px 2px; max-height: 120px; min-height: 46px; }
  .ai-workspace .ai-chat-attach, .ai-workspace .ai-chat-send { width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0; padding: 12px; }
  .ai-workspace .ai-chat-send { border-radius: 50%; }
  .ai-composer-hint { justify-content: center; font-size: 10px; padding: 0 10px 8px; }
  .ai-composer-keys { display: none; }
  .ai-workspace .ai-chat-pending { padding: 2px 16px 6px; font-size: 12px; }
  .ai-workspace .ai-chat-attach-list { padding: 10px 10px 0; max-height: 90px; }
  .ai-workspace .ai-attach-item .icon-btn { min-width: 32px; min-height: 32px; }
  .ai-jump-latest { bottom: 120px; min-height: 44px; }
  .ai-workspace .ai-draft { padding: 16px; }
  .ai-workspace .ai-draft .btn, .ai-workspace .ai-fill-btn, .ai-save-error .btn { min-height: 44px; }
  .ai-save-error { padding: 10px 16px; font-size: 12px; }
  .ai-workspace .ai-chat-warn { margin: 0 12px 8px; font-size: 12px; }
}
@media (max-width: 380px) {
  .ai-workspace { --ai-gutter: 14px; }
  .ai-workspace-actions [data-act="history"] .icon, .ai-workspace-actions [data-act="new"] .icon { display: none; }
  .ai-workspace-actions .btn { padding-inline: 8px; }
  .ai-workspace-heading h1 { font-size: 16px; }
  .ai-chat-welcome h2 { font-size: 21px; }
  .ai-workspace .ai-chat-body { padding-inline: 14px; }
  .ai-chat-suggestions { gap: 6px; }
  .ai-chat-suggestions button { padding-inline: 10px; }
}
@media (max-height: 620px) {
  .ai-workspace .ai-chat-host.is-empty .ai-chat-body { justify-content: flex-start; padding-top: 16px; padding-bottom: 20px; }
  .ai-chat-welcome { margin: 0; }
  .ai-chat-suggestions { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-workspace *, .ai-workspace *::before, .ai-workspace *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
