/* KX SigmaX Assistant v3 — "Aurora Precision" reskin (research-driven, 2026-07).
   Design language: clean SOLID card (no heavy glass — depth from layered shadows,
   hairlines and a restrained orange aurora wash), greeting-forward empty state,
   composer with inset circular send, near-bubble-less assistant messages.
   Dark default, light via html.sx-light. Launcher sits ABOVE #sx-theme-toggle
   (fixed right:22px bottom:22px, 52px). No backdrop-filter anywhere. */
#kx-agent{
  --kxa-surface:#141419;
  --kxa-surface-2:#1b1b22;
  --kxa-surface-3:#22222b;
  --kxa-field:#1b1b23;
  --kxa-text:#eceaf2;
  --kxa-muted:#9d9cae;
  --kxa-hairline:rgba(255,255,255,0.08);
  --kxa-hairline-2:rgba(255,255,255,0.14);
  --kxa-accent:#e01118;
  --kxa-accent-2:#ff4d4d;
  --kxa-accent-grad:linear-gradient(135deg,#ff4d4d 0%,#e01118 60%,#b80d13 100%);
  --kxa-orb:radial-gradient(circle at 30% 28%,#ff7a7a 0%,#e01118 55%,#9c0a0f 100%);
  --kxa-accent-soft:rgba(224,17,24,0.13);
  --kxa-aurora:radial-gradient(130% 90% at 88% -12%,rgba(224,17,24,0.20),rgba(224,17,24,0.05) 45%,transparent 68%);
  --kxa-user-bubble:rgba(224,17,24,0.15);
  --kxa-bot-surface:rgba(255,255,255,0.045);
  --kxa-shadow:0 24px 70px rgba(0,0,0,0.55),0 4px 16px rgba(0,0,0,0.35);
  --kxa-shadow-sm:0 8px 24px rgba(0,0,0,0.40);
  --kxa-ok:#3ecf72;
  --kxa-off:#8b8b96;
  font-family:Geist,Helvetica,Arial,sans-serif;
}
html.sx-light #kx-agent{
  --kxa-surface:#fdfdfe;
  --kxa-surface-2:#f6f6f8;
  --kxa-surface-3:#eeeef2;
  --kxa-field:#f6f6f8;
  --kxa-text:#191922;
  --kxa-muted:#6d6c7c;
  --kxa-hairline:rgba(20,20,35,0.08);
  --kxa-hairline-2:rgba(20,20,35,0.14);
  --kxa-accent-soft:rgba(224,17,24,0.09);
  --kxa-aurora:radial-gradient(130% 90% at 88% -12%,rgba(224,17,24,0.13),rgba(224,17,24,0.03) 45%,transparent 68%);
  --kxa-user-bubble:rgba(224,17,24,0.10);
  --kxa-bot-surface:rgba(20,20,35,0.035);
  --kxa-shadow:0 24px 70px rgba(20,20,35,0.16),0 4px 16px rgba(20,20,35,0.07);
  --kxa-shadow-sm:0 8px 24px rgba(20,20,35,0.10);
}
#kx-agent,#kx-agent *,#kxa-teaser,#kxa-teaser *{box-sizing:border-box;margin:0;padding:0;}

/* ── Launcher: clean gradient circle ───────────────────────── */
#kxa-launcher{
  position:fixed;right:22px;bottom:90px;z-index:99998;
  width:58px;height:58px;border-radius:999px;border:none;cursor:pointer;
  display:flex;align-items:center;justify-content:center;color:#fff;
  background:var(--kxa-accent-grad);
  box-shadow:0 10px 28px rgba(224,17,24,0.38),0 3px 10px rgba(0,0,0,0.25);
  transition:transform .2s ease,box-shadow .2s ease,opacity .18s ease;
  -webkit-tap-highlight-color:transparent;
}
#kxa-launcher:hover{transform:translateY(-2px);box-shadow:0 14px 34px rgba(224,17,24,0.46),0 4px 12px rgba(0,0,0,0.28);}
#kxa-launcher:active{transform:none;}
#kxa-launcher svg{width:26px;height:26px;display:block;}
#kxa-launcher.kxa-pulse{animation:kxa-pulse 2.2s ease-out 3;}
@keyframes kxa-pulse{
  0%{box-shadow:0 10px 28px rgba(224,17,24,0.38),0 0 0 0 rgba(224,17,24,0.45);}
  70%{box-shadow:0 10px 28px rgba(224,17,24,0.38),0 0 0 14px rgba(224,17,24,0);}
  100%{box-shadow:0 10px 28px rgba(224,17,24,0.38),0 0 0 0 rgba(224,17,24,0);}
}
#kx-agent.kxa-open #kxa-launcher{opacity:0;pointer-events:none;transform:scale(0.85);}

