/* ============================================================================
   WanChat /app —「暖纸工作台」主题令牌（slug: notion）
   参考：Notion 官网 DESIGN.md（light 优先 / warm paper notebook）
   约束：只使用 web/src/styles.css 中真实存在的变量名；视觉改观仅走
         ①语义令牌取值 ②官方 variant/size ③容器布局 三条途径之一。
   落地方式：直接替换 web/src/styles.css 的 `@theme inline` 与 `:root` / `.dark`
             变量块（本文件即该替换内容）。
   对比度全部按 WCAG 2.1 相对亮度公式实算，比值写在 proposal.md §7。
   ========================================================================== */

/* ---------------------------------------------------------------------------
   @theme inline —— 沿用原文映射，仅把四个阴影令牌的色相从冷蓝灰（15 23 42 /
   4 4 5）改为暖中性（32 29 24 / 25 24 23），保持原有四档 alpha 结构不变。
   意图：Notion 是 hairline 边界体系，阴影只作为浮动层（popover/dialog）的
   极淡托底；暖纸底色上若仍用冷蓝阴影会显出脏调。
   途径：①（--shadow-e1..e4 是 styles.css 中真实存在的令牌）
--------------------------------------------------------------------------- */
@theme inline {
  --font-heading: var(--font-sans);
  --font-sans:
    "Geist Variable", "gg sans", "Noto Sans SC", "PingFang SC", ui-sans-serif,
    system-ui, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial,
    sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --color-brand-ink: var(--brand-ink);
  /* 阴影阶梯：色相转暖，alpha 结构沿用原文（未改台阶数量与强度）。
     途径①：暖纸底色上冷蓝阴影（15 23 42）会悬挂出脏灰调。 */
  --shadow-e1: 0 1px 0 rgb(25 24 23 / 0.08), 0 1.5px 0 rgb(25 24 23 / 0.02);
  --shadow-e2:
    0 2px 4px -1px rgb(32 29 24 / 0.07), 0 6px 16px -4px rgb(32 29 24 / 0.1);
  --shadow-e3:
    0 10px 28px -8px rgb(32 29 24 / 0.16), 0 2px 6px -2px rgb(32 29 24 / 0.06);
  --shadow-pop:
    0 16px 40px -12px rgb(32 29 24 / 0.24), 0 4px 10px -4px rgb(32 29 24 / 0.1);
  /* Motion tokens：沿用原文（enter 240ms / rise 160ms 减速曲线），与 Notion
     的 200ms ease 同量级，不动。 */
  --animate-message-in: message-in 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
  --animate-rise-in: rise-in 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
  --animate-drawer-in: drawer-in 240ms cubic-bezier(0.22, 1, 0.36, 1);
  --animate-drawer-overlay-in: drawer-overlay-in 160ms ease-out;
  --animate-drop-in: drop-in 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
  --animate-breathe: breathe 1.2s ease-in-out infinite;
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --color-foreground: var(--foreground);
  --color-background: var(--background);
  --color-brand: var(--brand);
  --color-brand-foreground: var(--brand-foreground);
  --color-brand-soft: var(--brand-soft);
  --color-surface-chat-soft: var(--surface-chat-soft);
  --color-surface-chat-selected: var(--surface-chat-selected);
  --color-mention: var(--mention);
  --color-ink: var(--ink);
  --color-surface-rail: var(--surface-rail);
  --color-interactive: var(--interactive);
  --color-channel-icon: var(--channel-icon);
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --radius-3xl: calc(var(--radius) * 2.2);
  --radius-4xl: calc(var(--radius) * 2.6);
}

