/* ==========================================================================
   TerraCelest Design Tokens — Single Source of Truth
   Last Updated: September 13, 2026
   ========================================================================== */

:root {
  /* ─────────────────────────────────────────────────────────────
     COLOR PALETTE
     ───────────────────────────────────────────────────────────── */
  --primary: #00A69C;
  --primary-dark: #007A72;
  --primary-light: #35C1BC;
  --primary-faint: rgba(0, 166, 156, 0.08);

  --navy: #0B1D3A;
  --navy-light: #162E56;

  /* Surfaces */
  --bg: #F5F8FA;
  --surface: #FFFFFF;
  --surface-2: #E8F5F3;
  --surface-hover: #DDEEEB;

  /* Text */
  --text-main: #102A43;
  --text-muted: #627D98;
  --text-sub: #334E68;
  --text-inverse: #FFFFFF;

  /* Status */
  --success: #166534;
  --success-bg: #DCFCE7;
  --error: #BA1A1A;
  --error-bg: #FEE2E2;
  --warning: #92400E;
  --warning-bg: #FEF3C7;
  --info: #0369A1;
  --info-bg: #E0F2FE;

  /* Borders */
  --border: #D9E2EC;
  --border-light: #E8EEF2;
  --border-strong: #9FB3C8;

  /* ─────────────────────────────────────────────────────────────
     TYPOGRAPHY
     ───────────────────────────────────────────────────────────── */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Montserrat", sans-serif;

  --font-size-display: clamp(2.5rem, 8vw, 4rem);
  --font-size-h1: clamp(2rem, 5vw, 3rem);
  --font-size-h2: clamp(1.5rem, 4vw, 2.2rem);
  --font-size-h3: clamp(1.25rem, 2.5vw, 1.5rem);
  --font-size-h4: 1.125rem;
  --font-size-body-lg: 1rem;
  --font-size-body: 0.95rem;
  --font-size-body-sm: 0.875rem;
  --font-size-body-xs: 0.75rem;

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

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* ─────────────────────────────────────────────────────────────
     SPACING SCALE
     ───────────────────────────────────────────────────────────── */
  --spacing-2xs: 2px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-2xl: 32px;
  --spacing-3xl: 48px;
  --spacing-4xl: 64px;

  /* Legacy aliases */
  --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
     ───────────────────────────────────────────────────────────── */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* ─────────────────────────────────────────────────────────────
     SHADOWS
     ───────────────────────────────────────────────────────────── */
  --shadow-xs: 0 1px 3px rgba(11, 29, 58, 0.08);
  --shadow-sm: 0 2px 8px rgba(11, 29, 58, 0.12);
  --shadow-md: 0 4px 16px rgba(11, 29, 58, 0.16);
  --shadow-lg: 0 12px 32px rgba(11, 29, 58, 0.2);
  --shadow-xl: 0 20px 48px rgba(11, 29, 58, 0.25);

  --elevation-0: none;
  --elevation-1: var(--shadow-xs);
  --elevation-2: var(--shadow-sm);
  --elevation-3: var(--shadow-md);
  --elevation-4: var(--shadow-lg);
  --elevation-5: var(--shadow-xl);

  --shadow-nav: 0 -3px 16px rgba(11, 29, 58, 0.04);
  --shadow-sheet: 0 -8px 36px rgba(11, 29, 58, 0.16);

  /* ─────────────────────────────────────────────────────────────
     Z-INDEX STACK
     ───────────────────────────────────────────────────────────── */
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-fixed: 30;
  --z-bottom-nav: 40;
  --z-topbar: 50;
  --z-overlay: 80;
  --z-sheet: 90;
  --z-drawer: 100;
  --z-modal: 110;
  --z-popover: 120;
  --z-tooltip: 130;
  --z-notification: 140;
  --z-splash: 9999;

  /* ─────────────────────────────────────────────────────────────
     MOTION
     ───────────────────────────────────────────────────────────── */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  --transition-slow: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  --transition-reveal: 0.65s cubic-bezier(0.22, 1, 0.36, 1);

  /* ─────────────────────────────────────────────────────────────
     LAYOUT
     ───────────────────────────────────────────────────────────── */
  --topbar-h: 60px;
  --bottom-nav-h: 64px;
  --page-pad-x: 16px;
  --page-pad-y: 20px;
  --content-max: 480px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* ─────────────────────────────────────────────────────────────
     COMPONENT SIZING
     ───────────────────────────────────────────────────────────── */
  --btn-height-sm: 36px;
  --btn-height-md: 44px;
  --btn-height-lg: 48px;
  --input-height: 44px;
  --icon-size-sm: 16px;
  --icon-size-md: 24px;
  --icon-size-lg: 32px;

  /* ─────────────────────────────────────────────────────────────
     LEGACY ALIASES — kept for gradual migration
     ───────────────────────────────────────────────────────────── */
  --text-2: var(--text-sub);
  --text-3: var(--text-muted);
  --border-radius-standard: var(--radius-lg);
  --border-radius-pill: var(--radius-full);
  --border-radius-message: var(--radius-md);
  --transition-normal: var(--transition-base);

  /* ChatUp splash palette aliases (used by /onboarding.html etc.) */
  --tc-light-green: #EAF7F1;
  --tc-green: #00A69C;
  --tc-green-dark: #087F78;
  --tc-navy: #17324D;
  --tc-muted: #617381;
  --tc-white: #FFFFFF;
  --tc-shadow: 0 12px 35px rgba(23,50,77,.08);
  --tc-radius: 22px;
}

html[data-theme="dark"],
body[data-theme="dark"],
body.dark-theme {
  --bg: #0F1419;
  --surface: #161B22;
  --surface-2: #1C232D;
  --surface-hover: #242D3A;

  --text: #E6EDF3;
  --text-main: #E6EDF3;
  --text-2: #B1BAC4;
  --text-3: #8B95A1;
  --text-muted: #8B95A1;
  --text-sub: #B1BAC4;
  --text-inverse: #0F1419;

  --navy: #EDF7F5;
  --navy-light: #2A4045;

  --border: #2A3441;
  --border-light: #1F2731;
  --border-strong: #3D4A5A;

  --success-bg: #143321;
  --error-bg: #351515;
  --warning-bg: #37260C;
  --info-bg: #0E293B;

  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.6);

  --shadow-nav: 0 -3px 16px rgba(0, 0, 0, 0.35);
  --shadow-sheet: 0 -8px 36px rgba(0, 0, 0, 0.65);

  --tc-light-green: #0F1419;
  --tc-white: #161B22;
  --tc-navy: #E6EDF3;
  --tc-muted: #8B95A1;
}

@media (min-width: 640px) {
  :root {
    --page-pad-x: 24px;
    --page-pad-y: 28px;
    --content-max: 640px;
  }
}

@media (min-width: 900px) {
  :root {
    --page-pad-x: 40px;
    --page-pad-y: 36px;
    --content-max: 1040px;
  }
}
