:root {
  color-scheme: light;
  --ink: #202a2d;
  --muted: #6e7a7d;
  --line: #dfe5e3;
  --panel: #ffffff;
  --canvas: #f3f6f4;
  --sidebar: #eef3f1;
  --teal: #146b68;
  --teal-dark: #0e4d4b;
  --coral: #b94e38;
  --soft-teal: #e4f0ee;
  --soft-coral: #faece8;
  --soft-amber: #fff5dc;
  --shadow: 0 16px 44px rgba(28, 51, 49, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 登录 */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-shell { width: 100%; max-width: 410px; }
.auth-panel { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 38px; box-shadow: var(--shadow); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--teal); color: white; font-weight: 800; font-size: 23px; }
.eyebrow { margin: 0 0 7px; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: 1.45px; }
h1, h2, p { margin-top: 0; }
.auth-panel h1 { margin-bottom: 8px; font-size: 28px; }
.muted { color: var(--muted); font-size: 14px; }
.stack-form { display: grid; gap: 16px; margin-top: 28px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
input, textarea, select { color: var(--ink); background: #fbfcfb; border: 1px solid var(--line); border-radius: 7px; outline: none; }
input:focus, textarea:focus, select:focus, button:focus-visible { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20, 107, 104, .14); outline: none; }
input { width: 100%; min-width: 0; min-height: 42px; padding: 0 12px; }
.primary-button, .send-button, .new-chat-button { border: 0; border-radius: 7px; color: white; background: var(--teal); font-weight: 750; }
.primary-button { min-height: 44px; margin-top: 4px; }
.primary-button:hover:not(:disabled), .send-button:hover:not(:disabled), .new-chat-button:hover:not(:disabled) { background: var(--teal-dark); }
.form-error { margin: 0; color: var(--coral) !important; font-size: 13px; }

/* 应用框架 */
.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 288px minmax(0, 1fr); overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); border-right: 1px solid var(--line); padding: 24px 17px 17px; }
.sidebar-head, .chat-head, .account-line, .connection-line, .composer-actions, .title-line, .header-actions { display: flex; align-items: center; }
.sidebar-head { justify-content: space-between; margin: 0 7px 20px; }
.sidebar-head h1 { margin: 0; font-size: 21px; }
.new-chat-button { display: flex; gap: 8px; justify-content: center; align-items: center; min-height: 42px; margin-bottom: 11px; }
.new-chat-button span { font-size: 19px; line-height: 0; font-weight: 400; }
.conversation-search { margin-bottom: 10px; }
.conversation-search input { min-height: 36px; background: rgba(255, 255, 255, .62); font-size: 12px; }
.conversation-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 10px; padding: 3px; background: #e2e9e6; border-radius: 7px; }
.conversation-tab { min-height: 31px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.conversation-tab.active { color: var(--ink); background: var(--panel); box-shadow: 0 1px 3px rgba(28, 51, 49, .08); }
.workspace-list-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 7px 7px; color: var(--muted); font-size: 11px; }
.workspace-list-head strong { color: var(--ink); font-size: 12px; }
.workspace-detail-head { display: grid; grid-template-columns: 31px minmax(0, 1fr) 31px; align-items: center; gap: 7px; min-height: 48px; margin-bottom: 8px; padding: 5px 4px; background: rgba(255, 255, 255, .48); border: 1px solid var(--line); border-radius: 8px; }
.workspace-detail-head > div { display: grid; min-width: 0; gap: 1px; }
.workspace-detail-head small { color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.workspace-detail-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.workspace-back-button { display: grid; place-items: center; width: 31px; height: 31px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 25px; line-height: 1; }
.workspace-back-button:hover { color: var(--ink); background: #e5ece9; }
.conversation-list { min-height: 0; display: grid; align-content: start; gap: 4px; overflow-y: auto; }
.conversation-item { position: relative; display: grid; gap: 4px; width: 100%; padding: 11px 12px; text-align: left; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 7px; }
.conversation-item:hover { background: #e5ece9; }
.conversation-item.active { background: var(--soft-teal); border-color: #c1d9d5; }
.conversation-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 2px; font-size: 14px; }
.conversation-item small { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 11px; }
.conversation-item .pending-mark { color: var(--teal); }
.workspace-row { display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: center; gap: 3px; border-radius: 8px; }
.workspace-row:hover { background: #e5ece9; }
.workspace-item { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 9px; width: 100%; min-width: 0; padding: 9px 5px 9px 7px; color: var(--ink); background: transparent; border: 0; text-align: left; }
.workspace-symbol { grid-row: 1 / 3; display: grid; place-items: center; width: 34px; height: 34px; align-self: center; color: var(--teal-dark); background: var(--soft-teal); border-radius: 8px; font-size: 16px; }
.workspace-item strong { align-self: end; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.workspace-item small { align-self: start; margin-top: 3px; color: var(--muted); font-size: 10px; }
.workspace-row .workspace-edit-button { opacity: 0; }
.workspace-row:hover .workspace-edit-button, .workspace-row:focus-within .workspace-edit-button { opacity: 1; }
.workspace-color-blue .workspace-symbol { color: #285e96; background: #e4eef9; }
.workspace-color-amber .workspace-symbol { color: #875e0c; background: #fff0c8; }
.workspace-color-coral .workspace-symbol { color: #98432f; background: #fae8e3; }
.workspace-color-purple .workspace-symbol { color: #654a99; background: #eee8fa; }
.load-more-button { min-height: 34px; margin-top: 8px; color: var(--teal); background: transparent; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.archive-entry { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 33px; margin: -4px 0 10px; padding: 0 7px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; font-size: 11px; font-weight: 700; text-align: left; }
.archive-entry:hover, .archive-entry.active { color: var(--ink); background: #e4ebe8; }
.connection-line { gap: 8px; margin-bottom: 12px; line-height: 1.35; }
.status-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #9ba8a5; }
.status-dot.ready { background: #3e9a6d; }
.status-dot.busy { background: #d4982c; }
.status-dot.offline { background: var(--coral); }
.account-line { justify-content: space-between; gap: 8px; }
.admin-model-check { width: 100%; min-height: 34px; margin: 10px 0 8px; color: var(--teal-dark); background: var(--soft-teal); border: 1px solid #c7ded9; border-radius: 7px; font-size: 11px; font-weight: 750; }
.admin-model-check:hover:not(:disabled) { background: #dceeea; border-color: #9fc9c0; }
.text-button { padding: 0; border: 0; color: var(--teal); background: none; font-size: 12px; font-weight: 700; }

/* 会话头部 */
.chat-panel { min-width: 0; min-height: 0; height: 100vh; height: 100dvh; display: grid; grid-template-areas: "header" "banner" "messages" "composer"; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; }
.chat-head { grid-area: header; justify-content: space-between; gap: 15px; min-height: 79px; padding: 16px clamp(20px, 4vw, 64px); background: var(--panel); border-bottom: 1px solid var(--line); }
.conversation-heading { min-width: 0; flex: 1; }
.title-line { min-width: 0; gap: 5px; }
.chat-head h2 { min-width: 0; max-width: 52vw; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }
.workspace-chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: min(190px, 20vw); min-height: 27px; padding: 0 8px; color: var(--teal-dark); background: var(--soft-teal); border: 1px solid #c7ded9; border-radius: 14px; font-size: 10px; font-weight: 750; }
.workspace-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-chip:hover:not(:disabled) { border-color: #94c2ba; background: #dceeea; }
.header-actions { gap: 5px; }
.model-picker { position: relative; display: block; flex: 0 0 auto; }
.model-picker-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: min(230px, 25vw); min-height: 40px; padding: 0 12px; color: var(--ink); background: #fbfcfb; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 750; text-align: left; }
.model-picker-button:hover:not(:disabled), .model-picker-button[aria-expanded="true"] { border-color: #aacbc6; background: white; }
.model-picker-button > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-chevron { flex: 0 0 auto; color: var(--muted); font-size: 16px; transition: transform .16s ease; }
.model-picker-button[aria-expanded="true"] .model-picker-chevron { transform: rotate(180deg); }
.model-menu-layer { position: absolute; z-index: 40; top: calc(100% + 9px); right: 0; width: 320px; }
.model-menu-panel { width: 100%; max-height: min(70vh, 570px); padding: 8px; overflow-y: auto; overscroll-behavior: contain; color: var(--ink); background: rgba(255, 255, 255, .99); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(21, 38, 36, .18); }
.model-menu-section-title { padding: 7px 11px 5px; color: #8a9492; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.model-menu-section-title:not(:first-child) { margin-top: 4px; padding-top: 10px; border-top: 1px solid #edf1ef; }
.model-menu-item:disabled { cursor: not-allowed; opacity: .55; }
.model-menu-unavailable { color: #a05b46 !important; }
.model-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 51px; padding: 7px 10px; color: var(--ink); background: transparent; border: 0; border-radius: 9px; text-align: left; }
.model-menu-item:hover, .model-menu-item:focus-visible, .model-menu-item.active-group { color: var(--ink); background: #f0f4f2; box-shadow: none; }
.model-menu-item.selected { color: var(--teal-dark); background: var(--soft-teal); }
.model-menu-item-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.model-menu-item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 730; }
.model-menu-item-copy small { overflow: hidden; color: #89928f; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; line-height: 1.35; }
.model-menu-check { width: 17px; flex: 0 0 17px; color: var(--teal); font-size: 14px; font-weight: 800; text-align: center; }
.model-menu-arrow { flex: 0 0 auto; color: #66716f; font-size: 20px; line-height: 1; }
.model-submenu { position: absolute; top: 0; right: calc(100% + 9px); width: 355px; }
.model-submenu-head { display: flex; align-items: center; gap: 7px; min-height: 38px; padding: 2px 9px 7px; border-bottom: 1px solid #edf1ef; }
.model-submenu-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.model-menu-back { display: none; width: 31px; height: 31px; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: 7px; font-size: 25px; line-height: 1; }
.model-menu-back:hover { background: #edf2f0; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 7px; font-size: 19px; }
.icon-button:hover:not(:disabled) { color: var(--ink); background: #edf1ef; border-color: var(--line); }
.mini-icon-button { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; color: var(--muted); background: transparent; border: 0; border-radius: 5px; }
.mini-icon-button:hover { color: var(--teal); background: var(--soft-teal); }
.danger-button:hover:not(:disabled) { color: var(--coral); background: var(--soft-coral); border-color: #efd3cb; }
.service-banner { grid-area: banner; padding: 9px clamp(20px, 4vw, 64px); color: #755913; background: var(--soft-amber); border-bottom: 1px solid #efdfb5; font-size: 12px; text-align: center; }
.service-banner.error { color: #8d3828; background: var(--soft-coral); border-color: #efd3cb; }

/* 消息 */
.messages-wrap { grid-area: messages; position: relative; min-height: 0; overflow: hidden; }
.messages { height: 100%; width: 100%; padding: 25px clamp(20px, 5vw, 72px) 42px; overflow-y: auto; overscroll-behavior: contain; }
.load-older-button { position: absolute; z-index: 2; top: 8px; left: 50%; transform: translateX(-50%); min-height: 30px; padding: 0 12px; color: var(--teal); background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 3px 12px rgba(28, 51, 49, .08); font-size: 11px; }
.empty-state { display: grid; place-items: center; min-height: 40vh; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 17px; }
.message { display: flex; flex-direction: column; align-items: flex-start; width: min(100%, calc(930px - clamp(40px, 10vw, 144px))); margin: 0 auto 24px; }
.message.user { align-items: flex-end; }
.message-bubble { max-width: min(760px, 90%); padding: 13px 15px; border-radius: 9px; overflow-wrap: anywhere; line-height: 1.65; font-size: 14px; }
.message.user .message-bubble { color: white; background: var(--teal); white-space: pre-wrap; }
.message.assistant .message-bubble { width: min(760px, 92%); background: var(--panel); border: 1px solid var(--line); }
.message.assistant.pending .message-bubble { color: var(--muted); }
.message.assistant.failed:not(.partial-failed) .message-bubble { background: #fffafa; border-color: #efd3cb; }
.message-meta { display: flex; align-items: center; gap: 8px; max-width: min(760px, 90%); margin-top: 5px; color: #88928f; font-size: 10px; }
.message.user .message-meta { justify-content: flex-end; }
.message-status { font-weight: 700; }
.message-status.failed { color: var(--coral); }
.message.partial-failed .message-status.failed { color: #926815; }
.message-tools { display: flex; gap: 8px; }
.message-tool { padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 10px; }
.message-tool:hover { color: var(--teal); }
.message-attachments { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 180px)); gap: 8px; max-width: min(760px, 90%); margin-bottom: 8px; }
.message.user > .message-attachments { justify-content: end; }
.message-image-button { display: block; padding: 0; overflow: hidden; background: #dde5e2; border: 1px solid var(--line); border-radius: 8px; }
.message-image-button img { display: block; width: 100%; height: 130px; object-fit: cover; }
.message-file-card { display: flex; align-items: center; gap: 10px; min-width: min(300px, 78vw); max-width: min(430px, 90vw); padding: 10px 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.message-file-card:hover { color: var(--teal); border-color: var(--teal); background: var(--soft-teal); }
.message-file-icon { display: grid; place-items: center; flex: 0 0 44px; height: 44px; padding: 3px; color: white; background: var(--teal); border-radius: 7px; font-size: 10px; font-weight: 800; overflow: hidden; }
.message-file-body { min-width: 0; }
.message-file-body strong { display: block; overflow: hidden; color: inherit; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.message-file-body small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.message-error-card { display: flex; align-items: flex-start; gap: 10px; width: min(760px, 92%); margin-top: 9px; padding: 11px 13px; color: #8d3828; background: var(--soft-coral); border: 1px solid #efd3cb; border-radius: 9px; font-size: 12px; line-height: 1.55; }
.message-error-icon { display: grid; place-items: center; flex: 0 0 20px; height: 20px; margin-top: 1px; color: white; background: var(--coral); border-radius: 50%; font-size: 12px; font-weight: 850; }
.message-error-copy { min-width: 0; overflow-wrap: anywhere; }
.message-sources-button { display: flex; align-items: center; gap: 9px; width: min(760px, 92%); min-height: 42px; margin-top: 9px; padding: 7px 11px; color: var(--ink); text-align: left; background: #f8faf9; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 750; }
.message-sources-button:hover { color: var(--teal); background: var(--soft-teal); border-color: #b8d5d0; }
.message-source-badges { display: flex; flex: 0 0 auto; padding-left: 4px; }
.message-source-badge { display: grid; place-items: center; width: 22px; height: 22px; margin-left: -4px; color: white; background: var(--teal); border: 2px solid white; border-radius: 50%; font-size: 9px; font-weight: 850; }
.message-source-badge:nth-child(2) { background: #d68b24; }
.message-source-badge:nth-child(3) { background: #4c78b8; }
.message-sources-chevron { margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; }
.message-attachments.user-attachments { grid-template-columns: minmax(0, 1fr); }
.message-attachments.assistant-images { width: 100%; max-width: 100%; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); margin: 12px 0; }
.assistant-images .message-image-button { width: 100%; background: #eef3f1; }
.assistant-images .message-image-button img { width: 100%; height: auto; max-height: 680px; object-fit: contain; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 11px; }
.markdown .remote-image-link { display: block; width: fit-content; max-width: 100%; margin: 10px 0; }
.markdown .remote-inline-image { display: block; max-width: 100%; max-height: 520px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #eef3f1; }
.markdown .sources-heading { margin-top: 18px; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.markdown .source-card-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.markdown .source-card-list li { margin: 0; }
.markdown .source-card-list a { display: block; height: 100%; padding: 10px 12px; color: var(--ink); background: #f4f7f6; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; overflow-wrap: anywhere; }
.markdown .source-card-list a:hover { color: var(--teal); border-color: var(--teal); background: #edf6f3; }
.markdown h1, .markdown h2, .markdown h3 { margin: 16px 0 8px; line-height: 1.3; }
.markdown h1 { font-size: 19px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15px; }
.markdown ul, .markdown ol { margin: 7px 0 12px; padding-left: 22px; }
.markdown li { margin: 3px 0; }
.markdown blockquote { margin: 10px 0; padding: 5px 12px; color: var(--muted); border-left: 3px solid #bad1cd; }
.markdown code { padding: 2px 5px; background: #edf2f0; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }
.code-block { position: relative; margin: 12px 0; overflow: hidden; background: #182321; border-radius: 8px; }
.code-block pre { margin: 0; padding: 35px 14px 14px; overflow: auto; color: #eaf2f0; line-height: 1.55; }
.code-block pre code { padding: 0; color: inherit; background: transparent; }
.code-language { position: absolute; top: 8px; left: 12px; color: #9bb0ab; font-size: 10px; }
.copy-code { position: absolute; top: 6px; right: 8px; padding: 3px 7px; color: #d6e3df; background: #2b3c38; border: 0; border-radius: 4px; font-size: 10px; }
.markdown a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.markdown table { width: 100%; margin: 10px 0; border-collapse: collapse; font-size: 12px; }
.markdown th, .markdown td { padding: 6px 8px; border: 1px solid var(--line); text-align: left; }
.markdown th { background: #f0f4f2; }
.scroll-bottom-button { position: absolute; right: clamp(20px, 5vw, 72px); bottom: 12px; z-index: 2; min-height: 32px; padding: 0 12px; color: var(--teal); background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); font-size: 11px; }

/* 输入与附件 */
.composer { grid-area: composer; width: min(100%, 930px); margin: 0 auto; padding: 0 clamp(20px, 5vw, 72px) max(18px, env(safe-area-inset-bottom)); }
.composer.dragging { background: var(--soft-teal); outline: 2px dashed var(--teal); outline-offset: -8px; }
.composer textarea { display: block; width: 100%; min-height: 54px; max-height: 180px; padding: 14px 15px; resize: none; line-height: 1.5; }
.composer-actions { gap: 10px; min-height: 45px; }
.composer-hint { margin-right: auto; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.file-button { position: relative; font-size: 22px; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.image-mode-button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 10px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 11px; font-weight: 700; }
.image-mode-button[aria-pressed="true"] { color: #6f42c1; background: #f3edff; border-color: #cdbaf3; }
.image-mode-button:disabled { opacity: .5; cursor: not-allowed; }
.send-button { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 15px; }
.send-button span:first-child { font-size: 19px; line-height: 1; }
/* 上传原图期间发送按钮变成红色 × 取消按钮 */
.send-button.cancel-upload { background: var(--coral); }
.send-button.cancel-upload:hover:not(:disabled), .send-button.cancel-upload:focus-visible:not(:disabled) { background: #a03f2c; }
.attachment-strip { display: flex; gap: 8px; overflow-x: auto; padding: 3px 1px 8px; }
.attachment-card { position: relative; flex: 0 0 92px; height: 76px; overflow: hidden; background: #e5ece9; border: 1px solid var(--line); border-radius: 8px; }
.attachment-card img { width: 100%; height: 100%; object-fit: cover; }
.file-attachment-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); grid-template-rows: 1fr 1fr; column-gap: 8px; flex-basis: 190px; padding: 10px 32px 9px 10px; background: var(--panel); }
.attachment-file-type { display: grid; grid-row: 1 / 3; place-items: center; height: 42px; align-self: center; padding: 2px; color: white; background: var(--teal); border-radius: 6px; overflow: hidden; font-size: 9px; font-weight: 800; }
.attachment-file-name { align-self: end; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.attachment-file-size { align-self: start; margin-top: 3px; color: var(--muted); font-size: 9px; }
.attachment-remove { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 23px; height: 23px; padding: 0; color: white; background: rgba(22, 32, 30, .75); border: 0; border-radius: 50%; }
.attachment-count { flex: 0 0 auto; align-self: center; color: var(--muted); font-size: 11px; }

/* 提示和图片预览 */
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 14px; transform: translateX(-50%); max-width: min(90vw, 620px); padding: 11px 15px; color: white; background: #263633; border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; }
.toast .text-button { color: #8ed2ca; white-space: nowrap; }
.workspace-dialog { width: min(92vw, 520px); padding: 0; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 28px 80px rgba(14, 30, 27, .28); }
.workspace-dialog::backdrop { background: rgba(15, 27, 24, .42); backdrop-filter: blur(2px); }
.workspace-dialog form { display: grid; gap: 15px; padding: 21px 23px 20px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 2px 0 12px; font-size: 20px; }
.dialog-field { display: grid; gap: 7px; color: var(--ink); font-size: 12px; }
.dialog-field textarea { width: 100%; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.dialog-field select { width: 100%; min-height: 42px; padding: 0 10px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-copy { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 9px; padding-top: 5px; }
.dialog-actions.compact { grid-template-columns: 1fr auto auto; }
.dialog-actions button { min-height: 38px; margin: 0; padding: 0 14px; border-radius: 8px; font-size: 12px; font-weight: 750; }
.dialog-actions .secondary-button { color: var(--muted); background: white; border: 1px solid var(--line); }
.dialog-actions .primary-button { color: white; background: var(--teal); border: 1px solid var(--teal); }
.dialog-delete-button { color: var(--coral); background: var(--soft-coral); border: 1px solid #efd3cb; }
.model-update-dialog { width: min(92vw, 590px); max-height: min(86vh, 720px); padding: 0; overflow: hidden; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 28px 80px rgba(14, 30, 27, .28); }
.model-update-dialog::backdrop { background: rgba(15, 27, 24, .42); backdrop-filter: blur(2px); }
.model-update-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.model-update-head h2 { margin: 3px 0 0; font-size: 20px; }
.model-update-summary { margin: 0; padding: 16px 24px 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.model-update-list { display: grid; gap: 12px; max-height: 380px; padding: 4px 24px 12px; overflow-y: auto; }
.model-update-section { padding: 11px 13px; background: #f7f9f8; border: 1px solid var(--line); border-radius: 9px; }
.model-update-section h3 { margin: 0 0 7px; color: var(--teal-dark); font-size: 12px; }
.model-update-section ul { display: grid; gap: 5px; margin: 0; padding-left: 18px; }
.model-update-section li { font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.model-update-section small { display: block; color: var(--muted); font-size: 10px; }
.model-update-note { margin: 0; padding: 8px 24px 14px; color: #806522; font-size: 11px; line-height: 1.55; }
.model-update-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.model-update-actions button { min-height: 38px; padding: 0 14px; border-radius: 8px; font-size: 12px; font-weight: 750; }
.model-update-actions .secondary-button { color: var(--muted); background: white; border: 1px solid var(--line); }
.model-update-actions .primary-button { color: white; background: var(--teal); border: 1px solid var(--teal); }
.image-dialog { width: min(94vw, 1100px); max-height: 92vh; padding: 0; overflow: visible; background: transparent; border: 0; }
.image-dialog::backdrop { background: rgba(10, 18, 16, .78); }
.image-dialog img { display: block; max-height: 88vh; margin: auto; object-fit: contain; border-radius: 7px; box-shadow: var(--shadow); }
.image-dialog-close { position: fixed; top: 16px; right: 20px; width: 42px; height: 42px; color: white; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.4); border-radius: 50%; font-size: 25px; }
.source-drawer-layer { position: fixed; z-index: 30; inset: 0; display: flex; justify-content: flex-end; }
.source-drawer-backdrop { position: absolute; inset: 0; width: 100%; padding: 0; background: rgba(17, 29, 27, .28); border: 0; opacity: 0; transition: opacity .18s ease; }
.source-drawer { position: relative; display: flex; flex-direction: column; width: min(430px, 92vw); height: 100%; color: var(--ink); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(22, 42, 39, .15); transform: translateX(100%); transition: transform .2s ease; outline: none; }
.source-drawer-layer.open .source-drawer-backdrop { opacity: 1; }
.source-drawer-layer.open .source-drawer { transform: translateX(0); }
.source-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 24px 22px 17px; border-bottom: 1px solid var(--line); }
.source-drawer-head h2 { margin: 0 0 4px; font-size: 22px; }
.source-drawer-head p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.source-drawer-close { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 50%; font-size: 25px; line-height: 1; }
.source-drawer-close:hover { color: var(--ink); background: #edf2f0; border-color: var(--line); }
.source-drawer-list { min-height: 0; display: grid; align-content: start; gap: 10px; padding: 16px 18px 30px; overflow-y: auto; overscroll-behavior: contain; }
.source-drawer-card { display: grid; gap: 7px; padding: 13px 14px; color: var(--ink); background: #fafcfb; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.source-drawer-card:hover { border-color: #a9cec8; background: var(--soft-teal); }
.source-drawer-card-head { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font-size: 10px; }
.source-drawer-card-badge { display: grid; place-items: center; flex: 0 0 22px; height: 22px; color: white; background: var(--teal); border-radius: 6px; font-size: 9px; font-weight: 850; }
.source-drawer-provider { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-drawer-cited { margin-left: auto; padding: 2px 6px; color: var(--teal); background: var(--soft-teal); border-radius: 9px; font-size: 9px; font-weight: 750; }
.source-drawer-card strong { font-size: 13px; line-height: 1.45; }
.source-drawer-detail { display: -webkit-box; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.mobile-only { display: none; }
.mobile-backdrop { display: none; }

@media (max-width: 760px) {
  .auth-page { padding: 16px; }
  .auth-shell { width: calc(100vw - 32px); max-width: 410px; }
  .auth-panel { padding: 30px 24px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 12; inset: 0 auto 0 0; width: min(87vw, 320px); min-height: 100vh; min-height: 100dvh; transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-backdrop { position: fixed; z-index: 11; inset: 0; background: rgba(23, 35, 34, .28); }
  .mobile-backdrop.open { display: block; }
  .mobile-only { display: inline-grid; }
  .chat-head { min-height: 66px; gap: 5px; padding: 11px 10px; }
  .chat-head > .conversation-heading { min-width: 0; flex: 1; }
  .chat-head h2 { max-width: 34vw; font-size: 16px; }
  .workspace-chip { max-width: 31vw; }
  .chat-head .eyebrow { display: none; }
  .header-actions { gap: 1px; }
  .model-picker-button { width: min(128px, 34vw); min-height: 38px; padding: 0 9px; gap: 6px; font-size: 10px; }
  .model-menu-layer { position: fixed; top: 67px; right: 10px; left: 10px; width: auto; }
  .model-menu-panel { width: 100%; max-height: calc(100dvh - 82px); border-radius: 12px; }
  .model-submenu { position: static; width: 100%; }
  .model-menu-layer.submenu-open .model-menu-root { display: none; }
  .model-menu-back { display: grid; place-items: center; }
  .mini-icon-button { display: none; }
  .icon-button { width: 40px; height: 40px; }
  .messages { padding: 21px 14px 32px; }
  .message-bubble { max-width: 92%; }
  .message.assistant .message-bubble { width: 96%; max-width: 96%; }
  .message-error-card, .message-sources-button { width: 96%; max-width: 96%; }
  .message-attachments.user-images { max-width: 94%; grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .message-attachments.user-attachments { max-width: 94%; grid-template-columns: minmax(0, 1fr); }
  .message-attachments.assistant-images { max-width: 100%; grid-template-columns: 1fr; }
  .assistant-images .message-image-button img { max-height: 70vh; }
  .composer { padding: 0 12px max(9px, env(safe-area-inset-bottom)); background: var(--canvas); }
  .composer-hint { max-width: 42vw; }
  .image-mode-button span:last-child { display: none; }
  .image-mode-button { width: 36px; flex: 0 0 36px; justify-content: center; padding: 0; font-size: 16px; }
  .send-button { width: 44px; flex: 0 0 44px; justify-content: center; padding: 0; }
  .send-label { display: none; }
  .send-button.cancel-upload span:first-child { font-size: 22px; font-weight: 800; }
  .service-banner { padding: 8px 12px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .model-update-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 36px); }
  .model-update-head, .model-update-summary, .model-update-list, .model-update-note, .model-update-actions { padding-left: 16px; padding-right: 16px; }
  .model-update-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .workspace-dialog { width: calc(100vw - 24px); }
  .workspace-dialog form { padding: 18px 16px 16px; }
  .dialog-grid { grid-template-columns: 1fr; }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
  .dialog-actions > span { display: none; }
  .dialog-delete-button { grid-column: 1 / 3; }
  .source-drawer-layer { align-items: flex-end; }
  .source-drawer { width: 100%; height: min(82dvh, 720px); border-top: 1px solid var(--line); border-left: 0; border-radius: 16px 16px 0 0; transform: translateY(100%); }
  .source-drawer-layer.open .source-drawer { transform: translateY(0); }
  .source-drawer-head { padding: 18px 17px 14px; }
  .source-drawer-list { padding: 13px 13px max(24px, env(safe-area-inset-bottom)); }
}

@media (max-width: 400px) {
  .chat-head { padding-right: 6px; padding-left: 6px; }
  .workspace-chip { width: 28px; max-width: 28px; flex: 0 0 28px; justify-content: center; padding: 0; }
  .workspace-chip span:last-child { display: none; }
  .model-picker-button { width: min(102px, 32vw); padding: 0 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
