🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.
Python ai-agentai-assistantchatbotclaudecomputer-usedeepseekdesktop-appdshelectronfeishugeminigptgrokllmlocal-firstmodelflaremulti-modelopenai-compatiblepersonal-ai-agentwechat
feat(ui): 建立统一设计系统并重构聊天、机器人创建与头像体验
dyk98e517d0f2c01d
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 6789745..3ace93e 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -9,7 +9,8 @@ anymodel bot 自身以 MIT 许可发布(见 LICENSE)。以下组件随本程来源:https://github.com/yetone/magpie (vendor/magpie 子模块,v0.1.1720)- 以二进制形式随附:内置模型网关。-- 改编:`ui/tokens.css`、`ui/css/base.css`、`ui/css/settings.css` 中的中性色、圆角、动效与组件样式+- 改编:`ui/design/tokens/semantic.css`、`ui/design/components/`(`button.css`、`list.css`、`seg.css`、+ `popover.css`、`toast.css`)、`ui/css/settings.css` 中的中性色、圆角、动效与组件样式(`.list` / `.row`、分段控件 `.seg`、弹出菜单 `.pop`、设置页页签、"已保存"胶囊)改编自`internal/gui/assets/app.css`。未使用 magpie 的名称、喜鹊标志、`assets/icons/` 中的厂商 logo、赞助商/合作方图片或官网截图。diff --git "a/anymodelbot_design/logo avator/\344\270\273-\350\223\235\350\211\262.png" "b/anymodelbot_design/logo avator/\344\270\273-\350\223\235\350\211\262.png"new file mode 100644index 0000000..c9941a5Binary files /dev/null and "b/anymodelbot_design/logo avator/\344\270\273-\350\223\235\350\211\262.png" differdiff --git "a/anymodelbot_design/logo avator/\346\251\231\350\211\262\346\216\242\351\231\251\350\200\205.png" "b/anymodelbot_design/logo avator/\346\251\231\350\211\262\346\216\242\351\231\251\350\200\205.png"new file mode 100644index 0000000..906da1dBinary files /dev/null and "b/anymodelbot_design/logo avator/\346\251\231\350\211\262\346\216\242\351\231\251\350\200\205.png" differdiff --git "a/anymodelbot_design/logo avator/\347\264\253\351\222\273.png" "b/anymodelbot_design/logo avator/\347\264\253\351\222\273.png"new file mode 100644index 0000000..636b90bBinary files /dev/null and "b/anymodelbot_design/logo avator/\347\264\253\351\222\273.png" differdiff --git "a/anymodelbot_design/logo avator/\347\272\242\351\255\224.png" "b/anymodelbot_design/logo avator/\347\272\242\351\255\224.png"new file mode 100644index 0000000..442ee8fBinary files /dev/null and "b/anymodelbot_design/logo avator/\347\272\242\351\255\224.png" differdiff --git "a/anymodelbot_design/logo avator/\347\273\277\350\215\211.png" "b/anymodelbot_design/logo avator/\347\273\277\350\215\211.png"new file mode 100644index 0000000..c240365Binary files /dev/null and "b/anymodelbot_design/logo avator/\347\273\277\350\215\211.png" differdiff --git "a/anymodelbot_design/logo avator/\351\273\204\350\211\262\345\260\217\350\220\214.png" "b/anymodelbot_design/logo avator/\351\273\204\350\211\262\345\260\217\350\220\214.png"new file mode 100644index 0000000..42e366bBinary files /dev/null and "b/anymodelbot_design/logo avator/\351\273\204\350\211\262\345\260\217\350\220\214.png" differdiff --git a/scripts/build-bot-avatars.py b/scripts/build-bot-avatars.pynew file mode 100644index 0000000..7beed97--- /dev/null+++ b/scripts/build-bot-avatars.py@@ -0,0 +1,187 @@+#!/usr/bin/env python3+"""+把 anymodelbot_design/logo avator/ 里的 6 张毛绒机器人原图拆成可动的图层,输出 ui/design/bots/<key>.webp。++每个角色一张横向精灵图,8 格,每格 CELL×CELL,坐标系相同(叠在一起就是原图):+ 0 head 头(不含耳朵和头顶配件;面罩上的眼睛已抹掉,眼睛由 avatar.js 用 SVG 画,才能眨眼、换表情)+ 1 earL 左耳(向头里多留一截,转动时不露缝;头那一层盖住多出来的部分)+ 2 earR 右耳+ 3 top 头顶配件(天线球 / 星星 / 嫩芽 / 角 / 宝石 / 天线),同样向头里多留一截+ 4–7 上面四层各自的"发光部分"(红魔的灯带、紫钻的霓虹线),没有就是空的++只用 numpy + Pillow: python3 scripts/build-bot-avatars.py+几何(源图像素)和 ui/components/avatar.js 里的 BOT_CHARS 是同一套数,改一边要改另一边。+"""+import os+import sys++import numpy as np+from PIL import Image, ImageFilter++ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+SRC = os.path.join(ROOT, "anymodelbot_design", "logo avator")+OUT = os.path.join(ROOT, "ui", "design", "bots")++# 源图 1536×1024。取以 (767, 511) 为中心、边长 1290 的正方形(刚好装下最宽的红魔),缩到 CELL。+SIDE, CX, CY = 1290, 767, 511+CELL = 448+QUALITY = 86++CHARS = {+ # eyes: 两眼中心;er: 眼睛半径;patch: 抹眼睛(连同光晕)的实心 / 渐隐半径(× er)+ # visor: 面罩 x0, y0, x1, y1, 圆角(抹眼睛只在面罩里进行,不碰外圈绒毛)+ # ear: cutL/cutR 是头的侧边(耳朵和头的分界),y0–y1 是耳朵的纵向范围+ # top: x0–x1 × (0, cut) 是配件;stem 是配件插进头里的那一段(多留的部分只在这段宽度里)+ # keep: 抹眼睛时要保住的椭圆(小萌面罩上的腮红)+ # glow: 发光部分 = (通道, 从, 到, 出现在哪些层:h 头 / l 左耳 / r 右耳 / t 配件)+ "blue": dict(src="主-蓝色.png", eyes=[(622.7, 678.6), (906.6, 678.6)], er=44, patch=(1.5, 2.3), visor=(460, 532, 1075, 820, 140),+ ear=dict(cutL=356, cutR=1179, y0=515, y1=822), top=dict(x0=630, x1=900, cut=276, stem=(718, 815))),+ "yellow": dict(src="黄色小萌.png", eyes=[(622.7, 679.3), (908.5, 679.3)], er=46, patch=(1.6, 2.4), visor=(458, 531, 1076, 821, 140),+ keep=[(538, 746, 52, 31), (997, 746, 52, 31)],+ ear=dict(cutL=353, cutR=1183, y0=510, y1=825), top=dict(x0=625, x1=910, cut=270, stem=(715, 820))),+ "green": dict(src="绿草.png", eyes=[(622.6, 679.6), (910.0, 679.7)], er=45, patch=(1.5, 2.3), visor=(458, 532, 1078, 820, 140),+ ear=dict(cutL=353, cutR=1180, y0=512, y1=838), top=dict(x0=520, x1=1035, cut=270, stem=(722, 812))),+ "red": dict(src="红魔.png", eyes=[(606.1, 632.9), (924.9, 632.8)], er=50, patch=(1.6, 2.4), visor=(432, 478, 1104, 785, 150),+ ear=dict(cutL=374, cutR=1160, y0=380, y1=850), top=dict(x0=645, x1=890, cut=232, stem=(660, 875)),+ glow=("g", 70, 140, "lrt")),+ "purple": dict(src="紫钻.png", eyes=[(623.0, 679.5), (908.0, 679.5)], er=45, patch=(1.5, 2.3), visor=(470, 550, 1068, 812, 130),+ ear=dict(cutL=356, cutR=1179, y0=520, y1=835), top=dict(x0=640, x1=890, cut=290, stem=(700, 830)),+ glow=("g", 80, 170, "hlrt")),+ "orange": dict(src="橙色探险者.png", eyes=[(615.0, 663.0), (920.0, 663.0)], er=46, patch=(1.6, 2.4), visor=(447, 517, 1090, 805, 90),+ ear=dict(cutL=324, cutR=1210, y0=488, y1=830), top=dict(x0=655, x1=880, cut=220, stem=(695, 842))),+}+++def ramp(v, a, b):+ """a→b 之间从 0 平滑到 1(a > b 时反过来)"""+ t = np.clip((v - a) / (b - a), 0.0, 1.0)+ return t * t * (3 - 2 * t)+++def refine_eyes(rgb, eyes, er):+ """在给定位置附近找亮斑的质心,修正手量的眼睛中心"""+ v = rgb.max(axis=2).astype(np.float32)+ out = []+ for ex, ey in eyes:+ x0, y0 = int(ex - er * 1.6), int(ey - er * 1.6)+ win = v[y0 : y0 + int(er * 3.2), x0 : x0 + int(er * 3.2)]+ m = win > 225+ ys, xs = np.nonzero(m)+ if len(xs) < 50:+ out.append((ex, ey))+ continue+ out.append((x0 + xs.mean(), y0 + ys.mean()))+ return out+++def rounded_rect(xx, yy, x0, y0, x1, y1, rr, inset):+ """圆角矩形内为 1(向内收 inset,边缘 6px 渐变)"""+ x0, y0, x1, y1, rr = x0 + inset, y0 + inset, x1 - inset, y1 - inset, max(rr - inset, 1)+ qx = np.maximum(np.maximum(x0 + rr - xx, xx - (x1 - rr)), 0)+ qy = np.maximum(np.maximum(y0 + rr - yy, yy - (y1 - rr)), 0)+ d = np.hypot(qx, qy) - rr+ inside_box = (xx >= x0) & (xx <= x1) & (yy >= y0) & (yy <= y1)+ return np.where(inside_box, ramp(d, 0, -6), 0.0)+++def paint_out_eyes(rgb, c):+ """用两眼正中间一条干净的面罩绒毛(镜像平铺)盖住眼睛和它在面罩上的光晕"""+ h, w = rgb.shape[:2]+ yy, xx = np.mgrid[0:h, 0:w].astype(np.float32)+ (ax, ay), (bx, by) = c["eyes"]+ mx, my = int(round((ax + bx) / 2)), int(round((ay + by) / 2))+ r = c["er"]+ hw = max(int((bx - ax) / 2 - r * 2.3), 16)+ tile = rgb[my - 90 : my + 90, mx - hw : mx + hw].astype(np.float32)+ tile = np.concatenate([tile, tile[:, ::-1]], axis=1)+ tile = np.concatenate([tile, tile[::-1]], axis=0)+ th, tw = tile.shape[:2]+ ty = ((np.arange(h) - (my - 90)) % th)[:, None]+ tx = ((np.arange(w) - (mx - hw)) % tw)[None, :]+ tex = tile[ty, tx]+ x0, y0, x1, y1, rr = c["visor"]+ m = np.zeros((h, w), np.float32)+ for ex, ey in c["eyes"]:+ m = np.maximum(m, 1 - ramp(np.hypot(xx - ex, yy - ey), r * c["patch"][0], r * c["patch"][1]))+ m *= rounded_rect(xx, yy, x0, y0, x1, y1, rr, 10)+ for kx, ky, krx, kry in c.get("keep", []):+ m *= ramp(((xx - kx) / krx) ** 2 + ((yy - ky) / kry) ** 2, 1.0, 1.6)+ return rgb.astype(np.float32) * (1 - m[..., None]) + tex * m[..., None]+++def build(key, c):+ im = Image.open(os.path.join(SRC, c["src"])).convert("RGBA")+ a = np.asarray(im).astype(np.float32)+ rgb, alpha = a[..., :3], a[..., 3] / 255.0+ c = dict(c, eyes=refine_eyes(rgb, c["eyes"], c["er"]))+ h, w = alpha.shape+ yy, xx = np.mgrid[0:h, 0:w].astype(np.float32)+ f = 3.0 # 切口羽化(源图像素)+ ext = 42.0 # 向头里多留的长度++ e, t = c["ear"], c["top"]+ in_ear_y = ramp(yy, e["y0"] - 8, e["y0"] + 8) * (1 - ramp(yy, e["y1"] - 8, e["y1"] + 8))+ ear_l = ramp(xx, e["cutL"] + f, e["cutL"] - f) # x < cutL → 1+ ear_r = ramp(xx, e["cutR"] - f, e["cutR"] + f)+ in_top_x = ramp(xx, t["x0"] - f, t["x0"] + f) * (1 - ramp(xx, t["x1"] - f, t["x1"] + f))+ top = in_top_x * ramp(yy, t["cut"] + f, t["cut"] - f)++ head_m = alpha * (1 - ear_l) * (1 - ear_r) * (1 - top)+ earL_m = alpha * ramp(xx, e["cutL"] + ext, e["cutL"] + ext - 10) * in_ear_y+ earR_m = alpha * ramp(xx, e["cutR"] - ext, e["cutR"] - ext + 10) * in_ear_y+ stem_x = ramp(xx, t["stem"][0] - 6, t["stem"][0] + 6) * (1 - ramp(xx, t["stem"][1] - 6, t["stem"][1] + 6))+ top_m = alpha * np.maximum(top, stem_x * ramp(yy, t["cut"] + ext, t["cut"] + ext - 10))++ head_rgb = paint_out_eyes(rgb, c)++ # 发光部分:按通道取色,并避开绒毛外缘(外缘被背光照亮,颜色和灯带相近)+ g = np.zeros_like(alpha)+ parts = ""+ if "glow" in c:+ ch, lo, hi, parts = c["glow"]+ inner = np.asarray(Image.fromarray((alpha * 255).astype(np.uint8)).filter(ImageFilter.MinFilter(25))) / 255.0+ g = ramp(rgb[..., "rgb".index(ch)], lo, hi) * inner+ zone_l, zone_r, zone_t = ear_l * in_ear_y, ear_r * in_ear_y, top+ zone_h = np.clip(1 - zone_l - zone_r - zone_t, 0, 1)+ eye_d = np.min([np.hypot(xx - ex, yy - ey) for ex, ey in c["eyes"]], axis=0)+ on = lambda p: 1.0 if p in parts else 0.0+ g_head = g * zone_h * ramp(eye_d, c["er"] * c["patch"][1], c["er"] * c["patch"][1] + 6) * on("h")++ layers = [+ (head_rgb, head_m),+ (rgb, earL_m),+ (rgb, earR_m),+ (rgb, top_m),+ (rgb, g_head),+ (rgb, g * zone_l * on("l")),+ (rgb, g * zone_r * on("r")),+ (rgb, g * zone_t * on("t")),+ ]+ x0, y0 = CX - SIDE // 2, CY - SIDE // 2+ sheet = Image.new("RGBA", (CELL * len(layers), CELL), (0, 0, 0, 0))+ for i, (col, m) in enumerate(layers):+ layer = np.dstack([np.clip(col, 0, 255), np.clip(m * 255, 0, 255)]).astype(np.uint8)+ canvas = Image.new("RGBA", (SIDE, SIDE), (0, 0, 0, 0))+ canvas.paste(Image.fromarray(layer, "RGBA"), (-x0, -y0))+ # 预乘后再缩放:透明处原图的黑底不会渗进绒毛边缘+ pre = np.asarray(canvas).astype(np.float32)+ pre[..., :3] *= pre[..., 3:4] / 255.0+ small = np.asarray(Image.fromarray(pre.astype(np.uint8), "RGBA").resize((CELL, CELL), Image.LANCZOS)).astype(np.float32)+ a8 = small[..., 3:4]+ small[..., :3] = np.where(a8 > 0, small[..., :3] * 255.0 / np.maximum(a8, 1), 0)+ sheet.paste(Image.fromarray(np.clip(small, 0, 255).astype(np.uint8), "RGBA"), (i * CELL, 0))+ os.makedirs(OUT, exist_ok=True)+ path = os.path.join(OUT, key + ".webp")+ sheet.save(path, "WEBP", quality=QUALITY, alpha_quality=90, method=6)++ k = CELL / SIDE+ to = lambda x, y: (round((x - x0) * k / CELL * 100, 2), round((y - y0) * k / CELL * 100, 2))+ eyes = [tuple(float(v) for v in to(*p)) for p in c["eyes"]]+ print(f"{key}: {os.path.getsize(path) // 1024}KB eyes={eyes} r={round(c['er'] * k / CELL * 100, 2)}% "+ f"earL={to(e['cutL'], (e['y0'] + e['y1']) / 2)} earR={to(e['cutR'], (e['y0'] + e['y1']) / 2)} "+ f"top={to((t['stem'][0] + t['stem'][1]) / 2, t['cut'])}")+++if __name__ == "__main__":+ for key in sys.argv[1:] or CHARS:+ build(key, CHARS[key])diff --git a/src/agent/settings.ts b/src/agent/settings.tsindex c8552d2..8d5d9ba 100644--- a/src/agent/settings.ts+++ b/src/agent/settings.ts@@ -2,6 +2,9 @@export type PermissionPreset = "readonly" | "workspace";export type CuBackend = "cua" | "codex";export type CuApproval = "auto" | "ask-input";+/** 内置头像角色(ui/components/avatar.js 的 BOT_CHARS);blue 是主角 */+export const BOT_AVATARS = ["blue", "yellow", "green", "red", "purple", "orange"] as const;+export type BotAvatarKey = (typeof BOT_AVATARS)[number];export interface BotSettings {/** 权限预设:readonly = 只读(不能改文件、命令只读沙箱);workspace = 可写本机器人工作区(默认),越界操作需审批 */@@ -26,6 +29,8 @@ export interface BotSettings {};/** 后台小任务(记忆整理、上下文管家、交接摘要)用的模型;空 = 用对话模型 */utilityModel: string;+ /** 头像角色;空 = 由机器人 id 决定 */+ avatar: BotAvatarKey | "";}export const DEFAULT_SETTINGS: BotSettings = {@@ -34,6 +39,7 @@ export const DEFAULT_SETTINGS: BotSettings = {steward: { enabled: true },computerUse: { enabled: true, backend: "cua", approval: "auto" },utilityModel: "",+ avatar: "",};export function normalizeSettings(raw: unknown): BotSettings {@@ -57,6 +63,7 @@ export function normalizeSettings(raw: unknown): BotSettings {approval: cu.approval === "ask-input" ? "ask-input" : "auto",},utilityModel: typeof r.utilityModel === "string" ? r.utilityModel.trim().slice(0, 200) : "",+ avatar: (BOT_AVATARS as readonly string[]).includes(r.avatar) ? r.avatar : "",};}diff --git a/src/app.ts b/src/app.tsindex 4a1b37d..7aa9fb2 100644--- a/src/app.ts+++ b/src/app.ts@@ -15,6 +15,7 @@ import { WeixinLogin } from "./channels/weixin/login.js";import { startWebServer, type WebServer } from "./web/server.js";import { logger, mask } from "./log.js";import { AgentManager } from "./agent/manager.js";+import { normalizeSettings } from "./agent/settings.js";import { locateDshRuntime } from "./agent/host.js";import { findAppRoot } from "./magpie/supervisor.js";import { MODELFLARE_LINES, modelflareBaseUrl, verifyModelflareKey, type ModelflareLine, type VerifyResult } from "./modelflare.js";@@ -217,6 +218,7 @@ export class App {feishuAppId: process.env.FEISHU_APP_ID ?? "",feishuAppSecret: process.env.FEISHU_APP_SECRET ?? "",weixinEnabled: true,+ settings: normalizeSettings({ avatar: "blue" }),});log.info(`created default bot ${bot.id}`, { feishuAppId: bot.feishuAppId || "(未配置)" });}diff --git a/src/web/server.ts b/src/web/server.tsindex 8ae439a..f6289e6 100644--- a/src/web/server.ts+++ b/src/web/server.ts@@ -32,6 +32,7 @@ const MIME: Record<string, string> = {".css": "text/css; charset=utf-8",".svg": "image/svg+xml",".png": "image/png",+ ".webp": "image/webp",".json": "application/json",".woff2": "font/woff2",};@@ -322,7 +323,12 @@ export async function startWebServer(app: App, opts: { port?: number; host?: strif (m === "POST") {const b = await readJson(req);if (!String(b.name || "").trim()) throw new HttpError(400, "名称不能为空");- const bot = app.store.createBot({ name: String(b.name).trim(), systemPrompt: String(b.systemPrompt ?? ""), defaultModel: String(b.defaultModel ?? "") });+ const bot = app.store.createBot({+ name: String(b.name).trim(),+ systemPrompt: String(b.systemPrompt ?? ""),+ defaultModel: String(b.defaultModel ?? ""),+ settings: normalizeSettings({ avatar: b.avatar }),+ });await app.startBot(bot.id);return send(res, 201, { bot: publicBot(bot) });}@@ -359,6 +365,7 @@ export async function startWebServer(app: App, opts: { port?: number; host?: str...cur,...(b.permission !== undefined ? { permission: b.permission } : {}),...(b.utilityModel !== undefined ? { utilityModel: b.utilityModel } : {}),+ ...(b.avatar !== undefined ? { avatar: b.avatar } : {}),...(b.computerUse !== undefined ? { computerUse: { ...cur.computerUse, ...b.computerUse } } : {}),memory: { ...cur.memory, ...(b.memory ?? {}) },steward: { ...cur.steward, ...(b.steward ?? {}) },diff --git a/test/design-system.unit.test.ts b/test/design-system.unit.test.tsnew file mode 100644index 0000000..26a2afa--- /dev/null+++ b/test/design-system.unit.test.ts@@ -0,0 +1,77 @@+/**+ * 设计规范守卫(ui/design/README.md):颜色、字号、圆角、动效、层级只能来自 token。+ * 原始值只允许出现在 ui/design/tokens/ 里;组件文件里需要的"魔法数"先起名(--组件-xxx: 值)再用。+ * 另外检查所有 var(--x) 都有定义,改名或删 token 时不会留下悬空引用。+ */+import { describe, it, expect } from "vitest";+import fs from "node:fs";+import path from "node:path";++const UI = path.join(import.meta.dirname, "..", "ui");+const TOKENS = path.join(UI, "design", "tokens");++const files = (ext: string) =>+ (fs.readdirSync(UI, { recursive: true }) as string[]).filter((f) => f.endsWith(ext)).map((f) => path.join(UI, f));+const rel = (f: string) => path.relative(path.join(UI, ".."), f);+/** 注释换成等长空白,保留行号 */+const stripComments = (s: string) => s.replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, " "));+const lineOf = (s: string, i: number) => s.slice(0, i).split("\n").length;+/** 去掉自定义属性名,剩下的才是原始值(--ease-out 之类不算缓动关键字) */+const withoutVars = (v: string) => v.replace(/--[\w-]+/g, "");++type Hit = string;++function lintCss(file: string): Hit[] {+ const src = stripComments(fs.readFileSync(file, "utf8"));+ const hits: Hit[] = [];+ const decl = /([\w-]+)\s*:\s*([^;{}]+)/g;+ for (let m; (m = decl.exec(src)); ) {+ const [, prop, value] = m;+ const at = `${rel(file)}:${lineOf(src, m.index)}`;+ const raw = withoutVars(value);+ const custom = prop.startsWith("--");+ if (/#[0-9a-fA-F]{3,8}\b/.test(value) || /\b(rgba?|hsla?)\((?![^)]*var\()/.test(value)) hits.push(`${at} 原始颜色:${prop}: ${value.trim()}`);+ if (custom) continue;+ if ((prop === "font-size" || prop === "font") && /\d(px|rem|pt)\b/.test(raw)) hits.push(`${at} 原始字号:${prop}: ${value.trim()}`);+ if (prop === "border-radius" && (raw.match(/[\d.]+px/g) || []).some((n) => parseFloat(n) >= 3)) hits.push(`${at} 原始圆角:${value.trim()}`);+ if (/^(transition|animation)(-duration|-delay)?$/.test(prop) && (raw.match(/(?<![\w.-])[\d.]+m?s\b/g) || []).some((t) => parseFloat(t) > 0)) hits.push(`${at} 原始时长:${prop}: ${value.trim()}`);+ if (/^(transition|animation)(-timing-function)?$/.test(prop) && /cubic-bezier\(|\bease(-in-out|-in|-out)?\b/.test(raw)) hits.push(`${at} 原始缓动:${prop}: ${value.trim()}`);+ if (prop === "z-index" && /^\s*-?\d+\s*$/.test(value) && value.trim() !== "0") hits.push(`${at} 原始层级:z-index: ${value.trim()}`);+ }+ return hits;+}++function lintJs(file: string): Hit[] {+ const src = fs.readFileSync(file, "utf8");+ const hits: Hit[] = [];+ const bad = /(background|color|border|fill|stroke)[\w-]*\s*:\s*[^;"'`]*(#[0-9a-fA-F]{3,8}\b|rgba?\()|font-size\s*:\s*\d/g;+ for (let m; (m = bad.exec(src)); ) hits.push(`${rel(file)}:${lineOf(src, m.index)} 内联样式里的原始值:${m[0]}`);+ return hits;+}++describe("设计规范", () => {+ const css = files(".css").filter((f) => !f.startsWith(TOKENS + path.sep));+ const js = files(".js");++ it("颜色 / 字号 / 圆角 / 动效 / 层级只用 token", () => {+ expect([...css.flatMap(lintCss), ...js.flatMap(lintJs)]).toEqual([]);+ });++ it("每个 var(--x)(没有回退值的)都有定义", () => {+ const all = [...files(".css"), ...js].map((f) => [f, fs.readFileSync(f, "utf8")] as const);+ const defined = new Set<string>();+ for (const [, s] of all) for (const m of s.matchAll(/(?:^|[\s;{("'`])(--[\w-]+)\s*["'`]?\s*:/g)) defined.add(m[1]);+ const missing: string[] = [];+ for (const [f, s] of all)+ for (const m of s.matchAll(/var\(\s*(--[\w-]+)\s*\)/g)) if (!defined.has(m[1])) missing.push(`${rel(f)}:${lineOf(s, m.index!)} ${m[1]}`);+ expect(missing).toEqual([]);+ });++ it("入口按层引入了每个组件与基础样式文件", () => {+ const entry = fs.readFileSync(path.join(UI, "design", "index.css"), "utf8");+ const want = ["tokens", "base", "components"].flatMap((d) =>+ fs.readdirSync(path.join(UI, "design", d)).filter((f) => f.endsWith(".css")).map((f) => `${d}/${f}`),+ );+ expect(want.filter((f) => !entry.includes(`"${f}"`))).toEqual([]);+ });+});diff --git a/test/e2e.test.ts b/test/e2e.test.tsindex e14627b..9f98144 100644--- a/test/e2e.test.ts+++ b/test/e2e.test.ts@@ -169,9 +169,14 @@ describe("Web 界面 / API", () => {expect(seen.size).toBeGreaterThan(15);});it("机器人 CRUD + 飞书凭据(secret 不回显)+ 测试对话", async () => {- const c = await api("/bots", { method: "POST", body: { name: "测试机器人", systemPrompt: "你是测试", defaultModel: "mock-b" } });+ const c = await api("/bots", { method: "POST", body: { name: "测试机器人", systemPrompt: "你是测试", defaultModel: "mock-b", avatar: "red" } });expect(c.status).toBe(201);const id = c.json.bot.id;+ // 头像角色:创建时带上,设置里可以改,未知值被忽略+ expect(c.json.bot.settings.avatar).toBe("red");+ expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { avatar: "purple" } })).json.settings.avatar).toBe("purple");+ expect((await api(`/bots/${id}/settings`, { method: "PUT", body: { avatar: "pink" } })).json.settings.avatar).toBe("");+ expect((await api("/bots/default")).json.bot.settings.avatar).toBe("blue");const f = await api(`/bots/${id}/feishu`, { method: "PUT", body: { appId: "cli_x", appSecret: "very-secret-value" } });expect(f.status).toBe(200);const g = await api(`/bots/${id}`);diff --git a/test/phase3.unit.test.ts b/test/phase3.unit.test.tsindex 3fc694c..bae363c 100644--- a/test/phase3.unit.test.ts+++ b/test/phase3.unit.test.ts@@ -96,6 +96,10 @@ describe("settings", () => {expect(normalizeSettings({ computerUse: { approval: "always" } }).computerUse.approval).toBe("auto");expect(normalizeSettings({ computerUse: { approval: "readonly-free" } }).computerUse.approval).toBe("auto");expect(normalizeSettings({ computerUse: { approval: "ask-input", backend: "codex" } }).computerUse).toEqual({ enabled: true, backend: "codex", approval: "ask-input" });+ // 头像角色:只接受内置的 6 个,其他值回到"由 id 决定"+ expect(normalizeSettings({ avatar: "red" }).avatar).toBe("red");+ expect(normalizeSettings({ avatar: "pink" }).avatar).toBe("");+ expect(normalizeSettings({ avatar: 3 }).avatar).toBe("");expect(permissionMode("readonly")).toBe("read-only");expect(permissionMode("workspace")).toBe("workspace-write");});diff --git a/ui/components/avatar.js b/ui/components/avatar.jsindex 162d150..06d1b5f 100644--- a/ui/components/avatar.js+++ b/ui/components/avatar.js@@ -1,85 +1,241 @@-// 机器人头像(每个机器人一个色相;只在工作中才动)与应用标志。-import { useEffect } from "preact/hooks";+// 机器人头像:6 个内置毛绒角色(蓝色"小蓝"是主角),每个机器人配一个;会看指针、眨眼,并对平台里发生的事做出反应。+// 图层由 scripts/build-bot-avatars.py 从 anymodelbot_design/logo avator/ 生成(ui/design/bots/<key>.webp);+// 下面的几何是相对头像方框的百分比,和脚本输出的是同一套数,换图后要一起更新。+import { useEffect, useRef, useState } from "preact/hooks";import { html } from "./ui.js";+import { ms, reducedMotion } from "../design/motion.js";-/** Stable soft hue (0–359) from bot id/name. */-export function botHue(id, name) {- const s = String(id || name || "?");+/**+ * 角色。eyes:两眼中心;r:眼睛半径;earL / earR / top:耳朵与头顶配件的转轴;tip:配件的中心(特效从这里发出);+ * lens:护目镜镜片(只有探险者有)。pick:适合配给哪些机器人(新建页模板按这个配对)。+ */+export const BOT_CHARS = {+ blue: {+ name: "小蓝", role: "主角 · 通用助手", pick: "天线一直在线,什么信号都接得住。默认助手、会议纪要。",+ eyes: [[38.81, 62.99], [60.82, 62.99]], r: 3.41, earL: [18.14, 62.21], earR: [81.94, 62.21], top: [49.96, 31.78], tip: [49.8, 21.2],+ },+ yellow: {+ name: "小萌", role: "客服 · 陪聊", pick: "头顶一颗小星星,一笑就脸红。客服、答疑、陪聊。",+ eyes: [[38.34, 63.5], [61.4, 63.48]], r: 3.57, earL: [17.91, 62.13], earR: [82.25, 62.13], top: [50.04, 31.32], tip: [50, 19.7],+ },+ green: {+ name: "绿草", role: "日报 · 整理", pick: "每天长高一点点。群聊日报、记忆整理、知识库。",+ eyes: [[38.8, 63.07], [61.09, 63.08]], r: 3.49, earL: [17.91, 62.71], earR: [82.02, 62.71], top: [50, 31.32], tip: [50.2, 21.2],+ },+ red: {+ name: "红魔", role: "代码 · 自动化", pick: "戴上耳机就进入状态。写代码、跑脚本、自动化。",+ eyes: [[37.53, 59.46], [62.24, 59.45]], r: 3.88, earL: [19.53, 58.06], earR: [80.47, 58.06], top: [50.04, 28.37], tip: [50, 15],+ },+ purple: {+ name: "紫钻", role: "写作 · 创意", pick: "灵感会在头顶结晶。写作、润色、出点子。",+ eyes: [[38.86, 63.04], [60.96, 63.04]], r: 3.49, earL: [18.14, 62.91], earR: [81.94, 62.91], top: [49.84, 32.87], tip: [50, 22],+ },+ orange: {+ name: "探险者", role: "翻译 · 搜索", pick: "护目镜一戴,满世界找答案。翻译、搜索、操作电脑。",+ eyes: [[38.18, 61.84], [61.83, 61.84]], r: 3.57, earL: [15.66, 61.47], earR: [84.34, 61.47], top: [50.12, 27.44], tip: [50, 17],+ lens: [[35.27, 40.85], [64.81, 40.85], 6.4],+ },+};+export const CHAR_KEYS = Object.keys(BOT_CHARS);+export const MAIN_CHAR = "blue";++function hash(s) {let h = 2166136261;for (let i = 0; i < s.length; i++) {h ^= s.charCodeAt(i);h = Math.imul(h, 16777619);}- return Math.abs(h) % 360;+ return h >>> 0;+}+/** 机器人用哪个角色:设置里选过的 > 默认机器人用主角 > 由 id 稳定地挑一个 */+export function charOf(bot) {+ const a = bot && bot.settings && bot.settings.avatar;+ if (a && BOT_CHARS[a]) return a;+ if (!bot || bot.id === "default") return MAIN_CHAR;+ return CHAR_KEYS[hash(String(bot.id || bot.name || "?")) % CHAR_KEYS.length];+}++// —— 指针:一个全局监听,写每张脸的 --look-x / --look-y(只有指针靠近的脸会看过去) ——+let watchers = 0;+let px = -1e5;+let py = -1e5;+let raf = 0;+function applyLook() {+ raf = 0;+ for (const el of document.querySelectorAll(".bot-face")) {+ const r = el.getBoundingClientRect();+ if (!r.width) continue;+ const dx = px - (r.left + r.width / 2);+ const dy = py - (r.top + r.height / 2);+ const fall = Math.max(0, 1 - Math.hypot(dx, dy) / Math.max(140, r.width * 4));+ el.style.setProperty("--look-x", Math.max(-1, Math.min(1, (dx / (r.width * 0.7)) * fall)).toFixed(3));+ el.style.setProperty("--look-y", Math.max(-1, Math.min(1, (dy / (r.height * 0.7)) * fall)).toFixed(3));+ }+}+const onMove = (e) => {+ px = e.clientX;+ py = e.clientY;+ if (!raf) raf = requestAnimationFrame(applyLook);+};+const onOut = (e) => {+ if (e.relatedTarget) return;+ px = py = -1e5;+ if (!raf) raf = requestAnimationFrame(applyLook);+};+function watchPointer() {+ if (reducedMotion()) return () => {};+ if (watchers++ === 0) {+ window.addEventListener("pointermove", onMove, { passive: true });+ window.addEventListener("pointerout", onOut);+ }+ return () => {+ if (--watchers) return;+ window.removeEventListener("pointermove", onMove);+ window.removeEventListener("pointerout", onOut);+ };+}++// —— 表情:每种都画在以眼睛中心为原点的坐标里(单位同 viewBox 0–100),右眼镜像 ——+function eyeShapes(R) {+ const f = (n) => +(n * R).toFixed(2);+ const spiral = [];+ for (let i = 0; i <= 28; i++) {+ const t = (i / 28) * Math.PI * 4.2;+ const rr = (0.12 + (0.9 * i) / 28) * R;+ spiral.push(`${i ? "L" : "M"}${(Math.cos(t) * rr).toFixed(2)} ${(Math.sin(t) * rr).toFixed(2)}`);+ }+ return html`<circle class="e e-open" r=${R} />+ <path class="e e-happy line" d=${`M${f(-1.05)} ${f(0.45)}Q0 ${f(-1.3)} ${f(1.05)} ${f(0.45)}`} />+ <path class="e e-closed line" d=${`M${f(-1.05)} ${f(-0.15)}Q0 ${f(0.8)} ${f(1.05)} ${f(-0.15)}`} />+ <path class="e e-sad" d=${`M${f(-1.05)} 0L${f(1.05)} 0A${f(1.05)} ${f(1.05)} 0 0 1 ${f(-1.05)} 0Z`} />+ <path class="e e-x line" d=${`M${f(-0.8)} ${f(-0.8)}L${f(0.8)} ${f(0.8)}M${f(0.8)} ${f(-0.8)}L${f(-0.8)} ${f(0.8)}`} />+ <path class="e e-spiral line thin" d=${spiral.join("")} />+ <path class="e e-heart" d=${`M0 ${f(1.05)}C${f(-1.7)} ${f(-0.05)} ${f(-1)} ${f(-1.4)} 0 ${f(-0.5)}C${f(1)} ${f(-1.4)} ${f(1.7)} ${f(-0.05)} 0 ${f(1.05)}Z`} />`;+}++const BUSY = new Set(["thinking", "replying", "working"]);+/** 一次性反应对应的表情(error 先是 ×× 再变成难过,在 CSS 里接力) */+const SHOT_EYES = { hello: "happy", done: "happy", poke: "happy", love: "heart", dizzy: "spiral", error: "error" };+const STATE_EYES = { sleep: "closed" };++/** 粒子:只在大于 FX_MIN 的头像上画 */+const FX_MIN = 36;+const BURST = [0, 45, 90, 135, 180, 225, 270, 315];+const Twinkles = () => html`<span class="fx fx-twinkle"><i></i><i></i><i></i></span>`;+function Fx({ char, state, shot }) {+ const busy = BUSY.has(state);+ return html`+ ${busy && (char === "yellow" || char === "purple") && html`<${Twinkles} />`}+ ${state === "thinking" && !shot && html`<span class="fx fx-think"><i></i><i></i><i></i></span>`}+ ${state === "waiting" && !shot && html`<span class="fx fx-bang">!</span>`}+ ${state === "sleep" && !shot && html`<span class="fx fx-zzz"><i>z</i><i>z</i><i>z</i></span>`}+ ${(shot === "done" || shot === "hello" || shot === "love") && html`<span class="fx fx-burst">${BURST.map((a, i) => html`<i style=${{ "--a": a + "deg", "--i": i }}></i>`)}</span>`}+ ${shot === "done" && char === "green" && html`<span class="fx fx-leaf"></span>`}+ ${shot === "love" && html`<span class="fx fx-hearts"><i></i><i></i><i></i></span>`}+ ${shot === "dizzy" && html`<span class="fx fx-orbit"><i></i><i></i><i></i></span>`}`;}/**- * One shared pointermove on a container; writes --look-x/--look-y on each working face- * inside it (idle faces stay still).+ * 机器人头像。+ * bot / char 角色:给 bot 时按 charOf(bot),char 直接指定(选择器、样例页)+ * state 持续状态:idle | listening(用户在输入)| thinking | replying | working | waiting(等你批准)| sleep+ * cue 一次性反应 { kind: "error" | "done" | "hello", at },at 变了就再播一次;忙 → 不忙时自动播 done+ * greet 挂载时打个招呼(hello)+ * lively 大头像:空闲时也呼吸、眨眼、四处看,脚下有影子+ * pokeable 可以戳:戳一下开心,连戳三下冒爱心,戳太多会晕+ * neutral 还没有身份的灰色版(新建页占位)*/-export function usePointerLook(containerRef) {+export function BotAvatar({ bot, id, name, char, size = 34, state = "idle", working = false, cue, greet = false, lively = false, pokeable = false, neutral = false }) {+ const key = BOT_CHARS[char] ? char : neutral ? MAIN_CHAR : charOf(bot || (id || name ? { id, name } : null));+ const c = BOT_CHARS[key];+ const st = working && state === "idle" ? "working" : state;+ const [shot, setShot] = useState(greet ? "hello" : "");+ const [n, setN] = useState(0);+ const timer = useRef(0);+ const playing = useRef(greet ? "hello" : "");+ const prev = useRef(st);+ const lastCue = useRef(cue && cue.at);+ const pokes = useRef([]);++ const play = (kind) => {+ clearTimeout(timer.current);+ playing.current = kind;+ setShot(kind);+ setN((v) => v + 1);+ timer.current = setTimeout(() => ((playing.current = ""), setShot("")), ms(`--bot-${kind}`, 1200));+ };useEffect(() => {- const root = containerRef.current;- if (!root || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;- let raf = 0;- let px = -1e5;- let py = -1e5;- const apply = () => {- raf = 0;- for (const el of root.querySelectorAll(".bot-face.is-working")) {- const r = el.getBoundingClientRect();- if (!r.width) continue;- const dx = px - (r.left + r.width / 2);- const dy = py - (r.top + r.height / 2);- const reach = Math.max(96, r.width * 3.2);- const fall = Math.max(0, 1 - Math.hypot(dx, dy) / reach);- el.style.setProperty("--look-x", Math.max(-1, Math.min(1, (dx / (r.width * 0.55)) * fall)).toFixed(3));- el.style.setProperty("--look-y", Math.max(-1, Math.min(1, (dy / (r.height * 0.55)) * fall)).toFixed(3));- }- };- const onMove = (e) => {- px = e.clientX;- py = e.clientY;- if (!raf) raf = requestAnimationFrame(apply);- };- const onLeave = () => {- px = py = -1e5;- if (!raf) raf = requestAnimationFrame(apply);- };- root.addEventListener("pointermove", onMove, { passive: true });- root.addEventListener("pointerleave", onLeave);- return () => {- root.removeEventListener("pointermove", onMove);- root.removeEventListener("pointerleave", onLeave);- if (raf) cancelAnimationFrame(raf);- };+ if (greet) timer.current = setTimeout(() => ((playing.current = ""), setShot("")), ms("--bot-hello", 1600));+ const stop = watchPointer();+ return () => (clearTimeout(timer.current), stop());}, []);-}+ useEffect(() => {+ const was = prev.current;+ prev.current = st;+ if (cue && cue.at && cue.at !== lastCue.current) {+ lastCue.current = cue.at;+ play(cue.kind);+ } else if (BUSY.has(was) && !BUSY.has(st) && st !== "waiting" && playing.current !== "error") play("done");+ }, [st, cue && cue.at]);++ const poke = () => {+ const now = performance.now();+ pokes.current = pokes.current.filter((t) => now - t < 1800).concat(now);+ const k = pokes.current.length;+ if (k >= 6) pokes.current = [];+ play(k >= 6 ? "dizzy" : k >= 3 ? "love" : "poke");+ };-export function BotAvatar({ name, id, size = 34, working = false }) {- const vb = size;- const eyeR = size * 0.11;- const pupilR = size * 0.055;- const eyeY = size * 0.42;- const eyeDX = size * 0.16;- const mouthY = size * 0.68;- return html`<div class=${`bot-face${working ? " is-working" : ""}`} style=${{ width: size + "px", height: size + "px", "--bot-hue": String(botHue(id, name)) }} aria-hidden="true">- <div class="bot-face-3d">- <svg width=${size} height=${size} viewBox=${`0 0 ${vb} ${vb}`} xmlns="http://www.w3.org/2000/svg">- <circle class="bot-head" cx=${vb / 2} cy=${vb / 2} r=${vb / 2 - 0.5} />- <ellipse class="bot-eye-white" cx=${vb / 2 - eyeDX} cy=${eyeY} rx=${eyeR * 1.15} ry=${eyeR} />- <ellipse class="bot-eye-white" cx=${vb / 2 + eyeDX} cy=${eyeY} rx=${eyeR * 1.15} ry=${eyeR} />- <g class="bot-pupils">- <circle class="bot-pupil" cx=${vb / 2 - eyeDX} cy=${eyeY} r=${pupilR} />- <circle class="bot-pupil" cx=${vb / 2 + eyeDX} cy=${eyeY} r=${pupilR} />- </g>- <path class="bot-mouth bot-mouth-idle" d=${`M ${vb / 2 - size * 0.12} ${mouthY} Q ${vb / 2} ${mouthY + size * 0.08} ${vb / 2 + size * 0.12} ${mouthY}`} stroke-linecap="round" />- <ellipse class="bot-mouth bot-mouth-work" cx=${vb / 2} cy=${mouthY + size * 0.02} rx=${size * 0.07} ry=${size * 0.045} />- </svg>+ const eyes = (shot && SHOT_EYES[shot]) || STATE_EYES[st] || "open";+ const p = (pt) => `${pt[0]}% ${pt[1]}%`;+ const style = {+ "--s": size + "px",+ "--bf-sprite": `url("/amb/static/design/bots/${key}.webp")`,+ "--o-el": p(c.earL),+ "--o-er": p(c.earR),+ "--o-top": p(c.top),+ "--tip-x": c.tip[0] + "%",+ "--tip-y": c.tip[1] + "%",+ "--bf-seed": ((hash(String((bot && bot.id) || id || key)) % 1000) / 1000).toFixed(3),+ };+ const cls = `bot-face${lively ? " lively" : ""}${pokeable ? " pokeable" : ""}${neutral ? " neutral" : ""}${size < FX_MIN ? " sm" : ""}`;+ const part = (k) => html`<i class=${`bf-part bf-${k}`}><i class="bf-pin"><b class="bf-img"></b><b class="bf-glow"></b></i></i>`;+ return html`<div class=${cls} style=${style} data-char=${key} data-state=${st} data-shot=${shot || undefined} data-eyes=${eyes}+ aria-hidden="true" onClick=${pokeable ? poke : undefined}>+ ${lively && html`<i class="bf-shadow"></i>`}+ <i class="bf-aura"></i>+ <div class="bf-body">+ <div class="bf-shot" key=${n}>+ <div class="bf-look">+ ${part("ear-l")}${part("ear-r")}${part("top")}+ <i class="bf-part bf-head"><b class="bf-img"></b><b class="bf-glow"></b></i>+ ${c.lens && c.lens.slice(0, 2).map((l) => html`<i class="bf-lens" style=${{ left: l[0] + "%", top: l[1] + "%", "--lens": c.lens[2] * 2 + "%" }}></i>`)}+ ${c.eyes.map((e) => html`<i class="bf-blush" style=${{ left: (e[0] + (e[0] < 50 ? -5.6 : 5.6)).toFixed(2) + "%", top: (e[1] + 6.2).toFixed(2) + "%" }}></i>`)}+ <svg class="bf-eyes" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">+ <g class="bf-gaze"><g class="bf-glance">+ ${c.eyes.map((e, i) => html`<g transform=${`translate(${e[0]} ${e[1]})${i ? " scale(-1 1)" : ""}`}><g class="bf-lid">${eyeShapes(c.r)}</g></g>`)}+ </g></g>+ </svg>+ ${size >= FX_MIN && key === "blue" && BUSY.has(st) && html`<span class="fx fx-rings"><i></i><i></i><i></i></span>`}+ </div>+ ${size >= FX_MIN && html`<${Fx} char=${key} state=${st} shot=${shot} />`}+ </div></div></div>`;}+/** 选角色:一排 6 个头像(单选)。value 为空时高亮 fallback(当前由 id 决定的那个) */+export function AvatarPicker({ value, fallback, onChange, size = 44, label = "头像" }) {+ const cur = value || fallback;+ return html`<div class="avatar-picker" role="radiogroup" aria-label=${label}>+ ${CHAR_KEYS.map((k) => html`<button type="button" key=${k} class=${`avatar-opt${k === cur ? " on" : ""}`} role="radio" aria-checked=${k === cur}+ title=${`${BOT_CHARS[k].name} · ${BOT_CHARS[k].pick}`} onClick=${() => k !== cur && onChange(k)}>+ <${BotAvatar} char=${k} size=${size} state=${k === cur ? "listening" : "idle"} />+ <span class="avatar-name">${BOT_CHARS[k].name}</span>+ </button>`)}+ </div>`;+}+/** AnyModelBot 自己的标志:一个 m 字形的折线 */export function AppMark({ size = 32 }) {return html`<div class="app-mark" style=${{ width: size + "px", height: size + "px" }} aria-hidden="true">diff --git a/ui/components/ui.js b/ui/components/ui.jsindex 6061d44..71e67b2 100644--- a/ui/components/ui.js+++ b/ui/components/ui.js@@ -1,8 +1,10 @@-// 共用组件:图标、分段控件、弹出菜单、确认框、提示胶囊、复制按钮。+// 共用组件:图标、按钮、分段控件、弹出菜单、确认框、提示胶囊、复制按钮、骨架。+// 样式在 ui/design/components/*.css;这里的组件只是给常用组合一个带逻辑的写法,直接写 class 也可以。import { h } from "preact";import { useEffect, useLayoutEffect, useRef, useState, useCallback } from "preact/hooks";import htm from "htm";import { useStore, toasts, dismissToast, dialog } from "../lib/store.js";+import { usePresence } from "../design/motion.js";export const html = htm.bind(h);@@ -28,6 +30,20 @@ const P = {refresh: "M13.25 8a5.25 5.25 0 1 1-1.54-3.71M13.25 2.75v2.5h-2.5",stop: "M4.5 4.5h7v7h-7z",more: "M4 8h.01M8 8h.01M12 8h.01",+ panel: "M2.75 3.25h10.5c.41 0 .75.34.75.75v8c0 .41-.34.75-.75.75H2.75a.75.75 0 0 1-.75-.75V4c0-.41.34-.75.75-.75ZM10 3.25v9.5",+ compose: "M7.5 2.75H3.75a1 1 0 0 0-1 1v8.5a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V8.5M11.6 2.4a1.4 1.4 0 0 1 2 2L8 10l-2.5.5L6 8l5.6-5.6Z",+ clock: "M8 14a6 6 0 1 0 0-12 6 6 0 0 0 0 12ZM8 4.75V8l2.25 1.5",+ arrowLeft: "M13 8H3.5M7.25 3.75 3 8l4.25 4.25",+ sliders: "M2.5 4.5h6.5M12.5 4.5h1M2.5 11.5h1M7 11.5h6.5M10.75 3v3M5.25 10v3",+ spark: "M8 1.75c.35 2.9 1.35 3.9 4.25 4.25C9.35 6.35 8.35 7.35 8 10.25 7.65 7.35 6.65 6.35 3.75 6 6.65 5.65 7.65 4.65 8 1.75ZM12.25 10.5c.15 1.15.6 1.6 1.75 1.75-1.15.15-1.6.6-1.75 1.75-.15-1.15-.6-1.6-1.75-1.75 1.15-.15 1.6-.6 1.75-1.75Z",+ monitor: "M2.75 2.75h10.5c.41 0 .75.34.75.75v6.75c0 .41-.34.75-.75.75H2.75a.75.75 0 0 1-.75-.75V3.5c0-.41.34-.75.75-.75ZM5.75 13.75h4.5M8 11v2.75",+ lock: "M4.25 7.25h7.5c.41 0 .75.34.75.75v5c0 .41-.34.75-.75.75h-7.5a.75.75 0 0 1-.75-.75V8c0-.41.34-.75.75-.75ZM5.5 7.25V5a2.5 2.5 0 0 1 5 0v2.25",+ globe: "M8 14a6 6 0 1 0 0-12 6 6 0 0 0 0 12ZM2.25 8h11.5M8 2c1.55 1.65 2.35 3.65 2.35 6S9.55 12.35 8 14M8 2C6.45 3.65 5.65 5.65 5.65 8s.8 4.35 2.35 6",+ database: "M8 5.25c2.9 0 5.25-.78 5.25-1.75S10.9 1.75 8 1.75 2.75 2.53 2.75 3.5 5.1 5.25 8 5.25ZM2.75 3.5v9c0 .97 2.35 1.75 5.25 1.75s5.25-.78 5.25-1.75v-9M2.75 8c0 .97 2.35 1.75 5.25 1.75S13.25 8.97 13.25 8",+ info: "M8 14a6 6 0 1 0 0-12 6 6 0 0 0 0 12ZM8 7.25v3.75M8 4.9v.1",+ chat: "M3.25 2.75h9.5c.41 0 .75.34.75.75v6.75c0 .41-.34.75-.75.75H7.25L4.5 13.25V11H3.25a.75.75 0 0 1-.75-.75V3.5c0-.41.34-.75.75-.75Z",+ code: "M5.25 4.5 1.75 8l3.5 3.5M10.75 4.5 14.25 8l-3.5 3.5M9.1 2.75 6.9 13.25",+ shield: "M8 1.75 2.75 3.6v4.15c0 3.05 2.2 5.4 5.25 6.5 3.05-1.1 5.25-3.45 5.25-6.5V3.6L8 1.75Z",};export function Icon({ name, size = 16, stroke = 1.6, class: cls = "" }) {const fill = name === "stop";@@ -35,6 +51,34 @@ export function Icon({ name, size = 16, stroke = 1.6, class: cls = "" }) {stroke="currentColor" stroke-width=${name === "more" ? 2.6 : stroke} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${P[name]} /></svg>`;}+const cx = (...a) => a.filter(Boolean).join(" ");++/** 按钮:variant = "primary" | "ghost" | "danger";size = "sm" | "lg";loading 时转圈并禁用 */+export function Button({ variant, size, block, loading, icon, class: cls, type = "button", disabled, children, ...rest }) {+ return html`<button type=${type} class=${cx("btn", variant, size, block && "block", cls)} disabled=${disabled || loading} aria-busy=${loading || undefined} ...${rest}>+ ${loading ? html`<${Spinner} />` : icon && html`<${Icon} name=${icon} size=${14} />`}${children}+ </button>`;+}++/** 图标按钮:必须给 label(读屏与悬停提示) */+export function IconButton({ icon, label, size, iconSize = 14, on, class: cls, type = "button", ...rest }) {+ return html`<button type=${type} class=${cx("icon-btn", size, on && "on", cls)} title=${label} aria-label=${label} ...${rest}>+ <${Icon} name=${icon} size=${iconSize} />+ </button>`;+}++/** 行内提示:tone = "amber" | "red"(缺省为品牌色);action 放在右侧 */+export function Notice({ tone, action, children }) {+ return html`<div class=${cx("notice", tone)} role=${tone === "red" ? "alert" : undefined}>+ <span class="notice-text">${children}</span>${action}+ </div>`;+}++/** 骨架条:w / h 为任意 CSS 长度;circle 画圆 */+export function Skeleton({ w, h: height, circle }) {+ return html`<span class=${cx("skel", circle && "circle")} style=${{ width: w, height: height ?? (circle ? w : undefined) }} aria-hidden="true"></span>`;+}+/** 关闭 / 外部点击 / Esc */export function useDismiss(ref, onClose, active = true, ignore) {useEffect(() => {@@ -59,7 +103,13 @@ export function useDismiss(ref, onClose, active = true, ignore) {}, [active, onClose]);}-// —— 分段控件:滑动的品牌色 thumb ——+// —— 开关:只有开 / 关两态的设置 ——+export function Switch({ value, onChange, disabled, label, size }) {+ return html`<button type="button" role="switch" class=${cx("switch", size)} aria-checked=${!!value} aria-label=${label} title=${label}+ disabled=${disabled} onClick=${() => onChange(!value)}></button>`;+}++// —— 分段控件:滑动的 thumb ——export function Seg({ options, value, onChange, disabled, label }) {const ref = useRef(null);const thumb = useRef(null);@@ -171,10 +221,11 @@ export function Menu({ anchor, items, onClose, width = 240, prefer, align, label: it.group? html`<li class="group">${it.group}</li>`: html`<li role="menuitem" aria-disabled=${!!it.disabled}- class=${[sel === i ? "sel" : "", it.danger ? "danger" : "", it.disabled ? "disabled" : "", it.cur ? "cur" : "", it.note ? "explained" : ""].join(" ")}+ class=${[sel === i ? "sel" : "", it.danger ? "danger" : "", it.disabled ? "disabled" : "", it.cur ? "cur" : "", it.note ? "rich" : ""].join(" ")}onPointerMove=${() => !it.disabled && setSel(i)} onClick=${() => !it.disabled && run(it)}>- ${it.note ? html`<span class="v">${it.label}</span><span class="n" style="flex:none">${it.note}</span>` : html`<span class="v">${it.label}</span>`}- ${!it.note && html`<span class="check"><${Icon} name="check" size=${14} /></span>`}+ ${it.icon && html`<span class="lead"><${Icon} name=${it.icon} size=${15} /></span>`}+ ${it.note ? html`<span class="txt"><span class="v">${it.label}</span><span class="n">${it.note}</span></span>` : html`<span class="v">${it.label}</span>`}+ <span class="check"><${Icon} name="check" size=${14} /></span></li>`,)}</ul>@@ -228,7 +279,7 @@ export const Badge = ({ s }) => {};/** 自绘确认框:焦点先在"取消"(安全选项),Esc 关闭,Tab 在框内循环 */-export function Sheet({ title, onClose, children, wide, label }) {+export function Sheet({ title, onClose, children, wide, label, leaving }) {const ref = useRef(null);useEffect(() => {const prev = document.activeElement;@@ -257,7 +308,7 @@ export function Sheet({ title, onClose, children, wide, label }) {prev?.focus?.({ preventScroll: true });};}, []);- return html`<div class="scrim" onPointerDown=${(e) => e.target === e.currentTarget && onClose()}>+ return html`<div class=${cx("scrim", leaving && "leaving")} onPointerDown=${(e) => e.target === e.currentTarget && onClose()}><div class=${`sheet${wide ? " wide" : ""}`} ref=${ref} role="dialog" aria-modal="true" aria-label=${label || title}>${title && html`<h2>${title}</h2>`}${children}@@ -266,17 +317,22 @@ export function Sheet({ title, onClose, children, wide, label }) {}export function DialogHost() {- const d = useStore(dialog);- if (!d) return null;+ const cur = useStore(dialog);+ const last = useRef(cur);+ if (cur) last.current = cur;+ const { mounted, leaving } = usePresence(!!cur);+ if (!mounted) return null;+ const d = last.current;const done = (v) => {+ if (leaving) return;dialog.set(null);d.resolve(v);};- return html`<${Sheet} title=${d.title} onClose=${() => done(false)}>+ return html`<${Sheet} title=${d.title} leaving=${leaving} onClose=${() => done(false)}>${d.body && html`<p class="body">${d.body}</p>`}<div class="actions">- <button type="button" class="btn" data-autofocus onClick=${() => done(false)}>${d.cancelLabel || "取消"}</button>- <button type="button" class=${`btn ${d.danger ? "" : "primary"}`} style=${d.danger ? "background:var(--red);color:#fff" : ""} onClick=${() => done(true)}>${d.confirmLabel || "确定"}</button>+ <${Button} data-autofocus onClick=${() => done(false)}>${d.cancelLabel || "取消"}<//>+ <${Button} variant=${d.danger ? "danger" : "primary"} onClick=${() => done(true)}>${d.confirmLabel || "确定"}<//></div><//>`;}@@ -286,7 +342,7 @@ export function Toasts() {return html`<div class="toasts" role="status" aria-live="polite">${list.map((t) => html`<div key=${t.id} class=${`toast ${t.kind}${t.leaving ? " leaving" : ""}`}><span>${t.text}</span>- ${t.kind === "err" && html`<button type="button" class="icon-btn" style="width:18px;height:18px;color:inherit" aria-label="关闭" onClick=${() => dismissToast(t.id)}><${Icon} name="close" size=${12} /></button>`}+ ${t.kind === "err" && html`<${IconButton} icon="close" size="xs" iconSize=${12} label="关闭" onClick=${() => dismissToast(t.id)} />`}</div>`)}</div>`;}diff --git a/ui/css/avatar.css b/ui/css/avatar.cssdeleted file mode 100644index 3d8ed80..0000000--- a/ui/css/avatar.css+++ /dev/null@@ -1,59 +0,0 @@-/* Bot faces: static when idle (a quiet list); look-at, blink, bob and darting eyes only while working. */-.bot-face {- --look-x: 0;- --look-y: 0;- --face: hsl(var(--bot-hue, 240) 46% 78%);- --face-ink: hsl(var(--bot-hue, 240) 40% 22%);- --eye-white: #f8f8fc;- border-radius: 50%; flex: none; position: relative; perspective: 120px;-}-:root[data-theme="dark"] .bot-face {- --face: hsl(var(--bot-hue, 240) 34% 38%);- --face-ink: hsl(var(--bot-hue, 240) 60% 88%);- --eye-white: #1c1c28;-}-.bot-face-3d { width: 100%; height: 100%; border-radius: 50%; }-.bot-face svg { display: block; width: 100%; height: 100%; overflow: visible; }-.bot-head { fill: var(--face); stroke: color-mix(in srgb, var(--face-ink) 18%, transparent); stroke-width: 1; }-.bot-eye-white { fill: var(--eye-white); transform-box: fill-box; transform-origin: center; }-.bot-pupils { transform-box: view-box; transform-origin: center; }-.bot-pupil { fill: var(--face-ink); }-.bot-mouth { stroke: var(--face-ink); stroke-width: 1.4; transition: opacity .2s ease; }-.bot-mouth-idle { fill: none; }-.bot-mouth-work { fill: var(--face-ink); stroke: none; opacity: 0; }--.bot-face.is-working .bot-mouth-idle { opacity: 0; }-.bot-face.is-working .bot-mouth-work { opacity: 1; }-.bot-face.is-working { animation: bot-bob 1.6s ease-in-out infinite; }-.bot-face.is-working .bot-face-3d {- transform-style: preserve-3d;- transform: translateX(calc(var(--look-x) * 1.6px)) rotateY(calc(var(--look-x) * 18deg)) rotateX(calc(var(--look-y) * -10deg - 4deg));- transition: transform .14s ease-out;-}-.bot-face.is-working .bot-eye-white { animation: bot-eye-blink 2.4s calc(var(--bot-hue, 0) * 7ms) ease-in-out infinite; }-.bot-face.is-working .bot-pupils { animation: bot-dart 2.8s ease-in-out infinite; }-@keyframes bot-eye-blink {- 0%, 41%, 47%, 100% { transform: scaleY(1); }- 44% { transform: scaleY(0.08); }-}-@keyframes bot-bob {- 0%, 100% { transform: translateY(0); }- 50% { transform: translateY(-1.5px); }-}-@keyframes bot-dart {- 0%, 100% { transform: translate(calc(var(--look-x) * 2.4px), calc(var(--look-y) * 2.2px)); }- 22% { transform: translate(calc(var(--look-x) * 2.4px + 1.4px), calc(var(--look-y) * 2.2px - 0.6px)); }- 48% { transform: translate(calc(var(--look-x) * 2.4px - 1.2px), calc(var(--look-y) * 2.2px + 0.4px)); }- 70% { transform: translate(calc(var(--look-x) * 2.4px + 0.4px), calc(var(--look-y) * 2.2px + 1px)); }-}-@media (prefers-reduced-motion: reduce) {- .bot-face.is-working, .bot-face.is-working .bot-eye-white, .bot-face.is-working .bot-pupils { animation: none !important; }- .bot-face.is-working .bot-face-3d { transition: none; transform: none; }-}--/* the app's own mark (not Modelflare's or anyone else's logo) */-.app-mark {- display: grid; place-items: center; flex: none; border-radius: 30%;- background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line);-}-.app-mark svg { width: 56%; height: 56%; }diff --git a/ui/css/base.css b/ui/css/base.cssdeleted file mode 100644index c558d69..0000000--- a/ui/css/base.css+++ /dev/null@@ -1,257 +0,0 @@-/* Base + shared components. .list/.row, .seg, .pop, .text and the status pill- are adapted from yetone/magpie internal/gui/assets/app.css (MIT, © 2026 yetone). */-*, *::before, *::after { box-sizing: border-box; }-html, body { height: 100%; margin: 0; }-body {- font: 400 13px/1.4 var(--font);- color: var(--fg);- background: var(--bg);- -webkit-font-smoothing: antialiased;- overflow: hidden;- /* controls read as an app's: only what the window shows as content can be selected */- user-select: none;- -webkit-user-select: none;-}-:where(p, pre, code, td, .selectable, .msg, .notice-text, .err-text) { user-select: text; -webkit-user-select: text; }-h1, h2, h3, h4, p { margin: 0; }-button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: default; appearance: none; -webkit-appearance: none; text-align: center; }-input, textarea { font: inherit; color: inherit; }-a { color: var(--accent); text-decoration: none; }-a:hover { color: var(--accent-strong); text-decoration: underline; }-code, .mono { font-family: var(--code); font-size: 11.5px; font-variant-numeric: tabular-nums; }-.num { font-variant-numeric: tabular-nums; }-button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {- outline: 2px solid var(--accent); outline-offset: 1px;-}-svg.ic { width: 16px; height: 16px; flex: none; display: block; }-.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }--/* —— Buttons: primary / secondary (pill) / ghost / icon / text —— */-.btn {- display: inline-flex; align-items: center; justify-content: center; gap: 6px;- height: 28px; padding: 0 12px; border-radius: 8px;- font-size: 12.5px; font-weight: 500; white-space: nowrap;- background: var(--pill); color: var(--fg);- transition: background .12s, color .12s, transform .12s var(--ease), opacity .12s;-}-.btn:hover:not(:disabled) { background: var(--pill-hover); }-.btn:active:not(:disabled) { transform: scale(.96); }-.btn:disabled { opacity: .45; }-.btn.primary { background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line); }-.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }-.btn.primary:active:not(:disabled) { background: var(--accent-press); }-.btn.ghost { background: transparent; color: var(--ctl-fg); }-.btn.ghost:hover:not(:disabled) { background: var(--pill); color: var(--fg); }-.btn.lg { height: 36px; font-size: 13px; border-radius: 9px; }-.btn.block { width: 100%; }-.btn .spinner { width: 14px; height: 14px; }-.icon-btn {- width: 26px; height: 26px; border-radius: 7px; flex: none;- display: inline-flex; align-items: center; justify-content: center;- color: var(--muted); transition: background .12s, color .12s, transform .12s var(--ease);-}-.icon-btn:hover, .icon-btn.on { background: var(--pill); color: var(--fg); }-.icon-btn:active { transform: scale(.94); }-.text {- font-size: 12px; color: var(--ctl-fg); padding: 3px 7px; border-radius: 6px; white-space: nowrap;- transition: background .12s, color .12s;-}-.text:hover:not(:disabled) { background: var(--pill); color: var(--fg); }-.text:disabled { opacity: .45; }-.text.danger { color: var(--red); }-.text.danger:hover:not(:disabled) { background: var(--red-soft); color: var(--red); }-.text.accent { color: var(--accent); }-.copy.done { color: var(--green); background: var(--green-soft); animation: copy-pop .36s var(--ease); }-@keyframes copy-pop { 40% { transform: scale(1.12); } }--/* —— Inputs —— */-.field {- width: 100%; height: 32px; padding: 0 10px;- border: 1px solid var(--line); border-radius: 8px;- background: var(--card); color: var(--fg); outline: none;- transition: border-color .12s, box-shadow .12s;-}-.field::placeholder, textarea.field::placeholder { color: var(--placeholder); }-.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }-.field:focus-visible { outline: none; }-.field.mono { font-family: var(--code); font-size: 12.5px; }-.field.err { border-color: var(--red); }-.field.err:focus { border-color: var(--accent); }-textarea.field { height: auto; padding: 8px 10px; resize: none; line-height: 1.5; }-.field[readonly] { background: var(--card-2); }-.field-wrap { position: relative; display: flex; align-items: center; }-.field-wrap .field { padding-right: 62px; }-.field-wrap .tail { position: absolute; right: 4px; display: flex; gap: 2px; }--/* —— Badges / dots —— */-.badge {- display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;- font-size: 11px; font-weight: 500; white-space: nowrap; flex: none;- background: var(--pill); color: var(--fg-2);-}-.badge.ok { background: var(--green-soft); color: var(--green); }-.badge.err { background: var(--red-soft); color: var(--red); }-.badge.warn { background: var(--amber-soft); color: var(--amber); }-.badge.off { background: var(--pill); color: var(--muted); }-.badge.count { height: 18px; min-width: 18px; padding: 0 5px; justify-content: center; font-variant-numeric: tabular-nums; }-.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); display: inline-block; }-.dot.ok { background: var(--green); }-.dot.err { background: var(--red); }-.dot.warn { background: var(--amber); }--/* —— List card + rows (magpie .list / .row) —— */-.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }-.list + .list, .list-head + .list { margin-top: 8px; }-.list-head { display: flex; align-items: center; gap: 8px; margin: 18px 2px 6px; font-size: 11px; font-weight: 600; color: var(--muted); }-.list-head:first-child { margin-top: 0; }-.list-head .grow { flex: 1; }-.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 7px 12px 7px 14px; }-.row + .row, .row + .row-edit, .row-edit + .row { border-top: 1px solid var(--line-2); }-.row .who { min-width: 0; flex: 1 1 auto; }-.row .name { font-weight: 500; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.row .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }-.row .sub.wrap { white-space: normal; }-.row .ctl { display: flex; align-items: center; gap: 4px; flex: none; }-.row .val { font-family: var(--code); font-size: 11.5px; color: var(--fg-2); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; -webkit-user-select: text; }-.row.off > :not(.ctl) { opacity: .5; }-.row.compact { min-height: 40px; padding: 5px 9px 5px 11px; gap: 9px; }-.row.clickable:hover { background: var(--card-2); }-.row.flash { animation: row-flash 1.2s var(--ease); }-@keyframes row-flash { 0%, 35% { background: var(--sel); } }-.row-edit { padding: 12px 14px 14px; background: var(--card-2); display: grid; gap: 10px; }-.row-edit label { display: grid; gap: 5px; font-size: 11.5px; color: var(--fg-2); font-weight: 500; }-.row-edit .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }-.row-edit .hint, .hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }--/* —— Segmented control (magpie .seg; the thumb wears the brand) —— */-.seg {- position: relative; display: inline-flex; padding: 2px; border-radius: 8px;- background: var(--seg-track); flex: none;-}-.seg > .thumb {- position: absolute; top: 2px; left: 0; height: calc(100% - 4px); border-radius: 6px;- background: var(--accent-solid); box-shadow: var(--seg-edge), inset 0 0 0 1px var(--accent-line);- transition: transform .22s var(--ease), width .22s var(--ease);-}-.seg > .thumb.still { transition: none; }-.seg button {- position: relative; z-index: 1; white-space: nowrap; height: 22px; padding: 0 10px; border-radius: 6px;- font-size: 12px; color: var(--ctl-fg); transition: color .18s var(--ease);-}-.seg button.on { color: var(--on-accent); font-weight: 500; }-.seg button:hover:not(.on):not(:disabled) { color: var(--fg); }-.seg button:disabled { opacity: .45; }-.seg.disabled > .thumb { opacity: .5; }--/* —— Menu button (magpie .proto.pick) —— */-.pick {- display: inline-flex; align-items: center; gap: 4px; height: 24px; max-width: 260px;- padding: 0 6px 0 9px; border-radius: 7px; background: var(--pill); color: var(--fg);- font-size: 12px; transition: background .12s;-}-.pick:hover:not(:disabled) { background: var(--pill-hover); }-.pick:disabled { opacity: .45; }-.pick .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.pick .ic { width: 12px; height: 12px; color: var(--muted); transition: transform .18s var(--ease); }-.pick[aria-expanded="true"] .ic { transform: rotate(180deg); }--/* —— Popover (magpie .pop) —— */-.pop {- position: fixed; z-index: 40; width: 280px; max-height: 360px;- display: flex; flex-direction: column;- background: var(--pop-bg); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);- border-radius: 11px; box-shadow: var(--shadow); overflow: hidden;- transform-origin: var(--ox, 24px) top;- animation: pop-fade .18s ease-out, pop-in .42s cubic-bezier(.16, 1, .3, 1);-}-.pop.up { transform-origin: var(--ox, 24px) bottom; --pop-dy: 6px; }-@keyframes pop-fade { from { opacity: 0; } }-@keyframes pop-in { from { transform: translateY(var(--pop-dy, -6px)) scale(.94); } }-:is(.pop, .palette) .search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line-2); color: var(--faint); flex: none; }-:is(.pop, .palette) .search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; height: 38px; font-size: 13px; }-:is(.pop, .palette) .search input::placeholder { color: var(--faint); }-:is(.pop, .palette) ul { list-style: none; margin: 0; overflow-y: auto; padding: 5px; flex: 1 1 auto; }-:is(.pop, .palette) li {- display: flex; align-items: center; gap: 9px; min-height: 30px; padding: 0 8px; border-radius: 7px;- font-size: 12.5px; white-space: nowrap;-}-:is(.pop, .palette) li .v { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }-:is(.pop, .palette) li .n { flex: 1 1 0; min-width: 0; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }-:is(.pop, .palette) li.sel { background: var(--sel); }-:is(.pop, .palette) li.danger { color: var(--red); }-:is(.pop, .palette) li.disabled { opacity: .45; }-:is(.pop, .palette) li .check { color: var(--accent); margin-left: auto; display: none; }-:is(.pop, .palette) li.cur .check { display: inline-flex; }-:is(.pop, .palette) li.group { min-height: 22px; padding: 6px 8px 0; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; color: var(--faint); pointer-events: none; }-:is(.pop, .palette) li.sep { min-height: 0; height: 1px; margin: 4px 6px; padding: 0; background: var(--line-2); pointer-events: none; }-:is(.pop, .palette) li.explained { white-space: normal; padding: 6px 8px; align-items: flex-start; flex-direction: column; gap: 1px; }-:is(.pop, .palette) .empty { padding: 14px 12px; color: var(--muted); font-size: 12.5px; text-align: center; }-:is(.pop, .palette) .foot { flex: none; border-top: 1px solid var(--line-2); padding: 5px; display: flex; }-:is(.pop, .palette) .foot button { flex: 1; height: 30px; border-radius: 7px; font-size: 12px; color: var(--ctl-fg); }-:is(.pop, .palette) .foot button:hover:not(:disabled) { background: var(--pill); color: var(--fg); }-:is(.pop, .palette) .foot button:disabled { opacity: .45; }-.pop.model-picker { width: 340px; max-height: 420px; border: 1px solid var(--line); }-.pop.model-picker li:not(.group):not(.sep) { min-height: 34px; }--/* —— Sheet (modal dialog) —— */-.scrim {- position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .28);- display: grid; place-items: center; padding: 24px;- animation: pop-fade .16s ease-out;-}-.sheet {- width: min(440px, 100%); max-height: calc(100vh - 48px); overflow: auto;- background: var(--card); border-radius: 14px; box-shadow: var(--shadow);- padding: 18px 18px 16px; display: grid; gap: 12px;- animation: pop-in .36s cubic-bezier(.16, 1, .3, 1);-}-.sheet.wide { width: min(640px, 100%); }-.sheet h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }-.sheet .body { color: var(--fg-2); line-height: 1.55; }-.sheet .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }-.sheet pre.doc { white-space: pre-wrap; font: 11.5px/1.5 var(--code); color: var(--fg-2); margin: 0; max-height: 60vh; overflow: auto; }--/* —— Status pill ("已保存") —— */-.toasts { position: fixed; z-index: 60; left: 16px; bottom: 16px; display: grid; gap: 6px; justify-items: start; pointer-events: none; }-.toast {- pointer-events: auto; font-size: 12.5px; line-height: 16px; font-weight: 500; padding: 4px 11px; border-radius: 999px;- max-width: min(480px, calc(100vw - 32px));- box-shadow: 0 6px 20px rgba(0, 0, 0, .16);- animation: toast-in .2s var(--ease);-}-.toast.ok { background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line), 0 6px 20px rgba(0, 0, 0, .16); }-.toast.err { background: var(--red-soft); color: var(--red); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 30%, transparent), 0 6px 20px rgba(0, 0, 0, .16); display: flex; gap: 8px; align-items: center; }-.toast.warn { background: var(--amber-soft); color: var(--amber); }-.toast.leaving { animation: toast-out .2s var(--ease) forwards; }-@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }-@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }--/* —— Notice (inline, with an action) —— */-.notice {- display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-radius: 10px;- font-size: 12.5px; line-height: 1.5; background: var(--accent-soft); color: var(--fg);- box-shadow: inset 0 0 0 1px var(--accent-line);-}-.notice .notice-text { flex: 1; min-width: 0; }-.notice.amber { background: var(--amber-soft); color: var(--amber); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 25%, transparent); }-.notice.red { background: var(--red-soft); color: var(--red); box-shadow: inset 3px 0 0 var(--red), inset 0 0 0 1px color-mix(in srgb, var(--red) 22%, transparent); }-.notice .btn { height: 24px; font-size: 12px; padding: 0 10px; background: var(--card); }-.notice .btn:hover:not(:disabled) { background: var(--card-2); }--/* —— Spinner / skeleton —— */-.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }-@keyframes spin { to { transform: rotate(360deg); } }-.skel { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--pill) 0%, var(--pill-hover) 50%, var(--pill) 100%); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; }-@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }--.empty-state { padding: 32px 20px; text-align: center; color: var(--muted); }-.empty-state b { display: block; color: var(--fg); font-weight: 500; margin-bottom: 4px; }--@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }-@keyframes fade-in { from { opacity: 0; } }--@media (prefers-reduced-motion: reduce) {- *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }- .pop, .sheet, .toast, .view { animation: pop-fade .12s ease-out !important; }- .spinner { animation-duration: 1.6s; }-}diff --git a/ui/css/chat.css b/ui/css/chat.cssindex 8abf81e..9ffd2d2 100644--- a/ui/css/chat.css+++ b/ui/css/chat.css@@ -1,173 +1,245 @@-/* Chat: no header bar; a floating name pill, a 960 column, 560 bubbles, a floating composer. */-.chat { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--chat-bg); }-.drag-strip { position: absolute; z-index: 4; top: 0; left: 0; right: 0; height: 40px; -webkit-app-region: drag; pointer-events: none; }-:root.mac-app .drag-strip { pointer-events: auto; }+/* 对话页。布局与顶栏参考 Grok Bot,对话流与输入框参考 Codex:+ 顶栏 52(头像 + 名称 | 新对话 · 信息面板),760 阅读列;用户消息是浅灰气泡,机器人回复是整列正文;+ 底部是两行输入框(文字区 + 工具栏:更多 | 模型 · 发送)。+ 顶栏和输入框都是盖在对话流上的毛玻璃:消息从它们底下滚过,透出来是模糊的。 */+@layer app {+.chat { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }-.float-pill {- position: absolute; z-index: 6; top: 10px; left: 50%; transform: translateX(-50%);- display: inline-flex; align-items: center; gap: 8px; height: 39px; max-width: min(320px, calc(100% - 32px)); min-width: 120px;- padding: 0 16px 0 10px; border-radius: 20px;- background: var(--card); box-shadow: var(--float-edge);- font-size: 14px; font-weight: 500; color: var(--fg);- -webkit-app-region: no-drag; transition: background .12s;-}-.float-pill:hover, .float-pill[aria-pressed="true"] { background: var(--card-2); }-.float-pill:active { transform: translateX(-50%) scale(.98); }-.float-pill .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+/* —— 顶栏:对话页里浮在滚动内容上;内容滚到它底下时(.scrolled)才出现细线和投影 —— */+.chat-head {+ flex: none; display: flex; align-items: center; gap: var(--space-1); height: var(--head-h); padding: 0 var(--space-3) 0 var(--space-3-5);+ -webkit-app-region: drag;+}+.chat > .chat-head {+ position: absolute; z-index: var(--z-float); top: 0; left: 0; right: 0;+ background: var(--grain), var(--glass-chrome); backdrop-filter: var(--glass-filter);+ box-shadow: 0 .5px 0 transparent;+ transition: box-shadow var(--t-base);+}+.chat.scrolled > .chat-head { box-shadow: 0 .5px 0 var(--glass-edge), var(--shadow-xs); }+.chat-head > * { -webkit-app-region: no-drag; }+.chat-head .grow { -webkit-app-region: drag; align-self: stretch; }+.chat-head .icon-btn { --ib-size: 30px; }+.head-bot {+ display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; height: 32px; padding: 0 var(--space-2-5) 0 var(--space-1-5);+ border-radius: var(--r-md); font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--fg);+ transition: background var(--t-fast);+}+button.head-bot:hover { background: var(--pill); }+button.head-bot[aria-pressed="true"] { background: var(--pill-hover); }+button.head-bot:active { background: var(--pill-press); }+.head-bot .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; }+/* —— 对话流 —— */+.chat-scroll {+ flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; scroll-padding-top: var(--head-h);+ /* 输入框下面那一窄条:内容淡出,露出主区本身 */+ mask-image: linear-gradient(to top, transparent, var(--black) var(--space-4));+}.chat-col {width: min(var(--col-w), calc(100% - 48px)); margin: 0 auto;- padding: 64px 0 96px; display: flex; flex-direction: column;+ padding: calc(var(--head-h) + var(--space-6)) 0 150px; display: flex; flex-direction: column;}-.msg-row { display: flex; flex-direction: column; margin-top: 16px; }-.msg-row.cont { margin-top: 6px; }+.chat-skel { display: grid; gap: var(--space-3-5); margin-top: var(--space-6); }+.chat-skel .skel { height: 34px; border-radius: var(--r-3xl); }+.chat-skel .skel:nth-child(2) { justify-self: end; }+.chat-col > .notice { margin-top: var(--space-2); }++.msg-row { position: relative; display: flex; flex-direction: column; margin-top: var(--space-4); }+.msg-row.cont { margin-top: var(--space-1); }.msg-row.user { align-items: flex-end; }-.msg-row.assistant { align-items: flex-start; }-.msg {- max-width: min(var(--bubble-w), 85%); padding: 7px 12px 8px; border-radius: 20px;- font-size: 15px; line-height: 22.5px; word-break: break-word; overflow-wrap: anywhere;- cursor: text;-}+.msg-row.assistant { align-items: stretch; }+.msg { font-size: var(--fs-xl); word-break: break-word; overflow-wrap: anywhere; cursor: text; }.msg-row.user .msg {- background: linear-gradient(180deg, var(--bubble-top), var(--bubble-bottom)); color: var(--on-accent);- box-shadow: inset 0 0 0 1px var(--accent-line);- white-space: pre-wrap;+ max-width: min(var(--bubble-w), 80%); padding: 9px var(--space-4); border-radius: var(--r-3xl);+ background: var(--bubble-user); color: var(--fg); line-height: 1.55; white-space: pre-wrap;}-.msg-row.user .msg a { color: var(--on-accent); text-decoration: underline; font-weight: 600; }-.msg-row.assistant .msg { background: var(--bubble-ai); color: var(--fg); }+.msg-row.assistant .msg { color: var(--fg); line-height: 1.7; }.msg-row.pending .msg { opacity: .85; }-.caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; border-radius: 1px; background: var(--accent); animation: blink 1s steps(2) infinite; }-@keyframes blink { 50% { opacity: 0; } }-.typing { display: inline-flex; gap: 4px; padding: 8px 2px; }-.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: breathe 1.2s ease-in-out infinite; }-.typing i:nth-child(2) { animation-delay: .15s; }-.typing i:nth-child(3) { animation-delay: .3s; }-.msg-row.enter { animation: msg-in .18s var(--ease); }-@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }+.msg-row.enter { --rise: 6px; animation: rise-in var(--dur-base) var(--ease-out); }++/* 回复上方的工作状态:进行中带微光,结束后变成一条细线上的"用时" */+.work-line {+ display: flex; align-items: center; gap: var(--space-1-5); padding-bottom: var(--space-2); margin-bottom: var(--space-3);+ font-size: var(--fs-md); color: var(--muted); border-bottom: 1px solid var(--line-2);+}+.work-line.live { border-bottom-color: transparent; }+.msg-row.assistant .work-line:last-child { margin-bottom: 0; }+.shimmer {+ color: transparent;+ background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, var(--faint) 50%, var(--muted) 60%, var(--muted) 100%) 0 0 / 300% 100%;+ -webkit-background-clip: text; background-clip: text;+ animation: shimmer var(--dur-shimmer) linear infinite;+}++/* 消息下方的操作:悬停出现;最后一条回复常显 */+.msg-actions {+ display: flex; align-items: center; gap: var(--space-1); height: 24px; margin-top: var(--space-0-5);+ color: var(--muted); opacity: 0; transition: opacity var(--t-fast);+}+.msg-row.user .msg-actions { flex-direction: row-reverse; }+.msg-row:hover .msg-actions, .msg-row.last .msg-actions, .msg-actions:focus-within { opacity: 1; }+.msg-actions .when { font-size: var(--fs-xs); }+.msg-actions .icon-btn { --ib-size: 24px; }++.caret { display: inline-block; width: 7px; height: 15px; margin-left: var(--space-0-5); vertical-align: -2px; border-radius: 1px; background: var(--accent); animation: blink var(--dur-blink) steps(2) infinite; }+.typing { display: inline-flex; gap: var(--space-1); padding: var(--space-2) var(--space-0-5); }+.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: breathe var(--dur-shimmer) var(--ease-in-out) infinite; }+.typing i:nth-child(2) { animation-delay: var(--stagger); }+.typing i:nth-child(3) { animation-delay: calc(var(--stagger) * 2); }-.time-sep { align-self: center; margin: 20px 0 2px; font-size: 11.5px; color: var(--muted); }+.time-sep { align-self: center; margin: var(--space-8) 0 0; font-size: var(--fs-xs); color: var(--muted); }+.time-sep + .msg-row { margin-top: var(--space-4); }-/* markdown inside the assistant bubble */+/* markdown:回复是正文,标题和段落有呼吸感 */.md > :first-child { margin-top: 0; }.md > :last-child { margin-bottom: 0; }-.md p, .md ul, .md ol, .md blockquote, .md pre, .md table, .md h1, .md h2, .md h3, .md h4, .md hr { margin: 0 0 8px; }-.md h1, .md h2, .md h3, .md h4 { font-size: 15px; font-weight: 600; line-height: 22px; }-.md h1 { font-size: 17px; }+.md p, .md ul, .md ol, .md blockquote, .md pre, .md table, .md hr { margin: 0 0 var(--space-3); }+.md h1, .md h2, .md h3, .md h4 { margin: var(--space-5) 0 var(--space-2); font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: 1.5; }+.md h1 { font-size: var(--fs-2xl); }.md ul, .md ol { padding-left: 22px; }-.md li + li { margin-top: 2px; }-.md blockquote { padding-left: 10px; border-left: 3px solid var(--line); color: var(--fg-2); }+.md li + li { margin-top: var(--space-1); }+.md blockquote { padding-left: var(--space-3); border-left: 3px solid var(--line); color: var(--fg-2); }.md hr { border: 0; border-top: 1px solid var(--line); }-.md code { font-size: 12.5px; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--fg) 7%, transparent); }+.md code { font-size: var(--fs-sm); padding: 1px 5px; border-radius: var(--r-xs); background: var(--code-bg); }.md a { text-decoration: underline; text-underline-offset: 2px; }-.md .table-wrap { overflow-x: auto; margin: 0 0 8px; }-.md table { border-collapse: collapse; font-size: 13.5px; line-height: 1.45; margin: 0; }-.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }-.md th { font-weight: 600; background: color-mix(in srgb, var(--card) 60%, transparent); }-.codeblock { margin: 0 0 8px; border-radius: 10px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }-.codeblock .bar { display: flex; align-items: center; height: 28px; padding: 0 4px 0 10px; font: 11px var(--code); color: var(--muted); border-bottom: 1px solid var(--line-2); }+.md .table-wrap { overflow-x: auto; margin: 0 0 var(--space-3); }+.md table { border-collapse: collapse; font-size: var(--fs-md); line-height: 1.45; margin: 0; }+.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }+.md th { font-weight: var(--fw-semibold); background: var(--card-2); }+.codeblock { margin: 0 0 var(--space-3); border-radius: var(--r-xl); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); overflow: hidden; }+.codeblock .bar {+ display: flex; align-items: center; height: 30px; padding: 0 var(--space-1) 0 var(--space-3);+ font-family: var(--code); font-size: var(--fs-2xs); color: var(--muted);+}.codeblock .bar .lang { flex: 1; }-.codeblock pre { margin: 0; padding: 9px 12px; overflow-x: auto; font: 12.5px/1.55 var(--code); color: var(--fg); white-space: pre; }+.codeblock pre { margin: 0; padding: 0 var(--space-3-5) var(--space-3); overflow-x: auto; font: var(--fs-sm)/var(--lh-relaxed) var(--code); color: var(--fg); white-space: pre; }.codeblock pre code { font-size: inherit; padding: 0; background: none; }-/* cards in the stream: ask_user / approval / file / error */+/* 流里的卡片:提问 / 审批 / 文件 */.card {- width: min(var(--bubble-w), 100%); background: var(--card); border-radius: 22px;- box-shadow: inset 0 0 0 1px #f2f2f2; padding: 18px 20px; display: grid; gap: 10px;+ width: min(var(--bubble-w), 100%); background: var(--card); border-radius: var(--r-2xl);+ box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs); padding: var(--space-4) 18px; display: grid; gap: var(--space-2-5);}-:root[data-theme="dark"] .card { box-shadow: inset 0 0 0 1px var(--line); }-.card .q { font-size: 14.5px; font-weight: 600; color: var(--fg); line-height: 1.45; }-.card .q-detail { font-size: 13px; color: var(--fg-2); line-height: 1.5; white-space: pre-wrap; }-.card .opts { display: grid; gap: 2px; margin: 0 -8px; }+.card .q { font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--fg); line-height: 1.45; }+.card .q-detail { font-size: var(--fs-md); color: var(--fg-2); line-height: var(--lh-normal); white-space: pre-wrap; }+.card .q-block { display: grid; gap: var(--space-2); }+.card .opts { display: grid; gap: var(--space-0-5); margin: 0 calc(-1 * var(--space-2)); }.card .opt {- display: flex; align-items: center; gap: 10px; min-height: 41px; padding: 4px 8px; border-radius: 12px;- text-align: left; font-size: 15px; color: var(--fg); transition: background .12s;+ --focus-offset: 0px;+ display: flex; align-items: center; gap: var(--space-2-5); min-height: 41px; padding: var(--space-1) var(--space-2); border-radius: var(--r-lg);+ text-align: left; font-size: var(--fs-xl); color: var(--fg); transition: background var(--t-fast);}-.card .opt:hover:not(:disabled) { background: var(--side-bg); }+.card .opt:hover:not(:disabled) { background: var(--pill); }+.card .opt:active:not(:disabled) { background: var(--pill-hover); }.card .opt .letter {- width: 22px; height: 22px; border-radius: 7px; flex: none; display: grid; place-items: center;- background: #f2f2f2; color: var(--muted); font-size: 12px; font-weight: 600;+ width: 22px; height: 22px; border-radius: var(--r-sm); flex: none; display: grid; place-items: center;+ background: var(--pill); color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-semibold);+ transition: background var(--t-fast), color var(--t-fast);}-:root[data-theme="dark"] .card .opt .letter { background: var(--pill); }-.card .opt .desc { display: block; font-size: 12px; color: var(--muted); }-.card .opt.picked .letter { background: var(--accent-solid); color: var(--on-accent); }-.card.done .q { color: #808080; }+.card .opt:hover:not(:disabled) .letter { background: var(--pill-hover); color: var(--fg-2); }+.card .opt .desc { display: block; font-size: var(--fs-sm); color: var(--muted); }+.card .opt.picked .letter, .card .opt.picked:hover .letter { background: var(--fg); color: var(--surface-solid); }+.card.done .q { color: var(--muted); }.card.done .opt { color: var(--placeholder); }-.card .meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }-.card .actions { display: flex; gap: 8px; flex-wrap: wrap; }-.card .cmd { font: 12px/1.5 var(--code); background: var(--card-2); border-radius: 8px; padding: 7px 9px; white-space: pre-wrap; word-break: break-all; color: var(--fg-2); max-height: 160px; overflow: auto; }-.card .answer { display: flex; gap: 6px; }+.card .meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--muted); }+.card .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }+.card .cmd {+ font: var(--fs-sm)/var(--lh-normal) var(--code); background: var(--card-2); border-radius: var(--r-md); padding: 7px 9px;+ white-space: pre-wrap; word-break: break-all; color: var(--fg-2); max-height: 160px; overflow: auto;+}+.card .answer { display: flex; gap: var(--space-1-5); }.file-card {- display: flex; align-items: center; gap: 12px; width: min(353px, 100%); height: 71px; padding: 0 16px;- background: var(--card); border-radius: 20px; box-shadow: inset 0 0 0 1px #e0e0e0, 0 1px 3px rgba(0, 0, 0, .04);+ display: flex; align-items: center; gap: var(--space-3); width: min(360px, 100%); padding: var(--space-2-5) var(--space-3-5) var(--space-2-5) var(--space-2-5);+ background: var(--card); border-radius: var(--r-xl); box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs);}-:root[data-theme="dark"] .file-card { box-shadow: inset 0 0 0 1px var(--line); }-.file-card .ic { width: 32px; height: 32px; color: var(--muted); }-.file-card .fname { font-size: 14.5px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.file-card .fsub { font-size: 12px; color: var(--muted); }+.file-card > .ic { width: 40px; height: 40px; padding: var(--space-2); border-radius: var(--r-lg); background: var(--pill); color: var(--fg-2); }+.file-card .fname { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.file-card .fsub { font-size: var(--fs-sm); color: var(--muted); }.msg-row .notice { max-width: min(var(--bubble-w), 100%); }-.chat-empty { margin: auto; padding-top: 18vh; display: grid; justify-items: center; gap: 10px; text-align: center; color: var(--muted); }-.chat-empty h2 { font-size: 17px; font-weight: 600; color: var(--fg); }-.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }-.chip { height: 30px; padding: 0 12px; border-radius: 15px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; color: var(--fg-2); }-.chip:hover { background: var(--card-2); color: var(--fg); }+.chat-empty { margin: auto; padding-top: 16vh; display: grid; justify-items: center; gap: var(--space-2-5); text-align: center; color: var(--muted); }+.chat-empty h2 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); color: var(--fg); }+.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-1-5); }+.chip {+ height: 32px; padding: 0 var(--space-3-5); border-radius: var(--r-full); background: var(--card);+ box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs);+ font-size: var(--fs-sm); color: var(--fg-2); transition: color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);+}+.chip:hover { color: var(--fg); box-shadow: inset 0 0 0 .5px var(--line-strong), var(--shadow-sm); }+.chip:active { transform: scale(var(--press)); box-shadow: inset 0 0 0 .5px var(--line-strong), var(--shadow-xs); }-/* —— floating "back to bottom" —— */+/* —— 回到底部:玻璃小圆钮 —— */.to-bottom {- position: absolute; z-index: 5; left: 50%; bottom: 67px; transform: translateX(-50%);- width: 33px; height: 33px; border-radius: 50%; display: grid; place-items: center;- background: var(--card); color: var(--fg); box-shadow: var(--float-edge);- animation: fade-in .18s ease-out;+ position: absolute; z-index: var(--z-float); left: 50%; bottom: 128px; translate: -50% 0;+ width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;+ background: var(--grain), var(--glass-float); backdrop-filter: var(--glass-filter-sm); color: var(--fg-2); box-shadow: var(--shadow-float);+ --rise: 6px; animation: rise-in var(--dur-base) var(--ease-out);+ transition: color var(--t-fast), box-shadow var(--t-fast), scale var(--t-fast);}-.to-bottom:hover { background: var(--card-2); }-.to-bottom .new { position: absolute; top: 1px; right: 1px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card); }+.to-bottom:hover { color: var(--fg); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 .5px var(--line-strong), var(--shadow-md); }+.to-bottom:active { scale: var(--press-strong); }+.to-bottom .new { position: absolute; top: 0; right: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-solid); box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 2.5px var(--accent-line); }-/* —— composer: a 44px floating capsule —— */-.composer-dock { position: absolute; z-index: 5; left: 0; right: 0; bottom: 15px; pointer-events: none; }+/* —— 输入框:文字区 + 工具栏两行,一块浮在对话流上的玻璃。+ 状态:悬停描边加深;输入时描边更实、投影更大;拖入文件时 accent 描边 + 光晕 + 一层黄绿 —— */+.composer-dock {+ position: absolute; z-index: var(--z-float); left: 0; right: 0; bottom: 0; padding: var(--space-6) 0 var(--space-4); pointer-events: none;+}.composer {+ --composer-edge: var(--glass-edge);+ --composer-edge-w: .5px;+ --composer-shadow: var(--shadow-md);+ --composer-tint: transparent;pointer-events: auto; position: relative;width: min(var(--col-w), calc(100% - 48px)); margin: 0 auto;- display: flex; align-items: flex-end; gap: 6px; min-height: 44px; padding: 8px 8px 8px 10px;- background: var(--composer-bg); border-radius: 22px;- box-shadow: 0 1px 4px rgba(0, 0, 0, .10), 0 0 0 1px #e6e6e6;- transition: box-shadow .12s;-}-:root[data-theme="dark"] .composer { box-shadow: 0 1px 4px rgba(0, 0, 0, .4), 0 0 0 1px var(--line); }-.composer:focus-within { box-shadow: 0 1px 4px rgba(0, 0, 0, .10), 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }-.composer.drag { box-shadow: 0 0 0 2px var(--accent); }+ display: flex; flex-direction: column;+ background: var(--grain), linear-gradient(var(--composer-tint), var(--composer-tint)), var(--glass-float);+ backdrop-filter: var(--glass-filter); border-radius: var(--r-3xl);+ box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 var(--composer-edge-w) var(--composer-edge), var(--composer-shadow);+ transition: box-shadow var(--t-base);+}+.composer:hover { --composer-edge: var(--line-strong); }+.composer:focus-within { --composer-edge: var(--line-strong); --composer-edge-w: 1px; --composer-shadow: var(--shadow-lg); }+.composer.drag { --composer-edge: var(--accent); --composer-edge-w: 1.5px; --composer-shadow: var(--ring), var(--shadow-md); --composer-tint: var(--accent-wash); }.composer textarea {- flex: 1; min-width: 0; border: 0; outline: none; background: transparent; resize: none;- font-size: 15px; line-height: 22px; padding: 3px 4px 1px; max-height: calc(22px * 8 + 4px); overflow-y: auto; color: var(--fg);+ display: block; width: 100%; min-width: 0; border: 0; outline: none; background: transparent; resize: none;+ font-size: var(--fs-xl); line-height: 22px; padding: var(--space-3-5) var(--space-4) var(--space-1); max-height: calc(22px * 8 + 18px); overflow-y: auto; color: var(--fg);}.composer textarea::placeholder { color: var(--placeholder); }.composer textarea:focus-visible { outline: none; }-.composer .plus {- width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;- background: #f2f2f2; color: #7a7a7a; transition: background .12s;-}-:root[data-theme="dark"] .composer .plus { background: var(--pill); color: var(--ctl-fg); }-.composer .plus:hover, .composer .plus[aria-expanded="true"] { background: var(--pill-hover); color: var(--fg); }-.composer .model-chip {- flex: none; height: 28px; max-width: 220px; padding: 0 6px 0 9px; border-radius: 14px;- display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted);- transition: background .12s, color .12s;-}-.composer .model-chip:hover, .composer .model-chip[aria-expanded="true"] { background: var(--pill); color: var(--fg); }+.composer-bar { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-1-5) var(--space-2) var(--space-2) var(--space-2-5); }+.composer-bar .grow { flex: 1; }+.composer :is(.plus, .model-chip) {+ flex: none; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--ctl-fg);+ transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);+}+.composer :is(.plus, .model-chip):hover { background: var(--pill); color: var(--fg); }+.composer :is(.plus, .model-chip)[aria-expanded="true"] { background: var(--pill-hover); color: var(--fg); }+.composer :is(.plus, .model-chip):active { background: var(--pill-press); transform: scale(var(--press)); }+.composer .plus { width: 30px; border-radius: 50%; }+.composer .plus .ic { transition: transform var(--t-moderate); }+.composer .plus[aria-expanded="true"] .ic { transform: rotate(45deg); }+.composer .model-chip { max-width: 240px; padding: 0 var(--space-2) 0 var(--space-2-5); border-radius: var(--r-full); gap: var(--space-1); font-size: var(--fs-sm); }.composer .model-chip .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.composer .model-chip .ic { width: 12px; height: 12px; }+.composer .model-chip .ic { width: 12px; height: 12px; transition: transform var(--t-base); }+.composer .model-chip[aria-expanded="true"] .ic:last-child { transform: rotate(180deg); }+.composer .model-chip .ic.lead { width: 14px; height: 14px; }+.composer .model-chip.perm { max-width: 160px; }+/* 发送:空的时候是中性的灰钮(不用半透明的墨色或黄绿,会发浑);能发了才亮起品牌色,悬停时箭头往上提一点 */.send {- width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;- background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line);- transition: background .12s, opacity .12s, transform .12s var(--ease);-}-.send:hover:not(:disabled) { background: var(--accent-hover); }-.send:active:not(:disabled) { background: var(--accent-press); transform: scale(.94); }-.send:disabled { opacity: .4; }-.send.stop { background: var(--fg); color: var(--chat-bg); box-shadow: none; }-.send.stop:hover { background: var(--fg-2); }-.composer-disabled { pointer-events: auto; width: min(var(--col-w), calc(100% - 48px)); margin: 0 auto 8px; }+ width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;+ background: var(--send-bg); color: var(--send-fg); box-shadow: var(--primary-edge);+ transition: background var(--t-base), color var(--t-base), box-shadow var(--t-base), transform var(--t-fast);+}+.send .ic { transition: transform var(--t-base); }+.send:hover:not(:disabled) { background: var(--primary-hover); }+.send:hover:not(:disabled):not(.stop) .ic { transform: translateY(-1px); }+.send:active:not(:disabled) { background: var(--primary-press); transform: scale(var(--press-strong)); }+.send:disabled { background: var(--pill); color: var(--faint); box-shadow: none; }+.composer-disabled { pointer-events: auto; width: min(var(--col-w), calc(100% - 48px)); margin: 0 auto var(--space-2); }@media (max-width: 1000px) {.chat-col, .composer, .composer-disabled { width: calc(100% - 32px); }}+}diff --git a/ui/css/settings.css b/ui/css/settings.cssindex e3f75a9..7551544 100644--- a/ui/css/settings.css+++ b/ui/css/settings.css@@ -1,63 +1,118 @@-/* Settings (magpie's settings page: tabs + find, white .list cards, a control per row, saved on change). */-.settings { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg); }+/* 设置页与机器人设置(参考 Codex):白底,大标题,分组标题是正文色的小标题,白色圆角 .list 一行一项,开关用 Switch。+ 设置分页在侧栏(shell.css 的 .side-nav)。 */+@layer app {+.settings { flex: 1; min-height: 0; overflow-y: auto; }.set-head {- position: sticky; top: 0; z-index: 5;- display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 6px;- padding: 14px max(20px, calc((100% - 720px) / 2)) 10px;- background: color-mix(in srgb, var(--bg) 92%, transparent);- -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);+ display: flex; align-items: center; gap: var(--space-3);+ padding: var(--space-12) max(24px, calc((100% - var(--page-w)) / 2)) var(--space-2);-webkit-app-region: drag;}.set-head > * { -webkit-app-region: no-drag; }-.set-head.stuck { box-shadow: 0 1px 0 var(--line-2); }-:root.mac-app .set-head { padding-top: 16px; }-.set-title { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }-.set-title .grow { flex: 1; }-.warm-tabs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; row-gap: 2px; min-width: 0; flex: 1; margin-left: -7px; }-.warm-tabs button { height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); transition: color .12s, background-color .12s; white-space: nowrap; }-.warm-tabs button:hover:not(.on) { color: var(--fg-2); }-.warm-tabs button.on { color: var(--fg); background: var(--pill); }-.set-find { flex: 0 1 180px; min-width: 120px; height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); font-size: 12px; outline: none; }-.set-find:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }-.set-find::placeholder { color: var(--placeholder); }-.set-body { padding: 6px max(20px, calc((100% - 720px) / 2)) 40px; }-.set-part { margin: 14px 2px 6px; font-size: 11px; font-weight: 600; color: var(--muted); }-.set-part:first-child { margin-top: 4px; }-.set-none { margin: 18px 2px; font-size: 13px; color: var(--muted); text-align: center; }-.settings .row .sub { max-width: 440px; }-.mf-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); }+.set-title { font-size: var(--fs-4xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tighter); line-height: var(--lh-tight); }+.set-titles { min-width: 0; display: grid; gap: var(--space-0-5); }+.set-titles .set-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.set-sub { font-size: var(--fs-md); color: var(--muted); }+.set-back { --ib-size: 32px; --ib-r: var(--r-full); --ib-fg: var(--ctl-fg); margin-left: calc(-1 * var(--space-1-5)); }+.set-body { padding: var(--space-2) max(24px, calc((100% - var(--page-w)) / 2)) var(--space-16); }-/* bot settings page */-.bot-head { display: flex; align-items: center; gap: 10px; width: 100%; }-.bot-head .grow { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.inline-input { width: 220px; height: 26px; padding: 0 8px; border-radius: 7px; border: 1px solid transparent; background: var(--pill); outline: none; font-size: 12.5px; text-align: right; }-.inline-input:hover { background: var(--pill-hover); }-.inline-input:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); text-align: left; }-.prompt-edit { padding: 0 14px 12px; }-.prompt-edit textarea { min-height: 88px; font-size: 13px; }+/* 分组标题与卡片 */+.settings .list-head { margin: var(--space-8) var(--space-0-5) var(--space-2-5); font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--fg); }+.settings .list-head:first-child { margin-top: var(--space-6); }+.settings .list { border-radius: var(--r-2xl); }+.settings .list + .list { margin-top: var(--space-3); }+.settings .row { --row-h: 60px; --row-py: var(--space-3); --row-pl: var(--space-4); --row-pr: var(--space-4); --row-gap: var(--space-4); }+.settings .row .name { font-size: var(--fs-lg); }+.settings .row .sub { font-size: var(--fs-sm); line-height: var(--lh-snug); margin-top: var(--space-0-5); max-width: 460px; white-space: normal; }+.settings .row .ctl { gap: var(--space-1-5); }+.settings .pick { height: var(--ctl-md); padding: 0 var(--space-2) 0 var(--space-3); border-radius: var(--r-lg); }+.settings .seg { --seg-r: var(--r-lg); }+.settings .seg button { height: var(--ctl-sm); }+.set-part { margin: var(--space-8) var(--space-0-5) var(--space-2-5); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }+.set-part:first-child { margin-top: var(--space-6); }+.set-body > .list:first-child { margin-top: var(--space-6); }+.set-none { margin: var(--space-8) var(--space-0-5); font-size: var(--fs-md); color: var(--muted); }+.mf-state { display: inline-flex; align-items: center; gap: var(--space-1-5); font-size: var(--fs-sm); color: var(--fg-2); }++/* 机器人设置:身份是带标签的输入框(参考 Codex 的编辑页) */+.set-field { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }+.set-field .k { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--fg-2); }+.set-field .k .hint { font-weight: var(--fw-regular); }+.set-field .field { --field-h: var(--ctl-xl); --field-px: var(--space-3-5); --field-r: var(--r-xl); font-size: var(--fs-lg); }+.set-field textarea.field { min-height: 120px; padding: var(--space-3) var(--field-px); line-height: var(--lh-relaxed); }++/* 新建机器人(参考 Grok Bot 的创建页):居中的表单,下面是模板卡片 */+.new-bot { flex: 1; min-height: 0; display: flex; flex-direction: column; }+.new-bot .head-bot.static:hover { background: none; }+.new-body { flex: 1; min-height: 0; overflow-y: auto; display: grid; justify-items: center; align-content: start; gap: var(--space-12); padding: var(--space-12) var(--space-6) var(--space-16); }+.new-form { width: min(460px, 100%); display: grid; justify-items: center; }+.new-title { margin-top: var(--space-4); font-size: var(--fs-4xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tighter); line-height: var(--lh-tight); text-align: center; }+.new-lead { margin: var(--space-2) 0 var(--space-6); font-size: var(--fs-md); color: var(--muted); line-height: var(--lh-relaxed); text-align: center; }+.new-form .set-field { width: 100%; }+.new-form .btn { min-width: 140px; }+.new-sugg { width: min(720px, 100%); }+.new-sugg .list-head { margin: 0 var(--space-0-5) var(--space-3); font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--fg); }+.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: var(--space-3); }+/* 模板卡:悬停浮起 1px(描边加深、投影变大),按下压回去,选中是 accent 描边 + 一层黄绿,图标亮成黄绿片 */+.tpl {+ display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-3); row-gap: var(--space-0-5); align-content: start;+ padding: var(--space-3-5) var(--space-4); border-radius: var(--r-2xl); text-align: left;+ background: var(--card); box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs);+ transition: background var(--t-fast), box-shadow var(--t-base), transform var(--t-base);+}+.tpl:hover { box-shadow: inset 0 0 0 .5px var(--line-strong), var(--shadow-sm); transform: translateY(-1px); }+.tpl:active { box-shadow: inset 0 0 0 .5px var(--line-strong), var(--shadow-xs); transform: scale(var(--press)); transition-duration: var(--dur-fast); }+.tpl.on { background: linear-gradient(var(--accent-wash), var(--accent-wash)), var(--card); box-shadow: inset 0 0 0 1.5px var(--accent), var(--shadow-xs); }+.tpl-ic {+ grid-row: span 2; width: 36px; height: 36px; border-radius: var(--r-lg); display: grid; place-items: center; background: var(--pill); color: var(--fg-2);+ transition: background var(--t-base), color var(--t-base), box-shadow var(--t-base);+}+.tpl:hover .tpl-ic { background: var(--pill-hover); color: var(--fg); }+.tpl.on .tpl-ic { background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 .5px var(--accent-line); }+.tpl-name { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }+.tpl-desc { font-size: var(--fs-sm); color: var(--muted); line-height: var(--lh-snug); }/* onboarding */-.onboard { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg); display: grid; justify-items: center; align-content: center; padding: 48px 16px; -webkit-app-region: drag; }+.onboard {+ flex: 1; min-height: 0; height: 100vh; overflow-y: auto;+ display: grid; justify-items: center; align-content: center; padding: var(--space-12) var(--space-4);+ -webkit-app-region: drag;+}.onboard > * { -webkit-app-region: no-drag; }-.onboard-col { width: min(400px, 100%); display: grid; gap: 14px; animation: view-in .24s var(--ease); }-.onboard-hero { display: grid; justify-items: center; gap: 10px; text-align: center; margin-bottom: 6px; }-.onboard-hero h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }-.onboard-hero p { font-size: 13px; color: var(--muted); line-height: 1.55; }-.onboard .list { padding: 16px; display: grid; gap: 10px; }-.onboard label.k { font-size: 12px; font-weight: 600; color: var(--fg-2); }-.onboard .err-text { font-size: 12px; color: var(--red); line-height: 1.5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }-.onboard .slow { font-size: 12px; color: var(--muted); }-.onboard .links { display: grid; gap: 8px; justify-items: center; font-size: 12.5px; color: var(--muted); }+.onboard-col { width: min(400px, 100%); display: grid; gap: var(--space-3-5); --rise: 4px; animation: rise-in var(--dur-moderate) var(--ease-out); }+.onboard-hero { display: grid; justify-items: center; gap: var(--space-2-5); text-align: center; margin-bottom: var(--space-1-5); }+.onboard-hero h1 { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tighter); }+.onboard-hero p { font-size: var(--fs-md); color: var(--muted); line-height: var(--lh-relaxed); }+.onboard .list {+ padding: var(--space-4); display: grid; gap: var(--space-2-5); border: 0; border-radius: var(--r-3xl);+ background: var(--grain), var(--glass-sheet); box-shadow: var(--shadow-pop);+}+.onboard label.k { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--fg-2); }+.onboard .err-text { font-size: var(--fs-sm); color: var(--red); line-height: var(--lh-normal); display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }+.onboard .slow { font-size: var(--fs-sm); color: var(--muted); }+.onboard .links { display: grid; gap: var(--space-2); justify-items: center; font-size: var(--fs-sm); color: var(--muted); }.onboard details { width: 100%; }-.onboard details summary { list-style: none; cursor: default; display: flex; justify-content: center; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }+.onboard details summary { list-style: none; cursor: default; display: flex; justify-content: center; align-items: center; gap: var(--space-1); font-size: var(--fs-sm); color: var(--muted); }.onboard details summary::-webkit-details-marker { display: none; }+.onboard details summary .ic { transition: transform var(--t-base); }.onboard details[open] summary .ic { transform: rotate(180deg); }-.onboard details .row { margin-top: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }-.onboard .connected { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }-.picklist { max-height: 300px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }-.picklist .group { padding: 8px 4px 3px; font-size: 10.5px; font-weight: 600; color: var(--faint); letter-spacing: .04em; }-.picklist button { display: flex; align-items: center; width: 100%; height: 32px; padding: 0 8px; border-radius: 7px; font-size: 12.5px; text-align: left; gap: 8px; }-.picklist button:hover { background: var(--pill); }-.picklist button.cur { background: var(--sel); }+.onboard details summary { transition: color var(--t-fast); }+.onboard details summary:hover { color: var(--fg); }+.onboard details .row { margin-top: var(--space-2); background: var(--grain), var(--glass-sheet); box-shadow: var(--glass-ring); border-radius: var(--r-xl); }+.onboard .connected { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }+.picklist { max-height: 300px; overflow-y: auto; margin: 0 calc(-1 * var(--space-1-5)); padding: 0 var(--space-1-5); }+.picklist > .hint { padding: var(--space-2); }+.picklist .group { padding: var(--space-2) var(--space-1) 3px; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); color: var(--faint); letter-spacing: var(--tracking-caps); }+.picklist button {+ --focus-offset: -2px;+ display: flex; align-items: center; width: 100%; height: var(--ctl-lg); padding: 0 var(--space-2); border-radius: var(--r-md);+ font-size: var(--fs-sm); text-align: left; gap: var(--space-2); transition: background var(--t-fast);+}+.picklist button:hover { background: var(--sel); }+.picklist button:active { background: var(--sel-press); }+.picklist button.cur { background: var(--sel); font-weight: var(--fw-medium); }.picklist button .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }.picklist button .check { color: var(--accent); }++/* 头像角色(components/avatar.js 的 AvatarPicker):新建页在介绍语下面一排,机器人设置里是"身份"的第一项 */+.new-form .avatar-picker { justify-content: center; margin: calc(var(--space-2) * -1) 0 var(--space-6); }+}diff --git a/ui/css/shell.css b/ui/css/shell.cssindex a5c6549..937e955 100644--- a/ui/css/shell.css+++ b/ui/css/shell.css@@ -1,125 +1,198 @@-/* Shell: sidebar 280 | main 1fr | info panel 320 (on demand). No top bar. */+/* Shell:sidebar 280 | main 1fr | info panel 320(按需)。没有顶栏。+ 窗口最底层是环境光(--bg + 左上的品牌黄绿光 + 跟着当前机器人变的色相光),+ 侧栏是直接盖在环境光上的毛玻璃;主区和信息面板是浮在上面的圆角面板(--pane-gap 间隙)。 */+@property --aura-hue { syntax: "<number>"; inherits: true; initial-value: 250; }+@layer app {#app { height: 100%; }++/* —— 环境光:.app、引导页、设计库样例(.aura-bg)共用。--aura-hue 由 main.js 按当前机器人设置,换机器人时慢慢过渡 —— */+.app, .onboard, .aura-bg {+ --aura: oklch(var(--aura-l) var(--aura-c) var(--aura-hue) / var(--aura-a));+ --aura-2: oklch(var(--aura-l) calc(var(--aura-c) * .7) calc(var(--aura-hue) + 70) / calc(var(--aura-a) * .55));+ background:+ radial-gradient(70% 50% at 0% 0%, var(--aura-brand), transparent 72%),+ radial-gradient(60% 75% at 0% 100%, var(--aura), transparent 72%),+ radial-gradient(55% 60% at 100% 0%, var(--aura-2), transparent 70%),+ var(--bg);+ transition: --aura-hue var(--dur-ambient) var(--ease-in-out);+}.app {display: grid; height: 100vh;grid-template-columns: var(--side-w) minmax(0, 1fr);- background: var(--chat-bg);}/* "已保存" sits in the window's bottom-left corner, over the sidebar above the account button,so it never covers the floating composer */.app .toasts { bottom: 68px; }.app.with-panel { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--panel-w); }-.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }-.view { animation: view-in .24s var(--ease); }+/* 主区:浮在环境光上的面板。不要给它加 backdrop-filter / transform——里面的菜单是 position: fixed */+.main {+ position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column;+ margin: var(--pane-gap) var(--pane-gap) var(--pane-gap) 0;+ border-radius: var(--r-2xl); background: var(--surface); box-shadow: var(--shadow-pane); overflow: hidden;+}+.view { --rise: 4px; animation: rise-in var(--dur-moderate) var(--ease-out); }-/* —— Sidebar —— */+/* —— Sidebar(参考 Grok Bot):新建按钮 | 常驻搜索 | 机器人行 | 账户。+ 行的状态:悬停是更亮的一层玻璃,按下稍暗,选中是浮起的玻璃片(--side-active + --shadow-tile) —— */.side {+ --ib-bg-hover: var(--side-hover);+ --ib-bg-press: var(--side-press);+ --ib-bg-on: var(--side-active);min-height: 0; display: flex; flex-direction: column;- background: var(--side-bg); border-right: 1px solid var(--side-active);+ background: var(--grain), var(--glass-side);}.side-top {- display: flex; align-items: center; justify-content: flex-end; gap: 8px;- height: 60px; padding: 12px 17px 0 16px; flex: none;+ display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1);+ height: var(--head-h); padding: 0 var(--space-3) 0 var(--space-4); flex: none;-webkit-app-region: drag;}.side-top > * { -webkit-app-region: no-drag; }-.round-btn {- width: 36px; height: 36px; border-radius: 50%; flex: none;- display: inline-flex; align-items: center; justify-content: center;- background: var(--card); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line);- transition: background .12s, transform .12s var(--ease);-}-.round-btn:hover { background: var(--card-2); }-.round-btn:active { transform: scale(.96); }-.round-btn.on { background: var(--side-active); }-.side-search { flex: 1; min-width: 0; height: 36px; border-radius: 18px; padding: 0 14px; border: 0; outline: none; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }-.side-search:focus { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }-.side-search::placeholder { color: var(--placeholder); }--.side-hero { display: grid; justify-items: center; gap: 8px; padding: 2px 16px 18px; flex: none; }-.side-hero .name { font-size: 13px; font-weight: 500; color: var(--fg); }+.side-top.start { justify-content: flex-start; padding-left: var(--space-2); }+.side-back {+ display: inline-flex; align-items: center; gap: var(--space-1-5); height: var(--ctl-lg); padding: 0 var(--space-2-5) 0 var(--space-2);+ border-radius: var(--r-lg); font-size: var(--fs-md); color: var(--ctl-fg); transition: background var(--t-fast), color var(--t-fast);+}+.side-back:hover { background: var(--side-hover); color: var(--fg); }+.side-back:active { background: var(--side-press); }+.side-top .icon-btn { --ib-size: 30px; --ib-fg: var(--ctl-fg); }+.side-top .icon-btn.on { box-shadow: var(--shadow-tile); }+.side-search {+ flex: none; display: flex; align-items: center; gap: var(--space-2); height: 34px; margin: 0 var(--space-3) var(--space-2-5); padding: 0 var(--space-3);+ border-radius: var(--r-lg); background: var(--pill); color: var(--muted);+ box-shadow: inset 0 0 0 .5px var(--line-2);+ transition: box-shadow var(--t-fast), background var(--t-fast), color var(--t-fast);+}+.side-search:hover { background: var(--pill-hover); }+.side-search:focus-within { background: var(--card); color: var(--fg-2); box-shadow: inset 0 0 0 1px var(--accent), var(--ring); }+.side-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: var(--fs-md); color: var(--fg); }+.side-search input::placeholder { color: var(--muted); }+.side-search input::-webkit-search-cancel-button { display: none; }-.side-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 8px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 4px; }+.side-list {+ flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-0-5) var(--space-2) var(--space-2);+ display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-0-5);+}+.side-list > .hint { padding: var(--space-2) var(--space-2-5); }+/* 设置时的侧栏:分页导航 */+.side-nav { gap: var(--space-0-5); --rise: 3px; animation: rise-in var(--dur-moderate) var(--ease-out); }+.nav-item {+ --focus-offset: -2px;+ display: flex; align-items: center; gap: var(--space-2-5); height: var(--ctl-xl); padding: 0 var(--space-2-5);+ border-radius: var(--r-lg); font-size: var(--fs-lg); color: var(--fg-2); text-align: left;+ transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);+}+.nav-item .ic { color: var(--muted); transition: color var(--t-fast); }+.nav-item:hover { background: var(--side-hover); color: var(--fg); }+.nav-item:active { background: var(--side-press); }+.nav-item.sel { background: var(--side-active); box-shadow: var(--shadow-tile); color: var(--fg); font-weight: var(--fw-medium); }+.nav-item.sel .ic, .nav-item:hover .ic { color: var(--fg); }.thread {+ --focus-offset: -2px;min-width: 0;- display: flex; align-items: center; gap: 11px; width: 100%; height: 54px; padding: 0 9px;- border-radius: 14px; text-align: left; position: relative;- transition: background .12s;+ display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 60px; padding: 0 var(--space-2-5);+ border-radius: var(--r-xl); text-align: left; position: relative;+ transition: background var(--t-fast), box-shadow var(--t-fast);}.thread:hover { background: var(--side-hover); }-.thread.sel { background: var(--side-active); }-.thread .body { min-width: 0; flex: 1; }-.thread .title { font-size: 14px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }-.thread .snip { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }-.thread .badge.count { background: var(--amber-soft); color: var(--amber); }+button.thread:active { background: var(--side-press); }+.thread.sel, button.thread.sel:active { background: var(--side-active); box-shadow: var(--shadow-tile); }+.thread .body { min-width: 0; flex: 1; display: grid; gap: 1px; }+.thread .line { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }+.thread .title { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: var(--lh-tight); }+.thread .when { flex: none; font-size: var(--fs-xs); color: var(--muted); }+.thread .snip { flex: 1; min-width: 0; font-size: var(--fs-md); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }+.thread.sel .snip { color: var(--fg-2); }+.thread .badge.count { --badge-bg: var(--amber-soft); --badge-fg: var(--amber); align-self: center; }.thread .avatar-wrap { position: relative; flex: none; }.thread .working-dot {- position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%;- background: var(--accent); box-shadow: 0 0 0 2px var(--side-bg);- animation: breathe 1.4s ease-in-out infinite;-}-.thread.sel .working-dot { box-shadow: 0 0 0 2px var(--side-active); }-@keyframes breathe { 0%, 100% { opacity: .45; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }-.thread-new { display: flex; gap: 6px; align-items: center; padding: 6px 2px 6px 4px; }-.thread-new .field { height: 34px; border-radius: 10px; }-.side-empty { margin: 12px 4px; padding: 18px 14px; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--muted); }+ position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%;+ background: var(--green); box-shadow: 0 0 0 2px var(--surface-solid);+ animation: breathe var(--dur-pulse) var(--ease-in-out) infinite;+}+.thread-skel { flex: 1; display: grid; gap: var(--space-1-5); }+.thread .field { --field-h: 30px; }+.side-empty {+ margin: var(--space-3) var(--space-1); padding: 18px var(--space-3-5); border-radius: var(--r-xl);+ background: var(--card); box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs);+ text-align: center; display: grid; gap: var(--space-2-5); justify-items: center; color: var(--muted);+}-.side-foot { flex: none; display: flex; align-items: center; padding: 8px 17px 16px 16px; }+.side-foot { flex: none; display: flex; align-items: center; padding: var(--space-2) var(--space-2) var(--space-3); }.account {- display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; height: 44px; padding: 0 8px 0 0;- border-radius: 22px; text-align: left; transition: background .12s;+ --focus-offset: -2px;+ display: flex; align-items: center; gap: var(--space-2-5); min-width: 0; flex: 1; height: var(--ctl-2xl); padding: 0 var(--space-3) 0 var(--space-2);+ border-radius: var(--r-xl); text-align: left; transition: background var(--t-fast), box-shadow var(--t-fast);}.account:hover { background: var(--side-hover); }-.account.on { background: var(--side-active); }+.account:active { background: var(--side-press); }+.account.on { background: var(--side-active); box-shadow: var(--shadow-tile); }.account .me {- width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;- background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: 14px; color: var(--fg-2);+ width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;+ background: var(--card); box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-xs);+ font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--fg-2);}-.account .who { font-size: 14px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.account .who { flex: 1; min-width: 0; font-size: var(--fs-lg); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.account > .ic { color: var(--muted); transition: color var(--t-fast); }+.account:hover > .ic { color: var(--fg); }-/* macOS desktop: traffic lights live in the sidebar's top-left */+/* macOS desktop: traffic lights live in the sidebar's top-left.+ 拖动窗口只靠侧栏顶部和各页顶栏;不要把 .app 整个设成拖动区——盖在上面的命令面板、对话框、提示会跟着变成拖动区 */:root.mac-app .side-top { padding-left: 84px; }-/* —— Info panel —— */+/* —— Info panel(参考 Grok Bot 的详情栏):一块更通透的玻璃面板,分组直接是列表行,不再套卡片 —— */.panel {min-height: 0; display: flex; flex-direction: column;- background: var(--bg); border-left: 1px solid var(--line);- animation: panel-in .24s var(--ease);+ margin: var(--pane-gap) var(--pane-gap) var(--pane-gap) 0;+ border-radius: var(--r-2xl); background: var(--grain), var(--glass-panel); box-shadow: var(--shadow-pane); overflow: hidden;+ animation: slide-in var(--dur-moderate) var(--ease-out);}-@keyframes panel-in { from { opacity: 0; transform: translateX(12px); } }.panel-head {- height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px;+ height: var(--head-h); flex: none; display: flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-2-5) 0 var(--space-4);-webkit-app-region: drag;}.panel-head > * { -webkit-app-region: no-drag; }-.panel-head .title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }-.panel-body { flex: 1; overflow-y: auto; padding: 0 12px 16px; }-.panel-body .row { min-height: 44px; padding: 6px 10px 6px 12px; gap: 10px; }+.panel-head .title { flex: 1; min-width: 0; font-size: var(--fs-xl); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.panel-head .icon-btn { --ib-size: 30px; }+.panel-body { flex: 1; overflow-y: auto; padding: 0 var(--space-2) var(--space-6); }+.panel-body .list-head { margin: var(--space-5) var(--space-2) var(--space-1); }+.panel-body .list-head:first-child { margin-top: var(--space-2); }+.panel-body .list { background: transparent; border: 0; border-radius: 0; overflow: visible; }+.panel-body .list + .list, .panel-body .list-head + .list { margin-top: 0; }+.panel-body .row { --row-h: 48px; --row-py: var(--space-1-5); --row-pl: var(--space-2); --row-pr: var(--space-2); --row-gap: var(--space-2-5); border-radius: var(--r-lg); }+.panel-body .row + .row, .panel-body .row + .row-edit, .panel-body .row-edit + .row { border-top: 0; }+.panel-body .row.clickable { --focus-offset: 0px; }+.panel-body .row-edit { border-radius: var(--r-lg); background: var(--card-2); box-shadow: inset 0 0 0 .5px var(--line-2); margin: var(--space-0-5) 0 var(--space-1); }.panel-body .row > .hint { flex: none; white-space: nowrap; }+.panel-qr {+ width: 180px; height: 180px; image-rendering: pixelated; background: var(--qr-bg);+ padding: var(--space-2); border-radius: var(--r-lg); box-shadow: 0 0 0 .5px var(--line), var(--shadow-sm);+}+/* 会话记录预览(信息面板 → 最近会话) */+.transcript { display: grid; gap: var(--space-2); max-height: 60vh; overflow: auto; }+.transcript-msg { justify-self: start; max-width: 85%; }+.transcript-msg.user { justify-self: end; }+.transcript-msg .bubble {+ white-space: pre-wrap; padding: 7px 11px; border-radius: var(--r-2xl);+ font-size: var(--fs-md); line-height: var(--lh-normal); background: var(--bubble-ai);+}+.transcript-msg.user .bubble { background: var(--bubble-user); }+.transcript-msg .hint { margin-top: var(--space-0-5); }+.transcript-msg.user .hint { text-align: right; }.panel-scrim { display: none; }-/* narrow window: the panel overlays the chat as a drawer over a scrim */+/* narrow window: the panel floats over the chat as a glass drawer over a scrim */@media (max-width: 1180px) {.app.with-panel { grid-template-columns: var(--side-w) minmax(0, 1fr); }.app.with-panel .panel {- position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: var(--panel-w);- box-shadow: var(--shadow);+ position: fixed; z-index: var(--z-drawer); top: var(--pane-gap); right: var(--pane-gap); bottom: var(--pane-gap); width: var(--panel-w); margin: 0;+ background: var(--grain), var(--glass-pop); backdrop-filter: var(--glass-filter-lg); box-shadow: var(--shadow-pop);+ }+ .panel-scrim {+ display: block; position: fixed; z-index: calc(var(--z-drawer) - 1); inset: 0;+ background: var(--scrim-soft); animation: fade-in var(--dur-base) var(--ease-out);}- .panel-scrim { display: block; position: fixed; z-index: 29; inset: 0; background: rgba(0, 0, 0, .18); animation: fade-in .2s ease-out; }}@media (max-width: 900px) {:root { --side-w: 240px; }}--/* —— Command palette —— */-.palette-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .18); animation: pop-fade .14s ease-out; }-.palette {- position: fixed; z-index: 56; left: 50%; top: 14vh; width: min(520px, calc(100vw - 32px)); transform: translateX(-50%);- max-height: 60vh; display: flex; flex-direction: column;- background: var(--pop-bg); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);- border-radius: 13px; box-shadow: var(--shadow); overflow: hidden;- animation: pop-fade .16s ease-out;-}-.palette .search input { height: 46px; font-size: 14px; }-.palette li { min-height: 36px; font-size: 13px; }-.palette li kbd { margin-left: auto; font: 11px var(--code); color: var(--muted); }+}diff --git a/ui/design/README.md b/ui/design/README.mdnew file mode 100644index 0000000..47e9ebc--- /dev/null+++ b/ui/design/README.md@@ -0,0 +1,206 @@+# AnyModelBot 设计库++界面样式的唯一来源。无构建步骤:原生 CSS(`@layer` + 自定义属性)+ Preact/htm 组件。++- 样例页:本机服务的 `/amb/static/design/index.html`。token 表直接从 `tokens/*.css` 解析,不会和代码脱节;支持浅色/深色和双主题对照,也能模拟"减少动态效果"。+- 守卫测试:`test/design-system.unit.test.ts`。`npm test` 时检查规范有没有被破坏(规则见文末)。++## 目录++```+ui/design/+ index.css 入口:声明层顺序并按层引入下面所有文件+ tokens/+ primitives.css L1 原始值:品牌/状态色板,间距、字号、圆角、控件高度、层级等尺度+ semantic.css L2 语义 token:按用途命名、按主题取值(浅色 + 深色)+ motion.css 动效 token:时长、缓动、位移量、--motion 开关+ base/+ reset.css 重置、焦点环、可选中规则+ motion.css 关键帧库 + .anim-* 工具类 + 减少动态效果+ typography.css 文字角色 .t-*(在 utilities 层)+ utilities.css .stack .cluster .grow .truncate .tone-* .sr-only+ components/ 一个组件一个文件:glass button field badge list seg switch popover sheet toast notice feedback avatar+ motion.js ms("--dur-base")、usePresence()、reducedMotion()+ index.html / gallery.* 样例页+ui/css/ 页面样式(shell / chat / settings),放在 app 层+ui/components/ui.js 组件的 JS 写法:Button IconButton Notice Skeleton Seg Switch Menu MenuButton Sheet …+```++## 层叠顺序++```css+@layer tokens, base, components, app, utilities;+```++后面的层总是赢,和选择器权重无关:++- 页面样式(`ui/css/*.css`,整个文件包在 `@layer app { … }` 里)可以直接覆盖组件,不用拼权重。+- 工具类和文字角色在最后,加上就生效。+- 新的页面样式文件也要包进 `@layer app`,否则它会是"无层"样式,压过所有层。++## Token++**分两层。** 原始值(`--lime-500`、`--space-3`、`--r-md`)描述"有什么";语义 token(`--accent-solid`、`--line`、`--muted`)描述"用在哪"。++| 类别 | 规则 |+|---|---|+| 颜色 | 页面和组件**只用语义色**。原始色板只在 `semantic.css` 里引用。新颜色先加语义 token(两个主题都要给值),再用。 |+| 字号 | 9 级 `--fs-2xs … --fs-4xl`(11 / 11.5 / 12.5 / 13 / 14 / 15 / 17 / 20 / 24)。新界面优先用文字角色 `.t-*`。 |+| 圆角 | `--r-xs … --r-3xl`、`--r-full`。嵌套时内层 = 外层 − 内边距(`.seg`、`.pop` 里的列表项就是这样算的)。圆形用 `50%`。 |+| 间距 | 4 的倍数 `--space-1 … --space-16`,另有 `-0-5 / -1-5 / -2-5 / -3-5` 半步。组件内部的精调像素可以保留。 |+| 控件高度 | `--ctl-xs … --ctl-2xl`(22 / 24 / 28 / 32 / 36 / 44)。 |+| 投影 | `--shadow-xs / sm / md / lg`;`--shadow-pane`(浮在环境光上的面板)、`--shadow-tile`(侧栏选中项)、`--shadow-float` / `--shadow-pop`(玻璃的边 + 投影)、`--primary-edge`、`--seg-edge`。深色下更重,都是主题 token。 |+| 层级 | 只用 `--z-*`;同一窗格内的浮动件用 `calc(var(--z-float) ± 1)`。 |+| 焦点 | 输入框:accent 描边(浅色墨、深色黄绿)+ `box-shadow: var(--ring)` 黄绿光晕(错误时 `--ring-danger`);其他控件:全局 `:focus-visible` 2px 描边、外移 2px,装在会裁切的容器里时用 `--focus-offset` 往里收。 |++现有语义色名(`--bg --card --pill --line --fg --muted --accent …`)沿用 magpie 的叫法,分组见 `semantic.css` 里的 `/* —— 组 —— */` 注释。++## 品牌色++品牌色是 Modelflare 的**信号黄绿 `#d7ff00` + 墨色 `#161a00`**。界面骨架是纯灰阶(布局参考 Grok Bot / Codex),颜色留给两样东西:品牌信号和机器人头像。++**一句话:墨色负责操作,黄绿是"亮起的信号"。** 黄绿在白底上只有 1.15:1,所以它永远是**填充面**或**墨色上的光**,不当浅色背景上的文字和细线用。++| 角色 | token | 浅色 | 深色 |+|---|---|---|---|+| 主操作:主按钮、打开的开关 | `--primary` / `--on-primary` | 墨底白字 | 黄绿底墨字 |+| 发送 / 停止 | `--send-bg` / `--send-fg` | 墨色圆钮 + **黄绿箭头** | 黄绿圆钮 + 墨色箭头 |+| 焦点、勾选、指示点、链接 | `--accent` | 墨色 | 黄绿 |+| 输入框聚焦光晕 | `--ring`(`--accent-soft`) | 黄绿光晕 | 弱黄绿光晕 |+| 荧光笔:选中文字、定位闪烁 | `--mark` / `--on-mark` | 浅黄绿底墨字 | 暗黄绿底 |+| 品牌填充:应用标志、"已保存" | `--accent-solid` / `--on-accent` | 黄绿底墨字 | 同左 |++不要用品牌色的地方:分段控件的 thumb、菜单当前项、选中的侧栏行、用户气泡(都是中性灰);状态(成功、工作中)用 `--green`,不要用黄绿冒充。++## 材质++窗口是分层的,越往上越"实":++| 层 | 是什么 | token |+|---|---|---|+| 环境光 | 窗口最底层:`--bg` + 左上的品牌黄绿光 + 跟着当前机器人角色变色的色相光(切换机器人时 `--dur-ambient` 慢慢过渡)。`.app`、引导页、样例页的 `.aura-bg` 共用 | `--bg --aura-brand --aura-l --aura-c --aura-a`,色相 `--aura-hue` 由 `main.js` 设 |+| 侧栏 | 直接盖在环境光上的毛玻璃(底下是平滑的光,不需要模糊) | `--glass-side` |+| 主区、信息面板 | 浮在环境光上的圆角面板,四周留 `--pane-gap` | `--surface`、`--glass-panel`,`--shadow-pane` |+| 顶栏、输入框、回到底部 | 盖在滚动内容上的玻璃,内容从底下滚过是模糊的 | `--glass-chrome`、`--glass-float` + `--glass-filter` |+| 菜单、命令面板、提示、对话框 | 最上层的玻璃,模糊最重 | `--glass-pop`、`--glass-sheet` + `--glass-filter-lg`,`--shadow-pop` |++一块玻璃 = 半透明底 + 背景模糊 + 磨砂颗粒 `--grain` + 顶边高光 `--glass-hi` 与细描边 `--glass-edge`。写法:++```css+.pop { background: var(--grain), var(--glass-pop); backdrop-filter: var(--glass-filter-lg); box-shadow: var(--shadow-pop); }+<div class="glass" style="--glass-bg: var(--glass-chrome)">…</div> /* 临时用:.glass + --glass-bg / --glass-blur / --glass-shadow */+```++- **填充、悬停、描边都是半透明的一层**(`--pill*`、`--side-*`、`--line*`、`--sel*`),放在玻璃和实色上都对。不要在玻璃上用实色灰。+- **`backdrop-filter` 会让元素变成 `position: fixed` 子元素的包含块**。里面会渲染菜单、对话框的容器(侧栏、主区、`.chat`)不要加,模糊只加在叶子级的浮层上。+- 系统开了"降低透明度"(`prefers-reduced-transparency`),材质自动换成接近实色,层次靠描边和投影。++## 状态++每个可交互组件都要把下面这些状态想到;样例页的「状态矩阵」把它们按浅色 / 深色并排画出来(伪类规则被复制成 `.is-hover / .is-active / .is-focus`,和真实交互是同一份样式)。++| 状态 | 怎么表现 | 用什么 |+|---|---|---|+| 悬停 | 叠一层半透明,静默控件的字从 `--ctl-fg` 变 `--fg`;卡片类(模板、胶囊、提示里的按钮)是描边加深 + 投影变大 | `--pill` → `--pill-hover`;侧栏里是更亮的一层玻璃 `--side-hover` |+| 按下 | 再深一级,并轻微缩小(`--press` / `--press-strong`);列表行只变色不缩放 | `--pill-press`、`--sel-press`、`--side-press` |+| 键盘焦点 | `:focus-visible` 2px `--accent` 描边;输入框是描边 + 光晕 | `--focus-offset`、`--ring` |+| 打开 | 菜单展开时触发它的按钮保持"按住"的样子,箭头翻转,加号转成叉 | `[aria-expanded="true"]`,`.icon-btn.on` |+| 选中 / 当前 | 侧栏行和设置导航是浮起的玻璃片;菜单当前项打勾;模板卡 accent 描边 + `--accent-wash`,图标亮成黄绿 | `--side-active` + `--shadow-tile`,`--accent-wash` |+| 禁用 | `--o-disabled`,不响应悬停和按下;主按钮和发送钮退成中性灰(半透明的墨色或黄绿会发浑) | `:disabled` |+| 加载 | 转圈,颜色不变,只是不可点(`aria-busy`) | `Button loading` |+| 错误 | 红描边,聚焦时红光晕 | `.err` / `aria-invalid`,`--ring-danger` |+| 只读 | 次级底,聚焦不发光 | `[readonly]` |+| 滚动边缘 | 内容滚到顶栏底下时,顶栏才出现细线和投影 | `.chat.scrolled` |++## 主题++- `<html data-theme>` 总是解析后的 `light` / `dark`(`index.html` 首帧前设置,`lib/theme.js` 同步)。+- **主题可以局部生效**:任何元素加 `data-theme="dark"`,它的子树就换一套语义 token(样例页的双主题对照就是这样做的)。+- 因此**不要写** `:root[data-theme="dark"] .xxx { … }` 这类按主题的覆盖。需要两个主题不同的值,就加一个语义 token。+- 由其他语义 token 推导的值(`--ring`、`--code-bg`)写在 `:root, [data-theme] { … }` 里,每个作用域都会重新计算。++## 组件++每个组件把可调的地方开放成自己的变量。**变体、尺寸和上下文覆盖都只改变量,不改属性**:++```css+.btn.primary { --btn-bg: var(--accent-solid); --btn-fg: var(--on-accent); … } /* 变体 */+.notice .btn { --btn-h: var(--ctl-sm); --btn-bg: var(--card); } /* 上下文 */+```++| 组件 | 类名 API | 变量 |+|---|---|---|+| 按钮 | `.btn [primary\|ghost\|danger] [sm\|lg] [block]` | `--btn-h --btn-px --btn-r --btn-fs --btn-bg --btn-bg-hover --btn-bg-press --btn-fg --btn-fg-hover --btn-edge` |+| 毛玻璃 | `.glass`(组件自己是玻璃时直接写三行,见「材质」) | `--glass-bg --glass-blur --glass-shadow` |+| 图标按钮 | `.icon-btn [xs] [on]` | `--ib-size --ib-r --ib-fg --ib-fg-hover --ib-bg-hover --ib-bg-on --ib-bg-press` |+| 文字按钮 | `.text [danger\|accent]` | — |+| 输入框 | `.field [mono] [err]`,`.field-wrap > .field + .tail` | `--field-h --field-px --field-r --field-bg --field-edge --field-edge-hover --field-edge-focus --field-ring` |+| 徽标 / 点 | `.badge [ok\|err\|warn\|off] [count]`,`.dot [ok\|err\|warn]` | `--badge-bg --badge-fg`,`--dot-bg` |+| 列表行 | `.list > .row [compact] [clickable] [off] [flash]`,`.row-edit`,`.list-head` | `--row-h --row-py --row-pl --row-pr --row-gap` |+| 分段 | `Seg` 组件(`.seg > .thumb + button`),两个以上的选项 | `--seg-r --seg-pad --seg-thumb --seg-on` |+| 开关 | `Switch` 组件(`button.switch[role=switch] [sm]`),只有开 / 关 | `--switch-w --switch-h --switch-pad --switch-track --switch-track-hover --switch-dot --switch-stretch` |+| 菜单 | `.pick`,`.pop [up]`,`.palette`,`Menu` / `MenuButton` / `Popover` | `--pop-r --pop-pad` |+| 对话框 | `Sheet` / `confirmSheet()`(`.scrim > .sheet [wide]`) | `--sheet-w --sheet-r` |+| 提示胶囊 | `toast()` / `saved()` / `failed()`(`.toast [ok\|err\|warn]`) | `--toast-bg --toast-fg --toast-edge` |+| 行内提示 | `Notice` / `.notice [amber\|red]` | `--notice-bg --notice-fg --notice-edge` |+| 加载 | `Spinner`、`Skeleton`(`.skel [circle]`)、`.empty-state` | — |+| 头像 | `BotAvatar [bot\|char] [state] [cue] [lively] [pokeable] [greet] [neutral]`、`AvatarPicker`、`AppMark`;6 个内置角色,见下文「头像」 | `--avatar-aura --avatar-shadow`(主题),角色颜色 `--bot-*`(原画色,两个主题相同) |++JS 组件(`ui/components/ui.js`)只是给常用组合一个带逻辑的写法(loading、图标、无障碍属性);直接写类名同样合法。++## 动效++| 用途 | 时长 | 缓动 |+|---|---|---|+| 悬停、按下、颜色变化 | `--dur-fast` 120ms(`--t-fast`) | `--ease-out` |+| 出现 / 消失、提示胶囊、遮罩 | `--dur-base` 180ms | 入场 `--ease-out`,退场 `--ease-in` |+| 视图切换、面板、分段 thumb | `--dur-moderate` 240ms | `--ease-out` |+| 对话框 / 弹出层的弹性入场 | `--dur-slow` 360ms / `--dur-slower` 420ms | `--ease-spring` |+| 循环(转圈、骨架、呼吸、光标) | `--dur-spin --dur-shimmer --dur-pulse --dur-blink` | `linear` / `--ease-in-out` |++- **关键帧库**(`base/motion.css`):`fade-in/out`、`rise-in`、`sink-out`、`slide-in`、`pop-in/out`、`bump`、`flash`、`spin`、`shimmer`、`breathe`、`blink`。关键帧只描述起止,时长缓动由使用处给 token。+- **位移量是 token**:`--rise`、`--slide`、`--pop-dy`、`--pop-scale`,组件可以局部覆盖(`.toast { --rise: 6px }`)。+- **减少动态效果**:关键帧里的位移都乘以 `--motion`;系统开启"减少动态效果"时 `--motion: 0`,所有入场自动退化成纯淡入,按下不缩放,过渡几乎瞬时。新写的关键帧也要乘 `--motion`。+- **退场动画**:用 `usePresence(open)`(`design/motion.js`)让组件在退场时长内保持挂载,并给元素加 `.leaving` / `.anim-*-out`。`DialogHost` 是参考实现。+- **JS 里不写死毫秒数**:`ms("--dur-base")` 读 token(toast 的移除时机就是这样同步的)。+- 只给 `transform` 和 `opacity` 做动画;空闲列表保持安静(头像空闲时只在指针靠近时看过去、悬停时抖一下天线,不自己动)。++## 头像++6 个内置毛绒角色(原图在 `anymodelbot_design/logo avator/`),蓝色的**小蓝是主角**:默认机器人、新建页的默认选择、启动和连接页的吉祥物都是它。++| 角色 | key | 招牌动作 | 推荐配给 |+|---|---|---|---|+| 小蓝 | `blue` | 天线晃、天线球亮、一圈圈发信号 | 默认助手、会议纪要 |+| 小萌 | `yellow` | 星星一闪一闪、完成时像硬币一样转 | 客服 |+| 绿草 | `green` | 叶子被风吹、完成时长高一截、出错时蔫了 | 群聊日报 |+| 红魔 | `red` | 耳机灯带跟着节拍亮、耳机震 | 代码助手 |+| 紫钻 | `purple` | 宝石浮起来转、霓虹线一明一暗 | 写作助手 |+| 探险者 | `orange` | 眼睛大范围搜寻、护目镜反光 | 翻译官 |++- **配对**:机器人设置的 `settings.avatar`(新建页和机器人设置里选;模板自带推荐,见 `screens/new-bot.js` 的 `TEMPLATES`);没选过时 `charOf(bot)` 由 id 稳定地挑一个,`default` 机器人是小蓝。+- **持续状态** `state`:`idle`、`listening`(你在输入)、`thinking`(还没出字)、`replying`、`working`(后台任务)、`waiting`(等你批准)、`sleep`(连不上本机服务)。+- **一次性反应** `cue={ kind, at }`:`hello`(新建 / 打招呼,`greet` 在挂载时播)、`done`(忙 → 不忙时自动播)、`error`、以及戳头像触发的 `poke` / `love`(连戳三下)/ `dizzy`(戳六下)。时长是 `tokens/motion.css` 的 `--bot-*`。+- **lively**:只给大头像(空态、新建页、启动页):呼吸、眨眼、四处看、脚下有影子。小于 36px 不画粒子。+- **图层**:`python3 scripts/build-bot-avatars.py` 把每张原图拆成头(眼睛已抹掉)、两只耳朵、头顶配件和发光部分,输出 `design/bots/<key>.webp`(8 格精灵图)。眼睛是 `avatar.js` 画的 SVG,才能眨眼和换表情(睁眼、开心、闭眼、难过、××、晕、爱心)。换原图后重跑脚本,几何有变化时同步 `BOT_CHARS` 里的百分比。++## 新增或修改++1. 先在样例页里找现成的 token、组件、文字角色。+2. 缺颜色 → `semantic.css` 加语义 token(浅色、深色各一个值);缺尺度 → `primitives.css`。+3. 新组件 → `components/<name>.css`,开放 `--<name>-*` 变量,在 `index.css` 按层引入;需要逻辑时在 `ui/components/ui.js` 加 JS 写法;在 `gallery.js` 加样例。+4. 页面专属样式写在 `ui/css/*.css` 的 `@layer app` 里,只引用 token。+5. 跑 `npm test`。++## 守卫测试会拦下++- `ui/design/tokens/` 之外出现原始颜色(`#hex`、不含 `var()` 的 `rgb()/hsl()`)+- `font-size` / `font` 里写死 px+- `border-radius` 写死 ≥ 3px(1–2px 的细节、`50%` 不算)+- `transition` / `animation` 里写死时长或缓动(`linear`、`steps()` 可以)+- `z-index` 写死数字+- JS 内联样式里写死颜色或字号+- 引用了没定义的 `var(--x)`(带回退值的除外)+- 有组件或基础样式文件没在 `index.css` 里引入++组件文件里确实需要的"魔法数"(比如头像的眨眼周期),先起名再用:`--bf-blink: 4.2s`。自定义属性的定义不受时长规则限制,但要写清楚用途。diff --git a/ui/design/base/motion.css b/ui/design/base/motion.cssnew file mode 100644index 0000000..fb30e04--- /dev/null+++ b/ui/design/base/motion.css@@ -0,0 +1,33 @@+/* 关键帧库 + 动画工具类。关键帧只描述"从哪来/到哪去",时长和缓动由使用处给 token。+ 位移乘以 --motion:减少动态效果时只剩淡入淡出。 */+@keyframes fade-in { from { opacity: 0; } }+@keyframes fade-out { to { opacity: 0; } }+@keyframes rise-in { from { opacity: 0; transform: translateY(calc(var(--rise) * var(--motion))); } }+@keyframes sink-out { to { opacity: 0; transform: translateY(calc(var(--rise) * var(--motion))); } }+@keyframes slide-in { from { opacity: 0; transform: translateX(calc(var(--slide) * var(--motion))); } }+/* 弹出层:只管位移与缩放,配合 fade-in 一起用(两者时长不同) */+@keyframes pop-in { from { transform: translateY(calc(var(--pop-dy) * var(--motion))) scale(calc(1 - (1 - var(--pop-scale)) * var(--motion))); } }+@keyframes pop-out { to { opacity: 0; transform: translateY(calc(var(--pop-dy) * var(--motion) / 2)) scale(calc(1 - (1 - var(--pop-scale)) * var(--motion) / 2)); } }+/* 一次性反馈 */+@keyframes bump { 40% { transform: scale(calc(1 + .12 * var(--motion))); } }+@keyframes flash { 0%, 35% { background: var(--mark); } }+/* 循环 */+@keyframes spin { to { transform: rotate(360deg); } }+@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }+@keyframes breathe { 0%, 100% { opacity: .45; transform: scale(calc(1 - .15 * var(--motion))); } 50% { opacity: 1; transform: scale(1); } }+@keyframes blink { 50% { opacity: 0; } }++/* 工具类:可用 --anim-dur / --anim-ease / --anim-delay 微调 */+.anim-fade-in { animation: fade-in var(--anim-dur, var(--dur-base)) var(--anim-ease, var(--ease-out)) var(--anim-delay, 0s) both; }+.anim-rise-in { animation: rise-in var(--anim-dur, var(--dur-moderate)) var(--anim-ease, var(--ease-out)) var(--anim-delay, 0s) both; }+.anim-slide-in { animation: slide-in var(--anim-dur, var(--dur-moderate)) var(--anim-ease, var(--ease-out)) var(--anim-delay, 0s) both; }+.anim-pop-in { animation: fade-in var(--dur-base) var(--ease-out), pop-in var(--anim-dur, var(--dur-slower)) var(--anim-ease, var(--ease-spring)); }+.anim-fade-out { animation: fade-out var(--anim-dur, var(--dur-base)) var(--anim-ease, var(--ease-in)) forwards; pointer-events: none; }+.anim-sink-out { animation: sink-out var(--anim-dur, var(--dur-base)) var(--anim-ease, var(--ease-in)) forwards; pointer-events: none; }+.anim-pop-out { animation: pop-out var(--anim-dur, var(--dur-base)) var(--anim-ease, var(--ease-in)) forwards; pointer-events: none; }+.anim-flash { animation: flash var(--dur-flash) var(--ease-out); }+.anim-bump { animation: bump var(--dur-slow) var(--ease-out); }++@media (prefers-reduced-motion: reduce) {+ *, *::before, *::after { transition-duration: var(--dur-off) !important; scroll-behavior: auto !important; }+}diff --git a/ui/design/base/reset.css b/ui/design/base/reset.cssnew file mode 100644index 0000000..9c7e24c--- /dev/null+++ b/ui/design/base/reset.css@@ -0,0 +1,32 @@+/* 重置、焦点环、选择规则。 */+*, *::before, *::after { box-sizing: border-box; }+html, body { height: 100%; margin: 0; }+body {+ font: var(--fw-regular) var(--fs-md)/var(--lh-snug) var(--font);+ color: var(--fg);+ background: var(--bg);+ -webkit-font-smoothing: antialiased;+ overflow: hidden;+ /* 控件读起来像应用而不是网页:只有窗口里作为内容展示的东西才能选中 */+ user-select: none;+ -webkit-user-select: none;+}+/* 局部主题作用域要自带底色和字色 */+[data-theme]:not(:root) { background: var(--bg); color: var(--fg); }+:where(p, pre, code, td, .selectable, .msg, .notice-text, .err-text) { user-select: text; -webkit-user-select: text; }+h1, h2, h3, h4, p { margin: 0; }+button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: default; appearance: none; -webkit-appearance: none; text-align: center; }+input, textarea { font: inherit; color: inherit; }+a { color: var(--accent); text-decoration: none; }+a:hover { text-decoration: underline; }+/* 荧光笔:选中文字用品牌黄绿 */+::selection { background: var(--mark); color: var(--on-mark); }+code, .mono { font-family: var(--code); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }+/* 键盘焦点:2px accent 描边,外移 2px(描边跟着圆角走)。+ 装在 overflow: hidden 容器里、外移会被裁掉的行内控件,把 --focus-offset 设成负值往里收。 */+button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {+ outline: 2px solid var(--accent); outline-offset: var(--focus-offset, 2px);+}+/* 滚动条:细、半透明,盖在玻璃和环境光上都不突兀(macOS 的浮动滚动条不受影响) */+* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }+svg.ic { width: 16px; height: 16px; flex: none; display: block; }diff --git a/ui/design/base/typography.css b/ui/design/base/typography.cssnew file mode 100644index 0000000..3a4e85f--- /dev/null+++ b/ui/design/base/typography.css@@ -0,0 +1,13 @@+/* 文字角色:新界面优先用这些类,不要再挑字号。放在 utilities 层,加在组件上也能生效。+ 已有组件直接引用 --fs-* / --fw-* token,效果与对应角色一致。 */+.t-caption { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); color: var(--faint); }+.t-label { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); color: var(--muted); }+.t-meta { font-size: var(--fs-xs); color: var(--muted); line-height: var(--lh-normal); }+.t-control { font-size: var(--fs-sm); }+.t-body { font-size: var(--fs-md); line-height: var(--lh-snug); }+.t-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }+.t-heading { font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }+.t-display { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tighter); }+.t-page { font-size: var(--fs-4xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tighter); line-height: var(--lh-tight); }+.t-prose { font-size: var(--fs-xl); line-height: var(--lh-normal); }+.num { font-variant-numeric: tabular-nums; }diff --git a/ui/design/base/utilities.css b/ui/design/base/utilities.cssnew file mode 100644index 0000000..e5c7226--- /dev/null+++ b/ui/design/base/utilities.css@@ -0,0 +1,10 @@+/* 少量布局与文字工具类。只收"到处都在写"的那几种;更复杂的布局写在页面样式里。 */+.stack { display: grid; gap: var(--gap, var(--space-2)); align-content: start; }+.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--space-2)); }+.grow { flex: 1; min-width: 0; }+.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.pre-wrap { white-space: pre-wrap; }+.tone-fg { color: var(--fg); }+.tone-muted { color: var(--muted); }+.tone-danger { color: var(--red); }+.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }diff --git a/ui/design/bots/blue.webp b/ui/design/bots/blue.webpnew file mode 100644index 0000000..e3c4085Binary files /dev/null and b/ui/design/bots/blue.webp differdiff --git a/ui/design/bots/green.webp b/ui/design/bots/green.webpnew file mode 100644index 0000000..40f271bBinary files /dev/null and b/ui/design/bots/green.webp differdiff --git a/ui/design/bots/orange.webp b/ui/design/bots/orange.webpnew file mode 100644index 0000000..145e858Binary files /dev/null and b/ui/design/bots/orange.webp differdiff --git a/ui/design/bots/purple.webp b/ui/design/bots/purple.webpnew file mode 100644index 0000000..764b4b6Binary files /dev/null and b/ui/design/bots/purple.webp differdiff --git a/ui/design/bots/red.webp b/ui/design/bots/red.webpnew file mode 100644index 0000000..b906787Binary files /dev/null and b/ui/design/bots/red.webp differdiff --git a/ui/design/bots/yellow.webp b/ui/design/bots/yellow.webpnew file mode 100644index 0000000..e49768cBinary files /dev/null and b/ui/design/bots/yellow.webp differdiff --git a/ui/design/components/avatar.css b/ui/design/components/avatar.cssnew file mode 100644index 0000000..99ef75d--- /dev/null+++ b/ui/design/components/avatar.css@@ -0,0 +1,513 @@+/* 机器人头像:6 个内置毛绒角色,精灵图 ui/design/bots/<角色>.webp 由 scripts/build-bot-avatars.py 拆层生成。+ 结构 .bot-face > .bf-shadow + .bf-aura + .bf-body(持续状态)> .bf-shot(一次性反应)> .bf-look(看指针)+ > 耳朵 / 配件(.bf-part > .bf-pin > .bf-img + .bf-glow)+ 头 + 腮红 + 眼睛 SVG + 粒子+ 属性 data-char 角色;data-state 持续状态;data-shot 一次性反应;data-eyes 当前表情(都由 avatar.js 写)+ 分工 外层 .bf-part 放持续状态的循环(transform)和姿势(rotate,比如竖耳朵、耷拉),内层 .bf-pin 放一次性反应,+ 两者叠加互不覆盖。空闲的列表头像不自己动:只在指针靠近时看过去、悬停时抖一下天线;lively(大头像)才会呼吸、眨眼、张望。+ 角色颜色(--bot-*)是原画的颜色,两个主题相同,所以直接用 primitives;随主题变的只有光晕和影子(--avatar-*)。 */+.bot-face {+ --look-x: 0;+ --look-y: 0;+ --bf-eye: var(--bot-blue-eye);+ --bf-glow: var(--bot-blue-glow);+ /* 循环周期 */+ --bf-blink: 4.2s; /* 眨眼间隔 */+ --bf-blink-spread: -4s; /* 按 --bf-seed 错开,几个头像不会一起眨眼 */+ --bf-breathe: 3.4s; /* 大头像空闲时的呼吸 */+ --bf-glance: 7s; /* 大头像空闲时四处看 */+ --bf-nod: 1.6s; /* 你在输入时点头 */+ --bf-ponder: 2.6s; /* 思考:歪头、眼睛看左上右上 */+ --bf-read: 1.4s; /* 回复:眼睛像读行一样左右扫 */+ --bf-bob: .9s; /* 工作中上下浮动 */+ --bf-hop: 2.4s; /* 等你批准:跳两下停一下 */+ --bf-snore: 3.6s; /* 睡觉 */+ --bf-perk: .9s; /* 悬停时天线弹一下 */+ --bf-ring: 1.5s; /* 小蓝的天线信号 */+ --bf-ring-gap: .5s;+ --bf-sway: .55s; /* 天线、角左右晃 */+ --bf-twinkle: 1.3s; /* 小萌的星星、紫钻的闪光 */+ --bf-flutter: .9s; /* 绿草的叶子 */+ --bf-beat: .6s; /* 红魔的灯带节拍 */+ --bf-spin: 3.2s; /* 紫钻的宝石转动 */+ --bf-float: 2.2s; /* 紫钻的宝石悬浮 */+ --bf-sweep: 2.2s; /* 探险者护目镜的反光 */+ --bf-scan: 1.6s; /* 探险者四处搜寻 */+ --bf-dot: 1.2s; /* 思考气泡里的点 */+ --bf-bang: 1.2s;+ --bf-z: 3s;+ --bf-orbit: .9s;+ position: relative; flex: none; width: var(--s); height: var(--s);+ -webkit-user-select: none; user-select: none;+}+.bot-face[data-char="yellow"] { --bf-eye: var(--bot-yellow-eye); --bf-glow: var(--bot-yellow-glow); }+.bot-face[data-char="green"] { --bf-eye: var(--bot-green-eye); --bf-glow: var(--bot-green-glow); }+.bot-face[data-char="red"] { --bf-eye: var(--bot-red-eye); --bf-glow: var(--bot-red-glow); }+.bot-face[data-char="purple"] { --bf-eye: var(--bot-purple-eye); --bf-glow: var(--bot-purple-glow); }+.bot-face[data-char="orange"] { --bf-eye: var(--bot-orange-eye); --bf-glow: var(--bot-orange-glow); }+.bot-face.pokeable { cursor: pointer; }+.bot-face.neutral { filter: grayscale(1) contrast(.85) brightness(1.06); opacity: .5; }++/* —— 图层 —— */+.bf-shadow, .bf-body, .bf-shot, .bf-look, .bf-part, .bf-pin, .bf-img, .bf-glow { position: absolute; inset: 0; }+.bf-body, .bf-shot { transform-origin: 50% 89%; }+.bf-look {+ transform-origin: 50% 60%;+ transform: translate(calc(var(--look-x) * var(--s) * .03), calc(var(--look-y) * var(--s) * .018)) rotate(calc(var(--look-x) * 3deg));+ transition: transform var(--dur-moderate) var(--ease-out);+}+.bf-img, .bf-glow { background: var(--bf-sprite) 0 0 / 800% 100% no-repeat; }+.bf-ear-l .bf-img { background-position-x: calc(100% / 7); }+.bf-ear-r .bf-img { background-position-x: calc(200% / 7); }+.bf-top .bf-img { background-position-x: calc(300% / 7); }+.bf-head .bf-glow { background-position-x: calc(400% / 7); }+.bf-ear-l .bf-glow { background-position-x: calc(500% / 7); }+.bf-ear-r .bf-glow { background-position-x: calc(600% / 7); }+.bf-top .bf-glow { background-position-x: 100%; }+.bf-glow { opacity: 0; mix-blend-mode: plus-lighter; filter: drop-shadow(0 0 calc(var(--s) * .03) var(--bf-glow)); }+.bot-face:not([data-char="red"], [data-char="purple"]) .bf-glow { display: none; } /* 只有红魔、紫钻有发光层 */+.bf-ear-l, .bf-ear-l .bf-pin { transform-origin: var(--o-el); }+.bf-ear-r, .bf-ear-r .bf-pin { transform-origin: var(--o-er); }+.bf-top, .bf-top .bf-pin, .bf-top .bf-img { transform-origin: var(--o-top); }+.bf-part { transition: rotate var(--dur-slow) var(--ease-back), filter var(--dur-moderate) var(--ease-out); }++.bf-aura {+ position: absolute; inset: -14%; border-radius: 50%; opacity: 0;+ background: radial-gradient(closest-side, color-mix(in srgb, var(--bf-glow) var(--avatar-aura), transparent) 35%, transparent);+ transition: opacity var(--dur-moderate) var(--ease-out);+}+.bf-shadow {+ inset: auto 23% 3% 23%; height: 8%; border-radius: 50%;+ background: radial-gradient(closest-side, var(--avatar-shadow), transparent);+}++/* 腮红:开心时在面罩上亮起来 */+.bf-blush {+ position: absolute; width: 9%; height: 4.4%; translate: -50% -50%; border-radius: 50%;+ background: radial-gradient(closest-side, color-mix(in srgb, var(--bot-blush) 70%, var(--bf-glow)), transparent);+ opacity: 0; scale: .5;+ transition: opacity var(--dur-base) var(--ease-out), scale var(--dur-moderate) var(--ease-back);+}+.bot-face:is([data-eyes="happy"], [data-eyes="heart"]) .bf-blush { opacity: .9; scale: 1; }++/* 探险者的护目镜:镜片上扫过一道反光 */+.bf-lens { position: absolute; width: var(--lens); aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; overflow: hidden; }+.bf-lens::after {+ content: ""; position: absolute; inset: -30%; translate: -110% 0;+ background: linear-gradient(115deg, transparent 38%, var(--bot-glint) 50%, transparent 62%);+}++/* —— 眼睛与表情:坐标同 viewBox 0–100,每只眼睛以自己的中心为原点,右眼是镜像 —— */+.bf-eyes { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 calc(var(--s) * .028) var(--bf-glow)); }+.bf-gaze { transform: translate(calc(var(--look-x) * 2.4px), calc(var(--look-y) * 1.6px)); transition: transform var(--dur-fast) var(--ease-out); }+.bf-glance { transition: transform var(--dur-moderate) var(--ease-out); }+.bf-lid { transform-box: view-box; transform-origin: 0 0; transition: scale var(--dur-base) var(--ease-back); }+.bf-eyes .e {+ fill: var(--bf-eye); opacity: 0; scale: .3;+ transform-box: view-box; transform-origin: 0 0;+ transition: opacity var(--dur-fast) var(--ease-out), scale var(--dur-base) var(--ease-back);+}+.bf-eyes .line { fill: none; stroke: var(--bf-eye); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }+.bf-eyes .thin { stroke-width: 1.15; }+.bot-face[data-eyes="open"] .e-open,+.bot-face[data-eyes="happy"] .e-happy,+.bot-face[data-eyes="closed"] .e-closed,+.bot-face[data-eyes="heart"] .e-heart,+.bot-face[data-eyes="spiral"] .e-spiral { opacity: 1; scale: 1; }+.bot-face[data-eyes="spiral"] .e-spiral { animation: spin var(--dur-spin) linear infinite; }+.bot-face[data-eyes="heart"] .e-heart { animation: bf-heartbeat var(--bf-beat) var(--ease-in-out) infinite alternate; }+.bot-face[data-eyes="error"] .e-x { animation: bf-eye-x var(--bot-error) var(--ease-out) both; }+.bot-face[data-eyes="error"] .e-sad { animation: bf-eye-sad var(--bot-error) var(--ease-out) both; }+@keyframes bf-eye-x { 0%, 42% { opacity: 1; scale: 1; } 52%, 100% { opacity: 0; scale: .3; } }+@keyframes bf-eye-sad { 0%, 44% { opacity: 0; scale: .3; rotate: -14deg; } 58%, 100% { opacity: 1; scale: 1; rotate: -14deg; } }+@keyframes bf-heartbeat { to { scale: 1.25; } }+@keyframes bf-blink { 0%, 91%, 100% { transform: none; } 94.5% { transform: scaleY(.08); } }++/* —— 持续状态 —— */+/* 眨眼:大头像空闲时,以及所有"醒着做事"的状态 */+.bot-face.lively .bf-lid,+.bot-face:is([data-state="listening"], [data-state="thinking"], [data-state="replying"], [data-state="working"], [data-state="waiting"]) .bf-lid {+ animation: bf-blink var(--bf-blink) var(--ease-in-out) calc(var(--bf-seed) * var(--bf-blink-spread)) infinite;+}++/* 空闲(lively):呼吸、偶尔看看左右、天线轻轻晃 */+.bot-face.lively { --avatar-aura: 18%; }+.bot-face.lively .bf-aura { opacity: .7; }+.bot-face.lively[data-state="idle"] .bf-body { animation: bf-breathe var(--bf-breathe) var(--ease-in-out) infinite; }+.bot-face.lively[data-state="idle"] .bf-glance { animation: bf-glance-idle var(--bf-glance) var(--ease-in-out) calc(var(--bf-seed) * var(--bf-blink-spread)) infinite; }+.bot-face.lively[data-state="idle"] .bf-top { animation: bf-sway-soft var(--bf-breathe) var(--ease-in-out) infinite alternate; }+@keyframes bf-breathe { 50% { transform: translateY(-1.2%) scale(.994, 1.012); } }+@keyframes bf-glance-idle {+ 0%, 34%, 56%, 74%, 94%, 100% { transform: none; }+ 38%, 52% { transform: translate(-2px, .4px); }+ 78%, 90% { transform: translate(2px, -.8px); }+}+@keyframes bf-sway-soft { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }++/* 你在输入:竖起耳朵、眼睛看向输入框、轻轻点头 */+.bot-face[data-state="listening"] .bf-body { animation: bf-nod var(--bf-nod) var(--ease-in-out) infinite; }+.bot-face[data-state="listening"] .bf-glance { transform: translate(0, 1.4px); }+.bot-face[data-state="listening"] .bf-ear-l { rotate: 7deg; }+.bot-face[data-state="listening"] .bf-ear-r { rotate: -7deg; }+@keyframes bf-nod { 0%, 45%, 100% { transform: none; } 15% { transform: translateY(1.6%) scale(1.01, .98); } 30% { transform: translateY(-.6%); } }++/* 思考(还没出字):歪着头,眼睛在左上和右上之间找答案,背后发光,头上冒思考泡泡 */+.bot-face[data-state="thinking"] .bf-body { animation: bf-ponder var(--bf-ponder) var(--ease-in-out) infinite; }+.bot-face[data-state="thinking"] .bf-glance { animation: bf-glance-think var(--bf-ponder) var(--ease-in-out) infinite; }+@keyframes bf-ponder { 0%, 100% { transform: rotate(-4deg); } 50% { transform: translateY(-1.5%) rotate(4deg); } }+@keyframes bf-glance-think {+ 0%, 40%, 100% { transform: translate(-1.8px, -1.5px); }+ 52%, 88% { transform: translate(1.8px, -1.5px); }+}++/* 回复 / 工作中:上下浮动,眼睛眯起来专注地左右扫 */+.bot-face:is([data-state="replying"], [data-state="working"]) .bf-body { animation: bf-bob var(--bf-bob) var(--ease-in-out) infinite; }+.bot-face:is([data-state="replying"], [data-state="working"]) .bf-glance { animation: bf-glance-read var(--bf-read) linear infinite; }+.bot-face:is([data-state="replying"], [data-state="working"]) .bf-lid { scale: 1 .62; }+@keyframes bf-bob { 50% { transform: translateY(-3.5%); } }+@keyframes bf-glance-read {+ 0%, 100% { transform: translate(-1.8px, 0); }+ 72% { transform: translate(1.8px, 0); }+ 84% { transform: translate(1.8px, .8px); }+}++/* 思考、回复、工作、等待:背后的辉光一起一伏 */+.bot-face:is([data-state="thinking"], [data-state="replying"], [data-state="working"], [data-state="waiting"]) .bf-aura {+ opacity: 1; animation: bf-aura-pulse var(--bf-ponder) var(--ease-in-out) infinite;+}+@keyframes bf-aura-pulse { 0%, 100% { opacity: .55; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.04); } }++/* 等你批准:睁大眼睛看着你,跳两下停一下,头顶一个感叹号 */+.bot-face[data-state="waiting"] .bf-body { animation: bf-hop var(--bf-hop) var(--ease-out) infinite; }+.bot-face[data-state="waiting"] .bf-shadow { animation: bf-shadow-hop var(--bf-hop) var(--ease-out) infinite; }+.bot-face[data-state="waiting"] .bf-lid { scale: 1.2; }+.bot-face[data-state="waiting"] .bf-ear-l { rotate: 12deg; }+.bot-face[data-state="waiting"] .bf-ear-r { rotate: -12deg; }+@keyframes bf-hop {+ 0%, 44%, 100% { transform: none; }+ 6% { transform: scale(1.06, .92); }+ 14% { transform: translateY(-11%) scale(.96, 1.05); }+ 22% { transform: scale(1.05, .94); }+ 29% { transform: translateY(-6%); }+ 36% { transform: scale(1.02, .98); }+}+@keyframes bf-shadow-hop { 0%, 44%, 100% { transform: none; } 14% { transform: scale(.7); opacity: .5; } 29% { transform: scale(.85); } }++/* 睡觉:闭眼、歪头、耳朵和配件耷拉下来,冒 z */+.bot-face[data-state="sleep"] .bf-body { rotate: -6deg; animation: bf-snore var(--bf-snore) var(--ease-in-out) infinite; }+.bot-face[data-state="sleep"] .bf-ear-l { rotate: -9deg; }+.bot-face[data-state="sleep"] .bf-ear-r { rotate: 9deg; }+.bot-face[data-state="sleep"] .bf-top { rotate: 14deg; }+.bot-face[data-state="sleep"] .bf-eyes { filter: none; opacity: .75; }+@keyframes bf-snore { 50% { transform: scale(1.025, .975); } }++/* —— 一次性反应(.bf-shot 每次重新挂载,动画从头播) —— */+.bot-face[data-shot="hello"] .bf-shot { animation: bf-hello var(--bot-hello) var(--ease-out) both; }+.bot-face[data-shot="done"] .bf-shot { animation: bf-done var(--bot-done) var(--ease-out) both; }+.bot-face[data-shot="error"] .bf-shot { animation: bf-error var(--bot-error) var(--ease-out) both; }+.bot-face[data-shot="poke"] .bf-shot { animation: bf-poke var(--bot-poke) var(--ease-out) both; }+.bot-face[data-shot="love"] .bf-shot { animation: bf-love var(--bot-love) var(--ease-in-out) both; }+.bot-face[data-shot="dizzy"] .bf-shot { animation: bf-dizzy var(--bot-dizzy) var(--ease-in-out) both; }+.bot-face[data-shot="done"] .bf-shadow { animation: bf-shadow-done var(--bot-done) var(--ease-out) both; }+.bot-face[data-shot="hello"] .bf-shadow { animation: bf-shadow-hello var(--bot-hello) var(--ease-out) both; }+.bot-face:is([data-shot="hello"], [data-shot="done"], [data-shot="love"]) .bf-aura { opacity: 1; animation: bf-aura-flash var(--bot-done) var(--ease-out) both; }+@keyframes bf-hello {+ 0% { opacity: 0; transform: translateY(14%) scale(0); }+ 22% { opacity: 1; transform: scale(1.14, .88); }+ 34% { transform: translateY(-9%) scale(.94, 1.08); }+ 46% { transform: none; }+ 58% { transform: rotate(-9deg); }+ 70% { transform: rotate(8deg); }+ 82% { transform: rotate(-5deg); }+ 92% { transform: rotate(2deg); }+ 100% { transform: none; }+}+@keyframes bf-done {+ 0%, 100% { transform: none; }+ 14% { transform: scale(1.12, .84); }+ 36% { transform: translateY(-24%) scale(.92, 1.1) rotate(-5deg); }+ 52% { transform: translateY(-26%) rotate(5deg); }+ 70% { transform: scale(1.12, .86); }+ 84% { transform: scale(.96, 1.05); }+}+@keyframes bf-error {+ 0%, 100% { transform: none; }+ 8% { transform: translateX(-8%) rotate(-7deg); }+ 18% { transform: translateX(7%) rotate(6deg); }+ 28% { transform: translateX(-5%) rotate(-4deg); }+ 38% { transform: translateX(3%) rotate(2deg); }+ 48% { transform: none; }+ 62%, 86% { transform: translateY(3%) scale(1.03, .95); }+}+@keyframes bf-poke {+ 0%, 100% { transform: none; }+ 16% { transform: scale(1.18, .8); }+ 38% { transform: translateY(-8%) scale(.9, 1.12); }+ 58% { transform: scale(1.05, .95); }+ 76% { transform: scale(.98, 1.02); }+}+@keyframes bf-love {+ 0%, 100% { transform: none; }+ 12% { transform: scale(1.1, .9); }+ 26% { transform: translateY(-6%) scale(.96, 1.05) rotate(-6deg); }+ 40% { transform: rotate(6deg); }+ 54% { transform: translateY(-4%) rotate(-5deg); }+ 68% { transform: rotate(4deg); }+ 84% { transform: rotate(-2deg); }+}+@keyframes bf-dizzy {+ 0%, 100% { transform: none; }+ 10% { transform: translateX(-5%) rotate(-12deg); }+ 22% { transform: translateX(5%) rotate(11deg); }+ 34% { transform: translateX(-4%) rotate(-10deg); }+ 46% { transform: translateX(3%) rotate(8deg); }+ 58% { transform: translateX(-2%) rotate(-6deg); }+ 70% { transform: rotate(4deg); }+ 82% { transform: rotate(-2deg); }+}+@keyframes bf-shadow-done { 0%, 100% { transform: none; } 36%, 52% { transform: scale(.55); opacity: .4; } 70% { transform: scale(1.1); } }+@keyframes bf-shadow-hello { 0% { transform: scale(0); } 22% { transform: scale(1.1); } 34% { transform: scale(.8); } 46%, 100% { transform: none; } }+@keyframes bf-aura-flash { 0% { opacity: 0; transform: scale(.6); } 30% { opacity: 1; transform: scale(1.12); } 100% { opacity: 0; transform: scale(1); } }++/* 耳朵和配件跟着一次性反应动:天线弹簧、耳朵扇两下;悬停时也弹一下(打招呼) */+@keyframes bf-spring {+ 0%, 100% { transform: none; }+ 14% { transform: rotate(-16deg); }+ 30% { transform: rotate(13deg); }+ 46% { transform: rotate(-8deg); }+ 62% { transform: rotate(5deg); }+ 78% { transform: rotate(-2deg); }+}+@keyframes bf-flap-l { 0%, 100% { transform: none; } 25% { transform: rotate(16deg); } 50% { transform: rotate(-6deg); } 75% { transform: rotate(5deg); } }+@keyframes bf-flap-r { 0%, 100% { transform: none; } 25% { transform: rotate(-16deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-5deg); } }+.bot-face.pokeable:hover:not([data-shot]) .bf-top .bf-pin,+.bot-hover:hover .bot-face:not([data-shot]) .bf-top .bf-pin { animation: bf-spring var(--bf-perk) var(--ease-out); }+.bot-face.pokeable:hover:not([data-shot]) .bf-ear-l .bf-pin,+.bot-hover:hover .bot-face:not([data-shot]) .bf-ear-l .bf-pin { animation: bf-flap-l var(--bf-perk) var(--ease-out); }+.bot-face.pokeable:hover:not([data-shot]) .bf-ear-r .bf-pin,+.bot-hover:hover .bot-face:not([data-shot]) .bf-ear-r .bf-pin { animation: bf-flap-r var(--bf-perk) var(--ease-out); }+.bot-face:is([data-shot="hello"], [data-shot="done"], [data-shot="poke"], [data-shot="love"], [data-shot="dizzy"]) .bf-top .bf-pin { animation: bf-spring var(--bot-done) var(--ease-out); }+.bot-face:is([data-shot="hello"], [data-shot="done"], [data-shot="poke"], [data-shot="love"]) .bf-ear-l .bf-pin { animation: bf-flap-l var(--bot-poke) var(--ease-out); }+.bot-face:is([data-shot="hello"], [data-shot="done"], [data-shot="poke"], [data-shot="love"]) .bf-ear-r .bf-pin { animation: bf-flap-r var(--bot-poke) var(--ease-out); }+.bot-face[data-shot="error"] .bf-ear-l { rotate: -10deg; }+.bot-face[data-shot="error"] .bf-ear-r { rotate: 10deg; }+.bot-face[data-shot="error"] .bf-top { rotate: 12deg; }++/* —— 角色的招牌动作 —— */+/* 小蓝:天线左右晃、天线球亮起来、一圈圈发出信号;完成时天线球闪一下 */+.bot-face[data-char="blue"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top { animation: bf-sway var(--bf-sway) var(--ease-in-out) infinite alternate; }+.bot-face[data-char="blue"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top .bf-img { animation: bf-bulb var(--bf-ring) var(--ease-in-out) infinite; }+.bot-face[data-char="blue"]:is([data-shot="done"], [data-shot="hello"]) .bf-top .bf-img { animation: bf-bulb var(--bot-poke) var(--ease-out) 2; }+@keyframes bf-sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }+@keyframes bf-bulb { 0%, 100% { filter: none; } 40% { filter: brightness(1.45) drop-shadow(0 0 calc(var(--s) * .05) var(--bf-glow)); } }++/* 小萌:星星一闪一闪、身边冒小星星;完成时星星像硬币一样转两圈 */+.bot-face[data-char="yellow"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top { animation: bf-twinkle var(--bf-twinkle) var(--ease-in-out) infinite; }+.bot-face[data-char="yellow"]:is([data-shot="done"], [data-shot="hello"], [data-shot="love"]) .bf-top .bf-pin { animation: bf-coin var(--bot-done) var(--ease-out); }+@keyframes bf-twinkle {+ 0%, 100% { transform: none; filter: none; }+ 30% { transform: rotate(-10deg) scale(1.08); filter: brightness(1.25) drop-shadow(0 0 calc(var(--s) * .04) var(--bf-glow)); }+ 60% { transform: rotate(8deg) scale(1.03); }+}+@keyframes bf-coin {+ 0% { transform: perspective(calc(var(--s) * 2)) translateY(0) rotateY(0); }+ 60% { transform: perspective(calc(var(--s) * 2)) translateY(-5%) rotateY(720deg); }+ 100% { transform: perspective(calc(var(--s) * 2)) translateY(0) rotateY(720deg); }+}++/* 绿草:叶子像被风吹一样扑簌;完成时嫩芽长高一截、飘下一片叶子;出错时蔫了 */+.bot-face[data-char="green"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top { animation: bf-flutter var(--bf-flutter) var(--ease-in-out) infinite; }+.bot-face[data-char="green"]:is([data-shot="done"], [data-shot="hello"]) .bf-top .bf-pin { animation: bf-grow var(--bot-done) var(--ease-out); }+.bot-face[data-char="green"][data-shot="error"] .bf-top { rotate: 22deg; scale: 1 .86; }+@keyframes bf-flutter { 0%, 100% { transform: rotate(-6deg) skewX(3deg); } 50% { transform: rotate(6deg) skewX(-3deg); } }+@keyframes bf-grow {+ 0%, 100% { transform: none; }+ 30% { transform: scale(1.3) rotate(-6deg); }+ 50% { transform: scale(.92) rotate(4deg); }+ 68% { transform: scale(1.1); }+ 84% { transform: scale(.98); }+}++/* 红魔:耳机灯带跟着节拍亮(左耳 → 角 → 右耳),耳机一下一下地震;完成时灯带闪三下;出错时灯带乱闪 */+.bot-face[data-char="red"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-glow { animation: bf-beat var(--bf-beat) var(--ease-out) infinite; }+.bot-face[data-char="red"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top .bf-glow { animation-delay: calc(var(--bf-beat) / 3); }+.bot-face[data-char="red"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-ear-r .bf-glow { animation-delay: calc(var(--bf-beat) * 2 / 3); }+.bot-face[data-char="red"]:is([data-state="replying"], [data-state="working"]) .bf-ear-l { animation: bf-thump var(--bf-beat) var(--ease-out) infinite; }+.bot-face[data-char="red"]:is([data-state="replying"], [data-state="working"]) .bf-ear-r { animation: bf-thump var(--bf-beat) var(--ease-out) infinite; }+.bot-face[data-char="red"][data-state="thinking"] .bf-top { animation: bf-sway var(--bf-sway) var(--ease-in-out) infinite alternate; }+.bot-face[data-char="red"]:is([data-shot="done"], [data-shot="hello"]) .bf-glow { animation: bf-flash3 var(--bot-done) linear both; }+.bot-face[data-char="red"][data-shot="error"] .bf-glow { animation: bf-flicker var(--bot-error) steps(1) both; }+@keyframes bf-beat { 0%, 100% { opacity: .1; } 18% { opacity: 1; } }+@keyframes bf-thump { 0%, 100% { transform: none; } 18% { transform: scale(1.05); } }+@keyframes bf-flash3 { 0%, 30%, 62%, 100% { opacity: 0; } 14%, 46%, 78% { opacity: 1; } }+@keyframes bf-flicker { 0%, 12%, 30%, 44%, 70% { opacity: 1; } 6%, 22%, 38%, 58%, 100% { opacity: 0; } }++/* 紫钻:宝石浮起来慢慢转、霓虹线一明一暗、身边闪光;完成时宝石飞快转两圈;出错时霓虹乱闪 */+.bot-face[data-char="purple"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top { animation: bf-levitate var(--bf-float) var(--ease-in-out) infinite alternate; }+.bot-face[data-char="purple"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top .bf-img { animation: bf-gem var(--bf-spin) linear infinite; }+.bot-face[data-char="purple"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-glow { animation: bf-neon var(--bf-float) var(--ease-in-out) infinite alternate; }+.bot-face[data-char="purple"]:is([data-shot="done"], [data-shot="hello"], [data-shot="love"]) .bf-top .bf-pin { animation: bf-coin var(--bot-done) var(--ease-out); }+.bot-face[data-char="purple"]:is([data-shot="done"], [data-shot="hello"]) .bf-glow { animation: bf-flash3 var(--bot-done) linear both; }+.bot-face[data-char="purple"][data-shot="error"] .bf-glow { animation: bf-flicker var(--bot-error) steps(1) both; }+.bot-face[data-char="purple"][data-state="sleep"] .bf-top { rotate: 0deg; filter: brightness(.7) saturate(.6); }+@keyframes bf-levitate { from { transform: translateY(-2%); } to { transform: translateY(-6%); } }+@keyframes bf-gem { from { transform: perspective(calc(var(--s) * 2)) rotateY(0); } to { transform: perspective(calc(var(--s) * 2)) rotateY(360deg); } }+@keyframes bf-neon { from { opacity: .15; } to { opacity: .9; } }++/* 探险者:天线一蹦一蹦、眼睛大范围地左右搜寻、护目镜反光;完成时两只镜片一起闪 */+.bot-face[data-char="orange"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-top { animation: bf-sway var(--bf-sway) var(--ease-back) infinite alternate; }+.bot-face[data-char="orange"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-glance { animation: bf-scan var(--bf-scan) var(--ease-in-out) infinite alternate; }+.bot-face[data-char="orange"]:is([data-state="thinking"], [data-state="replying"], [data-state="working"]) .bf-lens::after { animation: bf-glint var(--bf-sweep) var(--ease-in-out) infinite; }+.bot-face[data-char="orange"].lively[data-state="idle"] .bf-lens::after { animation: bf-glint var(--bf-glance) var(--ease-in-out) infinite; }+.bot-face[data-char="orange"]:is([data-shot="done"], [data-shot="hello"]) .bf-lens::after { animation: bf-glint var(--bot-poke) var(--ease-out) both; }+.bot-face[data-char="orange"] .bf-lens + .bf-lens::after { animation-delay: calc(var(--bf-sweep) / 12); }+@keyframes bf-scan { from { transform: translate(-2.6px, -.3px); } to { transform: translate(2.6px, -.3px); } }+@keyframes bf-glint { 0%, 55% { translate: -110% 0; } 85%, 100% { translate: 110% 0; } }++/* —— 粒子(≥ 36px 才画) —— */+.bot-face .fx, .bot-face .fx i { position: absolute; display: block; pointer-events: none; }+.fx-rings { left: var(--tip-x); top: var(--tip-y); }+.fx-rings i {+ width: calc(var(--s) * .22); aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; opacity: 0;+ border: calc(var(--s) * .016) solid var(--bf-glow);+ animation: bf-ring var(--bf-ring) var(--ease-out) infinite;+}+.fx-rings i:nth-child(2) { animation-delay: var(--bf-ring-gap); }+.fx-rings i:nth-child(3) { animation-delay: calc(var(--bf-ring-gap) * 2); }+@keyframes bf-ring { 0% { opacity: .9; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.4); } }++.fx-twinkle { left: var(--tip-x); top: var(--tip-y); }+.fx-twinkle i {+ width: calc(var(--s) * .07); aspect-ratio: 1; translate: -50% -50%; scale: 0;+ background: var(--bf-eye); filter: drop-shadow(0 0 calc(var(--s) * .02) var(--bf-glow));+ clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);+ animation: bf-sparkle var(--bf-twinkle) var(--ease-in-out) infinite;+}+.fx-twinkle i:nth-child(1) { left: calc(var(--s) * -.17); top: calc(var(--s) * -.04); }+.fx-twinkle i:nth-child(2) { left: calc(var(--s) * .16); top: calc(var(--s) * -.09); animation-delay: calc(var(--bf-twinkle) / 3); }+.fx-twinkle i:nth-child(3) { left: calc(var(--s) * .12); top: calc(var(--s) * .07); animation-delay: calc(var(--bf-twinkle) * 2 / 3); }+@keyframes bf-sparkle { 0%, 100% { scale: 0; rotate: 0deg; } 50% { scale: 1; rotate: 45deg; } }++/* 思考泡泡 */+.fx-think {+ right: -14%; top: 0; width: 38%; height: 20%; border-radius: var(--r-full);+ display: flex; align-items: center; justify-content: center; gap: 9%;+ background: var(--surface-solid); box-shadow: var(--shadow-sm);+ --pop-dy: 4px; animation: fade-in var(--dur-base) var(--ease-out), pop-in var(--dur-slower) var(--ease-spring);+}+.bot-face .fx-think i { position: static; width: 16%; aspect-ratio: 1; border-radius: 50%; background: var(--muted); animation: bf-dot var(--bf-dot) var(--ease-in-out) infinite; }+.fx-think i:nth-child(2) { animation-delay: calc(var(--bf-dot) / 6); }+.fx-think i:nth-child(3) { animation-delay: calc(var(--bf-dot) / 3); }+@keyframes bf-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-40%); opacity: 1; } }++/* 等你批准的感叹号 */+.fx-bang {+ right: -6%; top: -4%; width: 28%; aspect-ratio: 1; border-radius: 50%;+ display: grid; place-items: center; background: var(--amber); color: var(--surface-solid);+ font-size: calc(var(--s) * .2); font-weight: var(--fw-semibold); line-height: 1;+ box-shadow: 0 0 0 calc(var(--s) * .03) var(--surface-solid);+ transform-origin: 50% 100%; animation: bf-bang var(--bf-bang) var(--ease-in-out) infinite;+}+@keyframes bf-bang { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg) scale(1.1); } }++/* 睡觉的 z */+.fx-zzz { right: 4%; top: 6%; }+.fx-zzz i {+ font-size: calc(var(--s) * .16); font-style: normal; font-weight: var(--fw-semibold); color: var(--muted); opacity: 0;+ animation: bf-z var(--bf-z) var(--ease-out) infinite;+}+.fx-zzz i:nth-child(2) { animation-delay: calc(var(--bf-z) / 3); }+.fx-zzz i:nth-child(3) { animation-delay: calc(var(--bf-z) * 2 / 3); }+@keyframes bf-z {+ 0% { opacity: 0; transform: scale(.5); }+ 20% { opacity: 1; }+ 100% { opacity: 0; transform: translate(calc(var(--s) * .2), calc(var(--s) * -.32)) scale(1.15) rotate(12deg); }+}++/* 完成 / 打招呼 / 爱心:一圈闪光炸开 */+.fx-burst { left: 50%; top: 48%; filter: drop-shadow(0 0 calc(var(--s) * .02) var(--bf-glow)); }+.fx-burst i {+ width: calc(var(--s) * .1); aspect-ratio: 1; translate: -50% -50%; opacity: 0;+ background: var(--bf-eye);+ clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);+ animation: bf-burst var(--bot-done) var(--ease-out) both;+}+.fx-burst i:nth-child(odd) { --far: .7; width: calc(var(--s) * .07); }+.bot-face[data-shot="hello"] .fx-burst i { animation-name: bf-burst-late; animation-duration: var(--bot-hello); }+.bot-face[data-shot="love"] .fx-burst i { background: var(--bot-blush); }+@keyframes bf-burst {+ 0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(0); }+ 65% { opacity: 1; }+ 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--s) * -.62 * var(--far, 1))) scale(1) rotate(90deg); }+}+@keyframes bf-burst-late {+ 0%, 22% { opacity: 0; transform: rotate(var(--a)) translateY(0) scale(0); }+ 30% { opacity: 1; }+ 80% { opacity: 1; }+ 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--s) * -.62 * var(--far, 1))) scale(1) rotate(90deg); }+}++/* 绿草长高时飘下来的叶子 */+.fx-leaf {+ left: var(--tip-x); top: var(--tip-y); width: calc(var(--s) * .12); height: calc(var(--s) * .07);+ border-radius: 0 100%; background: color-mix(in srgb, var(--bf-glow) 60%, var(--bf-eye));+ animation: bf-leaf var(--bot-done) var(--ease-in-out) both;+}+@keyframes bf-leaf {+ 0% { opacity: 0; transform: translate(0, 0) rotate(0); }+ 20% { opacity: 1; }+ 100% { opacity: 0; transform: translate(calc(var(--s) * .42), calc(var(--s) * .22)) rotate(200deg); }+}++/* 连戳三下:冒爱心 */+.fx-hearts { left: 50%; top: 18%; }+.fx-hearts i {+ font-size: calc(var(--s) * .16); font-style: normal; line-height: 1; color: var(--bot-blush); opacity: 0;+ animation: bf-heart-up var(--bot-love) var(--ease-out) both;+}+.fx-hearts i::before { content: "♥"; }+.fx-hearts i:nth-child(1) { --hx: -1; }+.fx-hearts i:nth-child(2) { --hx: .2; animation-delay: calc(var(--bot-love) / 6); }+.fx-hearts i:nth-child(3) { --hx: 1; animation-delay: calc(var(--bot-love) / 3); }+@keyframes bf-heart-up {+ 0% { opacity: 0; transform: translate(-50%, 0) scale(.4); }+ 25% { opacity: 1; transform: translate(calc(-50% + var(--hx) * var(--s) * .1), calc(var(--s) * -.12)) scale(1); }+ 100% { opacity: 0; transform: translate(calc(-50% + var(--hx) * var(--s) * .26), calc(var(--s) * -.42)) scale(.9); }+}++/* 戳晕了:头顶绕圈的小星星 */+.fx-orbit { left: 50%; top: 22%; }+.fx-orbit i {+ width: calc(var(--s) * .09); aspect-ratio: 1; margin: calc(var(--s) * -.045);+ background: var(--bot-yellow-glow);+ clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);+ animation: bf-orbit-x var(--bf-orbit) var(--ease-in-out) infinite alternate, bf-orbit-y var(--bf-orbit) var(--ease-in-out) calc(var(--bf-orbit) / -2) infinite alternate;+}+.fx-orbit i:nth-child(2) { animation-delay: calc(var(--bf-orbit) * -2 / 3), calc(var(--bf-orbit) * -2 / 3 - var(--bf-orbit) / 2); }+.fx-orbit i:nth-child(3) { animation-delay: calc(var(--bf-orbit) * -4 / 3), calc(var(--bf-orbit) * -4 / 3 - var(--bf-orbit) / 2); }+@keyframes bf-orbit-x { from { translate: calc(var(--s) * -.34) 0; } to { translate: calc(var(--s) * .34) 0; } }+@keyframes bf-orbit-y { from { transform: translateY(calc(var(--s) * -.07)) scale(.7); } to { transform: translateY(calc(var(--s) * .07)) scale(1.1); } }++/* 减少动态效果:只留表情变化,不动 */+@media (prefers-reduced-motion: reduce) {+ .bot-face, .bot-face * { animation: none !important; transition: none !important; }+ .bot-face .bf-look, .bot-face .bf-gaze { transform: none; }+ .bot-face .fx:not(.fx-bang, .fx-think) { display: none; }+ .bot-face[data-eyes="error"] .e-sad { opacity: 1; scale: 1; rotate: -14deg; }+}++/* —— 选角色 —— */+.avatar-picker { display: flex; flex-wrap: wrap; gap: var(--space-1); }+.avatar-opt {+ display: grid; justify-items: center; gap: var(--space-1); min-width: 64px; padding: var(--space-2-5) var(--space-1-5) var(--space-1-5);+ border-radius: var(--r-lg); color: var(--muted); font-size: var(--fs-xs);+ transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);+}+.avatar-opt:hover { background: var(--sel); color: var(--fg); }+.avatar-opt.on { background: var(--sel); color: var(--fg); font-weight: var(--fw-medium); box-shadow: inset 0 0 0 1.5px var(--accent); }++/* 应用自己的标志(不是 Modelflare 或其他任何人的 logo) */+.app-mark {+ display: grid; place-items: center; flex: none; border-radius: 30%;+ background: var(--accent-solid); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line);+}+.app-mark svg { width: 56%; height: 56%; }diff --git a/ui/design/components/badge.css b/ui/design/components/badge.cssnew file mode 100644index 0000000..a3c32aa--- /dev/null+++ b/ui/design/components/badge.css@@ -0,0 +1,19 @@+/* 状态徽标 .badge [ok | err | warn | off] [count],状态点 .dot [ok | err | warn]。+ 定制:覆盖 --badge-bg / --badge-fg。 */+.badge {+ --badge-bg: var(--pill);+ --badge-fg: var(--fg-2);+ display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-2); border-radius: var(--r-full);+ font-size: var(--fs-2xs); font-weight: var(--fw-medium); white-space: nowrap; flex: none;+ background: var(--badge-bg); color: var(--badge-fg);+}+.badge.ok { --badge-bg: var(--green-soft); --badge-fg: var(--green); }+.badge.err { --badge-bg: var(--red-soft); --badge-fg: var(--red); }+.badge.warn { --badge-bg: var(--amber-soft); --badge-fg: var(--amber); }+.badge.off { --badge-fg: var(--muted); }+.badge.count { height: 18px; min-width: 18px; padding: 0 5px; justify-content: center; font-variant-numeric: tabular-nums; }++.dot { --dot-bg: var(--faint); width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dot-bg); display: inline-block; }+.dot.ok { --dot-bg: var(--green); }+.dot.err { --dot-bg: var(--red); }+.dot.warn { --dot-bg: var(--amber); }diff --git a/ui/design/components/button.css b/ui/design/components/button.cssnew file mode 100644index 0000000..21ed0d7--- /dev/null+++ b/ui/design/components/button.css@@ -0,0 +1,81 @@+/* 按钮。.text 改编自 yetone/magpie internal/gui/assets/app.css(MIT,© 2026 yetone)。+ 定制方式:在变体或上下文里覆盖 --btn-* / --ib-* 变量,不要直接改属性。+ 状态(见 README「状态」):悬停叠一层、按下再深一级并轻微缩小、键盘焦点外描边、禁用变淡且不响应、+ 加载(aria-busy)保持本色只是不可点。 */++/* —— .btn [primary | ghost | danger] [sm | lg] [block] —— */+.btn {+ --btn-h: var(--ctl-md);+ --btn-px: var(--space-3);+ --btn-r: var(--r-md);+ --btn-fs: var(--fs-sm);+ --btn-bg: var(--pill);+ --btn-bg-hover: var(--pill-hover);+ --btn-bg-press: var(--pill-press);+ --btn-fg: var(--fg);+ --btn-fg-hover: var(--btn-fg);+ --btn-edge: 0 0 transparent;+ display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1-5);+ height: var(--btn-h); padding: 0 var(--btn-px); border-radius: var(--btn-r);+ font-size: var(--btn-fs); font-weight: var(--fw-medium); white-space: nowrap;+ background: var(--btn-bg); color: var(--btn-fg); box-shadow: var(--btn-edge);+ transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);+}+.btn:hover:not(:disabled) { background: var(--btn-bg-hover); color: var(--btn-fg-hover); }+.btn:active:not(:disabled) { background: var(--btn-bg-press); transform: scale(var(--press)); }+.btn:disabled { opacity: var(--o-disabled); }+/* 加载中:Button 的 loading 同时设 disabled 和 aria-busy——颜色不变,只是不可点 */+.btn[aria-busy="true"] { opacity: 1; cursor: progress; }+.btn .spinner { width: 14px; height: 14px; }++/* 主按钮:浅色墨底白字,深色黄绿底墨字;带一道顶边高光 */+.btn.primary {+ --btn-bg: var(--primary); --btn-bg-hover: var(--primary-hover); --btn-bg-press: var(--primary-press);+ --btn-fg: var(--on-primary); --btn-edge: var(--primary-edge);+}+/* 不可用时退成中性灰:半透明的墨色或黄绿都会发浑 */+.btn.primary:disabled:not([aria-busy="true"]) { --btn-bg: var(--pill); --btn-fg: var(--faint); --btn-edge: 0 0 transparent; opacity: 1; }+.btn.ghost { --btn-bg: transparent; --btn-bg-hover: var(--pill); --btn-bg-press: var(--pill-hover); --btn-fg: var(--ctl-fg); --btn-fg-hover: var(--fg); }+.btn.danger {+ --btn-bg: var(--red); --btn-bg-hover: color-mix(in srgb, var(--red) 88%, var(--fg)); --btn-bg-press: color-mix(in srgb, var(--red) 78%, var(--fg));+ --btn-fg: var(--on-danger); --btn-edge: inset 0 1px 0 color-mix(in srgb, var(--white) 16%, transparent);+}+.btn.sm { --btn-h: var(--ctl-sm); --btn-px: var(--space-2-5); }+.btn.lg { --btn-h: var(--ctl-xl); --btn-fs: var(--fs-md); --btn-r: var(--r-lg); }+.btn.block { width: 100%; }++/* —— 图标按钮 .icon-btn [xs] [on]:on / aria-expanded 是"打开着",比悬停深一级 —— */+.icon-btn {+ --ib-size: 26px;+ --ib-r: var(--r-md);+ --ib-fg: var(--muted);+ --ib-fg-hover: var(--fg);+ --ib-bg-hover: var(--pill);+ --ib-bg-on: var(--pill-hover);+ --ib-bg-press: var(--pill-press);+ width: var(--ib-size); height: var(--ib-size); border-radius: var(--ib-r); flex: none;+ display: inline-flex; align-items: center; justify-content: center;+ color: var(--ib-fg); transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);+}+.icon-btn:hover:not(:disabled) { background: var(--ib-bg-hover); color: var(--ib-fg-hover); }+.icon-btn.on:not(:disabled), .icon-btn[aria-expanded="true"]:not(:disabled) { background: var(--ib-bg-on); color: var(--ib-fg-hover); } /* 打开时悬停也保持打开的样子 */+.icon-btn:active:not(:disabled) { background: var(--ib-bg-press); transform: scale(var(--press-strong)); }+.icon-btn:disabled { opacity: var(--o-disabled); }+.icon-btn.xs { --ib-size: 18px; --ib-r: var(--r-sm); }++/* —— 文字按钮 .text [danger | accent] —— */+.text {+ font-size: var(--fs-sm); color: var(--ctl-fg); padding: 3px 7px; border-radius: var(--r-sm); white-space: nowrap;+ transition: background var(--t-fast), color var(--t-fast);+}+.text:hover:not(:disabled) { background: var(--pill); color: var(--fg); }+.text:active:not(:disabled) { background: var(--pill-hover); }+.text:disabled { opacity: var(--o-disabled); }+.text.danger { color: var(--red); }+.text.danger:hover:not(:disabled) { background: var(--red-soft); color: var(--red); }+.text.danger:active:not(:disabled) { background: color-mix(in srgb, var(--red) 18%, transparent); }+.text.accent { color: var(--accent); }+.text.accent:hover:not(:disabled) { color: var(--accent); }++/* 复制成功:变绿并弹一下 */+.icon-btn.copy.done { color: var(--green); background: var(--green-soft); animation: bump var(--dur-slow) var(--ease-out); }diff --git a/ui/design/components/feedback.css b/ui/design/components/feedback.cssnew file mode 100644index 0000000..4a52af8--- /dev/null+++ b/ui/design/components/feedback.css@@ -0,0 +1,15 @@+/* 加载与空状态:.spinner、.skel(骨架条)、.empty-state。 */+.spinner {+ width: 14px; height: 14px; border-radius: 50%; flex: none;+ border: 2px solid currentColor; border-right-color: transparent;+ animation: spin var(--dur-spin) linear infinite;+}+.skel {+ display: block; height: 12px; border-radius: var(--r-sm);+ background: linear-gradient(90deg, var(--pill) 0%, var(--pill-hover) 50%, var(--pill) 100%); background-size: 200% 100%;+ animation: shimmer var(--dur-shimmer) var(--ease-in-out) infinite;+}+.skel.circle { border-radius: 50%; }++.empty-state { padding: var(--space-8) var(--space-5); text-align: center; color: var(--muted); }+.empty-state b { display: block; color: var(--fg); font-weight: var(--fw-medium); margin-bottom: var(--space-1); }diff --git a/ui/design/components/field.css b/ui/design/components/field.cssnew file mode 100644index 0000000..5491857--- /dev/null+++ b/ui/design/components/field.css@@ -0,0 +1,33 @@+/* 输入框 .field [mono] [err],带尾部按钮的 .field-wrap > .field + .tail。+ 定制:覆盖 --field-*。+ 状态:悬停描边加深;聚焦 accent 描边 + --ring 光晕;错误(.err 或 aria-invalid)红描边,聚焦时红光晕;+ 只读是次级底、聚焦不发光;禁用变淡且不响应悬停。 */+.field {+ --field-h: var(--ctl-lg);+ --field-px: var(--space-2-5);+ --field-r: var(--r-md);+ --field-bg: var(--card);+ --field-edge: var(--line);+ --field-edge-hover: var(--line-strong);+ --field-edge-focus: var(--accent);+ --field-ring: var(--ring);+ width: 100%; height: var(--field-h); padding: 0 var(--field-px);+ border: 1px solid var(--field-edge); border-radius: var(--field-r);+ background: var(--field-bg); color: var(--fg); outline: none;+ transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);+}+.field::placeholder { color: var(--placeholder); }+.field:hover:not(:focus):not(:disabled):not([readonly]) { border-color: var(--field-edge-hover); }+.field:focus { border-color: var(--field-edge-focus); box-shadow: var(--field-ring); }+.field:focus-visible { outline: none; }+.field.mono { font-family: var(--code); font-size: var(--fs-sm); }+.field.err, .field[aria-invalid="true"] {+ --field-edge: var(--red); --field-edge-hover: var(--red); --field-edge-focus: var(--red); --field-ring: var(--ring-danger);+}+.field[readonly] { --field-bg: var(--card-2); --field-edge-focus: var(--line-strong); --field-ring: 0 0 transparent; }+.field:disabled { --field-bg: var(--card-2); opacity: var(--o-disabled); }+textarea.field { height: auto; padding: var(--space-2) var(--field-px); resize: none; line-height: var(--lh-normal); }++.field-wrap { position: relative; display: flex; align-items: center; }+.field-wrap .field { padding-right: 62px; }+.field-wrap .tail { position: absolute; right: var(--space-1); display: flex; gap: var(--space-0-5); }diff --git a/ui/design/components/glass.css b/ui/design/components/glass.cssnew file mode 100644index 0000000..69c26cc--- /dev/null+++ b/ui/design/components/glass.css@@ -0,0 +1,12 @@+/* 毛玻璃 .glass:半透明底 + 背景模糊 + 磨砂颗粒 + 顶边高光与细描边。+ 材质由三个变量决定(缺省是浮在内容上的输入框材质):+ --glass-bg 材质色:--glass-chrome | --glass-float | --glass-panel | --glass-pop | --glass-sheet+ --glass-blur 模糊:--glass-filter-sm | --glass-filter | --glass-filter-lg+ --glass-shadow 边与投影:--shadow-float | --shadow-pop+ 组件自己就是玻璃时(.pop .palette .sheet .toast,页面里的顶栏和输入框)直接写同样三行,不必加这个类。+ 注意:backdrop-filter 会让元素成为 position: fixed 子元素的包含块——里面会渲染菜单的容器(侧栏、主区)不要加。 */+.glass {+ background: var(--grain), var(--glass-bg, var(--glass-float));+ backdrop-filter: var(--glass-blur, var(--glass-filter));+ box-shadow: var(--glass-shadow, var(--shadow-float));+}diff --git a/ui/design/components/list.css b/ui/design/components/list.cssnew file mode 100644index 0000000..d31ab6b--- /dev/null+++ b/ui/design/components/list.css@@ -0,0 +1,43 @@+/* 列表卡片与行:一张 .list 白卡里放若干 .row,每行"说明在左、控件在右"。+ 改编自 yetone/magpie internal/gui/assets/app.css 的 .list / .row(MIT,© 2026 yetone)。+ 定制:覆盖 --row-h / --row-px / --row-gap。 */+.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; flex: none; }+.list + .list, .list-head + .list { margin-top: var(--space-2); }+.list-head {+ display: flex; align-items: center; gap: var(--space-2); margin: 18px var(--space-0-5) var(--space-1-5);+ font-size: var(--fs-2xs); font-weight: var(--fw-semibold); color: var(--muted);+}+.list-head:first-child { margin-top: 0; }+.list-head .grow { flex: 1; }++.row {+ --row-h: 48px;+ --row-py: 7px;+ --row-pl: var(--space-3-5);+ --row-pr: var(--space-3);+ --row-gap: var(--space-3);+ display: flex; align-items: center; gap: var(--row-gap); min-height: var(--row-h);+ padding: var(--row-py) var(--row-pr) var(--row-py) var(--row-pl);+}+.row + .row, .row + .row-edit, .row-edit + .row { border-top: 1px solid var(--line-2); }+.row .who { min-width: 0; flex: 1 1 auto; }+.row .name { font-weight: var(--fw-medium); letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+.row .sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }+.row .sub.wrap { white-space: normal; }+.row .ctl { display: flex; align-items: center; gap: var(--space-1); flex: none; }+.row .val {+ font-family: var(--code); font-size: var(--fs-xs); color: var(--fg-2); max-width: 280px;+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; -webkit-user-select: text;+}+.row.off > :not(.ctl) { opacity: .5; }+.row.compact { --row-h: 40px; --row-py: 5px; --row-pl: 11px; --row-pr: 9px; --row-gap: 9px; }+/* 可点的行:悬停叠一层,按下深一级,键盘焦点描边往里收(卡片会裁掉外描边) */+.row.clickable { --focus-offset: -2px; transition: background var(--t-fast); }+.row.clickable:hover { background: var(--pill); }+.row.clickable:active { background: var(--pill-hover); }+.row.flash { animation: flash var(--dur-flash) var(--ease-out); }++.row-edit { padding: var(--space-3) var(--space-3-5) var(--space-3-5); background: var(--card-2); display: grid; gap: var(--space-2-5); }+.row-edit label { display: grid; gap: 5px; font-size: var(--fs-xs); color: var(--fg-2); font-weight: var(--fw-medium); }+.row-edit .actions { display: flex; align-items: center; gap: var(--space-1-5); flex-wrap: wrap; }+.row-edit .hint, .hint { font-size: var(--fs-xs); color: var(--muted); line-height: var(--lh-normal); }diff --git a/ui/design/components/notice.css b/ui/design/components/notice.cssnew file mode 100644index 0000000..e53e53a--- /dev/null+++ b/ui/design/components/notice.css@@ -0,0 +1,26 @@+/* 行内提示(可带一个操作):.notice [amber | red] > .notice-text + .btn。+ 定制:覆盖 --notice-bg / --notice-fg / --notice-edge。 */+.notice {+ --notice-bg: var(--card-2);+ --notice-fg: var(--fg);+ --notice-edge: inset 0 0 0 1px var(--line);+ display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-2) var(--space-2-5) var(--space-2) var(--space-3);+ border-radius: var(--r-lg); font-size: var(--fs-sm); line-height: var(--lh-normal);+ background: var(--notice-bg); color: var(--notice-fg); box-shadow: var(--notice-edge);+}+.notice .notice-text { flex: 1; min-width: 0; }+.notice.amber {+ --notice-bg: var(--amber-soft); --notice-fg: var(--amber);+ --notice-edge: inset 0 0 0 1px color-mix(in srgb, var(--amber) 25%, transparent);+}+.notice.red {+ --notice-bg: var(--red-soft); --notice-fg: var(--red);+ --notice-edge: inset 3px 0 0 var(--red), inset 0 0 0 1px color-mix(in srgb, var(--red) 22%, transparent);+}+/* 提示里的按钮是一块白色小卡:悬停时浮起一点(描边加深、投影变大),在任何底色的提示上都成立 */+.notice .btn {+ --btn-h: var(--ctl-sm); --btn-px: var(--space-2-5);+ --btn-bg: var(--card); --btn-bg-hover: var(--card); --btn-bg-press: var(--card);+ --btn-edge: 0 0 0 .5px var(--line), var(--shadow-xs);+}+.notice .btn:hover:not(:disabled) { --btn-edge: 0 0 0 .5px var(--line-strong), var(--shadow-sm); }diff --git a/ui/design/components/popover.css b/ui/design/components/popover.cssnew file mode 100644index 0000000..d793a8e--- /dev/null+++ b/ui/design/components/popover.css@@ -0,0 +1,94 @@+/* 菜单按钮 .pick、弹出层 .pop、命令面板 .palette,以及两者共用的列表内容。+ .pick / .pop 改编自 yetone/magpie internal/gui/assets/app.css(MIT,© 2026 yetone)。 */++/* —— 菜单按钮:行右侧的下拉 —— */+.pick {+ display: inline-flex; align-items: center; gap: var(--space-1); height: var(--ctl-sm); max-width: 260px;+ padding: 0 var(--space-1-5) 0 9px; border-radius: var(--r-md); background: var(--pill); color: var(--fg);+ font-size: var(--fs-sm); transition: background var(--t-fast), transform var(--t-fast);+}+.pick:hover:not(:disabled), .pick[aria-expanded="true"] { background: var(--pill-hover); }+.pick:active:not(:disabled) { background: var(--pill-press); transform: scale(var(--press)); }+.pick:disabled { opacity: var(--o-disabled); }+.pick .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.pick .ic { width: 12px; height: 12px; color: var(--muted); transition: transform var(--t-base); }+.pick[aria-expanded="true"] .ic { transform: rotate(180deg); }++/* —— 弹出层:从锚点方向(--ox)弹出;向上打开时加 .up —— */+.pop {+ --pop-r: var(--r-xl);+ --pop-pad: 5px;+ position: fixed; z-index: var(--z-popover); width: 280px; max-height: 360px;+ display: flex; flex-direction: column;+ background: var(--grain), var(--glass-pop); backdrop-filter: var(--glass-filter-lg);+ border-radius: var(--pop-r); box-shadow: var(--shadow-pop); overflow: hidden;+ transform-origin: var(--ox, 24px) top;+ animation: fade-in var(--dur-base) var(--ease-out), pop-in var(--dur-slower) var(--ease-spring);+}+.pop.up { transform-origin: var(--ox, 24px) bottom; --pop-dy: 6px; }+.pop.model-picker { width: 340px; max-height: 420px; }+.pop.model-picker li:not(.group):not(.sep) { min-height: 34px; }++/* —— 命令面板 —— */+.palette-scrim {+ position: fixed; inset: 0; z-index: calc(var(--z-palette) - 1); background: var(--scrim-soft);+ backdrop-filter: blur(var(--blur-scrim)); animation: fade-in var(--dur-base) var(--ease-out);+}+.palette {+ --pop-r: var(--r-2xl);+ --pop-pad: 5px;+ position: fixed; z-index: var(--z-palette); left: 50%; top: 14vh; width: min(520px, calc(100vw - 32px)); translate: -50% 0;+ max-height: 60vh; display: flex; flex-direction: column;+ background: var(--grain), var(--glass-pop); backdrop-filter: var(--glass-filter-lg);+ border-radius: var(--pop-r); box-shadow: var(--shadow-pop); overflow: hidden;+ --pop-dy: -10px; --pop-scale: .97;+ animation: fade-in var(--dur-base) var(--ease-out), pop-in var(--dur-slower) var(--ease-spring);+}+.palette .search input { height: 46px; font-size: var(--fs-lg); }+.palette li { min-height: 36px; font-size: var(--fs-md); }+.palette li kbd { margin-left: auto; font-family: var(--code); font-size: var(--fs-2xs); color: var(--muted); }++/* —— 共用内容:搜索框、列表项、分组、分隔、空状态、底部操作 —— */+:is(.pop, .palette) .search { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); border-bottom: 1px solid var(--line-2); color: var(--muted); flex: none; transition: color var(--t-fast); }+:is(.pop, .palette) .search:focus-within { color: var(--fg-2); }+:is(.pop, .palette) .search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; height: 38px; font-size: var(--fs-md); }+:is(.pop, .palette) .search input::placeholder { color: var(--faint); }+:is(.pop, .palette) ul { list-style: none; margin: 0; overflow-y: auto; padding: var(--pop-pad); flex: 1 1 auto; }+:is(.pop, .palette) li {+ display: flex; align-items: center; gap: 9px; min-height: 30px; padding: 0 var(--space-2);+ border-radius: calc(var(--pop-r) - var(--pop-pad));+ font-size: var(--fs-sm); white-space: nowrap;+}+:is(.pop, .palette) li .v { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }+:is(.pop, .palette) li .n { flex: 1 1 0; min-width: 0; font-size: var(--fs-2xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }+/* 列表项状态:sel 是悬停或键盘指着的那一项(同一时刻只有一个),按下深一级;cur 打勾;危险项指着时泛红 */+:is(.pop, .palette) li { transition: background var(--t-fast), color var(--t-fast); }+:is(.pop, .palette) li.sel { background: var(--sel); }+:is(.pop, .palette) li.sel:active { background: var(--sel-press); }+:is(.pop, .palette) li.danger { color: var(--red); }+:is(.pop, .palette) li.danger.sel { background: var(--red-soft); }+:is(.pop, .palette) li.disabled { opacity: var(--o-disabled); }+:is(.pop, .palette) li.cur .v { font-weight: var(--fw-medium); }+:is(.pop, .palette) li .check { color: var(--accent); margin-left: auto; display: none; }+:is(.pop, .palette) li.cur .check { display: inline-flex; }+:is(.pop, .palette) li.group {+ min-height: 22px; padding: var(--space-1-5) var(--space-2) 0;+ font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); color: var(--faint); pointer-events: none;+}+:is(.pop, .palette) li.sep { min-height: 0; height: 1px; margin: var(--space-1) var(--space-1-5); padding: 0; background: var(--line-2); pointer-events: none; }+:is(.pop, .palette) li.explained { white-space: normal; padding: var(--space-1-5) var(--space-2); align-items: flex-start; flex-direction: column; gap: 1px; }+/* Menu 的说明项:[图标] 标题 / 说明两行 [✓] */+:is(.pop, .palette) li.rich { white-space: normal; padding: 7px var(--space-2); }+:is(.pop, .palette) li .lead { flex: none; align-self: flex-start; margin-top: 1px; color: var(--ctl-fg); display: inline-flex; }+:is(.pop, .palette) li .txt { flex: 1; min-width: 0; display: grid; gap: 1px; }+:is(.pop, .palette) li .txt .n { font-size: var(--fs-xs); line-height: var(--lh-snug); }+:is(.pop, .palette) .empty { padding: var(--space-3-5) var(--space-3); color: var(--muted); font-size: var(--fs-sm); text-align: center; }+:is(.pop, .palette) .foot { flex: none; border-top: 1px solid var(--line-2); padding: var(--pop-pad); display: flex; }+:is(.pop, .palette) .foot button {+ flex: 1; height: 30px; border-radius: calc(var(--pop-r) - var(--pop-pad));+ font-size: var(--fs-sm); color: var(--ctl-fg);+}+:is(.pop, .palette) .foot button { transition: background var(--t-fast), color var(--t-fast); }+:is(.pop, .palette) .foot button:hover:not(:disabled) { background: var(--sel); color: var(--fg); }+:is(.pop, .palette) .foot button:active:not(:disabled) { background: var(--sel-press); }+:is(.pop, .palette) .foot button:disabled { opacity: var(--o-disabled); }diff --git a/ui/design/components/seg.css b/ui/design/components/seg.cssnew file mode 100644index 0000000..fa6a0b3--- /dev/null+++ b/ui/design/components/seg.css@@ -0,0 +1,29 @@+/* 分段控件:中性的白色 thumb 按值滑动(参考 Codex / macOS);开关类设置用 Switch。改编自 yetone/magpie internal/gui/assets/app.css 的 .seg(MIT,© 2026 yetone)。+ 圆角同心:轨道 --seg-r,thumb = 轨道 − 内边距。+ 状态:未选项悬停字变深并叠一层;按下叠深一级;键盘焦点描边往里收;禁用整体变淡。 */+.seg {+ --seg-r: var(--r-md);+ --seg-pad: var(--space-0-5);+ --seg-thumb: var(--seg-thumb-bg);+ --seg-on: var(--fg);+ position: relative; display: inline-flex; padding: var(--seg-pad); border-radius: var(--seg-r);+ background: var(--seg-track); flex: none;+}+.seg > .thumb {+ position: absolute; top: var(--seg-pad); left: 0; height: calc(100% - 2 * var(--seg-pad));+ border-radius: calc(var(--seg-r) - var(--seg-pad));+ background: var(--seg-thumb); box-shadow: var(--seg-edge);+ transition: transform var(--t-moderate), width var(--t-moderate);+}+.seg > .thumb.still { transition: none; }+.seg button {+ --focus-offset: -2px;+ position: relative; z-index: var(--z-raised); white-space: nowrap; height: var(--ctl-xs); padding: 0 var(--space-2-5);+ border-radius: calc(var(--seg-r) - var(--seg-pad));+ font-size: var(--fs-sm); color: var(--ctl-fg); transition: color var(--t-base), background var(--t-fast);+}+.seg button.on { color: var(--seg-on); font-weight: var(--fw-medium); }+.seg button:hover:not(.on):not(:disabled) { color: var(--fg); background: var(--pill); }+.seg button:active:not(.on):not(:disabled) { background: var(--pill-hover); }+.seg button:disabled { opacity: var(--o-disabled); }+.seg.disabled > .thumb { opacity: .5; }diff --git a/ui/design/components/sheet.css b/ui/design/components/sheet.cssnew file mode 100644index 0000000..3510a2c--- /dev/null+++ b/ui/design/components/sheet.css@@ -0,0 +1,24 @@+/* 模态对话框:.scrim > .sheet [wide]。遮罩把后面的界面压暗并轻微模糊,对话框是最厚的一层玻璃。+ 退场时给 .scrim 加 .leaving(见 design/motion.js 的 usePresence)。 */+.scrim {+ position: fixed; inset: 0; z-index: var(--z-modal); background: var(--scrim); backdrop-filter: blur(var(--blur-scrim));+ display: grid; place-items: center; padding: var(--space-6);+ animation: fade-in var(--dur-base) var(--ease-out);+}+.sheet {+ --sheet-w: 440px;+ --sheet-r: var(--r-2xl);+ width: min(var(--sheet-w), 100%); max-height: calc(100vh - 48px); overflow: auto;+ background: var(--grain), var(--glass-sheet); backdrop-filter: var(--glass-filter-lg);+ border-radius: var(--sheet-r); box-shadow: var(--shadow-pop);+ padding: 18px 18px var(--space-4); display: grid; gap: var(--space-3);+ animation: pop-in var(--dur-slow) var(--ease-spring);+}+.sheet.wide { --sheet-w: 640px; }+.sheet h2 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }+.sheet .body { color: var(--fg-2); line-height: var(--lh-relaxed); }+.sheet .actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-1); }+.sheet pre.doc { white-space: pre-wrap; font: var(--fs-xs)/var(--lh-normal) var(--code); color: var(--fg-2); margin: 0; max-height: 60vh; overflow: auto; }++.scrim.leaving { animation: fade-out var(--dur-base) var(--ease-in) forwards; pointer-events: none; }+.scrim.leaving .sheet { animation: pop-out var(--dur-base) var(--ease-in) forwards; }diff --git a/ui/design/components/switch.css b/ui/design/components/switch.cssnew file mode 100644index 0000000..b496028--- /dev/null+++ b/ui/design/components/switch.css@@ -0,0 +1,29 @@+/* 开关:只有"开 / 关"两态的设置用它,两个以上的选项用 Seg。+ 打开 = 主操作色(浅色墨、深色黄绿),圆钮带一点弹性滑过去。+ 状态:悬停轨道加深一级;按下圆钮被"按扁"拉长;键盘焦点外描边;禁用变淡。+ 结构:<button role="switch" class="switch" aria-checked="true|false">,圆钮是 ::after。 */+.switch {+ --switch-w: 34px;+ --switch-h: 20px;+ --switch-pad: 2px;+ --switch-track: var(--switch-off);+ --switch-track-hover: var(--switch-off-hover);+ --switch-dot: var(--switch-knob);+ --switch-stretch: 3px; /* 按下时圆钮拉长多少 */+ position: relative; flex: none; width: var(--switch-w); height: var(--switch-h); border-radius: var(--r-full);+ background: var(--switch-track); box-shadow: inset 0 0 0 .5px var(--line-2);+ transition: background var(--t-base);+}+.switch::after {+ content: ""; position: absolute; top: var(--switch-pad); left: var(--switch-pad);+ width: calc(var(--switch-h) - 2 * var(--switch-pad)); height: calc(var(--switch-h) - 2 * var(--switch-pad)); border-radius: var(--r-full);+ background: var(--switch-dot); box-shadow: var(--seg-edge);+ transition: transform var(--dur-moderate) var(--ease-spring), width var(--dur-moderate) var(--ease-spring), background var(--t-base);+}+.switch:hover:not(:disabled) { background: var(--switch-track-hover); }+.switch[aria-checked="true"] { --switch-track: var(--primary); --switch-track-hover: var(--primary-hover); --switch-dot: var(--switch-knob-on); }+.switch[aria-checked="true"]::after { transform: translateX(calc(var(--switch-w) - var(--switch-h))); }+.switch:active:not(:disabled)::after { width: calc(var(--switch-h) - 2 * var(--switch-pad) + var(--switch-stretch)); }+.switch[aria-checked="true"]:active:not(:disabled)::after { transform: translateX(calc(var(--switch-w) - var(--switch-h) - var(--switch-stretch))); }+.switch:disabled { opacity: var(--o-disabled); }+.switch.sm { --switch-w: 28px; --switch-h: 16px; --switch-stretch: 2px; }diff --git a/ui/design/components/toast.css b/ui/design/components/toast.cssnew file mode 100644index 0000000..432ec8c--- /dev/null+++ b/ui/design/components/toast.css@@ -0,0 +1,27 @@+/* 提示胶囊("已保存"):.toasts > .toast [ok | err | warn] [leaving]。+ 改编自 yetone/magpie internal/gui/assets/app.css 的状态胶囊(MIT,© 2026 yetone)。 */+.toasts {+ position: fixed; z-index: var(--z-toast); left: var(--space-4); bottom: var(--space-4);+ display: grid; gap: var(--space-1-5); justify-items: start; pointer-events: none;+}+.toast {+ --toast-bg: var(--glass-pop);+ --toast-fg: var(--fg);+ --toast-edge: var(--glass-edge);+ pointer-events: auto; font-size: var(--fs-sm); line-height: 16px; font-weight: var(--fw-medium);+ padding: var(--space-1) 11px; border-radius: var(--r-full);+ max-width: min(480px, calc(100vw - 32px));+ background: var(--grain), var(--toast-bg); color: var(--toast-fg); backdrop-filter: var(--glass-filter-sm);+ box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 .5px var(--toast-edge), var(--shadow-md);+ display: flex; gap: var(--space-2); align-items: center;+ --rise: 6px;+ animation: rise-in var(--dur-base) var(--ease-out);+}+.toast.ok { --toast-bg: var(--accent-solid); --toast-fg: var(--on-accent); --toast-edge: var(--accent-line); } /* "已保存":黄绿信号 */+.toast.err { --toast-bg: color-mix(in srgb, var(--red-soft) 88%, transparent); --toast-fg: var(--red); --toast-edge: color-mix(in srgb, var(--red) 30%, transparent); }+.toast.warn { --toast-bg: color-mix(in srgb, var(--amber-soft) 88%, transparent); --toast-fg: var(--amber); --toast-edge: color-mix(in srgb, var(--amber) 25%, transparent); }+.toast.leaving { --rise: 4px; animation: sink-out var(--dur-base) var(--ease-in) forwards; }+.toast .icon-btn {+ --ib-fg: currentColor; --ib-fg-hover: currentColor;+ --ib-bg-hover: color-mix(in srgb, currentColor 12%, transparent); --ib-bg-press: color-mix(in srgb, currentColor 20%, transparent);+}diff --git a/ui/design/gallery.css b/ui/design/gallery.cssnew file mode 100644index 0000000..be4b162--- /dev/null+++ b/ui/design/gallery.css@@ -0,0 +1,124 @@+/* 设计库样例页(/amb/static/design/index.html)的版式。它自己也遵守规范:只用 token。 */+@layer app {+.gal { display: grid; grid-template-columns: 196px minmax(0, 1fr); height: 100vh; background: var(--bg); }+.gal-nav {+ display: grid; align-content: start; gap: 1px; overflow-y: auto;+ padding: var(--space-5) var(--space-3); background: var(--grain), var(--glass-side); border-right: .5px solid var(--line-2);+}+.gal-nav .brand { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2) var(--space-4); font-weight: var(--fw-semibold); }+.gal-nav .t-caption { padding: var(--space-3) var(--space-2-5) var(--space-1); }+.gal-nav a {+ display: block; padding: 5px var(--space-2-5); border-radius: var(--r-md);+ font-size: var(--fs-sm); color: var(--fg-2); transition: background var(--t-fast), color var(--t-fast);+}+.gal-nav a:hover { background: var(--side-hover); color: var(--fg); text-decoration: none; }++.gal-main { min-width: 0; overflow-y: auto; }+.gal-head {+ position: sticky; top: 0; z-index: var(--z-float);+ display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;+ padding: var(--space-3) var(--space-8);+ background: color-mix(in srgb, var(--bg) 92%, transparent);+ -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);+ border-bottom: 1px solid var(--line-2);+}+.gal-body { max-width: 1080px; padding: var(--space-2) var(--space-8) 120px; }+.gal-sec { padding-top: var(--space-8); scroll-margin-top: 56px; }+.gal-sec > h2 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }+.gal-sec > .lead { max-width: 680px; margin: var(--space-1-5) 0 var(--space-4); color: var(--muted); line-height: var(--lh-relaxed); }+.gal-sec h3 { margin: var(--space-6) var(--space-0-5) var(--space-2); }++/* —— 样例卡:标题 / 演示区(可双主题对照)/ 用法 —— */+.gal-specimen { margin: 0 0 var(--space-3); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; }+.gal-specimen > figcaption { display: flex; align-items: baseline; gap: var(--space-2); padding: var(--space-2-5) var(--space-3-5); border-bottom: 1px solid var(--line-2); }+.gal-specimen > figcaption b { font-weight: var(--fw-semibold); }+.gal-pair { display: grid; grid-template-columns: 1fr 1fr; }+.gal-pair > .gal-demo + .gal-demo { border-left: 1px solid var(--line); }+.gal-demo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-5); min-width: 0; }+.gal-demo[data-theme] { background: var(--card); }+.gal-demo.col { flex-direction: column; align-items: stretch; }+.gal-demo.flush { padding: 0; }+.gal-demo.flush > .list { border: 0; border-radius: 0; width: 100%; }+.gal-code {+ margin: 0; padding: var(--space-2-5) var(--space-3-5); border-top: 1px solid var(--line-2); background: var(--card-2);+ font: var(--fs-xs)/var(--lh-normal) var(--code); color: var(--fg-2); white-space: pre-wrap; overflow-x: auto;+ user-select: text; -webkit-user-select: text;+}++/* —— token 表 —— */+.gal-rows { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; }+.gal-row {+ display: grid; grid-template-columns: minmax(190px, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); align-items: center;+ padding: var(--space-2) var(--space-3-5); border-top: 1px solid var(--line-2);+}+.gal-row:first-child { border-top: 0; }+.gal-row.scale { grid-template-columns: minmax(190px, 1.1fr) 90px minmax(0, 2fr); }+.gal-name { min-width: 0; }+.gal-name code { display: block; color: var(--fg); cursor: copy; }+.gal-name .t-meta { display: block; }+.gal-chip { display: flex; align-items: center; gap: var(--space-2); min-width: 0; padding: var(--space-1); border-radius: var(--r-md); }+.gal-chip i {+ width: 28px; height: 28px; flex: none; border-radius: var(--r-sm); background: var(--sw);+ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 12%, transparent);+}+.gal-chip code { font-size: var(--fs-2xs); color: var(--muted); overflow-wrap: anywhere; }+.gal-bar { height: 10px; width: var(--w); border-radius: 2px; background: var(--accent-solid); box-shadow: inset 0 0 0 1px var(--accent-line); }+.gal-radius { width: 64px; height: 40px; border-radius: var(--r); background: var(--pill); box-shadow: inset 0 0 0 1px var(--line); }+.gal-height { height: var(--h); width: 120px; border-radius: var(--r-sm); background: var(--pill); box-shadow: inset 0 0 0 1px var(--line); }+.gal-elev { display: grid; place-items: end start; width: 150px; height: 84px; padding: var(--space-2-5); border-radius: var(--r-xl); background: var(--card); box-shadow: var(--sh); }++/* —— 动效 —— */+.gal-track { position: relative; flex: 1; min-width: 120px; height: 18px; border-radius: var(--r-full); background: var(--pill); }+.gal-track i {+ position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent);+ transition: left var(--d, var(--dur-slow)) var(--e, var(--ease-out));+}+.gal-track.on i { left: calc(100% - 15px); }+.gal-curve { width: 56px; height: 56px; flex: none; overflow: visible; }+.gal-curve rect { fill: none; stroke: var(--line); }+.gal-curve path { fill: none; stroke: var(--accent); stroke-width: 2; }+.gal-anim { display: grid; justify-items: center; gap: var(--space-2); width: 120px; }+.gal-anim-box { width: 72px; height: 48px; border-radius: var(--r-lg); background: var(--accent-solid); box-shadow: inset 0 0 0 1px var(--accent-line); }++/* —— 页面模式 —— */+.gal-chat { display: flex; flex-direction: column; width: 100%; }+.gal-chat > .msg-row:first-child { margin-top: 0; }+.gal-demo .composer { width: 100%; }++/* —— 材质:环境光 + 底下的彩色内容 + 六块玻璃 —— */+.gal-stage { position: relative; height: 300px; overflow: hidden; width: 100%; }+.gal-stage-under {+ position: absolute; inset: 0; padding: var(--space-4) var(--space-5); display: grid; align-content: start; gap: var(--space-2-5);+ font-size: var(--fs-lg); color: var(--fg);+}+.gal-stage-over {+ position: absolute; inset: 0; padding: var(--space-6) var(--space-5); display: grid; gap: var(--space-4);+ grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: center;+}+.gal-stage-swatch { width: 28px; height: 28px; border-radius: var(--r-lg); background: var(--sw); flex: none; }+.gal-mat { display: grid; gap: var(--space-0-5); align-content: start; min-height: 92px; padding: var(--space-3) var(--space-3-5); border-radius: var(--r-2xl); }+.gal-mat b { font-weight: var(--fw-semibold); }++/* —— 状态矩阵:一行一个组件,浅色 / 深色两条,画在真实的表面上 —— */+.gal-state > .gal-strip + .gal-strip { border-top: .5px solid var(--line); }+.gal-strip-in { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4) var(--space-5); padding: var(--space-4) var(--space-5) var(--space-3-5); }+.ctx-surface > .gal-strip-in { background: var(--surface); }+.ctx-side > .gal-strip-in { background: var(--grain), var(--glass-side); }+.gal-cell { display: grid; justify-items: start; gap: var(--space-2); }+.gal-cell-stage { min-height: var(--ctl-lg); display: flex; align-items: center; }+.gal-cell > .t-meta { font-size: var(--fs-2xs); }+.gal-pop-static { position: static; width: 168px; max-height: none; animation: none; }+.composer.gal-bare { width: auto; margin: 0; padding: var(--space-1-5); flex-direction: row; }+.card.gal-bare-card { width: 200px; padding: var(--space-1-5) var(--space-2-5); }+.card.gal-bare-card .opts, .card.gal-bare-card .opt { margin: 0; }++@media (max-width: 900px) {+ .gal { grid-template-columns: minmax(0, 1fr); }+ .gal-nav { display: none; }+ .gal-head, .gal-body { padding-left: var(--space-4); padding-right: var(--space-4); }+ .gal-pair { grid-template-columns: minmax(0, 1fr); }+ .gal-stage { height: 520px; }+ .gal-stage-over { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }+ .gal-pair > .gal-demo + .gal-demo { border-left: 0; border-top: 1px solid var(--line); }+}+}diff --git a/ui/design/gallery.js b/ui/design/gallery.jsnew file mode 100644index 0000000..6695d72--- /dev/null+++ b/ui/design/gallery.js@@ -0,0 +1,575 @@+// 设计库样例页:token 表直接解析 tokens/*.css(单一来源,不会和代码脱节),组件用真实实现渲染。+import { render, createContext } from "preact";+import { useContext, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";+import { html, Icon, Button, IconButton, Seg, Switch, MenuButton, Menu, Badge, Notice, Skeleton, Spinner, CopyButton, Toasts, DialogHost } from "../components/ui.js";+import { BotAvatar, AvatarPicker, AppMark, BOT_CHARS, CHAR_KEYS, MAIN_CHAR } from "../components/avatar.js";+import { TEMPLATES } from "../screens/new-bot.js";+import { Markdown } from "../components/markdown.js";+import { useStore, toast, saved, failed, confirmSheet } from "../lib/store.js";+import { themeMode, setThemeMode } from "../lib/theme.js";++const Compare = createContext(false);++// —— 解析 token 文件:取第一个规则块,"/* —— 组名:说明 —— */" 分组,行尾注释作为说明 ——+async function loadTokens(file) {+ const text = await fetch(new URL(`./tokens/${file}`, import.meta.url)).then((r) => r.text());+ const block = text.slice(text.indexOf("{") + 1, text.indexOf("\n}"));+ const groups = [];+ let g = null;+ for (const line of block.split("\n")) {+ const head = line.match(/\/\*\s*——\s*(.+?)\s*——\s*\*\//);+ if (head) {+ const [name, ...hint] = head[1].split(":");+ groups.push((g = { name, hint: hint.join(":"), tokens: [] }));+ continue;+ }+ const m = line.match(/^\s*(--[\w-]+):\s*(.+?);\s*(?:\/\*\s*(.*?)\s*\*\/)?\s*$/);+ if (!m) continue;+ if (!g) groups.push((g = { name: "", hint: "", tokens: [] }));+ g.tokens.push({ name: m[1], src: m[2], note: m[3] || "" });+ }+ return groups;+}+const group = (groups, name) => groups.find((g) => g.name === name)?.tokens || [];++function useResolvedTheme() {+ const [t, setT] = useState(document.documentElement.dataset.theme);+ useEffect(() => {+ const mo = new MutationObserver(() => setT(document.documentElement.dataset.theme));+ mo.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });+ return () => mo.disconnect();+ }, []);+ return t;+}++/** 读元素上的计算值(随主题作用域变化) */+function useComputed(ref, name, deps = []) {+ const [v, setV] = useState("");+ useLayoutEffect(() => setV(getComputedStyle(ref.current).getPropertyValue(name).trim()), deps);+ return v;+}++const copy = (text) => navigator.clipboard?.writeText(text).then(() => toast(`已复制 ${text}`));++// —— 样例卡:children 是函数,双主题对照时渲染两次 ——+function Demo({ title, note, code, col, flush, children }) {+ const compare = useContext(Compare);+ const cls = `gal-demo${col ? " col" : ""}${flush ? " flush" : ""}`;+ return html`<figure class="gal-specimen">+ ${title && html`<figcaption><b>${title}</b>${note && html`<span class="t-meta">${note}</span>`}</figcaption>`}+ ${compare+ ? html`<div class="gal-pair"><div class=${cls} data-theme="light">${children()}</div><div class=${cls} data-theme="dark">${children()}</div></div>`+ : html`<div class=${cls}>${children()}</div>`}+ ${code && html`<pre class="gal-code"><code>${code.trim()}</code></pre>`}+ </figure>`;+}++function Section({ id, title, lead, children }) {+ return html`<section class="gal-sec" id=${id}><h2>${title}</h2>${lead && html`<p class="lead">${lead}</p>`}${children}</section>`;+}++function TokenName({ t }) {+ return html`<div class="gal-name"><code onClick=${() => copy(`var(${t.name})`)} title="点击复制 var()">${t.name}</code>+ <span class="t-meta">${t.note || t.src}</span></div>`;+}++function ColorChip({ name, theme }) {+ const ref = useRef(null);+ const v = useComputed(ref, name, [theme]);+ return html`<div class="gal-chip" data-theme=${theme} ref=${ref} style=${{ "--sw": `var(${name})` }}><i></i><code>${v}</code></div>`;+}++function ColorRows({ tokens }) {+ const theme = useResolvedTheme();+ return html`<div class="gal-rows">+ <div class="gal-row"><span class="t-label">token</span><span class="t-label">浅色</span><span class="t-label">深色</span></div>+ ${tokens.map((t) => html`<div class="gal-row" key=${t.name}><${TokenName} t=${t} />+ <${ColorChip} name=${t.name} theme="light" key=${theme + "l"} /><${ColorChip} name=${t.name} theme="dark" key=${theme + "d"} /></div>`)}+ </div>`;+}++function ScaleRows({ tokens, sample }) {+ return html`<div class="gal-rows">${tokens.map((t) => html`<div class="gal-row scale" key=${t.name}><${TokenName} t=${t} />+ <code class="t-meta">${t.src}</code><div>${sample(t)}</div></div>`)}</div>`;+}++// —— 动效 ——+function bezierPath(v) {+ const m = v.match(/cubic-bezier\(([^)]+)\)/);+ const [x1, y1, x2, y2] = m ? m[1].split(",").map(Number) : [0, 0, 1, 1];+ return `M0 56 C${x1 * 56} ${56 - y1 * 56} ${x2 * 56} ${56 - y2 * 56} 56 0`;+}+function Runner({ d, e }) {+ const [on, setOn] = useState(false);+ return html`<div class="cluster grow">+ <div class=${`gal-track${on ? " on" : ""}`} style=${{ "--d": d && `var(${d})`, "--e": e && `var(${e})` }}><i></i></div>+ <${Button} size="sm" onClick=${() => setOn((v) => !v)}>播放<//>+ </div>`;+}+function Replay({ cls, label }) {+ const [n, setN] = useState(0);+ return html`<div class="gal-anim">+ <div key=${n} class=${`gal-anim-box ${cls}`}></div>+ <button type="button" class="text" onClick=${() => setN((k) => k + 1)}>${label} ↻</button>+ </div>`;+}++// —— 组件样例里有状态的小件 ——+function SegDemo() {+ const [v, setV] = useState("auto");+ return html`<${Seg} label="线路" value=${v} onChange=${setV} options=${[["auto", "自动"], ["intl", "国际"], ["cn", "中国大陆优化"]]} />+ <${Seg} label="禁用" value="a" disabled onChange=${() => {}} options=${[["a", "开"], ["b", "关"]]} />`;+}+function SwitchDemo() {+ const [on, setOn] = useState(true);+ return html`<${Switch} label="长期记忆" value=${on} onChange=${setOn} /><${Switch} label="关" value=${false} onChange=${() => {}} />+ <${Switch} label="小号" size="sm" value=${on} onChange=${setOn} /><${Switch} label="禁用" value=${true} disabled onChange=${() => {}} />`;+}+function MenuButtonDemo() {+ const [v, setV] = useState("auto");+ return html`<${MenuButton} label="默认模型" value=${v} onChange=${setV}+ options=${[["auto", "自动(列表第一个)"], ["opus", "claude-opus-5-5", "最强"], ["sonnet", "claude-sonnet-5-5", "均衡"]]} />`;+}+function MenuDemo() {+ const ref = useRef(null);+ const [open, setOpen] = useState(false);+ return html`<button type="button" class="btn" ref=${ref} aria-expanded=${open} onClick=${() => setOpen((v) => !v)}>打开菜单<//>+ ${open && html`<${Menu} anchor=${ref.current} label="示例菜单" onClose=${() => setOpen(false)} items=${[+ { group: "机器人" }, { label: "重命名", onSelect: () => toast("重命名") }, { label: "机器人设置", cur: true, onSelect: () => {} },+ { sep: true }, { label: "删除", danger: true, onSelect: () => failed("只是演示") }, { label: "不可用", disabled: true },+ ]} />`}`;+}+function FieldDemo() {+ const [show, setShow] = useState(false);+ return html`<input class="field" placeholder="默认" />+ <input class="field mono" placeholder="mono:sk-…" />+ <input class="field err" value="err:格式不对" />+ <input class="field" readonly value="readonly" />+ <div class="field-wrap"><input class="field mono" type=${show ? "text" : "password"} value="sk-demo-0000" />+ <span class="tail"><${IconButton} icon=${show ? "eyeOff" : "eye"} label="显示" onClick=${() => setShow((v) => !v)} /><${CopyButton} text="sk-demo-0000" /></span></div>+ <textarea class="field" rows="3" placeholder="textarea.field"></textarea>`;+}+// —— 头像:6 个角色、平台里的状态、一次性反应、尺寸、配对 ——+const AV_STATES = [["idle", "空闲"], ["listening", "在听"], ["thinking", "思考"], ["replying", "回复"], ["waiting", "等批准"], ["sleep", "睡觉"]];+const AV_SHOTS = [["hello", "打招呼 · 新建后"], ["done", "完成 · 回复结束"], ["error", "出错"], ["poke", "戳一下"], ["love", "连戳三下"], ["dizzy", "戳太多"]];++function AvatarCastDemo() {+ return html`<div class="cluster" style="--gap: var(--space-6); align-items: start">+ ${CHAR_KEYS.map((k) => html`<div class="stack" style="--gap: var(--space-1); justify-items: center; text-align: center; width: 120px">+ <${BotAvatar} char=${k} size=${96} lively pokeable greet />+ <b class="t-title">${BOT_CHARS[k].name}${k === MAIN_CHAR ? " · 主角" : ""}</b>+ <span class="t-meta">${BOT_CHARS[k].pick}</span>+ </div>`)}+ </div>`;+}++function AvatarStateDemo() {+ const [state, setState] = useState("thinking");+ const [char, setChar] = useState(MAIN_CHAR);+ const [cue, setCue] = useState(null);+ return html`<div class="stack" style="--gap: var(--space-4)">+ <${Seg} label="持续状态" value=${state} onChange=${setState} options=${AV_STATES} />+ <div class="cluster" style="--gap: var(--space-2)">+ ${AV_SHOTS.map(([k, l]) => html`<${Button} size="sm" onClick=${() => setCue({ kind: k, at: Date.now() })}>${l}<//>`)}+ </div>+ <div class="cluster" style="--gap: var(--space-4); align-items: end">+ <${BotAvatar} char=${char} size=${144} state=${state} cue=${cue} lively pokeable />+ ${CHAR_KEYS.filter((k) => k !== char).map((k) => html`<button type="button" class="avatar-opt" title="放大看" onClick=${() => setChar(k)}>+ <${BotAvatar} char=${k} size=${64} state=${state} cue=${cue} /><span>${BOT_CHARS[k].name}</span>+ </button>`)}+ </div>+ </div>`;+}++function AvatarSizeDemo() {+ const [working, setWorking] = useState(false);+ return html`<div class="stack" style="--gap: var(--space-4)">+ <div class="cluster" style="--gap: var(--space-5); align-items: end">+ ${[22, 38, 56, 96].map((s) => html`<div class="stack bot-hover" style="--gap: var(--space-1-5); justify-items: center"><${BotAvatar} char=${MAIN_CHAR} size=${s} working=${working} /><span class="t-meta">${s}px</span></div>`)}+ <div class="stack" style="--gap: var(--space-1-5); justify-items: center"><${BotAvatar} neutral size=${56} /><span class="t-meta">neutral(新建页占位)</span></div>+ <${Button} size="sm" onClick=${() => setWorking((v) => !v)}>${working ? "停下" : "开始工作"}<//>+ </div>+ <div class="cluster" style="--gap: var(--space-2)">${CHAR_KEYS.map((k) => html`<span class="bot-hover"><${BotAvatar} char=${k} size=${38} working=${working} /></span>`)}</div>+ <div class="cluster" style="--gap: var(--space-2)">${CHAR_KEYS.map((k) => html`<${BotAvatar} char=${k} size=${22} working=${working} />`)}</div>+ </div>`;+}++function AvatarPairDemo() {+ const [v, setV] = useState("");+ return html`<div class="stack" style="--gap: var(--space-4)">+ <div class="cluster" style="--gap: var(--space-4)">+ ${[{ key: "", name: "空白新建", avatar: MAIN_CHAR }, ...TEMPLATES].map((t) => html`<div class="cluster" style="--gap: var(--space-2)">+ <${BotAvatar} char=${t.avatar} size=${30} /><span class="t-body">${t.name}</span></div>`)}+ </div>+ <${AvatarPicker} value=${v} fallback=${MAIN_CHAR} onChange=${setV} />+ </div>`;+}++// —— 材质:环境光上叠几层玻璃,底下放有颜色的内容,才看得出透光和模糊 ——+const MATERIALS = [+ ["--glass-side", "侧栏", "只盖在环境光上,不模糊"],+ ["--glass-chrome", "顶栏", "--glass-filter"],+ ["--glass-float", "输入框 · 回到底部", "--glass-filter"],+ ["--glass-panel", "信息面板", "停靠时不模糊"],+ ["--glass-pop", "菜单 · 命令面板 · 提示", "--glass-filter-lg"],+ ["--glass-sheet", "对话框 · 引导卡片", "--glass-filter-lg"],+];+function GlassStage() {+ return html`<div class="gal-stage aura-bg" style="--aura-hue: 225">+ <div class="gal-stage-under" aria-hidden="true">+ ${["--accent-solid", "--green", "--red", "--amber", "--primary", "--accent-solid", "--green", "--red", "--amber", "--primary"].map((c, i) => html`<div class="cluster">+ <i class="gal-stage-swatch" style=${{ "--sw": `var(${c})` }}></i>+ <span>${["今日结论:周五前上线新版引导页", "客服话术改用新模板", "设计稿定稿(小林,周三)", "联调支付回调(阿杰,周四)", "价格以控制台为准"][i % 5]}</span></div>`)}+ </div>+ <div class="gal-stage-over">+ ${MATERIALS.map(([bg, label, blur]) => html`<div class="glass gal-mat" style=${{ "--glass-bg": `var(${bg})`, "--glass-blur": blur.startsWith("--") ? `var(${blur})` : "none" }}>+ <b>${label}</b><code class="t-meta">${bg}</code><span class="t-meta">${blur.startsWith("--") ? `模糊 ${blur}` : blur}</span></div>`)}+ </div>+ </div>`;+}++// —— 状态矩阵:每个组件的各种状态并排画出来,浅色一行、深色一行 ——+// 设计库把样式表里的 :hover / :active / :focus-visible / :focus-within / :focus 规则各复制一份,+// 换成 .is-hover / .is-active / .is-focus,于是悬停、按下、键盘焦点也能静态展示。只在设计库里做,产品代码不用这些类。+const PSEUDO = [[":focus-visible", ".is-focus"], [":focus-within", ".is-focus"], [":focus", ".is-focus"], [":hover", ".is-hover"], [":active", ".is-active"]];+function mirrorPseudoStates() {+ const visit = (owner) => {+ let rules;+ try {+ rules = owner.cssRules;+ } catch {+ return;+ }+ const adds = [];+ for (let i = 0; i < rules.length; i++) {+ const r = rules[i];+ if (r instanceof CSSImportRule) r.styleSheet && visit(r.styleSheet);+ else if (r instanceof CSSStyleRule) {+ if (!/:(hover|active|focus)/.test(r.selectorText)) continue;+ const sel = PSEUDO.reduce((s, [p, c]) => s.split(p).join(c), r.selectorText);+ adds.push([i + 1, `${sel} { ${r.style.cssText} }`]);+ } else if (r.cssRules) visit(r); // @layer / @media / @supports:插回原来的层里,层叠顺序不变+ }+ for (const [i, text] of adds.reverse()) {+ try {+ owner.insertRule(text, i);+ } catch {+ /* 个别选择器复制后不合法:跳过 */+ }+ }+ };+ for (const s of document.styleSheets) visit(s);+}++const noop = () => {};+/** 默认 / 悬停 / 按下 / 键盘焦点 四个基本状态;render 收到要加的类名 */+const basic = (render) => [["默认", () => render("")], ["悬停", () => render("is-hover")], ["按下", () => render("is-active")], ["键盘焦点", () => render("is-focus")]];+const btn = (v, label) => (c) => html`<button type="button" class=${`btn ${v} ${c}`}>${label}</button>`;++function SegState({ st, disabled }) {+ const ref = useRef(null);+ useLayoutEffect(() => {+ if (st) ref.current?.querySelectorAll(".seg button")[1]?.classList.add(st);+ }, []);+ return html`<div ref=${ref}><${Seg} label="示例" value="a" disabled=${disabled} onChange=${noop} options=${[["a", "自动"], ["b", "国际"]]} /></div>`;+}+const thread = (c, { working } = {}) => html`<button type="button" class=${`thread ${c}`} style="width: 236px">+ <span class="avatar-wrap"><${BotAvatar} id="a1f3c9d2" name="群聊日报" size=${38} working=${working} />${working && html`<span class="working-dot"></span>`}</span>+ <span class="body"><span class="line"><span class="title">群聊日报</span><span class="when num">09:24</span></span>+ <span class="line"><span class="snip">${working ? "正在工作…" : "今日结论:周五前上线"}</span></span></span>+</button>`;+const menuItem = (c, label = "机器人设置") => html`<div class="pop gal-pop-static"><ul>+ <li class=${c}><span class="v">${label}</span><span class="check"><${Icon} name="check" size=${14} /></span></li></ul></div>`;+const composer = (c) => html`<div class=${`composer ${c}`} style="width: 250px"><textarea rows="1" placeholder="发消息,/ 查看命令" tabindex="-1"></textarea>+ <div class="composer-bar"><button type="button" class="plus" tabindex="-1" aria-label="更多"><${Icon} name="plus" size=${15} stroke=${1.7} /></button><span class="grow"></span>+ <button type="button" class="send" tabindex="-1" aria-label="发送"><${Icon} name="up" size=${15} stroke=${2} /></button></div></div>`;++const STATE_ROWS = [+ { name: "主按钮", note: ".btn.primary · 加载保持本色只是不可点;禁用退成中性灰", cells: [...basic(btn("primary", "保存")), ["加载", () => html`<${Button} variant="primary" loading>保存<//>`], ["禁用", () => html`<button type="button" class="btn primary" disabled>保存</button>`]] },+ { name: "次按钮", note: ".btn", cells: [...basic(btn("", "取消")), ["加载", () => html`<${Button} loading>刷新<//>`], ["禁用", () => html`<button type="button" class="btn" disabled>取消</button>`]] },+ { name: "幽灵按钮", note: ".btn.ghost", cells: [...basic(btn("ghost", "跳过")), ["禁用", () => html`<button type="button" class="btn ghost" disabled>跳过</button>`]] },+ { name: "危险按钮", note: ".btn.danger", cells: [...basic(btn("danger", "永久删除")), ["禁用", () => html`<button type="button" class="btn danger" disabled>永久删除</button>`]] },+ { name: "图标按钮", note: ".icon-btn · 打开(on / aria-expanded)比悬停深一级", cells: [...basic((c) => html`<button type="button" class=${`icon-btn ${c}`} aria-label="信息面板"><${Icon} name="panel" /></button>`),+ ["打开", () => html`<button type="button" class="icon-btn on" aria-label="信息面板"><${Icon} name="panel" /></button>`], ["禁用", () => html`<button type="button" class="icon-btn" disabled aria-label="新对话"><${Icon} name="compose" /></button>`]] },+ { name: "文字按钮", note: ".text [accent | danger]", cells: [...basic((c) => html`<button type="button" class=${`text ${c}`}>更换密钥</button>`),+ ["强调", () => html`<button type="button" class="text accent">改用大陆线路</button>`], ["危险 · 悬停", () => html`<button type="button" class="text danger is-hover">删除</button>`], ["禁用", () => html`<button type="button" class="text" disabled>更换密钥</button>`]] },+ { name: "输入框", note: ".field · 错误状态聚焦时是红色光晕;只读聚焦不发光", cells: [+ ["默认", () => html`<input class="field" placeholder="App ID" style="width: 150px" />`], ["悬停", () => html`<input class="field is-hover" placeholder="App ID" style="width: 150px" />`],+ ["聚焦", () => html`<input class="field is-focus" value="cli_a1b2" style="width: 150px" />`], ["错误", () => html`<input class="field err" value="格式不对" style="width: 150px" />`],+ ["错误 · 聚焦", () => html`<input class="field err is-focus" value="格式不对" style="width: 150px" />`], ["只读", () => html`<input class="field" readonly value="https://…/v1" style="width: 150px" />`],+ ["禁用", () => html`<input class="field" disabled value="未启用" style="width: 150px" />`]] },+ { name: "开关 · 关", note: ".switch[aria-checked=false] · 按下时圆钮被按扁", cells: [...basic((c) => html`<button type="button" role="switch" aria-checked="false" aria-label="长期记忆" class=${`switch ${c}`}></button>`),+ ["禁用", () => html`<button type="button" role="switch" aria-checked="false" aria-label="长期记忆" class="switch" disabled></button>`]] },+ { name: "开关 · 开", note: ".switch[aria-checked=true]", cells: [...basic((c) => html`<button type="button" role="switch" aria-checked="true" aria-label="长期记忆" class=${`switch ${c}`}></button>`),+ ["禁用", () => html`<button type="button" role="switch" aria-checked="true" aria-label="长期记忆" class="switch" disabled></button>`]] },+ { name: "分段", note: ".seg · 状态画在第二项(未选中)上", cells: [["默认", () => html`<${SegState} />`], ["悬停", () => html`<${SegState} st="is-hover" />`], ["按下", () => html`<${SegState} st="is-active" />`],+ ["键盘焦点", () => html`<${SegState} st="is-focus" />`], ["禁用", () => html`<${SegState} disabled />`]] },+ { name: "菜单按钮", note: ".pick · 打开时箭头翻转", cells: [...basic((c) => html`<button type="button" class=${`pick ${c}`}><span class="v">claude-sonnet-5-5</span><${Icon} name="chevDown" /></button>`),+ ["打开", () => html`<button type="button" class="pick" aria-expanded="true"><span class="v">claude-sonnet-5-5</span><${Icon} name="chevDown" /></button>`],+ ["禁用", () => html`<button type="button" class="pick" disabled><span class="v">自动</span><${Icon} name="chevDown" /></button>`]] },+ { name: "菜单项", note: ".pop li · 悬停和键盘指着是同一个 .sel,同一时刻只有一项", cells: [["默认", () => menuItem("")], ["指着", () => menuItem("sel")], ["按下", () => menuItem("sel is-active")],+ ["当前", () => menuItem("cur")], ["危险 · 指着", () => menuItem("danger sel", "删除")], ["禁用", () => menuItem("disabled", "不可用")]] },+ { name: "侧栏行", note: ".thread · 悬停是更亮的一层玻璃,选中是浮起的玻璃片", ctx: "side", cells: [...basic((c) => thread(c)), ["选中", () => thread("sel")], ["工作中", () => thread("", { working: true })]] },+ { name: "设置导航", note: ".nav-item", ctx: "side", cells: [...basic((c) => html`<button type="button" class=${`nav-item ${c}`} style="width: 200px"><${Icon} name="sliders" />常规</button>`),+ ["选中", () => html`<button type="button" class="nav-item sel" style="width: 200px"><${Icon} name="sliders" />常规</button>`]] },+ { name: "侧栏搜索 · 账户", note: ".side-search · .account", ctx: "side", cells: [+ ["默认", () => html`<label class="side-search" style="width: 200px; margin: 0"><${Icon} name="search" /><input placeholder="搜索" tabindex="-1" /></label>`],+ ["悬停", () => html`<label class="side-search is-hover" style="width: 200px; margin: 0"><${Icon} name="search" /><input placeholder="搜索" tabindex="-1" /></label>`],+ ["聚焦", () => html`<label class="side-search is-focus" style="width: 200px; margin: 0"><${Icon} name="search" /><input value="日报" tabindex="-1" /></label>`],+ ["账户 · 悬停", () => html`<button type="button" class="account is-hover" style="width: 200px"><span class="me">R</span><span class="who">root</span><${Icon} name="gear" /></button>`],+ ["账户 · 打开", () => html`<button type="button" class="account on" style="width: 200px"><span class="me">R</span><span class="who">root</span><${Icon} name="gear" /></button>`]] },+ { name: "发送按钮", note: ".send · 空的时候是中性灰钮,能发了才亮起品牌色;悬停时箭头上提", cells: [+ ["空", () => html`<button type="button" class="send" disabled aria-label="发送"><${Icon} name="up" size=${15} stroke=${2} /></button>`],+ ...basic((c) => html`<button type="button" class=${`send ${c}`} aria-label="发送"><${Icon} name="up" size=${15} stroke=${2} /></button>`),+ ["停止", () => html`<button type="button" class="send stop" aria-label="停止"><${Icon} name="stop" size=${12} /></button>`]] },+ { name: "对话输入框", note: ".composer · 输入中描边更实、投影更大;拖入文件时 accent 描边 + 一层黄绿", cells: [["默认", () => composer("")], ["悬停", () => composer("is-hover")], ["输入中", () => composer("is-focus")], ["拖入文件", () => composer("drag")]] },+ { name: "输入框工具", note: ".composer .model-chip / .plus · 打开时箭头翻转、加号转成叉", cells: [+ ...basic((c) => html`<div class="composer gal-bare"><button type="button" class=${`model-chip ${c}`}><span class="v">claude-sonnet-5-5</span><${Icon} name="chevDown" /></button></div>`),+ ["打开", () => html`<div class="composer gal-bare"><button type="button" class="model-chip" aria-expanded="true"><span class="v">claude-sonnet-5-5</span><${Icon} name="chevDown" /></button></div>`],+ ["加号 · 打开", () => html`<div class="composer gal-bare"><button type="button" class="plus" aria-expanded="true" aria-label="更多"><${Icon} name="plus" size=${15} stroke=${1.7} /></button></div>`]] },+ { name: "模板卡", note: ".tpl · 悬停浮起 1px,选中是 accent 描边 + 一层黄绿", cells: [+ ...basic((c) => html`<button type="button" class=${`tpl ${c}`} style="width: 190px"><span class="tpl-ic"><${Icon} name="chat" size=${17} /></span><span class="tpl-name">群聊日报</span><span class="tpl-desc">每天整理群消息</span></button>`),+ ["选中", () => html`<button type="button" class="tpl on" style="width: 190px"><span class="tpl-ic"><${Icon} name="chat" size=${17} /></span><span class="tpl-name">群聊日报</span><span class="tpl-desc">每天整理群消息</span></button>`]] },+ { name: "建议胶囊", note: ".chip", cells: basic((c) => html`<button type="button" class=${`chip ${c}`}>你能帮我做什么?</button>`) },+ { name: "问题选项", note: ".card .opt", cells: [+ ...basic((c) => html`<div class="card gal-bare-card"><button type="button" class=${`opt ${c}`}><span class="letter">A</span><span>国内线路<span class="desc">延迟低</span></span></button></div>`),+ ["已选", () => html`<div class="card gal-bare-card"><button type="button" class="opt picked"><span class="letter">A</span><span>国内线路<span class="desc">延迟低</span></span></button></div>`],+ ["已结束", () => html`<div class="card done gal-bare-card"><button type="button" class="opt" disabled><span class="letter">B</span><span>海外线路<span class="desc">模型更全</span></span></button></div>`]] },+ { name: "列表行", note: ".row.clickable · 键盘焦点描边往里收(卡片会裁掉外描边)", cells: basic((c) => html`<div class="list" style="width: 220px"><div class=${`row compact clickable ${c}`} tabindex="0"><div class="who"><div class="name">最近会话</div><div class="sub">3 分钟前</div></div></div></div>`) },+];++function StateRow({ name, note, ctx = "surface", cells }) {+ return html`<figure class="gal-specimen gal-state">+ <figcaption><b>${name}</b>${note && html`<span class="t-meta">${note}</span>`}</figcaption>+ ${["light", "dark"].map((t) => html`<div class=${`gal-strip aura-bg ctx-${ctx}`} data-theme=${t} style=${{ "--aura-hue": ctx === "side" ? "155" : "225" }}>+ <div class="gal-strip-in">${cells.map(([label, el]) => html`<div class="gal-cell"><div class="gal-cell-stage">${el()}</div><span class="t-meta">${label}</span></div>`)}</div>+ </div>`)}+ </figure>`;+}++const MD = "支持 **粗体**、`行内代码`、[链接](https://modelflare.dev):\n\n- 列表项\n- 第二项\n\n```js\nconst ok = true;\n```";++function Gallery() {+ const mode = useStore(themeMode);+ const [compare, setCompare] = useState(false);+ const [reduced, setReduced] = useState(false);+ const [prim, setPrim] = useState(null);+ const [sem, setSem] = useState(null);+ const [mot, setMot] = useState(null);+ useEffect(() => {+ loadTokens("primitives.css").then(setPrim);+ loadTokens("semantic.css").then(setSem);+ loadTokens("motion.css").then(setMot);+ }, []);+ const motion = (mot || []).flatMap((g) => g.tokens);+ const nav = [+ ["原则", [["principles", "分层与约定"]]],+ ["Token", [["color", "颜色"], ["material", "材质"], ["type", "文字"], ["space", "间距与尺寸"], ["elevation", "投影与层级"], ["motion", "动效"]]],+ ["组件", [["states", "状态矩阵"], ["buttons", "按钮"], ["inputs", "输入"], ["menus", "菜单与分段"], ["status", "状态与反馈"], ["lists", "列表行"], ["overlays", "对话框与提示"], ["avatars", "头像"]]],+ ["页面模式", [["patterns", "对话"], ["custom", "定制"]]],+ ];+ return html`<${Compare.Provider} value=${compare}><div class="gal">+ <nav class="gal-nav" aria-label="目录">+ <div class="brand"><${AppMark} size=${24} />设计库</div>+ ${nav.map(([g, items]) => html`<div class="t-caption">${g}</div>${items.map(([id, label]) => html`<a href=${"#" + id}>${label}</a>`)}`)}+ </nav>+ <main class="gal-main">+ <header class="gal-head">+ <span class="t-heading grow">AnyModelBot 设计库</span>+ <${Seg} label="主题" value=${mode} onChange=${setThemeMode} options=${[["system", "跟随系统"], ["light", "浅色"], ["dark", "深色"]]} />+ <${Seg} label="对照" value=${compare ? "both" : "one"} onChange=${(v) => setCompare(v === "both")} options=${[["one", "单主题"], ["both", "双主题对照"]]} />+ </header>+ <div class="gal-body">++ <${Section} id="principles" title="分层与约定" lead="页面只用语义 token 和组件;组件通过自己的 --组件-* 变量对外开放定制。完整规范见 ui/design/README.md。">+ <${Demo} title="层叠顺序" note="后面的层总是赢,和选择器权重无关" code=${`+@layer tokens, base, components, app, utilities;+/* tokens primitives.css(原始色板与尺度)→ semantic.css(按主题的语义色)→ motion.css+ base reset、关键帧库+ components .btn .field .badge .list/.row .seg .pick/.pop .sheet .toast .notice .spinner/.skel …+ app ui/css/*.css 页面样式:覆盖组件只需改 --组件-* 变量+ utilities .t-*(文字角色).stack .cluster .grow .truncate .tone-* */`}>+ ${() => html`<${Notice} action=${html`<a class="btn" href="#custom">看定制示例</a>`}>写新界面前先在这里找现成的 token 和组件;找不到再加,并且加在 token 文件里。<//>`}+ <//>+ <//>++ <${Section} id="color" title="颜色" lead="页面与组件只用语义色。中性色按主题精调;品牌与状态色来自原始色板。点击 token 名复制 var()。">+ ${sem && ["环境", "材质", "表面", "线", "文字", "品牌", "状态"].map((g) => html`<h3 class="t-label">${g}</h3><${ColorRows} tokens=${group(sem, g).filter((t) => !/^[\d.]+$/.test(t.src))} />`)}+ ${prim && html`<h3 class="t-label">原始色板(只在 semantic.css 里引用)</h3>+ <${ColorRows} tokens=${[...group(prim, "品牌"), ...group(prim, "状态色"), ...group(prim, "黑白")]} />`}+ <//>++ <${Section} id="material" title="材质" lead="窗口最底层是环境光(--bg + 左上的品牌黄绿光 + 跟着当前机器人变的色相光)。侧栏直接盖在环境光上;主区和信息面板是浮起的面板;顶栏、输入框、菜单、对话框是盖在内容上的毛玻璃——半透明底 + 背景模糊 + 磨砂颗粒 + 顶边高光与细描边。系统开了「降低透明度」时,材质换成接近实色。">+ <${Demo} flush title="六种材质" note="底下是会滚过去的内容:顶栏、输入框、菜单、对话框会把它模糊掉" code=${`<div class="glass" style="--glass-bg: var(--glass-pop); --glass-blur: var(--glass-filter-lg); --glass-shadow: var(--shadow-pop)">…</div>+.pop { background: var(--grain), var(--glass-pop); backdrop-filter: var(--glass-filter-lg); box-shadow: var(--shadow-pop); } /* 组件自己就是玻璃时直接写三行 */`}>+ ${() => html`<${GlassStage} />`}+ <//>+ <//>++ <${Section} id="type" title="文字" lead="9 级字号;新界面优先用文字角色类(.t-*),不再挑字号。">+ ${prim && html`<${ScaleRows} tokens=${group(prim, "字号")} sample=${(t) => html`<span style=${{ fontSize: `var(${t.name})` }}>模型网关 Modelflare 0123</span>`} />`}+ <h3 class="t-label">文字角色</h3>+ <${Demo} col code=${`<div class="t-heading">…</div> <p class="t-meta">…</p>`}>+ ${() => html`${[["t-display", "引导页标题"], ["t-heading", "对话框 / 页面标题"], ["t-title", "列表标题"], ["t-prose", "对话正文:15px,行高 1.5"], ["t-body", "界面正文:13px"], ["t-control", "控件文字:12.5px"], ["t-meta", "次要说明:11.5px,muted"], ["t-label", "分组标题:11px semibold"], ["t-caption", "菜单分组:11px,字距 .04em"]].map(+ ([c, s]) => html`<div class="cluster"><code class="t-meta" style="width:96px">.${c}</code><span class=${c}>${s}</span></div>`,+ )}`}+ <//>+ <//>++ <${Section} id="space" title="间距与尺寸" lead="间距以 4 为步长;圆角嵌套时内层 = 外层 − 内边距;控件高度 6 档。">+ ${prim && html`<h3 class="t-label">间距</h3><${ScaleRows} tokens=${group(prim, "间距")} sample=${(t) => html`<div class="gal-bar" style=${{ "--w": `var(${t.name})` }}></div>`} />+ <h3 class="t-label">圆角</h3><${ScaleRows} tokens=${group(prim, "圆角")} sample=${(t) => html`<div class="gal-radius" style=${{ "--r": `var(${t.name})` }}></div>`} />+ <h3 class="t-label">控件高度</h3><${ScaleRows} tokens=${group(prim, "控件高度")} sample=${(t) => html`<div class="gal-height" style=${{ "--h": `var(${t.name})` }}></div>`} />`}+ <//>++ <${Section} id="elevation" title="投影与层级" lead="投影是主题 token(深色下更重);层级只用 --z-*,同一窗格内的浮动件用 calc(var(--z-float) ± 1)。">+ <${Demo} title="投影">+ ${() => html`${["--shadow-xs", "--shadow-sm", "--shadow-md", "--shadow-lg", "--shadow-pane", "--shadow-tile", "--shadow-float", "--shadow-pop", "--primary-edge"].map((s) => html`<div class="gal-elev" style=${{ "--sh": `var(${s})` }}><code class="t-meta">${s}</code></div>`)}`}+ <//>+ ${prim && html`<${ScaleRows} tokens=${group(prim, "层级")} sample=${() => ""} />`}+ <//>++ <${Section} id="motion" title="动效" lead="状态反馈 fast,出现/消失 base,视图与面板 moderate,弹出层 slow/slower + spring。入场 ease-out,退场 ease-in。">+ <div class="cluster" style="margin-bottom: var(--space-3)">+ <${Seg} label="减少动态效果" value=${reduced ? "on" : "off"} onChange=${(v) => setReduced(v === "on")} options=${[["off", "正常"], ["on", "模拟减少动态效果(--motion: 0)"]]} />+ </div>+ <div style=${reduced ? { "--motion": "0" } : {}}>+ <h3 class="t-label">时长</h3>+ <div class="gal-rows">${motion.filter((t) => /^--dur-(fast|base|moderate|slow|slower)$/.test(t.name)).map((t) => html`<div class="gal-row scale" key=${t.name}>+ <${TokenName} t=${t} /><code class="t-meta">${t.src}</code><${Runner} d=${t.name} /></div>`)}</div>+ <h3 class="t-label">缓动</h3>+ <div class="gal-rows">${motion.filter((t) => t.name.startsWith("--ease-")).map((t) => html`<div class="gal-row scale" key=${t.name}>+ <${TokenName} t=${t} /><svg class="gal-curve" viewBox="0 0 56 56"><rect width="56" height="56" /><path d=${bezierPath(t.src)} /></svg><${Runner} d="--dur-slower" e=${t.name} /></div>`)}</div>+ <h3 class="t-label">关键帧库</h3>+ <${Demo} code=${`<div class="anim-rise-in">…</div> /* 可用 --anim-dur / --anim-ease / --anim-delay 微调 */+.toast { --rise: 6px; animation: rise-in var(--dur-base) var(--ease-out); } /* 组件里直接用关键帧 + token */+const { mounted, leaving } = usePresence(open); /* design/motion.js:退场动画播完再卸载 */`}>+ ${() => html`${[["anim-fade-in", "fade-in"], ["anim-rise-in", "rise-in"], ["anim-slide-in", "slide-in"], ["anim-pop-in", "pop-in"], ["anim-sink-out", "sink-out"], ["anim-pop-out", "pop-out"], ["anim-bump", "bump"], ["anim-flash", "flash"]].map(([c, l]) => html`<${Replay} cls=${c} label=${l} />`)}+ <div class="gal-anim"><${Spinner} /><span class="t-meta">spin</span></div>+ <div class="gal-anim"><span class="typing"><i></i><i></i><i></i></span><span class="t-meta">breathe(stagger)</span></div>+ <div class="gal-anim"><span><span class="caret"></span></span><span class="t-meta">blink</span></div>`}+ <//>+ </div>+ <//>++ <${Section} id="states" title="状态矩阵" lead="每个可交互组件的全部状态,浅色一行、深色一行,画在它真实所在的表面上(主区或侧栏玻璃)。悬停、按下、键盘焦点是把样式表里的伪类规则复制成 .is-hover / .is-active / .is-focus 静态画出来的,和真实交互用的是同一份样式;把指针移上去也能直接试。">+ ${STATE_ROWS.map((r) => html`<${StateRow} key=${r.name} ...${r} />`)}+ <//>++ <${Section} id="buttons" title="按钮" lead="变体 primary / 默认 / ghost / danger,尺寸 sm / 默认 / lg。图标按钮必须有 label。">+ <${Demo} title=".btn" code=${`<button class="btn primary lg block">连接</button>+<${"${Button}"} variant="primary" size="lg" loading=\${busy} icon="plus">新建<//>`}>+ ${() => html`<${Button} variant="primary">主要<//><${Button}>默认<//><${Button} variant="ghost">幽灵<//><${Button} variant="danger">删除<//>+ <${Button} variant="primary" size="sm">小号<//><${Button} variant="primary" size="lg">大号<//>+ <${Button} icon="plus">带图标<//><${Button} variant="primary" loading>保存中<//><${Button} disabled>禁用<//>`}+ <//>+ <${Demo} title=".icon-btn · .text · CopyButton">+ ${() => html`<${IconButton} icon="gear" label="设置" /><${IconButton} icon="refresh" label="刷新" on /><${IconButton} icon="close" label="关闭" size="xs" iconSize=${12} />+ <${CopyButton} text="复制的内容" /><button type="button" class="text">文字按钮</button><button type="button" class="text accent">强调</button><button type="button" class="text danger">危险</button>`}+ <//>+ <//>++ <${Section} id="inputs" title="输入">+ <${Demo} col title=".field" note="聚焦:accent 描边 + --ring 光晕" code=${`<input class="field mono err" /> <div class="field-wrap"><input class="field" /><span class="tail">…</span></div>`}>+ ${() => html`<${FieldDemo} />`}+ <//>+ <//>++ <${Section} id="menus" title="菜单与分段">+ <${Demo} title="Seg" note="两个以上的选项;中性 thumb 按值滑动">${() => html`<${SegDemo} />`}<//>+ <${Demo} title="Switch" note="只有开 / 关两态;打开 = 主操作色(浅色墨、深色黄绿)" code=${`<${"${Switch}"} label="长期记忆" value=\${on} onChange=\${setOn} />`}>${() => html`<${SwitchDemo} />`}<//>+ <${Demo} title="MenuButton · Menu" note="↑↓ 选择,Enter 执行,Esc 关闭">${() => html`<${MenuButtonDemo} /><${MenuDemo} />`}<//>+ <//>++ <${Section} id="status" title="状态与反馈">+ <${Demo} title="Badge · dot">+ ${() => html`${["connected", "running", "connecting", "pending", "error", "disabled"].map((s) => html`<${Badge} s=${s} />`)}+ <span class="badge count">3</span><span class="badge count warn">2</span>+ <span class="dot ok"></span><span class="dot warn"></span><span class="dot err"></span><span class="dot"></span>`}+ <//>+ <${Demo} col title="Notice" code=${`<${"${Notice}"} tone="amber" action=\${html\`<button class="btn">去控制台</button>\`}>…<//>`}>+ ${() => html`<${Notice} action=${html`<button type="button" class="btn">操作</button>`}>默认(中性):内置网关已更新,重启后生效。<//>+ <${Notice} tone="amber" action=${html`<button type="button" class="btn">去控制台</button>`}>这个 Key 所在的分组暂无可用模型。<//>+ <${Notice} tone="red" action=${html`<button type="button" class="btn">重试</button>`}>无法连接本机服务:ECONNREFUSED<//>`}+ <//>+ <${Demo} col title="Skeleton · Spinner · 空状态">+ ${() => html`<div class="cluster"><${Skeleton} w="34px" circle /><div class="stack grow"><${Skeleton} w="40%" /><${Skeleton} w="70%" /></div></div>+ <div class="cluster"><${Spinner} /><span class="t-meta">加载中…</span></div>+ <div class="empty-state"><b>还没有会话</b>在微信或飞书里给机器人发一条消息试试</div>`}+ <//>+ <//>++ <${Section} id="lists" title="列表行" lead="设置页的基本单元:一张 .list 卡片,每行说明在左、控件在右,改动即保存。">+ <${Demo} flush>+ ${() => html`<div class="list">+ <div class="row"><div class="who"><div class="name">外观</div><div class="sub">跟随系统、浅色或深色</div></div><div class="ctl"><${SegDemo} /></div></div>+ <div class="row"><div class="who"><div class="name">长期记忆</div><div class="sub">开 / 关用 Switch</div></div><div class="ctl"><${Switch} label="长期记忆" value=${true} onChange=${() => {}} /></div></div>+ <div class="row"><div class="who"><div class="name">默认模型</div><div class="sub">新对话使用的模型</div></div><div class="ctl"><${MenuButtonDemo} /></div></div>+ <div class="row"><div class="who"><div class="name">Modelflare</div><div class="sub">已连接 ••••x9Qa</div></div><div class="ctl"><${Badge} s="connected" /><button type="button" class="text">更换密钥</button></div></div>+ <div class="row compact clickable"><div class="who"><div class="name">.row.compact.clickable</div><div class="sub">信息面板里的紧凑行</div></div><span class="hint num">3 分钟前</span></div>+ <div class="row-edit"><label>展开编辑区 .row-edit<input class="field" placeholder="App ID" /></label><div class="actions"><${Button} variant="primary">保存<//><${Button}>取消<//></div></div>+ </div>`}+ <//>+ <//>++ <${Section} id="overlays" title="对话框与提示" lead="确认框默认聚焦「取消」;危险操作用 danger。对话框退场有动画(usePresence)。">+ <${Demo} title="confirmSheet · toast">+ ${() => html`<${Button} onClick=${() => confirmSheet({ title: "保存这些更改?", body: "改动会立即生效。" }).then((ok) => ok && saved())}>普通确认<//>+ <${Button} variant="danger" onClick=${() => confirmSheet({ title: "删除这个机器人?", body: "对话记录与记忆会一起删除,无法恢复。", confirmLabel: "删除", danger: true })}>危险确认<//>+ <${Button} onClick=${saved}>toast:已保存<//><${Button} onClick=${() => toast("配额快用完了", "warn")}>toast:warn<//><${Button} onClick=${() => failed("上游返回 HTTP 429")}>toast:err<//>`}+ <//>+ <//>++ <${Section} id="avatars" title="头像" lead="6 个内置毛绒角色,蓝色的小蓝是主角。每个机器人配一个:新建页和机器人设置里可以选,模板自带推荐,没选过时由 id 决定,默认机器人是小蓝。持续状态跟着平台走(你在输入、思考、回复、工作、等批准、睡觉),完成、出错、新建时播一次性反应;指针靠近时会看过去,大头像可以戳。">+ <${Demo} title="角色" note="96px · lively · 可以戳(连戳三下、六下试试)">${() => html`<${AvatarCastDemo} />`}<//>+ <${Demo} title="状态与反应" note="上面切持续状态,按钮播一次性反应;点右边的小头像换成主视图">${() => html`<${AvatarStateDemo} />`}<//>+ <${Demo} title="尺寸" note="22 顶栏 / 38 侧栏 / 56 / 96 空态;小于 36px 不画粒子。悬停 38px 那排,天线会弹一下">${() => html`<${AvatarSizeDemo} />`}<//>+ <${Demo} title="配对" note="新建页的模板 → 角色;下面是选择器(AvatarPicker)">${() => html`<${AvatarPairDemo} />`}<//>+ <//>++ <${Section} id="patterns" title="对话" lead="ui/css/chat.css 里的页面模式(顶栏参考 Grok Bot,对话流与输入框参考 Codex):用户消息是浅灰气泡,回复是整列正文,上方一行工作状态,下方悬停出现操作。">+ <${Demo} col>+ ${() => html`<div class="gal-chat">+ <div class="msg-row user"><div class="msg">帮我比较一下几个模型</div><div class="msg-actions"><${CopyButton} text="帮我比较一下几个模型" /><span class="when num">09:24</span></div></div>+ <div class="msg-row assistant last"><div class="work-line"><span>用时 1 分 24 秒</span></div><div class="msg"><${Markdown} text=${MD} /></div>+ <div class="msg-actions"><${CopyButton} text=${MD} /><span class="when num">09:26</span></div></div>+ <div class="msg-row user"><div class="msg">再整理成日报</div></div>+ <div class="msg-row assistant"><div class="work-line live"><span class="shimmer">思考中 12 秒</span></div></div>+ <div class="msg-row assistant"><div class="card"><div class="q-block"><div class="q">要用哪条线路?</div>+ <div class="opts"><button type="button" class="opt picked"><span class="letter">A</span><span>国内线路<span class="desc">延迟低</span></span></button>+ <button type="button" class="opt"><span class="letter">B</span><span>海外线路<span class="desc">模型更全</span></span></button></div></div></div></div>+ <div class="msg-row assistant"><div class="file-card"><${Icon} name="file" size=${32} stroke=${1.2} /><div class="grow"><div class="fname">report.pdf</div><div class="fsub">已交付到机器人工作区</div></div></div></div>+ </div>+ <div class="composer"><textarea rows="1" placeholder="给「我的助手」发消息,/ 查看命令"></textarea>+ <div class="composer-bar"><button type="button" class="plus" aria-label="更多"><${Icon} name="plus" size=${15} stroke=${1.7} /></button><span class="grow"></span>+ <button type="button" class="model-chip"><span class="v">claude-sonnet-5-5</span><${Icon} name="chevDown" /></button>+ <button type="button" class="send" aria-label="发送"><${Icon} name="up" size=${15} stroke=${2} /></button></div></div>+ <div class="chips"><button type="button" class="chip">总结今天的消息</button><button type="button" class="chip">写一封邮件</button></div>`}+ <//>+ <//>++ <${Section} id="custom" title="定制" lead="不改组件源码:在上下文里覆盖组件变量;需要一块不同主题的区域时,加 data-theme。">+ <${Demo} title="覆盖组件变量" code=${`.notice .btn { --btn-h: var(--ctl-sm); --btn-bg: var(--card); } /* 上下文覆盖 */+<button class="btn" style="--btn-bg: var(--green-soft); --btn-fg: var(--green)">…</button>+.thread .badge.count { --badge-bg: var(--amber-soft); --badge-fg: var(--amber); }`}>+ ${() => html`<button type="button" class="btn" style="--btn-bg: var(--green-soft); --btn-fg: var(--green); --btn-bg-hover: var(--green-soft)">绿色按钮</button>+ <button type="button" class="btn primary" style="--btn-r: var(--r-full); --btn-px: var(--space-5)">胶囊主按钮</button>+ <span class="badge" style="--badge-bg: var(--accent-soft); --badge-fg: var(--accent)">自定义徽标</span>+ <div class="seg" style="--seg-thumb: var(--card); --seg-on: var(--fg)"><span class="thumb" style="width:52px;transform:translateX(0)"></span><button type="button" class="on">中性</button><button type="button">分段</button></div>`}+ <//>+ <${Demo} title="局部主题" code=${`<div data-theme="dark">…</div> /* 子树换一套语义 token */`}>+ ${() => html`<div data-theme="dark" class="cluster" style="padding: var(--space-3); border-radius: var(--r-xl)"><${Button} variant="primary">深色区域<//><${Badge} s="running" /><span class="t-meta">--bg / --fg 自动切换</span></div>+ <div data-theme="light" class="cluster" style="padding: var(--space-3); border-radius: var(--r-xl); box-shadow: inset 0 0 0 1px var(--line)"><${Button} variant="primary">浅色区域<//><${Badge} s="running" /></div>`}+ <//>+ <//>+ </div>+ </main>+ <${Toasts} />+ <${DialogHost} />+ </div><//>`;+}++// 等 @import 进来的样式表都加载完再复制伪类规则+if (document.readyState === "complete") mirrorPseudoStates();+else addEventListener("load", mirrorPseudoStates, { once: true });+render(html`<${Gallery} />`, document.getElementById("app"));diff --git a/ui/design/index.css b/ui/design/index.cssnew file mode 100644index 0000000..a438be9--- /dev/null+++ b/ui/design/index.css@@ -0,0 +1,29 @@+/* AnyModelBot 设计库入口。规范见 ui/design/README.md,在线样例见 /amb/static/design/index.html。+ 层叠顺序(后面的层总是赢,与选择器权重无关):+ tokens → base → components → app(页面样式,ui/css/*)→ utilities+ 页面样式放在 app 层,可以随意覆盖组件,不用拼选择器权重;工具类排最后,加上就生效。 */+@layer tokens, base, components, app, utilities;++@import url("tokens/primitives.css") layer(tokens);+@import url("tokens/semantic.css") layer(tokens);+@import url("tokens/motion.css") layer(tokens);++@import url("base/reset.css") layer(base);+@import url("base/motion.css") layer(base);++@import url("components/glass.css") layer(components);+@import url("components/button.css") layer(components);+@import url("components/field.css") layer(components);+@import url("components/badge.css") layer(components);+@import url("components/list.css") layer(components);+@import url("components/seg.css") layer(components);+@import url("components/switch.css") layer(components);+@import url("components/popover.css") layer(components);+@import url("components/sheet.css") layer(components);+@import url("components/toast.css") layer(components);+@import url("components/notice.css") layer(components);+@import url("components/feedback.css") layer(components);+@import url("components/avatar.css") layer(components);++@import url("base/typography.css") layer(utilities);+@import url("base/utilities.css") layer(utilities);diff --git a/ui/design/index.html b/ui/design/index.htmlnew file mode 100644index 0000000..8f82c28--- /dev/null+++ b/ui/design/index.html@@ -0,0 +1,32 @@+<!doctype html>+<html lang="zh-CN">+<head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <title>AnyModelBot 设计库</title>+ <link rel="icon" href="data:," />+ <script>+ // 与 ui/index.html 相同:首帧前解析主题与平台+ (function () {+ var root = document.documentElement;+ var m = "system";+ try { m = localStorage.getItem("amb-theme") || "system"; } catch (_) {}+ var dark = m === "dark" || (m !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);+ root.setAttribute("data-theme", dark ? "dark" : "light");+ if (/Windows/.test(navigator.userAgent)) root.classList.add("win");+ })();+ </script>+ <link rel="stylesheet" href="/amb/static/design/index.css" />+ <link rel="stylesheet" href="/amb/static/css/shell.css" />+ <link rel="stylesheet" href="/amb/static/css/chat.css" />+ <link rel="stylesheet" href="/amb/static/css/settings.css" />+ <link rel="stylesheet" href="/amb/static/design/gallery.css" />+ <script type="importmap">+ { "imports": { "preact": "/amb/vendor/preact.mjs", "preact/hooks": "/amb/vendor/hooks.mjs", "htm": "/amb/vendor/htm.mjs" } }+ </script>+</head>+<body>+ <div id="app"></div>+ <script type="module" src="/amb/static/design/gallery.js"></script>+</body>+</html>diff --git a/ui/design/motion.js b/ui/design/motion.jsnew file mode 100644index 0000000..7edea87--- /dev/null+++ b/ui/design/motion.js@@ -0,0 +1,32 @@+// 动效的 JS 一侧:读取 CSS 时长 token、尊重"减少动态效果"、让退场动画播完再卸载。+// 时长只在 tokens/motion.css 里定义一次,JS 用 ms("--dur-base") 读,不要再写死毫秒数。+import { useEffect, useState } from "preact/hooks";++const mq = window.matchMedia("(prefers-reduced-motion: reduce)");++export const reducedMotion = () => mq.matches;++/** "--dur-base" → 180;token 不存在或不是时长时返回 fallback */+export function ms(token, fallback = 0) {+ const v = getComputedStyle(document.documentElement).getPropertyValue(token).trim();+ const n = parseFloat(v);+ if (!Number.isFinite(n)) return fallback;+ return v.endsWith("ms") ? n : v.endsWith("s") ? n * 1000 : fallback;+}++/**+ * 进出场:open 变 false 后再保留挂载 exit 时长,期间 leaving = true(给元素加 .leaving 或 .anim-*-out)。+ * const { mounted, leaving } = usePresence(open);+ * if (!mounted) return null;+ */+export function usePresence(open, exit = "--dur-base") {+ const [state, setState] = useState(open ? "open" : "closed");+ useEffect(() => {+ if (open) return setState("open");+ if (state === "closed") return;+ setState("leaving");+ const t = setTimeout(() => setState("closed"), ms(exit, 180));+ return () => clearTimeout(t);+ }, [open]);+ return { mounted: open || state !== "closed", leaving: !open && state !== "closed" };+}diff --git a/ui/design/tokens/motion.css b/ui/design/tokens/motion.cssnew file mode 100644index 0000000..ff8996b--- /dev/null+++ b/ui/design/tokens/motion.css@@ -0,0 +1,59 @@+/* 动效 token。原则:+ - 状态反馈(悬停、按下、颜色)用 fast;出现/消失用 base;整块视图或面板用 moderate;+ 弹出层与对话框的弹性入场用 slow/slower + spring。+ - 入场用 ease-out(或 spring),退场用 ease-in,循环用 ease-in-out 或 linear。+ - 位移量也是 token(--rise / --slide / --pop-*),组件可以局部覆盖;关键帧把它们乘以 --motion,+ 减少动态效果时 --motion = 0,所有入场自动退化成纯淡入。 */+:root {+ --dur-fast: 120ms;+ --dur-base: 180ms;+ --dur-moderate: 240ms;+ --dur-slow: 360ms;+ --dur-slower: 420ms;++ --ease-out: cubic-bezier(.2, .8, .2, 1);+ --ease-in: cubic-bezier(.4, 0, 1, 1);+ --ease-in-out: cubic-bezier(.42, 0, .58, 1);+ --ease-spring: cubic-bezier(.16, 1, .3, 1);+ --ease-back: cubic-bezier(.34, 1.56, .64, 1); /* 越过一点再回来:头像的弹跳 */++ /* 时长 + 缓动的组合:transition: background var(--t-fast), color var(--t-fast) */+ --t-fast: var(--dur-fast) var(--ease-out);+ --t-base: var(--dur-base) var(--ease-out);+ --t-moderate: var(--dur-moderate) var(--ease-out);++ /* 循环 */+ --dur-spin: 800ms;+ --dur-blink: 1s;+ --dur-shimmer: 1.2s;+ --dur-pulse: 1.4s;+ --dur-flash: 1.2s;+ --dur-ambient: 1.2s; /* 环境光换色(切换机器人时) */+ --stagger: 150ms;+ --dur-off: .01ms; /* 减少动态效果时代替 0:时长为 0 的过渡不触发 transitionend */++ /* 机器人头像的一次性反应(avatar.js 用 ms() 读,播完回到持续状态) */+ --bot-hello: 1.6s;+ --bot-done: 1.3s;+ --bot-error: 1.5s;+ --bot-poke: .7s;+ --bot-love: 1.6s;+ --bot-dizzy: 2.2s;++ /* 位移量 */+ --motion: 1;+ --rise: 6px;+ --slide: 12px;+ --pop-dy: -6px;+ --pop-scale: .94;+ --press: .96;+ --press-strong: .94;+}+@media (prefers-reduced-motion: reduce) {+ :root {+ --motion: 0;+ --press: 1;+ --press-strong: 1;+ --dur-spin: 1.6s;+ }+}diff --git a/ui/design/tokens/primitives.css b/ui/design/tokens/primitives.cssnew file mode 100644index 0000000..c294837--- /dev/null+++ b/ui/design/tokens/primitives.css@@ -0,0 +1,145 @@+/* L1 · 原始值(primitives):与主题无关的色板与尺度。+ 颜色:组件和页面不直接用这一层,一律通过 semantic.css 的语义 token 取色。+ 尺度(间距、字号、圆角、控件高度、层级):组件可以直接用。+ Modelflare 品牌色:信号黄绿 #d7ff00 + 墨色 #161a00(modelflare.dev / docs.modelflare.dev),+ 浅色前景用定价页的橄榄绿 #5f711c(黄绿在白底上只有 1.15:1)。 */+:root {+ /* —— 品牌:黄绿(填充)与橄榄(前景) —— */+ --lime-100: #edf7b8;+ --lime-200: #e9ff66;+ --lime-300: #e6ff4d;+ --lime-400: #daff14;+ --lime-500: #d7ff00;+ --lime-600: #c7ef00;+ --olive-50: #f1f4e9;+ --olive-500: #789600;+ --olive-600: #5f711c;+ --olive-700: #465612;+ --olive-900: #31361a;+ --olive-950: #161a00;++ /* —— 状态色:50/900 是浅/深底,300/600(700) 是深/浅底上的前景 —— */+ --green-50: #e4f6ec;+ --green-300: #6fd99b;+ --green-600: #189a58;+ --green-900: #1e3a2b;+ --red-50: #fbe9e9;+ --red-300: #f28b82;+ --red-600: #d64545;+ --red-900: #45272a;+ --red-950: #3b0d0a;+ --amber-50: #fbf0df;+ --amber-300: #f2b544;+ --amber-700: #b45309;+ --amber-900: #3f3220;++ /* —— 机器人角色:取自 anymodelbot_design 原图的眼睛与辉光,两个主题相同 —— */+ --bot-blue-eye: #6dd4fb;+ --bot-blue-glow: #2a9dff;+ --bot-yellow-eye: #fcfcdc;+ --bot-yellow-glow: #ffc21a;+ --bot-green-eye: #b5fbd6;+ --bot-green-glow: #2ee88a;+ --bot-red-eye: #fc9379;+ --bot-red-glow: #ff3b2a;+ --bot-purple-eye: #fdc1fb;+ --bot-purple-glow: #c24dff;+ --bot-orange-eye: #fdd77c;+ --bot-orange-glow: #ff8c1a;+ --bot-blush: #ff7aa8;+ --bot-glint: rgba(255, 255, 255, .8); /* 镜片、宝石上扫过的反光 */++ /* —— 黑白 —— */+ --white: #ffffff;+ --black: #000000;++ /* —— 间距:4 的倍数,另有 2/6/10/14 半步 —— */+ --space-0-5: 2px;+ --space-1: 4px;+ --space-1-5: 6px;+ --space-2: 8px;+ --space-2-5: 10px;+ --space-3: 12px;+ --space-3-5: 14px;+ --space-4: 16px;+ --space-5: 20px;+ --space-6: 24px;+ --space-8: 32px;+ --space-10: 40px;+ --space-12: 48px;+ --space-16: 64px;++ /* —— 字号:8 级。桌面应用的密度,小号保留半像素 —— */+ --fs-2xs: 11px; /* 分组标题、徽标、快捷键 */+ --fs-xs: 11.5px; /* 次要说明、元信息、等宽值 */+ --fs-sm: 12.5px; /* 控件:按钮、菜单项、分段、输入框 */+ --fs-md: 13px; /* 界面正文 */+ --fs-lg: 14px; /* 列表标题、面板标题 */+ --fs-xl: 15px; /* 对话正文、对话框标题 */+ --fs-2xl: 17px; /* 空状态标题 */+ --fs-3xl: 20px; /* 引导页标题 */+ --fs-4xl: 24px; /* 页面大标题(设置、机器人设置) */++ /* —— 字重、行高、字距 —— */+ --fw-regular: 400;+ --fw-medium: 500;+ --fw-semibold: 600;++ --lh-tight: 1.3;+ --lh-snug: 1.4;+ --lh-normal: 1.5;+ --lh-relaxed: 1.55;++ --tracking-tighter: -.02em;+ --tracking-tight: -.01em;+ --tracking-caps: .04em;++ /* —— 圆角:嵌套时内层 = 外层 − 内边距(.seg 8 → thumb 6) —— */+ --r-xs: 4px;+ --r-sm: 6px;+ --r-md: 8px;+ --r-lg: 10px;+ --r-xl: 12px;+ --r-2xl: 14px;+ --r-3xl: 20px;+ --r-full: 999px;++ /* —— 控件高度 —— */+ --ctl-xs: 22px;+ --ctl-sm: 24px;+ --ctl-md: 28px;+ --ctl-lg: 32px;+ --ctl-xl: 36px;+ --ctl-2xl: 44px;++ /* —— 层级:同一窗格内的浮动件 < 抽屉 < 弹出层 < 模态 < 命令面板 < 提示 —— */+ --z-raised: 1;+ --z-float: 5;+ --z-drawer: 30;+ --z-popover: 40;+ --z-modal: 50;+ --z-palette: 56;+ --z-toast: 60;++ /* —— 透明度 —— */+ --o-disabled: .45;++ /* —— 毛玻璃:背景模糊半径与饱和度增强。材质的颜色在 semantic.css —— */+ --blur-sm: 12px; /* 小浮件:回到底部、提示胶囊 */+ --blur-md: 24px; /* 顶栏、输入框 */+ --blur-lg: 40px; /* 菜单、命令面板、对话框 */+ --blur-scrim: 6px; /* 对话框后面的遮罩 */+ --glass-sat: 180%; /* 透出来的颜色更饱满,玻璃才不发灰 */+ --glass-filter: blur(var(--blur-md)) saturate(var(--glass-sat));+ --glass-filter-lg: blur(var(--blur-lg)) saturate(var(--glass-sat));+ --glass-filter-sm: blur(var(--blur-sm)) saturate(var(--glass-sat));++ /* —— 版式宽度 —— */+ --side-w: 280px;+ --panel-w: 320px;+ --col-w: 760px; /* 对话阅读列:参考 Codex,回复是整列宽的正文 */+ --bubble-w: 600px; /* 用户气泡最大宽度 */+ --head-h: 52px; /* 对话顶栏、信息面板顶栏 */+ --page-w: 680px; /* 设置页、机器人设置的内容列 */+ --pane-gap: 8px; /* 主区、信息面板与窗口边缘的间隙:它们是浮在环境光上的面板 */+}diff --git a/ui/design/tokens/semantic.css b/ui/design/tokens/semantic.cssnew file mode 100644index 0000000..ba5695f--- /dev/null+++ b/ui/design/tokens/semantic.css@@ -0,0 +1,238 @@+/* L2 · 语义 token:按用途命名,按主题取值。组件和页面只用这一层的颜色。+ 中性灰、圆角与动效改编自 yetone/magpie internal/gui/assets/app.css(MIT,© 2026 yetone)。+ 中性色按主题逐个精调,直接写在这里,不经过原始色板。++ 空间结构(见 README「材质」):窗口最底层是环境光(--bg + 柔光),侧栏是直接盖在上面的毛玻璃,+ 主区和信息面板是浮在环境光上的面板;顶栏、输入框、菜单、对话框是盖在内容上的玻璃。+ 所以填充、悬停、描边都是半透明的一层,放在玻璃和实色上都对。++ 主题可以局部生效:任何元素加 data-theme="light|dark",它的子树就换一套取值。+ <html data-theme> 总是解析后的值,由 index.html 在首帧前设置、lib/theme.js 保持同步。 */+:root, [data-theme="light"] {+ color-scheme: light;++ /* —— 环境:窗口最底层的柔光,玻璃透出它;色相光跟着当前机器人变(shell.css 的 .app) —— */+ --bg: #efefed; /* 窗口底色、引导页 */+ --aura-brand: color-mix(in srgb, var(--lime-500) 30%, transparent); /* 左上角的品牌黄绿光 */+ --aura-l: .88; /* 机器人色相光:OKLCH 亮度 */+ --aura-c: .06; /* 彩度 */+ --aura-a: .85; /* 不透明度 */++ /* —— 材质:毛玻璃 = 半透明底 + 背景模糊(--glass-filter*)+ 磨砂颗粒 + 顶边高光与细描边 —— */+ --surface: rgba(255, 255, 255, .86); /* 主区:对话、设置。底下是平滑的环境光,不需要模糊 */+ --surface-solid: #ffffff; /* 主区上需要实色的地方 */+ --glass-side: rgba(255, 255, 255, .42); /* 侧栏 */+ --glass-chrome: rgba(255, 255, 255, .72); /* 盖在滚动内容上的顶栏 */+ --glass-float: rgba(255, 255, 255, .68); /* 输入框、回到底部 */+ --glass-panel: rgba(255, 255, 255, .66); /* 信息面板 */+ --glass-pop: rgba(252, 252, 252, .74); /* 菜单、命令面板、提示 */+ --glass-sheet: rgba(255, 255, 255, .84); /* 对话框 */+ --glass-edge: rgba(0, 0, 0, .08); /* 玻璃的细描边 */+ --glass-hi: rgba(255, 255, 255, .8); /* 玻璃顶边的高光 */+ --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23g)' opacity='.035'/%3E%3C/svg%3E"); /* 磨砂颗粒 */++ /* —— 表面:卡片与静默填充。填充都是半透明的一层 —— */+ --card: #ffffff; /* 卡片、输入框 */+ --card-2: rgba(0, 0, 0, .022); /* 卡片里的次级面、代码块 */+ --pill: rgba(0, 0, 0, .045); /* 次级按钮、标签、静默填充;也是控件的悬停层 */+ --pill-hover: rgba(0, 0, 0, .075);+ --pill-press: rgba(0, 0, 0, .1);+ --seg-track: rgba(0, 0, 0, .055);+ --seg-thumb-bg: var(--white);+ --side-hover: rgba(255, 255, 255, .55); /* 侧栏行:悬停是更亮的一层玻璃 */+ --side-press: rgba(255, 255, 255, .36);+ --side-active: rgba(255, 255, 255, .9); /* 选中:浮起的白色玻璃片 */+ --bubble-user: rgba(0, 0, 0, .05); /* 用户消息气泡;机器人回复不加气泡 */+ --bubble-ai: rgba(0, 0, 0, .035); /* 信息面板里的会话记录等次要气泡 */+ --qr-bg: var(--white); /* 二维码在任何主题下都要白底 */+ --scrim: rgba(0, 0, 0, .2);+ --scrim-soft: rgba(0, 0, 0, .1);+ --scroll-thumb: rgba(0, 0, 0, .16);+ --scroll-thumb-hover: rgba(0, 0, 0, .3);++ /* —— 线 —— */+ --line: rgba(0, 0, 0, .1); /* 输入框边、卡片边 */+ --line-2: rgba(0, 0, 0, .06); /* 卡片内分隔线 */+ --line-strong: rgba(0, 0, 0, .2); /* 悬停的输入框、聚焦的对话输入框 */++ /* —— 文字 —— */+ --fg: #1a1a1a;+ --fg-2: #4d4d4d;+ --muted: #737373; /* 玻璃上的次要文字,侧栏最浅处约 4:1 */+ --faint: #b3b3b3;+ --ctl-fg: #5e5e5e; /* 静默控件上的图标与文字 */+ --placeholder: #949494;++ /* —— 品牌:墨色负责操作,Modelflare 黄绿是"亮起的信号"(用法见 README「品牌色」) —— */+ --primary: var(--olive-950); /* 主按钮、打开的开关:浅色下是 Modelflare 墨色 */+ --primary-hover: color-mix(in srgb, var(--olive-950) 84%, var(--white));+ --primary-press: color-mix(in srgb, var(--olive-950) 72%, var(--white));+ --on-primary: var(--white);+ --primary-edge: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(22, 26, 0, .28); /* 主按钮的顶边高光 + 落影 */+ --send-bg: var(--olive-950); /* 发送 / 停止:墨色圆钮 + 黄绿箭头 */+ --send-fg: var(--lime-500);+ --accent: var(--olive-950); /* 焦点描边、勾选、指示点、链接 */+ --accent-solid: var(--lime-500); /* 黄绿填充面:应用标志、"已保存"、选中模板的图标 */+ --on-accent: var(--olive-950); /* 黄绿面上的字,15.39:1 */+ --accent-line: color-mix(in srgb, var(--olive-500) 35%, transparent);+ --accent-soft: color-mix(in srgb, var(--lime-500) 45%, transparent); /* 焦点光晕 */+ --accent-wash: color-mix(in srgb, var(--lime-500) 14%, transparent); /* 选中卡片的底 */+ --mark: color-mix(in srgb, var(--lime-500) 55%, var(--white)); /* 荧光笔:文字选区、定位闪烁 */+ --on-mark: var(--olive-950);+ --sel: rgba(0, 0, 0, .055); /* 菜单、命令面板的当前项(悬停或键盘) */+ --sel-press: rgba(0, 0, 0, .09);+ --switch-off: rgba(0, 0, 0, .13);+ --switch-off-hover: rgba(0, 0, 0, .19);+ --switch-knob: var(--white);+ --switch-knob-on: var(--white);++ /* —— 状态 —— */+ --green: var(--green-600);+ --green-soft: var(--green-50);+ --red: var(--red-600);+ --red-soft: var(--red-50);+ --on-danger: var(--white);+ --amber: var(--amber-700);+ --amber-soft: var(--amber-50);++ /* —— 投影:xs/sm 贴面,md 浮起的胶囊,lg 弹出层与对话框,pane 浮在环境光上的面板 —— */+ --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 10px rgba(0, 0, 0, .05);+ --shadow-md: 0 2px 6px rgba(0, 0, 0, .05), 0 10px 28px rgba(0, 0, 0, .09);+ --shadow-lg: 0 4px 12px rgba(0, 0, 0, .06), 0 24px 60px rgba(0, 0, 0, .16);+ --shadow-pane: 0 0 0 .5px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .04), 0 8px 30px rgba(0, 0, 0, .04);+ --shadow-tile: 0 0 0 .5px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .06); /* 侧栏选中项:浮起的玻璃片 */+ --seg-edge: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .08);++ /* —— 机器人头像:角色颜色在 primitives 的 --bot-*,这里只给随主题变的光晕和影子 —— */+ --avatar-aura: 30%; /* 工作中头像背后的辉光(角色辉光色的混合比例) */+ --avatar-shadow: rgba(0, 0, 0, .16); /* 大头像脚下的影子 */++ /* —— 字体 —— */+ --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;+ --code: ui-monospace, "SF Mono", Menlo, Consolas, "Microsoft YaHei UI", monospace;+}+/* 由其他语义 token 推导的值:每个主题作用域都要重新计算,否则子树会继承外层主题算好的结果 */+:root, [data-theme] {+ --code-bg: color-mix(in srgb, var(--fg) 7%, transparent);+ --ring: 0 0 0 3px var(--accent-soft); /* 焦点光晕,配合 accent 色描边 */+ --ring-danger: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent);+ --glass-ring: inset 0 1px 0 var(--glass-hi), 0 0 0 .5px var(--glass-edge); /* 玻璃的边:顶边高光 + 细描边 */+ --shadow-float: var(--glass-ring), var(--shadow-md); /* 浮在内容上的玻璃:输入框、回到底部、提示 */+ --shadow-pop: var(--glass-ring), var(--shadow-lg); /* 菜单、命令面板、对话框 */+}+:root.win {+ --font: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;+ --code: "Cascadia Mono", Consolas, "Microsoft YaHei UI", "Microsoft YaHei", monospace;+}++[data-theme="dark"] {+ color-scheme: dark;++ --bg: #0c0c0c;+ --aura-brand: color-mix(in srgb, var(--lime-500) 8%, transparent);+ --aura-l: .4;+ --aura-c: .1;+ --aura-a: .55;++ --surface: rgba(20, 20, 20, .84);+ --surface-solid: #151515;+ --glass-side: rgba(16, 16, 16, .4);+ --glass-chrome: rgba(22, 22, 22, .7);+ --glass-float: rgba(42, 42, 42, .62);+ --glass-panel: rgba(26, 26, 26, .68);+ --glass-pop: rgba(36, 36, 36, .72);+ --glass-sheet: rgba(30, 30, 30, .86);+ --glass-edge: rgba(255, 255, 255, .09);+ --glass-hi: rgba(255, 255, 255, .07);+ --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23g)' opacity='.05'/%3E%3C/svg%3E");++ --card: rgba(255, 255, 255, .045);+ --card-2: rgba(255, 255, 255, .025);+ --pill: rgba(255, 255, 255, .065);+ --pill-hover: rgba(255, 255, 255, .095);+ --pill-press: rgba(255, 255, 255, .125);+ --seg-track: rgba(255, 255, 255, .05);+ --seg-thumb-bg: rgba(255, 255, 255, .14);+ --side-hover: rgba(255, 255, 255, .045);+ --side-press: rgba(255, 255, 255, .03);+ --side-active: rgba(255, 255, 255, .085);+ --bubble-user: rgba(255, 255, 255, .075);+ --bubble-ai: rgba(255, 255, 255, .05);+ --scrim: rgba(0, 0, 0, .48);+ --scrim-soft: rgba(0, 0, 0, .3);+ --scroll-thumb: rgba(255, 255, 255, .16);+ --scroll-thumb-hover: rgba(255, 255, 255, .3);++ --line: rgba(255, 255, 255, .1);+ --line-2: rgba(255, 255, 255, .065);+ --line-strong: rgba(255, 255, 255, .22);++ --fg: #ececec;+ --fg-2: #b4b4b4;+ --muted: #959595;+ --faint: #5a5a5a;+ --ctl-fg: #a3a3a3;+ --placeholder: #707070;++ --primary: var(--lime-500); /* 深色下主操作直接是黄绿,和 Modelflare 官网一致 */+ --primary-hover: var(--lime-300);+ --primary-press: var(--lime-600);+ --on-primary: var(--olive-950);+ --primary-edge: inset 0 1px 0 rgba(255, 255, 255, .45), 0 1px 2px rgba(0, 0, 0, .4);+ --send-bg: var(--lime-500);+ --send-fg: var(--olive-950);+ --accent: var(--lime-500);+ --accent-soft: color-mix(in srgb, var(--lime-500) 14%, transparent);+ --accent-line: color-mix(in srgb, var(--lime-500) 30%, transparent);+ --accent-wash: color-mix(in srgb, var(--lime-500) 7%, transparent);+ --mark: color-mix(in srgb, var(--lime-500) 32%, transparent);+ --on-mark: var(--fg);+ --sel: rgba(255, 255, 255, .08);+ --sel-press: rgba(255, 255, 255, .115);+ --switch-off: rgba(255, 255, 255, .16);+ --switch-off-hover: rgba(255, 255, 255, .22);+ --switch-knob: #d4d4d4;+ --switch-knob-on: var(--olive-950);++ --green: var(--green-300);+ --green-soft: var(--green-900);+ --red: var(--red-300);+ --red-soft: var(--red-900);+ --on-danger: var(--red-950);+ --amber: var(--amber-300);+ --amber-soft: var(--amber-900);++ --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .25);+ --shadow-md: 0 2px 8px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .42);+ --shadow-lg: 0 4px 14px rgba(0, 0, 0, .35), 0 28px 70px rgba(0, 0, 0, .6);+ --shadow-pane: 0 0 0 .5px rgba(255, 255, 255, .08), 0 8px 30px rgba(0, 0, 0, .35);+ --shadow-tile: inset 0 1px 0 rgba(255, 255, 255, .05), 0 0 0 .5px rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .3);+ --seg-edge: inset 0 .5px 0 rgba(255, 255, 255, .1), 0 1px 2px rgba(0, 0, 0, .3);++ --avatar-aura: 52%;+ --avatar-shadow: rgba(0, 0, 0, .5);+}++/* 系统设置了"降低透明度":玻璃换成接近实色的材质,层次靠描边和投影 */+@media (prefers-reduced-transparency: reduce) {+ [data-theme="light"] {+ --surface: #fbfbfb;+ --glass-side: #f2f2f1;+ --glass-chrome: #fbfbfb;+ --glass-float: #ffffff;+ --glass-panel: #f8f8f8;+ --glass-pop: #fcfcfc;+ --glass-sheet: #ffffff;+ }+ [data-theme="dark"] {+ --surface: #161616;+ --glass-side: #121212;+ --glass-chrome: #161616;+ --glass-float: #262626;+ --glass-panel: #1a1a1a;+ --glass-pop: #242424;+ --glass-sheet: #1e1e1e;+ }+}diff --git a/ui/index.html b/ui/index.htmlindex 1a17b9f..d8f7874 100644--- a/ui/index.html+++ b/ui/index.html@@ -17,10 +17,9 @@if (/Electron/.test(navigator.userAgent) && /Mac/.test(navigator.platform)) root.classList.add("mac-app");})();</script>- <link rel="stylesheet" href="/amb/static/tokens.css" />- <link rel="stylesheet" href="/amb/static/css/base.css" />+ <!-- 设计库(token / 基础 / 组件 / 工具类,见 ui/design/README.md)+ 页面样式(@layer app) -->+ <link rel="stylesheet" href="/amb/static/design/index.css" /><link rel="stylesheet" href="/amb/static/css/shell.css" />- <link rel="stylesheet" href="/amb/static/css/avatar.css" /><link rel="stylesheet" href="/amb/static/css/chat.css" /><link rel="stylesheet" href="/amb/static/css/settings.css" /><script type="importmap">diff --git a/ui/lib/format.js b/ui/lib/format.jsindex 29f72fe..c774bed 100644--- a/ui/lib/format.js+++ b/ui/lib/format.js@@ -25,6 +25,15 @@ export function fmtAgo(t) {return `${d.getMonth() + 1}月${d.getDate()}日`;}+/** 消息旁的时刻:"15:33" */+export const fmtClock = (t) => (t ? hm(new Date(t)) : "");++/** 一段工作的用时:"12 秒" / "1 分 24 秒" */+export function fmtDur(ms) {+ const s = Math.max(1, Math.round(ms / 1000));+ return s < 60 ? `${s} 秒` : `${Math.floor(s / 60)} 分 ${s % 60} 秒`;+}+export function fmtTime(t) {return t ? new Date(t).toLocaleString("zh-CN", { hour12: false }) : "";}diff --git a/ui/lib/store.js b/ui/lib/store.jsindex 1148ac6..b2b5c3b 100644--- a/ui/lib/store.js+++ b/ui/lib/store.js@@ -1,5 +1,6 @@// 极小的全局状态:toast、确认框、主题。组件用 useStore 订阅。import { useEffect, useState } from "preact/hooks";+import { ms } from "../design/motion.js";export function createStore(initial) {let value = initial;@@ -35,7 +36,7 @@ export function toast(text, kind = "ok") {}export function dismissToast(id) {toasts.set((l) => l.map((t) => (t.id === id ? { ...t, leaving: true } : t)));- setTimeout(() => toasts.set((l) => l.filter((t) => t.id !== id)), 200);+ setTimeout(() => toasts.set((l) => l.filter((t) => t.id !== id)), ms("--dur-base", 180));}export const saved = () => toast("已保存");export const failed = (e) => toast(typeof e === "string" ? e : e?.message || "出错了", "err");diff --git a/ui/main.js b/ui/main.jsindex a436cc7..24b5bb0 100644--- a/ui/main.js+++ b/ui/main.js@@ -6,18 +6,21 @@ import { html, Icon, DialogHost, Toasts } from "./components/ui.js";import { Sidebar } from "./screens/sidebar.js";import { ChatScreen } from "./screens/chat.js";import { InfoPanel } from "./screens/info-panel.js";-import { SettingsScreen, TABS } from "./screens/settings.js";+import { SettingsScreen, SettingsSide, TABS } from "./screens/settings.js";import { BotSettingsScreen } from "./screens/bot-settings.js";+import { NewBotScreen } from "./screens/new-bot.js";+import { BotAvatar, MAIN_CHAR, charOf } from "./components/avatar.js";import { Onboarding } from "./screens/onboarding.js";import { api } from "./lib/api.js";import { setThemeMode } from "./lib/theme.js";import { failed } from "./lib/store.js";-// —— 路由:#/chat/<bot> · #/settings/<tab>[/<row>] · #/bot/<bot>/settings[/<section>] ——+// —— 路由:#/chat/<bot> · #/new · #/settings/<tab>[/<row>] · #/bot/<bot>/settings[/<section>] ——function parseHash() {const [kind, a, b, c] = location.hash.replace(/^#\/?/, "").split("/").map((x) => decodeURIComponent(x || ""));if (kind === "settings") return { view: "settings", tab: TABS.some(([t]) => t === a) ? a : "general", row: b || "" };if (kind === "bot" && a && b === "settings") return { view: "bot-settings", botId: a, section: c || "" };+ if (kind === "new") return { view: "new" };if (kind === "models") return { view: "settings", tab: "modelflare", row: "" }; // 旧链接return { view: "chat", botId: kind === "chat" ? a : "" };}@@ -112,6 +115,9 @@ function Palette({ commands, onClose }) {</div>`;}+/** 环境光色相(OKLCH 色相角):和头像角色的主色一致 */+const AURA_HUE = { blue: 245, yellow: 95, green: 155, red: 25, purple: 305, orange: 55 };+function App() {const [route, setRoute] = useState(parseHash);const [mf, mfErr, reloadMf] = useLoader(() => api("/modelflare"));@@ -126,7 +132,7 @@ function App() {const [localWorking, setLocalWorking] = useState({});const [infoOpen, setInfoOpen] = useState(false);const [palette, setPalette] = useState(false);- const [creating, setCreating] = useState(false);+ const [settingsQ, setSettingsQ] = useState("");const [lastBot, setLastBot] = useState(readLastBot);useEffect(() => {@@ -164,7 +170,7 @@ function App() {.then((d) => {const latest = {};for (const c of d.conversations || []) if (!latest[c.botId] || c.updatedAt > latest[c.botId].updatedAt) latest[c.botId] = c;- setPreviews(Object.fromEntries(Object.entries(latest).map(([k, c]) => [k, (c.lastMessage || "").replace(/\s+/g, " ")])));+ setPreviews(Object.fromEntries(Object.entries(latest).map(([k, c]) => [k, { text: (c.lastMessage || "").replace(/\s+/g, " "), at: c.updatedAt }])));}).catch(() => {});api("/approvals?status=pending")@@ -207,6 +213,10 @@ function App() {if (id) setLastBot(id);go(`/chat/${encodeURIComponent(id || (bot && bot.id) || "")}`);};+ const newBot = () => go("/new");+ useEffect(() => {+ if (route.view !== "settings") setSettingsQ("");+ }, [route.view]);const openBotSettings = (id, section = "") => go(`/bot/${encodeURIComponent(id)}/settings${section ? "/" + section : ""}`);const onBotUpdated = () => reloadBots();const onDeleted = (id) => {@@ -232,11 +242,12 @@ function App() {if (route.view === "chat") setInfoOpen((v) => !v);} else if (mod(e) && !e.shiftKey && e.key.toLowerCase() === "n") {e.preventDefault();- setCreating(true);+ newBot();} else if (e.key === "Escape" && !e.defaultPrevented) {const t = e.target;const typing = t && (t.tagName === "TEXTAREA" || t.tagName === "INPUT");if (route.view === "bot-settings" && !typing) openChat(route.botId);+ else if (route.view === "new" && !typing && bots && bots.length) openChat();else if (route.view === "settings" && !typing) openChat();else if (route.view === "chat" && infoOpen && !typing) setInfoOpen(false);}@@ -247,7 +258,7 @@ function App() {const commands = [{ label: "打开设置", kbd: isMac ? "⌘," : "Ctrl+,", keys: "settings preferences", run: () => openSettings() },- { label: "新建机器人", kbd: isMac ? "⌘N" : "Ctrl+N", keys: "new bot", run: () => setCreating(true) },+ { label: "新建机器人", kbd: isMac ? "⌘N" : "Ctrl+N", keys: "new bot", run: newBot },...(route.view === "chat" ? [{ label: infoOpen ? "关闭信息面板" : "打开信息面板", kbd: isMac ? "⌘⇧I" : "Ctrl+Shift+I", keys: "info panel", run: () => setInfoOpen((v) => !v) }] : []),...(bot ? [{ label: `「${bot.name}」的设置`, keys: "bot settings", run: () => openBotSettings(bot.id) }] : []),{ label: "Modelflare 设置", keys: "modelflare key 密钥 模型", run: () => openSettings("modelflare") },@@ -260,7 +271,10 @@ function App() {// —— 渲染 ——if (!mf) {return html`<main class="onboard" data-screen=${mfErr ? "error" : "loading"}>- ${mfErr ? html`<div class="onboard-col"><div class="notice red"><span class="notice-text">无法连接本机服务:${mfErr}</span><button type="button" class="btn" onClick=${reloadMf}>重试</button></div></div>` : html`<span class="spinner" style="color:var(--muted)"></span>`}+ ${mfErr+ ? html`<div class="onboard-col"><div class="onboard-hero"><${BotAvatar} char=${MAIN_CHAR} size=${88} state="sleep" lively pokeable /></div>+ <div class="notice red"><span class="notice-text">无法连接本机服务:${mfErr}</span><button type="button" class="btn" onClick=${reloadMf}>重试</button></div></div>`+ : html`<${BotAvatar} char=${MAIN_CHAR} size=${72} state="thinking" lively />`}</main>`;}if (!connected) {@@ -272,20 +286,23 @@ function App() {const view = route.view;const panelBot = view === "chat" && infoOpen && bot;const routedBot = view === "bot-settings" && bots ? bots.find((b) => b.id === route.botId) : null;- return html`<div class=${`app${panelBot ? " with-panel" : ""}`}>- <${Sidebar} bots=${bots} botsError=${botsErr} reloadBots=${reloadBots} selectedId=${bot && bot.id} view=${view}- previews=${previews} pending=${pending} working=${working} username=${status && status.username}- creating=${creating} setCreating=${setCreating}- onSelect=${openChat} onCreated=${(b) => { reloadBots(); openChat(b.id); }} onDeleted=${onDeleted} onOpenSettings=${() => openSettings()} />+ // 环境光的色相跟着当前机器人角色的主色(设置页和新建页用缺省的冷色)+ const auraBot = view === "chat" ? bot : view === "bot-settings" ? routedBot : null;+ const auraHue = (auraBot && AURA_HUE[charOf(auraBot)]) || 250;+ return html`<div class=${`app${panelBot ? " with-panel" : ""}`} style=${{ "--aura-hue": String(auraHue) }}>+ ${view === "settings"+ ? html`<${SettingsSide} tab=${route.tab} query=${settingsQ} onQuery=${setSettingsQ} onTab=${(t) => openSettings(t)} onBack=${() => openChat()}+ username=${status && status.username} />`+ : html`<${Sidebar} bots=${bots} botsError=${botsErr} reloadBots=${reloadBots} selectedId=${bot && bot.id} view=${view === "chat" && bots && !bots.length ? "new" : view}+ previews=${previews} pending=${pending} working=${working} username=${status && status.username}+ onNew=${newBot} onSelect=${openChat} onDeleted=${onDeleted} onOpenSettings=${() => openSettings()} />`}<main class="main">${view === "chat" && bot && html`<${ChatScreen} key=${bot.id} bot=${bot} models=${models} modelsError=${modelsError} reloadModels=${reloadModels}defaultModel=${settings && settings.defaultModel} infoOpen=${infoOpen} onToggleInfo=${() => setInfoOpen((v) => !v)}- onWorking=${onWorking} onOpenSettings=${openSettings} onBotUpdated=${onBotUpdated} />`}- ${view === "chat" && bots && !bots.length && html`<section class="chat" data-screen="chat"><div class="chat-empty">- <h2>还没有机器人</h2><p>在左侧点 + 新建一个,然后直接对话。</p>- <button type="button" class="btn primary" onClick=${() => setCreating(true)}>新建机器人</button>- </div></section>`}- ${view === "settings" && html`<${SettingsScreen} tab=${route.tab} focusRow=${route.row} onTab=${(t) => openSettings(t)}+ onWorking=${onWorking} pending=${pending[bot.id] || 0} onOpenSettings=${openSettings} onOpenBotSettings=${openBotSettings} onBotUpdated=${onBotUpdated} />`}+ ${(view === "new" || (view === "chat" && bots && !bots.length)) && html`<${NewBotScreen} first=${!!bots && !bots.length}+ onCreated=${(b) => { reloadBots(); openChat(b.id); }} onCancel=${bots && bots.length ? () => openChat() : null} />`}+ ${view === "settings" && html`<${SettingsScreen} tab=${route.tab} query=${settingsQ} onQuery=${setSettingsQ} focusRow=${route.row}mf=${mf} onMfChanged=${reloadMf} onSettings=${setSettings} models=${models} modelsError=${modelsError} reloadModels=${reloadModels}status=${status} bots=${bots} onOpenBotSettings=${openBotSettings} />`}${view === "bot-settings" && routedBot && html`<${BotSettingsScreen} key=${routedBot.id} bot=${routedBot} section=${route.section}diff --git a/ui/screens/bot-settings.js b/ui/screens/bot-settings.jsindex 277274c..60f79b5 100644--- a/ui/screens/bot-settings.js+++ b/ui/screens/bot-settings.js@@ -1,16 +1,11 @@-// 机器人设置(信息面板的 ⚙):同样的白色圆角 list + 行,改动即保存。+// 机器人设置(信息面板的 ⚙,参考 Codex 的编辑页):返回 + 头像 + 大标题;身份是头像角色 + 带标签的输入框,其余是白色圆角 list + 行,改动即保存。import { useEffect, useRef, useState } from "preact/hooks";-import { html, Icon, Seg, MenuButton, autoGrow } from "../components/ui.js";-import { BotAvatar } from "../components/avatar.js";+import { html, Icon, Seg, Switch, MenuButton, Skeleton, autoGrow } from "../components/ui.js";+import { BotAvatar, AvatarPicker, charOf } from "../components/avatar.js";import { ModelPicker, shortModel } from "../components/model-picker.js";import { api } from "../lib/api.js";import { confirmSheet, failed, saved } from "../lib/store.js";-const ONOFF = [- [false, "关"],- [true, "开"],-];-function Row({ id, name, sub, title, children, off }) {return html`<div class=${`row${off ? " off" : ""}`} id=${`bot-${id}`} title=${title}><div class="who"><div class="name">${name}</div>${sub && html`<div class="sub">${sub}</div>`}</div>@@ -33,6 +28,7 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadModconst [name, setName] = useState(bot.name);const [prompt, setPrompt] = useState(bot.systemPrompt || "");const promptRef = useRef(null);+ const [hi, setHi] = useState(null);useEffect(() => {setName(bot.name);setPrompt(bot.systemPrompt || "");@@ -60,6 +56,11 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadModfailed(e);}};+ const pickAvatar = async (k) => {+ await put({ avatar: k });+ setHi({ kind: "hello", at: Date.now() });+ onBotUpdated();+ };const del = async () => {if (!(await confirmSheet({ title: `删除「${bot.name}」?`, body: "会永久删除这个机器人及其全部会话,无法恢复。", confirmLabel: "永久删除", danger: true }))) return;try {@@ -80,25 +81,26 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadModconst codex = cu && cu.backends && cu.backends.find((b) => b.id === "codex");return html`<section class="settings view" data-screen="bot-settings"><div class="set-head">- <div class="bot-head">- <button type="button" class="icon-btn" aria-label="返回对话" title="返回对话(Esc)" onClick=${onBack}><${Icon} name="chevLeft" /></button>- <${BotAvatar} name=${bot.name} id=${bot.id} size=${26} />- <span class="grow">${bot.name} · 设置</span>- </div>+ <button type="button" class="icon-btn set-back" aria-label="返回对话" title="返回对话(Esc)" onClick=${onBack}><${Icon} name="arrowLeft" size=${16} /></button>+ <${BotAvatar} bot=${bot} char=${s && s.avatar} size=${36} cue=${hi} pokeable />+ <div class="set-titles"><h1 class="set-title">${bot.name}</h1><div class="set-sub">机器人设置</div></div></div><div class="set-body"><div class="list-head">身份</div>- <div class="list">- <${Row} id="name" name="名称">- <input class="inline-input" value=${name} aria-label="名称" maxlength="60" onInput=${(e) => setName(e.target.value)} onBlur=${commitName}- onKeyDown=${(e) => { if (e.key === "Enter") e.target.blur(); if (e.key === "Escape") { e.stopPropagation(); setName(bot.name); requestAnimationFrame(() => e.target.blur()); } }} />- <//>- <${Row} id="prompt" name="人设 / 系统提示词" sub="离开输入框时保存" />- <div class="prompt-edit">- <textarea class="field" ref=${promptRef} aria-label="人设 / 系统提示词" placeholder="例如:你是一个乐于助人的中文助手,回答简洁准确。" value=${prompt}- onInput=${(e) => setPrompt(e.target.value)} onBlur=${() => prompt !== (bot.systemPrompt || "") && putBot({ systemPrompt: prompt })} />- </div>+ <div class="set-field" id="bot-avatar">+ <span class="k">头像<span class="hint">每个角色有自己的小动作</span></span>+ ${s ? html`<${AvatarPicker} value=${s.avatar} fallback=${charOf(bot)} onChange=${pickAvatar} />` : html`<${Skeleton} w="60%" />`}</div>+ <label class="set-field" id="bot-name">+ <span class="k">名称</span>+ <input class="field" value=${name} maxlength="60" onInput=${(e) => setName(e.target.value)} onBlur=${commitName}+ onKeyDown=${(e) => { if (e.key === "Enter") e.target.blur(); if (e.key === "Escape") { e.stopPropagation(); setName(bot.name); requestAnimationFrame(() => e.target.blur()); } }} />+ </label>+ <label class="set-field" id="bot-prompt">+ <span class="k">人设 / 系统提示词<span class="hint">离开输入框时保存</span></span>+ <textarea class="field" ref=${promptRef} placeholder="例如:你是一个乐于助人的中文助手,回答简洁准确。" value=${prompt}+ onInput=${(e) => setPrompt(e.target.value)} onBlur=${() => prompt !== (bot.systemPrompt || "") && putBot({ systemPrompt: prompt })} />+ </label><div class="list-head">模型</div><div class="list">@@ -111,7 +113,7 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadMod<//></div>- ${!s && html`<div class="list" style="margin-top:8px"><div class="row"><span class="skel" style="width:45%"></span></div><div class="row"><span class="skel" style="width:35%"></span></div></div>`}+ ${!s && html`<div class="list"><div class="row"><${Skeleton} w="45%" /></div><div class="row"><${Skeleton} w="35%" /></div></div>`}${s && html`<div class="list-head">权限</div><div class="list">@@ -124,20 +126,20 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadMod<div class="list-head">记忆</div><div class="list"><${Row} id="memory" name="长期记忆" sub="remember / forget / recall">- <${Seg} label="长期记忆" value=${s.memory.enabled} onChange=${(v) => put({ memory: { enabled: v } })} options=${ONOFF} />+ <${Switch} label="长期记忆" value=${s.memory.enabled} onChange=${(v) => put({ memory: { enabled: v } })} /><//><${Row} id="memory-review" name="回合结束后自动整理" off=${!s.memory.enabled}>- <${Seg} label="自动整理记忆" value=${s.memory.review} disabled=${!s.memory.enabled} onChange=${(v) => put({ memory: { review: v } })} options=${ONOFF} />+ <${Switch} label="自动整理记忆" value=${s.memory.review} disabled=${!s.memory.enabled} onChange=${(v) => put({ memory: { review: v } })} /><//><${Row} id="memory-team" name="允许写入团队记忆" sub="所有机器人共享" off=${!s.memory.enabled}>- <${Seg} label="团队记忆" value=${s.memory.teamWrite} disabled=${!s.memory.enabled} onChange=${(v) => put({ memory: { teamWrite: v } })} options=${ONOFF} />+ <${Switch} label="团队记忆" value=${s.memory.teamWrite} disabled=${!s.memory.enabled} onChange=${(v) => put({ memory: { teamWrite: v } })} /><//></div><div class="list-head">上下文</div><div class="list"><${Row} id="steward" name="自动压缩或开新段" sub="上下文变长时整理,并留下交接便条">- <${Seg} label="上下文管家" value=${s.steward.enabled} onChange=${(v) => put({ steward: { enabled: v } })} options=${ONOFF} />+ <${Switch} label="上下文管家" value=${s.steward.enabled} onChange=${(v) => put({ steward: { enabled: v } })} /><//></div>@@ -145,7 +147,7 @@ export function BotSettingsScreen({ bot, section, models, modelsError, reloadMod<div class="list"><${Row} id="computer" name="电脑操作" sub=${cu ? cu.reason : ""} title=${cu && cu.notice}><span class=${`dot ${cu && cu.available ? "ok" : "err"}`}></span>- <${Seg} label="电脑操作" value=${s.computerUse.enabled} onChange=${(v) => put({ computerUse: { enabled: v } })} options=${ONOFF} />+ <${Switch} label="电脑操作" value=${s.computerUse.enabled} onChange=${(v) => put({ computerUse: { enabled: v } })} /><//><${Row} id="computer-backend" name="后端" off=${!s.computerUse.enabled}><${MenuButton} label="电脑操作后端" value=${s.computerUse.backend} disabled=${!s.computerUse.enabled} onChange=${(v) => put({ computerUse: { backend: v } })}diff --git a/ui/screens/chat.js b/ui/screens/chat.jsindex afa735a..f8dcb2b 100644--- a/ui/screens/chat.js+++ b/ui/screens/chat.js@@ -1,12 +1,13 @@-// 对话页:无顶栏,顶部居中悬浮名称胶囊(点开信息面板),960 内容列,560 气泡,底部悬浮输入胶囊。+// 对话页(参考 Grok Bot 的顶栏、Codex 的对话与输入框):顶栏左侧头像 + 名称,右侧新对话 / 信息面板;+// 760 阅读列,用户消息是浅灰气泡,机器人回复是整列正文,上方一行"思考中 / 正在回复 / 用时";底部两行输入框。import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";-import { html, Icon, Menu, Popover, Badge, autoGrow } from "../components/ui.js";+import { html, Icon, IconButton, CopyButton, Menu, Popover, Badge, Skeleton, autoGrow } from "../components/ui.js";import { BotAvatar } from "../components/avatar.js";import { Markdown, Linkified } from "../components/markdown.js";import { ModelPicker, shortModel, sameModel } from "../components/model-picker.js";import { api, streamChat } from "../lib/api.js";import { confirmSheet, failed, saved } from "../lib/store.js";-import { fmtSep } from "../lib/format.js";+import { fmtSep, fmtClock, fmtDur } from "../lib/format.js";const COMMANDS = [["/model", "列出或切换模型"],@@ -15,6 +16,11 @@ const COMMANDS = [["/status", "查看当前模型与运行方式"],["/help", "显示全部命令"],];+// 文件权限(输入框左下角,参考 Codex 的权限胶囊):机器人设置里的同一项+const PERMS = {+ workspace: { label: "工作区可写", icon: "shield", note: "只能改这个机器人的工作区,越界操作先问你" },+ readonly: { label: "只读", icon: "lock", note: "不能改文件,命令在只读沙箱里运行" },+};const NEAR_BOTTOM = 80;const LINE_PX = 22;let seq = 0;@@ -50,8 +56,8 @@ export function PromptCard({ requestId, fallback }) {return () => clearInterval(t);}, [row && row.status]);- if (gone || (!row && !requestId)) return html`<div class="notice"><span class="notice-text" style="white-space:pre-wrap">${fallback}</span></div>`;- if (!row) return html`<div class="card"><span class="skel" style="width:60%"></span><span class="skel" style="width:40%"></span></div>`;+ if (gone || (!row && !requestId)) return html`<div class="notice"><span class="notice-text pre-wrap">${fallback}</span></div>`;+ if (!row) return html`<div class="card"><${Skeleton} w="60%" /><${Skeleton} w="40%" /></div>`;const pending = row.status === "pending";const decide = async (ok) => {setBusy(true);@@ -103,7 +109,7 @@ export function PromptCard({ requestId, fallback }) {const sendAll = () =>submit(qs.map((q, i) => ({ id: q.id, selected: picked[q.id] || [], ...(i === qs.length - 1 && custom.trim() ? { custom: custom.trim() } : {}) })));return html`<div class=${`card${pending ? "" : " done"}`}>- ${qs.map((q) => html`<div style="display:grid;gap:8px">+ ${qs.map((q) => html`<div class="q-block"><div class="q">${q.question}</div>${q.detail && html`<div class="q-detail">${q.detail}</div>`}${(q.options || []).length > 0 && html`<div class="opts" role=${q.multiSelect ? "group" : "radiogroup"}>@@ -130,13 +136,32 @@ export function PromptCard({ requestId, fallback }) {function FileCard({ name }) {return html`<div class="file-card"><${Icon} name="file" size=${32} stroke=${1.2} />- <div style="min-width:0">+ <div class="grow"><div class="fname">${name}</div><div class="fsub">已交付到机器人工作区 · 微信/飞书会直接发送</div></div></div>`;}+/** 回复上方的工作状态:没出字时"思考中",出字后"正在回复 N 秒",结束后"用时 N 秒"(短于 3 秒不显示) */+function WorkLine({ live, text, startedAt, workedMs }) {+ const [, tick] = useState(0);+ useEffect(() => {+ if (!live) return;+ const t = setInterval(() => tick((n) => n + 1), 1000);+ return () => clearInterval(t);+ }, [live]);+ const ms = live ? Date.now() - startedAt : workedMs;+ if (!live && !(ms >= 3000)) return null;+ const label = live ? (text ? `正在回复 ${fmtDur(ms)}` : ms >= 3000 ? `思考中 ${fmtDur(ms)}` : "思考中") : `用时 ${fmtDur(ms)}`;+ return html`<div class=${`work-line${live ? " live" : ""}`} aria-live="off"><span class=${live ? "shimmer" : ""}>${label}</span></div>`;+}++/** 消息下方的操作:复制 + 时刻(悬停时出现,最后一条回复常显) */+function MsgActions({ text, at }) {+ return html`<div class="msg-actions"><${CopyButton} text=${text} label="复制这条消息" />${at && html`<span class="when num">${fmtClock(at)}</span>`}</div>`;+}+function ErrorNotice({ text, onRetry, onFixKey }) {const auth = isAuthError(text);return html`<div class="notice red" role="alert">@@ -146,22 +171,26 @@ function ErrorNotice({ text, onRetry, onFixKey }) {</div>`;}-export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModel, infoOpen, onToggleInfo, onWorking, onOpenSettings, onBotUpdated }) {+export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModel, infoOpen, onToggleInfo, onWorking, onOpenSettings, onOpenBotSettings, onBotUpdated, pending = 0 }) {const [items, setItems] = useState(null);const [convModel, setConvModel] = useState("");const [text, setText] = useState("");const [generating, setGenerating] = useState(false);const [atBottom, setAtBottom] = useState(true);+ const [scrolled, setScrolled] = useState(false); // 内容滚到顶栏底下了:顶栏出现细线const [unseen, setUnseen] = useState(false);- const [menu, setMenu] = useState(null); // "plus" | "model" | null+ const [menu, setMenu] = useState(null); // "plus" | "perm" | "model" | null+ const [perm, setPerm] = useState("");const [slashSel, setSlashSel] = useState(0);const [slashOff, setSlashOff] = useState(false);const [loadErr, setLoadErr] = useState("");+ const [cue, setCue] = useState(null); // 头像的一次性反应(出错);完成时头像自己会播const scroller = useRef(null);const stick = useRef(true);const ta = useRef(null);const plusRef = useRef(null);const modelRef = useRef(null);+ const permRef = useRef(null);const ctrl = useRef(null);const mounted = useRef(true);const lastUser = useRef("");@@ -191,6 +220,9 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModemounted.current = false;};}, [load]);+ useEffect(() => {+ api(`/bots/${encodeURIComponent(bot.id)}/settings`).then((d) => mounted.current && setPerm(d.settings.permission)).catch(() => {});+ }, [bot.id]);useEffect(() => onWorking(bot.id, generating), [generating]);useEffect(() => () => onWorking(bot.id, false), []);@@ -206,6 +238,7 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModeconst near = el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM;stick.current = near;setAtBottom(near);+ setScrolled(el.scrollTop > 2);if (near) setUnseen(false);};const toBottom = () => {@@ -227,7 +260,7 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModestick.current = true;const liveId = uid();const isReset = /^\/reset\b/i.test(t);- setItems((l) => [...(l || []), { kind: "msg", id: uid(), role: "user", text: t, at: Date.now(), enter: true }, { kind: "msg", id: liveId, role: "assistant", text: "", at: Date.now(), live: true }]);+ setItems((l) => [...(l || []), { kind: "msg", id: uid(), role: "user", text: t, at: Date.now(), enter: true }, { kind: "msg", id: liveId, role: "assistant", text: "", at: Date.now(), live: true, startedAt: Date.now() }]);const ac = new AbortController();ctrl.current = ac;setGenerating(true);@@ -260,12 +293,13 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModeif (!mounted.current) return;ctrl.current = null;setGenerating(false);+ if (isError(finalText)) setCue({ kind: "error", at: Date.now() });setItems((l) => {const out = [];for (const it of l || []) {if (it.id !== liveId) out.push(it);else if (isError(finalText)) out.push({ kind: "error", id: liveId, text: errText(finalText), retry: t.startsWith("/") ? undefined : t, at: it.at });- else if (finalText) out.push({ ...it, text: finalText, live: false });+ else if (finalText) out.push({ ...it, text: finalText, live: false, workedMs: Date.now() - it.startedAt });}return isReset && !isError(finalText) ? out.filter((x) => x.id === liveId) : out;});@@ -315,6 +349,20 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultMode}};+ // —— 文件权限 ——+ const pickPerm = async (p) => {+ const prev = perm;+ setPerm(p);+ try {+ const d = await api(`/bots/${encodeURIComponent(bot.id)}/settings`, { method: "PUT", body: { permission: p } });+ setPerm(d.settings.permission);+ saved();+ } catch (e) {+ setPerm(prev);+ failed(e);+ }+ };+// —— 模型 ——const effective = convModel || bot.defaultModel || defaultModel || (models && models[0]) || "";const pickModel = async (m) => {@@ -356,6 +404,7 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModeconst rows = useMemo(() => {const out = [];let prev = null;+ const lastAi = (items || []).findLast((x) => x.kind === "msg" && x.role === "assistant" && !x.live)?.id;for (const it of items || []) {if (it.at && (!prev?.at || new Date(it.at).toDateString() !== new Date(prev.at).toDateString() || it.at - prev.at > 15 * 60_000)) {out.push(html`<div class="time-sep" key=${"t" + it.id}>${fmtSep(it.at)}</div>`);@@ -365,12 +414,12 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultModeconst cont = prev && (prev.kind === "msg" ? prev.role : "assistant") === role;const cls = `msg-row ${role}${cont ? " cont" : ""}${it.enter ? " enter" : ""}`;if (it.kind === "msg") {- out.push(html`<div class=${cls} key=${it.id}>+ out.push(html`<div class=${`${cls}${it.id === lastAi ? " last" : ""}`} key=${it.id}>${it.role === "user"- ? html`<div class="msg"><${Linkified} text=${it.text} /></div>`- : it.live && !it.text- ? html`<div class="msg" aria-label="正在回复"><span class="typing"><i></i><i></i><i></i></span></div>`- : html`<div class="msg"><${Markdown} text=${it.text} />${it.live && html`<span class="caret" aria-hidden="true"></span>`}</div>`}+ ? html`<div class="msg"><${Linkified} text=${it.text} /></div><${MsgActions} text=${it.text} at=${it.at} />`+ : html`${(it.live || it.workedMs) && html`<${WorkLine} live=${it.live} text=${it.text} startedAt=${it.startedAt} workedMs=${it.workedMs} />`}+ ${it.text && html`<div class="msg"><${Markdown} text=${it.text} /></div>`}+ ${!it.live && html`<${MsgActions} text=${it.text} at=${it.at} />`}`}</div>`);} else if (it.kind === "prompt") {out.push(html`<div class=${cls} key=${it.id}><${PromptCard} requestId=${it.requestId} fallback=${it.prompt} /></div>`);@@ -385,18 +434,25 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultMode}, [items, generating]);const empty = items && items.length === 0;- return html`<section class="chat" data-screen="chat" aria-label=${`和 ${bot.name} 的对话`}>- <div class="drag-strip"></div>- <button type="button" class="float-pill" aria-pressed=${infoOpen} title="信息面板(⌘⇧I)" onClick=${onToggleInfo}>- <${BotAvatar} name=${bot.name} id=${bot.id} size=${21} working=${generating} />- <span class="name">${bot.name}</span>- </button>+ // 头像跟着对话走:等你批准 > 还没出字(思考)/ 出字了(回复)> 你在输入(在听)+ const replying = generating && (items || []).some((x) => x.live && x.text);+ const face = pending > 0 ? "waiting" : generating ? (replying ? "replying" : "thinking") : text.trim() ? "listening" : "idle";+ return html`<section class=${`chat${scrolled ? " scrolled" : ""}`} data-screen="chat" aria-label=${`和 ${bot.name} 的对话`}>+ <header class="chat-head">+ <button type="button" class="head-bot bot-hover" aria-pressed=${infoOpen} title="信息面板(⌘⇧I)" onClick=${onToggleInfo}>+ <${BotAvatar} bot=${bot} size=${22} state=${face} cue=${cue} />+ <span class="name">${bot.name}</span>+ </button>+ <span class="grow"></span>+ <${IconButton} icon="compose" iconSize=${16} label="开始新的一段对话(/new)" disabled=${generating} onClick=${() => send("/new")} />+ <${IconButton} icon="panel" iconSize=${16} label="信息面板(⌘⇧I)" on=${infoOpen} aria-pressed=${infoOpen} onClick=${onToggleInfo} />+ </header><div class="chat-scroll" ref=${scroller} onScroll=${onScroll}><div class="chat-col" role="log" aria-live="polite" aria-busy=${generating}>- ${loadErr && html`<div class="notice red" style="margin-top:8px"><span class="notice-text">读取历史消息失败:${loadErr}</span><button type="button" class="btn" onClick=${load}>重试</button></div>`}- ${items === null && html`<div style="display:grid;gap:14px;margin-top:24px"><span class="skel" style="width:40%;height:34px;border-radius:17px"></span><span class="skel" style="width:28%;height:34px;border-radius:17px;justify-self:end"></span></div>`}+ ${loadErr && html`<div class="notice red"><span class="notice-text">读取历史消息失败:${loadErr}</span><button type="button" class="btn" onClick=${load}>重试</button></div>`}+ ${items === null && html`<div class="chat-skel"><${Skeleton} w="40%" /><${Skeleton} w="28%" /></div>`}${empty && html`<div class="chat-empty">- <${BotAvatar} name=${bot.name} id=${bot.id} size=${56} />+ <${BotAvatar} bot=${bot} size=${88} state=${face} cue=${cue} lively pokeable greet /><h2>和 ${bot.name} 开始对话</h2><p>在这里直接测试机器人;飞书和微信渠道在信息面板里配置。</p><div class="chips">@@ -410,10 +466,16 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultMode${!atBottom && html`<button type="button" class="to-bottom" aria-label="回到底部" onClick=${toBottom}><${Icon} name="down" />${unseen && html`<span class="new"></span>`}</button>`}<div class="composer-dock"><div class="composer">- <button type="button" class="plus" ref=${plusRef} aria-label="更多操作" aria-haspopup="menu" aria-expanded=${menu === "plus"} onClick=${() => setMenu(menu === "plus" ? null : "plus")}><${Icon} name="plus" size=${14} stroke=${1.8} /></button>- <textarea ref=${ta} rows="1" placeholder=${`给「${bot.name}」发消息`} aria-label="消息" value=${text}+ <textarea ref=${ta} rows="1" placeholder=${`给「${bot.name}」发消息,/ 查看命令`} aria-label="消息" value=${text}onInput=${(e) => { setText(e.target.value); setSlashOff(false); setSlashSel(0); autoGrow(e.target, LINE_PX * 8 + 8); }}onKeyDown=${onKey} />+ <div class="composer-bar">+ <button type="button" class="plus" ref=${plusRef} aria-label="更多操作" aria-haspopup="menu" aria-expanded=${menu === "plus"} onClick=${() => setMenu(menu === "plus" ? null : "plus")}><${Icon} name="plus" size=${15} stroke=${1.7} /></button>+ ${PERMS[perm] && html`<button type="button" class=${`model-chip perm ${perm}`} ref=${permRef} title=${`文件权限:${PERMS[perm].note}`} aria-haspopup="menu" aria-expanded=${menu === "perm"}+ onClick=${() => setMenu(menu === "perm" ? null : "perm")}>+ <${Icon} name=${PERMS[perm].icon} size=${14} class="lead" /><span class="v">${PERMS[perm].label}</span><${Icon} name="chevDown" />+ </button>`}+ <span class="grow"></span><button type="button" class="model-chip" ref=${modelRef} title=${effective ? `当前模型:${effective}` : "选择模型"} aria-haspopup="listbox" aria-expanded=${menu === "model"}onClick=${() => setMenu(menu === "model" ? null : "model")}><span class="v">${effective ? shortModel(effective) : "选择模型"}</span><${Icon} name="chevDown" />@@ -421,6 +483,7 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultMode${generating? html`<button type="button" class="send stop" aria-label="停止生成(Esc)" title="停止(Esc)" onClick=${stop}><${Icon} name="stop" size=${12} /></button>`: html`<button type="button" class="send" aria-label="发送" title="发送(Enter)" disabled=${!text.trim()} onClick=${() => send()}><${Icon} name="up" size=${15} stroke=${2} /></button>`}+ </div></div></div>${slashOpen && ta.current && html`<${Popover} anchor=${ta.current} prefer="up" width=${320} keepFocus label="命令" onClose=${() => setSlashOff(true)}>@@ -432,6 +495,13 @@ export function ChatScreen({ bot, models, modelsError, reloadModels, defaultMode</ul><//>`}${menu === "plus" && html`<${Menu} anchor=${plusRef.current} prefer="up" width=${240} label="更多操作" onClose=${() => setMenu(null)} items=${plusItems} />`}+ ${menu === "perm" && html`<${Menu} anchor=${permRef.current} prefer="up" width=${280} label="文件权限" onClose=${() => setMenu(null)}+ items=${[+ { group: "文件权限" },+ ...Object.entries(PERMS).map(([k, p]) => ({ label: p.label, note: p.note, icon: p.icon, cur: k === perm, onSelect: () => k !== perm && pickPerm(k) })),+ { sep: true },+ { label: "更多权限设置…", onSelect: () => onOpenBotSettings?.(bot.id, "permission") },+ ]} />`}${menu === "model" && html`<${ModelPicker} anchor=${modelRef.current} prefer="up" align="right" models=${models} error=${modelsError} onRetry=${reloadModels}current=${convModel || bot.defaultModel || defaultModel} onPick=${pickModel} onClose=${() => setMenu(null)}reset=${{ label: "跟随机器人默认", note: shortModel(bot.defaultModel || defaultModel) || "自动", onSelect: () => pickModel("") }}diff --git a/ui/screens/info-panel.js b/ui/screens/info-panel.jsindex 8b0c93e..8e836d5 100644--- a/ui/screens/info-panel.js+++ b/ui/screens/info-panel.js@@ -1,6 +1,6 @@// 信息面板:点悬浮胶囊或 ⌘⇧I 打开,面板自己的 ✕ 关闭,⚙ 进机器人设置。import { useCallback, useEffect, useState } from "preact/hooks";-import { html, Icon, Badge, Sheet, Spinner } from "../components/ui.js";+import { html, Icon, Badge, Sheet, Spinner, Skeleton } from "../components/ui.js";import { PromptCard } from "./chat.js";import { api } from "../lib/api.js";import { confirmSheet, failed, saved, toast } from "../lib/store.js";@@ -88,7 +88,7 @@ function WeixinRow({ bot, st, reload }) {</div>${open && html`<div class="row-edit">${login && login.state !== "idle" && html`<div class="actions"><${Badge} s=${login.state} /><span class="hint">${login.message}</span></div>`}- ${active && login.qrDataUrl && html`<img src=${login.qrDataUrl} alt="微信登录二维码" style="width:180px;height:180px;image-rendering:pixelated;background:#fff;padding:8px;border-radius:10px;border:1px solid var(--line)" />+ ${active && login.qrDataUrl && html`<img class="panel-qr" src=${login.qrDataUrl} alt="微信登录二维码" /><p class="hint">用微信扫一扫,然后在手机上确认。</p>`}${login && login.state === "need_verifycode" && html`<div class="actions"><input class="field" style="width:140px" placeholder="验证码" value=${code} onInput=${(e) => setCode(e.target.value)} /><button type="button" class="btn" onClick=${() => call("/verify", { code }).then(() => setCode(""))}>提交</button></div>`}@@ -120,7 +120,7 @@ function MemorySection({ botId }) {${!d && html`<div class="row"><span class="hint">${err || "加载中…"}</span></div>`}${d && !all.length && html`<div class="row"><span class="hint">还没有长期记忆</span></div>`}${all.slice(0, 30).map(({ sc, e, topic }) => html`<div class="row compact">- <div class="who"><div class="sub wrap selectable" style="color:var(--fg);font-size:12.5px">${e.text}</div><div class="sub">${sc.label}${topic ? " · " + topic : ""}</div></div>+ <div class="who"><div class="sub wrap selectable tone-fg t-control">${e.text}</div><div class="sub">${sc.label}${topic ? " · " + topic : ""}</div></div><button type="button" class="icon-btn" title="删除" aria-label="删除这条记忆" onClick=${() => forget(sc, e.text, topic)}><${Icon} name="trash" size=${13} /></button></div>`)}</div>`;@@ -129,12 +129,12 @@ function MemorySection({ botId }) {function ConversationSheet({ conv, onClose }) {const [d] = usePoll(() => api(`/conversations/${encodeURIComponent(conv.id)}/messages`), 0, [conv.id]);return html`<${Sheet} title=${`${CHANNEL_NAME[conv.channel] || conv.channel} · ${conv.title || conv.peerId}`} wide onClose=${onClose}>- <div style="display:grid;gap:8px;max-height:60vh;overflow:auto">+ <div class="transcript">${!d && html`<span class="hint">加载中…</span>`}${d && !d.messages.length && html`<span class="hint">没有消息</span>`}- ${d && d.messages.map((m) => html`<div style=${`justify-self:${m.role === "user" ? "end" : "start"};max-width:85%`}>- <div class="selectable" style=${`white-space:pre-wrap;padding:7px 11px;border-radius:14px;font-size:13px;line-height:1.5;${m.role === "user" ? "background:var(--accent-solid);color:var(--on-accent)" : "background:var(--bubble-ai)"}`}>${m.content}</div>- <div class="hint" style=${`text-align:${m.role === "user" ? "right" : "left"};margin-top:2px`}>${fmtTime(m.createdAt)}</div>+ ${d && d.messages.map((m) => html`<div class=${`transcript-msg${m.role === "user" ? " user" : ""}`}>+ <div class="bubble selectable">${m.content}</div>+ <div class="hint">${fmtTime(m.createdAt)}</div></div>`)}</div><div class="actions"><button type="button" class="btn" data-autofocus onClick=${onClose}>关闭</button></div>@@ -158,12 +158,12 @@ export function InfoPanel({ bot, onClose, onOpenBotSettings, onOpenChat }) {<div class="list">${detail && detail.bot? html`<${FeishuRow} bot=${detail.bot} st=${detail.channels.feishu} reload=${reloadDetail} /><${WeixinRow} bot=${detail.bot} st=${detail.channels.weixin} reload=${reloadDetail} />`- : html`<div class="row"><span class="skel" style="width:50%"></span></div><div class="row"><span class="skel" style="width:40%"></span></div>`}+ : html`<div class="row"><${Skeleton} w="50%" /></div><div class="row"><${Skeleton} w="40%" /></div>`}</div><div class="list-head">待审批${pending.length > 0 && html`<span class="badge count warn">${pending.length}</span>`}</div>${pending.length- ? html`<div style="display:grid;gap:8px">${pending.map((a) => html`<div key=${a.id} style="display:grid;gap:4px">+ ? html`<div class="stack">${pending.map((a) => html`<div key=${a.id} class="stack" style="--gap: var(--space-1)"><span class="hint">${CHANNEL_NAME[a.conversationId.split(":")[1]] || ""} · ${fmtAgo(a.createdAt)} · 截止 ${fmtTime(a.expiresAt).slice(-8, -3)}</span><${PromptCard} requestId=${a.id} fallback="" /></div>`)}@@ -174,7 +174,7 @@ export function InfoPanel({ bot, onClose, onOpenBotSettings, onOpenChat }) {<div class="list-head">最近会话</div><div class="list">- ${!convs && html`<div class="row"><span class="skel" style="width:60%"></span></div>`}+ ${!convs && html`<div class="row"><${Skeleton} w="60%" /></div>`}${convs && !convs.conversations.length && html`<div class="row"><span class="hint">还没有会话</span></div>`}${convs && convs.conversations.slice(0, 12).map((c) => html`<div class="row compact clickable" role="button" tabindex="0"onClick=${() => (c.channel === "web" ? onOpenChat() : setViewing(c))} onKeyDown=${(e) => e.key === "Enter" && (c.channel === "web" ? onOpenChat() : setViewing(c))}>diff --git a/ui/screens/new-bot.js b/ui/screens/new-bot.jsnew file mode 100644index 0000000..204de3c--- /dev/null+++ b/ui/screens/new-bot.js@@ -0,0 +1,99 @@+// 新建机器人(参考 Grok Bot 的创建页):头像角色 + 名称 + 人设,下面是从模板开始。+// 默认是主角小蓝;每个模板配了一个合适的角色(avatar),选模板时一起换,也可以自己挑。+import { useEffect, useRef, useState } from "preact/hooks";+import { html, Icon, IconButton, Button, autoGrow } from "../components/ui.js";+import { BotAvatar, AvatarPicker, MAIN_CHAR } from "../components/avatar.js";+import { api } from "../lib/api.js";+import { failed } from "../lib/store.js";++export const TEMPLATES = [+ { key: "digest", icon: "file", avatar: "green", name: "群聊日报", desc: "把群里的讨论整理成日报:结论、待办和负责人",+ prompt: "你是群聊日报助手。被要求总结时,把群里的讨论整理成日报:先写三条以内的结论,再列待办(事项、负责人、时间),最后列还没解决的问题。只写群里确实说过的内容,不要编造。" },+ { key: "support", icon: "chat", avatar: "yellow", name: "客服助手", desc: "按已知资料回答客户问题,拿不准就转人工",+ prompt: "你是客服助手。用简洁、礼貌的中文回答客户问题,只依据已知的资料作答;资料里没有或拿不准时,直接说明会转给人工处理,不要猜测。" },+ { key: "translate", icon: "globe", avatar: "orange", name: "翻译官", desc: "中英互译,保留语气、术语和格式",+ prompt: "你是翻译官。收到中文就译成英文,收到其他语言就译成中文。保留原文的语气、术语和格式(列表、代码、链接),只输出译文。" },+ { key: "minutes", icon: "clock", avatar: "blue", name: "会议纪要", desc: "把会议记录整理成结论、待办和待定问题",+ prompt: "你是会议纪要助手。把会议记录或转写整理成:会议主题、结论、待办(事项、负责人、截止时间)、待定问题。语言精炼,不添加记录里没有的信息。" },+ { key: "writer", icon: "compose", avatar: "purple", name: "写作助手", desc: "起草公告、邮件和周报,按你的语气润色",+ prompt: "你是写作助手。帮我起草和润色公告、邮件、周报等文字。先弄清用途和读者,再给出成稿;语气自然、结构清楚,不写空话。" },+ { key: "coder", icon: "code", avatar: "red", name: "代码助手", desc: "读代码、写脚本,在自己的工作区里改文件",+ prompt: "你是代码助手。阅读和修改工作区里的代码,编写脚本解决问题。动手前先说明计划,改完说明改了什么、怎么验证。" },+];++export function NewBotScreen({ first, onCreated, onCancel }) {+ const [name, setName] = useState("");+ const [prompt, setPrompt] = useState("");+ const [tpl, setTpl] = useState("");+ const [avatar, setAvatar] = useState(MAIN_CHAR);+ const [hi, setHi] = useState(null);+ const [busy, setBusy] = useState(false);+ const nameRef = useRef(null);+ const promptRef = useRef(null);+ useEffect(() => {+ requestAnimationFrame(() => nameRef.current?.focus());+ }, []);+ useEffect(() => autoGrow(promptRef.current, 240), [prompt]);++ const pick = (t) => {+ setTpl(t.key);+ if (t.avatar !== avatar) choose(t.avatar);+ setName(t.name);+ setPrompt(t.prompt);+ requestAnimationFrame(() => (nameRef.current?.focus(), nameRef.current?.select()));+ };+ const choose = (k) => {+ setAvatar(k);+ setHi({ kind: "hello", at: Date.now() });+ };+ const create = async (e) => {+ e.preventDefault();+ const n = name.trim();+ if (!n || busy) return;+ setBusy(true);+ try {+ const r = await api("/bots", { method: "POST", body: { name: n, systemPrompt: prompt.trim(), avatar } });+ onCreated(r.bot);+ } catch (err) {+ failed(err);+ setBusy(false);+ }+ };++ return html`<section class="new-bot view" data-screen="new-bot">+ <header class="chat-head">+ <span class="head-bot static"><${BotAvatar} char=${avatar} size=${22} /><span class="name">新机器人</span></span>+ <span class="grow"></span>+ ${onCancel && html`<${IconButton} icon="close" iconSize=${15} label="取消(Esc)" onClick=${onCancel} />`}+ </header>+ <div class="new-body">+ <form class="new-form" onSubmit=${create}>+ <${BotAvatar} char=${avatar} size=${96} lively pokeable greet cue=${hi} state=${busy ? "thinking" : name.trim() ? "listening" : "idle"} />+ <h1 class="new-title">${first ? "创建你的第一个机器人" : "新建机器人"}</h1>+ <p class="new-lead">挑一个伙伴,起个名字、写几句人设,或者从下面的模板开始。</p>+ <${AvatarPicker} value=${avatar} onChange=${choose} size=${40} />+ <label class="set-field">+ <span class="k">名称</span>+ <input class="field" ref=${nameRef} maxlength="60" placeholder="例如:群聊日报" value=${name} onInput=${(e) => setName(e.target.value)}+ onKeyDown=${(e) => e.key === "Escape" && name && (e.stopPropagation(), setName(""))} />+ </label>+ <label class="set-field">+ <span class="k">人设<span class="hint">可选,之后在机器人设置里也能改</span></span>+ <textarea class="field" ref=${promptRef} rows="3" placeholder="例如:你是一个乐于助人的中文助手,回答简洁准确。" value=${prompt}+ onInput=${(e) => { setPrompt(e.target.value); setTpl(""); }} />+ </label>+ <${Button} type="submit" variant="primary" size="lg" loading=${busy} disabled=${!name.trim()}>创建<//>+ </form>+ <div class="new-sugg">+ <div class="list-head">从模板开始</div>+ <div class="tpl-grid">+ ${TEMPLATES.map((t) => html`<button type="button" key=${t.key} class=${`tpl${tpl === t.key ? " on" : ""}`} aria-pressed=${tpl === t.key} onClick=${() => pick(t)}>+ <span class="tpl-ic"><${Icon} name=${t.icon} size=${17} /></span>+ <span class="tpl-name">${t.name}</span>+ <span class="tpl-desc">${t.desc}</span>+ </button>`)}+ </div>+ </div>+ </div>+ </section>`;+}diff --git a/ui/screens/onboarding.js b/ui/screens/onboarding.jsindex 7e0577a..7d6800b 100644--- a/ui/screens/onboarding.js+++ b/ui/screens/onboarding.js@@ -1,7 +1,7 @@// 首次启动 / 断开后:只有一个动作——粘贴 Modelflare API Key。不是向导路由,而是"未连接"时的整页空态。import { useEffect, useMemo, useRef, useState } from "preact/hooks";import { html, Icon, Seg, Spinner } from "../components/ui.js";-import { AppMark } from "../components/avatar.js";+import { BotAvatar, MAIN_CHAR } from "../components/avatar.js";import { groupModels } from "../components/model-picker.js";import { api } from "../lib/api.js";@@ -15,7 +15,8 @@ export const LINE_OPTIONS = [];/** 粘贴 Key → 校验(GET /v1/models)→ 写入。onConnected(result) 收到 { models, keyTail, … } */-export function KeyForm({ line: initialLine = "auto", onConnected, showLine = true, submitLabel = "连接 Modelflare" }) {+/** onFace(state):给旁边的头像用——"listening"(在输入)/ "thinking"(正在校验)/ "idle" / "error"(一次性) */+export function KeyForm({ line: initialLine = "auto", onConnected, onFace, showLine = true, submitLabel = "连接 Modelflare" }) {const [key, setKey] = useState("");const [show, setShow] = useState(false);const [line, setLine] = useState(initialLine);@@ -25,6 +26,7 @@ export function KeyForm({ line: initialLine = "auto", onConnected, showLine = trconst input = useRef(null);const btn = useRef(null);useEffect(() => input.current?.focus(), []);+ useEffect(() => onFace?.(busy ? "thinking" : key.trim() ? "listening" : "idle"), [busy, !!key.trim()]);const submit = async (lineOverride) => {const k = key.trim();@@ -41,6 +43,7 @@ export function KeyForm({ line: initialLine = "auto", onConnected, showLine = tronConnected(r);} catch (e) {setErr({ message: e.message, code: e.data?.code, suggestLine: e.data?.suggestLine });+ onFace?.("error");} finally {clearTimeout(t);setBusy(false);@@ -125,7 +128,7 @@ function ModelStep({ models, initial, onDone }) {${ms.map(([m, label]) => html`<button type="button" role="option" aria-selected=${m === cur} class=${m === cur ? "cur" : ""} onClick=${() => setCur(m)} onDblClick=${start}><span class="v">${label}</span>${m === cur && html`<span class="check"><${Icon} name="check" size=${14} /></span>`}</button>`)}`)}- ${!groups.length && html`<p class="hint" style="padding:8px">没有匹配的模型</p>`}+ ${!groups.length && html`<p class="hint">没有匹配的模型</p>`}</div>`: html`<div class="notice amber"><span class="notice-text">这个 Key 所在的分组暂无可用模型。可以在控制台给分组开放模型后再回来刷新。</span><a class="btn" href=${MF_CONSOLE} target="_blank" rel="noopener noreferrer">去控制台 ↗</a></div>`}@@ -136,16 +139,19 @@ function ModelStep({ models, initial, onDone }) {export function Onboarding({ status, gateway, defaultModel, onDone }) {const [models, setModels] = useState(null);+ const [face, setFace] = useState("idle");+ const [cue, setCue] = useState(null);+ const onFace = (f) => (f === "error" ? setCue({ kind: "error", at: Date.now() }) : setFace(f));return html`<main class="onboard" data-screen="onboarding"><div class="onboard-col"><div class="onboard-hero">- <${AppMark} size=${44} />+ <${BotAvatar} char=${MAIN_CHAR} size=${88} state=${face} cue=${cue} lively pokeable greet /><h1>用 Modelflare 开始</h1><p>粘贴 API Key,GPT、Claude、Grok、Gemini 等模型会自动列出。</p></div>${gateway && gateway.mode === "managed" && gateway.state === "failed" && html`<div class="notice red"><span class="notice-text">内置模型网关没有启动:${gateway.lastError || "未知原因"}。修复后重启应用再连接。</span></div>`}${models === null- ? html`<${KeyForm} line=${status.line} onConnected=${(r) => setModels(r.models || [])} />+ ? html`<${KeyForm} line=${status.line} onFace=${onFace} onConnected=${(r) => (setFace("idle"), setModels(r.models || []))} /><div class="links"><a href=${MF_CONSOLE} target="_blank" rel="noopener noreferrer">还没有 Key?去 Modelflare 控制台创建 ↗</a></div>`diff --git a/ui/screens/settings.js b/ui/screens/settings.jsindex 0fbccb7..1ed4197 100644--- a/ui/screens/settings.js+++ b/ui/screens/settings.js@@ -1,7 +1,8 @@-// 设置页(magpie 风格):页签 + 查找设置;白色圆角 list,一行一项;改动即保存,左下角"已保存"。-// 入口只有左下角账户按钮、⌘/Ctrl+, 和命令面板,不放齿轮。+// 设置页(参考 Codex):侧栏换成设置导航(返回应用 + 查找 + 分页),主区是大标题 + 白色圆角 list,一行一项;改动即保存。+// 入口只有左下角账户按钮、⌘/Ctrl+, 和命令面板。import { useEffect, useMemo, useRef, useState } from "preact/hooks";-import { html, Icon, Seg, Sheet, CopyButton } from "../components/ui.js";+import { html, Icon, Seg, Switch, Sheet, CopyButton, Skeleton } from "../components/ui.js";+import { AccountButton } from "./sidebar.js";import { ModelPicker, shortModel } from "../components/model-picker.js";import { KeyForm, LINE_OPTIONS, MF_CONSOLE, MF_DOCS } from "./onboarding.js";import { api } from "../lib/api.js";@@ -9,13 +10,13 @@ import { useStore, confirmSheet, failed, saved } from "../lib/store.js";import { themeMode, setThemeMode } from "../lib/theme.js";export const TABS = [- ["general", "常规"],- ["modelflare", "Modelflare"],- ["computer", "电脑操作"],- ["privacy", "隐私与安全"],- ["network", "网络与访问"],- ["data", "数据"],- ["about", "关于"],+ ["general", "常规", "sliders"],+ ["modelflare", "Modelflare", "spark"],+ ["computer", "电脑操作", "monitor"],+ ["privacy", "隐私与安全", "lock"],+ ["network", "网络与访问", "globe"],+ ["data", "数据", "database"],+ ["about", "关于", "info"],];const ZOOMS = [[1, "100%"],@@ -53,17 +54,36 @@ function NoticesSheet({ onClose }) {<//>`;}-export function SettingsScreen({ tab, focusRow, onTab, mf, onMfChanged, onSettings, models, modelsError, reloadModels, status, bots, onOpenBotSettings }) {+/** 设置时的侧栏:返回应用 | 查找设置 | 分页 | 账户 */+export function SettingsSide({ tab, query, onQuery, onTab, onBack, username }) {+ const searching = !!query.trim();+ return html`<aside class="side" aria-label="设置">+ <div class="side-top start">+ <button type="button" class="side-back" title="返回应用(Esc)" onClick=${onBack}><${Icon} name="arrowLeft" size=${15} />返回应用</button>+ </div>+ <label class="side-search">+ <${Icon} name="search" size=${14} />+ <input type="search" placeholder="查找设置" aria-label="查找设置" value=${query} onInput=${(e) => onQuery(e.target.value)}+ onKeyDown=${(e) => e.key === "Escape" && query && (e.stopPropagation(), onQuery(""))} />+ </label>+ <nav class="side-list side-nav" aria-label="设置分页">+ ${TABS.map(([t, label, icon]) => {+ const on = !searching && t === tab;+ return html`<button type="button" key=${t} class=${`nav-item${on ? " sel" : ""}`} aria-current=${on ? "page" : undefined}+ onClick=${() => { onQuery(""); onTab(t); }}><${Icon} name=${icon} size=${16} /><span>${label}</span></button>`;+ })}+ </nav>+ <div class="side-foot"><${AccountButton} username=${username} on onClick=${() => onTab("general")} /></div>+ </aside>`;+}++export function SettingsScreen({ tab, query: q, onQuery: setQ, focusRow, mf, onMfChanged, onSettings, models, modelsError, reloadModels, status, bots, onOpenBotSettings }) {const [s, setS] = useState(null);- const [q, setQ] = useState("");const [rekey, setRekey] = useState(false);const [notices, setNotices] = useState(false);const [cu, setCu] = useState(null);const [flash, setFlash] = useState("");- const [stuck, setStuck] = useState(false);const mode = useStore(themeMode);- const body = useRef(null);- const find = useRef(null);useEffect(() => {api("/settings").then(setS).catch(failed);@@ -126,7 +146,7 @@ export function SettingsScreen({ tab, focusRow, onTab, mf, onMfChanged, onSettindesktop && { tab: "general", id: "close", name: "关闭窗口时", sub: "隐藏到托盘时机器人继续在后台收发消息", keys: "托盘 退出 tray",ctl: html`<${Seg} label="关闭窗口时" value=${s.closeToTray} onChange=${(v) => put({ closeToTray: v }, { closeToTray: v })} options=${[[true, "隐藏到托盘"], [false, "退出"]]} />` },desktop && s.autostart.supported && { tab: "general", id: "autostart", name: "开机自启", sub: "登录系统后在后台启动", keys: "启动 login",- ctl: html`<${Seg} label="开机自启" value=${s.autostart.on} onChange=${(v) => put({ autostart: v }, { autostart: { ...s.autostart, on: v } })} options=${[[false, "关"], [true, "开"]]} />` },+ ctl: html`<${Switch} label="开机自启" value=${s.autostart.on} onChange=${(v) => put({ autostart: v }, { autostart: { ...s.autostart, on: v } })} />` },desktop && { tab: "general", id: "browser", name: "在浏览器中打开", sub: "用系统浏览器打开同一个本机界面", keys: "browser",ctl: html`<button type="button" class="text" onClick=${() => api("/desktop/open-in-browser", { method: "POST", body: {} }).catch(failed)}>打开</button>` },@@ -180,18 +200,11 @@ export function SettingsScreen({ tab, focusRow, onTab, mf, onMfChanged, onSettinconst shown = needle ? rows.filter((r) => `${r.name} ${r.sub || ""} ${r.keys || ""}`.toLowerCase().includes(needle)) : rows.filter((r) => r.tab === tab);const parts = needle ? TABS.map(([t, label]) => [label, shown.filter((r) => r.tab === t)]).filter(([, l]) => l.length) : [["", shown]];- return html`<section class="settings view" data-screen="settings" ref=${body} onScroll=${(e) => setStuck(e.target.scrollTop > 2)}>- <div class=${`set-head${stuck ? " stuck" : ""}`}>- <div class="set-title">设置</div>- ${!needle && html`<nav class="warm-tabs" role="tablist" aria-label="设置分页">- ${TABS.map(([t, label]) => html`<button type="button" role="tab" aria-selected=${t === tab} class=${t === tab ? "on" : ""} onClick=${() => onTab(t)}>${label}</button>`)}- </nav>`}- ${needle && html`<span style="flex:1"></span>`}- <input class="set-find" ref=${find} type="search" placeholder="查找设置" aria-label="查找设置" value=${q} onInput=${(e) => setQ(e.target.value)}- onKeyDown=${(e) => e.key === "Escape" && q && (e.stopPropagation(), setQ(""))} />- </div>+ const title = needle ? "搜索结果" : (TABS.find(([t]) => t === tab) || TABS[0])[1];+ return html`<section class="settings view" data-screen="settings" key=${needle ? "search" : tab}>+ <div class="set-head"><h1 class="set-title">${title}</h1></div><div class="set-body">- ${!s && html`<div class="list"><div class="row"><span class="skel" style="width:40%"></span></div><div class="row"><span class="skel" style="width:55%"></span></div></div>`}+ ${!s && html`<div class="list"><div class="row"><${Skeleton} w="40%" /></div><div class="row"><${Skeleton} w="55%" /></div></div>`}${s && !shown.length && html`<p class="set-none">没有匹配的设置</p>`}${parts.map(([label, list]) => html`${label && html`<div class="set-part">${label}</div>`}<div class="list">${list.map((r) => html`<${Row} key=${r.id} id=${r.id} name=${r.name} sub=${r.sub} title=${r.title || r.sub} flash=${flash === r.id}>${r.ctl}<//>`)}</div>`)}diff --git a/ui/screens/sidebar.js b/ui/screens/sidebar.jsindex 7fd4d49..9925556 100644--- a/ui/screens/sidebar.js+++ b/ui/screens/sidebar.js@@ -1,49 +1,34 @@-// 侧栏 280:顶部搜索 / 新建两个圆形按钮,应用标志,机器人行(头像 + 名称 + 一行预览),左下角账户按钮(打开设置)。+// 侧栏 280(参考 Grok Bot):顶部只有新建按钮,常驻搜索框,机器人行(头像 + 名称 + 时间 + 一行预览),左下角账户(打开设置)。+// 新建在主区的新建页(screens/new-bot.js);新建页打开时列表顶部有一行占位的"新机器人"。import { useEffect, useRef, useState } from "preact/hooks";-import { html, Icon, Menu } from "../components/ui.js";-import { AppMark, BotAvatar, usePointerLook } from "../components/avatar.js";+import { html, Icon, IconButton, Menu, Skeleton } from "../components/ui.js";+import { BotAvatar } from "../components/avatar.js";import { api } from "../lib/api.js";import { confirmSheet, failed, toast } from "../lib/store.js";+import { fmtAgo } from "../lib/format.js";-export function Sidebar({ bots, botsError, reloadBots, selectedId, view, previews, pending, working, username, creating, setCreating, onSelect, onCreated, onDeleted, onOpenSettings }) {+/** 左下角账户:头像字母 + 用户名 + 齿轮,点开设置 */+export function AccountButton({ username, on, onClick }) {+ const me = (username || "本机用户").trim();+ return html`<button type="button" class=${`account${on ? " on" : ""}`} title="设置(⌘,)" aria-label="打开设置" onClick=${onClick}>+ <span class="me" aria-hidden="true">${me.slice(0, 1).toUpperCase()}</span>+ <span class="who">${me}</span>+ <${Icon} name="gear" size=${15} />+ </button>`;+}++export function Sidebar({ bots, botsError, reloadBots, selectedId, view, previews, pending, working, username, onNew, onSelect, onDeleted, onOpenSettings }) {const [q, setQ] = useState("");- const [searching, setSearching] = useState(false);- const [name, setName] = useState("");- const [busy, setBusy] = useState(false);const [ctx, setCtx] = useState(null); // { bot, x, y }const [renaming, setRenaming] = useState("");const [renameText, setRenameText] = useState("");const root = useRef(null);const searchRef = useRef(null);- const newRef = useRef(null);const renameRef = useRef(null);- usePointerLook(root);- useEffect(() => {- if (creating) requestAnimationFrame(() => newRef.current?.focus());- }, [creating]);useEffect(() => {if (renaming) requestAnimationFrame(() => (renameRef.current?.focus(), renameRef.current?.select()));}, [renaming]);- useEffect(() => {- if (searching) requestAnimationFrame(() => searchRef.current?.focus());- else setQ("");- }, [searching]);-- const create = async () => {- const n = name.trim();- if (!n || busy) return;- setBusy(true);- try {- const r = await api("/bots", { method: "POST", body: { name: n } });- setName("");- setCreating(false);- onCreated(r.bot);- } catch (e) {- failed(e);- }- setBusy(false);- };const rename = async (bot) => {const n = renameText.trim();setRenaming("");@@ -67,53 +52,44 @@ export function Sidebar({ bots, botsError, reloadBots, selectedId, view, preview};const needle = q.trim().toLowerCase();- const list = (bots || []).filter((b) => !needle || b.name.toLowerCase().includes(needle) || (previews[b.id] || "").toLowerCase().includes(needle));- const me = (username || "本机用户").trim();+ const list = (bots || []).filter((b) => !needle || b.name.toLowerCase().includes(needle) || (previews[b.id]?.text || "").toLowerCase().includes(needle));return html`<aside class="side" ref=${root} aria-label="机器人"><div class="side-top">- ${searching- ? html`<input class="side-search" ref=${searchRef} placeholder="搜索机器人" aria-label="搜索机器人" value=${q} onInput=${(e) => setQ(e.target.value)}- onKeyDown=${(e) => e.key === "Escape" && (e.stopPropagation(), setSearching(false))} onBlur=${() => !q && setSearching(false)} />`- : html`<button type="button" class="round-btn" title="搜索" aria-label="搜索机器人" onClick=${() => setSearching(true)}><${Icon} name="search" /></button>`}- <button type="button" class=${`round-btn${creating ? " on" : ""}`} title="新建机器人(⌘N)" aria-label="新建机器人" onClick=${() => setCreating(!creating)}><${Icon} name="plus" /></button>+ <${IconButton} icon="plus" iconSize=${16} label="新建机器人(⌘N)" on=${view === "new"} onClick=${onNew} /></div>- ${!searching && html`<div class="side-hero"><${AppMark} size=${56} /><span class="name">AnyModelBot</span></div>`}+ <label class="side-search">+ <${Icon} name="search" size=${14} />+ <input ref=${searchRef} type="search" placeholder="搜索" aria-label="搜索机器人" value=${q} onInput=${(e) => setQ(e.target.value)}+ onKeyDown=${(e) => e.key === "Escape" && q && (e.stopPropagation(), setQ(""))} />+ </label><nav class="side-list" aria-label="机器人列表">- ${creating && html`<form class="thread-new" onSubmit=${(e) => { e.preventDefault(); create(); }}>- <input class="field" placeholder="新机器人的名称" aria-label="新机器人的名称" value=${name} ref=${newRef}- onInput=${(e) => setName(e.target.value)} onKeyDown=${(e) => e.key === "Escape" && (e.stopPropagation(), setCreating(false))} />- <button type="submit" class="btn primary" disabled=${!name.trim() || busy}>创建</button>- </form>`}+ ${view === "new" && html`<div class="thread sel" aria-current="page"><${BotAvatar} neutral size=${38} />+ <span class="body"><span class="line"><span class="title">新机器人</span></span><span class="line"><span class="snip">正在创建…</span></span></span></div>`}${botsError && html`<div class="side-empty"><span>无法读取机器人列表</span><button type="button" class="btn" onClick=${reloadBots}>重试</button></div>`}- ${!bots && !botsError && [0, 1, 2].map((k) => html`<div class="thread" key=${k}><span class="skel" style="width:34px;height:34px;border-radius:50%"></span><span style="flex:1;display:grid;gap:6px"><span class="skel" style="width:50%"></span><span class="skel" style="width:75%"></span></span></div>`)}- ${bots && !bots.length && !creating && html`<div class="side-empty"><span>还没有机器人</span><button type="button" class="btn primary" onClick=${() => setCreating(true)}>新建机器人</button></div>`}- ${bots && needle && !list.length && html`<p class="hint" style="padding:8px 10px">没有匹配的机器人</p>`}+ ${!bots && !botsError && [0, 1, 2].map((k) => html`<div class="thread" key=${k}><${Skeleton} w="38px" circle /><span class="thread-skel"><${Skeleton} w="50%" /><${Skeleton} w="75%" /></span></div>`)}+ ${bots && !bots.length && view !== "new" && html`<div class="side-empty"><span>还没有机器人</span><button type="button" class="btn primary" onClick=${onNew}>新建机器人</button></div>`}+ ${bots && needle && !list.length && html`<p class="hint">没有匹配的机器人</p>`}${list.map((b) => {- const sel = view === "chat" && b.id === selectedId;+ const sel = (view === "chat" || view === "bot-settings") && b.id === selectedId;const n = pending[b.id] || 0;if (renaming === b.id)- return html`<div class="thread sel" key=${b.id}><${BotAvatar} name=${b.name} id=${b.id} size=${34} />- <input class="field" style="height:30px" value=${renameText} aria-label="新名称" ref=${renameRef}+ return html`<div class="thread sel" key=${b.id}><${BotAvatar} bot=${b} size=${38} />+ <input class="field" value=${renameText} aria-label="新名称" ref=${renameRef}onInput=${(e) => setRenameText(e.target.value)} onBlur=${() => rename(b)}onKeyDown=${(e) => { if (e.key === "Enter") e.target.blur(); if (e.key === "Escape") { e.stopPropagation(); setRenaming(""); } }} /></div>`;- return html`<button type="button" key=${b.id} class=${`thread${sel ? " sel" : ""}`} aria-current=${sel ? "page" : undefined}+ const pv = previews[b.id];+ return html`<button type="button" key=${b.id} class=${`thread bot-hover${sel ? " sel" : ""}`} aria-current=${sel ? "page" : undefined}onClick=${() => onSelect(b.id)} onContextMenu=${(e) => { e.preventDefault(); setCtx({ bot: b, x: e.clientX, y: e.clientY }); }}>- <span class="avatar-wrap"><${BotAvatar} name=${b.name} id=${b.id} size=${34} working=${!!working[b.id]} />${working[b.id] && html`<span class="working-dot" title="工作中"></span>`}</span>+ <span class="avatar-wrap"><${BotAvatar} bot=${b} size=${38} state=${n > 0 ? "waiting" : working[b.id] ? "working" : "idle"} />${working[b.id] && html`<span class="working-dot" title="工作中"></span>`}</span><span class="body">- <span class="title" style="display:block">${b.name}</span>- <span class="snip" style="display:block">${previews[b.id] || "还没有对话"}</span>+ <span class="line"><span class="title">${b.name}</span>${pv?.at && html`<span class="when num">${fmtAgo(pv.at)}</span>`}</span>+ <span class="line"><span class="snip">${working[b.id] ? "正在工作…" : pv?.text || "还没有对话"}</span>${n > 0 && html`<span class="badge count" title=${`${n} 个待审批`}>${n}</span>`}</span></span>- ${n > 0 && html`<span class="badge count" title=${`${n} 个待审批`}>${n}</span>`}</button>`;})}</nav>- <div class="side-foot">- <button type="button" class=${`account${view === "settings" ? " on" : ""}`} title="设置(⌘,)" aria-label="打开设置" onClick=${onOpenSettings}>- <span class="me" aria-hidden="true">${me.slice(0, 1).toUpperCase()}</span>- <span class="who">${me}</span>- </button>- </div>+ <div class="side-foot"><${AccountButton} username=${username} onClick=${onOpenSettings} /></div>${ctx && html`<${Menu} anchor=${{ left: ctx.x, right: ctx.x, top: ctx.y, bottom: ctx.y, width: 0 }} width=${200} label=${`${ctx.bot.name} 的操作`} onClose=${() => setCtx(null)}items=${[{ label: "重命名", onSelect: () => { setRenameText(ctx.bot.name); setRenaming(ctx.bot.id); } },diff --git a/ui/tokens.css b/ui/tokens.cssdeleted file mode 100644index 2ab2604..0000000--- a/ui/tokens.css+++ /dev/null@@ -1,112 +0,0 @@-/* AnyModelBot design tokens.- Neutral greys, radii and motion adapted from yetone/magpie internal/gui/assets/app.css (MIT, © 2026 yetone).- Accent = Modelflare signal yellow-green #d7ff00 with ink #161a00 (modelflare.dev / docs.modelflare.dev);- light-mode foreground accent = Modelflare pricing olive #5f711c (the yellow-green is 1.15:1 on white).- Derived (not from Modelflare's CSS): --accent-hover/--accent-press used as states, --sel, --bubble-*.-- Dark values are defined once: <html data-theme> always holds the resolved theme- ("light" | "dark"), set before first paint by index.html and kept in sync by lib/theme.js. */-:root {- --bg: #f4f4f6;- --card: #ffffff;- --card-2: #f9f9fb;- --pill: #f1f1f4;- --pill-hover: #e9e9ee;- --seg-track: #e6e6eb;- --seg-edge: 0 1px 2px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .08);- --line: #e3e3e8;- --line-2: #ececf0;- --fg: #1c1c21;- --fg-2: #4b4b53;- --muted: #85858d;- --faint: #b9b9c2;- --ctl-fg: #63636b;-- /* Modelflare brand */- --accent: #5f711c; /* text, links, icons, focus ring */- --accent-strong: #465612; /* link hover */- --accent-solid: #d7ff00; /* filled brand surfaces */- --on-accent: #161a00; /* ink on --accent-solid, 15.39:1 */- --accent-hover: #e6ff4d;- --accent-press: #c7ef00;- --accent-soft: #f1f4e9;- --accent-line: #78960059;- --sel: #edf7b8;- --bubble-top: #daff14;- --bubble-bottom: #d7ff00;-- --green: #189a58;- --green-soft: #e4f6ec;- --red: #d64545;- --red-soft: #fbe9e9;- --amber: #b45309;- --amber-soft: #fbf0df;-- --pop-bg: rgba(255, 255, 255, .94);- --shadow: 0 16px 44px rgba(20, 22, 30, .16), 0 2px 8px rgba(20, 22, 30, .06), 0 0 0 .5px rgba(20, 22, 30, .1);- --float-edge: 0 1px 3px rgba(0, 0, 0, .08), 0 0 0 1px #ededed;-- /* chat surfaces: pure neutral greys */- --chat-bg: #fcfcfc;- --side-bg: #f5f5f5;- --side-hover: #ececec;- --side-active: #e4e4e4;- --bubble-ai: #f0f0f0;- --placeholder: #a4a4a4;- --composer-bg: #ffffff;-- --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;- --code: ui-monospace, "SF Mono", Menlo, Consolas, "Microsoft YaHei UI", monospace;- --ease: cubic-bezier(.2, .8, .2, 1);- --side-w: 280px;- --panel-w: 320px;- --col-w: 960px;- --bubble-w: 560px;- color-scheme: light;-}-:root.win {- --font: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;- --code: "Cascadia Mono", Consolas, "Microsoft YaHei UI", "Microsoft YaHei", monospace;-}-:root[data-theme="dark"] {- --bg: #1a1a1e;- --card: #232327;- --card-2: #1f1f23;- --pill: #2d2d33;- --pill-hover: #36363d;- --seg-track: rgba(255, 255, 255, .035);- --seg-edge: inset 0 .5px 0 rgba(255, 255, 255, .08), 0 1px 2px rgba(0, 0, 0, .3);- --line: #333339;- --line-2: #2c2c32;- --fg: #ededf1;- --fg-2: #b9b9c1;- --muted: #8b8b94;- --faint: #56565f;- --ctl-fg: #a1a1aa;-- --accent: #d7ff00;- --accent-strong: #e9ff66;- --accent-soft: #d7ff0014;- --accent-line: #d7ff004d;- --sel: #31361a;-- --green: #6fd99b;- --green-soft: #1e3a2b;- --red: #f28b82;- --red-soft: #45272a;- --amber: #f2b544;- --amber-soft: #3f3220;-- --pop-bg: rgba(38, 38, 43, .96);- --shadow: 0 16px 44px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3), 0 0 0 .5px rgba(255, 255, 255, .1);- --float-edge: 0 1px 3px rgba(0, 0, 0, .4), 0 0 0 1px #333339;-- --chat-bg: #1c1c20;- --side-bg: #1a1a1e;- --side-hover: #26262b;- --side-active: #2d2d33;- --bubble-ai: #2d2d33;- --placeholder: #6e6e77;- --composer-bg: #26262b;- color-scheme: dark;-}