/* ==========================================================================
   GloxChat design foundation (gx.css) — loaded FIRST by every page.
   Source of truth: design-system/gloxchat/MASTER.md (UI/UX Pro Max:
   "Chat & Messaging App" → Minimalism & Swiss Style + micro-interactions,
   messenger blue + online green, Plus Jakarta Sans).

   Decisions recorded here:
   • Primary actions use brand blue (#2563EB, white text 5.2:1). Green is the
     "online / success" signal, never decoration (colour is never the only cue).
   • Light and dark are designed together. Dark follows the system unless the
     page sets <html data-theme="light|dark">.
   • One font family, self-hosted (CSP font-src 'self'; no third-party font
     requests, which also matters for visitors' privacy). Scripts the font
     does not cover (Arabic, CJK, Devanagari, Thai …) fall back to the
     system's Noto/UI fonts, so every language renders.
   • Radius follows hierarchy (controls 10, cards 14, sheets 20, pills full);
     elevation is one scale; motion is one set of tokens; z-index is a scale.
   • Motion respects prefers-reduced-motion everywhere.
   ========================================================================== */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/plus-jakarta-sans-vietnamese-wght-normal.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/plus-jakarta-sans-cyrillic-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

:root {
  /* ── Type ── */
  --gx-font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", "Noto Sans Thai", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Apple SD Gothic Neo", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --gx-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gx-text-xs: .75rem;    /* 12 — captions, never body */
  --gx-text-sm: .875rem;   /* 14 — dense UI */
  --gx-text-md: 1rem;      /* 16 — body */
  --gx-text-lg: 1.125rem;  /* 18 */
  --gx-text-xl: 1.25rem;   /* 20 */
  --gx-text-2xl: 1.5rem;   /* 24 */
  --gx-text-3xl: 1.875rem; /* 30 */
  --gx-text-4xl: clamp(2rem, 1.4rem + 2.4vw, 2.75rem);
  --gx-text-display: clamp(2.4rem, 1.5rem + 4vw, 4.25rem);
  --gx-leading: 1.6; --gx-leading-tight: 1.15;

  /* ── Colour: brand + semantic (light) ── */
  --gx-blue-50: #eff5ff; --gx-blue-100: #dbe7fe; --gx-blue-200: #bfd4fe; --gx-blue-500: #3b82f6;
  --gx-blue-600: #2563eb; --gx-blue-700: #1d4ed8; --gx-blue-800: #1e40af; --gx-blue-950: #0b1a3f;
  --gx-indigo-500: #6366f1; --gx-teal-500: #14b8a6; --gx-green-600: #059669; --gx-green-500: #10b981;

  --gx-primary: var(--gx-blue-600);        --gx-on-primary: #ffffff;
  --gx-primary-hover: var(--gx-blue-700);  --gx-primary-soft: var(--gx-blue-50); --gx-primary-text: var(--gx-blue-700);
  --gx-online: var(--gx-green-600);        --gx-online-soft: #e7f8f1;
  --gx-success: #047857; --gx-success-soft: #ecfdf5;
  --gx-warning: #b45309; --gx-warning-soft: #fffbeb; --gx-warning-line: #fde68a;
  --gx-danger: #dc2626;  --gx-danger-text: #b91c1c; --gx-danger-soft: #fef2f2;
  --gx-ai: #6d28d9;      --gx-ai-soft: #f5f3ff;

  --gx-bg: #ffffff;          /* page */
  --gx-bg-subtle: #f6f8fc;   /* app canvas, alternating bands */
  --gx-surface: #ffffff;     /* cards, sheets */
  --gx-surface-2: #f1f5fd;   /* muted fills, inputs at rest */
  --gx-surface-3: #e8eef9;   /* pressed, selected */
  --gx-border: #e2e8f4;      --gx-border-strong: #c9d4e6;
  --gx-fg: #0f172a;          /* 17.9:1 on white */
  --gx-fg-2: #334155;        /* 10.4:1 */
  --gx-muted: #475569;       /* 7.6:1 — secondary text */
  --gx-subtle: #64748b;      /* 4.8:1 — meta text only, ≥14px */
  --gx-bubble-in: #f1f5fd;   --gx-bubble-in-fg: #0f172a;   /* visitor */
  --gx-bubble-out: #2563eb;  --gx-bubble-out-fg: #ffffff;  /* agent */
  --gx-grad: linear-gradient(110deg, #1d4ed8 0%, #2563eb 40%, #0ea5e9 75%, #14b8a6 100%);

  /* ── Shape, depth, space ── */
  --gx-r-xs: 6px; --gx-r-sm: 10px; --gx-r-md: 14px; --gx-r-lg: 20px; --gx-r-full: 999px;
  --gx-shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --gx-shadow-md: 0 1px 2px rgb(15 23 42 / .04), 0 6px 16px -6px rgb(15 23 42 / .12);
  --gx-shadow-lg: 0 2px 6px rgb(15 23 42 / .05), 0 18px 40px -14px rgb(15 23 42 / .22);
  --gx-shadow-xl: 0 30px 70px -24px rgb(15 23 42 / .35);
  --gx-ring: 0 0 0 3px rgb(37 99 235 / .35);
  --gx-space-1: 4px; --gx-space-2: 8px; --gx-space-3: 12px; --gx-space-4: 16px; --gx-space-5: 24px;
  --gx-space-6: 32px; --gx-space-7: 48px; --gx-space-8: 64px; --gx-space-9: 96px;
  --gx-container: 1200px; --gx-measure: 68ch;
  --gx-z-base: 0; --gx-z-raised: 10; --gx-z-sticky: 20; --gx-z-overlay: 40; --gx-z-modal: 100; --gx-z-toast: 1000;

  /* ── Motion: one set of tokens. Exits ≈ 65% of enters. ── */
  --gx-ease-out: cubic-bezier(.16, 1, .3, 1);      /* arrivals: decelerate */
  --gx-ease-in: cubic-bezier(.4, 0, 1, 1);         /* exits: accelerate */
  --gx-ease-spring: cubic-bezier(.34, 1.4, .64, 1); /* small confirmations only */
  --gx-dur-1: 120ms;  /* press, hover colour */
  --gx-dur-2: 200ms;  /* toggles, menus */
  --gx-dur-3: 320ms;  /* sheets, modals, list entries */
  --gx-dur-4: 560ms;  /* the one page-load moment */
  --gx-stagger: 40ms;

  color-scheme: light;
}

/* ── Dark: designed with light, not inverted. ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gx-primary: #2563eb; --gx-primary-hover: #1d4ed8; --gx-on-primary: #ffffff; /* white text 5.2:1 and 6.7:1 */
    --gx-primary-soft: rgb(59 130 246 / .14); --gx-primary-text: #93c5fd;
    --gx-online: #34d399; --gx-online-soft: rgb(16 185 129 / .16);
    --gx-success: #34d399; --gx-success-soft: rgb(16 185 129 / .14);
    --gx-warning: #fbbf24; --gx-warning-soft: rgb(245 158 11 / .14); --gx-warning-line: rgb(245 158 11 / .35);
    --gx-danger: #f87171; --gx-danger-text: #fca5a5; --gx-danger-soft: rgb(239 68 68 / .14);
    --gx-ai: #c4b5fd; --gx-ai-soft: rgb(139 92 246 / .16);
    --gx-bg: #070c18; --gx-bg-subtle: #0a1120; --gx-surface: #0e1628; --gx-surface-2: #131d33; --gx-surface-3: #1a2642;
    --gx-border: #1e2a44; --gx-border-strong: #2c3c5e;
    --gx-fg: #e9eef8; --gx-fg-2: #cbd5e6; --gx-muted: #a3b1c9; --gx-subtle: #8494b2;
    --gx-bubble-in: #16213a; --gx-bubble-in-fg: #e9eef8; --gx-bubble-out: #2563eb; --gx-bubble-out-fg: #ffffff;
    --gx-shadow-md: 0 1px 2px rgb(0 0 0 / .3), 0 8px 20px -8px rgb(0 0 0 / .5);
    --gx-shadow-lg: 0 2px 8px rgb(0 0 0 / .35), 0 22px 48px -16px rgb(0 0 0 / .6);
    --gx-shadow-xl: 0 30px 80px -24px rgb(0 0 0 / .75);
    --gx-ring: 0 0 0 3px rgb(96 165 250 / .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --gx-primary: #2563eb; --gx-primary-hover: #1d4ed8; --gx-on-primary: #ffffff; /* white text 5.2:1 and 6.7:1 */
  --gx-primary-soft: rgb(59 130 246 / .14); --gx-primary-text: #93c5fd;
  --gx-online: #34d399; --gx-online-soft: rgb(16 185 129 / .16);
  --gx-success: #34d399; --gx-success-soft: rgb(16 185 129 / .14);
  --gx-warning: #fbbf24; --gx-warning-soft: rgb(245 158 11 / .14); --gx-warning-line: rgb(245 158 11 / .35);
  --gx-danger: #f87171; --gx-danger-text: #fca5a5; --gx-danger-soft: rgb(239 68 68 / .14);
  --gx-ai: #c4b5fd; --gx-ai-soft: rgb(139 92 246 / .16);
  --gx-bg: #070c18; --gx-bg-subtle: #0a1120; --gx-surface: #0e1628; --gx-surface-2: #131d33; --gx-surface-3: #1a2642;
  --gx-border: #1e2a44; --gx-border-strong: #2c3c5e;
  --gx-fg: #e9eef8; --gx-fg-2: #cbd5e6; --gx-muted: #a3b1c9; --gx-subtle: #8494b2;
  --gx-bubble-in: #16213a; --gx-bubble-in-fg: #e9eef8; --gx-bubble-out: #2563eb; --gx-bubble-out-fg: #ffffff;
  --gx-shadow-md: 0 1px 2px rgb(0 0 0 / .3), 0 8px 20px -8px rgb(0 0 0 / .5);
  --gx-shadow-lg: 0 2px 8px rgb(0 0 0 / .35), 0 22px 48px -16px rgb(0 0 0 / .6);
  --gx-shadow-xl: 0 30px 80px -24px rgb(0 0 0 / .75);
  --gx-ring: 0 0 0 3px rgb(96 165 250 / .45);
  color-scheme: dark;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 88px; }
body {
  margin: 0; font-family: var(--gx-font); font-size: var(--gx-text-md); line-height: var(--gx-leading);
  color: var(--gx-fg); background: var(--gx-bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
img, svg, video, canvas { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: var(--gx-leading-tight); letter-spacing: -.02em; text-wrap: balance; margin: 0 0 .5em; }
p { text-wrap: pretty; }
a { color: var(--gx-primary-text); text-underline-offset: .18em; }
:where(code, kbd, pre) { font-family: var(--gx-mono); font-size: .92em; }
.tabular, :where(td, .price, .num) { font-variant-numeric: tabular-nums; }
:where(.break-anywhere, code) { overflow-wrap: anywhere; }

/* Focus: always visible for keyboard users, never for mouse clicks. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus { outline: none; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--gx-primary); outline-offset: 2px; box-shadow: var(--gx-ring); border-radius: var(--gx-r-xs);
}
:where(button, [role="button"], a, label[for], summary, select) { cursor: pointer; touch-action: manipulation; }
:where(button:disabled, [aria-disabled="true"]) { cursor: not-allowed; }

.gx-skip {
  position: absolute; left: 12px; top: -60px; z-index: var(--gx-z-toast);
  padding: 10px 16px; border-radius: var(--gx-r-sm); background: var(--gx-primary); color: var(--gx-on-primary);
  font-weight: 700; text-decoration: none; transition: top var(--gx-dur-2) var(--gx-ease-out);
}
.gx-skip:focus { top: 12px; }
.sr-only, .gx-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Reusable primitives (opt-in, prefixed so they never collide) ── */
.gx-container { width: min(100% - 32px, var(--gx-container)); margin-inline: auto; }
.gx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--gx-r-sm); border: 1px solid transparent;
  font-weight: 650; font-size: var(--gx-text-md); text-decoration: none; white-space: nowrap;
  transition: background-color var(--gx-dur-1) var(--gx-ease-out), border-color var(--gx-dur-1), color var(--gx-dur-1),
              box-shadow var(--gx-dur-2) var(--gx-ease-out), transform var(--gx-dur-1) var(--gx-ease-out);
}
.gx-btn:active:not(:disabled) { transform: scale(.97); }
.gx-btn-primary { background: var(--gx-primary); color: var(--gx-on-primary); box-shadow: 0 1px 0 rgb(255 255 255 / .15) inset, var(--gx-shadow-sm); }
.gx-btn-primary:hover { background: var(--gx-primary-hover); box-shadow: var(--gx-shadow-md); }
.gx-btn-secondary { background: var(--gx-surface); color: var(--gx-fg); border-color: var(--gx-border-strong); }
.gx-btn-secondary:hover { border-color: var(--gx-primary); color: var(--gx-primary-text); }
.gx-btn-ghost { background: transparent; color: var(--gx-fg-2); }
.gx-btn-ghost:hover { background: var(--gx-surface-2); color: var(--gx-fg); }
.gx-btn-danger { background: var(--gx-danger); color: #fff; }
.gx-btn-lg { min-height: 52px; padding: 0 26px; font-size: var(--gx-text-lg); border-radius: var(--gx-r-md); }
.gx-btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.gx-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--gx-on-primary) transparent var(--gx-on-primary) transparent;
  animation: gx-spin .7s linear infinite;
}
.gx-card { background: var(--gx-surface); border: 1px solid var(--gx-border); border-radius: var(--gx-r-md); box-shadow: var(--gx-shadow-sm); }
.gx-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--gx-r-full); font-size: var(--gx-text-sm); font-weight: 600; background: var(--gx-primary-soft); color: var(--gx-primary-text); }
.gx-dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--gx-online); box-shadow: 0 0 0 3px var(--gx-online-soft); }

/* ── Motion primitives ──
   [data-gx-reveal] is set by gx.js only when motion is allowed and the element
   is below the fold, so content is never hidden without JavaScript. */
@keyframes gx-spin { to { transform: rotate(360deg); } }
@keyframes gx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes gx-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes gx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gx-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(16 185 129 / .45); } 70% { box-shadow: 0 0 0 8px rgb(16 185 129 / 0); } }
@keyframes gx-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }
.gx-reveal-wait { opacity: 0; transform: translateY(14px); }
.gx-reveal-in { animation: gx-rise var(--gx-dur-4) var(--gx-ease-out) both; animation-delay: var(--gx-delay, 0ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .gx-reveal-wait { opacity: 1; transform: none; }
}
