/* Harman Singh Mind Assistant. Every selector is scoped under #hsa-root so theme and Elementor styles can't leak in. */

#hsa-root {
  --g: #2B4541;
  --gd: #1F3633;
  --gl: #35564F;
  --sage: #A8AB8F;
  --sage-l: #E6EADD;
  --cream: #FAF9F0;
  --ink: #1F1F1F;
  --muted: #6B6B6B;
  --line: rgba(31, 54, 51, .10);
  --hsa-vh: 100dvh;
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 99990;
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
#hsa-root *, #hsa-root *::before, #hsa-root *::after { box-sizing: border-box; }
#hsa-root [hidden] { display: none !important; }
#hsa-root button, #hsa-root textarea, #hsa-root a { font-family: inherit; letter-spacing: normal; text-transform: none; }
#hsa-root button {
  -webkit-appearance: none; appearance: none; margin: 0; padding: 0; border: 0; background: none;
  color: inherit; cursor: pointer; box-shadow: none; text-shadow: none; line-height: 1; border-radius: 0;
}
#hsa-root svg { display: block; width: 20px; height: 20px; flex: none; }
#hsa-root :focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

/* ---------- launcher ---------- */
#hsa-root .hsa-launch {
  position: relative; display: block; width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(150deg, var(--gl), var(--gd)); color: var(--cream);
  box-shadow: 0 14px 30px -8px rgba(15, 30, 28, .55), 0 0 0 1px rgba(255, 255, 255, .08) inset;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  animation: hsa-pulse 3.6s ease-out 2s 3;
}
#hsa-root .hsa-launch:hover { transform: translateY(-2px) scale(1.04); }
#hsa-root .hsa-launch:active { transform: scale(.96); }
#hsa-root .hsa-launch svg { width: 26px; height: 26px; }
#hsa-root .hsa-l-chat, #hsa-root .hsa-l-close {
  position: absolute; inset: 0; display: grid; place-items: center;
  transition: opacity .2s, transform .3s cubic-bezier(.2, .8, .2, 1);
}
#hsa-root .hsa-l-close { opacity: 0; transform: rotate(-60deg) scale(.6); }
#hsa-root.is-open .hsa-l-chat { opacity: 0; transform: rotate(60deg) scale(.6); }
#hsa-root.is-open .hsa-l-close { opacity: 1; transform: none; }
#hsa-root .hsa-badge {
  position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--sage); border: 3px solid var(--gd);
}
#hsa-root.is-open .hsa-badge { display: none; }
@keyframes hsa-pulse {
  0% { box-shadow: 0 14px 30px -8px rgba(15, 30, 28, .55), 0 0 0 0 rgba(168, 171, 143, .55); }
  70%, 100% { box-shadow: 0 14px 30px -8px rgba(15, 30, 28, .55), 0 0 0 18px rgba(168, 171, 143, 0); }
}

/* ---------- teaser ---------- */
#hsa-root .hsa-teaser {
  position: absolute; right: 0; bottom: 78px; width: max-content; max-width: min(280px, calc(100vw - 48px));
  padding: 12px 40px 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 18px 18px 6px 18px;
  box-shadow: 0 18px 40px -16px rgba(15, 30, 28, .4); font-size: 14px; line-height: 1.4; cursor: pointer;
  animation: hsa-rise .5s cubic-bezier(.2, .8, .2, 1);
}
#hsa-root .hsa-teaser-x {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--muted);
}
#hsa-root .hsa-teaser-x svg { width: 14px; height: 14px; }
#hsa-root .hsa-teaser-x:hover { background: var(--sage-l); }
@keyframes hsa-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- panel ---------- */
#hsa-root .hsa-panel {
  position: absolute; right: 0; bottom: 78px; width: 400px; height: min(660px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cream); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: 0 40px 90px -24px rgba(15, 30, 28, .5), 0 10px 28px -10px rgba(15, 30, 28, .22);
  transform-origin: bottom right; opacity: 0; visibility: hidden; transform: translateY(14px) scale(.96);
  transition: opacity .25s ease, transform .35s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .35s;
}
#hsa-root.is-open .hsa-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

