/* ==========================================================================
   设计令牌
   所有颜色、字号、间距、圆角、阴影都从这里取值，组件内不写裸色值。
   换主题色只需改 --brand，其余品牌色阶由 color-mix 自动推导。
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../vendor/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../vendor/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* 品牌：换项目时只改这一项 */
  --brand: #2f5bff;
  --brand-ink: #ffffff;

  /* 字体 */
  --font-sans: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  /* 字号 */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-20: 20px;
  --fs-24: 24px;
  --fs-30: 30px;
  --fs-40: 40px;

  /* 间距（4px 网格） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* 圆角：由 --radius-scale 整体缩放 */
  --radius-scale: 1;
  --r-1: calc(4px * var(--radius-scale));
  --r-2: calc(6px * var(--radius-scale));
  --r-3: calc(8px * var(--radius-scale));
  --r-4: calc(12px * var(--radius-scale));
  --r-5: calc(16px * var(--radius-scale));
  --r-full: 999px;

  /* 尺寸与密度 */
  --ctl-h: 36px;
  --ctl-h-sm: 30px;
  --ctl-h-lg: 42px;
  --cell-y: 13px;
  --sidebar-w: 224px;
  --sidebar-w-mini: 68px;
  --topbar-h: 56px;
  --page-x: 28px;

  /* 动效 */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --t-fast: .14s;
  --t-base: .22s;

  /* 中性色 */
  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f0f2f5;
  --line: #e6e8ed;
  --line-strong: #d3d7de;
  --text: #0f1319;
  --text-2: #4b5563;
  --text-3: #79818f;
  --text-4: #a5acb8;

  /* 语义色 */
  --success: #0e9f6e;
  --warning: #d97706;
  --danger: #e5484d;
  --info: #0b8bd6;
  --success-text: #067a53;
  --warning-text: #b05c02;
  --danger-text: #cd2b31;
  --info-text: #0a6fae;

  /* 阴影 */
  --shadow-1: 0 1px 2px rgb(15 19 25 / .05);
  --shadow-2: 0 1px 2px rgb(15 19 25 / .04), 0 6px 16px -6px rgb(15 19 25 / .1);
  --shadow-3: 0 2px 4px rgb(15 19 25 / .04), 0 16px 40px -12px rgb(15 19 25 / .2);
  --shadow-4: 0 4px 8px rgb(15 19 25 / .05), 0 32px 72px -16px rgb(15 19 25 / .32);
  --overlay: rgb(10 13 18 / .46);

  /* 图表分类色：固定顺序，已通过色觉校验 */
  --series-1: #2f5bff;
  --series-2: #eb6834;
  --series-3: #14a37f;
  --series-4: #e0a000;
  --series-5: #d6518f;
  --series-6: #7a5cf0;

  /* 顶部导航（默认深色） */
  --head-bg: #0d1016;
  --head-line: rgb(255 255 255 / .09);
  --head-text: #eef0f4;
  --head-text-2: #a2aab7;
  --head-hover: rgb(255 255 255 / .07);
  --head-active: rgb(255 255 255 / .13);

  /* 侧栏（默认浅色，暗色模式随表面色变化） */
  --side-bg: var(--surface);
  --side-line: var(--line);
  --side-text: var(--text);
  --side-text-2: var(--text-2);
  --side-text-3: var(--text-3);
  --side-hover: var(--surface-3);
  --side-active: var(--brand-soft);
  --side-active-text: var(--brand-text);
}

/* 品牌色阶：放在 html 上，暗色模式下随表面色重新计算 */
:root,
[data-theme="dark"] {
  --brand-hover: color-mix(in oklab, var(--brand) 88%, #000);
  --brand-active: color-mix(in oklab, var(--brand) 78%, #000);
  --brand-soft: color-mix(in oklab, var(--brand) 9%, var(--surface));
  --brand-soft-2: color-mix(in oklab, var(--brand) 16%, var(--surface));
  --brand-line: color-mix(in oklab, var(--brand) 34%, var(--surface));
  --brand-text: color-mix(in oklab, var(--brand) 86%, var(--text));
  --focus-ring: 0 0 0 3px color-mix(in oklab, var(--brand) 24%, transparent);

  --success-soft: color-mix(in oklab, var(--success) 10%, var(--surface));
  --warning-soft: color-mix(in oklab, var(--warning) 11%, var(--surface));
  --danger-soft: color-mix(in oklab, var(--danger) 9%, var(--surface));
  --info-soft: color-mix(in oklab, var(--info) 10%, var(--surface));
  --success-line: color-mix(in oklab, var(--success) 28%, var(--surface));
  --warning-line: color-mix(in oklab, var(--warning) 30%, var(--surface));
  --danger-line: color-mix(in oklab, var(--danger) 28%, var(--surface));
  --info-line: color-mix(in oklab, var(--info) 28%, var(--surface));
}

[data-theme="dark"] {
  color-scheme: dark;

  --canvas: #0a0c10;
  --surface: #12151b;
  --surface-2: #171b22;
  --surface-3: #1e232c;
  --line: #242a34;
  --line-strong: #353c49;
  --text: #eef0f4;
  --text-2: #aab1bd;
  --text-3: #7d8593;
  --text-4: #5b6370;

  --success: #2bb98a;
  --warning: #e8a03a;
  --danger: #f0656a;
  --info: #3fa9e8;
  --success-text: #4fcea3;
  --warning-text: #eeb15f;
  --danger-text: #f58589;
  --info-text: #6cbdf0;

  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 1px 2px rgb(0 0 0 / .4), 0 6px 16px -6px rgb(0 0 0 / .5);
  --shadow-3: 0 2px 4px rgb(0 0 0 / .4), 0 16px 40px -12px rgb(0 0 0 / .7);
  --shadow-4: 0 4px 8px rgb(0 0 0 / .4), 0 32px 72px -16px rgb(0 0 0 / .8);
  --overlay: rgb(0 0 0 / .62);

  --brand-text: color-mix(in oklab, var(--brand) 62%, #ffffff);

  --series-1: #4e76f5;
  --series-2: #de6230;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d4528c;
  --series-6: #8a73e8;
}

/* 导航风格：mix 深色顶栏 + 浅色侧栏（默认），dark 全深色，light 全浅色 */
[data-sidebar="dark"] {
  --side-bg: #0d1016;
  --side-line: rgb(255 255 255 / .09);
  --side-text: #eef0f4;
  --side-text-2: #a2aab7;
  --side-text-3: #6d7584;
  --side-hover: rgb(255 255 255 / .06);
  --side-active: rgb(255 255 255 / .1);
  --side-active-text: #ffffff;
}

[data-sidebar="light"]:not([data-theme="dark"]) {
  --head-bg: var(--surface);
  --head-line: var(--line);
  --head-text: var(--text);
  --head-text-2: var(--text-2);
  --head-hover: var(--surface-3);
  --head-active: var(--surface-3);
}

/* 紧凑密度 */
[data-density="compact"] {
  --ctl-h: 32px;
  --ctl-h-sm: 26px;
  --ctl-h-lg: 38px;
  --cell-y: 8px;
  --topbar-h: 52px;
  --page-x: 20px;
}

/* 圆角风格 */
[data-radius="sharp"] { --radius-scale: .5; }
[data-radius="round"] { --radius-scale: 1.4; }
