.contact-chat-invite {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--text);
}
.contact-chat-mount, .chat-widget { min-width: 0; width: 100%; }
.chat-widget {
  --chat-ink: #14322d;
  --chat-muted: #64736d;
  --chat-teal: #08796f;
  --chat-teal-deep: #045950;
  max-width: 900px;
  margin: 0 auto;
  color: var(--chat-ink);
}
.chat-panel {
  display: flex; flex-direction: column;
  width: 100%;
  min-width: 0;
  border: 1px solid #d4e3dd; border-radius: 24px;
  background: white;
  box-shadow: 0 1px 2px #0a1e1a0f, 0 30px 70px -30px #04231f8c;
  overflow: hidden; overscroll-behavior: contain;
}
.chat-panel.has-history .chat-messages { height: 360px; min-height: 120px; max-height: 360px; }
.chat-panel > :not(.chat-messages) { flex-shrink: 0; }

/* Header */
.chat-header {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px;
  color: white;
  background:
    radial-gradient(150% 190% at 100% -30%, #ffffff2e 0%, #ffffff00 58%),
    linear-gradient(125deg, #07766b 0%, #05645b 56%, #04574f 100%);
  overflow: hidden;
}
.chat-header::before,
.chat-header::after {
  content: ""; position: absolute; pointer-events: none;
  border: 1px solid #ffffff26; border-radius: 50%;
}
.chat-header::before { width: 200px; height: 200px; top: -112px; right: -48px; }
.chat-header::after { width: 112px; height: 112px; top: -64px; right: 48px; border-color: #ffffff1a; }
.chat-avatar {
  position: relative; z-index: 1; flex: none;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: 1px solid #ffffff45; border-radius: 15px;
  background: #ffffff24;
  box-shadow: inset 0 1px 0 #ffffff40;
}
.chat-avatar svg { width: 26px; height: 26px; }
.chat-heading { position: relative; z-index: 1; display: grid; gap: 3px; min-width: 0; }
.chat-header .chat-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0;
  color: #d9f4ee; font-size: 10.5px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase;
}
.chat-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #7fe3bd; box-shadow: 0 0 0 3px #7fe3bd2e;
  transition: background 180ms ease, box-shadow 180ms ease;
}
.chat-panel.is-offline .chat-dot { background: #cfdad6; box-shadow: 0 0 0 3px #ffffff14; }
.chat-header strong {
  display: block;
  font-size: 21px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em;
}
.chat-subtitle { display: block; color: #d9eee9; font-size: 12.5px; line-height: 1.4; }

/* Conversation */
.chat-messages {
  min-height: 120px; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 20px;
  background:
    radial-gradient(70% 55% at 100% 0%, #08796f0e 0%, #08796f00 65%),
    linear-gradient(180deg, #f4f9f7 0%, #edf5f2 100%);
  scrollbar-width: thin; scrollbar-color: #b9cec7 transparent;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  border: 2px solid transparent; border-radius: 99px;
  background: #bfd4cd; background-clip: content-box;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: #a6c2b9; background-clip: content-box; }
.chat-row {
  display: flex; align-items: flex-end; gap: 10px;
  margin: 0 0 14px;
  animation: chat-rise 180ms ease-out both;
}
.chat-row:last-child { margin-bottom: 0; }
.chat-row-user { justify-content: flex-end; }
.chat-author {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; margin-bottom: 2px;
  border: 1px solid #c9e2da; border-radius: 50%;
  background: #dcefe8; color: var(--chat-teal-deep);
}
.chat-author svg { width: 17px; height: 17px; }
.chat-messages .chat-bubble {
  width: fit-content; max-width: min(78%, 620px); margin: 0; padding: 12px 15px;
  border: 1px solid #e1ebe7; border-radius: 5px 16px 16px 16px;
  background: white; color: var(--chat-ink);
  font-size: 14.5px; line-height: 1.62;
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 1px 2px #0c2e2708;
}
.chat-row-user .chat-bubble {
  margin-left: auto;
  border-color: transparent; border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, #087a70, #045d55);
  color: white;
  box-shadow: 0 8px 18px -12px #045950cc;
}
@keyframes chat-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Typing indicator */
.chat-typing .chat-bubble { padding: 15px 18px; }
.chat-dots { display: inline-flex; align-items: center; gap: 4px; }
.chat-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #90afa5;
  animation: chat-dot 1.1s infinite ease-in-out;
}
.chat-dots i:nth-child(2) { animation-delay: .15s; }
.chat-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Empty-state prompts */
.chat-quick {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px 0;
}
.chat-quick button {
  padding: 8px 13px;
  border: 1px solid #d7e5e0; border-radius: 999px;
  background: white; color: #0a5e56;
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.chat-quick button:hover { border-color: #9cc9bf; background: #f1faf7; color: var(--chat-teal-deep); }

/* Status and recovery */
.chat-panel .chat-status { margin: 0; color: var(--chat-muted); font-size: 12.5px; line-height: 1.5; }
.chat-panel .chat-status:not(:empty) {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 20px 0;
}
.chat-panel .chat-status:not(:empty)::before {
  content: ""; flex: none;
  width: 14px; height: 14px;
  border: 2px solid #cfe2dc; border-top-color: var(--chat-teal);
  border-radius: 50%;
  animation: chat-spin .8s linear infinite;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }
.chat-panel .chat-status.is-error {
  display: block;
  padding: 11px 14px;
  border: 1px solid #ecdcc2; border-left: 3px solid #d9a441; border-radius: 10px;
  background: #fdf8ee; color: #6d5a34;
}
.chat-status.is-error::before { display: none; }
.chat-recovery { padding: 12px 20px 0; }
.chat-recovery button {
  min-height: 44px; width: 100%; padding: 10px 16px;
  border: 1px solid #c9dcd6; border-radius: 12px;
  background: white; color: var(--chat-teal-deep); font-weight: 600; cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.chat-recovery button:hover { border-color: #9cc9bf; background: #f0f7f4; }
.chat-recovery .chat-edit { margin-top: 8px; }

/* Composer */
.chat-form {
  display: grid; grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px; align-items: end;
  padding: 14px 20px 2px;
}
.chat-form label {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: -2px;
  color: var(--chat-muted); font-size: 12px; font-weight: 600;
}
.chat-hint { color: #77847f; font-size: 11.5px; font-weight: 500; }
.chat-form textarea {
  width: 100%; min-width: 0; min-height: 52px; max-height: 132px;
  resize: none; padding: 14px 16px;
  border: 1px solid #d6e4df; border-radius: 14px;
  background: #fbfdfc; color: var(--chat-ink);
  font-size: 16px; line-height: 1.5;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.chat-form textarea::placeholder { color: #6f7c77; }
.chat-form textarea:focus { border-color: #4fa79b; background: white; box-shadow: 0 0 0 4px #08796f1f; }
.chat-form button {
  align-self: end;
  width: 52px; height: 52px; min-height: 52px; padding: 0;
  border-radius: 50%;
  box-shadow: 0 10px 20px -10px #045950e6;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.chat-form button svg { width: 22px; height: 22px; }
.chat-form .button-primary { background: linear-gradient(135deg, #0b8a7e, #056b62); }
.chat-form .button-primary:hover { background: linear-gradient(135deg, #0a9689, #06776c); transform: translateY(-1px); }
.chat-widget button:disabled {
  opacity: .5; cursor: default; transform: none;
  box-shadow: none;
}
.chat-widget :focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* Footer */
.chat-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 4px 16px;
  padding: 6px 20px 0;
  font-size: 13px;
}
.chat-footer button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 42px; padding: 8px 0;
  border: 0; background: none; color: var(--chat-muted);
  font-weight: 600; cursor: pointer;
  transition: color 160ms ease;
}
.chat-footer button svg { width: 16px; height: 16px; opacity: .85; }
.chat-footer button:hover { color: var(--chat-teal-deep); }
.chat-footer-links { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.chat-footer a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 0;
  color: var(--chat-teal-deep); font-weight: 700;
}
.chat-footer a svg { width: 15px; height: 15px; }
.chat-footer .lead-open {
  padding: 8px 14px;
  border: 1px solid #cfe3dd; border-radius: 999px;
  background: #f3faf8;
  color: var(--chat-teal-deep);
}
.chat-footer .lead-open:hover { border-color: #9cc9bf; background: #eaf7f3; }
.is-unavailable .chat-footer-links { width: 100%; margin: 8px 0 0; }
.is-unavailable .chat-footer a {
  width: 100%; justify-content: center;
  margin: 0; padding: 12px 16px;
  border-radius: 12px;
  background: var(--teal); color: white;
}
.chat-panel .chat-note {
  margin: 0; padding: 6px 20px 16px;
  color: #6b7873; font-size: 11.5px; line-height: 1.5;
}
.chat-note a { color: #5d6b65; }

/* Lead dialog */
.lead-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 26px;
  border: 1px solid #d4e3dd; border-radius: 20px;
  color: var(--text); background: white;
  box-shadow: 0 40px 100px -30px #041b18cc;
  overflow: auto; overscroll-behavior: contain;
}
.lead-dialog::backdrop { background: #10272bc4; backdrop-filter: blur(3px); }
.lead-form { display: grid; gap: 14px; }
.lead-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lead-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.lead-close {
  min-width: 44px; min-height: 44px;
  border: 0; border-radius: 12px;
  background: #f0f5f4; cursor: pointer; font-size: 24px;
  transition: background 160ms ease;
}
.lead-close:hover { background: #e4efeb; }
.lead-form p { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; }
.lead-form label { display: grid; gap: 6px; font-size: 14px; }
.lead-form input:not([type="checkbox"]), .lead-form textarea {
  width: 100%; min-width: 0; padding: 11px 13px;
  border: 1px solid #c9dcd6; border-radius: 10px;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.lead-form input:not([type="checkbox"]):focus, .lead-form textarea:focus {
  border-color: #4fa79b; box-shadow: 0 0 0 3px #08796f1a;
}
.lead-form textarea { resize: vertical; }
.lead-form .lead-consent { display: block; font-size: 12px; line-height: 1.5; }
.lead-consent input { margin-right: 6px; }
.lead-consent a { text-decoration: underline; }
.lead-form .lead-status { color: var(--chat-teal-deep); overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .floating-call { right: auto; left: 16px; bottom: max(20px, env(safe-area-inset-bottom)); padding: 14px; }
  .floating-call span { display: none; }
  .chat-panel { border-radius: 20px; }
  .chat-header { gap: 12px; padding: 16px; }
  .chat-avatar { width: 42px; height: 42px; border-radius: 13px; }
  .chat-avatar svg { width: 23px; height: 23px; }
  .chat-header strong { font-size: 18px; }
  .chat-subtitle { font-size: 11.5px; }
  .chat-messages { padding: 14px; }
  .chat-messages .chat-bubble { max-width: min(88%, 620px); font-size: 14px; }
  .chat-quick { padding: 10px 14px 0; }
  .chat-form { padding: 12px 14px 2px; }
  .chat-hint { display: none; }
  .chat-footer { padding: 6px 14px 0; }
  .chat-panel .chat-note { padding: 6px 14px 14px; }
  .lead-dialog { padding: 20px; }
}
@media (max-width: 360px) {
  .chat-header { padding: 14px; }
  .chat-subtitle { display: none; }
  .chat-form { grid-template-columns: minmax(0, 1fr) 48px; }
  .chat-form button { width: 48px; height: 48px; min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-row, .chat-dots i, .chat-status::before { animation: none; }
  .chat-form button, .chat-quick button, .chat-footer button { transition: none; }
}
