/* Foramind Studio — the help bubble and its panel (web/helpchat.js). Studio tokens from app.css. */
.hb { --hb-gap: 24px; --hb-y: var(--hb-gap); --hb-fab: 56px; }
/* the Sunum tab's fixed action bar on phones (--studio-bar-h on <html>, app.js): the button sits above it */
html[style*="--studio-bar-h"] .hb { --hb-y: calc(var(--hb-gap) + var(--studio-bar-h, 0px)); }
.hb-fab { position: fixed; z-index: 70; right: max(var(--hb-gap), env(safe-area-inset-right)); bottom: calc(var(--hb-y) + env(safe-area-inset-bottom));
  width: var(--hb-fab); height: var(--hb-fab); border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  /* a white button with the glossy chat icon (web/brand/help-chat.webp), like the home page's illustration tiles */
  background: #fff; color: var(--ink); box-shadow: 0 10px 28px rgba(91, 43, 196, .22), 0 2px 6px rgba(20, 22, 58, .12), inset 0 0 0 1px rgba(138, 60, 255, .14); cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .2s, bottom .25s var(--ease), opacity .2s, visibility .2s; }
.hb-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(91, 43, 196, .32), 0 2px 6px rgba(20, 22, 58, .14), inset 0 0 0 1px rgba(138, 60, 255, .22); }
.hb-fab:focus-visible { outline: none; box-shadow: var(--focus), 0 10px 28px rgba(91, 43, 196, .35); }
.hb-i { grid-area: 1 / 1; display: grid; place-items: center; transition: transform .25s var(--ease), opacity .2s; }
.hb-i svg { width: 27px; height: 27px; }
.hb-i img { width: 36px; height: 36px; display: block; filter: drop-shadow(0 2px 3px rgba(91, 43, 196, .18)); }
.hb-i-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.hb.open .hb-i-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.hb.open .hb-i-x { opacity: 1; transform: none; }

/* the panel: above the button on a wide screen */
.hb-panel { position: fixed; z-index: 95; right: max(var(--hb-gap), env(safe-area-inset-right)); bottom: calc(var(--hb-y) + var(--hb-fab) + 14px + env(safe-area-inset-bottom));
  width: min(390px, calc(100vw - 2 * var(--hb-gap))); height: min(620px, calc(100vh - var(--hb-y) - var(--hb-fab) - 110px)); min-height: 340px;
  display: flex; flex-direction: column; background: #fff; border-radius: var(--r-lg); box-shadow: var(--sh-3); border: 1px solid var(--line-3); overflow: hidden;
  transform-origin: bottom right; transform: translateY(12px) scale(.96); opacity: 0; transition: transform .26s var(--ease), opacity .18s; }
.hb.open .hb-panel { transform: none; opacity: 1; }
.hb-panel[hidden] { display: none; }
.hb-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--line-3); flex: none; }
.hb-mark { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--violet-tint); flex: none; }
.hb-mark img { width: 20px; height: 20px; }
.hb-head h2 { flex: 1; min-width: 0; font-size: var(--fs-18); letter-spacing: -.015em; }
.hb-ic { width: 36px; height: 36px; border-radius: 50%; border: 0; background: none; color: var(--ink-3); display: grid; place-items: center; flex: none; }
.hb-ic:hover { background: var(--surface); color: var(--ink); }
.hb-ic:focus-visible { outline: none; box-shadow: var(--focus); }
.hb-ic svg { width: 19px; height: 19px; }
.hb-ic[hidden] { display: none; }
.hb-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.hb-guide { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 12px; border-radius: var(--r-md); background: var(--blue-tint); color: var(--ink); text-decoration: none; transition: filter .15s; flex: none; }
.hb-guide:hover { filter: brightness(.97); }
.hb-guide:focus-visible { outline: none; box-shadow: var(--focus); }
.hb-gi { width: 38px; height: 38px; border-radius: var(--r-12); background: #fff; color: var(--accent-deep); display: grid; place-items: center; flex: none; }
.hb-gi svg { width: 21px; height: 21px; }
.hb-guide > span:nth-child(2) { flex: 1; min-width: 0; }
.hb-guide b { display: block; font-size: var(--fs-14); }
.hb-guide small { display: block; font-size: var(--fs-13); color: var(--ink-3); line-height: 1.35; }
.hb-guide > svg { width: 18px; height: 18px; color: var(--accent-deep); flex: none; }
.hb-log { display: flex; flex-direction: column; gap: 8px; }
.hb-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: var(--fs-14); line-height: 1.5; overflow-wrap: anywhere; }
.hb-msg p { margin: 0; }
.hb-msg p + p { margin-top: 6px; }
.hb-msg.bot { align-self: flex-start; background: var(--surface); color: var(--ink); border-bottom-left-radius: 6px; }
.hb-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.hb-msg.err { background: var(--danger-tint); color: #8c241c; }
.hb-msg .hb-retry { margin: 4px 0 -4px -10px; min-height: 30px; }
.hb-link { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; color: var(--accent-deep); }
.hb-link:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.hb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* a ready answer: the matched question, the Rehber's steps as links, its links as small buttons */
.hb-qt { font-weight: 700; color: var(--accent-deep); }
.hb-steps { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.hb-steps li { padding-left: 2px; }
.hb-steps li::marker { color: var(--accent-deep); font-weight: 700; }
.hb-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px !important; }
.hb-act { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 5px 11px; border-radius: var(--r-pill); background: #fff; color: var(--accent-deep);
  font-size: var(--fs-13); font-weight: 600; text-decoration: none; box-shadow: inset 0 0 0 1px var(--line-3); max-width: 100%; }
.hb-act:hover { box-shadow: inset 0 0 0 1.5px var(--info-line); }
.hb-act:focus-visible { outline: none; box-shadow: var(--focus); }
.hb-act svg { width: 15px; height: 15px; flex: none; }
.hb-tag { display: inline-block; margin-bottom: 4px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--violet-tint); color: var(--accent-deep); font-size: var(--fs-12); font-weight: 700; }
.hb-msg.err.soft { background: var(--surface); color: var(--ink); }
/* "did this help?" */
.hb-fb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 2px; font-size: var(--fs-13); color: var(--ink-3); }
.hb-fb > span { flex-basis: 100%; }
.hb-chip.yes { border-color: var(--accent); }
.hb-glabel { margin: 4px 2px -2px; font-size: var(--fs-12); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.hb-msg.typing { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: var(--fs-13); color: var(--ink-3); }
.hb-dots { display: inline-flex; gap: 5px; }
.hb-msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: hbDot 1.1s infinite ease-in-out; }
.hb-msg.typing i:nth-child(2) { animation-delay: .15s; }
.hb-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hbDot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }
.hb-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 2px; }
.hb-chip { border: 1.5px solid var(--info-line); background: #fff; color: var(--accent-deep); border-radius: var(--r-pill); padding: 7px 12px; font-size: var(--fs-13); font-weight: 600; line-height: 1.25; text-align: left; transition: background .15s;
  max-width: 100%; min-height: 34px; overflow-wrap: anywhere; cursor: pointer; }
