/* Keep the conversation typography and controls independent of the page underneath. */
body.ai-dialogue-active #aiDialogueFlow.chat-v2 {
  --chat-font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --ds-font: var(--chat-font);
  --chat-ink: #25312d;
  --chat-muted: #6f7975;
  --chat-accent: #39765f;
  position: fixed; inset: auto 0; top: var(--chat-top, 0px); height: var(--chat-height, 100dvh);
  z-index: 3000; background: #fff; overflow: hidden; font-family: var(--chat-font); color: var(--chat-ink);
  -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility;
}
#aiDialogueFlow.chat-v2[hidden], #aiDialogueFlow.chat-v2.hidden { display: none !important; }
body.ai-dialogue-active #imagePreviewBackdrop { z-index: 3100; }
body.ai-dialogue-active #imagePreviewSheet { z-index: 3101; grid-template-rows: auto minmax(0, 1fr); }
body.ai-dialogue-active #imagePreviewSheet .image-preview-actions { display: none; }
#aiDialogueFlow.chat-v2 .chat-shell { display: flex; flex-direction: column; max-width: 800px; height: 100%; margin: 0 auto; }
.chat-v2 * { box-sizing: border-box; letter-spacing: 0; }
.chat-v2 button, .chat-v2 textarea { font-family: var(--chat-font); }
.chat-v2 button { cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
.chat-v2 .app-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.chat-v2 .chat-head { flex: 0 0 auto; display: grid; grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr); align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top, 0px)) 20px 10px; background: #fff; border-bottom: 1px solid #f2f4f3; }
.chat-v2 .chat-head h2 { flex: 1; margin: 0; color: var(--chat-ink); text-align: center; font-size: 17px; line-height: 1.4; font-weight: 600; }
.chat-v2 .chat-head button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; padding: 0; background: transparent; border: 0; border-radius: 8px; color: #64716a; box-shadow: none; }
.chat-v2 .chat-head button:hover { background: #f3f6f4; color: var(--chat-ink); }
.chat-v2 .chat-head [data-chat-close] { justify-self: start; }
.chat-v2 .chat-head [data-chat-new] { display: flex; align-items: center; justify-content: center; justify-self: end; gap: 6px; width: 88px; font-size: 13px; font-weight: 400; }
.chat-v2 .chat-reading-area { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-v2 .chat-jump { position: absolute; bottom: 12px; left: calc(50% - 22px); width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #dce4de; border-radius: 50%; background: #fff; color: #39765f; box-shadow: 0 2px 10px #142d1e0d; z-index: 2; }
.chat-v2 .chat-jump[hidden] { display: none; }
.chat-v2 .chat-messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 28px 28px 12px; scroll-behavior: auto; scrollbar-width: thin; scrollbar-color: #dce3de transparent; }
.chat-v2 .chat-welcome { min-height: 72%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 0; text-align: center; }
.chat-v2 .chat-welcome-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px; color: var(--chat-accent); }
.chat-v2 .chat-welcome-mark .app-icon { width: 32px; height: 32px; stroke-width: 1.35; }
.chat-v2 .chat-welcome h3 { margin: 0; color: var(--chat-ink); font-size: 24px; font-weight: 600; line-height: 1.65; }
.chat-v2 .chat-welcome h3 span { display: block; margin-bottom: 3px; color: var(--chat-muted); font-size: 18px; font-weight: 400; }
.chat-v2 .chat-message { margin-bottom: 32px; max-width: 100%; min-width: 0; }
.chat-v2 .chat-message.user { margin-left: auto; width: fit-content; max-width: 86%; background: #f0f3f1; padding: 12px 16px; border-radius: 8px; }
.chat-v2 .chat-text { color: var(--chat-ink); line-height: 1.8; font-size: 16px; overflow-wrap: anywhere; word-break: normal; user-select: text; }
.chat-v2 .user .chat-text { font-size: 15px; line-height: 1.75; white-space: pre-wrap; }
.chat-v2 .chat-text > :first-child { margin-top: 0; }
.chat-v2 .chat-text > :last-child { margin-bottom: 0; }
.chat-v2 .chat-text p { margin: 0 0 12px; }
.chat-v2 .chat-text h1, .chat-v2 .chat-text h2, .chat-v2 .chat-text h3, .chat-v2 .chat-text h4 { margin: 20px 0 9px; font-size: 18px; font-weight: 600; line-height: 1.65; }
.chat-v2 .chat-text ul, .chat-v2 .chat-text ol { padding-left: 24px; margin: 10px 0 18px; }
.chat-v2 .chat-text li { margin: 5px 0; }
.chat-v2 .chat-text li > p { margin-bottom: 8px; }
.chat-v2 .chat-text strong { font-weight: 600; }
.chat-v2 .chat-text blockquote { margin: 16px 0; padding: 2px 0 2px 14px; border-left: 2px solid #c5d5cb; color: #64716a; }
.chat-v2 .chat-text hr { margin: 24px 0; border: 0; border-top: 1px solid #e7ece8; }
.chat-v2 .chat-text pre { padding: 16px; max-width: 100%; overflow-x: auto; border: 1px solid #e5eae6; background: #f6f8f6; border-radius: 6px; line-height: 1.65; white-space: pre; }
.chat-v2 .chat-text code { font-family: Consolas, Menlo, monospace; font-size: 13px; }
.chat-v2 .chat-text :not(pre) > code { padding: 2px 4px; background: #f1f4f2; border-radius: 3px; }
.chat-v2 .chat-text a { color: var(--chat-accent); text-decoration: underline; text-underline-offset: 3px; }
.chat-v2 .chat-text table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 14px; }
.chat-v2 .chat-text td, .chat-v2 .chat-text th { min-width: 120px; padding: 9px 12px; border: 1px solid #e2e8e3; vertical-align: top; overflow-wrap: anywhere; }
.chat-v2 .chat-text th { background: #f5f7f5; font-weight: 600; }
.chat-v2 .chat-message-tools { min-height: 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin-top: 10px; color: var(--chat-muted); }
.chat-v2 .chat-message-tools:empty { display: none; }
.chat-v2 .chat-message-tools button { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #77827b; box-shadow: none; }
.chat-v2 .chat-message-tools .app-icon { width: 17px; height: 17px; }
.chat-v2 .chat-message-tools small { margin: 0 8px; font-size: 12px; }
.chat-v2 button:disabled { cursor: default; opacity: .35; }
.chat-v2 .chat-message-tools button:not(:disabled):hover { background: #f1f5f2; color: var(--chat-accent); }
.chat-v2 .chat-message-tools [aria-label="已复制"] { color: #39765f; background: #eff6f1; }
.chat-v2 .chat-version-nav { display: flex; align-items: center; gap: 0; margin-left: 8px; padding-left: 8px; border-left: 1px solid #e5ebe6; white-space: nowrap; }
.chat-v2 .chat-version-nav span { min-width: 56px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.chat-v2 [data-direction="1"] .app-icon { transform: rotate(180deg); }
.chat-v2 .chat-quote { display: flex; align-items: center; gap: 8px; padding: 9px 10px; margin: 2px 2px 6px; border-left: 2px solid #6b9b82; background: #f3f7f4; border-radius: 4px; }
.chat-v2 .chat-quote[hidden] { display: none; }
.chat-v2 .chat-quote > div { flex: 1; min-width: 0; }
.chat-v2 .chat-quote small, .chat-v2 .chat-sent-quote small { color: #68776d; font-size: 12px; }
.chat-v2 .chat-quote p, .chat-v2 .chat-sent-quote p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; margin: 3px 0 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.chat-v2 .chat-quote button { flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; color: #6f7b73; border-radius: 6px; }
.chat-v2 .chat-quote button .app-icon { transform: rotate(45deg); }
.chat-v2 .chat-sent-quote { margin: 0 0 9px; padding: 0 0 0 10px; border-left: 2px solid #bdcfc0; color: #637368; }
.chat-v2 button.chat-sent-quote { display: block; width: 100%; text-align: left; border: 0; border-left: 2px solid #bdcfc0; background: transparent; border-radius: 0; padding: 0 0 0 10px; font-weight: 400; }
.chat-v2 .chat-thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--chat-muted); font-size: 14px; }
.chat-v2 .chat-thinking-dots { display: inline-flex; align-items: center; gap: 4px; }
.chat-v2 .chat-thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: #6c9580; animation: chat-think 1.4s ease-in-out infinite; }
.chat-v2 .chat-thinking-dots i:nth-child(2) { animation-delay: 150ms; }
.chat-v2 .chat-thinking-dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes chat-think { 0%, 70%, 100% { opacity: .35; } 35% { opacity: 1; } }
.chat-v2 .chat-photo { display: block; border: 0; padding: 0; margin-bottom: 10px; border-radius: 6px; overflow: hidden; background: #e8eee9; max-width: 100%; }
.chat-v2 .chat-photo img { display: block; width: 200px; height: 200px; max-width: 100%; object-fit: contain; }
.chat-v2 .chat-compose-wrap { flex: 0 0 auto; padding: 12px 28px max(20px, env(safe-area-inset-bottom, 0px)); background: #fff; }
.chat-v2 .chat-composer { display: block; background: #fff; border: 1px solid #dce4de; border-radius: 8px; padding: 8px; box-shadow: 0 4px 18px #142d1e08; transition: border-color 140ms ease, box-shadow 140ms ease; }
.chat-v2 .chat-composer:focus-within { border-color: #7c9f89; box-shadow: 0 0 0 2px #54826a0d, 0 4px 18px #142d1e08; }
.chat-v2 .chat-composer textarea { display: block; width: 100%; min-width: 0; min-height: 44px; max-height: 174px; overflow-y: auto; padding: 9px 8px; line-height: 26px; font: inherit; font-family: var(--chat-font); font-size: 16px; resize: none; border: 0; outline: none; box-shadow: none; background: transparent; color: var(--chat-ink); }
.chat-v2 .chat-composer textarea::placeholder { color: #87918b; opacity: 1; }
.chat-v2 .chat-composer textarea:focus-visible { outline: none; }
.chat-v2 .chat-compose-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.chat-v2 .chat-composer button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 0; border-radius: 50%; box-shadow: none; background: transparent; color: #768279; }
.chat-v2 .chat-composer button:not(:disabled):hover { background: #eef3ef; color: var(--chat-accent); }
#aiDialogueFlow.chat-v2 .chat-composer .store-agent-send { width: 44px; height: 44px; background: #243b30; color: #fff; box-shadow: none; }
#aiDialogueFlow.chat-v2 .chat-composer .store-agent-send:not(:disabled):hover { background: #375645; color: #fff; }
.chat-v2 .chat-stop { width: 13px; height: 13px; background: currentColor; border-radius: 2px; }
.chat-v2 .chat-reference { display: flex; align-items: center; gap: 10px; padding: 2px 4px 8px; }
.chat-v2 .chat-reference[hidden], .chat-v2 .chat-notice[hidden] { display: none; }
.chat-v2 .chat-reference button { border: 0; background: transparent; padding: 0; min-width: 40px; min-height: 40px; display: grid; place-items: center; }
.chat-v2 .chat-reference button[data-chat-preview] { width: 52px; height: 52px; flex-basis: 52px; border-radius: 5px; overflow: hidden; }
.chat-v2 .chat-reference img { display: block; height: 52px; width: 52px; object-fit: cover; }
.chat-v2 .chat-reference span { flex: 1; min-width: 0; overflow-wrap: anywhere; color: #68776d; font-size: 12px; }
.chat-v2 .chat-error, .chat-v2 .chat-notice { color: #a04a38; font-size: 13px; line-height: 1.7; }
.chat-v2 .chat-error { margin: 8px 0 0; }
.chat-v2 .chat-note { margin: 8px 0 0; color: #6d7b71; font-size: 12px; line-height: 1.7; }
.chat-v2 .chat-notice { padding: 8px 28px; display: flex; align-items: center; gap: 8px; }
.chat-v2 .chat-notice button { flex: 0 0 auto; min-height: 40px; border: 0; background: transparent; color: inherit; }
.chat-v2 button:focus-visible { outline: 2px solid #6c937c; outline-offset: 2px; }
.chat-v2 .chat-jump:hover { background: #f2f7f3; }
.chat-v2.chat-compact .chat-composer textarea { max-height: 70px; }
.chat-v2.chat-compact .chat-quote p { -webkit-line-clamp: 1; }
.chat-v2.chat-compact .chat-reference button[data-chat-preview], .chat-v2.chat-compact .chat-reference img { width: 40px; height: 40px; flex-basis: 40px; }
#aiDialogueFlow.chat-v2 .chat-quote .chat-quote-open { display: block; flex: 1; min-width: 0; width: auto; height: auto; padding: 0; text-align: left; font-weight: 400; border-radius: 0; background: transparent; color: #637368; }
.chat-v2 .chat-quote-remove .app-icon { transform: rotate(45deg); }
body.ai-dialogue-active #appActionConfirmation { z-index: 3400; }
body.ai-dialogue-active #appActionConfirmation [data-app-action-confirm]:not(.is-danger) { border-color: #243b30; background: #243b30; }
body.ai-dialogue-active #appActionConfirmation [data-app-action-cancel] { border-color: #dce4de; background: #f5f7f5; color: #25312d; }
body.ai-dialogue-active #appActionConfirmation button:focus-visible { outline-color: #6c937c; }
.chat-quote-dialog { position: fixed; inset: 0; z-index: 3300; display: grid; place-items: center; padding: 20px; background: #12251b66; font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; color: #25312d; }
.chat-quote-dialog section { width: min(640px, 100%); max-height: min(calc(var(--chat-dialog-height, 100dvh) - 40px), 760px); display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 8px; box-shadow: 0 12px 48px #12251b24; }
.chat-quote-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #edf1ee; }
.chat-quote-dialog h3 { margin: 0; font-size: 16px; font-weight: 600; }
.chat-quote-dialog button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 0; background: transparent; color: #68776d; border-radius: 6px; }
.chat-quote-dialog .app-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; transform: rotate(45deg); }
.chat-quote-full { min-height: 0; overflow: auto; padding: 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.8; overscroll-behavior: contain; }
.chat-quote-dialog button:focus-visible, .chat-quote-full:focus-visible { outline: 2px solid #6c937c; outline-offset: -3px; }
@media (max-width: 480px) {
  .chat-v2 .chat-head { padding-inline: 12px; }
  .chat-v2 .chat-messages { padding: 26px 20px 8px; }
  .chat-v2 .chat-compose-wrap { padding: 8px 12px max(12px, env(safe-area-inset-bottom, 0px)); }
  .chat-v2 .chat-notice { padding-inline: 20px; }
}
@media (max-height: 600px) {
  .chat-v2 .chat-composer textarea { max-height: 70px; }
  .chat-v2 .chat-welcome { min-height: 60%; padding-block: 12px; }
  .chat-v2 .chat-quote p { -webkit-line-clamp: 1; }
  .chat-v2 .chat-reference button[data-chat-preview], .chat-v2 .chat-reference img { width: 40px; height: 40px; flex-basis: 40px; }
}
@media (prefers-reduced-motion: reduce) { .chat-v2 button, .chat-v2 .chat-composer { transition: none; } .chat-v2 .chat-thinking-dots i { animation: none; opacity: .7; } }
