/* ---------- 颜色和尺寸 ---------- */
:root {
  --bg: #f4f5fb; --surface: #ffffff; --surface-2: #f0f1f7; --fg: #15161d; --fg2: #6c7086; --hairline: rgba(20, 22, 40, .08);
  --accent: #5b6cff; --accent-2: #a35bff; --accent-fg: #fff; --danger: #ff4d67;
  --grad: linear-gradient(135deg, #5b6cff 0%, #8f5bff 55%, #ff6fa8 100%);
  --glass: rgba(255, 255, 255, .72); --glass-border: rgba(255, 255, 255, .6);
  --shadow: 0 1px 2px rgba(20, 22, 40, .04), 0 8px 24px rgba(20, 22, 40, .07);
  --shadow-lg: 0 12px 40px rgba(40, 30, 120, .18);
  --code-bg: #f6f7fb; --radius: 1.125rem; --sidebar-w: 280px; --dock-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d0e14; --surface: #171821; --surface-2: #20222d; --fg: #eceef6; --fg2: #9095ab; --hairline: rgba(255, 255, 255, .08);
  --accent: #7b88ff; --glass: rgba(23, 24, 33, .7); --glass-border: rgba(255, 255, 255, .08);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  --code-bg: #0f1016;
  color-scheme: dark;
}
:root[data-font="serif"] { --font: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif; }
:root[data-font="kai"] { --font: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", serif; }
/* 苹方：苹果设备自带；其他系统装了苹方才生效 */
:root[data-font="pingfang"] { --font: "PingFang SC", "PingFang TC", -apple-system, "SF Pro Text", "Helvetica Neue", "Microsoft YaHei", sans-serif; }
/* 自定义字体用 FontFace 注册为 UserFont，没加载好之前退回默认字体 */
:root[data-font="custom"] { --font: "UserFont", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--fg); font: 1rem/1.6 var(--font); -webkit-text-size-adjust: 100%; overscroll-behavior: none;
  /* 装饰：几团柔和的彩色光斑 */
  background:
    radial-gradient(40rem 28rem at 110% -10%, rgba(143, 91, 255, .16), transparent 60%),
    radial-gradient(32rem 24rem at -20% 30%, rgba(91, 108, 255, .14), transparent 60%),
    radial-gradient(30rem 22rem at 80% 110%, rgba(255, 111, 168, .12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS 上输入框字号小于 16px 会自动放大页面 */
input, textarea, select { font-size: max(1rem, 16px); }
svg { width: 1.375rem; height: 1.375rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.ic { width: 1.125rem; height: 1.125rem; vertical-align: -0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 通用控件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; padding: .625rem 1rem; min-height: 44px;
  border-radius: .875rem; border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; font-weight: 500;
  transition: transform .15s, box-shadow .2s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: var(--accent-fg); border: none; box-shadow: 0 6px 18px rgba(91, 108, 255, .35); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.icon-btn { width: 2.5rem; height: 2.5rem; min-width: 40px; min-height: 40px; flex-shrink: 0; border: none; background: none; border-radius: 50%;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--fg2); transition: background .15s, transform .15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled, .btn:disabled { opacity: .5; cursor: default; }
.hint { font-size: .8125rem; color: var(--fg2); margin: 0; }

/* ---------- 登录页 ---------- */
#authScreen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: min(380px, 100%); display: grid; gap: .75rem; text-align: center; padding: 2rem 1.5rem;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 1.75rem; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6); }
.auth-logo { width: 4rem; height: 4rem; margin: 0 auto .25rem; border-radius: 1.25rem; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(143, 91, 255, .45); }
.auth-logo svg { width: 2rem; height: 2rem; stroke: none; }
.auth-card h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.02em; }
.auth-card input { padding: .75rem .875rem; border-radius: .875rem; border: 1px solid var(--hairline); background: var(--surface); }
.auth-msg { min-height: 1.5em; margin: 0; font-size: .875rem; color: var(--danger); }

/* ---------- 页面框架：左右滑动的 pager + 底部 Dock ---------- */
#shell { height: 100dvh; overflow: hidden; }
#pager { display: flex; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain; }
#pager::-webkit-scrollbar { display: none; }
#pager.locked { overflow-x: hidden; }
.page { flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; position: relative; overflow: hidden; }
.page-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: calc(1rem + var(--safe-top)) 1rem calc(var(--dock-h) + 2rem + var(--safe-bottom)); }
.page-scroll > * { max-width: 680px; margin-left: auto; margin-right: auto; }

#dock { position: fixed; left: 50%; bottom: calc(.625rem + var(--safe-bottom)); transform: translateX(-50%); z-index: 12;
  display: flex; gap: .25rem; padding: .375rem; border-radius: 1.5rem;
  background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(1.8); -webkit-backdrop-filter: blur(20px) saturate(1.8);
  transition: transform .25s ease, opacity .2s; }
#dock button { display: flex; flex-direction: column; align-items: center; gap: .125rem; min-width: 4.25rem; padding: .375rem .75rem;
  border: none; background: none; border-radius: 1.125rem; cursor: pointer; color: var(--fg2); font-size: .6875rem; font-weight: 500;
  transition: color .2s, background .25s; }
#dock button svg { width: 1.375rem; height: 1.375rem; }
#dock button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* 手机上打字时隐藏 Dock，给键盘让出空间 */
body.typing #dock { transform: translate(-50%, 150%); opacity: 0; pointer-events: none; }

/* ---------- 首页 ---------- */
.card { background: var(--surface); border-radius: 1.375rem; box-shadow: var(--shadow); border: 1px solid var(--hairline); }
.hero { position: relative; overflow: hidden; padding: 1.5rem 1.375rem 1.375rem; margin-bottom: 1rem; border-radius: 1.75rem;
  background: var(--grad); color: #fff; box-shadow: 0 14px 40px rgba(110, 80, 255, .35); }
/* 装饰光圈 */
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 70%); }
.hero::before { width: 14rem; height: 14rem; right: -4rem; top: -5rem; }
.hero::after { width: 9rem; height: 9rem; right: 5rem; bottom: -5rem; opacity: .6; }
.hero-date { margin: 0; font-size: .8125rem; opacity: .85; letter-spacing: .04em; }
.hero-title { margin: .25rem 0 .375rem; font-size: 2rem; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
.hero-sub { margin: 0; font-size: .9375rem; opacity: .9; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: grid; justify-items: start; gap: .125rem; padding: 1rem; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 1.375rem; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .2s; min-width: 0; }
.tile:active { transform: scale(.97); }
.tile-icon { width: 2.75rem; height: 2.75rem; border-radius: .875rem; display: flex; align-items: center; justify-content: center;
  color: #fff; margin-bottom: .5rem; box-shadow: 0 6px 14px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .35); }
.tile-name { font-weight: 600; }
.tile-sub { font-size: .8125rem; color: var(--fg2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-blue { background: linear-gradient(135deg, #4facfe, #3b6cff); }
.g-purple { background: linear-gradient(135deg, #a46bff, #6a4dff); }
.g-orange { background: linear-gradient(135deg, #ffb347, #ff7a45); }
.g-pink { background: linear-gradient(135deg, #ff8fb1, #ff4f8b); }

.group-title { font-size: .8125rem; font-weight: 600; color: var(--fg2); text-transform: uppercase; letter-spacing: .06em; margin: 1.25rem .375rem .5rem; }
.list { overflow: hidden; margin-bottom: .75rem; }
.row-item { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem .75rem;
  width: 100%; min-height: 52px; padding: .625rem 1rem; border: none; background: none; text-align: left; }
.row-item + .row-item { border-top: 1px solid var(--hairline); }
.row-item.link { cursor: pointer; }
.row-item.link:active { background: var(--surface-2); }
.row-item.danger { color: var(--danger); }
.row-item.center { justify-content: center; }
.row-item .chev { width: 1.125rem; height: 1.125rem; color: var(--fg2); opacity: .6; }
.recent-text { flex: 1; min-width: 0; display: grid; }
.recent-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { font-size: .75rem; color: var(--fg2); }
.empty { padding: 1.25rem 1rem; text-align: center; color: var(--fg2); font-size: .875rem; }

/* ---------- 我的 ---------- */
.profile { display: flex; align-items: center; gap: 1rem; padding: 1.125rem; }
.avatar { width: 3.75rem; height: 3.75rem; border-radius: 50%; background: var(--grad); color: #fff; font-size: 1.5rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 6px 18px rgba(143, 91, 255, .4); }
.profile-text { flex: 1; min-width: 0; }
.row-label { display: grid; }
.row-label small { font-size: .75rem; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; }
.row-item .row-inline .btn { min-height: 36px; padding: .375rem .75rem; }
.profile-name { font-size: 1.25rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.profile-email { font-size: .875rem; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; }
/* iOS 风格的分段控件 */
.seg { display: flex; padding: 2px; border-radius: .75rem; background: var(--surface-2); }
.seg button { border: none; background: none; padding: .375rem .75rem; border-radius: .625rem; cursor: pointer; font-size: .875rem; color: var(--fg2);
  transition: background .2s, color .2s; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); font-weight: 500; }

/* ---------- 聊天页：侧边栏 ---------- */
#app { display: flex; height: 100%; }
#sidebar { width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--surface) 82%, transparent); border-right: 1px solid var(--hairline); }
.sidebar-head { padding: .75rem; display: grid; gap: .5rem; }
.sidebar-head input { width: 100%; padding: .5625rem .75rem; border-radius: .75rem; border: 1px solid var(--hairline); background: var(--surface-2); }
#sessionList { list-style: none; margin: 0; padding: 0 .5rem; flex: 1; overflow-y: auto; }
#sessionList li { display: flex; align-items: center; gap: .25rem; padding: .375rem .375rem .375rem .75rem; margin-bottom: 2px;
  border-radius: .75rem; cursor: pointer; white-space: nowrap; overflow: hidden; min-height: 44px; transition: background .15s; }
#sessionList li span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#sessionList li:hover { background: var(--surface-2); }
#sessionList li.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }
#sessionList li .icon-btn { width: 2rem; height: 2rem; min-width: 32px; min-height: 32px; opacity: .55; }
#sessionList li .icon-btn svg { width: 1rem; height: 1rem; }
.sidebar-foot { padding: .75rem; padding-bottom: calc(var(--dock-h) + 1.25rem + var(--safe-bottom)); border-top: 1px solid var(--hairline); }
.user-email { font-size: .75rem; color: var(--fg2); padding: 0 .25rem .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 手机/竖屏平板：侧边栏变抽屉 */
@media (max-width: 899px) {
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(82vw, var(--sidebar-w)); background: var(--surface);
    transform: translateX(-105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  #app.drawer-open #sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-foot { padding-bottom: calc(.75rem + var(--safe-bottom)); }
  #backdrop { position: fixed; inset: 0; background: rgba(10, 10, 25, .35); z-index: 25; }
}
@media (min-width: 900px) { #menuBtn { display: none; } #backdrop { display: none !important; } }

/* ---------- 聊天页：顶栏和消息 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#topbar { position: absolute; inset: 0 0 auto; z-index: 5; display: flex; align-items: center; gap: .125rem;
  padding: .5rem .625rem; padding-top: calc(.5rem + var(--safe-top));
  background: var(--glass); border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(20px) saturate(1.8); -webkit-backdrop-filter: blur(20px) saturate(1.8); }
.title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
#chatTitle { margin: 0; font-size: 1rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#modelSelect { border: none; background: transparent; color: var(--fg2); font-size: max(.8125rem, 13px); max-width: 100%; text-align: center; cursor: pointer; }

#messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: calc(4.5rem + var(--safe-top)) .875rem 1.5rem; }
.msg { max-width: 820px; margin: 0 auto 1.25rem; display: flex; flex-direction: column; }
.msg.new { animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg.user { align-items: flex-end; }
.msg.assistant::before { content: ""; width: 1.75rem; height: 1.75rem; margin-bottom: .375rem; border-radius: .625rem; background: var(--grad);
  box-shadow: 0 4px 12px rgba(143, 91, 255, .35); }
.bubble { padding: .625rem .9375rem; border-radius: var(--radius); max-width: 100%; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: .375rem; max-width: 85%; white-space: pre-wrap;
  box-shadow: 0 6px 18px rgba(110, 80, 255, .28); }
.msg.assistant .bubble { padding-left: .125rem; padding-right: .125rem; }
.msg.error .bubble { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); padding: .625rem .9375rem; }
.msg-images, .msg-files { display: flex; flex-wrap: wrap; gap: .375rem; margin-bottom: .375rem; justify-content: flex-end; }
.msg-images img { width: 7.5rem; height: 7.5rem; object-fit: cover; border-radius: .875rem; cursor: zoom-in; box-shadow: var(--shadow); }
.msg-images img.loading { background: var(--surface-2); }
.file-chip { font-size: .8125rem; padding: .25rem .625rem; border-radius: .625rem; background: var(--surface); border: 1px solid var(--hairline); }
.msg-actions { display: flex; gap: 2px; margin-top: .25rem; opacity: .55; }
.msg-actions:hover, .msg:focus-within .msg-actions { opacity: 1; }
.msg-actions button { border: none; background: none; cursor: pointer; padding: .375rem .5rem; border-radius: .5rem; font-size: .8125rem; color: var(--fg2); min-height: 32px; }
.msg-actions button:hover { background: var(--surface-2); }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.placeholder { text-align: center; color: var(--fg2); margin-top: 30vh; }

/* Markdown */
.bubble p { margin: .4em 0; }
.bubble pre { position: relative; background: var(--code-bg); border: 1px solid var(--hairline); border-radius: .875rem; padding: .75rem;
  overflow-x: auto; overscroll-behavior-x: contain; font-size: .84rem; }
.bubble pre code.hljs { background: transparent; padding: 0; }
.bubble code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.bubble :not(pre) > code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.bubble table { border-collapse: collapse; display: block; overflow-x: auto; overscroll-behavior-x: contain; }
.bubble th, .bubble td { border: 1px solid var(--hairline); padding: .375rem .625rem; }
.bubble blockquote { margin: .5em 0; padding-left: .75rem; border-left: 3px solid var(--accent); color: var(--fg2); }
.bubble img { max-width: 100%; }
.copy-code { position: absolute; top: .375rem; right: .375rem; font-size: .75rem; padding: .1875rem .5rem; border-radius: .5rem;
  border: 1px solid var(--hairline); background: var(--surface); cursor: pointer; opacity: .85; }

/* 欢迎页 */
.welcome { position: absolute; inset: 22% 1rem auto; text-align: center; pointer-events: none; }
.welcome-orb { width: 4rem; height: 4rem; margin: 0 auto 1rem; border-radius: 1.375rem; background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 12px 34px rgba(143, 91, 255, .45); animation: float 4s ease-in-out infinite; }
.welcome-orb svg { width: 2rem; height: 2rem; stroke: none; }
@keyframes float { 50% { transform: translateY(-6px); } }
.welcome h2 { font-weight: 700; font-size: 1.5rem; letter-spacing: -.01em; margin: 0 0 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; pointer-events: auto; max-width: 640px; margin: 0 auto; }
.chips button { border: 1px solid var(--hairline); background: var(--surface); box-shadow: var(--shadow); padding: .5rem .875rem;
  border-radius: 1.25rem; cursor: pointer; font-size: .875rem; transition: transform .15s; }
.chips button:active { transform: scale(.96); }

/* ---------- 输入区 ---------- */
#composer { padding: .5rem .75rem; padding-bottom: calc(var(--dock-h) + 1.25rem + var(--safe-bottom)); transition: padding .25s; }
body.typing #composer { padding-bottom: calc(.625rem + var(--safe-bottom)); }
.composer-box { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: .125rem; padding: .375rem;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 1.5rem; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .2s; }
.composer-box:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.composer-box.dragover { border-color: var(--accent); border-style: dashed; }
#input { flex: 1; border: none; outline: none; resize: none; background: transparent; padding: .5rem .25rem; max-height: 40vh; line-height: 1.5; }
.icon-btn.send { background: var(--grad); color: #fff; box-shadow: 0 4px 12px rgba(110, 80, 255, .4); }
.icon-btn.send.stop { background: var(--danger); box-shadow: 0 4px 12px rgba(255, 77, 103, .4); }
.icon-btn.recording { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.attachments { max-width: 820px; margin: 0 auto .375rem; display: flex; flex-wrap: wrap; gap: .375rem; }
.attachments:empty { display: none; }
.att { position: relative; display: flex; align-items: center; gap: .375rem; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: .75rem; padding: .25rem 1.75rem .25rem .25rem; font-size: .8125rem; max-width: 220px; box-shadow: var(--shadow); }
.att img { width: 2.75rem; height: 2.75rem; object-fit: cover; border-radius: .5rem; }
.att .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: .25rem; }
.att .rm { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); border: none; background: none; cursor: pointer; font-size: 1rem; color: var(--fg2); }

/* ---------- 设置弹窗 ---------- */
dialog { border: none; border-radius: 1.5rem; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: 90dvh;
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 10, 25, .4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#settingsForm, .dialog-form { padding: 1.25rem; display: grid; gap: .75rem; }
.dialog-form h2 { margin: 0 0 .25rem; }
.dialog-form label { display: grid; gap: .25rem; font-size: .875rem; color: var(--fg2); }
.dialog-form input { padding: .625rem .75rem; border-radius: .75rem; border: 1px solid var(--hairline); background: var(--surface-2); color: var(--fg); }
#settingsForm h2 { margin: 0 0 .25rem; }
#settingsForm label { display: grid; gap: .25rem; font-size: .875rem; color: var(--fg2); }
#settingsForm input:not([type=checkbox]), #settingsForm textarea, .row-inline select {
  padding: .625rem .75rem; border-radius: .75rem; border: 1px solid var(--hairline); background: var(--surface-2); color: var(--fg); }
#settingsForm label.check { display: flex; align-items: center; gap: .5rem; color: var(--fg); }
#settingsForm .row { display: grid; grid-template-columns: 1fr 1fr; gap: .625rem; }
#settingsForm fieldset { border: 1px solid var(--hairline); border-radius: 1rem; padding: .75rem; margin: 0; display: grid; gap: .625rem; min-width: 0; }
#settingsForm legend { padding: 0 .375rem; font-weight: 600; font-size: .875rem; }
.row-inline { display: flex; gap: .5rem; flex-wrap: wrap; }
.row-inline select { flex: 1; min-width: 0; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- 提示和图片预览 ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--dock-h) + 1.75rem + var(--safe-bottom)); transform: translateX(-50%); z-index: 50;
  background: color-mix(in srgb, var(--fg) 88%, transparent); color: var(--bg); padding: .5rem 1rem; border-radius: 1.25rem;
  font-size: .875rem; max-width: 90vw; box-shadow: var(--shadow-lg); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 60; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 95vw; max-height: 90dvh; border-radius: .75rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
