* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ================= 主题变量 =================
   每套主题 = 一组 CSS 变量；背景 SVG 的颜色也由变量驱动 */

:root, html[data-theme="dusk"] {
  --ink: #2b2b28; --ink-2: #6c6a62; --ink-3: #9b988d;
  --glass: rgba(250, 247, 240, 0.8);
  --glass-strong: rgba(250, 248, 242, 0.94);
  --line: rgba(60, 55, 40, 0.1);
  --accent: #23231f; --accent-ink: #f5f2ea;
  --whisper-bg: #2f4a3a; --whisper-ink: #eceadf;
  --tabbar-bg: rgba(252, 250, 244, 0.92);
  --tab-active-bg: #23231f; --tab-active-ink: #f2efe6;
  --chat-bg1: #f6f1e4; --chat-bg2: #efe8d6; --chat-bg3: #e7dfc9;
  --bar-bg: rgba(247, 243, 233, 0.85);
  --bubble-user-bg: rgba(38, 38, 34, 0.92); --bubble-user-ink: #f3f0e8;
  --input-bg: rgba(255, 255, 255, 0.6);
  --overlay: rgba(40, 34, 22, 0.35);
  --toast-bg: rgba(35, 32, 26, 0.9); --toast-ink: #f2efe6;
  --body-bg: #ddd2bb;
  /* 背景风景 */
  --sky1: #eae3d1; --sky2: #e4d7bf; --sky3: #d8c4a5; --sky4: #c9ae8c;
  --glow1: rgba(245, 207, 149, 0.9); --glow2: rgba(240, 196, 136, 0.35); --glow3: rgba(240, 196, 136, 0);
  --sun-core: #f3d9a4;
  --hill1: #b4b29a; --hill2: #93a086; --hill3: #70846e; --hill4: #4d5f4d;
  --tree: #394839;
  --bg-dim: rgba(255, 255, 255, 0);
}

html[data-theme="night"] {
  --ink: #e9e7e0; --ink-2: #a8a69e; --ink-3: #6f6d67;
  --glass: rgba(28, 30, 37, 0.72);
  --glass-strong: rgba(32, 34, 41, 0.95);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #e6dfd0; --accent-ink: #1d1f24;
  --whisper-bg: #24382e; --whisper-ink: #dfe6db;
  --tabbar-bg: rgba(24, 26, 32, 0.92);
  --tab-active-bg: #e6dfd0; --tab-active-ink: #1d1f24;
  --chat-bg1: #12151c; --chat-bg2: #141821; --chat-bg3: #161a23;
  --bar-bg: rgba(20, 23, 30, 0.88);
  --bubble-user-bg: rgba(230, 223, 208, 0.93); --bubble-user-ink: #1e2026;
  --input-bg: rgba(255, 255, 255, 0.08);
  --overlay: rgba(0, 0, 0, 0.5);
  --toast-bg: rgba(233, 231, 224, 0.95); --toast-ink: #1e2026;
  --body-bg: #101318;
  --sky1: #171e2c; --sky2: #131926; --sky3: #0f141e; --sky4: #0a0e16;
  --glow1: rgba(214, 226, 255, 0.5); --glow2: rgba(190, 205, 240, 0.18); --glow3: rgba(190, 205, 240, 0);
  --sun-core: #e9eeff;
  --hill1: #1e2836; --hill2: #18202c; --hill3: #121822; --hill4: #0b0f17;
  --tree: #060910;
  --bg-dim: rgba(255, 255, 255, 0);
}

html[data-theme="sakura"] {
  --ink: #43302e; --ink-2: #8a6a66; --ink-3: #b99d99;
  --glass: rgba(253, 246, 246, 0.82);
  --glass-strong: rgba(253, 248, 248, 0.95);
  --line: rgba(120, 60, 60, 0.12);
  --accent: #4a2f33; --accent-ink: #fdf3f0;
  --whisper-bg: #7c4a58; --whisper-ink: #fbeef0;
  --tabbar-bg: rgba(253, 248, 248, 0.92);
  --tab-active-bg: #4a2f33; --tab-active-ink: #fdf3f0;
  --chat-bg1: #fbf1ef; --chat-bg2: #f8e9e7; --chat-bg3: #f5e0df;
  --bar-bg: rgba(251, 241, 239, 0.88);
  --bubble-user-bg: rgba(74, 47, 51, 0.92); --bubble-user-ink: #fdf3f0;
  --input-bg: rgba(255, 255, 255, 0.65);
  --overlay: rgba(80, 40, 50, 0.35);
  --toast-bg: rgba(74, 47, 51, 0.92); --toast-ink: #fdf3f0;
  --body-bg: #f0dcd8;
  --sky1: #fceef0; --sky2: #f9dfe4; --sky3: #f3ccd5; --sky4: #e8b4c2;
  --glow1: rgba(255, 214, 220, 0.9); --glow2: rgba(250, 190, 200, 0.35); --glow3: rgba(250, 190, 200, 0);
  --sun-core: #ffe8ec;
  --hill1: #d8a8b4; --hill2: #bd8a9c; --hill3: #9c6f85; --hill4: #75526a;
  --tree: #5b3a55;
  --bg-dim: rgba(255, 255, 255, 0);
}