.hb-chip:hover { background: var(--blue-tint); }
.hb-chip:focus-visible { outline: none; box-shadow: var(--focus); }
.hb-form { flex: none; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-3); background: #fff; }
.hb-box { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .15s; }
.hb-box:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); background: #fff; }
.hb-box textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; resize: none; padding: 7px 0; font-size: var(--fs-16); line-height: 1.4; max-height: 120px; }
.hb-send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--cta); color: #fff; display: grid; place-items: center; flex: none; }
.hb-send svg { width: 18px; height: 18px; }
.hb-send:disabled { background: var(--line-2); cursor: not-allowed; }
.hb-send:focus-visible { outline: none; box-shadow: var(--focus); }
.hb-form.off .hb-box { opacity: .55; }
.hb-foot { display: flex; justify-content: space-between; gap: 8px; margin: 6px 4px 0; font-size: var(--fs-12); color: var(--muted); line-height: 1.35; }
.hb-foot .off { color: var(--warn-ink); font-weight: 600; }
.hb-left { white-space: nowrap; }
.hb-left.bad { color: var(--danger); font-weight: 700; }

/* where it does not belong: no studio header (sign-in, welcome), or something over the page (a dialog, an overlay,
   the HAD! stage, a presentation over the whole window, a full-screen picture) */
body:not(:has(#app > .topbar, #app > .proj)) .hb,
body:has(.dlg-wrap, .lib-wrap, .live-stage, .pseudo-full, .lightbox, .wiz-ov, .rev-dock.open, .ppv-wrap, .lrm-big-wrap, .fc-bigwrap, .fmt-intro, .fside-scrim.on) .hb { display: none; }
/* a toast says something at the bottom: the button steps aside for it */
body:has(#toast.on) .hb:not(.open) .hb-fab { opacity: 0; visibility: hidden; transform: scale(.8); }
/* the map editor: the button stays clear of the canvas (its zoom bar is in the middle) and the inspector's last
   lines can scroll above it */
body:has(.proj) .inspector { padding-bottom: calc(var(--s-6) + 56px); }

/* phones: over the bottom tab bar; the panel is a full-height sheet that follows the on-screen keyboard */
@media (max-width: 639px) {
  .hb { --hb-gap: 16px; --hb-fab: 52px; }
  body:has(.tabbar) .hb { --hb-y: calc(64px + 12px); }
  .hb-panel { left: 0; right: 0; top: var(--hb-top, 0px); bottom: auto; width: 100%; height: var(--hb-vh, 100dvh); min-height: 0; max-height: none;
    border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); transform-origin: bottom center; transform: translateY(24px); }
  .hb-head { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .hb-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .hb.open .hb-fab { opacity: 0; visibility: hidden; }
  .hb-msg { max-width: 92%; }
  .hb-body { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .hb-form { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .hb-chip, .hb-act { min-height: 40px; }      /* a finger-sized target */
  html.hb-lock, html.hb-lock body { overflow: hidden; overscroll-behavior: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hb-fab, .hb-i, .hb-panel { transition: none; }
  .hb-fab:hover { transform: none; }
  .hb-msg.typing i { animation: none; opacity: .7; }
}