/* ── First-visit teaser next to the launcher ───────────────── */
#kxa-teaser{
  position:fixed;right:90px;bottom:99px;z-index:99997;
  display:flex;align-items:center;gap:4px;
  background:var(--kxa-surface);color:var(--kxa-text);
  border:1px solid var(--kxa-hairline-2);border-radius:999px;
  box-shadow:var(--kxa-shadow-sm);padding:4px 6px 4px 4px;
  font-family:Geist,Helvetica,Arial,sans-serif;
  animation:kxa-rise .24s ease-out both;
}
#kxa-teaser[hidden]{display:none;}
#kxa-teaser button{font-family:inherit;background:none;border:none;cursor:pointer;color:inherit;-webkit-tap-highlight-color:transparent;}
#kxa-teaser-open{font-size:13px;font-weight:550;padding:8px 6px 8px 12px;white-space:nowrap;}
#kxa-teaser-x{
  width:26px;height:26px;border-radius:999px;display:flex;align-items:center;justify-content:center;
  color:var(--kxa-muted);flex:0 0 auto;
}
#kxa-teaser-x:hover{background:var(--kxa-surface-3);color:var(--kxa-text);}
#kxa-teaser-x svg{width:12px;height:12px;display:block;}

/* ── Panel: solid card + aurora wash ───────────────────────── */
#kxa-panel{
  position:fixed;right:22px;bottom:88px;z-index:100000;
  width:392px;max-width:calc(100vw - 32px);
  height:min(645px,calc(100vh - 120px));
  display:none;flex-direction:column;overflow:hidden;
  color:var(--kxa-text);background:var(--kxa-surface);
  border:1px solid var(--kxa-hairline-2);border-radius:20px;
  box-shadow:var(--kxa-shadow);
  isolation:isolate;
}
#kxa-panel::before{
  content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;
  background:var(--kxa-aurora);
}
#kx-agent.kxa-open #kxa-panel{display:flex;animation:kxa-in .22s ease-out;}
@keyframes kxa-in{from{opacity:0;transform:translateY(12px);}to{opacity:1;transform:none;}}
@keyframes kxa-rise{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:none;}}

/* header */
#kx-agent .kxa-head{
  display:flex;align-items:center;gap:11px;padding:15px 16px 13px;
  border-bottom:1px solid var(--kxa-hairline);flex:0 0 auto;background:transparent;
}
#kx-agent .kxa-ava{
  width:36px;height:36px;border-radius:999px;flex:0 0 auto;
  display:flex;align-items:center;justify-content:center;color:#fff;
  background:var(--kxa-orb);
  box-shadow:0 3px 10px rgba(224,17,24,0.30);
}
#kx-agent .kxa-ava svg{width:18px;height:18px;display:block;}
#kx-agent .kxa-head .kxa-ava{position:relative;}
#kx-agent .kxa-head .kxa-ava::after{
  content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:999px;
  background:var(--kxa-ok);border:2px solid var(--kxa-surface);
}
#kx-agent.kxa-offline .kxa-head .kxa-ava::after{background:var(--kxa-off);}
#kx-agent .kxa-title{font-size:15px;font-weight:650;letter-spacing:0.01em;flex:1 1 auto;line-height:1.2;}
#kx-agent .kxa-sub{display:block;font-size:11.5px;font-weight:400;color:var(--kxa-muted);margin-top:2px;}
#kx-agent .kxa-hbtn{
  background:transparent;border:1px solid transparent;color:var(--kxa-muted);cursor:pointer;border-radius:10px;
  font-family:inherit;font-size:12px;min-height:38px;padding:6px 10px;display:flex;align-items:center;gap:5px;
  transition:color .15s ease,background .15s ease;flex:0 0 auto;
  -webkit-tap-highlight-color:transparent;
}
#kx-agent .kxa-hbtn:hover{color:var(--kxa-text);background:var(--kxa-surface-3);}
#kx-agent .kxa-hbtn svg{width:15px;height:15px;display:block;}

