:root {
  --bg: #0A0E14;
  --surface: #0F1A2E;
  --surface-2: #141C2E;
  --surface-3: #1A2438;
  --border: #1C1F26;
  --border-strong: #2A3142;
  --text: #E6E8EB;
  --text-secondary: #8A8F99;
  --text-tertiary: #4A5060;
  --text-inverse: #0A0E14;
  --accent: #0A84FF;
  --accent-pressed: #0060CC;
  --accent-soft: rgba(10, 132, 255, 0.15);
  --on-accent: #FFFFFF;
  --success: #34C759;
  --warning: #FF9F0A;
  --danger: #FF453A;
  --danger-soft: rgba(255, 69, 58, 0.10);
  --danger-soft-strong: rgba(255, 69, 58, 0.18);
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow-color: rgba(0, 0, 0, 0.45);

  --chat-light-bg: #FFFFFF;
  --chat-light-bubble-in: #E9E9EB;
  --chat-light-bubble-in-text: #000000;
  --chat-light-bubble-out: #0B93F6;
  --chat-light-bubble-out-text: #FFFFFF;
  --chat-light-header-bg: #F7F7F7;
  --chat-light-header-border: #D9D9DE;
  --chat-light-timestamp: #8E8E93;
  --chat-light-typing-dot: #8E8E93;
  --chat-light-shadow-typing: 0 1px 2px rgba(0, 0, 0, 0.08);
  --chat-dark-shadow-typing: 0 1px 2px rgba(0, 0, 0, 0.35);
  --chat-dark-bg: #000000;
  --chat-dark-bubble-in: #26262A;
  --chat-dark-bubble-in-text: #FFFFFF;
  --chat-dark-bubble-out: #0B93F6;
  --chat-dark-bubble-out-text: #FFFFFF;
  --chat-dark-header-bg: #1C1C1E;
  --chat-dark-header-border: #2C2C2E;
  --chat-dark-timestamp: #8E8E93;
  --chat-dark-typing-dot: #8E8E93;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, sans-serif;

  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.2;
  --leading-normal: 1.45;
  --leading-relaxed: 1.6;

  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-wide: 0.5px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --radius-bubble: 18px;
  --radius-bubble-sm: 6px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  --dur-fast: 120ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;
  --dur-bubble: 260ms;

  --tabbar-height: 56px;
  --header-height: 52px;

  --tap-target: 44px;
  --border-hairline: 1px;
  --focus-ring: 2px;
  --accent-rail: 3px;
  --banner-icon-size: 20px;
  --tab-button-gap: 3px;
  --grabber-width: 40px;
  --grabber-height: 4px;
  --progress-height: 6px;
  --textarea-min-height: 240px;
  --dialog-max-width: 340px;
  --toast-offset: var(--space-2);
  --header-title-reserve: calc(var(--tap-target) * 3);

  --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);

  --z-header: 10;
  --z-tabbar: 20;
  --z-overlay: 100;
  --z-toast: 200;
  --z-dialog: 300;
}

body[data-theme="light"] {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #F7F7FA;
  --surface-3: #EFEFF4;
  --border: #E1E1E6;
  --border-strong: #C8C8CE;
  --text: #0A0E14;
  --text-secondary: #6B6E76;
  --text-tertiary: #9A9DA6;
  --text-inverse: #FFFFFF;
  --accent: #0A84FF;
  --accent-pressed: #0060CC;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --on-accent: #FFFFFF;
  --success: #248A3D;
  --warning: #B25000;
  --danger: #C4261A;
  --danger-soft: rgba(196, 38, 26, 0.08);
  --danger-soft-strong: rgba(196, 38, 26, 0.14);
  --overlay: rgba(0, 0, 0, 0.35);
  --shadow-color: rgba(0, 0, 0, 0.15);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
  transition: background var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard);
}

button {
  font-family: inherit;
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
    --dur-bubble: 0ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}