/* WepChat 设计系统 —— 追求 Android 原生质感 */

:root {
  --bg: #ffffff;
  --bg2: #f6f6f8;
  --surface: #f1f1f4;
  --surface2: #e9e9ee;
  --surface-hover: #ececf0;
  --surface-active: #e4e4e9;
  --input-bg: rgba(241, 241, 244, 0.78);
  --card-bg: #f6f6f8;
  --text: #101012;
  --text2: #6d6d76;
  --text3: #9b9ba4;
  --border: rgba(0, 0, 0, 0.09);
  --accent: #101012;
  --accent-fg: #ffffff;
  --danger: #e0342b;
  --success: #16824f;
  --warning: #c77a08;
  --info: #2872e1;
  --link: #2872e1;
  --bubble-user: #f1f1f4;
  --bubble-assistant: transparent;
  --code-bg: #f7f7f9;
  --code-head: #ececf0;
  --overlay: rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  --status-bar-bg: #ffffff;
  --nav-bar-bg: #ffffff;
  --glass-bg: rgba(244, 244, 247, 0.2);
  --glass-panel-bg: rgba(248, 248, 250, 0.14);
  --glass-orb-bg: rgba(248, 248, 250, 0.08);
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-edge: rgba(15, 15, 20, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 10px 30px rgba(20, 20, 28, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.66);
  --raised-shadow: 0 7px 18px rgba(30, 30, 40, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --pressed-shadow: inset 0 2px 5px rgba(25, 25, 35, 0.12), 0 1px 2px rgba(30, 30, 40, 0.05);
  --glass-blur: 22px;
  --content-width: 760px;
  --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --radius: 16px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --fs-chat: 16px;
}

html.dark {
  --bg: #131316;
  --bg2: #18181c;
  --surface: #202024;
  --surface2: #2a2a30;
  --surface-hover: #29292e;
  --surface-active: #323238;
  --input-bg: rgba(32, 32, 36, 0.76);
  --card-bg: #18181c;
  --text: #ececee;
  --text2: #a2a2ac;
  --text3: #71717b;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #ececee;
  --accent-fg: #131316;
  --danger: #ff5449;
  --success: #69d79b;
  --warning: #f5a524;
  --info: #8ab8ff;
  --link: #6ea8ff;
  --bubble-user: #242429;
  --bubble-assistant: transparent;
  --code-bg: #1b1b1f;
  --code-head: #26262b;
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --status-bar-bg: #131316;
  --nav-bar-bg: #131316;
  --glass-bg: rgba(31, 31, 36, 0.24);
  --glass-panel-bg: rgba(27, 27, 32, 0.2);
  --glass-orb-bg: rgba(35, 35, 40, 0.12);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-edge: rgba(0, 0, 0, 0.5);
  --glass-highlight: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 12px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --raised-shadow: 0 8px 22px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  --pressed-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.42), 0 1px 1px rgba(255, 255, 255, 0.03);
}

/* 暖纸：温暖、舒展、接近纸张阅读 */
html[data-theme="warm-paper"] {
  --bg: #f7f4ed; --bg2: #f0ece3; --surface: #eae5db; --surface2: #dfd8cb;
  --surface-hover: #e4ded2; --surface-active: #d9d1c4; --input-bg: rgba(239, 234, 224, 0.76);
  --card-bg: #f1ede5; --text: #2d2a26; --text2: #706960; --text3: #9a9287;
  --border: rgba(73, 60, 46, 0.12); --accent: #bd6042; --accent-fg: #fffaf5;
  --danger: #bd473b; --success: #3f7d55; --warning: #b87518; --info: #5f7394;
  --link: #9f5138; --bubble-user: #e8dfd2; --code-bg: #eee8dd; --code-head: #e2d9cb;
  --status-bar-bg: #f7f4ed; --nav-bar-bg: #f7f4ed;
  --glass-bg: rgba(242, 237, 227, 0.2); --glass-panel-bg: rgba(247, 242, 233, 0.14); --glass-orb-bg: rgba(248, 243, 234, 0.08); --glass-border: rgba(255, 253, 248, 0.78);
  --glass-edge: rgba(87, 68, 48, 0.13); --glass-highlight: rgba(255, 254, 250, 0.88);
  --glass-shadow: 0 12px 32px rgba(77, 59, 39, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --content-width: 720px; --radius: 18px;
}
html.dark[data-theme="warm-paper"] {
  --bg: #1c1a18; --bg2: #221f1c; --surface: #2b2723; --surface2: #37312b;
  --surface-hover: #342f2a; --surface-active: #403932; --input-bg: rgba(42, 38, 34, 0.76);
  --card-bg: #221f1c; --text: #f0ece5; --text2: #b7aea2; --text3: #817970;
  --border: rgba(255, 239, 220, 0.11); --accent: #df7957; --accent-fg: #211814;
  --danger: #f17668; --success: #78bd8b; --warning: #e5aa52; --info: #9eb3d2;
  --link: #e39170; --bubble-user: #342e29; --code-bg: #24211e; --code-head: #302b26;
  --status-bar-bg: #1c1a18; --nav-bar-bg: #1c1a18;
  --glass-bg: rgba(43, 38, 34, 0.24); --glass-panel-bg: rgba(37, 33, 29, 0.2); --glass-orb-bg: rgba(48, 43, 38, 0.12); --glass-border: rgba(255, 239, 220, 0.14);
  --glass-edge: rgba(0, 0, 0, 0.54); --glass-highlight: rgba(255, 244, 230, 0.18);
}

/* 星云：Gemini / Material 式冷色与圆润层级 */
html[data-theme="nebula"] {
  --bg: #f7f9ff; --bg2: #f0f3fb; --surface: #e9eef9; --surface2: #dce4f3;
  --surface-hover: #e0e7f5; --surface-active: #d4deef; --input-bg: rgba(235, 240, 251, 0.74);
  --card-bg: #f0f3fb; --text: #20242c; --text2: #626a79; --text3: #8d96a7;
  --border: rgba(47, 70, 110, 0.11); --accent: #3978f6; --accent-fg: #ffffff;
  --danger: #d84747; --success: #19845c; --warning: #bd760c; --info: #3978f6;
  --link: #356fd7; --bubble-user: #e3eaf8; --code-bg: #edf1f9; --code-head: #dfe6f3;
  --status-bar-bg: #f7f9ff; --nav-bar-bg: #f7f9ff;
  --glass-bg: rgba(235, 241, 253, 0.2); --glass-panel-bg: rgba(242, 246, 255, 0.14); --glass-orb-bg: rgba(242, 246, 255, 0.08); --glass-border: rgba(255, 255, 255, 0.78);
  --glass-edge: rgba(65, 91, 145, 0.13); --glass-highlight: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 12px 34px rgba(69, 91, 140, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.76);
  --radius: 22px;
}
html.dark[data-theme="nebula"] {
  --bg: #10131b; --bg2: #151925; --surface: #1b2130; --surface2: #252d40;
  --surface-hover: #232a3b; --surface-active: #2d364b; --input-bg: rgba(28, 34, 49, 0.74);
  --card-bg: #151925; --text: #edf1fa; --text2: #abb5c8; --text3: #727d91;
  --border: rgba(183, 205, 255, 0.11); --accent: #8ab4ff; --accent-fg: #101827;
  --danger: #ff716c; --success: #72d7aa; --warning: #f1b85b; --info: #8ab4ff;
  --link: #9dc0ff; --bubble-user: #20283a; --code-bg: #171c28; --code-head: #22293a;
  --status-bar-bg: #10131b; --nav-bar-bg: #10131b;
  --glass-bg: rgba(28, 34, 50, 0.24); --glass-panel-bg: rgba(24, 30, 44, 0.2); --glass-orb-bg: rgba(34, 41, 58, 0.12); --glass-border: rgba(181, 205, 255, 0.15);
  --glass-edge: rgba(0, 0, 0, 0.55); --glass-highlight: rgba(184, 208, 255, 0.2);
}

/* 澄镜：Apple 式中性层级与更清透的控制层 */
html[data-theme="clear-glass"] {
  --bg: #f5f5f7; --bg2: #ededf0; --surface: #e5e5e9; --surface2: #dadae0;
  --surface-hover: #dfdfe4; --surface-active: #d4d4db; --input-bg: rgba(242, 242, 246, 0.62);
  --card-bg: rgba(250, 250, 252, 0.82); --text: #171719; --text2: #66666d; --text3: #8d8d95;
  --border: rgba(0, 0, 0, 0.1); --accent: #087cf0; --accent-fg: #ffffff;
  --danger: #d9342b; --success: #16824f; --warning: #bd7508; --info: #087cf0;
  --link: #087cf0; --bubble-user: rgba(226, 226, 232, 0.82); --code-bg: #ededf1; --code-head: #e1e1e7;
  --status-bar-bg: #f5f5f7; --nav-bar-bg: #f5f5f7;
  --glass-bg: rgba(245, 245, 249, 0.12); --glass-panel-bg: rgba(248, 248, 251, 0.08); --glass-orb-bg: rgba(250, 250, 252, 0.05); --glass-border: rgba(255, 255, 255, 0.9);
  --glass-edge: rgba(0, 0, 0, 0.12); --glass-highlight: rgba(255, 255, 255, 0.96);
  --glass-shadow: 0 14px 38px rgba(35, 35, 45, 0.16), inset 0 1px 0 #fff;
  --glass-blur: 26px; --radius: 20px;
}
html.dark[data-theme="clear-glass"] {
  --bg: #09090b; --bg2: #111114; --surface: #19191d; --surface2: #25252a;
  --surface-hover: #222227; --surface-active: #2c2c32; --input-bg: rgba(27, 27, 32, 0.6);
  --card-bg: rgba(20, 20, 24, 0.84); --text: #f4f4f6; --text2: #a9a9b0; --text3: #72727a;
  --border: rgba(255, 255, 255, 0.12); --accent: #0a84ff; --accent-fg: #ffffff;
  --danger: #ff6259; --success: #68d391; --warning: #f5b84c; --info: #69adff;
  --link: #69adff; --bubble-user: rgba(39, 39, 44, 0.86); --code-bg: #151518; --code-head: #202024;
  --status-bar-bg: #09090b; --nav-bar-bg: #09090b;
  --glass-bg: rgba(30, 30, 35, 0.16); --glass-panel-bg: rgba(25, 25, 30, 0.12); --glass-orb-bg: rgba(38, 38, 44, 0.07); --glass-border: rgba(255, 255, 255, 0.19);
  --glass-edge: rgba(0, 0, 0, 0.62); --glass-highlight: rgba(255, 255, 255, 0.25);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

/* 常规毛玻璃：更高的不透明度与原生 backdrop blur，避免 SVG 位移滤镜开销 */
html:not(.real-glass) {
  --glass-bg: rgba(244, 244, 247, 0.7);
  --glass-panel-bg: rgba(248, 248, 250, 0.56);
  --glass-orb-bg: rgba(248, 248, 250, 0.36);
}
html.dark:not(.real-glass) {
  --glass-bg: rgba(31, 31, 36, 0.72);
  --glass-panel-bg: rgba(27, 27, 32, 0.62);
  --glass-orb-bg: rgba(35, 35, 40, 0.42);
}
html:not(.real-glass)[data-theme="warm-paper"] {
  --glass-bg: rgba(242, 237, 227, 0.72);
  --glass-panel-bg: rgba(247, 242, 233, 0.58);
  --glass-orb-bg: rgba(248, 243, 234, 0.4);
}
html.dark:not(.real-glass)[data-theme="warm-paper"] {
  --glass-bg: rgba(43, 38, 34, 0.73);
  --glass-panel-bg: rgba(37, 33, 29, 0.62);
  --glass-orb-bg: rgba(48, 43, 38, 0.44);
}
html:not(.real-glass)[data-theme="nebula"] {
  --glass-bg: rgba(235, 241, 253, 0.7);
  --glass-panel-bg: rgba(242, 246, 255, 0.56);
  --glass-orb-bg: rgba(242, 246, 255, 0.38);
}
html.dark:not(.real-glass)[data-theme="nebula"] {
  --glass-bg: rgba(28, 34, 50, 0.72);
  --glass-panel-bg: rgba(24, 30, 44, 0.62);
  --glass-orb-bg: rgba(34, 41, 58, 0.44);
}
html:not(.real-glass)[data-theme="clear-glass"] {
  --glass-bg: rgba(245, 245, 249, 0.54);
  --glass-panel-bg: rgba(248, 248, 251, 0.4);
  --glass-orb-bg: rgba(250, 250, 252, 0.28);
}
html.dark:not(.real-glass)[data-theme="clear-glass"] {
  --glass-bg: rgba(30, 30, 35, 0.58);
  --glass-panel-bg: rgba(25, 25, 30, 0.48);
  --glass-orb-bg: rgba(38, 38, 44, 0.32);
}

html.fs-large { --fs-chat: 17.5px; }
html.plus-app { --sat: 0px; }

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

[v-cloak] { display: none; }
.liquid-glass-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.app-lock-screen {
  position: fixed; inset: 0; z-index: 2000; padding: calc(var(--sat) + 24px) 24px calc(var(--sab) + 24px);
  display: grid; place-items: center; color: #f5f5f7;
  background: radial-gradient(circle at 28% 12%, rgba(80,228,108,.16), transparent 34%), #090a0d;
}
.app-lock-card { width: min(100%, 340px); display: flex; flex-direction: column; align-items: center; text-align: center; }
.app-lock-card img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 20px 34px rgba(0,0,0,.38)); }
.app-lock-card h2 { margin-top: 18px; font-size: 24px; }.app-lock-card p { margin-top: 7px; color: rgba(255,255,255,.58); font-size: 13px; }
.app-lock-card input { width: 100%; height: 52px; margin-top: 26px; padding: 0 16px; border: 1px solid rgba(255,255,255,.14); border-radius: 15px; color: #fff; background: rgba(255,255,255,.07); text-align: center; font-size: 19px; letter-spacing: .2em; }
.app-lock-card input:focus { border-color: rgba(109,240,125,.55); box-shadow: 0 0 0 3px rgba(109,240,125,.1); }
.app-lock-error { margin-top: 9px; color: #ff7b72; font-size: 12px; }
.app-lock-submit { width: 100%; height: 49px; margin-top: 14px; border-radius: 15px; color: #0b170d; background: #6df07d; font-weight: 750; }
.app-lock-submit:disabled { opacity: .35; }
.app-lock-card small { margin-top: 17px; color: rgba(255,255,255,.36); font-size: 10.5px; line-height: 1.55; }
.app-lock-fade-enter-active, .app-lock-fade-leave-active { transition: opacity .22s; }.app-lock-fade-enter-from, .app-lock-fade-leave-to { opacity: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--app-font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { height: 100%; }

button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
button:active { opacity: 0.6; }
input, textarea, select {
  font: inherit; color: var(--text); background: none; border: none; outline: none;
  user-select: text; -webkit-user-select: text;
}
a { color: var(--link); text-decoration: none; }

::-webkit-scrollbar { width: 0; height: 0; }

/* ============ 布局骨架 ============ */
.shell { height: 100%; display: flex; flex-direction: column; position: relative; }
.shell.page-covered { visibility: hidden; content-visibility: hidden; pointer-events: none; }

.topbar {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--sat) + 6px) 8px 6px;
  background: var(--bg);
  position: relative; z-index: 5;
}
html.plus-app .topbar { padding-top: 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 21px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); flex: none;
  transition: background .18s, transform .18s cubic-bezier(.22,.8,.3,1), box-shadow .18s;
}
.icon-btn:active { background: var(--surface); opacity: 1; transform: translateY(1px) scale(.94); box-shadow: var(--pressed-shadow); }
.icon-btn svg { width: 23px; height: 23px; }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn.danger { color: var(--danger); }
.topbar .model-pill + .icon-btn { margin-left: auto; }

.connection-banner {
  flex: 0 0 auto; width: calc(100% - 20px); margin: 8px 10px 0; padding: 9px 11px;
  border: 1px solid rgba(210,45,45,.42); border-radius: 10px; background: rgba(215,45,45,.12);
  color: #b42323; display: flex; align-items: center; gap: 8px; text-align: left;
  font-size: 12px; line-height: 1.35;
}
.connection-banner.ok { border-color: rgba(28,140,79,.35); background: rgba(28,140,79,.11); color: #167044; }
.connection-banner.info { border-color: rgba(45,105,190,.35); background: rgba(45,105,190,.1); color: #285caa; }
.connection-code { flex: 0 0 auto; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.connection-message { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.connection-attempt { flex: 0 0 auto; font-weight: 700; }
.connection-close {
  flex: 0 0 auto; width: 24px; height: 24px; margin: -4px -4px -4px 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: currentColor;
  font-size: 20px; line-height: 1; opacity: .78;
}
.connection-close:active { background: rgba(127,127,127,.16); opacity: 1; }
.image-recovery-btn { margin-top: 9px; padding: 8px 11px; border: 1px solid rgba(210,45,45,.35); border-radius: 9px; background: rgba(215,45,45,.08); color: var(--danger); font-size: 12px; font-weight: 700; }
.image-recovery-btn:disabled { opacity: .45; }
html.dark .connection-banner { color: #ff8b86; background: rgba(220,55,55,.18); border-color: rgba(255,100,95,.38); }
html.dark .connection-banner.ok { color: #69d79b; background: rgba(40,160,95,.16); border-color: rgba(80,210,135,.35); }
html.dark .connection-banner.info { color: #8ab8ff; background: rgba(50,105,190,.16); border-color: rgba(100,155,235,.35); }

.model-pill {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: auto; max-width: min(40vw, 190px); min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 42px; padding: 0 8px; border-radius: 21px; overflow: hidden;
  transition: background .18s, transform .2s cubic-bezier(.22,.8,.3,1), box-shadow .18s;
}
.model-pill:active { background: var(--surface); opacity: 1; transform: translateX(-50%) translateY(1px) scale(.97); box-shadow: var(--pressed-shadow); }
.model-pill .mp-name {
  font-weight: 600; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-pill .mp-sub { color: var(--text3); font-size: 12px; margin-top: -2px; }
.model-pill svg { width: 16px; height: 16px; color: var(--text3); flex: none; }
.mp-col { min-width: 0; display: flex; flex-direction: column; align-items: center; }

/* ============ 消息区 ============ */
.chat-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.chat-inner { max-width: var(--content-width); margin: 0 auto; padding: 8px 16px 174px; }

.msg { margin: 18px 0; font-size: var(--fs-chat); }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  background: var(--bubble-user); border-radius: 20px 20px 6px 20px;
  padding: 10px 15px; max-width: 86%;
  white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text;
}
html[data-theme="warm-paper"] .msg { margin: 21px 0; line-height: 1.66; }
html[data-theme="warm-paper"] .msg-user .bubble { border-radius: 18px 18px 7px 18px; }
html[data-theme="nebula"] .msg { margin: 20px 0; line-height: 1.58; }
html[data-theme="nebula"] .msg-user .bubble { border-radius: 22px 22px 8px 22px; }
html[data-theme="clear-glass"] .msg-user .bubble { border: 1px solid var(--border); box-shadow: inset 0 1px 0 var(--glass-highlight); }
.msg-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.att-chip {
  display: flex; align-items: center; gap: 6px; padding: 7px 11px;
  background: var(--surface); border-radius: 12px; font-size: 12.5px; color: var(--text2);
  max-width: 220px;
}
.att-chip .an { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip svg { width: 15px; height: 15px; flex: none; }
.att-img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }

.msg-assistant .md { user-select: text; -webkit-user-select: text; }
.image-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 8px; margin: 8px 0 4px; max-width: 520px;
}
.gen-img {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--bg2); text-align: left;
}
.gen-img img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--surface); }
.gen-img span {
  display: block; padding: 7px 9px; color: var(--text3); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.html-preview-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.html-preview-card {
  width: min(100%, 520px); border: 1px solid var(--border); border-radius: 14px;
  background: var(--bg2); overflow: hidden; text-align: left;
}
.html-preview-card:active { background: var(--surface); opacity: 1; }
.html-preview-head { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.html-preview-title { font-size: 14px; font-weight: 650; color: var(--text); line-height: 1.25; }
.html-preview-path {
  color: var(--text3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.html-preview-frame-wrap {
  height: 220px; background: #fff; border-top: 1px solid var(--border);
  overflow: hidden; position: relative;
}
.html-preview-frame {
  width: 100%; height: 100%; border: 0; display: block; pointer-events: none; background: #fff;
}
.js-run-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px;
  border-top: 1px solid var(--border); background: var(--code-bg);
}
.js-run-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-fg);
}
.js-run-icon svg { width: 20px; height: 20px; }
.js-run-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.js-run-copy span { font-size: 13.5px; font-weight: 650; color: var(--text); }
.js-run-copy small {
  color: var(--text3); font-size: 12px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 消息操作行 */
.msg-actions {
  display: flex; gap: 2px; margin-top: 6px; opacity: 0.75;
}
.ma-btn {
  width: 34px; height: 30px; border-radius: 8px; color: var(--text3);
  display: flex; align-items: center; justify-content: center;
}
.ma-btn svg { width: 16.5px; height: 16.5px; }
.ma-btn:active { background: var(--surface); color: var(--text); opacity: 1; }
.msg-model-tag { font-size: 11.5px; color: var(--text3); align-self: center; margin-left: 6px; }

/* 思考过程 */
.reasoning {
  border-left: 2.5px solid var(--border);
  padding: 2px 0 2px 12px; margin: 4px 0 10px;
  color: var(--text2); font-size: 13.5px;
}
.reasoning-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text2); font-size: 13px; padding: 4px 0; font-weight: 500;
}
.reasoning-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.reasoning-toggle.open svg { transform: rotate(90deg); }
.reasoning-body { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }

/* 工具调用卡片 */
.tool-card {
  border: 1px solid var(--border); border-radius: 14px;
  margin: 10px 0; overflow: hidden; background: var(--bg2);
  font-size: 13.5px;
}

/* 思考过程卡片 */
.reasoning-card { border-left: 2.5px solid #8b5cf6; }
.reasoning-card .tool-ic { background: rgba(139, 92, 246, 0.12); }
.reasoning-card .tool-ic svg { color: #8b5cf6; }
html.dark .reasoning-card { border-left-color: #a78bfa; }
html.dark .reasoning-card .tool-ic svg { color: #a78bfa; }
.reasoning-card .reasoning-body {
  color: var(--text2); white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto; user-select: text; -webkit-user-select: text;
  font-size: 13px; line-height: 1.6;
}
.tool-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 13px; width: 100%; text-align: left;
}
.tool-head:active { background: var(--surface); opacity: 1; }
.tool-ic {
  width: 28px; height: 28px; border-radius: 8px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.tool-ic svg { width: 16px; height: 16px; color: var(--text2); }
.tool-status { color: var(--text3); font-size: 12px; flex: none; display: flex; align-items: center; gap: 5px; }
.tool-body { border-top: 1px solid var(--border); padding: 10px 13px; }
.tool-sec { color: var(--text3); font-size: 11.5px; margin: 6px 0 3px; font-weight: 600; letter-spacing: 0.4px; }
.tool-pre {
  background: var(--code-bg); border-radius: 8px; padding: 8px 10px;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 12px; white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto; user-select: text; -webkit-user-select: text;
}
.diff-view {
  background: var(--code-bg); border-radius: 8px; overflow: auto;
  max-height: 260px; border: 1px solid var(--border);
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 12px; user-select: text; -webkit-user-select: text;
}
.df-line { padding: 2px 10px; white-space: pre; min-height: 20px; }
.df-line.meta { color: var(--text3); background: var(--code-head); font-weight: 600; }
.df-line.add { color: #16783a; background: rgba(52, 199, 89, 0.12); }
.df-line.del { color: var(--danger); background: rgba(224, 52, 43, 0.1); }
html.dark .df-line.add { color: #7ee09d; background: rgba(52, 199, 89, 0.14); }

/* 加载指示 */
.typing-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--text);
  display: inline-block; animation: pulse 1s ease-in-out infinite; margin: 6px 0;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1);} 50% { opacity: 0.35; transform: scale(0.8);} }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--text2);
  border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-box {
  background: rgba(224, 52, 43, 0.08); color: var(--danger);
  border-radius: 12px; padding: 10px 13px; font-size: 13.5px; margin: 8px 0;
  user-select: text; -webkit-user-select: text;
}
.err-retry { font-weight: 600; margin-left: 8px; color: var(--danger); text-decoration: underline; }

/* 空状态 */
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.empty-logo {
  width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700;
  margin-bottom: 14px;
}
.empty-title { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.empty-sub { color: var(--text3); font-size: 14px; margin-bottom: 26px; }
.sugg-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; }
.sugg {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px;
  text-align: left; font-size: 14px; color: var(--text2); background: var(--bg);
}
.sugg:active { background: var(--surface); opacity: 1; }
.sugg b { color: var(--text); font-weight: 600; display: block; margin-bottom: 1px; }

/* ============ 底部输入区 ============ */
.composer-wrap {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 14px;
  padding: 8px 12px calc(var(--sab) + 8px);
  pointer-events: none;
  background: none;
}
.composer {
  max-width: var(--content-width); margin: 0 auto; pointer-events: auto; position: relative; overflow: hidden; isolation: isolate;
  background: transparent; border: 1px solid var(--glass-edge); border-radius: 27px;
  padding: 8px 8px 8px 6px;
  display: flex; flex-direction: column;
  box-shadow: var(--glass-shadow);
  contain: layout paint style;
}
.composer::before {
  content: ""; position: absolute; inset: -10px; z-index: 0; border-radius: inherit; pointer-events: none;
  background: var(--glass-bg);
  background: linear-gradient(145deg, color-mix(in srgb, var(--glass-highlight) 52%, transparent), transparent 34%), var(--glass-bg);
  -webkit-backdrop-filter: blur(2px) saturate(1.28); backdrop-filter: blur(2px) saturate(1.28);
  filter: url("#wc-liquid-composer"); transform: translateZ(0);
}
.comp-attach, .comp-row { position: relative; z-index: 1; }
.comp-attach { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 8px; }
.comp-row { display: flex; align-items: flex-end; gap: 4px; }
.comp-input {
  flex: 1; resize: none; max-height: 132px; min-height: 24px;
  padding: 7px 6px; font-size: 16px; line-height: 1.45;
  background: transparent; overflow-y: auto;
}
.comp-input::placeholder { color: var(--text3); }
.send-btn {
  width: 38px; height: 38px; border-radius: 19px; flex: none;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, transform 0.15s, box-shadow .18s;
  box-shadow: 0 4px 13px color-mix(in srgb, var(--accent) 28%, transparent);
}
.send-btn:disabled { opacity: 0.25; }
.send-btn:not(:disabled):active { transform: translateY(1px) scale(.93); opacity: 1; box-shadow: var(--pressed-shadow); }
.send-btn svg { width: 19px; height: 19px; }
.plus-btn {
  width: 38px; height: 38px; border-radius: 19px; flex: none; color: var(--text2);
  display: flex; align-items: center; justify-content: center;
}
.wb-btn {
  height: 38px; padding: 0 12px; border-radius: 19px; flex: none;
  background: var(--bg); color: var(--text); font-size: 13px; font-weight: 650;
}
.wb-btn:active { background: var(--surface2); opacity: 1; }
.plus-btn svg { width: 22px; height: 22px; }
.plus-btn:active { background: var(--surface2); opacity: 1; }
.att-x {
  width: 17px; height: 17px; border-radius: 50%; background: var(--text3); color: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none; line-height: 1;
}

/* ============ 抽屉 ============ */
.drawer-mask {
  position: fixed; inset: 0; background: var(--overlay); z-index: 20;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drawer-mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(82vw, 320px); z-index: 21;
  background: var(--bg2); display: flex; flex-direction: column;
  transform: translateX(-103%); transition: transform 0.28s cubic-bezier(0.25, 0.8, 0.35, 1);
  padding-top: var(--sat); box-shadow: none;
}
.drawer.on { transform: translateX(0); box-shadow: var(--shadow); }
.dr-search {
  margin: 12px 14px 4px; background: var(--surface); border-radius: 12px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px;
}
.dr-search svg { width: 17px; height: 17px; color: var(--text3); flex: none; }
.dr-search input { flex: 1; height: 100%; font-size: 14.5px; }
.dr-global-search-btn { width: 34px; height: 34px; margin-right: -7px; border-radius: 17px; display: grid; place-items: center; color: var(--text3); flex: none; }
.dr-global-search-btn svg { width: 18px; height: 18px; transition: transform .25s, color .2s; }
.dr-global-search-btn.on { color: var(--accent); background: var(--surface); }
.dr-global-search-btn.on svg { transform: rotate(180deg); }
.global-search-pop {
  position: absolute; z-index: 4; left: 10px; right: 10px; top: calc(var(--sat) + 64px); max-height: min(58vh, 480px);
  overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 17px;
  background: color-mix(in srgb, var(--bg) 94%, transparent); box-shadow: 0 18px 46px rgba(0,0,0,.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.15); backdrop-filter: blur(18px) saturate(1.15);
  animation: globalSearchIn .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes globalSearchIn { from { opacity: 0; transform: translateY(-5px) scale(.985); } }
.global-search-input { height: 48px; padding: 0 10px 0 13px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.global-search-input svg { width: 17px; height: 17px; color: var(--text3); }
.global-search-input input { flex: 1; min-width: 0; font-size: 14px; }
.global-search-input button { width: 28px; height: 28px; border-radius: 14px; color: var(--text3); font-size: 18px; }
.global-search-results { overflow-y: auto; padding: 6px; }
.global-search-empty { padding: 30px 16px; color: var(--text3); text-align: center; font-size: 12.5px; line-height: 1.6; }
.global-search-result { width: 100%; padding: 10px 11px; border-radius: 12px; display: flex; flex-direction: column; gap: 5px; text-align: left; }
.global-search-result:active { background: var(--surface); opacity: 1; }
.global-search-result-head { display: flex; align-items: center; gap: 7px; }
.global-search-result-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.global-search-result-head i { padding: 2px 5px; border-radius: 6px; color: var(--text3); background: var(--surface); font-size: 9px; font-style: normal; }
.global-search-snippet { color: var(--text2); font-size: 11.5px; line-height: 1.48; }
.msg-search-hit { animation: msgSearchHit 1.7s ease; }
@keyframes msgSearchHit { 0%,100% { background: transparent; } 22%,72% { background: color-mix(in srgb, var(--accent) 10%, transparent); } }
.branch-blocked { flex: none; margin: 0 12px 7px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--warning) 28%, transparent); border-radius: 12px; color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, transparent); font-size: 11.5px; line-height: 1.45; }
.msg-variant-switch { height: 28px; display: inline-flex; align-items: center; gap: 2px; color: var(--text3); }
.msg-variant-switch button { width: 24px; height: 26px; border-radius: 9px; color: var(--text2); font-size: 20px; line-height: 1; }
.msg-variant-switch button:disabled { opacity: .25; }
.msg-variant-switch b { min-width: 28px; text-align: center; font-size: 10px; font-variant-numeric: tabular-nums; }
.msg-token-usage { margin-left: 2px; color: var(--text3); font-size: 10px; white-space: nowrap; }
.msg-actions .ma-btn:disabled { opacity: .25; }
.dr-new {
  margin: 8px 14px; display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 12px; font-weight: 600; font-size: 15px;
}
.dr-new:active { background: var(--surface); opacity: 1; }
.dr-new svg { width: 20px; height: 20px; }
.dr-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 8px 12px; }
.dr-group { color: var(--text3); font-size: 12px; font-weight: 600; padding: 14px 8px 5px; }
.dr-item {
  display: flex; align-items: center; border-radius: 12px; overflow: hidden;
}
.dr-item.cur { background: var(--surface); }
.dr-item-main {
  flex: 1; min-width: 0; text-align: left; padding: 11px 4px 11px 8px;
  font-size: 14.5px;
}
.dr-item-main .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.dr-item-more { width: 38px; height: 40px; color: var(--text3); display: flex; align-items: center; justify-content: center; flex: none; }
.dr-item-more svg { width: 17px; height: 17px; }
.dr-foot {
  flex: none; border-top: 1px solid var(--border);
  padding: 8px 14px calc(var(--sab) + 10px);
}
.dr-foot-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 8px; border-radius: 12px; font-size: 15px;
}
.dr-foot-btn:active { background: var(--surface); opacity: 1; }
.dr-foot-btn svg { width: 20px; height: 20px; color: var(--text2); }
.dr-empty { color: var(--text3); text-align: center; padding: 32px 0; font-size: 13.5px; }

/* ============ 底部动作面板 / 弹层 ============ */
.sheet-mask {
  position: fixed; inset: 0; background: var(--overlay); z-index: 55;
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  background: var(--bg); border-radius: 22px 22px 0 0;
  max-height: 86vh; display: flex; flex-direction: column;
  animation: slideUp 0.26s cubic-bezier(0.25, 0.8, 0.35, 1);
  padding-bottom: calc(var(--sab) + 8px);
}
@keyframes slideUp { from { transform: translateY(40%); opacity: 0.6; } }
.sheet-grip { width: 38px; height: 4.5px; border-radius: 3px; background: var(--surface2); margin: 9px auto 2px; flex: none; }
.sheet-title { font-size: 16.5px; font-weight: 700; padding: 10px 20px 6px; flex: none; display:flex; align-items:center; justify-content: space-between; }
.sheet-actions { display: flex; align-items: center; gap: 2px; margin-right: -8px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 12px 10px; }

.act-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 12px; border-radius: 13px; font-size: 15.5px; text-align: left;
}
.act-item:active { background: var(--surface); opacity: 1; }
.act-item svg { width: 20px; height: 20px; color: var(--text2); flex: none; }
.act-item.danger, .act-item.danger svg { color: var(--danger); }

/* 模型选择 */
.prov-group { padding: 4px 0 2px; }
.prov-group-name { color: var(--text3); font-size: 12.5px; font-weight: 600; padding: 10px 12px 4px; }
.model-item {
  display: flex; align-items: center; width: 100%; gap: 10px;
  padding: 12px; border-radius: 13px; font-size: 15px; text-align: left;
}
.model-item:active { background: var(--surface); opacity: 1; }
.model-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.model-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.model-sub { color: var(--text3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-item .check { margin-left: auto; color: var(--text); flex: none; width: 18px; height: 18px; }
.model-none { color: var(--text3); font-size: 13.5px; text-align: center; padding: 20px 12px; line-height: 1.7; }
.picker-list { padding-bottom: calc(var(--sab) + 12px); }
.picker-item {
  display: flex; align-items: center; width: 100%; gap: 10px; min-height: 52px;
  padding: 10px 12px; border-radius: 12px; text-align: left;
}
.picker-item:active { background: var(--surface); opacity: 1; }
.picker-item:disabled { opacity: .4; }
.picker-item .check { width: 19px; height: 19px; flex: none; }

/* ============ 全屏页（设置等） ============ */
.page {
  position: fixed; inset: 0; z-index: 40;
  background: radial-gradient(circle at 14% -8%, color-mix(in srgb, var(--surface) 64%, transparent), transparent 34%), var(--bg);
  display: flex; flex-direction: column;
}
@keyframes pageHeadIn { from { transform: translateY(3px); opacity: .72; } }
.page-head {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--sat) + 6px) 10px 6px;
  animation: pageHeadIn .18s cubic-bezier(.22,.8,.3,1);
}
html.plus-app .page-head { padding-top: 6px; }
.page-head .icon-btn {
  background: color-mix(in srgb, var(--card-bg) 76%, transparent); border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  box-shadow: 0 3px 9px rgba(24,24,32,.06), inset 0 1px 0 var(--glass-highlight);
  transition: transform .18s cubic-bezier(.22,.8,.3,1), box-shadow .18s, background .18s;
}
.page-head .icon-btn:active { transform: translateY(1px) scale(.96); box-shadow: var(--pressed-shadow); }
.page-title { font-size: 17.5px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-act { color: var(--text); font-weight: 600; font-size: 15.5px; padding: 8px 12px; border-radius: 12px; flex: none; }
.page-act:active { background: var(--surface); opacity: 1; }
.page-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px calc(var(--sab) + 24px); }

.sec-label { color: var(--text3); font-size: 12.5px; font-weight: 600; margin: 20px 4px 8px; letter-spacing: 0.3px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.page .card { box-shadow: var(--raised-shadow); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  width: 100%; text-align: left; font-size: 15px; position: relative;
}
.page .row { transition: transform .18s cubic-bezier(.22,.8,.3,1), background .18s, box-shadow .18s; }
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 15px; right: 0; height: 1px; background: var(--border);
}
.row:active { background: var(--surface); opacity: 1; }
.page button.row:active { transform: translateY(1px) scale(.997); box-shadow: var(--pressed-shadow); }
.row.static:active { background: none; }
.row-label { flex: 1; min-width: 0; line-height: 1.28; }
.row-label .rl-sub {
  display: block; color: var(--text3); font-size: 12.5px;
  margin-top: 3px; line-height: 1.45; font-weight: 400;
  white-space: normal; word-break: break-word;
}
.row-value { color: var(--text3); font-size: 14px; flex: none; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { width: 17px; height: 17px; color: var(--text3); flex: none; }
.row input[type="text"], .row input[type="password"], .row input[type="number"], .row input[type="url"] {
  flex: 1; text-align: right; font-size: 15px; min-width: 0;
}
.row input::placeholder { color: var(--text3); }
.select-control {
  flex: 1; min-width: 0; max-width: 62%; text-align: right; text-align-last: right;
  font-size: 15px; color: var(--text);
}
.select-button {
  flex: 1; min-width: 0; max-width: 62%; text-align: right; font-size: 15px;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.provider-model-list { overflow: hidden; }
.provider-model-row {
  min-height: 54px; display: flex; align-items: center; position: relative; padding: 0 7px 0 14px;
}
.provider-model-row + .provider-model-row::before,
.provider-model-add::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--border);
}
.provider-model-main {
  min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start;
  padding: 9px 4px 9px 0; text-align: left;
}
.provider-model-name { width: 100%; font-size: 14.5px; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.provider-model-summary { width: 100%; color: var(--text3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.provider-model-test {
  width: 38px; height: 38px; border-radius: 19px; display: flex; align-items: center; justify-content: center;
  color: var(--text3); flex: none;
}
.provider-model-test svg { width: 20px; height: 20px; }
.provider-model-test:active { background: var(--surface); opacity: 1; }
.provider-model-test.ok { color: #178a50; }
.provider-model-test.error { color: var(--danger); }
.mini-spinner { width: 17px; height: 17px; border: 2px solid var(--border); border-top-color: var(--text2); border-radius: 50%; animation: spin .8s linear infinite; }
.provider-model-result { flex: none; font-size: 11.5px; font-weight: 650; margin-left: 5px; }
.provider-model-result.ok { color: #178a50; }
.provider-model-result.error { color: var(--danger); }
.provider-model-add { width: 100%; height: 46px; position: relative; color: var(--link); font-weight: 600; font-size: 14px; }
.provider-model-add:active { background: var(--surface); opacity: 1; }
.provider-model-empty { color: var(--text3); text-align: center; padding: 18px 12px 12px; font-size: 13px; }

.settings-menu {
  margin-top: 8px; display: flex; flex-direction: column; gap: 10px;
  background: transparent; border: 0; overflow: visible;
}
.page .settings-menu { box-shadow: none; }
.settings-menu .row + .row::before { display: none; }
.setting-entry { min-height: 62px; padding: 12px 15px 12px 16px; }
.settings-menu .setting-entry {
  border: 1px solid var(--border); border-radius: 17px; background: var(--card-bg);
  box-shadow: var(--raised-shadow); overflow: hidden;
}
.settings-menu .setting-entry:active { transform: translateY(2px) scale(.992); background: var(--surface); box-shadow: var(--pressed-shadow); }
.setting-ic {
  width: 36px; height: 36px; border-radius: 10px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex: none; color: var(--text2);
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  box-shadow: 0 4px 10px rgba(20,20,28,.08), inset 0 1px 0 var(--glass-highlight);
  transition: transform .2s cubic-bezier(.22,.8,.3,1), box-shadow .2s;
}
.settings-menu .setting-entry:active .setting-ic { transform: scale(.94); box-shadow: var(--pressed-shadow); }
.setting-ic svg { width: 19px; height: 19px; }
.settings-menu .row-label { font-weight: 650; }
.settings-menu .rl-sub { font-weight: 400; }
.settings-menu .chev { transition: transform .2s cubic-bezier(.22,.8,.3,1); }
.settings-menu .setting-entry:active .chev { transform: translateX(2px); }

/* 数据总览 */
.storage-overview {
  border: 1px solid var(--border); border-radius: 20px; padding: 16px;
  background: var(--card-bg); box-shadow: var(--raised-shadow); overflow: hidden;
}
.storage-total { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.storage-total span { display: flex; flex-direction: column; gap: 2px; }
.storage-total small { color: var(--text3); font-size: 12px; }
.storage-total strong { font-size: 25px; line-height: 1.15; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.storage-total > i { font-style: normal; color: var(--text3); font-size: 12px; padding-bottom: 3px; }
.storage-bar { height: 9px; margin: 15px 0 14px; display: flex; gap: 2px; border-radius: 999px; overflow: hidden; background: var(--surface2); box-shadow: inset 0 1px 3px rgba(0,0,0,.12); }
.storage-seg { min-width: 0; height: 100%; }
.storage-seg:first-child { border-radius: 999px 0 0 999px; }
.storage-seg:last-child { border-radius: 0 999px 999px 0; }
.storage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.storage-item { min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.storage-item > span { min-width: 0; color: var(--text2); display: flex; align-items: center; gap: 7px; }
.storage-item b { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.storage-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: inset 0 1px 0 rgba(255,255,255,.45); }
.storage-note { margin-top: 13px; color: var(--text3); font-size: 10.5px; }
.storage-overview .conversation { background: var(--accent); }
.storage-overview .images { background: #8d6cf2; }
.storage-overview .files { background: #3c9e72; }
.storage-overview .configuration { background: #e18a35; }
.storage-overview .other { background: var(--text3); }
.about-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
}
.about-logo {
  width: 52px; height: 52px; border-radius: 15px; background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700;
  flex: none;
}
.about-copy { min-width: 0; }
.about-title { font-size: 20px; font-weight: 750; line-height: 1.2; }
.about-sub { color: var(--text3); font-size: 13px; margin-top: 4px; }
.about-card { margin-bottom: 18px; }
.about-release-note {
  padding: 0 15px 14px; color: var(--text2); font-size: 13px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text;
}

/* 开关 */
.switch {
  width: 48px; height: 28px; border-radius: 14px; background: var(--surface2);
  position: relative; transition: background 0.2s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch.on { background: #34c759; }
.switch.on::after { transform: translateX(20px); }

.textarea-block {
  width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; font-size: 14.5px; min-height: 88px; resize: vertical; line-height: 1.55;
}
.code-editor-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; min-height: 260px; line-height: 1.5; white-space: pre;
  overflow: auto;
}
.image-workbench .card { border-radius: 14px; }
.image-wb-prompt {
  margin-top: 10px; min-height: 112px; resize: none;
}
.preset-card { margin-bottom: 18px; }
.preset-item {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 15px;
  position: relative;
}
.preset-item::before {
  content: ""; position: absolute; top: 0; left: 15px; right: 0; height: 1px; background: var(--border);
}
.preset-main {
  flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 3px;
}
.preset-name { font-size: 15px; font-weight: 650; line-height: 1.25; }
.preset-prompt {
  color: var(--text3); font-size: 12.5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.preset-del {
  width: 34px; height: 34px; border-radius: 10px; color: var(--danger);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.preset-del:active { background: rgba(224,52,43,0.08); opacity: 1; }
.preset-del svg { width: 18px; height: 18px; }
.preset-empty { color: var(--text3); font-size: 13px; padding: 16px; text-align: center; }
.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 3px; gap: 2px; box-shadow: inset 0 1px 3px rgba(0,0,0,.09); }
.seg button {
  flex: 1; padding: 7px 4px; border-radius: 10px; font-size: 13.5px; color: var(--text2); font-weight: 500;
  transition: transform .18s cubic-bezier(.22,.8,.3,1), background .18s, box-shadow .18s;
}
.seg button.on { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.seg button:active { transform: scale(.96); opacity: 1; }

/* 主题选择与即时预览 */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
.theme-choice {
  min-width: 0; min-height: 72px; padding: 10px; border: 1px solid var(--border); border-radius: 15px;
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 16px; gap: 8px; align-items: center;
  text-align: left; background: var(--bg); transition: border-color .18s, transform .18s, background .18s;
}
.theme-choice:active { transform: scale(.98); opacity: 1; }
.theme-choice.on { border-color: var(--accent); background: var(--surface); }
.theme-swatch { width: 32px; height: 40px; border-radius: 11px; position: relative; overflow: hidden; border: 1px solid rgba(0,0,0,.09); box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.theme-swatch i, .theme-swatch b { position: absolute; display: block; border-radius: 50%; }
.theme-swatch i { width: 23px; height: 23px; left: -6px; bottom: -5px; }
.theme-swatch b { width: 18px; height: 18px; right: -4px; top: 3px; }
.theme-choice-graphite .theme-swatch { background: #f4f4f6; }
.theme-choice-graphite .theme-swatch i { background: #18181b; }
.theme-choice-graphite .theme-swatch b { background: #d8d8dd; }
.theme-choice-warm-paper .theme-swatch { background: #f7f0e4; }
.theme-choice-warm-paper .theme-swatch i { background: #bd6042; }
.theme-choice-warm-paper .theme-swatch b { background: #d9cabb; }
.theme-choice-nebula .theme-swatch { background: #eef3ff; }
.theme-choice-nebula .theme-swatch i { background: #3978f6; }
.theme-choice-nebula .theme-swatch b { background: #896cff; }
.theme-choice-clear-glass .theme-swatch { background: linear-gradient(145deg,#fff,#dfe4ec); }
.theme-choice-clear-glass .theme-swatch i { background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 3px 9px rgba(40,55,75,.22); }
.theme-choice-clear-glass .theme-swatch b { background: #0a84ff; }
.theme-choice-copy { min-width: 0; display: flex; flex-direction: column; }
.theme-choice-copy strong { font-size: 14px; line-height: 1.2; }
.theme-choice-copy small { color: var(--text3); font-size: 10.5px; line-height: 1.3; margin-top: 4px; }
.theme-check { color: var(--accent); font-weight: 800; opacity: 0; }
.theme-choice.on .theme-check { opacity: 1; }
.theme-live-preview {
  margin: 0 12px 10px; min-height: 132px; padding: 15px 13px 12px; border-radius: 17px;
  border: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; gap: 9px;
}
.tlp-assistant { color: var(--text); font-size: 12.5px; line-height: 1.45; }
.tlp-user { align-self: flex-end; max-width: 80%; padding: 7px 10px; border-radius: 14px 14px 5px 14px; background: var(--bubble-user); font-size: 12px; }
.tlp-controls {
  margin-top: auto; height: 34px; padding: 4px 5px 4px 9px; border: 1px solid var(--glass-edge); border-radius: 18px;
  background: var(--glass-bg); box-shadow: var(--glass-shadow); display: flex; align-items: center; gap: 7px;
  -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
}
.tlp-controls span { width: 10px; height: 10px; border: 1.5px solid var(--text2); border-radius: 50%; position: relative; }
.tlp-controls span::before, .tlp-controls span::after { content: ""; position: absolute; background: var(--text2); }
.tlp-controls span::before { width: 5px; height: 1px; left: 1px; top: 3px; }
.tlp-controls span::after { width: 1px; height: 5px; left: 3px; top: 1px; }
.tlp-controls b { flex: 1; color: var(--text3); font-size: 11px; font-weight: 500; }
.tlp-controls i { width: 25px; height: 25px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-style: normal; display: flex; align-items: center; justify-content: center; }

.big-btn {
  width: 100%; padding: 13px; border-radius: 14px; font-size: 15.5px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg); margin-top: 10px;
}
.big-btn.plain { background: var(--surface); color: var(--text); }
.big-btn.danger { background: rgba(224,52,43,0.1); color: var(--danger); }
.big-btn:disabled { opacity: 0.4; }

.hint { color: var(--text3); font-size: 12.5px; margin: 8px 4px 0; line-height: 1.6; }

.session-admin-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.session-admin-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden;
}
.session-admin-main {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 12px 10px; text-align: left;
}
.session-admin-main:active { background: var(--surface); opacity: 1; }
.session-admin-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session-admin-title {
  display: block; max-width: 100%; min-width: 0;
  font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-admin-meta {
  display: block; max-width: 100%; min-width: 0;
  color: var(--text3); font-size: 12px; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-admin-main .chev {
  width: 17px; height: 17px; color: var(--text3); flex: none;
}
.session-admin-current {
  flex: none; padding: 3px 7px; border-radius: 999px;
  background: var(--surface); color: var(--text2); font-size: 11.5px; font-weight: 650;
}
.session-admin-actions {
  display: flex; gap: 6px; padding: 0 10px 10px;
}
.session-admin-actions button {
  flex: 1; min-width: 0; padding: 8px 6px; border-radius: 10px;
  background: var(--surface); color: var(--text2); font-size: 12.5px; font-weight: 650;
}
.session-admin-actions button:disabled { opacity: 0.38; }
.session-admin-actions button:active { opacity: 1; background: var(--surface2); }
.session-admin-actions button.danger { color: var(--danger); background: rgba(224, 52, 43, 0.08); }
.session-admin-files { border-top: 1px solid var(--border); padding: 4px 10px 8px; }
.session-admin-empty { color: var(--text3); font-size: 12.5px; padding: 10px 2px; }
.session-admin-file { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.session-admin-file + .session-admin-file { border-top: 1px solid var(--border); }
.session-admin-file .file-ext {
  width: 34px; height: 28px; border-radius: 8px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.session-admin-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.session-admin-file-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ============ 文件管理 ============ */
.file-tree { margin-top: 4px; }
.file-row { display: flex; align-items: center; gap: 6px; padding: 4px 8px; width: 100%; text-align: left; }
.file-row:active { background: var(--surface); opacity: 1; }
.file-row .chev { width: 17px; height: 17px; color: var(--text3); flex: none; }
.file-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 8px 4px; text-align: left; border-radius: 11px;
}
.file-main:active { background: var(--surface); opacity: 1; }
.file-ic {
  width: 38px; height: 38px; border-radius: 11px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.file-ic svg { width: 19px; height: 19px; color: var(--text2); }
.file-ic.kind-folder { background: rgba(40, 114, 225, 0.1); color: var(--link); }
.file-ic.kind-folder svg { color: var(--link); }
.file-ic.kind-html { background: rgba(255, 149, 0, 0.13); }
.file-ic.kind-code { background: rgba(88, 86, 214, 0.12); }
.file-ic.kind-md { background: rgba(52, 199, 89, 0.12); }
.file-ic.kind-image { background: rgba(255, 45, 85, 0.1); }
.file-ext { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 10.5px; font-weight: 800; color: var(--text2); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { color: var(--text3); font-size: 12px; margin-top: 1px; }
.file-act {
  width: 34px; height: 34px; border-radius: 10px; color: var(--text3);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.file-act svg { width: 17px; height: 17px; }
.file-act:active { background: rgba(224, 52, 43, 0.08); color: var(--danger); opacity: 1; }
.folder-chev { transition: transform 0.18s; }
.folder-chev.open { transform: rotate(90deg); }
.svc-card { margin-bottom: 8px; }
.svc-row { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; }
.svc-row + .svc-row { border-top: 1px solid var(--border); }
.svc-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  text-align: left; padding: 6px 4px; border-radius: 10px;
}
.svc-main:active { background: var(--surface); opacity: 1; }
.svc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text3); flex: none; }
.svc-dot.on { background: #34c759; box-shadow: 0 0 0 4px rgba(52,199,89,0.12); }
.svc-info { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.svc-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-meta { color: var(--text3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-act {
  flex: none; padding: 7px 8px; border-radius: 9px; font-size: 12.5px;
  color: var(--text2); font-weight: 600;
}
.svc-act:active { background: var(--surface); opacity: 1; color: var(--text); }

/* ============ HTML 预览 ============ */
.preview-page { background: var(--bg); }
.pv-tabs { display: flex; gap: 4px; padding: 0 12px 8px; }
.pv-tab { padding: 7px 15px; border-radius: 18px; font-size: 13.5px; color: var(--text2); background: var(--surface); font-weight: 500; }
.pv-tab.on { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.browser-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px 8px; flex: none;
}
.browser-btn, .browser-go {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); background: var(--surface);
}
.browser-btn svg, .browser-go svg { width: 17px; height: 17px; }
.browser-btn:disabled { opacity: 0.35; }
.browser-btn:not(:disabled):active, .browser-go:active { background: var(--surface2); color: var(--text); opacity: 1; }
.browser-address {
  min-width: 0; flex: 1; height: 34px; border: 1px solid var(--border);
  border-radius: 10px; padding: 0 10px; background: var(--bg2);
  color: var(--text); font-size: 13px; font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}
.pv-frame-wrap { flex: 1; position: relative; background: #fff; }
.pv-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.pv-src {
  position: absolute; inset: 0; overflow: auto; background: var(--code-bg);
  padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-all; user-select: text; -webkit-user-select: text; color: var(--text);
}
.pv-console { position: absolute; inset: 0; overflow: auto; background: var(--bg); padding: 8px 12px; }
.pv-log {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-all; user-select: text; -webkit-user-select: text;
}
.pv-log.warn { color: #b58900; }
.pv-log.error { color: var(--danger); }
.pv-empty { color: var(--text3); text-align: center; padding: 40px 0; font-size: 13px; }

/* 文件查看器 / 轻量编辑器 */
.viewer-page { background: var(--bg); }
.viewer-workbench { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.viewer-img { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 12px; }
.viewer-img img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.viewer-editbar {
  flex: none; display: flex; gap: 6px; align-items: flex-end;
  padding: 8px 12px calc(var(--sab) + 10px); background: var(--bg);
}
.viewer-editbar textarea {
  flex: 1; resize: none; max-height: 112px; min-height: 38px;
  border: 1px solid var(--border); border-radius: 19px;
  background: var(--surface); color: var(--text);
  padding: 9px 13px; font-size: 15px; line-height: 1.4;
}
.viewer-md {
  position: absolute; inset: 0; overflow: auto; padding: 14px 16px calc(var(--sab) + 20px);
  user-select: text; -webkit-user-select: text;
}
.viewer-source { position: absolute; inset: 0; background: var(--code-bg); }
.viewer-code-pane { position: absolute; inset: 0; min-width: 0; min-height: 0; }
.viewer-source-js {
  display: flex; flex-direction: column; background: var(--bg);
}
.viewer-source-js .viewer-code-pane {
  position: relative; inset: auto; flex: 1 1 58%; border-bottom: 1px solid var(--border);
}
.viewer-source-js .code-highlight,
.viewer-source-js .code-input {
  padding-bottom: 14px;
}
.code-editor {
  position: absolute; inset: 0; background: var(--code-bg);
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55;
}
.code-highlight, .code-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 14px 16px calc(var(--sab) + 20px);
  border: none; margin: 0; resize: none; white-space: pre; overflow: auto;
  font: inherit; line-height: inherit; tab-size: 2;
}
.code-highlight {
  pointer-events: none; color: var(--text); background: transparent;
}
.code-input {
  color: transparent; caret-color: var(--text); background: transparent;
  -webkit-text-fill-color: transparent;
}
.code-input::selection { background: rgba(40, 114, 225, 0.22); }
.viewer-terminal {
  flex: 0 0 38%; min-height: 158px; max-height: 46%;
  display: flex; flex-direction: column; background: #101116; color: #e9ecf1;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}
.term-head {
  flex: none; height: 34px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #9ba3af; font-size: 12px;
}
.term-head span { font-weight: 700; letter-spacing: 0; }
.term-head button {
  color: #c5cad3; font-size: 12px; padding: 4px 8px; border-radius: 7px;
}
.term-head button:active { background: rgba(255,255,255,0.1); opacity: 1; }
.term-body {
  flex: 1; min-height: 0; overflow: auto; padding: 8px 12px;
  -webkit-overflow-scrolling: touch;
}
.term-empty { color: #6f7785; font-size: 12.5px; padding: 16px 0; text-align: center; }
.term-line {
  white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text;
  font-size: 12.5px; line-height: 1.5; padding: 2px 0; color: #e9ecf1;
}
.term-line.cmd { color: #7dd3fc; }
.term-line.prompt { color: #93c5fd; }
.term-line.input { color: #fde68a; }
.term-line.return { color: #bbf7d0; }
.term-line.write { color: #86efac; }
.term-line.warn { color: #fbbf24; }
.term-line.error { color: #fb7185; }
.term-line.muted { color: #7f8794; }
.term-input-row {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px calc(var(--sab) + 8px);
  border-top: 1px solid rgba(255,255,255,0.08); color: #7dd3fc;
}
.term-input-row.waiting { background: rgba(125, 211, 252, 0.08); }
.term-input-row input {
  min-width: 0; flex: 1; height: 28px; color: #f3f4f6;
  font: inherit; font-size: 12.5px;
}
.term-input-row input::placeholder { color: #656d7a; }
.viewer-run-fab {
  position: absolute; right: 16px; bottom: calc(38% + 14px);
  width: 52px; height: 52px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow); z-index: 3;
}
.viewer-run-fab svg { width: 23px; height: 23px; }
.viewer-run-fab:disabled { opacity: 0.62; }
.viewer-run-fab:disabled svg { animation: spin 0.9s linear infinite; }

/* ============ Markdown 内容 ============ */
.md { word-break: break-word; line-height: 1.65; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 10px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; font-weight: 700; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 10px 0; padding-left: 24px; }
.md li { margin: 4px 0; }
.md li > p { margin: 4px 0; }
.md blockquote {
  border-left: 3px solid var(--surface2); padding: 2px 0 2px 13px; margin: 12px 0; color: var(--text2);
}
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.md code { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; }
.md :not(pre) > code {
  background: var(--surface); padding: 2px 6px; border-radius: 6px; font-size: 0.86em;
}
.md a.md-link { color: var(--link); word-break: break-all; }
.md a.md-link .lnk-ic { margin-left: 2px; opacity: 0.6; vertical-align: -1px; }
.md img.md-img { max-width: 100%; border-radius: 14px; margin: 8px 0; display: block; }
.md strong { font-weight: 700; }

.tbl-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; font-size: 0.9em; min-width: 100%; }
.md th, .md td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.md th { background: var(--bg2); font-weight: 600; }
.md tr:last-child td { border-bottom: none; }

/* 代码块 */
.code-block { border-radius: 14px; overflow: hidden; margin: 12px 0; background: var(--code-bg); border: 1px solid var(--border); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--code-head); padding: 5px 8px 5px 14px;
}
.code-lang { font-size: 12px; color: var(--text2); font-family: ui-monospace, Menlo, monospace; }
.code-actions { display: flex; gap: 2px; }
.code-btn { font-size: 12.5px; color: var(--text2); padding: 5px 10px; border-radius: 8px; font-weight: 500; }
.code-btn:active { background: var(--surface); opacity: 1; }
.code-block pre { overflow-x: auto; padding: 12px 14px; -webkit-overflow-scrolling: touch; }
.code-block code.hljs {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; background: none; padding: 0; display: block;
  user-select: text; -webkit-user-select: text;
}

/* highlight.js 主题（跟随明暗） */
.hljs { color: var(--text); }
.hljs-comment, .hljs-quote { color: var(--text3); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-tag { color: #c04891; }
html.dark .hljs-keyword, html.dark .hljs-selector-tag, html.dark .hljs-built_in, html.dark .hljs-tag { color: #e58ac0; }
.hljs-string, .hljs-attr, .hljs-template-tag { color: #2e7d32; }
html.dark .hljs-string, html.dark .hljs-attr { color: #8fd694; }
.hljs-number, .hljs-literal, .hljs-symbol { color: #b26a00; }
html.dark .hljs-number, html.dark .hljs-literal { color: #eab064; }
.hljs-title, .hljs-name, .hljs-function .hljs-title, .hljs-selector-id, .hljs-selector-class { color: #2860c9; }
html.dark .hljs-title, html.dark .hljs-name, html.dark .hljs-selector-id, html.dark .hljs-selector-class { color: #82aaff; }
.hljs-variable, .hljs-template-variable, .hljs-regexp { color: #a3512c; }
html.dark .hljs-variable, html.dark .hljs-regexp { color: #df9776; }
.hljs-meta, .hljs-doctag { color: #7a7a85; }

/* ============ 对话框 ============ */
.model-editor-mask {
  position: fixed; inset: 0; z-index: 65; background: var(--overlay); display: flex;
  align-items: center; justify-content: center; padding: 18px; animation: fadeIn .18s;
}
.model-editor-dialog {
  width: 100%; max-width: 390px; max-height: calc(100vh - 36px); overflow: hidden;
  display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow); animation: dlgIn .2s cubic-bezier(.25,.8,.35,1);
}
.model-editor-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 10px; }
.model-editor-title { font-size: 17px; font-weight: 720; }
.model-editor-sub { color: var(--text3); font-size: 12px; margin-top: 2px; }
.model-editor-close { width: 32px; height: 32px; margin-left: auto; border-radius: 16px; font-size: 24px; line-height: 1; color: var(--text3); }
.model-editor-close:active { background: var(--surface); opacity: 1; }
.model-editor-body { overflow-y: auto; padding: 4px 18px 10px; }
.model-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-editor-field { display: block; margin-bottom: 11px; }
.model-editor-field > span { display: block; color: var(--text2); font-size: 12.5px; margin: 0 2px 6px; }
.model-editor-field input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 10px 11px; font-size: 14px; }
.model-editor-caps { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.model-editor-cap { min-height: 52px; padding: 9px 12px; display: flex; align-items: center; gap: 12px; position: relative; }
.model-editor-cap + .model-editor-cap::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; height: 1px; background: var(--border); }
.model-editor-cap > span { flex: 1; min-width: 0; font-size: 14px; }
.model-editor-cap small { display: block; color: var(--text3); font-size: 11.5px; line-height: 1.35; margin-top: 2px; }
.model-editor-actions { display: flex; align-items: center; gap: 3px; padding: 10px 12px calc(var(--sab) + 10px); border-top: 1px solid var(--border); }
.model-editor-actions button { padding: 9px 12px; border-radius: 11px; font-weight: 620; font-size: 14px; }
.model-editor-actions button:active { background: var(--surface); opacity: 1; }
.model-editor-actions .primary { color: var(--link); }
.model-editor-delete { color: var(--danger); }
.model-editor-spacer { flex: 1; }

.dlg-mask {
  position: fixed; inset: 0; background: var(--overlay); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 32px;
  animation: fadeIn 0.18s;
}
.dlg {
  background: var(--bg); border-radius: 22px; width: 100%; max-width: 330px;
  padding: 22px 20px 12px; animation: dlgIn 0.2s cubic-bezier(0.25, 0.8, 0.35, 1);
  box-shadow: var(--shadow);
}
.dlg-mask-liquid { background: rgba(0, 0, 0, 0.18); }
html.dark .dlg-mask-liquid { background: rgba(0, 0, 0, 0.28); }
.dlg-liquid {
  position: relative; isolation: isolate; overflow: hidden; background: transparent;
  border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  contain: layout paint style;
}
.dlg-liquid::before {
  content: ""; position: absolute; inset: -10px; z-index: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--glass-highlight) 46%, transparent), transparent 36%), var(--glass-panel-bg);
  -webkit-backdrop-filter: blur(2px) saturate(1.28); backdrop-filter: blur(2px) saturate(1.28);
  filter: url("#wc-liquid-confirm"); transform: translateZ(0);
}
.dlg-liquid > * { position: relative; z-index: 1; }
.dlg-liquid .dlg-btn {
  background: color-mix(in srgb, var(--glass-bg) 72%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--glass-highlight) 72%, transparent), 0 2px 7px rgba(0, 0, 0, 0.06);
  transition: transform .16s cubic-bezier(.22,.8,.3,1), background .16s, box-shadow .16s;
}
.dlg-liquid .dlg-btn:active { transform: translateY(1px) scale(.97); box-shadow: var(--pressed-shadow); }
@keyframes dlgIn { from { transform: scale(0.92); opacity: 0; } }
.dlg-title { font-size: 16.5px; font-weight: 700; margin-bottom: 8px; }
.dlg-msg { color: var(--text2); font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow-y: auto; }
.dlg-input {
  width: 100%; background: var(--surface); border-radius: 12px; padding: 11px 13px;
  font-size: 15px; margin-top: 12px;
}
.dlg-btns { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; margin-top: 16px; }
.dlg-btn { padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14.5px; color: var(--text2); }
.dlg-btn.primary { color: var(--text); }
.dlg-btn.danger { color: var(--danger); }
.dlg-btn:active { background: var(--surface); opacity: 1; }

/* toast（浏览器降级用） */
#wc-toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 90px); transform: translateX(-50%) translateY(8px);
  background: rgba(30,30,34,0.94); color: #fff; padding: 9px 18px; border-radius: 20px;
  font-size: 13.5px; z-index: 99; opacity: 0; pointer-events: none; transition: all 0.22s; max-width: 80vw;
}
html.dark #wc-toast { background: rgba(240,240,244,0.95); color: #17171a; }
#wc-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 滚动到底按钮 */
.scroll-down {
  position: absolute; right: 16px; bottom: calc(var(--sab) + 96px); width: 36px; height: 36px; border-radius: 18px;
  background: var(--bg); border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center; color: var(--text2); z-index: 4;
  transition: transform .18s cubic-bezier(.22,.8,.3,1), box-shadow .18s;
}
.scroll-down:active { transform: translateY(1px) scale(.92); opacity: 1; box-shadow: var(--pressed-shadow); }
.scroll-down svg { width: 18px; height: 18px; }

.token-widget {
  position: absolute; right: 14px; top: 12px;
  z-index: 4; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.token-orb {
  width: 44px; height: 44px; border-radius: 999px; padding: 0; position: relative; overflow: hidden;
  isolation: isolate; border: 1px solid var(--glass-border); color: var(--text2);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  transition: transform .22s cubic-bezier(.22,.8,.3,1), box-shadow .22s, color .22s;
  contain: layout paint style;
}
.token-orb::before {
  content: ""; position: absolute; inset: -3px; z-index: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at 30% 18%, var(--glass-highlight), transparent 32%), var(--glass-orb-bg);
  -webkit-backdrop-filter: blur(4px) saturate(1.32); backdrop-filter: blur(4px) saturate(1.32);
  filter: url("#wc-liquid-token"); transform: translateZ(0);
}
.token-orb-value {
  position: relative; z-index: 1; display: flex; width: 100%; height: 100%; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1; font-weight: 750; letter-spacing: -.25px; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--bg) 68%, transparent);
}
.token-orb:active { transform: translateY(1px) scale(.91); opacity: 1; box-shadow: var(--pressed-shadow); }
.token-widget.warn .token-orb { color: var(--warning); box-shadow: 0 5px 20px color-mix(in srgb, var(--warning) 34%, transparent), inset 0 1px 0 var(--glass-highlight); }
.token-widget.danger .token-orb { color: var(--danger); box-shadow: 0 5px 20px color-mix(in srgb, var(--danger) 38%, transparent), inset 0 1px 0 var(--glass-highlight); }
.token-widget.open .token-orb { color: var(--accent); transform: scale(1.04); }
.token-widget.open .token-orb:active { transform: translateY(1px) scale(.92); }
.token-panel {
  width: 210px; position: relative; isolation: isolate; overflow: hidden; background: transparent;
  border: 1px solid var(--glass-edge); border-radius: 18px;
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
  padding: 10px 12px; font-size: 12.5px;
  animation: tokenPanelIn .22s cubic-bezier(.22,.8,.3,1);
  contain: layout paint style;
}
.token-panel::before {
  content: ""; position: absolute; inset: -8px; z-index: 0; border-radius: inherit; pointer-events: none;
  background: var(--glass-panel-bg);
  background: linear-gradient(145deg, color-mix(in srgb, var(--glass-highlight) 42%, transparent), transparent 38%), var(--glass-panel-bg);
  -webkit-backdrop-filter: blur(2px) saturate(1.24); backdrop-filter: blur(2px) saturate(1.24);
  filter: url("#wc-liquid-panel"); transform: translateZ(0);
}
.token-panel > * { position: relative; z-index: 1; }
@keyframes tokenPanelIn { from { opacity: 0; transform: translateY(-5px) scale(.97); } }

.liquid-scrolling .composer::before,
.liquid-scrolling .token-panel::before {
  filter: none;
  -webkit-backdrop-filter: blur(2px) saturate(1.08);
  backdrop-filter: blur(2px) saturate(1.08);
}

html:not(.real-glass) .composer {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.22);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.22);
}
html:not(.real-glass) .composer::before {
  inset: 0; background: linear-gradient(145deg, var(--glass-highlight), transparent 34%, transparent 70%, color-mix(in srgb, var(--glass-highlight) 34%, transparent));
  filter: none; -webkit-backdrop-filter: none; backdrop-filter: none; transform: none;
  opacity: .55; mix-blend-mode: soft-light;
}
html:not(.real-glass) .token-orb::before {
  inset: 0; filter: none; transform: none;
  -webkit-backdrop-filter: blur(7px) saturate(1.24);
  backdrop-filter: blur(7px) saturate(1.24);
}
html:not(.real-glass) .token-panel::before {
  inset: 0; filter: none; transform: none;
  -webkit-backdrop-filter: blur(11px) saturate(1.16);
  backdrop-filter: blur(11px) saturate(1.16);
}
html:not(.real-glass) .dlg-liquid::before {
  inset: 0; filter: none; transform: none;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.18);
}
.tp-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 7px; }
.tp-head button { width: 24px; height: 24px; border-radius: 12px; color: var(--text3); font-size: 18px; line-height: 1; }
.tp-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; color: var(--text3); }
.tp-grid b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-warn { margin-top: 8px; color: var(--danger); line-height: 1.45; }
.tp-foot { margin-top: 8px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .composer, .token-orb, .token-panel, .tlp-controls, .dlg-liquid { background: var(--surface); }
  .token-orb::before, .token-panel::before, .dlg-liquid::before { background: var(--surface); filter: none; }
}

@media (max-width: 370px) {
  .theme-grid { grid-template-columns: 1fr; }
  .storage-grid { grid-template-columns: 1fr; }
}

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

.fade-enter-active, .fade-leave-active { transition: opacity 0.18s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }
