/* Proposal A: a measured reading column and a single composer surface. */
/* 宽屏：标题移到卡片左侧的独立列，卡片从页面顶距 24px 一直撑到底部 24px（上方不再被标题占用）。 */
/* 左右留白与最大宽度沿用 ai-tools.css 公共规则，保证标题与其它工具页同一条左基线 */
#view-chat .ai-tool-main { padding-top: 24px; }
/* 标题字体与上下边距全部沿用 ai-tools.css 公共规则，与「智能润色」等页面一致 */
#view-chat .ai-tool-workspace { grid-template-columns: minmax(0, 900px) 200px; justify-content: center; gap: 24px; }
@media (min-width: 1181px) {
    #view-chat .ai-tool-main {
        display: grid; grid-template-columns: 160px minmax(0, 900px) 200px;
        grid-template-rows: minmax(0, 1fr); justify-content: start; align-items: stretch; gap: 24px;
    }
    #view-chat .ai-tool-page-head { grid-column: 1; grid-row: 1; align-self: start; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
    /* 让卡片与设置列直接成为主区栅格的子项 */
    #view-chat .ai-tool-workspace { display: contents; }
    #view-chat .chat-shell { grid-column: 2; grid-row: 1; }
    #view-chat .ai-tool-rail { grid-column: 3; grid-row: 1; }
}
#view-chat .chat-shell { --chat-reading-width: 860px; border-radius: 12px; }
#view-chat .ai-conversation-head { min-height: 62px; padding: 13px 24px; gap: 16px; border-bottom-color: transparent; }
#view-chat .chat-conversation-summary { flex: 1; flex-wrap: wrap; gap: 6px 12px; }
#view-chat .chat-conversation-summary > strong { max-width: min(100%, 32em); font-size: 15px; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; }
#view-chat .chat-save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--text-sub); font-size: 11px; line-height: 1.6; }
#view-chat .chat-save-state[data-state="saved"] { color: var(--brand); }
#view-chat .chat-save-state[data-state="saved"]::before { content: '✓'; font-weight: 700; }
#view-chat .chat-save-state[data-state="streaming"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
#view-chat .ai-current-model { display: none; }
#view-chat .chat-new-conversation { flex: none; min-height: 36px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 12px; }
#view-chat .chat-new-conversation svg { width: 16px; height: 16px; }
#view-chat .chat-messages {
    padding: 10px max(24px, calc((100% - var(--chat-reading-width)) / 2)) 24px;
    gap: 28px; scrollbar-gutter: stable; scroll-padding: 20px; overscroll-behavior: contain;
}
#view-chat .chat-msg { flex: 0 0 auto; min-width: 0; gap: 14px; }
#view-chat .chat-msg-assistant { width: 100%; max-width: 100%; }
#view-chat .chat-msg-user { max-width: 85%; margin-bottom: 0; }
#view-chat .chat-msg-avatar { width: 34px; height: 34px; flex-basis: 34px; margin-top: 0; font-size: 13px; }
#view-chat .chat-msg-assistant .chat-msg-avatar { font-family: 'Songti SC', SimSun, serif; font-size: 20px; font-weight: 500; }
#view-chat .chat-msg-user .chat-msg-avatar { width: 28px; height: 28px; flex-basis: 28px; margin-top: 7px; font-size: 11px; }
#view-chat .chat-msg-body { flex: 1; min-width: 0; }
#view-chat .chat-assistant-label { margin: 4px 0 14px; color: var(--text-sub); font-size: 11px; line-height: 1.8; }
#view-chat .chat-msg-content { font-size: 15px; line-height: 1.9; overflow-wrap: anywhere; }
#view-chat .chat-msg-assistant .chat-msg-content { width: 100%; max-width: none; padding: 0; }
#view-chat .chat-msg-user .chat-msg-content { padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); }
#view-chat .chat-msg-content p { margin: 0 0 17px; }
#view-chat .chat-msg-content :is(h1, h2, h3) { margin: 0 0 17px; color: var(--text); font-family: inherit; font-size: 17px; line-height: 1.65; }
#view-chat .chat-msg-content :is(h1, h2, h3):not(:first-child) { margin-top: 22px; }
#view-chat .chat-msg-content pre { width: 100%; box-sizing: border-box; overflow-x: auto; white-space: pre; }
#view-chat .chat-msg-content table { display: block; max-width: 100%; overflow-x: auto; }
#view-chat .chat-msg-actions { flex-wrap: wrap; margin-top: 14px; gap: 7px; opacity: 1; }
#view-chat :is(.chat-msg-copy-btn, .chat-msg-regenerate-btn) { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-sub); font-family: inherit; font-size: 12px; line-height: 1.5; cursor: pointer; }
#view-chat :is(.chat-msg-copy-btn, .chat-msg-regenerate-btn):hover { background: var(--card-2); color: var(--brand); }
#view-chat .chat-msg-copy-btn.copied { color: var(--brand); }
#view-chat .chat-msg-regenerate-btn svg { width: 15px; height: 15px; }
#view-chat .chat-msg-meta:empty { display: none; }
#view-chat .chat-msg-meta { margin-top: 6px; font-size: 10px; color: var(--muted); }
#view-chat .chat-followups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#view-chat .chat-followups button { min-height: 32px; padding: 6px 12px; font-size: 11px; line-height: 1.5; color: var(--text-sub); background: var(--card); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
#view-chat .chat-followups button:hover { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }
#view-chat .chat-composer { width: 100%; max-width: calc(var(--chat-reading-width) + 48px); margin: 0 auto; padding: 5px 24px 15px; box-sizing: border-box; }
#view-chat .chat-input-row { padding: 15px 16px 11px; gap: 9px; border-radius: 14px; border: 1px solid var(--border); background: var(--input-bg); box-shadow: 0 4px 16px #203b2d06; }
#view-chat .chat-input-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
/* Override global !important form focus rules only on the inner textarea. */
#view-chat #chatInput, #view-chat #chatInput:focus, #view-chat #chatInput:focus-visible {
    display: block; flex: none; box-sizing: border-box; width: 100%; min-height: 54px; max-height: min(180px, 22dvh);
    padding: 0; margin: 0; border: 0 !important; border-radius: 0; outline: none !important; box-shadow: none !important;
    background: transparent !important; color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.8;
    resize: none; overflow-y: auto; scrollbar-width: thin;
}
#view-chat #chatInput::placeholder { color: var(--muted); opacity: 1; }
#view-chat .ai-chat-input-tools { flex-wrap: wrap; gap: 6px; }
#view-chat .chat-attach-btn { flex: none; width: auto; height: 33px; min-height: 33px; padding: 5px 6px; gap: 5px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text-sub); font-size: 12px; }
#view-chat .chat-attach-btn:hover { color: var(--brand); background: var(--brand-soft); }
#view-chat .chat-inline-model { display: flex; align-items: center; min-width: 0; max-width: 160px; margin-left: 4px; padding-left: 10px; border-left: 1px solid var(--border); }
#view-chat #chatComposerModel { box-sizing: border-box; width: 100%; min-width: 0; max-width: 150px; height: 31px; padding: 4px 19px 4px 4px; background-color: transparent; border: 0; border-radius: 5px; color: var(--text-sub); font-family: inherit; font-size: 12px; cursor: pointer; text-overflow: ellipsis; }
#view-chat #chatComposerModel option { background: var(--card); color: var(--text); }
#view-chat .chat-generation-tools { display: flex; align-items: center; flex: none; margin-left: auto; gap: 5px; }
#view-chat .chat-send-btn { width: 38px; min-width: 38px; height: 38px; min-height: 38px; padding: 9px; margin: 0; border-radius: 50% !important; background: var(--brand); color: var(--on-brand); }
#view-chat .chat-send-btn svg { width: 20px; height: 20px; }
#view-chat .chat-stop-btn { width: 32px; height: 32px; padding: 7px; background: var(--card-2); color: var(--text); border: 1px solid var(--border); border-radius: 50%; }
#view-chat .chat-control-btn { min-height: 32px; padding: 5px 8px; font-size: 11px; color: var(--text-sub); }
#view-chat .chat-attachments { max-height: 100px; overflow-y: auto; margin: 0 0 2px; scrollbar-width: thin; }
#view-chat .chat-attachment-chip { max-width: 100%; box-sizing: border-box; color: var(--text-sub); background: var(--card-2); border-color: var(--border); border-radius: 7px; }
#view-chat .chat-composer-bar { justify-content: flex-end; margin-top: 7px; gap: 4px 12px; }
#view-chat :is(.chat-composer-hint, .chat-billing-note, .chat-tokens-info) { font-size: 10px; line-height: 1.6; color: var(--muted); }
#view-chat .chat-tokens-info:not(:empty) { flex-basis: 100%; text-align: right; }
#view-chat .ai-tool-settings { border-radius: 12px; }
#view-chat .ai-prompt-section { margin-top: 6px; }
#view-chat .ai-prompt-section h3 { font-size: 13px; }
#view-chat .ai-prompt-list { gap: 3px; }
#view-chat .ai-prompt-list button { min-height: 38px; padding: 8px 0; border: 0; border-radius: 5px; background: transparent; color: var(--brand); }
#view-chat .ai-prompt-list button:hover { padding-inline: 8px; background: var(--brand-soft); }
#view-chat .chat-empty { padding: 24px 12px; }
@media (min-width: 1800px) {
    #view-chat .chat-shell { --chat-reading-width: 860px; }
    #view-chat .chat-msg-content { font-size: 16px; }
}
@media (max-width: 1390px) and (min-width: 1181px) {
    #view-chat .ai-tool-main { grid-template-columns: 160px minmax(0, 900px) 200px; gap: 18px; }
    #view-chat .ai-conversation-head { padding-inline: 20px; }
}
@media (max-width: 1180px) {
    #view-chat .ai-tool-workspace { grid-template-columns: minmax(0, 900px); justify-content: start; gap: 18px; }
    #view-chat .chat-shell { height: min(880px, 88dvh); min-height: 460px; }
}
@media (max-width: 600px) {
    #view-chat .chat-shell { height: min(720px, calc(100dvh - 240px)); min-height: 450px; border-radius: 10px; }
    #view-chat .ai-conversation-head { min-height: 56px; padding: 11px 13px; gap: 8px; }
    #view-chat .chat-conversation-summary { gap: 1px 6px; }
    #view-chat .chat-conversation-summary > strong { font-size: 12px; max-width: 180px; }
    #view-chat .chat-save-state { font-size: 9px; }
    #view-chat .chat-new-conversation { min-height: 32px; padding: 6px 8px; gap: 3px; font-size: 10px; }
    #view-chat .chat-messages { padding: 10px 12px 18px; gap: 23px; }
    #view-chat .chat-msg { gap: 8px; }
    #view-chat .chat-msg-user { max-width: 94%; }
    #view-chat .chat-msg-avatar { width: 26px; height: 26px; flex-basis: 26px; }
    #view-chat .chat-msg-assistant .chat-msg-avatar { font-size: 16px; }
    #view-chat .chat-msg-user .chat-msg-avatar { width: 24px; height: 24px; flex-basis: 24px; }
    #view-chat .chat-assistant-label { margin: 1px 0 10px; font-size: 10px; }
    #view-chat .chat-msg-content { font-size: 14px; }
    #view-chat .chat-msg-content :is(h1, h2, h3) { font-size: 15px; }
    #view-chat .chat-msg-user .chat-msg-content { padding: 10px 12px; }
    #view-chat .chat-composer { padding: 5px 10px 12px; }
    #view-chat .chat-input-row { padding: 12px 10px 9px; border-radius: 12px; }
    #view-chat #chatInput { min-height: 52px; font-size: 13px; }
    #view-chat .chat-attach-btn { padding: 5px 3px; font-size: 11px; gap: 4px; }
    #view-chat .chat-inline-model { flex: 1 1 65px; max-width: 100px; padding-left: 6px; margin-left: 1px; }
    #view-chat #chatComposerModel { font-size: 11px; padding-right: 10px; }
    #view-chat .chat-composer-hint { display: block; font-size: 9px; }
    #view-chat .chat-billing-note, #view-chat .chat-tokens-info { font-size: 9px; }
    #view-chat .ai-chat-input-tools:has(#chatStopBtn:not([hidden])) .chat-generation-tools { flex-basis: 100%; justify-content: flex-end; }
}
@media (max-width: 360px) {
    #view-chat .chat-attach-btn span { display: none; }
    #view-chat .chat-conversation-summary > strong { max-width: 135px; }
}
@media (min-width: 1181px) and (max-height: 700px) {
    #view-chat .ai-tool-main { padding-block: 12px; gap: 10px; }
    #view-chat .ai-tool-page-head h2 { font-size: 22px; }
    #view-chat .ai-tool-page-head p { display: none; }
    #view-chat .ai-conversation-head { min-height: 48px; padding-block: 7px; }
    #view-chat #chatInput { min-height: 42px; }
}
