/* =====================================================================
 * Atomocode UI 设计令牌（v1.1）
 * ---------------------------------------------------------------------
 * 三层：Primitive（原始值）→ Semantic（语义）→ 兼容层（旧变量名别名）。
 * 纪律：
 *   ① 新组件只消费 Semantic/兼容层，禁止散点色值；
 *   ② 旧组件仍用 --bg/--card/--accent 等名字，由本文件别名到语义层——
 *      渐进迁移，不要求一次性重写 chat.css；
 *   ③ 禁止渐变、辉光、玻璃拟态；阴影只用于浮层；
 *   ④ 所有可读文字对比度 ≥ 4.5:1（原 --text-3:#8a929c 仅 2.75~3.15:1，已废）。
 * ===================================================================== */

:root {
  color-scheme: light;

  /* ---------- Primitive：中性色阶 ---------- */
  --gray-0: #ffffff;
  --gray-25: #f7f8f9;
  --gray-50: #f2f4f5;
  --gray-100: #eceef0;
  --gray-200: #e2e5e8;
  --gray-300: #cbd1d7;
  --gray-500: #6b747e;
  --gray-600: #5b646e;
  --gray-700: #3c434b;
  --gray-800: #262b31;
  --gray-900: #1b1f24;

  /* ---------- Primitive：品牌与状态 ---------- */
  --blue-600: #315f8c;
  --blue-700: #294f74;
  --blue-800: #223f5d;
  --blue-200: #d7e3ee;
  --teal-600: #0d6f63;
  --teal-700: #0b5b51;
  --green-600: #2f7d55;
  --amber-700: #8a5c1a;
  --red-600: #b3453f;

  /* ---------- Semantic：文字 ---------- */
  --text-1: var(--gray-900);      /* 正文 */
  --text-2: var(--gray-600);      /* 次要说明 */
  --text-3: #646d77;              /* 时间等弱信息；在 #fff/#f7f8f9/#f2f4f5 上均 ≥4.6:1 */
  --text-on-action: #ffffff;

  /* ---------- Semantic：表面与边框 ---------- */
  --surface-page: var(--gray-25);
  --surface-1: var(--gray-0);
  --surface-2: var(--gray-50);
  --surface-3: var(--gray-100);
  --border-1: var(--gray-200);
  --border-strong: var(--gray-300);

  /* ---------- Semantic：动作与状态 ---------- */
  --action: var(--blue-600);
  --action-hover: var(--blue-700);
  --action-active: var(--blue-800);
  --action-soft: #eaf0f5;
  --action-2: var(--teal-600);
  --action-2-soft: #e6f1ef;
  --success: var(--green-600);
  --warning: var(--amber-700);
  --danger: var(--red-600);
  --focus-ring: var(--blue-600);

  /* ---------- 排版 ---------- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-17: 17px;
  --fs-20: 20px;
  --lh-body: 1.7;
  --lh-tight: 1.35;

  /* ---------- 间距 / 圆角 / 阴影 ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgb(20 28 36 / 4%);
  --shadow-2: 0 2px 8px rgb(20 28 36 / 7%);
  --shadow-pop: 0 10px 28px rgb(20 28 36 / 12%);

  /* ---------- 动效 ---------- */
  --ease-out: cubic-bezier(.2, .7, .3, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;

  /* =====================================================================
   * 兼容层：既有组件消费的旧变量名 → 语义层
   * （chat.css / console.html 存量样式不改名即可获得新色板）
   * ===================================================================== */
  --bg: var(--surface-page);
  --bg2: var(--surface-2);
  --card: var(--surface-1);
  --line: var(--border-1);
  --fg: var(--text-1);
  --muted: var(--text-2);
  --accent: var(--action);
  --accent2: var(--action-2);
  --ok: var(--success);
  --warn: var(--warning);
  --err: var(--danger);
}

/* ---------- 深色主题：只覆盖语义层，兼容层自动跟随 ---------- */
html[data-theme="dark"] {
  color-scheme: dark;

  --text-1: #e8eaed;
  --text-2: #a7aeb7;
  --text-3: #9198a1;              /* 深底上 ≥4.5:1 */

  --surface-page: #131518;
  --surface-1: #1b1e22;
  --surface-2: #22262b;
  --surface-3: #2a2f35;
  --border-1: #30353b;
  --border-strong: #3d444c;

  --action: #7ba7d3;
  --action-hover: #93b8dd;
  --action-active: #a9c7e6;
  --action-soft: #22303d;
  --action-2: #56b7a8;
  --action-2-soft: #1e2f2c;
  --success: #5cb98a;
  --warning: #d9a45c;
  --danger: #e0817b;
  --focus-ring: #7ba7d3;
  --text-on-action: #10161c;

  --shadow-1: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-2: 0 2px 8px rgb(0 0 0 / 36%);
  --shadow-pop: 0 12px 32px rgb(0 0 0 / 48%);
}

/* ---------- 基础：字体与焦点 ---------- */
html {
  font-family: var(--font-sans);
}
body {
  font: var(--fs-14) / var(--lh-body) var(--font-sans);
}

/* 焦点必须可见且不被容器裁切；禁止裸 outline:0 */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 线性图标：跟随文字色，垂直居中 */
.ui-icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.16em;
  stroke: currentColor;
  fill: none;
}

/* 尊重系统减弱动效 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 高对比度模式：边框不可依赖浅色 */
@media (forced-colors: active) {
  .cu-bubble,
  .cu-inputrow,
  .cu-chip {
    border-color: CanvasText;
  }
}
