/* Crux — liquid-glass triage chat modal.
   All classes are crux-scoped so they never collide with page styles. */
.crux-chat-root{
  --cx-paper:#EBE2D0; --cx-ink:#2A2420; --cx-taupe:#6A5E4C;
  --cx-clay:#7A2230; --cx-clay-deep:#611A26;
  --cx-serif:'Besley',Georgia,'Times New Roman',serif;
  --cx-sans:'IBM Plex Sans',system-ui,-apple-system,sans-serif;
}

/* overlay — dims + blurs the page behind the (opaque) panel.
   When closed it must NOT intercept clicks, or the page becomes dead and the
   trigger can't reopen the chat — hence visibility:hidden + pointer-events:none. */
.crux-overlay{
  position:fixed;inset:0;z-index:9999;
  display:flex;align-items:center;justify-content:center;padding:24px;
  background:rgba(42,36,32,.36);
  -webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);
  opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity .28s ease,visibility 0s linear .28s;
}
.crux-overlay.is-open{opacity:1;visibility:visible;pointer-events:auto;transition:opacity .28s ease,visibility 0s linear 0s}

/* the panel — opaque so text reads crisply; the "glass" now lives in the
   blurred/dimmed page behind it plus the soft rim + shadow. */
.crux-panel{
  position:relative;display:flex;flex-direction:column;overflow:hidden;
  width:100%;max-width:430px;height:min(82vh,620px);
  border-radius:22px;
  background:linear-gradient(180deg,#F3ECDD,#EBE2D0);
  border:1px solid rgba(255,255,255,.6);
  box-shadow:0 1px 0 rgba(255,255,255,.85) inset,0 26px 64px -14px rgba(42,36,32,.5),0 6px 18px rgba(42,36,32,.2);
  transform:translateY(14px) scale(.98);opacity:0;
  transition:transform .3s cubic-bezier(.2,.7,.2,1),opacity .3s ease;
  font-family:var(--cx-sans);color:var(--cx-ink);
}
.crux-overlay.is-open .crux-panel{transform:none;opacity:1}

/* faint constellation behind the glass — brand reinforcement */
.crux-wmark{position:absolute;right:-22%;bottom:-16%;width:380px;height:380px;color:var(--cx-ink);--star:var(--cx-clay);opacity:.05;pointer-events:none;z-index:0}

.crux-panel > :not(.crux-wmark){position:relative;z-index:1}

/* header */
.crux-head{display:flex;align-items:center;gap:11px;padding:16px 16px 14px 18px;border-bottom:1px solid rgba(42,36,32,.10)}
.crux-head .crux-mk{width:30px;height:30px;color:var(--cx-ink);flex:none}
.crux-head .crux-id{flex:1;min-width:0;line-height:1.25}
.crux-head .crux-id b{font-family:var(--cx-serif);font-weight:500;font-size:16px;letter-spacing:.01em;display:block}
.crux-head .crux-id span{font-size:11.5px;color:var(--cx-taupe);letter-spacing:.02em}
.crux-x{flex:none;width:32px;height:32px;border:none;border-radius:9px;background:transparent;color:var(--cx-taupe);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.15s}
.crux-x:hover{background:rgba(42,36,32,.07);color:var(--cx-ink)}
.crux-x svg{width:16px;height:16px}

/* message thread */
.crux-thread{flex:1;overflow-y:auto;padding:20px 18px 8px;display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth}
.crux-thread::-webkit-scrollbar{width:7px}
.crux-thread::-webkit-scrollbar-thumb{background:rgba(42,36,32,.16);border-radius:4px}
.crux-msg{max-width:84%;font-size:14.5px;line-height:1.5;padding:11px 14px;border-radius:16px;white-space:pre-wrap;word-wrap:break-word;animation:crux-rise .26s ease both}
.crux-msg.bot{align-self:flex-start;background:#fff;border:1px solid rgba(42,36,32,.07);color:var(--cx-ink);border-bottom-left-radius:5px;box-shadow:0 1px 3px rgba(42,36,32,.06)}
.crux-msg.me{align-self:flex-end;background:var(--cx-clay);color:#fff;border-bottom-right-radius:5px}
@keyframes crux-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

/* typing indicator */
.crux-typing{align-self:flex-start;display:flex;gap:5px;padding:13px 15px;background:#fff;border:1px solid rgba(42,36,32,.07);border-radius:16px;border-bottom-left-radius:5px}
.crux-typing i{width:7px;height:7px;border-radius:50%;background:var(--cx-taupe);opacity:.5;animation:crux-blink 1.3s infinite both}
.crux-typing i:nth-child(2){animation-delay:.18s}
.crux-typing i:nth-child(3){animation-delay:.36s}
@keyframes crux-blink{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:.9;transform:translateY(-3px)}}

/* composer */
.crux-foot{padding:12px 14px 14px;border-top:1px solid rgba(42,36,32,.10)}
.crux-form{display:flex;align-items:flex-end;gap:9px;background:#fff;border:1px solid rgba(42,36,32,.14);border-radius:16px;padding:7px 7px 7px 14px;transition:border-color .15s,box-shadow .15s}
.crux-form:focus-within{border-color:rgba(122,34,48,.6);box-shadow:0 0 0 3px rgba(122,34,48,.14)}
.crux-input{flex:1;border:none;background:transparent;resize:none;outline:none;font-family:var(--cx-sans);font-size:14.5px;line-height:1.5;color:var(--cx-ink);max-height:120px;padding:6px 0}
.crux-input::placeholder{color:var(--cx-taupe);opacity:.8}
.crux-send{flex:none;width:38px;height:38px;border:none;border-radius:11px;background:var(--cx-clay);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:.16s}
.crux-send:hover{background:var(--cx-clay-deep)}
.crux-send:disabled{opacity:.4;cursor:default}
.crux-send svg{width:16px;height:16px}
.crux-note{margin:10px 2px 0;font-size:11px;color:var(--cx-taupe);text-align:center;letter-spacing:.01em}
.crux-note a{color:var(--cx-taupe)}

/* done / disabled state */
.crux-panel.is-done .crux-form{opacity:.55;pointer-events:none}

/* mobile — compact centered card (not a full-screen sheet) so the dimmed
   site shows around it and it reads as a dismissible chat overlay */
@media(max-width:560px){
  .crux-overlay{padding:18px;align-items:center;justify-content:center}
  .crux-panel{max-width:none;width:100%;height:min(72vh,540px);border-radius:20px}
}
@media(prefers-reduced-motion:reduce){
  .crux-overlay,.crux-panel,.crux-msg{transition:none;animation:none}
}