/* header: textured green sheet */
#hsa-root .hsa-head {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 20px 18px 30px;
  color: #fff;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 16px),
    linear-gradient(160deg, var(--gl), var(--gd));
}
#hsa-root .hsa-avatar {
  position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sage); color: var(--gd); font-weight: 700; font-size: 16px; letter-spacing: .02em;
}
#hsa-root .hsa-dot {
  position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: #7fd18b; border: 2.5px solid var(--gd);
}
#hsa-root .hsa-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#hsa-root .hsa-who strong { font-size: 17px; font-weight: 600; line-height: 1.15; }
#hsa-root .hsa-who span { font-size: 12.5px; color: rgba(255, 255, 255, .72); }
#hsa-root .hsa-x {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .1); color: #fff; transition: background .2s;
}
#hsa-root .hsa-x:hover { background: rgba(255, 255, 255, .2); }

/* body sits over the header like a sheet */
#hsa-root .hsa-body {
  position: relative; flex: 1; min-height: 0; margin-top: -16px; background: var(--cream);
  border-radius: 22px 22px 0 0; display: flex;
}
#hsa-root .hsa-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px 16px 8px;
  display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: var(--sage) transparent;
}

/* messages */
#hsa-root .hsa-msg { display: flex; animation: hsa-rise .35s cubic-bezier(.2, .8, .2, 1); }
#hsa-root .hsa-user { justify-content: flex-end; }
#hsa-root .hsa-col { max-width: 86%; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#hsa-root .hsa-user .hsa-col { align-items: flex-end; }
#hsa-root .hsa-bubble {
  padding: 12px 15px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere;
}
#hsa-root .hsa-bot .hsa-bubble {
  background: #fff; border: 1px solid var(--line); border-radius: 18px 18px 18px 6px;
  box-shadow: 0 1px 2px rgba(31, 54, 51, .05);
}
#hsa-root .hsa-user .hsa-bubble { background: var(--g); color: #fff; border-radius: 18px 18px 6px 18px; }
#hsa-root .hsa-bubble p { margin: 0; }
#hsa-root .hsa-bubble p + p, #hsa-root .hsa-bubble ul + p, #hsa-root .hsa-bubble p + ul { margin-top: 8px; }
#hsa-root .hsa-bubble ul { margin: 0; padding-left: 18px; list-style: disc; }
#hsa-root .hsa-bubble li { margin: 2px 0; padding: 0; }
#hsa-root .hsa-bubble strong { font-weight: 600; }
#hsa-root .hsa-bubble a { color: var(--g); text-decoration: underline; text-underline-offset: 2px; }
#hsa-root .hsa-user .hsa-bubble a { color: #fff; }

/* typing */
#hsa-root .hsa-typing { display: flex; gap: 5px; padding: 15px 16px; }
#hsa-root .hsa-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); animation: hsa-bounce 1.2s infinite ease-in-out; }
#hsa-root .hsa-typing i:nth-child(2) { animation-delay: .15s; }
#hsa-root .hsa-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hsa-bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* quick replies: same dotted pill as the site's section tags */
#hsa-root .hsa-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; animation: hsa-rise .5s .15s both cubic-bezier(.2, .8, .2, 1); }
#hsa-root .hsa-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: #fff; border: 1px solid rgba(31, 54, 51, .14); font-size: 13.5px; font-weight: 500; color: var(--ink);
  transition: background .2s, transform .2s, border-color .2s;
}
#hsa-root .hsa-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); flex: none; }
#hsa-root .hsa-pill:hover { background: var(--sage-l); border-color: var(--sage); transform: translateY(-1px); }

/* sources */
#hsa-root .hsa-src { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); padding: 0 4px; }
#hsa-root .hsa-src a {
  display: inline-flex; align-items: center; gap: 4px; color: var(--g); font-weight: 500; text-decoration: none;
  border-bottom: 1px solid rgba(43, 69, 65, .3);
}
#hsa-root .hsa-src a:hover { border-color: var(--g); }
#hsa-root .hsa-src svg { width: 12px; height: 12px; }