/* ---------------------------------------------------------------------------
   :root —— 浅色「暖纸工作台」（参考 Notion 的 #f6f5f4 canvas + #ffffff card）
   表面栈（浅色）：rail #e6e3dd → sidebar #eeece8 → canvas #f6f5f4 → card #ffffff
--------------------------------------------------------------------------- */
:root {
  /* 画布：#fcfcfc（与侧栏同色、零层级）→ #f6f5f4 暖纸底。意图：给白卡留出
     「贴上去」的层级，ΔL 相对白卡 1.089:1；同时降低 15px 正文长时间驻留的眩光。 */
  --background: #f6f5f4;
  /* 正文：#060607（近纯黑，17.7:1 过于锐利）→ #191817（暖墨 = 参考 Ink Black
     在暖底上 ~90% alpha 的合成值），canvas 上 16.28:1。 */
  --foreground: #191817;
  --card: #ffffff;
  --card-foreground: #191817;
  --popover: #ffffff;
  --popover-foreground: #191817;
  /* 自己/他人气泡由 message-bubble.tsx 决定：自己=variant="default"(bg-primary)
     + 本地覆盖 --message-self，他人=variant="secondary"。 */
  --message-self: #d9e9fc; /* 本人气泡：#e8f3fe → Sky Tint 再深一档；与 --secondary 暖灰气泡在色相上彻底分开 */
  --message-self-foreground: #0b2545; /* 本人气泡文字：深海军蓝，12.46:1（>4.5） */
  --primary: var(--brand);
  --primary-foreground: var(--brand-foreground);
  /* 他人气泡底：#ebedef 冷灰 → #e9e5df 暖灰；对画布 1.152:1，气泡边界可辨。
     同时作为 Button variant="secondary" / 菜单底色。 */
  --secondary: #e9e5df;
  --secondary-foreground: #191817;
  --muted: #f1eeea; /* 弱底：#f2f3f5 冷灰 → #f1eeea 暖灰，用于输入态/空态块 */
  /* 次级文字：#5c5e66 冷灰 → #615d59（参考 Graphite「warm cast body text」）；
     对 canvas 5.99:1、对白卡 6.53:1，均 >4.5。 */
  --muted-foreground: #615d59;
  --accent: #eae6e0; /* hover 底：暖一档灰，替代 #ebedef 冷灰 */
  --accent-foreground: #191817;
  /* 危险色：#da373c（纯红）→ #b32518（参考 Vermillion #e32d14 加深），
     保证 shadcn destructive 的 bg-destructive/10 + text-destructive 组合也达标：
     对 canvas 6.04、对白卡 6.57、对 destructive/10 底（canvas 上）5.13。 */
  --destructive: #b32518;
  /* 边界：从实色 #dcdee1 改为暖墨 12% alpha（= #dbdad9 on canvas，1.282:1）。
     意图：复刻参考的 hairline rgba(0,0,0,0.08)——卡片靠 1px 细线而非阴影分隔。 */
  --border: rgb(25 24 23 / 0.12);
  /* 输入框边界必须能被辨识（WCAG 1.4.11 非文本对比 ≥3:1）：
     #dcdee1 对 canvas 仅 1.35:1 → #8f8880，对 canvas 3.21:1、对白卡 3.50:1。 */
  --input: #8f8880;
  --ring: var(--brand);
  /* chart-1..5：原为 oklch(0.87/0.556/0.439/0.371/0.269 0 0) 冷灰阶 →
     暖中性阶，保持「单色渐变阶梯」脚本不变（参考：色彩只作稀疏标点）。 */
  --chart-1: #d9d4cc;
  --chart-2: #b3ada3;
  --chart-3: #8c867c;
  --chart-4: #6b655c;
  --chart-5: #4a453e;
  /* 圆角：#0.625rem(10px) → 0.5rem(8px)。理由：参考「cards 12px / buttons 8px」。
     映射后 Button/Input 走 rounded-lg = 8px（与参考按钮 8px 一致），
     气泡 rounded-xl = 11.2px ≈ 参考卡片 12px，弹窗 rounded-2xl = 14.4px。 */
  --radius: 0.5rem;
  /* 主色：参考 Notion Blue #0075de 作填充时白字 4.57:1 达标，但作正文/链接文字
     （shadcn Button variant="link"、Tab active 用 text-primary）对 canvas 只有
     4.19:1。因此加深一档到 #006bce：白字 5.26:1、对 canvas 4.83:1，两头都过线。 */
  --brand: #006bce;
  --brand-foreground: #ffffff;
  --brand-soft: #e6f3fe; /* 直接取参考 Sky Tint：选中态/浅蓝洗底 */
  /* 链接与强调文字：#1d4ed8 → #005cba；对 canvas 5.95、白卡 6.48、brand-soft 5.75。 */
  --brand-ink: #005cba;
  /* 引用/回复气泡底：#e8f2ff → #eef5fc（Sky Tint 的更浅一档），与本人气泡再分层。 */
  --surface-chat-soft: #eef5fc;
  /* 会话/列表选中底：#e5ecfc → #e2eefc，保持蓝调但更收敛（对 canvas 1.079）。 */
  --surface-chat-selected: #e2eefc;
  /* @ 提及：#3370ff（与 brand 并存的第三种蓝）→ #0057b0，与 --brand-ink 同族但更深，
     用于提及落在浅蓝底上的场景；对 canvas 6.45、白卡 7.02、chat-soft 6.39。 */
  --mention: #0057b0;
  --ink: #191817; /* 与 foreground 同步，避免同文件里 #060607 与暖墨并存 */
  /* 空间 rail：#e1e8f2（蓝灰）→ #e6e3dd 暖灰，成为表面栈最深一阶（对 canvas 1.176）。 */
  --surface-rail: #e6e3dd;
  /* 参考明确「Do not use gradients — strictly flat fills」：把 rail 渐变改为平涂。 */
  --workspace-background: var(--surface-rail);
  --workspace-rail-background: transparent;
  --workspace-header-background: var(--background);
  --interactive: #6b655e; /* 图标/次要交互：#4e5058 → 暖灰，对 canvas 5.29 */
  --channel-icon: #8a847c; /* 频道图标：#80848e → 暖灰，对 canvas 3.40（图形边界 ≥3） */
  /* 会话侧栏：#fcfcfc（与画布同色、零层级）→ #eeece8 暖灰，对 canvas 1.084，
     让「rail → 侧栏 → 画布 → 白卡」形成四级表面栈。 */
  --sidebar: #eeece8;
  --sidebar-foreground: #191817;
  --sidebar-primary: var(--brand);
  --sidebar-primary-foreground: var(--brand-foreground);
  --sidebar-accent: #e2ded8; /* 侧栏 hover/选中：对 canvas 1.13，正文对比 13.23 */
  --sidebar-accent-foreground: #191817;
  --sidebar-border: rgb(25 24 23 / 0.10);
  --sidebar-ring: var(--ring);
}

