/* Click Digital Health · the help chat on every marketing page and in the onboarding portal.
 * Uses the tokens in styles.css. Desktop: a launcher pill and a panel in the bottom-right corner.
 * Under 640px: a round launcher and a full-screen sheet. */

.ch { position: fixed; right: 24px; bottom: 24px; z-index: 65; font-family: var(--font-sans); }
.menu-open .ch { display: none; }
/* Room under the footer so the launcher never covers its last row. */
.has-ch .foot { padding-bottom: 96px; }
.ch-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ch-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- launcher */
.ch-launch {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 18px 0 14px; border-radius: 999px;
  border: 1px solid var(--night-3); background: var(--night); color: var(--on-night); cursor: pointer;
  font: 600 14.5px var(--font-sans); letter-spacing: -0.01em; box-shadow: var(--shadow-2), 0 0 0 4px oklch(15.5% 0.032 266 / 0.06);
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s, background-color 0.2s;
}
.ch-launch:hover { background: var(--night-2); box-shadow: var(--shadow-2), 0 0 0 4px oklch(61% 0.2 258 / 0.16); }
.ch-launch:active { transform: translateY(1px); }
.ch-launch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ch-launch__mark { position: relative; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: oklch(61% 0.2 258 / 0.22); color: var(--accent-2); }
.ch-launch__mark .ch-ico { width: 15px; height: 15px; }
.ch-launch__mark::after { content: ""; position: absolute; right: -2px; top: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 2px var(--night); }
.ch.is-open .ch-launch__mark::after { display: none; }

/* ---------- panel */
.ch-panel {
  position: absolute; right: 0; bottom: 60px; display: flex; flex-direction: column;
  width: 400px; height: min(600px, calc(100vh - 120px)); height: min(600px, calc(100dvh - 120px));
  border-radius: 16px; overflow: hidden; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-3);
  transform-origin: 100% 100%; animation: ch-in 0.22s var(--ease-out);
}
@keyframes ch-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.ch-head {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 16px; color: var(--on-night);
  background:
    radial-gradient(360px 120px at 0% 0%, oklch(61% 0.2 258 / 0.3), transparent 70%),
    linear-gradient(var(--night-line) 1px, transparent 1px) 0 -1px / 24px 24px,
    linear-gradient(90deg, var(--night-line) 1px, transparent 1px) -1px 0 / 24px 24px,
    var(--night);
}
.ch-head__t { flex: 1; min-width: 0; }
.ch-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--white); }
.ch-title:focus { outline: none; }
.ch-sub { display: flex; align-items: center; gap: 7px; margin: 3px 0 0; font: 500 11px/1.3 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-night-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px oklch(74% 0.17 152 / 0.2); }
.ch-btn { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: none; color: var(--on-night-2); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.ch-btn:hover { background: oklch(100% 0 0 / 0.08); color: var(--white); }
.ch-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.ch-btn .ch-ico { width: 17px; height: 17px; }

/* ---------- conversation */
.ch-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--paper-2); }
.ch-msg { max-width: 92%; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.ch-msg--me { align-self: flex-end; padding: 9px 13px; border-radius: 12px 12px 4px 12px; background: var(--night-2); color: var(--on-night); white-space: pre-wrap; }
.ch-msg--bot { align-self: flex-start; padding: 11px 14px; border-radius: 12px 12px 12px 4px; background: var(--white); border: 1px solid var(--line); color: var(--ink); }
.ch-msg--bot p { margin: 0; }
.ch-msg--bot p + p, .ch-msg--bot p + ul, .ch-msg--bot ul + p, .ch-msg--bot p + ol, .ch-msg--bot ol + p { margin-top: 8px; }
.ch-msg--bot ul, .ch-msg--bot ol { margin: 0; padding-left: 20px; }
.ch-msg--bot li + li { margin-top: 3px; }
.ch-msg--bot b { font-weight: 600; }
.ch-msg--bot a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ch-msg--intro { color: var(--ink-2); }
.ch-msg--err { align-self: stretch; max-width: none; padding: 10px 12px; border-radius: 10px; background: color-mix(in oklab, var(--danger) 8%, var(--white)); border: 1px solid color-mix(in oklab, var(--danger) 30%, var(--white)); color: oklch(42% 0.15 25); font-size: 13.5px; }
.ch-msg--err a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.ch-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.ch-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: ch-dot 1.2s infinite; }
.ch-dots i:nth-child(2) { animation-delay: 0.15s; }
.ch-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ch-dot { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip { padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--white); font: 500 13px/1.3 var(--font-sans); color: var(--ink-2); text-align: left; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.ch-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.ch-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- composer */
.ch-form { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--white); }
.ch-row { display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--white); transition: border-color 0.15s, box-shadow 0.15s; }
.ch-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px oklch(61% 0.2 258 / 0.18); }
.ch-input { flex: 1; min-width: 0; max-height: 120px; padding: 6px 0; border: 0; background: none; resize: none; font: 15px/1.45 var(--font-sans); color: var(--ink); outline: none; }
.ch-input::placeholder { color: var(--ink-3); }
.ch-send { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; transition: background-color 0.15s, opacity 0.15s; }
.ch-send:hover { background: color-mix(in oklab, var(--ink) 86%, var(--accent)); }
.ch-send:disabled { opacity: 0.35; cursor: default; }
.ch-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-send .ch-ico { width: 16px; height: 16px; }
.ch-warn { margin: 8px 2px 0; font-size: 13px; color: oklch(48% 0.17 25); }
.ch-note { margin: 8px 2px 0; font-size: 11.5px; line-height: 1.4; color: var(--ink-3); }

/* Narrow screens: a round launcher and a full-screen sheet. Pages get room at the bottom so the
 * launcher never covers the last thing on the page. */
@media (max-width: 639px) {
  .ch { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .ch-launch { width: 52px; height: 52px; padding: 0; justify-content: center; }
  .ch-launch > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ch-launch__mark { width: 30px; height: 30px; background: none; }
  .ch-launch__mark .ch-ico { width: 21px; height: 21px; }
  .ch-launch__mark::after { right: -1px; top: -1px; }
  .ch.is-open { z-index: 80; }
  .ch.is-open .ch-launch { display: none; }
  .ch-panel { position: fixed; inset: 0 0 auto; width: auto; height: 100vh; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; animation-name: ch-up; }
  @keyframes ch-up { from { opacity: 0; transform: translateY(24px); } }
  .ch-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .ch-form { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .ch-input { font-size: 16px; }
  html.ch-lock, html.ch-lock body { overflow: hidden; }
}
