/**
 * 烽火台设计系统 — Design Tokens
 *
 * 单一主题：Claude APP 浅暖色
 * 来源：秋白 PlanD + 深度补丁 + Claude APP 截图
 */

/* ============================================================
   唯一主题：Claude APP 暖白（参考 Claude iOS APP）
   ============================================================ */
:root {
  /* --- 强调色（赤陶/terracotta，Claude 品牌色）--- */
  --color-primary: #AE5630;
  --color-primary-text: #C4724C;

  /* --- 背景（暖白/奶油系）--- */
  --bg-primary: #FAF9F7;
  --bg-secondary: #F0EDE8;
  --bg-tertiary: #FFFFFF;
  --bg-hover: #EBE8E3;
  --bg-active: #E0DDD8;

  /* --- 文字（暖棕/暖黑系）--- */
  --text-primary: #1A1A18;
  --text-secondary: #6B6A68;
  --text-tertiary: rgba(26, 26, 24, 0.4);
  --text-muted: #9B9590;
  --text-inverse: #FAF9F7;

  /* --- 边框 --- */
  --border-primary: rgba(100, 95, 85, 0.15);
  --border-secondary: rgba(100, 95, 85, 0.08);

  /* --- 角色色（功能性色彩，不随主题变）--- */
  --color-role-d: #9333ea;
  --color-role-a: #3b82f6;
  --color-role-b: #22c55e;
  --color-role-c: #f97316;
  --color-role-d-dim: #9333ea1a;
  --color-role-a-dim: #3b82f61a;
  --color-role-b-dim: #22c55e1a;
  --color-role-c-dim: #f973161a;

  /* --- 权限模式色 --- */
  --color-mode-yolo: #DC143C;
  --color-mode-accept: #007AFF;
  --color-mode-default: #8E8E93;
  --color-mode-plan: #34C759;

  /* --- 状态色 --- */
  --color-success: #1A7F37;
  --color-warning: #B45309;
  --color-error: #DC2626;
  --color-info: #0E7490;

  /* --- 会话状态 --- */
  --color-status-idle: #1A7F37;
  --color-status-running: #0E7490;
  --color-status-thinking: #9333ea;
  --color-status-error: #DC2626;
  --color-status-stopped: #8B8580;
  --color-status-connecting: #007AFF;
  --color-status-disconnected: #9B9590;

  /* --- 消息气泡（Claude 风格：AI 无背景，用户暖米色）--- */
  --bg-bubble-user: #F0EDE8;
  --bg-bubble-assistant: transparent;
  --bg-bubble-tool: transparent;
  --bg-bubble-error: #FEF2F2;
  --bg-bubble-thinking: #F5F2ED;

  /* --- 代码块（暖灰底）--- */
  --bg-code: #F0EDE8;
  --bg-code-header: #E8E4DE;
  --text-code: #2D2016;

  /* --- 输入区 --- */
  --bg-input: #FFFFFF;
  --border-input: rgba(100, 95, 85, 0.15);
  --border-input-focus: #AE5630;

  /* --- 滚动条 --- */
  --scrollbar-thumb: #D5CFC6;
  --scrollbar-track: transparent;

  /* --- 轻量语法着色（浅色暖调）--- */
  --syntax-keyword: #cf222e;
  --syntax-string: #0a3069;
  --syntax-comment: #8B7355;

  /* --- Spinner（统一赤陶橙，Safari fallback 用 !important 防覆盖）--- */
  --spinner-color: #C17F4A;

  /* --- Rate limit --- */
  --color-rate-limit: #B45309;
  --color-rate-limit-bg: rgba(180, 83, 9, 0.06);
  --color-rate-limit-border: rgba(180, 83, 9, 0.2);
  --color-rate-limit-bar-bg: rgba(180, 83, 9, 0.12);

  /* --- Diff 9色（暖色浅底）--- */
  --diff-add-color: #1A7F37;
  --diff-add-bg: rgba(26, 127, 55, 0.1);
  --diff-del-color: #CF222E;
  --diff-del-bg: rgba(207, 34, 46, 0.1);
  --diff-hunk-color: #0550AE;
  --diff-hunk-bg: rgba(5, 80, 174, 0.06);
  --diff-context: #8B7355;
  --diff-line-no: #9B9590;
  --diff-header-color: #AE5630;

  /* --- 终端输出分色 --- */
  --color-term-stdout: var(--text-primary);
  --color-term-stderr: #B45309;
  --color-term-command: #1A7F37;
  --color-term-exit-error: #DC2626;

  /* --- 导航栏背景（暖白毛玻璃）--- */
  --bg-nav-bar: rgba(250, 249, 247, 0.92);

  /* --- 按压态 --- */
  --bg-pressed: #E5DFD8;
  --bg-pinned: #F0EDE8;
  --bg-pinned-pressed: #E8E4DE;
}

/* ============================================================
   字号（秋白深度补丁排版比例）
   ============================================================ */
:root {
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', 'Menlo', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif;
  --font-serif: 'Georgia', 'Noto Serif SC', 'Source Serif Pro', serif;

  --line-height-tight: 1.3;
  --line-height-normal: 1.65;  /* 从 1.6→1.65，Claude 风格 */
  --line-height-relaxed: 1.8;
}

/* ============================================================
   间距
   ============================================================ */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* --- 阴影（统一三层） --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   按钮 & 交互
   ============================================================ */
:root {
  --button-min-height: 48px;
  --button-min-width: 48px;
  --button-padding: var(--space-3) var(--space-4);
  --tab-height: 56px;
  --nav-height: 49px;
  --topbar-height: 48px;
  --input-min-height: 48px;
  --input-max-height: 160px;
  --toolbar-button-size: 44px;
}

/* ============================================================
   动画
   ============================================================ */
:root {
  --duration-instant: 50ms;
  --duration-fast: 100ms;
  --duration-quick: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
  --duration-emphasis: 450ms;
  --duration-enter: 250ms;
  --duration-exit: 200ms;

  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1.0);
  --ease-in: cubic-bezier(0.42, 0, 1.0, 1.0);
  --ease-out: cubic-bezier(0, 0, 0.58, 1.0);
  --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1.0);
  --ease-spring-settle: cubic-bezier(0.32, 0.72, 0, 1.0);
  --ease-spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring-gentle: cubic-bezier(0.22, 0.61, 0.36, 1.0);
  --ease-wechat-nav: cubic-bezier(0.36, 0.66, 0.04, 1.0);
  --ease-claude: cubic-bezier(0.165, 0.85, 0.45, 1);

  --conv-row-height: 68px;   /* 放大行高，更舒适 */
  --avatar-size: 44px;        /* 放大头像，图标更清晰 */
  --avatar-radius: 50%;       /* 正圆 */
  --ease-bounce: var(--ease-spring-bounce);
}

/* 减弱动画 */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-enter: 0ms;
    --duration-exit: 0ms;
  }
}

/* ============================================================
   Z-index 层级
   ============================================================ */
:root {
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;
}

/* ============================================================
   iOS Safe Area
   ============================================================ */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================================
   全局基础样式
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  touch-action: manipulation;
  height: 100dvh;
}

body {
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }

::selection { background: var(--color-primary); color: white; }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}