/* ── Messages ──────────────────────────────────────────────── */
#kx-agent .kxa-body{
  flex:1 1 auto;overflow-y:auto;padding:18px 16px 12px;position:relative;
  display:flex;flex-direction:column;gap:14px;scrollbar-width:thin;
  overscroll-behavior:contain;
}
#kx-agent .kxa-row{display:flex;gap:9px;align-items:flex-end;animation:kxa-rise .2s ease-out both;}
#kx-agent .kxa-row-user{justify-content:flex-end;}
#kx-agent .kxa-row .kxa-ava{width:26px;height:26px;margin-bottom:18px;box-shadow:none;}
#kx-agent .kxa-row .kxa-ava svg{width:13px;height:13px;}
#kx-agent .kxa-rcol{display:flex;flex-direction:column;gap:4px;max-width:85%;min-width:0;}
#kx-agent .kxa-row-user .kxa-rcol{align-items:flex-end;}
#kx-agent .kxa-msg{
  padding:10px 14px;font-size:13.5px;line-height:1.6;overflow-wrap:break-word;
}
#kx-agent .kxa-msg-user{
  background:var(--kxa-user-bubble);color:var(--kxa-text);
  border-radius:16px 16px 5px 16px;white-space:pre-wrap;
}
#kx-agent .kxa-msg-bot{
  background:var(--kxa-bot-surface);
  border-radius:5px 16px 16px 16px;
}
#kx-agent .kxa-msg-err{background:var(--kxa-accent-soft);border:1px solid rgba(224,17,24,0.30);}
#kx-agent .kxa-time{font-size:10.5px;color:var(--kxa-muted);opacity:0.75;padding:0 4px;user-select:none;}
#kx-agent .kxa-msg p{margin:0 0 7px;}
#kx-agent .kxa-msg p:last-child{margin-bottom:0;}
#kx-agent .kxa-msg ul{margin:2px 0 7px;padding-left:18px;}
#kx-agent .kxa-msg ul:last-child{margin-bottom:0;}
#kx-agent .kxa-msg li{margin:3px 0;}
#kx-agent .kxa-msg a{color:var(--kxa-accent);text-decoration:underline;text-underline-offset:2px;}
#kx-agent .kxa-msg strong{font-weight:600;}
#kx-agent .kxa-msg code{font-family:ui-monospace,Menlo,monospace;font-size:12px;background:var(--kxa-surface-3);border:1px solid var(--kxa-hairline);border-radius:5px;padding:1px 5px;}
#kx-agent .kxa-cursor{display:inline-block;width:7px;height:14px;margin-left:2px;vertical-align:-2px;background:var(--kxa-accent);border-radius:2px;animation:kxa-blink .85s steps(1) infinite;}
@keyframes kxa-blink{50%{opacity:0;}}

/* typing dots */
#kx-agent .kxa-dots{display:inline-flex;gap:4px;align-items:center;height:14px;}
#kx-agent .kxa-dots i{width:6px;height:6px;border-radius:999px;background:var(--kxa-muted);animation:kxa-dot 1.1s ease-in-out infinite;}
#kx-agent .kxa-dots i:nth-child(2){animation-delay:.15s;}
#kx-agent .kxa-dots i:nth-child(3){animation-delay:.3s;}
@keyframes kxa-dot{0%,60%,100%{transform:translateY(0);opacity:.45;}30%{transform:translateY(-4px);opacity:1;}}

/* ── Greeting-forward empty state ──────────────────────────── */
#kx-agent .kxa-hello{
  display:flex;flex-direction:column;align-items:center;text-align:center;
  padding:26px 14px 6px;gap:10px;animation:kxa-rise .24s ease-out both;
}
#kx-agent .kxa-hello-ava{width:54px;height:54px;box-shadow:0 8px 24px rgba(224,17,24,0.35);}
#kx-agent .kxa-hello-ava svg{width:26px;height:26px;}
#kx-agent .kxa-hello-hi{font-size:20px;font-weight:700;letter-spacing:-0.01em;margin-top:2px;}
#kx-agent .kxa-hello-tx{font-size:13px;color:var(--kxa-muted);line-height:1.6;max-width:300px;}