/* ---------------------------------------------------------------------------
   .dark —— 反转的暖纸（warm charcoal），不是纯 oklch(0 0) 中性灰
   表面栈（深色）：rail #161514 → sidebar #201f1d → canvas #1e1d1b → card #262522
--------------------------------------------------------------------------- */
.dark {
  /* rail：#e3e5e8（浅色竖带缺陷）→ #161514，深色下 rail 成为最深一阶。 */
  --surface-rail: #161514;
  --workspace-background: var(--surface-rail); /* 去渐变，改平涂（参考 flat fills） */
  --workspace-rail-background: color-mix(in oklab, var(--background) 45%, transparent);
  --workspace-header-background: var(--background); /* 去 brand 混色渐变，改平涂 */
  --message-self: #1e3a54; /* 本人气泡：暖化后的深钢蓝（原 #203b59） */
  --message-self-foreground: #dceaff; /* 9.65:1 */
  --background: #1e1d1b; /* 画布：oklch(0.145 0 0) 纯灰 → 暖炭，与浅色 #f6f5f4 同源 */
  --foreground: #f0eee9; /* 正文 14.53:1（原 oklch(0.985 0 0) 为 15.8:1，略降眩光） */
  --card: #262522;
  --card-foreground: #f0eee9;
  --popover: #262522;
  --popover-foreground: #f0eee9;
  --secondary: #2e2c28; /* 他人气泡底：对 canvas 1.209，气泡边界可辨 */
  --secondary-foreground: #f0eee9;
  --muted: #2b2a27;
  --muted-foreground: #a8a29a; /* 6.66:1（原 oklch(0.708 0 0) 冷灰） */
  --accent: #2b2a27;
  --accent-foreground: #f0eee9;
  /* 危险色：oklch(0.704 0.191 22.216) → #ff8a7d；bg-destructive/20 + text-destructive
     组合在 canvas 上 5.06、白卡上 4.63，均 >4.5（原值在深底上偏暗）。 */
  --destructive: #ff8a7d;
  --border: rgb(240 238 233 / 0.12); /* 暖白 hairline，对 canvas 1.395 */
  /* 输入框边界：0.15 alpha 对卡片不足 3:1 → 0.40 alpha（合成 #777572，
     对卡片 3.34:1、对 canvas 3.67:1）。 */
  --input: rgb(240 238 233 / 0.40);
  --chart-1: #e8e4dd;
  --chart-2: #b8b2a8;
  --chart-3: #8f897f;
  --chart-4: #6a645b;
  --chart-5: #4a453e;
  /* 主色：oklch(0.68 0.15 256) → #2f95ff；深色下的 --brand-foreground 6.16:1。 */
  --brand: #2f95ff;
  --brand-foreground: #06121f;
  --brand-soft: #22384e; /* 选中底：与 brand-ink 组合 6.09:1 */
  --brand-ink: #7fbdff; /* 链接/强调文字：对 canvas 8.52、白卡 7.76 */
  --surface-chat-soft: #24384e;
  --surface-chat-selected: #2a3a4d;
  --mention: #86c5ff; /* 提及：比 brand-ink 再亮一档，便于在 chat-soft 上区分 */
  --ink: #121110;
  /* 侧栏：oklch(0.205 0 0) 与 card 同色 → #201f1d，与 canvas 1.023（深色下侧栏
     靠 --sidebar-border 与画布分离，而非靠大色差）。 */
  --sidebar: #201f1d;
  --sidebar-foreground: #f0eee9;
  --sidebar-accent: #2e2c28;
  --sidebar-accent-foreground: #f0eee9;
  --sidebar-border: rgb(240 238 233 / 0.10);
  --interactive: #a09a92;
  --channel-icon: #8f897f;
}
