/* Site chat widget. Dark theme only; tokens come from styles.css (fallbacks inline). */
.chat-bubble,
.chat-panel {
  --c-bg: var(--bg, #09090b);
  --c-surface: var(--surface, #18181b);
  --c-elevated: var(--elevated, #1c1c22);
  --c-border: var(--border, rgba(255, 255, 255, 0.08));
  --c-text: var(--text, #fafafa);
  --c-muted: var(--muted, #a1a1aa);
  --c-indigo: var(--indigo, #6366f1);
  --c-indigo-light: var(--indigo-light, #818cf8);
  /* fill behind white text: #5457e5 = 5.4:1 (the site indigo #6366f1 is only 4.47:1) */
  --c-action: #5457e5;
  --c-action-hover: #4446c4;
  /* the site's own indigo -> violet gradient (styles.css), used for the launcher border */
  --c-grad: linear-gradient(135deg, var(--indigo, #6366f1), var(--violet, #8b5cf6));
  font-family: var(--font, 'Inter', system-ui, -apple-system, sans-serif);
}

.chat-bubble {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 9998;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--c-grad);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.chat-bubble__label { display: none; }
.chat-bubble:hover { filter: brightness(1.1); transform: translateY(-1px); }
.chat-bubble:focus-visible,
.chat-close:focus-visible,
.chat-chip:focus-visible,
.chat-send:focus-visible,
.chat-stop:focus-visible,
.chat-action:focus-visible,
.chat-link:focus-visible,
.chat-input:focus-visible {
  outline: 2px solid var(--c-indigo-light);
  outline-offset: 2px;
}

.chat-panel {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  width: 380px;
  height: 560px;
  max-height: calc(100dvh - 108px);
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: chat-in 0.18s ease-out;
}
.chat-panel[hidden] { display: none; }

@keyframes chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 0 16px;
}
.chat-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.chat-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--c-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.chat-close:hover { color: var(--c-text); background: var(--c-surface); }
.chat-note {
  padding: 0 16px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
}

.chat-log:focus-visible { outline: 2px solid var(--c-indigo-light); outline-offset: -2px; }
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--c-action);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.chat-msg--assistant {
  align-self: flex-start;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-bottom-left-radius: 4px;
}
.chat-msg--system {
  align-self: stretch;
  max-width: 100%;
  background: var(--c-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-text);
}
.chat-msg p + p,
.chat-msg p + ul,
.chat-msg p + ol,
.chat-msg ul + p,
.chat-msg ol + p,
.chat-msg ul + ul,
.chat-msg ol + ol { margin-top: 8px; }
.chat-msg ul,
.chat-msg ol { padding-left: 20px; }
.chat-msg li + li { margin-top: 3px; }
.chat-msg code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 5px;
}
.chat-help { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--c-border); font-size: 12.5px; color: var(--c-muted); }
.chat-link { color: var(--c-indigo-light); text-decoration: underline; text-underline-offset: 2px; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-chip {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: transparent;
  color: var(--c-text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.chat-chip:hover { border-color: var(--c-indigo-light); background: var(--c-surface); }
/* preset install guides: first, full width, stronger than the question chips */
.chat-chip--guide {
  flex: 1 1 100%;
  border-radius: 12px;
  border-color: var(--c-indigo);
  background: rgba(99, 102, 241, 0.12);
  font-weight: 600;
}
.chat-chip--guide:hover { background: rgba(99, 102, 241, 0.2); }

.chat-msg.chat-guide { max-width: 100%; }
.chat-guide__title { font-weight: 600; }
.chat-msg .chat-guide__steps { padding-left: 22px; }
.chat-msg .chat-guide__steps li + li { margin-top: 6px; }
.chat-guide__steps li::marker { color: var(--c-indigo-light); font-weight: 600; }

.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--c-action);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.chat-action:hover { background: var(--c-action-hover); }

.chat-form {
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}
.chat-form[hidden] { display: none; }
.chat-label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--c-muted); }
/* One bordered row: the field grows with the text, Send/Stop stay at its bottom-right. */
.chat-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface);
}
.chat-box:focus-within {
  outline: 2px solid var(--c-indigo-light);
  outline-offset: 2px;
}
.chat-input {
  display: block;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 8px;
  resize: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
}
.chat-input:focus-visible { outline: none; }
.chat-input:disabled { opacity: 0.6; }
.chat-row { display: flex; align-items: center; justify-content: flex-end; margin-top: 4px; padding: 0 4px; }
.chat-counter { margin-right: auto; font-size: 12px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.chat-send,
.chat-stop {
  flex: none;
  min-width: 64px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chat-send { background: var(--c-action); color: #fff; }
.chat-send:not(:disabled):hover { background: var(--c-action-hover); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-stop { background: var(--c-elevated); color: var(--c-text); border: 1px solid var(--c-border); }
.chat-send[hidden],
.chat-stop[hidden] { display: none; }

@media (max-width: 640px) {
  .chat-panel {
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .chat-msg { max-width: 94%; }
  /* full-screen panel open: lock page scroll (class set on <html> by chat.js) */
  html.chat-open,
  html.chat-open body { overflow: hidden; }
}

/* typing indicator: shown in an empty assistant bubble until the first text arrives */
.chat-typing { display: inline-flex; gap: 4px; align-items: center; height: 21px; }
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-muted);
  animation: chat-dot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: none; }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Desktop: labelled pill in the style of the Revclar help bar (icon + text), same toggle behaviour. */
@media (min-width: 768px) {
  .chat-bubble {
    width: auto;
    height: 44px;
    min-width: 44px;
    padding: 0 16px;
    border: 2px solid transparent;
    border-radius: 999px;
    color: var(--c-indigo-light);
    background: linear-gradient(var(--c-elevated), var(--c-elevated)) padding-box, var(--c-grad) border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .chat-bubble svg { width: 18px; height: 18px; flex-shrink: 0; }
  .chat-bubble:hover { filter: none; background: linear-gradient(color-mix(in srgb, var(--c-elevated) 90%, #fff), color-mix(in srgb, var(--c-elevated) 90%, #fff)) padding-box, var(--c-grad) border-box; }
  .chat-bubble__label { display: inline; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.85); white-space: nowrap; }
  .chat-bubble:hover .chat-bubble__label { color: #fff; }
  .chat-panel { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-height: calc(100dvh - 96px); }
}

@media (prefers-reduced-motion: reduce) {
  /* the page sets html{scroll-behavior:smooth}; do not animate the see_pricing jump */
  html { scroll-behavior: auto; }
  .chat-typing span { animation: none; opacity: 0.6; }
  .chat-panel { animation: none; }
  .chat-bubble { transition: none; }
  .chat-bubble:hover { transform: none; }
}