html[data-theme="pine"] {
  --ink: #22302a; --ink-2: #5c6e64; --ink-3: #8fa096;
  --glass: rgba(243, 249, 244, 0.8);
  --glass-strong: rgba(245, 251, 246, 0.94);
  --line: rgba(30, 60, 45, 0.12);
  --accent: #1e3229; --accent-ink: #eef7f0;
  --whisper-bg: #1e3229; --whisper-ink: #dcebe0;
  --tabbar-bg: rgba(244, 250, 245, 0.92);
  --tab-active-bg: #1e3229; --tab-active-ink: #eef7f0;
  --chat-bg1: #eff6f0; --chat-bg2: #e6f0e8; --chat-bg3: #dce9df;
  --bar-bg: rgba(239, 246, 240, 0.88);
  --bubble-user-bg: rgba(30, 50, 41, 0.92); --bubble-user-ink: #eef7f0;
  --input-bg: rgba(255, 255, 255, 0.62);
  --overlay: rgba(20, 50, 35, 0.35);
  --toast-bg: rgba(30, 50, 41, 0.92); --toast-ink: #eef7f0;
  --body-bg: #cfdfcf;
  --sky1: #ecf4ec; --sky2: #dcecdd; --sky3: #c2dcc5; --sky4: #a4c8ab;
  --glow1: rgba(240, 250, 235, 0.9); --glow2: rgba(215, 240, 210, 0.35); --glow3: rgba(215, 240, 210, 0);
  --sun-core: #f6fbee;
  --hill1: #9dbba0; --hill2: #7ba382; --hill3: #588765; --hill4: #3a6449;
  --tree: #274636;
  --bg-dim: rgba(255, 255, 255, 0);
}

html[data-theme="sky"] {
  --ink: #22303e; --ink-2: #5d7183; --ink-3: #93a7b8;
  --glass: rgba(246, 251, 254, 0.8);
  --glass-strong: rgba(248, 252, 255, 0.94);
  --line: rgba(40, 70, 100, 0.12);
  --accent: #1f3347; --accent-ink: #eef6fc;
  --whisper-bg: #2b5273; --whisper-ink: #e6f2fb;
  --tabbar-bg: rgba(246, 251, 254, 0.92);
  --tab-active-bg: #1f3347; --tab-active-ink: #eef6fc;
  --chat-bg1: #f0f7fc; --chat-bg2: #e7f1f8; --chat-bg3: #dceaf4;
  --bar-bg: rgba(240, 247, 252, 0.88);
  --bubble-user-bg: rgba(31, 51, 71, 0.92); --bubble-user-ink: #eef6fc;
  --input-bg: rgba(255, 255, 255, 0.62);
  --overlay: rgba(25, 50, 75, 0.35);
  --toast-bg: rgba(31, 51, 71, 0.92); --toast-ink: #eef6fc;
  --body-bg: #cfdfe9;
  --sky1: #eaf4fb; --sky2: #d7e9f6; --sky3: #bcd8ec; --sky4: #9cc3e0;
  --glow1: rgba(255, 244, 214, 0.9); --glow2: rgba(255, 228, 170, 0.35); --glow3: rgba(255, 228, 170, 0);
  --sun-core: #fff6dd;
  --hill1: #a8c3d4; --hill2: #86aac2; --hill3: #6490ad; --hill4: #44708f;
  --tree: #2d4d66;
  --bg-dim: rgba(255, 255, 255, 0);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--body-bg);
  overflow: hidden;
}

