/*
 * Help chat (help.js). One source: zchart/site/public/help/help.css; the Pips Pulse site keeps a copy.
 * Colours come from each site's own tokens (ZChart: styles.css paper/ink; Pips Pulse: site.css canvas/card),
 * picked by [data-site]; the fallbacks only matter on a page without them.
 */
.zh {
  --zh-bg: #ffffff;
  --zh-fg: #0e1116;
  --zh-muted: #686d75;
  --zh-line: rgba(14, 17, 22, 0.1);
  --zh-soft: #f4f2ee;
  --zh-btn: #0e1116;
  --zh-btn-fg: #ffffff;
  --zh-you: #0e1116;
  --zh-you-fg: #ffffff;
  --zh-accent: #3d7eff;
  --zh-shadow: 0 1px 2px rgba(14, 17, 22, 0.12), 0 18px 48px -12px rgba(14, 17, 22, 0.35);
  --zh-ease: cubic-bezier(0.23, 1, 0.32, 1);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--zh-fg);
}
.zh[data-site='zchart'] {
  --zh-fg: var(--paper-ink, #0e1116);
  --zh-muted: var(--paper-muted, #686d75);
  --zh-line: var(--paper-line, rgba(14, 17, 22, 0.1));
  --zh-soft: var(--paper, #f4f2ee);
  --zh-btn: var(--paper-ink, #0e1116);
  --zh-you: var(--paper-ink, #0e1116);
  --zh-accent: var(--accent, #3d7eff);
  font-family: var(--font, inherit);
}
.zh[data-site='pipspulse'] {
  --zh-bg: #ffffff;
  --zh-fg: #111417;
  --zh-muted: #5d6e78;
  --zh-line: #d4e1e8;
  --zh-soft: #e4eef3;
  --zh-btn: var(--card, #0e1012);
  --zh-btn-fg: var(--card-ink, #f2f6f8);
  --zh-you: var(--card, #0e1012);
  --zh-you-fg: var(--card-ink, #f2f6f8);
  --zh-accent: #4d6f8f;
  --zh-shadow: var(--shadow-float, 0 1px 2px rgb(60 90 110 / 0.18), 0 18px 40px -12px rgb(60 90 110 / 0.35));
  font-family: var(--font, inherit);
}
@media (prefers-color-scheme: dark) {
  .zh[data-site='pipspulse'] {
    --zh-bg: #161c21;
    --zh-fg: #eef3f6;
    --zh-muted: #8e9ea8;
    --zh-line: #33414a;
    --zh-soft: #1c2329;
    --zh-btn: #eef3f6;
    --zh-btn-fg: #0e1012;
    --zh-you: #dfe9ef;
    --zh-you-fg: #0e1012;
    --zh-accent: #8fb6d6;
  }
}

.zh svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.zh button {
  font: inherit;
  color: inherit;
}

/* The round button */
.zh-launch {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--zh-btn);
  color: var(--zh-btn-fg) !important;
  box-shadow: var(--zh-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 160ms var(--zh-ease);
}
.zh-launch:hover {
  transform: scale(1.05);
}
.zh-launch:active {
  transform: scale(0.96);
}
.zh-launch:focus-visible,
.zh button:focus-visible,
.zh a:focus-visible,
.zh-input:focus-visible {
  outline: 2px solid var(--zh-accent);
  outline-offset: 2px;
}
.zh-launch svg {
  width: 26px;
  height: 26px;
}
.zh-launch .zh-i-chat {
  fill: currentColor;
  stroke: none;
}
.zh-launch .zh-i-chat circle {
  fill: var(--zh-btn);
}
.zh-i-close,
.zh-open .zh-i-chat {
  display: none;
}
.zh-open .zh-i-close {
  display: block;
}

/* The greeting beside the button */
.zh-greet {
  position: relative;
  max-width: 290px;
  background: var(--zh-bg);
  border-radius: 16px;
  box-shadow: var(--zh-shadow);
  animation: zh-in 260ms var(--zh-ease);
}
.zh-greet-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: 0;
  background: none;
  padding: 16px 36px 16px 18px;
  cursor: pointer;
  border-radius: 16px;
}
.zh-greet-body b {
  font-weight: 600;
}
.zh-greet-body span {
  color: var(--zh-muted);
  font-size: 14px;
}
.zh-greet-x,
.zh-x {
  border: 0;
  background: none;
  color: var(--zh-muted) !important;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 8px;
}
.zh-greet-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
}
.zh-greet-x svg {
  width: 15px;
  height: 15px;
}

/* The chat */
.zh-panel {
  width: 370px;
  height: min(560px, calc(100vh - 120px));
  height: min(560px, calc(100dvh - 120px));
  background: var(--zh-bg);
  border-radius: 18px;
  box-shadow: var(--zh-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: zh-in 240ms var(--zh-ease);
  transform-origin: bottom right;
}
.zh-panel[hidden] {
  display: none;
}
@keyframes zh-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
@media (prefers-reduced-motion: reduce) {
  .zh-panel,
  .zh-greet {
    animation: none;
  }
}
.zh-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px 14px 18px;
  border-bottom: 1px solid var(--zh-line);
}
.zh-who {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.zh-who b {
  font-weight: 600;
}
.zh-who span {
  font-size: 13px;
  color: var(--zh-muted);
}
.zh-x {
  width: 36px;
  height: 36px;
}
.zh-x:hover,
.zh-greet-x:hover {
  background: var(--zh-soft);
}

.zh-list {
  position: relative; /* help.js measures messages from here */
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zh-msg {
  display: flex;
}
.zh-you {
  justify-content: flex-end;
}
.zh-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--zh-soft);
  overflow-wrap: anywhere;
}
.zh-bot .zh-bubble {
  border-bottom-left-radius: 6px;
}
.zh-you .zh-bubble {
  background: var(--zh-you);
  color: var(--zh-you-fg);
  border-bottom-right-radius: 6px;
}
.zh-bubble p {
  margin: 0;
  white-space: pre-line;
}
.zh-bubble p + p {
  margin-top: 8px;
}
.zh-bubble a {
  color: var(--zh-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.zh-tg {
  display: inline-flex;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--zh-btn);
  color: var(--zh-btn-fg) !important;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 14px;
}

.zh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 2px;
}
.zh-chips-label {
  width: 100%;
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--zh-muted);
}
.zh-chip {
  border: 1px solid var(--zh-line);
  background: var(--zh-bg);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 120ms;
}
.zh-chip:hover {
  background: var(--zh-soft);
}
.zh-helped {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--zh-muted);
  padding-left: 4px;
}
.zh-mini {
  border: 1px solid var(--zh-line);
  background: none;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px !important;
  cursor: pointer;
}
.zh-mini:hover {
  background: var(--zh-soft);
}

.zh-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 6px;
  border-top: 1px solid var(--zh-line);
}
.zh-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--zh-line);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 16px; /* 16px or more: phones do not zoom in on focus */
  background: var(--zh-bg);
  color: var(--zh-fg);
}
.zh-input::placeholder {
  color: var(--zh-muted);
}
.zh-send {
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--zh-btn);
  color: var(--zh-btn-fg) !important;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.zh-send svg {
  width: 20px;
  height: 20px;
}
.zh-foot {
  padding: 4px 16px 12px;
  text-align: center;
  font-size: 13px;
}
.zh-foot-link {
  color: var(--zh-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Phones: the chat takes the screen; the button stays out of the way */
@media (max-width: 520px) {
  .zh {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .zh-open {
    inset: 0;
    gap: 0;
  }
  .zh-open .zh-launch,
  .zh-open .zh-greet {
    display: none;
  }
  .zh-panel {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .zh-head {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .zh-greet {
    max-width: calc(100vw - 28px);
  }
}
@media print {
  .zh {
    display: none;
  }
}