/* handoff card: buttons echo the site's "arrow chip" buttons */
#hsa-root .hsa-card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #fff;
  border: 1px solid var(--line); border-radius: 18px;
}
#hsa-root .hsa-card-t { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; }
#hsa-root .hsa-btn {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 7px 6px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 600; text-decoration: none; transition: transform .2s, background .2s, box-shadow .2s;
}
#hsa-root .hsa-btn span { flex: 1; }
#hsa-root .hsa-btn-main { background: var(--g); color: #fff; }
#hsa-root .hsa-btn-main:hover { background: var(--gd); transform: translateY(-1px); box-shadow: 0 10px 20px -10px rgba(15, 30, 28, .6); }
#hsa-root .hsa-chip { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--sage); color: var(--gd); }
#hsa-root .hsa-chip svg { width: 16px; height: 16px; }
#hsa-root .hsa-btn-ghost { padding-right: 14px; background: transparent; border: 1px solid rgba(31, 54, 51, .18); color: var(--g); }
#hsa-root .hsa-btn-ghost:hover { background: var(--sage-l); }
#hsa-root .hsa-btn-ghost svg { width: 16px; height: 16px; }

/* composer */
#hsa-root .hsa-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--cream); }
#hsa-root .hsa-comp {
  display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 14px; background: #fff;
  border: 1px solid rgba(31, 54, 51, .14); border-radius: 18px; transition: border-color .2s, box-shadow .2s;
}
#hsa-root .hsa-comp:focus-within { border-color: var(--sage); box-shadow: 0 0 0 4px rgba(168, 171, 143, .22); }
#hsa-root .hsa-comp textarea {
  flex: 1; min-width: 0; max-height: 112px; resize: none; border: 0; outline: 0; background: transparent; box-shadow: none;
  padding: 8px 0; margin: 0; font-size: 16px; line-height: 1.4; color: var(--ink); height: auto;
}
#hsa-root .hsa-comp textarea::placeholder { color: #8d8d85; }
#hsa-root .hsa-send {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--g); color: #fff; transition: opacity .2s, transform .2s, background .2s;
}
#hsa-root .hsa-send:hover:not(:disabled) { background: var(--gd); transform: translateY(-1px); }
#hsa-root .hsa-send:disabled { background: var(--sage); color: var(--gd); opacity: .55; cursor: default; }
#hsa-root .hsa-note { margin: 8px 0 0; text-align: center; font-size: 11.5px; line-height: 1.3; color: var(--muted); }

/* ---------- mobile: full-screen sheet ---------- */
@media (max-width: 640px) {
  #hsa-root { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  #hsa-root .hsa-launch { width: 58px; height: 58px; }
  #hsa-root .hsa-teaser { bottom: 72px; }
  #hsa-root .hsa-panel {
    position: fixed; top: var(--hsa-top, 0px); left: 0; right: 0; bottom: auto; width: 100%; height: var(--hsa-vh, 100dvh);
    border: 0; border-radius: 0; transform: translateY(24px); transform-origin: bottom center;
  }
  #hsa-root .hsa-head { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  #hsa-root .hsa-col { max-width: 90%; }
  #hsa-root.is-open .hsa-launch { opacity: 0; pointer-events: none; transform: scale(.6); }
  /* keyboard open: compact header and hide the footnote so the conversation keeps room */
  #hsa-root.hsa-kb .hsa-head { padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 22px; gap: 10px; }
  #hsa-root.hsa-kb .hsa-avatar { width: 34px; height: 34px; font-size: 13px; }
  #hsa-root.hsa-kb .hsa-who span, #hsa-root.hsa-kb .hsa-note { display: none; }
  #hsa-root.hsa-kb .hsa-x { width: 32px; height: 32px; }
  #hsa-root.hsa-kb .hsa-foot { padding-bottom: 10px; }
}
html.hsa-lock, html.hsa-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
  #hsa-root *, #hsa-root *::before, #hsa-root *::after { animation: none !important; transition-duration: .01ms !important; }
}
