/* ─────────────────────────────────────────────────────────────────────
   freebrain skin for new-api
   注入方式：反向代理改写 index.html，不修改 new-api 二进制。
   覆写目标 = new-api web/src/styles/theme.css 的 :root 变量契约 (55 个)。
   来源 = freebrain-site/app/globals.css 的设计 token。
   ───────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Geist';
  src: url('/__fb/Geist.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/__fb/GeistMono.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ── freebrain 原始 token（保留原名，便于对照 globals.css） ── */
  --fb-paper: #fcfcfa;
  --fb-paper-2: #f4f3f0;
  --fb-ink: #141311;
  --fb-ink-60: #55524c;
  --fb-ink-40: #8c8880;
  --fb-hairline: #dddad4;
  --fb-peri: #5057c4;
  --fb-peri-deep: #3f46a8;
  --fb-peri-on-ink: #a8aef5;
  --fb-spot-chat: #1f6c9f;
  --fb-spot-image: #956400;
  --fb-spot-video: #9f2f2d;
  --fb-ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* ── 映射到 new-api / shadcn 契约 ── */
  --background: var(--fb-paper);
  --foreground: var(--fb-ink);
  --card: var(--fb-paper);
  --card-foreground: var(--fb-ink);
  --popover: var(--fb-paper);
  --popover-foreground: var(--fb-ink);

  --primary: var(--fb-peri);
  --primary-foreground: var(--fb-paper);
  --secondary: var(--fb-paper-2);
  --secondary-foreground: var(--fb-ink);
  --muted: var(--fb-paper-2);
  --muted-foreground: var(--fb-ink-60);
  --accent: color-mix(in oklch, var(--fb-peri) 10%, var(--fb-paper));
  --accent-foreground: var(--fb-ink);
  --neutral: var(--fb-ink-40);
  --neutral-foreground: var(--fb-ink);

  /* 语义色：三个 modality spot 各就各位，success 补一个同调低饱和绿 */
  --destructive: var(--fb-spot-video);
  --destructive-foreground: var(--fb-paper);
  --warning: var(--fb-spot-image);
  --warning-foreground: var(--fb-paper);
  --info: var(--fb-spot-chat);
  --info-foreground: var(--fb-paper);
  --success: #3d7a55;
  --success-foreground: var(--fb-paper);

  --border: var(--fb-hairline);
  --input: var(--fb-hairline);
  --ring: var(--fb-peri);

  --chart-1: var(--fb-peri);
  --chart-2: var(--fb-spot-chat);
  --chart-3: var(--fb-spot-image);
  --chart-4: var(--fb-spot-video);
  --chart-5: var(--fb-ink-40);
  --overview-accent-1: var(--fb-peri);
  --overview-accent-2: var(--fb-spot-chat);
  --overview-accent-3: var(--fb-spot-image);

  --sidebar: var(--fb-paper-2);
  --sidebar-foreground: var(--fb-ink);
  --sidebar-primary: var(--fb-peri);
  --sidebar-primary-foreground: var(--fb-paper);
  --sidebar-accent: color-mix(in oklch, var(--fb-peri) 10%, var(--fb-paper-2));
  --sidebar-accent-foreground: var(--fb-peri-deep);
  --sidebar-border: var(--fb-hairline);
  --sidebar-ring: var(--fb-peri);

  --skeleton-base: var(--fb-paper-2);
  --skeleton-highlight: var(--fb-paper);
  --table-row: var(--fb-paper);
  --table-header: var(--fb-paper-2);
  --table-header-hover: color-mix(in oklch, var(--fb-ink) 6%, var(--fb-paper));
  --table-disabled: var(--fb-paper-2);
  --table-disabled-hover: color-mix(in oklch, var(--fb-ink) 5%, var(--fb-paper));
  --table-disabled-border: var(--fb-hairline);

  /* 三个半径里的 card 档；shadcn 由 --radius 派生 sm/md/lg */
  --radius: 10px;
  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Geist', ui-sans-serif, system-ui, sans-serif;
}

/* ── 深色：freebrain 是浅色品牌，这里按 ink 底 + peri-on-ink 推导 ── */
.dark {
  --background: var(--fb-ink);
  --foreground: var(--fb-paper-2);
  --card: #1a1917;
  --card-foreground: var(--fb-paper-2);
  --popover: #1a1917;
  --popover-foreground: var(--fb-paper-2);

  --primary: var(--fb-peri-on-ink);
  --primary-foreground: var(--fb-ink);
  --secondary: #23211e;
  --secondary-foreground: var(--fb-paper-2);
  --muted: #1c1a18;
  --muted-foreground: var(--fb-ink-40);
  --accent: color-mix(in oklch, var(--fb-peri-on-ink) 14%, var(--fb-ink));
  --accent-foreground: var(--fb-paper-2);

  --border: #2c2926;
  --input: #2c2926;
  --ring: var(--fb-peri-on-ink);

  --sidebar: #1a1917;
  --sidebar-foreground: var(--fb-paper-2);
  --sidebar-primary: var(--fb-peri-on-ink);
  --sidebar-primary-foreground: var(--fb-ink);
  --sidebar-accent: color-mix(in oklch, var(--fb-peri-on-ink) 14%, #1a1917);
  --sidebar-accent-foreground: var(--fb-peri-on-ink);
  --sidebar-border: #2c2926;
  --sidebar-ring: var(--fb-peri-on-ink);

  --skeleton-base: #1c1a18;
  --skeleton-highlight: #23211e;
  --table-row: var(--fb-ink);
  --table-header: #1c1a18;
  --table-header-hover: #23211e;
  --table-disabled: #1a1917;
  --table-disabled-hover: #201e1b;
  --table-disabled-border: #2c2926;
}

/* ── 质感规则（freebrain §2：零阴影、单一缓动） ──
   零阴影用 Tailwind v4 的 --tw-shadow 通道做，不动 box-shadow 本身，
   这样 ring / outline / focus-visible 完全不受影响。 */
* {
  --tw-shadow: 0 0 #0000 !important;
  --tw-drop-shadow: none !important;
}

/* 单一缓动曲线；只改曲线不改时长，避免抽屉/弹层的时序被打乱 */
*,
*::before,
*::after {
  transition-timing-function: var(--fb-ease);
}

/* 品牌字重：Geist 可变轴 440 = freebrain 的中间调 */
body {
  font-family: var(--font-sans);
  font-weight: 440;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code,
pre,
kbd,
samp,
.font-mono {
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* 表格数字对齐（freebrain globals.css 同款） */
table {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--fb-peri);
  color: var(--fb-paper);
}

/* 发丝线：仅在高分屏上把 1px 边框收到 0.5px，低分屏保持 1px 以免渲染成 0 */
@media (min-resolution: 1.5dppx) {
  .border,
  .border-t,
  .border-b,
  .border-l,
  .border-r,
  .border-x,
  .border-y {
    border-width: 0.5px;
  }
}
