/* ==========================================================================
 * Bots design tokens + foundation（DESIGN-SPEC B1，深色主题）
 * 颜色只用 token；布局尺寸在 style.css。
 * ========================================================================== */

:root {
  color-scheme: dark;

  /* Core color tokens (DESIGN-SPEC B1) */
  --bg: #0B0B0D;
  --surface: #121318;
  --surface-2: #181A21;
  --surface-3: #1F222B;
  --border: #23252F;
  --border-strong: #2E3140;
  --text: #F5F6FA;
  --text-muted: #9AA1B2;
  --text-faint: #6B7280;
  --accent: #4F6BFF;
  --accent-hover: #6B82FF;
  --accent-soft: rgba(79, 107, 255, 0.14);
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --focus: rgba(79, 107, 255, 0.45);

  /* Semantic additions (G: allowed supplements) */
  --overlay: rgba(0, 0, 0, 0.55);
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger-soft: rgba(248, 113, 113, 0.12);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.55);

  /* Radius scale */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-pill: 999px;

  /* Spacing scale (8pt grid with 4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Typography, touch targets and component sizing */
  --text-caption: 12px;
  --text-small: 13px;
  --text-body: 14px;
  --text-control: 15px;
  --text-title: 16px;
  --text-heading: 18px;
  --text-display: 22px;
  --text-avatar: 46px;
  --r-xxs: 2px;
  --r-xs: 4px;
  --r-circle: 50%;
  --r-bubble: 22px;
  --r-input: 28px;
  --r-square: 0px;
  --on-accent: #FFFFFF;
  --text-zero: 0px;
  --touch-target: 40px;

  --duration-hover: 120ms;
  --duration-panel: 180ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Typography */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas,
    "Liberation Mono", monospace;

  /* Layout aliases (batch 2: topbar 52 / content 810) */
  --sidebar-width: 264px;
  --topbar-height: 52px;
  --content-max: 810px;

  /* Legacy aliases used by the existing stylesheet. */
  --bg-elevated: var(--surface);
  --bg-hover: var(--surface-2);
  --bg-active: var(--surface-3);
  --bg-user-bubble: var(--accent-soft);
  --bg-code: var(--surface-2);
  --text-dim: var(--text-muted);
  --green: var(--success);
  --red: var(--danger);
  --grey: var(--text-faint);
  --radius: var(--r-lg);
}

/* --------------------------------------------------------------------------
 * Base reset / typography
 * -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 表单控件继承正文字体：否则 <button>/<input> 会落回浏览器默认 13.3333px，
 * 与 B2 字阶（12/13/14/16/18/22）不一致。 */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--accent-hover);
}

a:hover {
  color: var(--accent);
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* --------------------------------------------------------------------------
 * Scrollbar
 * -------------------------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
  border: 3px solid transparent;
}

/* --------------------------------------------------------------------------
 * Focus visibility
 * -------------------------------------------------------------------------- */

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 鼠标/初始程序化聚焦不画环；键盘用户仍靠 focus-visible。 */
:focus:not(:focus-visible) {
  outline: none;
}

/* composer 是文本输入，浏览器会把输入框聚焦始终视为 focus-visible；
 * 初始程序化聚焦不画 accent 边，首次用户交互后由 is-user-active 打开。 */
.composer-input:focus-visible {
  outline: none;
}

.composer:focus-within {
  border-color: var(--border-strong);
}

html.is-user-active .composer:focus-within {
  border-color: var(--accent);
}
