/* AI 助手 · 重建版移动端界面
   设计：内容优先、低动效、清晰层级
*/
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --surface-3: #e7ebf3;
  --text: #172033;
  --muted: #68738a;
  --subtle: #9aa4b7;
  --line: #dfe4ee;
  --line-strong: #cbd3e1;
  --accent: #5264e8;
  --accent-strong: #3f50d6;
  --accent-soft: #e9ecff;
  --danger: #d9485f;
  --ok: #1b9b67;
  --shadow-sm: 0 2px 10px rgba(25, 35, 55, .06);
  --shadow-md: 0 12px 34px rgba(25, 35, 55, .12);
  --header-h: 54px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --press: cubic-bezier(.2, .8, .2, 1);
  --fast: 160ms;
  --normal: 240ms;
}
[data-theme="dark"] {
  --bg: #0c0f15;
  --surface: #151923;
  --surface-2: #1b202d;
  --surface-3: #222938;
  --text: #edf1f8;
  --muted: #9aa5b8;
  --subtle: #69748a;
  --line: #293143;
  --line-strong: #39445b;
  --accent: #8491ff;
  --accent-strong: #9ba6ff;
  --accent-soft: rgba(132,145,255,.15);
  --danger: #ff7184;
  --ok: #4ed29a;
  --shadow-sm: 0 2px 12px rgba(0,0,0,.18);
  --shadow-md: 0 18px 48px rgba(0,0,0,.42);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, a, select { cursor: pointer; }
img { -webkit-user-drag: none; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }

/* 基础控件 */
.btn {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 13px; padding: 0 17px; font-weight: 650;
  transition: transform var(--fast) var(--press), background var(--normal) var(--ease), box-shadow var(--normal) var(--ease), opacity var(--fast) ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent), #36b9d9); box-shadow: 0 8px 20px rgba(82,100,232,.24); }
.btn-primary:active { box-shadow: 0 4px 12px rgba(82,100,232,.18); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.icon-btn {
  width: 42px; height: 42px; border: 0; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted);
  transition: background var(--normal) var(--ease), color var(--normal) var(--ease), transform var(--fast) var(--press);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.96); }
input[type="text"], input[type="url"], input[type="password"], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 11px 13px; outline: none; transition: border-color var(--normal) var(--ease), box-shadow var(--normal) var(--ease);
}
textarea { resize: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.select, .model-select { min-height: 42px; background: var(--surface-2); border-color: transparent; }

/* 登录 */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; background: var(--bg); }
.gate-glow { position: fixed; width: 520px; height: 280px; top: -120px; left: 50%; transform: translateX(-50%); background: radial-gradient(circle, rgba(82,100,232,.2), transparent 68%); pointer-events: none; }
.gate-card { position: relative; width: min(100%, 400px); padding: 28px 22px 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-md); }
.gate-logo { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 17px; background: var(--accent-soft); }
.gate-title { margin: 0; text-align: center; font-size: 22px; letter-spacing: -.02em; }
.gate-sub, .gate-foot { color: var(--muted); text-align: center; font-size: 12.5px; }
.gate-sub { margin: 7px 0 22px; }
.gate-foot { margin: 16px 0 0; }
.gate-form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 600; }
.field-hint { margin: 0; color: var(--subtle); font-size: 12px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 48px; }
.input-eye { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--subtle); }
.gate-error { margin: 0; padding: 10px 12px; border-radius: 10px; color: var(--danger); background: rgba(217,72,95,.1); font-size: 13px; }

/* 应用布局 */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.app-header { z-index: 20; flex: none; height: calc(var(--header-h) + var(--safe-top)); padding: var(--safe-top) 12px 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.header-left { justify-self: start; display: flex; gap: 4px; }
.header-right { justify-self: end; display: flex; gap: 4px; }
.app-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.app-main { position: relative; flex: 1; min-height: 0; }
.tab-panel { position: absolute; inset: 0; display: none; flex-direction: column; }
.tab-panel.active { display: flex; }
.tab-chat { background: var(--bg); overflow: hidden; }
.bottom-nav { z-index: 20; flex: none; height: calc(var(--nav-h) + var(--safe-bottom)); padding: 5px 12px var(--safe-bottom); display: flex; gap: 6px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(18px); }
.nav-btn { flex: 1; min-width: 0; border: 0; border-radius: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--subtle); background: transparent; font-size: 11px; font-weight: 650; transition: color var(--normal) var(--ease), background var(--normal) var(--ease); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }
.nav-btn svg { transition: transform var(--normal) var(--ease); }
.nav-btn.active svg { transform: translateY(-1px); }