.serif { font-family: Georgia, "Times New Roman", "Songti SC", SimSun, serif; }
.muted { color: var(--ink-2); font-size: 13px; }
.hidden { display: none !important; }

/* ---------- 背景与整体布局 ---------- */

.bg-scene { position: fixed; inset: 0; z-index: 0; }
.bg-scene svg { width: 100%; height: 100%; display: block; }
.bg-scene .s-sky1 { stop-color: var(--sky1); } .bg-scene .s-sky2 { stop-color: var(--sky2); }
.bg-scene .s-sky3 { stop-color: var(--sky3); } .bg-scene .s-sky4 { stop-color: var(--sky4); }
.bg-scene .s-glow1 { stop-color: var(--glow1); } .bg-scene .s-glow2 { stop-color: var(--glow2); }
.bg-scene .s-glow3 { stop-color: var(--glow3); }
.bg-scene .sun-core { fill: var(--sun-core); }
.bg-scene .hill1 { fill: var(--hill1); } .bg-scene .hill2 { fill: var(--hill2); }
.bg-scene .hill3 { fill: var(--hill3); } .bg-scene .hill4 { fill: var(--hill4); }
.bg-scene .trees { fill: var(--tree); }

/* 自定义背景图：盖住 SVG，上暗下浅保证文字可读 */
.bg-scene img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none;
}
body.has-bg-img .bg-scene svg { display: none; }
body.has-bg-img .bg-scene img { display: block; }
body.has-bg-img .bg-scene::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,.28));
}

#login-view, #app-view, #chat-view, #modal-root, #toast { position: relative; z-index: 1; }

#login-view, #app-view {
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 毛玻璃 ---------- */

.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border-radius: var(--radius, 26px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 24px 60px rgba(40, 40, 30, 0.16);
}

/* ---------- 登录 ---------- */

