/* =====================================================================
   theme.css — 设计令牌（Design Tokens）
   语义色体系：所有颜色经 CSS 变量映射，深浅色仅切换变量值，
   组件不写死颜色 → 跨模块一致性 & 易于分布式扩展。
   ===================================================================== */

:root {
  /* 品牌与强调 */
  --brand: #4b69c6;
  --brand-strong: #3a53a0;
  --accent: #c62828;

  /* 语义色（浅色主题，默认） */
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --success: #2e7d32;
  --warning: #ed6c02;
  --error: #d32f2f;
  --info: #0288d1;

  /* 排版 */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono",
    monospace;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2.25rem;

  /* 间距 / 圆角 / 阴影 */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* 布局 */
  --container: 1120px;
  --header-h: 64px;
}

/* 手动深色：html[data-theme="dark"] */
html[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1d2025;
  --surface-2: #262a31;
  --text: #e7e9ee;
  --text-muted: #9aa2af;
  --border: #333842;
  --brand: #6f8cf0;
  --brand-strong: #8aa2ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* 跟随系统（data-theme="auto" 时） */
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #14161a;
    --surface: #1d2025;
    --surface-2: #262a31;
    --text: #e7e9ee;
    --text-muted: #9aa2af;
    --border: #333842;
    --brand: #6f8cf0;
    --brand-strong: #8aa2ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

/* 基础重置与全局 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0 0 var(--space-3);
  font-weight: 700;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-3); }

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: var(--brand-strong); }

img, svg, video { max-width: 100%; height: auto; display: block; }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow: auto;
}

.muted { color: var(--text-muted); }

/* 无障碍：焦点可见 */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 尊重减少动效偏好（兼容性/可用性） */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
