/* 智学云 · 全站主题语义变量（日间 / 夜间）
 * 所有者：theme-tokens.css。所有页面、浮层、图表与独立窗口只引用这里的语义变量，
 * 不再各自硬编码白底与墨色。主题由 html[data-theme] 决定，preference 由 theme.js 写入。
 * 载入顺序：本文件必须排在其它样式表之前，theme-dark.css 排在最后。
 */

:root {
  color-scheme: light;

  /* 表面层级 */
  --color-canvas: #f6f6f2;
  --color-shell: #ffffff;
  --color-shell-veil: rgba(255, 255, 255, .97);
  --color-surface: #ffffff;
  --color-surface-subtle: #f8f9fb;
  --color-surface-raised: #ffffff;
  --color-surface-hover: #f2f4f7;
  --color-surface-inset: #f6f7f9;

  /* 文字 */
  --color-text-heading: #182238;
  --color-text-body: #303d51;
  --color-text-secondary: #5e6a7c;
  --color-text-muted: #647184;
  --color-text-on-dark: #f2f5f9;

  /* 边框 */
  --color-border-subtle: #e4e8ee;
  --color-border-soft: #edf0f4;
  --color-border-strong: #d4dbe4;
  --color-border-control: #7d899b;
  --color-border-warm: #eadfcf;

  /* 品牌 */
  --color-brand-fill: #b8893e;
  --color-brand-fill-strong: #98702f;
  --color-brand-fill-soft: #d6a85c;
  --color-brand-on-fill: #182238;
  --color-brand-text: #805b23;
  --color-brand-soft: #f8f0e2;
  --color-brand-soft-text: #805b23;
  --color-focus-ring: #805b23;
  --color-search-focus-border: var(--color-brand-fill);
  --color-search-focus-halo: color-mix(in srgb, var(--color-brand-fill) 8.24%, transparent);
  --color-accent-purple: #6d5dd3;
  --color-accent-purple-soft: #f0eefb;

  /* 状态 */
  --color-success-text: #216e4e;
  --color-success-bg: #eaf5ef;
  --color-warning-text: #805b23;
  --color-warning-bg: #fff3d9;
  --color-danger-text: #b42332;
  --color-danger-bg: #fdeef0;
  --color-info-text: #285da8;
  --color-info-bg: #edf3ff;

  /* 选区与遮罩 */
  --color-selection-bg: #e9d5ac;
  --color-selection-text: #182238;
  --color-overlay: rgba(24, 34, 56, 0.4);
  --color-scrim: rgba(24, 34, 56, 0.55);
  --color-scrim-strong: rgba(24, 34, 56, 0.72);

  /* 阴影 */
  --shadow-card: 0 2px 6px rgba(24, 34, 56, 0.025);
  --shadow-card-hover: 0 10px 28px rgba(24, 34, 56, 0.09);
  --shadow-raised: 0 18px 48px rgba(24, 34, 56, 0.14);
  --shadow-inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.6);

  /* 壳体装饰线（顶栏 / 侧栏顶部） */
  --color-shell-accent: linear-gradient(90deg,
    rgba(184, 137, 62, 0.12) 0%,
    rgba(184, 137, 62, 0.5) 25%,
    #b8893e 50%,
    rgba(184, 137, 62, 0.5) 75%,
    rgba(184, 137, 62, 0.12) 100%);

  /* 图表 / 画布 / 代码 */
  --chart-grid: #e6eaf0;
  --chart-axis: #647184;
  --chart-1: #b8893e;
  --chart-2: #2f6fed;
  --chart-3: #216e4e;
  --chart-4: #6d5dd3;
  --chart-5: #b42332;
  --code-bg: #f6f8fa;
  --code-text: #303d51;
  --canvas-ui-bg: #f2f4f7;
  --canvas-grid: #e2e8f0;
  --canvas-node: #ffffff;
  --canvas-node-border: #d9dfe8;
  --canvas-wire: #97a2b4;

  /* 骨架屏与滚动条 */
  --skeleton-base: #eef1f5;
  --skeleton-hi: #f7f9fb;
  --scroll-thumb: #c9d1dc;
  --scroll-thumb-hover: #b3bfcd;
}

