:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #101319;
  --panel-2: #151922;
  --panel-3: #1b202a;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #f5f7fb;
  --muted: #8d95a5;
  --blue: #5d7cff;
  --purple: #8d63ff;
  --green: #3dd598;
  --danger: #ff6b78;
  --shadow: 0 22px 70px rgba(0, 0, 0, .35);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.brand-large { justify-content: center; font-size: 24px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: white; background: linear-gradient(140deg, #3be7d1, #6d65ff 58%, #d35cff); box-shadow: 0 8px 25px rgba(98, 95, 255, .3); }
.icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px; min-width: 30px; min-height: 30px; }
.icon-button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.theme-toggle { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--panel-2); color: var(--text); cursor: pointer; box-shadow: 0 5px 18px rgba(0,0,0,.12); }
.theme-toggle:hover { border-color: rgba(93,124,255,.5); color: #aebaff; transform: translateY(-1px); }
.theme-toggle span { font-size: 17px; line-height: 1; }
.login-theme-toggle { position: fixed; z-index: 5; top: 18px; right: 18px; }
.primary-button { border: 0; border-radius: 12px; padding: 12px 18px; color: white; background: linear-gradient(135deg, var(--blue), var(--purple)); cursor: pointer; font-weight: 700; box-shadow: 0 10px 28px rgba(93,124,255,.22); }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled { opacity: .5; cursor: not-allowed; }
.alert { border-radius: 12px; padding: 11px 14px; margin-bottom: 18px; font-size: 14px; }
.alert.error { background: rgba(255,107,120,.1); border: 1px solid rgba(255,107,120,.22); color: #ffadb5; }

/* 登录 */
.login-page { min-height: 100vh; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 18%, rgba(93,124,255,.18), transparent 30%), radial-gradient(circle at 80% 80%, rgba(141,99,255,.12), transparent 28%), #090b0f; }
.login-page::before { content: ""; position: fixed; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 75%); }
.login-card { width: min(410px, calc(100vw - 32px)); padding: 42px; border: 1px solid var(--line); border-radius: 24px; background: rgba(16,19,25,.86); backdrop-filter: blur(24px); box-shadow: var(--shadow); position: relative; }
.login-subtitle { text-align: center; color: var(--muted); margin: 12px 0 30px; }
.login-form { display: grid; gap: 16px; }
.login-form label, .create-user-form label { display: grid; gap: 8px; color: #bec4d0; font-size: 13px; }
.login-form input, .create-user-form input { width: 100%; border: 1px solid var(--line-strong); background: #0c0f14; color: var(--text); padding: 12px 13px; border-radius: 11px; outline: none; }
.login-form input:focus, .create-user-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(93,124,255,.12); }
.login-form .primary-button { margin-top: 5px; }
.login-footnote { color: #636b78; text-align: center; font-size: 12px; margin: 22px 0 0; }

/* 主界面 */
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 260px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0d1015; }
.sidebar-head { height: 72px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; }
.mobile-close, .menu-button { display: none; }
.product-menu { display: grid; gap: 4px; padding: 0 14px 8px; }
.product-menu a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px; border-radius: 10px; color: #8f97a5; font-size: 13px; }
.product-menu a:hover { color: white; background: rgba(255,255,255,.045); }
.product-menu a.active { color: #e9edff; background: rgba(93,124,255,.13); }
.product-menu span { width: 22px; color: #9eabff; text-align: center; }
.new-chat { margin: 6px 14px 18px; height: 44px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025)); border-radius: 12px; cursor: pointer; text-align: left; padding: 0 14px; }
.new-chat:hover { border-color: rgba(93,124,255,.5); background: rgba(93,124,255,.08); }
.new-chat span { color: #98a8ff; margin-right: 8px; font-size: 18px; }
.history-label { padding: 0 16px 8px; display: flex; justify-content: space-between; align-items: center; color: #737b89; font-size: 12px; }
.history-list { padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.history-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 42px; border: 0; border-radius: 10px; padding: 7px 8px 7px 11px; background: transparent; color: #aeb5c1; cursor: pointer; text-align: left; margin: 2px 0; }
.history-item:hover { background: rgba(255,255,255,.045); color: var(--text); }
.history-item.active { background: rgba(93,124,255,.12); color: #e9edff; }
.history-icon { color: #6f7785; flex: 0 0 auto; }
.history-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.history-menu { opacity: 0; flex: 0 0 auto; border: 0; background: transparent; color: #8d95a5; cursor: pointer; padding: 3px 5px; }
.history-item:hover .history-menu { opacity: 1; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 14px; }
.user-line { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #33425f, #55418a); font-weight: 700; }
.user-line strong, .user-line small { display: block; }
.user-line strong { font-size: 13px; }
.user-line small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.user-actions { display: flex; gap: 12px; margin: 13px 3px 0 44px; font-size: 12px; color: #8d95a5; }
.user-actions form { margin: 0; }
.user-actions button { padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; }
.user-actions a:hover, .user-actions button:hover { color: white; }

.workspace { grid-column: 2; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; height: 72px; padding: 0 28px; display: flex; align-items: center; gap: 12px; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.055); background: rgba(9,11,15,.82); backdrop-filter: blur(20px); }
.topbar h1 { font-size: 15px; margin: 0; max-width: 55vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar p { font-size: 11px; color: #6f7785; margin: 4px 0 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.api-indicator { color: #7f8794; font-size: 12px; display: flex; align-items: center; gap: 7px; }
.api-indicator span { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 12px rgba(61,213,152,.7); }
.conversation { flex: 1; width: 100%; padding: 36px max(24px, calc((100% - 940px) / 2)) 405px; }
.empty-state { min-height: calc(100vh - 390px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-orb { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 22px; font-size: 24px; background: radial-gradient(circle at 35% 30%, #8be8df, #6b6eff 55%, #171b24 58%); box-shadow: 0 18px 60px rgba(90,94,255,.28); }
.empty-state h2 { margin: 20px 0 8px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.empty-state p { color: var(--muted); margin: 0 0 28px; }
.suggestions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.suggestions button { color: #aab2c0; border: 1px solid var(--line); background: rgba(255,255,255,.025); padding: 9px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.suggestions button:hover { color: white; border-color: rgba(93,124,255,.4); }
.message-stream { display: grid; gap: 42px; }
.generation-block { display: grid; gap: 14px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.user-message { justify-self: end; max-width: 74%; border-radius: 18px 18px 5px 18px; padding: 13px 16px; background: #202631; color: #eef1f6; line-height: 1.6; white-space: pre-wrap; }
.input-gallery { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 8px; }
.input-thumb { position: relative; width: 74px; height: 74px; margin: 0; }
.input-gallery img { width: 100%; height: 100%; border-radius: 11px; border: 1px solid var(--line); object-fit: cover; }
.input-thumb span { position: absolute; left: 5px; bottom: 5px; padding: 2px 6px; border-radius: 5px; background: rgba(0,0,0,.76); color: #edf0f5; font-size: 9px; }
.input-audio-gallery { display: grid; gap: 6px; margin: 0 0 9px; }
.input-audio { display: flex; align-items: center; gap: 7px; min-width: 230px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(9,11,15,.42); }
.input-audio span { color: #aeb7c8; font-size: 10px; white-space: nowrap; }
.input-audio audio { width: 210px; height: 28px; }
.prompt-mention { color: #aebcff; background: rgba(93,124,255,.12); border-radius: 5px; padding: 1px 3px; }
.assistant-result { max-width: 760px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.status-pill { padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.06); }
.status-pill.running, .status-pill.queued, .status-pill.submitting { color: #9bb4ff; background: rgba(93,124,255,.11); }
.status-pill.succeeded { color: #80e8bd; background: rgba(61,213,152,.1); }
.status-pill.failed { color: #ff9ca6; background: rgba(255,107,120,.1); }
.loading-card { height: 280px; border: 1px solid var(--line); border-radius: 16px; display: grid; place-items: center; background: linear-gradient(110deg, #11151c 30%, #171c25 45%, #11151c 60%); background-size: 220% 100%; animation: shimmer 2s infinite; color: #8992a2; }
@keyframes shimmer { to { background-position: -220% 0; } }
.video-card { width: min(100%, 680px); border-radius: 17px; overflow: hidden; border: 1px solid var(--line); background: #050608; box-shadow: var(--shadow); }
.video-card video { display: block; width: 100%; max-height: 560px; background: black; }
.result-actions { display: flex; gap: 8px; margin-top: 11px; }
.result-actions button, .result-actions a { border: 1px solid var(--line); background: #151922; border-radius: 9px; padding: 8px 11px; color: #cbd1dc; cursor: pointer; font-size: 12px; }
.result-actions button:hover, .result-actions a:hover { border-color: rgba(93,124,255,.4); color: white; }
.error-card { border: 1px solid rgba(255,107,120,.18); background: rgba(255,107,120,.055); color: #ffadb5; padding: 15px; border-radius: 13px; line-height: 1.5; }
.image-orb { background: radial-gradient(circle at 35% 30%, #fff3ae, #ff7ad9 46%, #685cff 72%, #171b24 74%); box-shadow: 0 18px 60px rgba(203,91,255,.25); }
.image-output-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; width: min(100%, 760px); }
.generated-image-card { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #080a0e; box-shadow: var(--shadow); }
.generated-image-card img { display: block; width: 100%; max-height: 720px; object-fit: contain; background: #050608; }
.image-loading { width: min(100%, 620px); height: 220px; }
.language-orb { background: radial-gradient(circle at 35% 30%, #a7fff0, #5b87ff 48%, #925dff 72%, #171b24 74%); }
.language-conversation { padding-bottom: 405px; }
.language-stream { display: grid; gap: 28px; }
.chat-row { width: 100%; animation: rise .25s ease both; }
.chat-user { display: flex; justify-content: flex-end; }
.chat-user-bubble { max-width: min(74%, 720px); padding: 13px 16px; border-radius: 18px 18px 5px 18px; background: #202631; color: #eef1f6; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-assistant { display: flex; justify-content: flex-start; }
.assistant-chat-card { width: min(100%, 820px); }
.assistant-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; color: white; background: linear-gradient(135deg, #4bd9cc, #6b73ff 58%, #a75aff); }
.assistant-text { margin: 0; color: #e7ebf3; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.assistant-text code { padding: 2px 5px; border-radius: 5px; background: #1d2330; color: #cbd5ff; font-family: Consolas, "SFMono-Regular", monospace; font-size: .92em; }
.assistant-text .code-block { margin: 12px 0; padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #0d1016; white-space: pre; }
.assistant-text .code-block code { padding: 0; background: transparent; color: #d9dfeb; }
.md-heading { margin: 14px 0 5px; color: white; font-weight: 750; }
.md-h1 { font-size: 20px; }.md-h2 { font-size: 18px; }.md-h3 { font-size: 16px; }.md-h4 { font-size: 14px; }
.md-list-line { display: grid; grid-template-columns: 22px 1fr; gap: 2px; }
.md-list-line > span { color: #8fa2ff; }
.md-spacer { height: 10px; }
.reasoning-details { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); color: #8992a2; }
.reasoning-details summary { padding: 10px 12px; cursor: pointer; color: #9aa6bd; font-size: 12px; }
.reasoning-details pre { margin: 0; padding: 0 12px 13px; color: #858e9e; font: inherit; font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.language-loading { min-height: 80px; display: flex; align-items: center; gap: 5px; color: #8992a2; font-size: 13px; }
.language-loading span { width: 7px; height: 7px; border-radius: 50%; background: #8598ff; animation: chat-bounce 1.2s infinite ease-in-out; }
.language-loading span:nth-child(2) { animation-delay: .14s; }
.language-loading span:nth-child(3) { animation-delay: .28s; }
.language-loading em { margin-left: 7px; font-style: normal; }
@keyframes chat-bounce { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-5px); opacity: 1; } }
.composer-wrap { position: fixed; z-index: 12; bottom: 0; left: 260px; right: 0; padding: 18px max(22px, calc((100% - 940px) / 2)) 15px; background: linear-gradient(to top, #090b0f 68%, rgba(9,11,15,.96) 82%, transparent); }
.composer { position: relative; border: 1px solid var(--line-strong); background: rgba(20,24,31,.96); border-radius: 20px; padding: 11px 13px 12px; box-shadow: 0 18px 60px rgba(0,0,0,.4); }
.composer:focus-within { border-color: rgba(93,124,255,.36); box-shadow: 0 18px 60px rgba(0,0,0,.4), 0 0 0 3px rgba(93,124,255,.06); }
.composer.drag-over { border-color: #718cff; box-shadow: 0 18px 60px rgba(0,0,0,.4), 0 0 0 3px rgba(93,124,255,.16); }
.composer.drag-over::after { content: "松开以上传所选文件"; position: absolute; z-index: 60; inset: 7px; display: grid; place-items: center; border: 2px dashed #718cff; border-radius: 15px; background: rgba(13,17,25,.92); color: #dbe1ff; font-size: 15px; font-weight: 600; pointer-events: none; }
.mode-tabs { display: flex; gap: 4px; margin-bottom: 7px; }
.mode-tab { border: 0; border-radius: 8px; padding: 7px 10px; background: transparent; color: #7f8795; cursor: pointer; font-size: 12px; }
.mode-tab.active { background: rgba(93,124,255,.12); color: #b8c4ff; }
.prompt-editor { position: relative; min-height: 0; }
.composer textarea { display: block; width: 100%; min-height: 148px; max-height: 42vh; resize: vertical; border: 0; outline: none; background: transparent; color: var(--text); padding: 12px 112px 12px 8px; line-height: 1.65; font-size: 14px; }
.composer textarea::placeholder { color: #666e7b; }
.prompt-expand { position: absolute; z-index: 4; top: 8px; right: 7px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(32,37,46,.94); color: #9da6b5; cursor: pointer; font-size: 11px; }
.prompt-expand:hover { border-color: rgba(93,124,255,.45); color: white; background: #292f3a; }
.prompt-expand span { color: #aebaff; font-size: 14px; }
.prompt-expand b { font-weight: 550; }
body.prompt-editor-open { overflow: hidden; }
.composer-wrap.editor-expanded { top: 72px; z-index: 40; display: flex; flex-direction: column; padding-top: 18px; background: rgba(9,11,15,.985); }
.editor-expanded .composer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-expanded .prompt-editor { flex: 1; min-height: 150px; display: flex; }
.editor-expanded .composer textarea { flex: 1; height: 100% !important; min-height: 0; max-height: none; resize: none; padding-top: 46px; }
.editor-expanded .composer-bottom, .editor-expanded .mode-tabs, .editor-expanded .upload-area, .editor-expanded .audio-upload-area { flex: 0 0 auto; }
.editor-expanded .mention-menu { top: 44px; bottom: auto; }
.editor-expanded .composer-note { flex: 0 0 auto; }
.mention-menu { position: absolute; z-index: 35; left: 5px; bottom: calc(100% + 8px); width: min(360px, calc(100% - 10px)); max-height: 260px; overflow-y: auto; padding: 7px; border: 1px solid var(--line-strong); border-radius: 14px; background: #1c2028; box-shadow: 0 20px 60px rgba(0,0,0,.48); }
.mention-option { width: 100%; display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: center; border: 0; border-radius: 10px; padding: 7px; background: transparent; color: #eef1f6; text-align: left; cursor: pointer; }
.mention-option:hover, .mention-option.active { background: rgba(93,124,255,.13); }
.mention-option img { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: #0d1015; }
.mention-option span { min-width: 0; display: grid; gap: 3px; }
.mention-option strong { color: #bcc7ff; font-size: 12px; }
.mention-option small { color: #777f8d; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-area { display: flex; gap: 10px; padding: 5px 5px 8px; overflow-x: auto; }
.upload-button { width: 92px; height: 78px; flex: 0 0 auto; display: grid; place-items: center; align-content: center; border: 1px dashed #3a414d; border-radius: 11px; color: #8b93a0; cursor: pointer; }
.upload-button:hover { border-color: var(--blue); color: #b9c4ff; }
.upload-button span { font-size: 20px; line-height: 1; }
.upload-button strong { font-size: 10px; font-weight: 500; margin-top: 4px; }
.upload-button small { font-size: 9px; color: #636b78; margin-top: 2px; }
.preview-list { display: flex; gap: 8px; }
.preview-item { position: relative; width: 78px; height: 78px; flex: 0 0 auto; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; border: 1px solid var(--line); }
.preview-label { position: absolute; left: 5px; bottom: 5px; background: rgba(0,0,0,.72); border-radius: 5px; padding: 2px 5px; font-size: 9px; }
.preview-remove { position: absolute; right: -4px; top: -4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #323845; color: white; cursor: pointer; }
.preview-mention { position: absolute; left: 5px; bottom: 5px; max-width: calc(100% - 10px); border: 0; border-radius: 5px; padding: 3px 6px; background: rgba(12,15,21,.82); color: #c0caff; font-size: 9px; cursor: pointer; }
.preview-mention:hover { background: #596cdd; color: white; }
.audio-upload-area { display: flex; gap: 9px; align-items: center; padding: 3px 5px 8px; overflow-x: auto; }
.audio-upload-button { min-width: 174px; height: 54px; flex: 0 0 auto; display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 8px 10px; border: 1px dashed #3a414d; border-radius: 11px; color: #929baa; cursor: pointer; }
.audio-upload-button:hover { border-color: var(--blue); color: #c4cdff; }
.audio-upload-button span { grid-row: 1 / 3; font-size: 21px; color: #8ba0ff; text-align: center; }
.audio-upload-button strong { align-self: end; font-size: 11px; font-weight: 550; }
.audio-upload-button small { align-self: start; color: #687180; font-size: 9px; white-space: nowrap; }
.audio-preview-list { display: flex; gap: 8px; }
.audio-preview-item { position: relative; width: 248px; height: 54px; flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 18px 28px; gap: 2px 7px; padding: 5px 29px 4px 9px; border: 1px solid var(--line); border-radius: 11px; background: #171b22; }
.audio-preview-item strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd1dc; font-size: 10px; font-weight: 500; }
.audio-preview-item small { color: #697280; font-size: 9px; }
.audio-preview-item audio { grid-column: 1 / 3; width: 100%; height: 26px; }
.audio-preview-item .preview-remove { right: 5px; top: 5px; }
.composer-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.parameter-row { display: flex; gap: 5px; flex-wrap: wrap; }
.parameter-row label { position: relative; }
.parameter-row label { color: transparent; font-size: 0; }
.parameter-row select { appearance: none; border: 0; background: #20252e; color: #c5cbd6; padding: 7px 24px 7px 9px; border-radius: 8px; outline: none; cursor: pointer; font-size: 11px; background-image: linear-gradient(45deg, transparent 50%, #77808e 50%), linear-gradient(135deg, #77808e 50%, transparent 50%); background-position: calc(100% - 11px) 50%, calc(100% - 7px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.parameter-row select:disabled { opacity: .55; }
.duration-picker { position: relative; }
.duration-trigger { height: 30px; border: 0; border-radius: 8px; padding: 0 9px; background: #20252e; color: #c5cbd6; cursor: pointer; font-size: 11px; }
.duration-trigger:hover, .duration-trigger[aria-expanded="true"] { background: #292f3a; color: white; }
.duration-popover { position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 14px); transform: translateX(-50%); width: 330px; padding: 17px; border: 1px solid var(--line-strong); border-radius: 16px; background: #20232a; box-shadow: 0 22px 70px rgba(0,0,0,.48); }
.duration-popover::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg); background: #20232a; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.duration-popover p { margin: 0 0 15px; color: #aeb5c1; font-size: 12px; }
.duration-slider-row { display: grid; grid-template-columns: 1fr 70px; gap: 15px; align-items: center; }
.duration-slider-row input { width: 100%; accent-color: #8586ff; cursor: pointer; }
.duration-slider-row output { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-height: 42px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.075); color: white; font-size: 16px; }
.duration-slider-row output small { color: #9aa1ae; font-size: 11px; }
.duration-ticks { display: flex; justify-content: space-between; padding: 5px 85px 0 1px; color: #828a97; font-size: 9px; }
.submit-zone { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.char-count { color: #666e7a; font-size: 10px; }
.char-count b { font-weight: 500; }
.send-button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #6684ff, #8c63ff); color: white; font-size: 21px; cursor: pointer; box-shadow: 0 8px 22px rgba(93,124,255,.28); }
.send-button:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.composer-note { text-align: center; color: #555c68; font-size: 10px; margin: 7px 0 0; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 30px; transform: translate(-50%, 20px); background: #262c37; border: 1px solid var(--line-strong); color: white; padding: 10px 15px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .22s; box-shadow: var(--shadow); font-size: 13px; max-width: min(500px, calc(100vw - 32px)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #3a1f27; border-color: rgba(255,107,120,.3); }
.sidebar-backdrop { display: none; }

/* 管理 */
.admin-page { background: #0b0e13; min-height: 100vh; }
.admin-topbar { height: 68px; border-bottom: 1px solid var(--line); padding: 0 max(24px, calc((100% - 1000px)/2)); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.admin-topbar-actions { display: flex; align-items: center; gap: 12px; }
.admin-topbar a:hover { color: white; }
.admin-main { max-width: 1000px; margin: 0 auto; padding: 42px 24px; display: grid; gap: 18px; }
.admin-card { border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: var(--panel); }
.section-heading h1 { margin: 0; font-size: 22px; }
.section-heading p { margin: 7px 0 22px; color: var(--muted); font-size: 13px; }
.create-user-form { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 12px; align-items: end; }
.create-user-form .check-label { display: flex; align-items: center; height: 42px; white-space: nowrap; }
.create-user-form .check-label input { width: auto; }
.user-table { display: grid; }
.user-row { display: grid; grid-template-columns: minmax(130px, 1fr) 110px 180px 210px; gap: 14px; align-items: center; padding: 14px 5px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row small { display: block; color: var(--muted); margin-top: 3px; }
.role-badge { justify-self: start; padding: 5px 8px; border-radius: 999px; background: #202530; color: #aeb6c5; font-size: 11px; }
.user-status { font-size: 12px; color: var(--green); }
.user-status.disabled { color: var(--danger); }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-actions button { border: 1px solid var(--line); background: var(--panel-2); color: #bec5d1; border-radius: 8px; padding: 7px 9px; cursor: pointer; font-size: 11px; }

/* 浅色主题 */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f1f3f8;
  --panel-3: #e8ebf3;
  --line: rgba(31, 39, 55, .10);
  --line-strong: rgba(31, 39, 55, .17);
  --text: #1c2331;
  --muted: #687286;
  --shadow: 0 20px 60px rgba(56, 68, 96, .14);
}
html[data-theme="light"] .theme-toggle { background: #fff; color: #3b4557; box-shadow: 0 5px 18px rgba(45,58,86,.1); }
html[data-theme="light"] .theme-toggle:hover { color: #536ce0; background: #f4f6ff; }
html[data-theme="light"] .icon-button:hover { background: rgba(31,39,55,.06); }
html[data-theme="light"] .login-page { background: radial-gradient(circle at 50% 18%, rgba(93,124,255,.15), transparent 32%), radial-gradient(circle at 80% 80%, rgba(141,99,255,.1), transparent 28%), #f5f7fb; }
html[data-theme="light"] .login-page::before { background-image: linear-gradient(rgba(58,70,96,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(58,70,96,.035) 1px, transparent 1px); }
html[data-theme="light"] .login-card { background: rgba(255,255,255,.88); }
html[data-theme="light"] .login-form label,
html[data-theme="light"] .create-user-form label { color: #4e596d; }
html[data-theme="light"] .login-form input,
html[data-theme="light"] .create-user-form input { background: #fff; color: var(--text); }
html[data-theme="light"] .login-footnote { color: #828ba0; }
html[data-theme="light"] .sidebar { background: #ffffff; }
html[data-theme="light"] .product-menu a { color: #606a7d; }
html[data-theme="light"] .product-menu a:hover { color: #283044; background: rgba(45,58,86,.055); }
html[data-theme="light"] .product-menu a.active { color: #4055bc; background: rgba(93,124,255,.11); }
html[data-theme="light"] .new-chat { background: linear-gradient(180deg, #fff, #f7f8fb); }
html[data-theme="light"] .new-chat:hover { background: #f3f5ff; }
html[data-theme="light"] .history-label { color: #7d879a; }
html[data-theme="light"] .history-item { color: #596478; }
html[data-theme="light"] .history-item:hover { background: rgba(45,58,86,.055); }
html[data-theme="light"] .history-item.active { color: #4055bc; background: rgba(93,124,255,.1); }
html[data-theme="light"] .user-actions { color: #667186; }
html[data-theme="light"] .user-actions a:hover,
html[data-theme="light"] .user-actions button:hover { color: #334bbb; }
html[data-theme="light"] .topbar { border-bottom-color: rgba(31,39,55,.08); background: rgba(255,255,255,.86); }
html[data-theme="light"] .topbar p,
html[data-theme="light"] .api-indicator { color: #758095; }
html[data-theme="light"] .suggestions button { color: #5d687d; background: rgba(255,255,255,.7); }
html[data-theme="light"] .suggestions button:hover { color: #4055bc; }
html[data-theme="light"] .user-message,
html[data-theme="light"] .chat-user-bubble { background: #e9edff; color: #263250; }
html[data-theme="light"] .input-audio { background: rgba(255,255,255,.62); }
html[data-theme="light"] .input-audio span { color: #606b7e; }
html[data-theme="light"] .prompt-mention { color: #4058c7; background: rgba(93,124,255,.11); }
html[data-theme="light"] .assistant-text { color: #273044; }
html[data-theme="light"] .assistant-text code { background: #edf0f7; color: #334cae; }
html[data-theme="light"] .assistant-text .code-block { background: #f4f6fa; }
html[data-theme="light"] .assistant-text .code-block code { color: #354055; }
html[data-theme="light"] .md-heading { color: #20283a; }
html[data-theme="light"] .reasoning-details { background: #f7f8fb; color: #667186; }
html[data-theme="light"] .reasoning-details summary { color: #5e6980; }
html[data-theme="light"] .reasoning-details pre { color: #626d82; }
html[data-theme="light"] .loading-card { background: linear-gradient(110deg, #f0f2f7 30%, #fafbfc 45%, #f0f2f7 60%); background-size: 220% 100%; color: #6f7a8f; }
html[data-theme="light"] .result-actions button,
html[data-theme="light"] .result-actions a { background: #fff; color: #4e596d; }
html[data-theme="light"] .result-actions button:hover,
html[data-theme="light"] .result-actions a:hover { color: #4055bc; }
html[data-theme="light"] .generated-image-card { background: #fff; }
html[data-theme="light"] .composer-wrap { background: linear-gradient(to top, #f5f7fb 68%, rgba(245,247,251,.96) 82%, transparent); }
html[data-theme="light"] .composer { background: rgba(255,255,255,.97); box-shadow: 0 18px 60px rgba(56,68,96,.16); }
html[data-theme="light"] .composer:focus-within { box-shadow: 0 18px 60px rgba(56,68,96,.16), 0 0 0 3px rgba(93,124,255,.08); }
html[data-theme="light"] .composer.drag-over::after { background: rgba(248,250,255,.95); color: #4055bc; }
html[data-theme="light"] .mode-tab { color: #6f798c; }
html[data-theme="light"] .mode-tab.active { color: #4055bc; background: rgba(93,124,255,.1); }
html[data-theme="light"] .composer textarea::placeholder { color: #8d96a8; }
html[data-theme="light"] .prompt-expand { background: rgba(246,248,252,.96); color: #59657a; }
html[data-theme="light"] .prompt-expand:hover { background: #eef1fb; color: #4055bc; }
html[data-theme="light"] .composer-wrap.editor-expanded { background: rgba(245,247,251,.99); }
html[data-theme="light"] .mention-menu { background: #fff; box-shadow: 0 20px 60px rgba(56,68,96,.18); }
html[data-theme="light"] .mention-option { color: #253047; }
html[data-theme="light"] .mention-option:hover,
html[data-theme="light"] .mention-option.active { background: rgba(93,124,255,.09); }
html[data-theme="light"] .mention-option img { background: #f0f2f7; }
html[data-theme="light"] .mention-option strong { color: #4055bc; }
html[data-theme="light"] .mention-option small { color: #778197; }
html[data-theme="light"] .upload-button,
html[data-theme="light"] .audio-upload-button { border-color: #c6ccda; color: #657085; }
html[data-theme="light"] .upload-button:hover,
html[data-theme="light"] .audio-upload-button:hover { color: #4055bc; }
html[data-theme="light"] .upload-button small,
html[data-theme="light"] .audio-upload-button small { color: #858fa1; }
html[data-theme="light"] .audio-preview-item { background: #f7f8fb; }
html[data-theme="light"] .audio-preview-item strong { color: #424d61; }
html[data-theme="light"] .audio-preview-item small { color: #7e889b; }
html[data-theme="light"] .parameter-row select,
html[data-theme="light"] .duration-trigger { background-color: #eef1f6; color: #4f5a6e; }
html[data-theme="light"] .duration-trigger:hover,
html[data-theme="light"] .duration-trigger[aria-expanded="true"] { background: #e5e9f2; color: #334bbb; }
html[data-theme="light"] .duration-popover,
html[data-theme="light"] .duration-popover::after { background: #fff; }
html[data-theme="light"] .duration-popover { box-shadow: 0 22px 70px rgba(56,68,96,.2); }
html[data-theme="light"] .duration-popover p { color: #5f6a7e; }
html[data-theme="light"] .duration-slider-row output { background: #eef1f6; color: #283248; }
html[data-theme="light"] .composer-note { color: #838da0; }
html[data-theme="light"] .toast { background: #fff; color: #263044; }
html[data-theme="light"] .toast.error { background: #fff2f3; color: #a53b48; }
html[data-theme="light"] .alert.error,
html[data-theme="light"] .error-card { background: #fff2f3; color: #a53b48; }
html[data-theme="light"] .status-pill.failed { color: #b34350; }
html[data-theme="light"] .admin-page { background: #f5f7fb; }
html[data-theme="light"] .admin-topbar a:hover { color: #4055bc; }
html[data-theme="light"] .role-badge { background: #eef1f6; color: #5a6579; }
html[data-theme="light"] .row-actions button { color: #4f5a6e; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-close, .menu-button { display: inline-grid; place-items: center; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.52); }
  .sidebar-backdrop.show { display: block; }
  .workspace { grid-column: 1; }
  .topbar { padding: 0 16px; justify-content: flex-start; }
  .topbar-actions { margin-left: auto; gap: 6px; }
  .topbar-actions .api-indicator { display: none; }
  .conversation { padding: 22px 14px 430px; }
  .empty-state { min-height: calc(100vh - 430px); }
  .suggestions { display: none; }
  .composer-wrap { left: 0; padding: 12px 10px 8px; }
  .composer { border-radius: 17px; }
  .composer textarea { min-height: 118px; max-height: 34vh; padding-right: 45px; font-size: 14px; }
  .prompt-expand { width: 31px; padding: 0; justify-content: center; }
  .prompt-expand b { display: none; }
  .composer-wrap.editor-expanded { top: 0; padding: 8px; }
  .editor-expanded .composer textarea { padding-right: 45px; }
  .composer-bottom { align-items: flex-end; }
  .parameter-row { gap: 4px; }
  .parameter-row select { padding: 6px 20px 6px 7px; }
  .duration-popover { left: auto; right: -48px; transform: none; width: min(330px, calc(100vw - 28px)); }
  .duration-popover::after { left: auto; right: 62px; transform: rotate(45deg); }
  .char-count { display: none; }
  .user-message { max-width: 88%; }
  .image-output-grid { grid-template-columns: 1fr; }
  .language-conversation { padding-bottom: 430px; }
  .chat-user-bubble { max-width: 88%; }
  .create-user-form { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr auto; }
  .user-row > :nth-child(3) { display: none; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .admin-topbar { padding: 0 14px; }
  .admin-topbar-actions > span { display: none; }
}