/* ── Quick replies ─────────────────────────────────────────── */
#kx-agent .kxa-chips{display:flex;flex-wrap:wrap;gap:8px;padding:0 2px 2px 37px;animation:kxa-rise .2s ease-out both;}
#kx-agent .kxa-chip{
  font-family:inherit;font-size:12.5px;font-weight:500;color:var(--kxa-text);cursor:pointer;
  background:transparent;border:1px solid var(--kxa-hairline-2);border-radius:999px;
  min-height:44px;padding:10px 16px;text-align:left;
  transition:border-color .15s ease,background .15s ease;
  -webkit-tap-highlight-color:transparent;
}
#kx-agent .kxa-chip:hover{border-color:var(--kxa-accent);background:var(--kxa-accent-soft);}
/* intro variant: stacked full-width action rows with arrow */
#kx-agent .kxa-chips-intro{flex-direction:column;flex-wrap:nowrap;gap:9px;padding:6px 10px 4px;align-self:stretch;}
#kx-agent .kxa-chips-intro .kxa-chip{
  display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;
  background:var(--kxa-surface-2);border:1px solid var(--kxa-hairline);border-radius:14px;
  font-size:13.5px;font-weight:550;padding:13px 15px;min-height:48px;
  transition:border-color .15s ease,background .15s ease,transform .15s ease;
}
#kx-agent .kxa-chips-intro .kxa-chip svg{width:15px;height:15px;flex:0 0 auto;color:var(--kxa-accent);}
#kx-agent .kxa-chips-intro .kxa-chip:hover{border-color:rgba(224,17,24,0.45);background:var(--kxa-surface-3);transform:translateY(-1px);}

/* ── Action cards ──────────────────────────────────────────── */
#kx-agent .kxa-card{
  display:flex;align-items:center;gap:12px;width:100%;min-height:60px;
  font-family:inherit;text-align:left;cursor:pointer;color:var(--kxa-text);
  background:var(--kxa-surface-2);
  border:1px solid var(--kxa-hairline-2);border-radius:16px;padding:12px 14px;
  box-shadow:var(--kxa-shadow-sm);
  transition:border-color .18s ease,transform .18s ease;
  -webkit-tap-highlight-color:transparent;animation:kxa-rise .22s ease-out both;
}
#kx-agent .kxa-card:hover{border-color:rgba(224,17,24,0.55);transform:translateY(-1px);}
#kx-agent .kxa-card:active{transform:none;}
#kx-agent .kxa-card-ic{
  width:36px;height:36px;border-radius:11px;flex:0 0 auto;color:#fff;
  display:flex;align-items:center;justify-content:center;
  background:var(--kxa-accent-grad);
  box-shadow:0 3px 10px rgba(224,17,24,0.30);
}
#kx-agent .kxa-card-ic svg{width:17px;height:17px;display:block;}
#kx-agent .kxa-card-tx{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px;}
#kx-agent .kxa-card-label{font-size:13.5px;font-weight:600;line-height:1.3;}
#kx-agent .kxa-card-sub{font-size:11px;color:var(--kxa-muted);line-height:1.4;}
#kx-agent .kxa-card-cta{
  flex:0 0 auto;font-size:12px;font-weight:650;color:#fff;border-radius:999px;padding:9px 14px;
  background:var(--kxa-accent-grad);box-shadow:0 3px 10px rgba(224,17,24,0.28);white-space:nowrap;
}

/* ── Jump-to-latest pill ───────────────────────────────────── */
#kxa-jump{
  position:absolute;left:50%;bottom:96px;transform:translateX(-50%);z-index:5;
  display:none;align-items:center;gap:6px;cursor:pointer;
  font-family:inherit;font-size:12px;font-weight:600;color:var(--kxa-text);
  background:var(--kxa-surface-2);
  border:1px solid var(--kxa-hairline-2);border-radius:999px;min-height:34px;padding:7px 13px;
  box-shadow:var(--kxa-shadow-sm);
  -webkit-tap-highlight-color:transparent;
}
#kxa-jump.kxa-show{display:flex;animation:kxa-rise .18s ease-out both;}
#kxa-jump svg{width:13px;height:13px;display:block;color:var(--kxa-accent);}