/* 夜间 · 墨蓝香槟 */
html[data-theme="dark"] {
  color-scheme: dark;

  --color-canvas: #111821;
  --color-shell: #151e29;
  --color-shell-veil: rgba(21, 30, 41, .97);
  --color-surface: #1a2532;
  --color-surface-subtle: #1f2c3b;
  --color-surface-raised: #263547;
  --color-surface-hover: #22303f;
  --color-surface-inset: #18222e;

  --color-text-heading: #dee5ee;
  --color-text-body: #c8d2df;
  --color-text-secondary: #9baabd;
  --color-text-muted: #92a1b4;
  --color-text-on-dark: #f2f5f9;

  --color-border-subtle: #334357;
  --color-border-soft: #2a394b;
  --color-border-strong: #46596f;
  --color-border-control: #71839b;
  --color-border-warm: #3b3329;

  --color-brand-fill: #d1ad6b;
  --color-brand-fill-strong: #b99454;
  --color-brand-fill-soft: #e0c18b;
  --color-brand-on-fill: #17202b;
  --color-brand-text: #e0c18b;
  --color-brand-soft: #332e25;
  --color-brand-soft-text: #e0c18b;
  --color-focus-ring: #e0c18b;
  --color-search-focus-border: var(--color-brand-fill);
  --color-search-focus-halo: color-mix(in srgb, var(--color-brand-fill) 16%, transparent);
  --color-accent-purple: #a99bf0;
  --color-accent-purple-soft: #2a2740;

  --color-success-text: #8dceab;
  --color-success-bg: #203a31;
  --color-warning-text: #e5c17c;
  --color-warning-bg: #3b3020;
  --color-danger-text: #f0a3aa;
  --color-danger-bg: #3e2730;
  --color-info-text: #9abdeb;
  --color-info-bg: #20324a;

  --color-selection-bg: #655138;
  --color-selection-text: #f2e7d2;
  --color-overlay: rgba(3, 7, 13, 0.7);
  --color-scrim: rgba(6, 10, 16, 0.62);
  --color-scrim-strong: rgba(6, 10, 16, 0.82);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 10px 26px rgba(0, 0, 0, 0.45);
  --shadow-raised: 0 18px 44px rgba(0, 0, 0, 0.55);
  --shadow-inset-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --color-shell-accent: linear-gradient(90deg,
    rgba(209, 173, 107, 0.06) 0%,
    rgba(209, 173, 107, 0.3) 25%,
    rgba(224, 193, 139, 0.5) 50%,
    rgba(209, 173, 107, 0.3) 75%,
    rgba(209, 173, 107, 0.06) 100%);

  --chart-grid: #2a394b;
  --chart-axis: #92a1b4;
  --chart-1: #d1ad6b;
  --chart-2: #6fa3ff;
  --chart-3: #7fc7a3;
  --chart-4: #a99bf0;
  --chart-5: #ef9aa0;
  --code-bg: #0f1620;
  --code-text: #c8d2df;
  --canvas-ui-bg: #18222e;
  --canvas-grid: #26333f;
  --canvas-node: #1f2c3b;
  --canvas-node-border: #3a4a5e;
  --canvas-wire: #6c7d92;

  --skeleton-base: #1f2c3b;
  --skeleton-hi: #2a394b;
  --scroll-thumb: #3c4c60;
  --scroll-thumb-hover: #4d5f76;
}

/* 原生控件、选区与滚动条跟随主题 */
html { background: var(--color-canvas); }
body { accent-color: var(--color-brand-fill); }
::selection { background: var(--color-selection-bg); color: var(--color-selection-text); }
/* 输入框里被浏览器自动填充后整段选中时，也跟随品牌色，不用系统默认蓝 */
input::selection,
textarea::selection,
select::selection { background: var(--color-selection-bg); color: var(--color-selection-text); }

html[data-theme] * { scrollbar-color: var(--scroll-thumb) transparent; }
html[data-theme] ::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; }
html[data-theme] ::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
html[data-theme] ::-webkit-scrollbar-track { background: transparent; }

/* 手动切换只过渡必要颜色，不改变尺寸与布局 */
html[data-theme-anim] body,
html[data-theme-anim] .app,
html[data-theme-anim] .app *,
html[data-theme-anim] .app *::before,
html[data-theme-anim] .app *::after {
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme-anim] body,
  html[data-theme-anim] .app,
  html[data-theme-anim] .app *,
  html[data-theme-anim] .app *::before,
  html[data-theme-anim] .app *::after { transition: none; }
}

/* 打印与导出：固定使用既定浅色交付配色，不随界面夜间模式变黑 */
@media print {
  :root,
  html[data-theme] {
    color-scheme: light;
    --color-canvas: #ffffff;
    --color-shell: #ffffff;
    --color-shell-veil: rgba(255, 255, 255, .97);
    --color-surface: #ffffff;
    --color-surface-subtle: #f8f9fb;
    --color-surface-raised: #ffffff;
    --color-surface-hover: #f2f4f7;
    --color-surface-inset: #f6f7f9;
    --color-text-heading: #182238;
    --color-text-body: #303d51;
    --color-text-secondary: #5e6a7c;
    --color-text-muted: #647184;
    --color-border-subtle: #e4e8ee;
    --color-border-soft: #edf0f4;
    --color-border-strong: #d4dbe4;
    --color-border-control: #7d899b;
    --color-border-warm: #eadfcf;
    --color-brand-fill: #b8893e;
    --color-brand-fill-strong: #98702f;
    --color-brand-on-fill: #182238;
    --color-brand-text: #805b23;
    --color-brand-soft: #f8f0e2;
    --color-success-text: #216e4e;
    --color-success-bg: #eaf5ef;
    --color-warning-text: #805b23;
    --color-warning-bg: #fff3d9;
    --color-danger-text: #b42332;
    --color-danger-bg: #fdeef0;
    --color-info-text: #285da8;
    --color-info-bg: #edf3ff;
    --shadow-card: none;
    --shadow-card-hover: none;
    --shadow-raised: none;
  }
}