/* 对话 */
.chat-empty { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px 10px; text-align: center; }
.empty-logo { width: 72px; height: 72px; margin-bottom: 16px; display: grid; place-items: center; border-radius: 20px; background: var(--accent-soft); }
.chat-empty h2 { margin: 0 0 7px; font-size: 20px; letter-spacing: -.02em; }
.empty-sub { max-width: 300px; margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.chat-suggestions { width: min(100%, 350px); display: grid; gap: 8px; }
.suggestion { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; text-align: left; color: var(--muted); background: var(--surface); transition: border-color var(--normal) var(--ease), background var(--normal) var(--ease), transform var(--fast) var(--press); }
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); }
.suggestion:active { transform: scale(.992); }
.chat-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 14px 18px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; scroll-padding-bottom: 18px; overflow-anchor: none; }
.msg { display: flex; gap: 9px; }
.msg-user { flex-direction: row-reverse; }
.msg-avatar { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 700; }
.msg-user .msg-avatar { background: linear-gradient(135deg, var(--accent), #31c6df); }
.msg-assistant .msg-avatar { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.msg-avatar.has-image { overflow: hidden; border-color: transparent; }
.msg-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.msg-body { min-width: 0; max-width: 82%; display: flex; flex-direction: column; gap: 6px; }
.msg-user .msg-body { align-items: flex-end; }
.msg-bubble { padding: 10px 13px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; word-break: break-word; }
.msg-user .msg-bubble { color: #fff; border-color: transparent; border-bottom-right-radius: 5px; background: linear-gradient(135deg, var(--accent), #2eb8d5); box-shadow: 0 6px 18px rgba(82,100,232,.2); }
.msg-assistant .msg-bubble { border-bottom-left-radius: 5px; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 7px; line-height: 1.3; }
.md h1:first-child, .md h2:first-child, .md h3:first-child, .md h4:first-child { margin-top: 0; }
.md ul, .md ol { margin: 7px 0 10px; padding-left: 22px; }
.md li + li { margin-top: 4px; }
.md blockquote { margin: 9px 0; padding: 8px 11px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.md hr { margin: 14px 0; border: 0; border-top: 1px solid var(--line); }
.md a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.md code { padding: 2px 5px; border-radius: 5px; color: var(--accent-strong); background: var(--surface-2); font: .9em ui-monospace, SFMono-Regular, Consolas, monospace; }
.md pre { position: relative; margin: 10px 0; padding: 34px 11px 11px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface-2); }
.md pre code { display: block; padding: 0; color: inherit; background: transparent; white-space: pre; }
.code-head { position: absolute; top: 0; left: 0; right: 0; height: 27px; padding: 5px 9px; color: var(--subtle); background: var(--surface-3); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.code-copy { position: absolute; top: 3px; right: 5px; min-height: 21px; padding: 0 7px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; }
.code-copy:hover { color: var(--text); background: var(--surface); }
.md table { width: 100%; margin: 10px 0; border-collapse: collapse; font-size: 13px; }
.md th, .md td { padding: 7px 8px; border: 1px solid var(--line); text-align: left; }
.md th { color: var(--text); background: var(--surface-2); }
.md img { max-width: 100%; border-radius: 9px; }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-images img { width: 128px; height: 128px; object-fit: cover; border-radius: 13px; border: 1px solid var(--line); cursor: zoom-in; }
.msg-actions { display: flex; gap: 3px; opacity: 0; transition: opacity var(--normal) var(--ease); }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-action { border: 0; padding: 6px 9px; border-radius: 8px; color: var(--muted); background: transparent; font-size: 12px; }
.msg-action:hover { background: var(--surface-2); color: var(--text); }
.msg-error .msg-bubble { color: var(--danger); background: rgba(217,72,95,.08); border-color: rgba(217,72,95,.3); }
.thinking-state { width: fit-content; min-width: 0; min-height: 46px; display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.thinking-label, .generation-status { display: inline-flex; align-items: center; gap: 5px; line-height: 1.25; opacity: .92; }
.activity-label { white-space: nowrap; }
.activity-emoji { display: inline-block; min-width: 1.2em; color: var(--text); font-size: 16px; line-height: 1; text-align: center; transform-origin: center; transition: opacity 130ms var(--ease), transform 180ms var(--ease); }
.image-generation-bubble { align-self: flex-start; width: fit-content; max-width: min(86vw, 360px); padding: 10px 12px; }
.msg-image-generation-grid { --generation-slot-size: clamp(92px, 32vw, 148px); width: max-content; max-width: 100%; display: grid; grid-template-columns: repeat(2, var(--generation-slot-size)); gap: 8px; }
.msg-image-generation-grid[data-count="1"] { grid-template-columns: var(--generation-slot-size); }
.generation-status { margin-bottom: 2px; color: var(--muted); font-size: 13px; }
.msg-image-generation-slot { position: relative; width: var(--generation-slot-size); min-width: 0; min-height: 0; aspect-ratio: 1; overflow: hidden; isolation: isolate; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); transform: translateZ(0) scale(.95); transform-origin: center; will-change: transform, box-shadow; animation: none; }
.msg-image-generation-slot::before { content: ""; position: absolute; z-index: 1; inset: 0; border-radius: inherit; background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 68%); opacity: .34; animation: image-glow 3s var(--ease) infinite; pointer-events: none; }
.msg-image-generation-slot::after { content: ""; position: absolute; z-index: 2; inset: 3px; border-radius: 9px; background: linear-gradient(112deg, var(--surface-2) 8%, var(--surface-3) 32%, color-mix(in srgb, var(--accent-soft) 88%, var(--surface)) 50%, var(--surface-3) 68%, var(--surface-2) 92%); background-size: 280% 100%; transform: translateZ(0); animation: image-fill-flow 2.9s var(--ease) infinite; pointer-events: none; }
.msg-image-generation-fill { position: absolute; z-index: 3; top: 3px; bottom: 3px; left: -120%; width: 240%; display: block; border-radius: 9px; pointer-events: none; background: linear-gradient(105deg, transparent 28%, color-mix(in srgb, var(--accent) 12%, transparent) 42%, color-mix(in srgb, var(--accent) 64%, transparent) 50%, color-mix(in srgb, var(--accent) 12%, transparent) 58%, transparent 72%); filter: blur(1px); }
.msg-image-generation-slot:nth-child(2), .msg-image-generation-slot:nth-child(2)::before, .msg-image-generation-slot:nth-child(2)::after { animation-delay: .22s; }
.msg-image-generation-slot:nth-child(3), .msg-image-generation-slot:nth-child(3)::before, .msg-image-generation-slot:nth-child(3)::after { animation-delay: .44s; }
.msg-image-generation-slot:nth-child(4), .msg-image-generation-slot:nth-child(4)::before, .msg-image-generation-slot:nth-child(4)::after { animation-delay: .66s; }
@keyframes image-breathe { 0%,100% { transform: translateZ(0) scale(.94); box-shadow: 0 2px 8px transparent; } 50% { transform: translateZ(0) scale(1); box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 28%, transparent); } }
@keyframes image-glow { 0%,100% { opacity: .2; transform: scale(.94); } 50% { opacity: .72; transform: scale(1.08); } }
@keyframes image-fill-flow { 0% { background-position: 120% 50%; opacity: .58; } 50% { opacity: 1; } 100% { background-position: -20% 50%; opacity: .58; } }

/* 输入区 */
.composer-wrap { position: relative; z-index: 3; flex: none; min-height: 0; padding: 8px 12px calc(8px + var(--safe-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line); }
.composer-model-tools { min-width: 0; flex: 1; display: flex; align-items: center; gap: 7px; }
.model-picker { position: relative; min-width: 0; flex: 1; }
.model-picker-trigger { width: 100%; height: 40px; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 11px 0 12px; border: 1px solid transparent; border-radius: 11px; color: var(--text); background: var(--surface-2); font-size: 13px; font-weight: 600; text-align: left; touch-action: manipulation; transition: color var(--normal) var(--ease), border-color var(--normal) var(--ease), background var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
.model-picker-trigger:hover { background: var(--surface-3); }
.model-picker-trigger:focus-visible { border-color: var(--line-strong); outline: 2px solid var(--accent-soft); outline-offset: 0; }
.model-picker-trigger > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-trigger svg { flex: none; color: var(--muted); transition: transform var(--normal) var(--ease); }
.model-picker.is-open .model-picker-trigger svg { transform: rotate(180deg); }
.model-picker-menu { position: absolute; z-index: 85; left: 0; right: 0; bottom: calc(100% + 8px); max-height: min(320px, 46vh); overflow-y: auto; padding: 6px; border: 1px solid var(--line-strong); border-radius: 14px; background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: var(--shadow-md); backdrop-filter: blur(18px); transform-origin: bottom center; }
.model-picker-menu:not(.hidden) { animation: model-menu-in .16s var(--ease) both; }
.model-picker-option { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 13px; text-align: left; transition: color var(--fast) var(--ease), background var(--fast) var(--ease); }
.model-picker-option:hover, .model-picker-option:focus-visible { color: var(--text); background: var(--surface-2); outline: none; }
.model-picker-option.is-selected { color: var(--accent-strong); background: var(--accent-soft); }
.model-picker-option-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-option-check { flex: none; color: var(--accent); font-size: 15px; font-weight: 800; }
.model-select-native { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
@keyframes model-menu-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.chat-routing-toggle { flex: none; min-height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px 5px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: none; backdrop-filter: blur(14px); touch-action: manipulation; transition: color var(--normal) var(--ease), border-color var(--normal) var(--ease), background var(--normal) var(--ease), box-shadow var(--normal) var(--ease), transform var(--fast) var(--press); }
.chat-routing-toggle:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow-md); }
.chat-routing-toggle:active { transform: scale(.97); }
.chat-routing-toggle-copy { white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .01em; }
.chat-routing-toggle-track { position: relative; width: 34px; height: 20px; flex: none; border-radius: 999px; background: var(--line-strong); transition: background var(--normal) var(--ease); }
.chat-routing-toggle-thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.22); transform: translateX(0); transition: transform var(--normal) var(--ease), background var(--normal) var(--ease); }
.chat-routing-toggle.is-on { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface)); }
.chat-routing-toggle.is-on .chat-routing-toggle-track { background: var(--accent); }
.chat-routing-toggle.is-on .chat-routing-toggle-thumb { background: #fff; transform: translateX(14px); }
.composer-attachments { display: flex; gap: 8px; overflow-x: auto; padding: 2px 3px 8px; scrollbar-width: none; }
.composer-attachments::-webkit-scrollbar { display: none; }
.attach-item { position: relative; flex: none; }
.attach-item img { width: 58px; height: 58px; object-fit: cover; border: 1px solid var(--line); border-radius: 11px; }
.attach-remove { position: absolute; top: -7px; right: -7px; width: 21px; height: 21px; padding: 0; border: 2px solid var(--bg); border-radius: 50%; color: #fff; background: var(--danger); font-size: 13px; line-height: 1; }
.composer { border: 1px solid var(--line-strong); border-radius: 16px; padding: 8px 8px 7px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
.composer:focus-within { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.composer textarea { display: block; min-height: 32px; max-height: 200px; height: 32px; padding: 0 5px; border: 0; border-radius: 8px; background: transparent; line-height: 1.45; overflow-y: hidden; transition: none; }
.composer textarea:focus { box-shadow: none; }
.composer-divider { height: 1px; margin: 7px 2px; background: var(--line); }
.composer-bottom { min-height: 34px; display: flex; align-items: center; gap: 6px; }
.composer-bottom .icon-btn { width: 38px; height: 38px; }
.send-btn { width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--accent), #32bfdc); box-shadow: 0 7px 16px rgba(82,100,232,.24); transition: transform var(--fast) var(--press), opacity var(--fast) ease, box-shadow var(--normal) var(--ease); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .4; pointer-events: none; }
.composer-tip { margin: 7px 2px 0; color: var(--subtle); text-align: center; font-size: 11px; }

/* 生图 */
.tab-image, .tab-me { background: var(--bg); }
.image-scroll, .me-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px calc(24px + var(--safe-bottom)); }
.image-composer-card, .card { border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-sm); }
.image-composer-card { padding: 15px; }
.mode-seg, .seg-row { display: flex; gap: 5px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg-btn { min-height: 36px; flex: 1; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 13px; transition: color var(--normal) var(--ease), background var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
.seg-btn.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.edit-picker { margin-top: 12px; }
.edit-pick { width: 100%; min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: 13px; color: var(--muted); background: var(--surface-2); }
.edit-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.thumb-wrap { position: relative; }
.edit-thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 11px; border: 1px solid var(--line); }
.image-prompt { min-height: 105px; margin-top: 13px; line-height: 1.55; }
.opt-row { display: flex; align-items: flex-start; gap: 12px; margin-top: 13px; }
.opt-row-2 { display: grid; grid-template-columns: 1fr 1fr; }
.opt-col { min-width: 0; }
.opt-label { display: block; margin: 1px 0 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.chip-row { min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 12px; transition: color var(--normal) var(--ease), border-color var(--normal) var(--ease), background var(--normal) var(--ease); }
.chip.active { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-soft); }
#image-generate { margin-top: 17px; }
.image-progress { margin-top: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface); }
.progress-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.image-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.result-card { position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.result-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.result-card.placeholder, .result-card.error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; color: var(--muted); text-align: center; font-size: 12px; }
.result-card.error { color: var(--danger); }
.result-actions { position: absolute; inset: auto 0 0; display: flex; justify-content: center; gap: 8px; padding: 22px 8px 8px; background: linear-gradient(transparent, rgba(0,0,0,.66)); opacity: 0; transition: opacity var(--normal) var(--ease); }
.result-card:hover .result-actions, .result-card:focus-within .result-actions { opacity: 1; }
.result-action { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; color: #fff; background: rgba(0,0,0,.45); }
.image-history { margin-top: 22px; }
.ih-title { margin: 0 0 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.ih-item { margin-bottom: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ih-item-head { display: flex; align-items: center; gap: 8px; }
.ih-prompt { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ih-del, .cell-btn { min-height: 34px; padding: 0 10px; border: 0; border-radius: 9px; color: var(--accent-strong); background: var(--accent-soft); font-size: 12px; }
.ih-thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 9px; scrollbar-width: none; }
.ih-thumbs::-webkit-scrollbar { display: none; }
.ih-thumbs img { width: 88px; height: 88px; flex: none; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* 我的：单列、低密度设置页 */
.me-scroll { padding: 18px 16px calc(30px + var(--safe-bottom)); }
.me-profile { flex: none; display: flex; align-items: center; gap: 13px; min-height: 82px; padding: 16px 2px 20px; border-bottom: 1px solid var(--line); }
.me-avatar { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 17px; color: #fff; background: linear-gradient(145deg, var(--accent), #33bdd7); box-shadow: 0 9px 22px color-mix(in srgb, var(--accent) 22%, transparent); font-size: 18px; font-weight: 750; }
.me-avatar.has-image { overflow: hidden; }
.me-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.me-info { min-width: 0; flex: 1; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.me-role { margin-top: 3px; color: var(--muted); font-size: 12px; }
.me-logout { min-width: 52px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--surface); font-size: 12px; transition: color var(--normal) var(--ease), border-color var(--normal) var(--ease), background var(--normal) var(--ease), transform var(--fast) var(--press); }
.me-logout:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.me-logout:active { transform: scale(.97); }
.me-section { margin-top: 25px; }
.me-section-title { margin: 0 3px 9px; color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .08em; }
.me-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.me-row, .me-status-row, .me-select-row, .me-toggle-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.me-row:last-child, .me-status-row:last-child, .me-select-row:last-child, .me-toggle-row:last-child { border-bottom: 0; }
.me-row-copy, .me-status-copy, .me-select-row > span, .me-toggle-row > span { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.me-row-label, .me-select-row strong, .me-toggle-row strong { font-size: 14px; font-weight: 650; }
.me-row-value, .me-select-row small, .me-toggle-row small { display: block; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.me-row-action { min-height: 36px; flex: none; padding: 0 11px; border: 0; border-radius: 10px; color: var(--accent-strong); background: var(--accent-soft); font-size: 12px; font-weight: 650; transition: background var(--normal) var(--ease), transform var(--fast) var(--press); }
.me-row-action:hover { background: color-mix(in srgb, var(--accent-soft) 72%, var(--accent)); }
.me-row-action:active, .me-toggle:active { transform: scale(.97); }
.me-status-row { border-bottom: 0; }
.me-status-copy { gap: 3px; }
.me-toggle { min-width: 64px; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-2); font-size: 12px; font-weight: 650; transition: color var(--normal) var(--ease), background var(--normal) var(--ease), border-color var(--normal) var(--ease), transform var(--fast) var(--press); }
.me-toggle.is-on { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.me-persona-row { border-bottom: 1px solid var(--line); }
.me-setting-block { padding: 14px; border-bottom: 1px solid var(--line); }
.me-setting-heading { margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 650; }
.me-avatar-settings { padding-bottom: 4px; }
.avatar-setting-row { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 7px 0; border-top: 1px solid var(--line); }
.avatar-setting-preview { width: 42px; height: 42px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 13px; color: #fff; font-size: 13px; font-weight: 750; }
.avatar-setting-preview-user { background: linear-gradient(135deg, var(--accent), #31c6df); }
.avatar-setting-preview-assistant { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.avatar-setting-preview.has-image { border-color: transparent; }
.avatar-setting-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-setting-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.avatar-setting-copy strong { font-size: 13px; font-weight: 650; }
.avatar-setting-copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.avatar-setting-actions { flex: none; display: flex; align-items: center; gap: 6px; }
.avatar-reset { min-height: 34px; padding: 0 9px; border: 1px solid transparent; border-radius: 9px; color: var(--subtle); background: transparent; font-size: 12px; transition: color var(--normal) var(--ease), background var(--normal) var(--ease); }
.avatar-reset:hover { color: var(--danger); background: rgba(217,72,95,.1); }
.me-theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 11px; background: var(--surface-2); }
.me-theme-btn { min-height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 12px; transition: color var(--normal) var(--ease), background var(--normal) var(--ease), box-shadow var(--normal) var(--ease); }
.me-theme-btn.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.me-select-row { cursor: default; }
.me-select-row .model-select { width: min(44%, 168px); min-width: 106px; min-height: 38px; flex: none; padding: 8px 29px 8px 10px; border-color: transparent; border-radius: 10px; color: var(--text); background: var(--surface-2); font-size: 12px; }
.me-select-row .model-select:focus { border-color: var(--accent); }
.me-danger-card { background: color-mix(in srgb, var(--surface) 92%, var(--danger)); }
.me-danger-row { width: 100%; min-height: 58px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); color: var(--danger); background: transparent; text-align: left; font-size: 14px; font-weight: 650; transition: background var(--normal) var(--ease); }
.me-danger-row span { color: var(--muted); font-size: 11px; font-weight: 400; }
.me-danger-row:hover { background: rgba(217,72,95,.08); }
.me-danger-row:last-child { border-bottom: 0; }
.me-about-section { margin-bottom: 4px; }
.me-about-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; color: var(--text); border-bottom: 1px solid var(--line); font-size: 13px; text-decoration: none; }
.me-about-row:last-child { border-bottom: 0; }
.me-about-row strong { color: var(--muted); font-size: 12px; font-weight: 500; }
.me-about-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.me-about-link:hover { background: var(--surface-2); }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; background: var(--ok); }
.dot-bad { background: var(--danger); }
.about-foot { margin: 16px 0 3px; color: var(--subtle); text-align: center; font-size: 11px; }

/* 弹窗、浮层 */
.sheet-mask { position: fixed; inset: 0; z-index: 90; background: rgba(6,10,18,.52); backdrop-filter: blur(4px); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; max-height: 78vh; display: flex; flex-direction: column; padding: 8px 16px calc(16px + var(--safe-bottom)); border-radius: 22px 22px 0 0; background: var(--surface); box-shadow: 0 -16px 50px rgba(0,0,0,.22); transform: translateY(105%); transition: transform .32s var(--ease); }
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; margin: 0 auto 10px; border-radius: 999px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 10px; }
.sheet-title { font-size: 16px; font-weight: 750; }
.sheet-body { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.persona-panel { gap: 14px; }
.persona-lock-card { display: flex; align-items: flex-start; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.persona-lock-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); font-size: 20px; }
.persona-lock-card strong { display: block; font-size: 14px; }
.persona-lock-card p, .persona-editor-note { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.persona-editor-note { margin: 0; padding: 10px 12px; border-radius: 10px; color: var(--muted); background: var(--surface-2); }
.sheet-empty { padding: 38px 0; color: var(--subtle); text-align: center; font-size: 13px; }
.history-list { min-height: 0; overflow-y: auto; padding: 2px 0 8px; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 11px 9px; border-radius: 12px; transition: background var(--normal) var(--ease); }
.history-item:hover, .history-item.active { background: var(--surface-2); }
.history-item-main { min-width: 0; flex: 1; }
.history-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.history-item-meta { margin-top: 2px; color: var(--subtle); font-size: 11px; }
.history-item-del { width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--subtle); background: transparent; }
.history-item-del:hover { color: var(--danger); background: rgba(217,72,95,.1); }
.history-popover { top: 60px; bottom: auto; left: 12px; right: auto; width: min(320px, calc(100vw - 20px)); max-height: min(70vh, 420px); padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 16px; transform: none !important; overflow: visible; box-shadow: var(--shadow-md); }
.history-popover { transition: none !important; }
.history-popover::before { content: ""; position: absolute; top: -7px; left: var(--history-arrow-left, 18px); width: 14px; height: 14px; background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); }
.history-popover.history-popover-above::before { top: auto; bottom: -7px; transform: rotate(225deg); }
.history-popover .sheet-handle { display: none; }
.history-popover .sheet-head { padding: 3px 2px 8px; }
.history-popover .history-list { max-height: min(58vh, 340px); }
.confirm-box { position: fixed; left: 50%; top: 50%; z-index: 140; width: min(320px, calc(100vw - 48px)); padding: 21px 18px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-md); transform: translate(-50%, -50%); text-align: center; }
.confirm-title { font-weight: 750; }
.confirm-desc { margin: 7px 0 17px; color: var(--muted); font-size: 13px; }
.confirm-actions { display: flex; gap: 9px; }
.confirm-actions .btn { flex: 1; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: rgba(4,6,10,.96); }
.lb-stage { min-height: 0; flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; }
.lb-stage img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.lb-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; color: #fff; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); }
.lb-close { position: absolute; top: calc(10px + var(--safe-top)); right: 10px; z-index: 2; }
.lb-actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px; padding: 14px 16px calc(15px + var(--safe-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.lb-use { width: auto; padding: 0 16px; font-size: 13px; font-weight: 650; background: #5264e8; border: 0; }

/* 其他动态组件 */
.spinner { width: 16px; height: 16px; flex: none; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-root { position: fixed; left: 50%; bottom: calc(82px + var(--safe-bottom)); z-index: 120; width: max-content; max-width: calc(100vw - 40px); display: flex; flex-direction: column; align-items: center; gap: 7px; transform: translateX(-50%); pointer-events: none; }
.toast { padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 11px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-md); font-size: 13px; }
.toast-err { color: var(--danger); }
.image-choice-inline { width: 100%; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.image-choice-title { margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 700; }
.image-choice-grid { display: flex; gap: 8px; overflow-x: auto; padding: 2px 1px 4px; scrollbar-width: thin; }
.image-choice-item { flex: 0 0 88px; display: flex; flex-direction: column; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--surface-2); transition: border-color var(--normal) var(--ease), background var(--normal) var(--ease), transform var(--fast) var(--press); }
.image-choice-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.image-choice-item:active { transform: scale(.97); }
.image-choice-item:disabled { cursor: wait; opacity: .68; }
.image-choice-item.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); opacity: 1; }
.image-choice-item img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; }
.image-choice-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font-size: 11px; }
.image-choice-cancel { min-height: 32px; margin-top: 8px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--subtle); background: transparent; font-size: 12px; }
.image-choice-cancel:disabled { cursor: wait; opacity: .5; }
.image-choice-cancel:hover { color: var(--text); background: var(--surface-2); }
.image-context-menu { position: fixed; z-index: 250; min-width: 145px; padding: 5px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-md); }
.image-context-menu button { display: block; width: 100%; padding: 9px 11px; border: 0; border-radius: 8px; color: var(--text); background: transparent; text-align: left; font-size: 13px; }
.image-context-menu button:hover { background: var(--surface-2); }
.img-load-error { opacity: .55; }

/* 桌面、动效 */
@media (min-width: 720px) {
  .app { max-width: 520px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,.16); }
  body { background: #dfe4ee; }
}
@media (min-width: 480px) { .msg-body { max-width: 76%; } }
@media (max-width: 380px) {
  .composer-model-tools { gap: 5px; }
  .chat-routing-toggle { gap: 4px; padding-left: 7px; padding-right: 6px; }
  .chat-routing-toggle-copy { font-size: 10px; }
  .chat-routing-toggle-track { width: 30px; }
  .chat-routing-toggle.is-on .chat-routing-toggle-thumb { transform: translateX(10px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  /* 生图占位框由 chat.js 的 requestAnimationFrame 驱动，不受系统动画策略覆盖。 */
  .msg-image-generation-slot, .msg-image-generation-slot::before, .msg-image-generation-slot::after { animation: none !important; }
}