#login-view { justify-content: center; }
.login-card { padding: 44px 34px; text-align: center; }
.brand { font-size: 13px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 18px; }
.login-card h1 { font-size: 30px; font-weight: 500; margin-bottom: 8px; }
.login-card input {
  width: 100%; margin-top: 26px; padding: 14px 18px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--input-bg);
  outline: none; color: var(--ink);
}
.login-card input:focus { border-color: rgba(70,60,40,.35); }
.err { color: #c05a3e; font-size: 12.5px; min-height: 18px; margin-top: 10px; }

.cta-black {
  width: 100%; margin-top: 14px; padding: 15px; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 999px;
  cursor: pointer; letter-spacing: 0.05em; transition: transform .15s ease;
}
.cta-black:active { transform: scale(.98); }

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 4px 10px;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
#top-date { font-size: 15px; }
.sync { font-size: 11.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.sync .dot { width: 6px; height: 6px; border-radius: 50%; background: #4a7c59; display: inline-block; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--input-bg); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.dark { background: var(--accent); border: none; color: var(--accent-ink); backdrop-filter: blur(10px); }

/* ---------- Tab 切换 ---------- */

.tab { flex: 1; overflow-y: auto; padding: 6px 2px 110px; scrollbar-width: thin; }
.tab-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 4px 14px; }
.tab-head h2 { font-size: 26px; font-weight: 500; }

/* ---------- 首页 ---------- */

.home-card { padding: 26px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.greeting h1, .greeting p { font-size: 28px; }
.greeting p#greet-title { font-size: 29px; font-weight: 500; }
.greeting .muted { margin-top: 6px; }

.char-chips { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.char-chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--input-bg);
  cursor: pointer; font-size: 13px; color: var(--ink); white-space: nowrap; flex: none;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #b8ae94, #8e9a86);
  background-size: cover; background-position: center;
  display: inline-flex; align-items: center; justify-content: center;
  color: #f5f2ea; font-size: 16px; overflow: hidden;
}
.avatar.small { width: 28px; height: 28px; font-size: 12px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 悄悄话 */
.whisper-card {
  background: var(--whisper-bg); color: var(--whisper-ink); border-radius: 20px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; position: relative;
}
.whisper-head { display: flex; align-items: center; gap: 10px; }
.whisper-meta { display: flex; flex-direction: column; }
.whisper-meta b { font-size: 13px; letter-spacing: 0.04em; }
.whisper-meta span { font-size: 11px; opacity: .7; }
.whisper-card .avatar { border: 1.5px solid rgba(255,255,255,.5); }
#whisper-text { font-size: 14.5px; line-height: 1.65; min-height: 24px; }
#whisper-text.pending { opacity: .6; }
.whisper-btn {
  position: absolute; right: 14px; top: 14px;
  width: 32px; height: 32px; border-radius: 11px; border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12); color: var(--whisper-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.whisper-btn svg { width: 16px; height: 16px; }
.whisper-btn:disabled { opacity: .5; cursor: default; }

/* Us / Day */
.us-row { display: flex; align-items: center; gap: 18px; }
.us-block { flex: 1.2; display: flex; flex-direction: column; gap: 2px; }
.us-label { font-size: 15px; color: var(--ink-2); font-style: italic; }
.us-num { display: flex; align-items: baseline; gap: 10px; }
.us-num span { font-size: 74px; line-height: 1; font-weight: 400; }
.us-num em { font-style: italic; font-size: 17px; color: var(--ink-2); font-family: Georgia, serif; }
.day-pill {
  align-self: flex-start; margin-top: 8px; font-size: 11px; padding: 3px 10px;
  background: var(--input-bg); border-radius: 999px; color: var(--ink-2);
}
.ring-block { flex: 1; display: flex; align-items: center; gap: 14px; }
.ring { width: 64px; height: 64px; flex: none; }
.ring .ring-track { stroke: var(--line); }
.ring .ring-arc { stroke: var(--accent); }
.ring-meta b { font-size: 13px; line-height: 1.3; display: block; color: var(--ink); }
.ring-meta span { font-size: 11.5px; color: var(--ink-2); }

/* 统计 */
.stats-row {
  display: flex; align-items: center; padding: 14px 6px 2px;
  border-top: 1px dashed var(--line);
}
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.stat b { font-size: 22px; font-weight: 500; }
.stat span { font-size: 11.5px; color: var(--ink-2); letter-spacing: 0.08em; }
.stat-divider { width: 1px; height: 30px; background: var(--line); }

.empty-state { text-align: center; padding: 48px 28px; }
.empty-state h1 { font-size: 26px; font-weight: 500; margin-bottom: 10px; }
.empty-state .muted { margin-bottom: 22px; }

/* ---------- 列表（会话 / 记忆） ---------- */

.list-card { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.list-empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 34px 10px; }

.session-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 18px; cursor: pointer; transition: background .15s;
}
.session-item:hover, .session-item:active { background: var(--input-bg); }
.session-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.session-meta b { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-meta span { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-time { font-size: 11px; color: var(--ink-3); flex: none; }

.mem-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 0 6px 12px; }
.link-btn {
  background: none; border: none; color: var(--ink-2); font-size: 13px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px;
}
.link-btn.danger { color: #c05a3e; }

.memory-item {
  padding: 13px 16px; border-radius: 18px; display: flex; align-items: flex-start; gap: 10px;
}
.memory-item:hover { background: var(--input-bg); }
.memory-item.disabled { opacity: .45; }
.memory-item p { flex: 1; font-size: 13.5px; line-height: 1.6; }
.memory-item .tag { font-size: 10.5px; color: var(--ink-3); flex: none; margin-top: 2px; }
.memory-item .ops { display: flex; gap: 2px; flex: none; }
.mini-btn {
  width: 28px; height: 28px; border: none; background: none; color: var(--ink-3);
  cursor: pointer; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
}
.mini-btn:hover { background: var(--line); color: var(--ink); }
.mini-btn svg { width: 15px; height: 15px; }

/* ---------- 表单卡片 ---------- */

.form-card { padding: 22px 22px 20px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.form-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.form-card label { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.form-card input:not([type=range]):not([type=checkbox]), .form-card textarea, .form-card select {
  padding: 11px 14px; font-size: 14px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--input-bg); outline: none; color: var(--ink); font-family: inherit; resize: vertical;
}
.form-card textarea { min-height: 130px; }
.form-card input:focus, .form-card textarea:focus { border-color: rgba(70,60,40,.35); }
.form-card input[type=range] { margin: 8px 0; accent-color: var(--accent); }
.form-card .cta-black { margin-top: 14px; }

.me-char-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.me-char-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 14px; background: var(--input-bg); font-size: 13.5px;
}
.me-char-row span { flex: 1; }

/* 主题选择 */
.theme-row { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-dot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer; font-size: 11px; color: var(--ink-2);
}
.theme-dot .swatch {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 2px 8px rgba(0,0,0,.15);
}
.theme-dot.active .swatch { border-color: var(--accent); }
.theme-dot.active { color: var(--ink); font-weight: 600; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.switch-row span { font-size: 13.5px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: .2s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- 底部导航 ---------- */

.tabbar {
  position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 7px;
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 999px; border: 1px solid rgba(255,255,255,.4);
  box-shadow: 0 14px 40px rgba(50,45,30,.22);
  z-index: 30;
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 72px; padding: 8px 10px; border: none; background: none;
  color: var(--ink-2); font-size: 10.5px; cursor: pointer; border-radius: 18px;
}
.tab-btn svg { width: 21px; height: 21px; }
.tab-btn.active { background: var(--tab-active-bg); color: var(--tab-active-ink); }

/* ---------- 聊天界面 ---------- */

#chat-view {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  max-width: 540px; margin: 0 auto;
  background: linear-gradient(180deg, var(--chat-bg1) 0%, var(--chat-bg2) 55%, var(--chat-bg3) 100%);
}

.chat-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bar-bg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.3);
}
.chat-title-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title-meta b { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title-meta .muted { font-size: 11.5px; }

#chat-scroll {
  flex: 1; overflow-y: auto; padding: 18px 14px 10px; scrollbar-width: thin;
}
#messages { display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin: 0 auto; }

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg .avatar { margin-top: 2px; }

.msg-body { max-width: 78%; display: flex; flex-direction: column; gap: 5px; }
.msg.user .msg-body { align-items: flex-end; }

.bubble {
  padding: 11px 15px; font-size: 14.5px; line-height: 1.65; word-break: break-word;
  background: var(--glass-strong); border-radius: 4px 20px 20px 20px;
  border: 1px solid rgba(255,255,255,.4);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.msg.user .bubble {
  background: var(--bubble-user-bg); color: var(--bubble-user-ink); border-radius: 20px 4px 20px 20px; border: none;
}
.bubble code { background: var(--line); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.bubble.streaming::after {
  content: "▍"; animation: blink 1s steps(2) infinite; color: var(--ink-2);
}
@keyframes blink { 50% { opacity: 0; } }

.msg-ops { display: flex; align-items: center; gap: 2px; opacity: .55; }
.msg-ops:hover, .msg-ops:active { opacity: 1; }
.msg-ops .mini-btn { width: 26px; height: 26px; }
.msg-ops .mini-btn svg { width: 14px; height: 14px; }
.swipe-chip { font-size: 10.5px; color: var(--ink-3); padding: 0 4px; user-select: none; }

.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--bar-bg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,.3);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 18px;
  background: var(--input-bg); padding: 11px 16px; font-size: 14.5px;
  font-family: inherit; color: var(--ink); outline: none; max-height: 140px; line-height: 1.5;
}
.composer textarea:focus { border-color: rgba(70,60,40,.35); }
.send-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:disabled { opacity: .4; }
.send-btn.stop { background: #c05a3e; color: #fff; }

/* ---------- 模态与 Toast ---------- */

#modal-root {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 24px;
}
.modal {
  width: 100%; max-width: 420px; background: var(--glass-strong);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 24px; border: 1px solid rgba(255,255,255,.5);
  padding: 24px 22px; max-height: 80dvh; overflow-y: auto;
}
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.modal .sub { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: 12px 14px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 13px; background: var(--input-bg); outline: none; color: var(--ink);
  font-family: inherit; resize: vertical;
}
.modal .row { display: flex; gap: 10px; margin-top: 18px; }
.modal .row button { flex: 1; padding: 12px; border-radius: 999px; border: none; font-size: 14px; cursor: pointer; }
.btn-ghost { background: var(--line); color: var(--ink); }
.btn-solid { background: var(--accent); color: var(--accent-ink); }
.btn-danger { background: #c05a3e; color: #fff; }

.pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px; border-radius: 16px; cursor: pointer; border: 1px solid transparent;
  font-size: 12.5px; text-align: center; word-break: break-all;
}
.pick-item:hover { background: var(--input-bg); }
.pick-item .avatar { width: 52px; height: 52px; font-size: 20px; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; background: var(--toast-bg); color: var(--toast-ink);
  padding: 10px 20px; border-radius: 999px; font-size: 13px; max-width: 86vw;
  text-align: center; pointer-events: none;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* 滚动条 */
.tab::-webkit-scrollbar, #chat-scroll::-webkit-scrollbar { width: 4px; }
.tab::-webkit-scrollbar-thumb, #chat-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