/* ── Composer ──────────────────────────────────────────────── */
#kx-agent .kxa-foot{flex:0 0 auto;padding:10px 14px calc(11px + env(safe-area-inset-bottom,0px));background:transparent;}
#kx-agent .kxa-inrow{position:relative;display:block;}
#kxa-input{
  display:block;width:100%;resize:none;font-family:inherit;font-size:13.5px;line-height:1.5;
  color:var(--kxa-text);background:var(--kxa-field);border:1px solid var(--kxa-hairline-2);
  border-radius:16px;padding:13px 54px 13px 15px;min-height:48px;max-height:120px;outline:none;
  transition:border-color .15s ease,box-shadow .15s ease;
}
#kxa-input::placeholder{color:var(--kxa-muted);}
#kxa-input:focus{border-color:rgba(224,17,24,0.65);box-shadow:0 0 0 3px var(--kxa-accent-soft);}
#kxa-input:disabled{opacity:0.55;}
#kxa-send{
  position:absolute;right:7px;bottom:7px;
  width:34px;height:34px;border-radius:999px;border:none;cursor:pointer;
  background:var(--kxa-accent-grad);color:#fff;display:flex;align-items:center;justify-content:center;
  box-shadow:0 3px 10px rgba(224,17,24,0.32);
  transition:opacity .15s ease,transform .15s ease;
  -webkit-tap-highlight-color:transparent;
}
#kxa-send:hover{transform:translateY(-1px);}
#kxa-send:disabled{opacity:0.4;cursor:default;transform:none;}
#kxa-send svg{width:16px;height:16px;display:block;}
#kx-agent .kxa-note{font-size:10.5px;color:var(--kxa-muted);text-align:center;margin-top:8px;}

/* ── Prefill glow + toast (rendered on the form pages) ─────── */
.kxa-prefilled{
  border-color:rgba(224,17,24,0.85) !important;
  box-shadow:0 0 0 2px rgba(224,17,24,0.30) !important; /* persists until the visitor edits the field */
  animation:kxa-glow 1.6s ease-out 3;
}
@keyframes kxa-glow{
  0%{box-shadow:0 0 0 0 rgba(224,17,24,0.55);}
  55%{box-shadow:0 0 0 7px rgba(224,17,24,0.14),0 0 20px 3px rgba(224,17,24,0.40);}
  100%{box-shadow:0 0 0 2px rgba(224,17,24,0.30);}
}
form.wpcf7-form{scroll-margin-top:170px;}
#kxa-toast{
  position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:100001;
  display:flex;align-items:center;gap:11px;max-width:min(92vw,480px);
  font-family:Geist,Helvetica,Arial,sans-serif;font-size:13.5px;font-weight:500;line-height:1.5;
  color:#f4f2f8;padding:13px 14px 13px 18px;border-radius:16px;
  background:#1d1d26;
  border:1px solid rgba(255,255,255,0.10);border-left:3px solid #e01118;
  box-shadow:0 16px 44px rgba(0,0,0,0.45);
  animation:kxa-toast-in .26s ease-out both;
}
@keyframes kxa-toast-in{from{opacity:0;transform:translate(-50%,10px);}to{opacity:1;transform:translate(-50%,0);}}
#kxa-toast button{
  flex:0 0 auto;background:rgba(255,255,255,0.10);border:none;
  color:#fff;cursor:pointer;border-radius:999px;width:28px;height:28px;font-size:15px;line-height:1;
  display:flex;align-items:center;justify-content:center;font-family:inherit;
}
#kxa-toast button:hover{background:rgba(255,255,255,0.18);}

/* ── Motion preferences ────────────────────────────────────── */
@media (prefers-reduced-motion:reduce){
  #kx-agent.kxa-open #kxa-panel,#kxa-launcher.kxa-pulse,#kx-agent .kxa-row,#kx-agent .kxa-chips,
  #kx-agent .kxa-card,#kx-agent .kxa-hello,#kxa-jump.kxa-show,#kxa-toast,#kxa-teaser,.kxa-prefilled{animation:none;}
  #kxa-launcher,#kx-agent .kxa-card,#kx-agent .kxa-chip,#kxa-send{transition:none;}
}

/* ── Mobile: full sheet ────────────────────────────────────── */
@media (max-width:560px){
  #kxa-launcher{right:16px;bottom:78px;width:54px;height:54px;}
  #kxa-teaser{right:82px;bottom:86px;}
  #kxa-panel{
    right:0;bottom:0;left:0;top:0;width:100%;max-width:none;height:100%;
    border-radius:0;border:none;
  }
  #kx-agent .kxa-rcol{max-width:88%;}
}
