.clinic-chat {
  --chat-navy: #0e2a40;
  --chat-ink: #18394d;
  --chat-line: #dce5eb;
  --chat-right: max(18px, env(safe-area-inset-right));
  --chat-bottom: calc(96px + env(safe-area-inset-bottom));
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: var(--chat-right);
  bottom: var(--chat-bottom);
  z-index: 998;
  display: grid;
  justify-items: end;
  gap: 10px;
  pointer-events: none;
  color: var(--chat-ink);
  font: 400 15px/1.45 "DM Sans", system-ui, sans-serif;
  text-align: left;
}
.clinic-chat[hidden], .clinic-chat-panel[hidden] { display: none; }
.clinic-chat [hidden] { display: none !important; }
.clinic-chat-launch, .clinic-chat-panel { pointer-events: auto; }
.clinic-chat button, .clinic-chat input { font: inherit; }
.clinic-chat button { cursor: pointer; }
.clinic-chat :focus-visible { outline: 2px solid #257394; outline-offset: 2px; }
.clinic-chat-launch {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 3px 11px 3px 3px;
  border: 1px solid var(--chat-line);
  border-radius: 999px;
  color: var(--chat-navy);
  background: #fff;
  box-shadow: 0 8px 24px #0e2a4026;
  transform-origin: right center;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.clinic-chat-launch span { font-weight: 700; }
.clinic-chat-launch img, .clinic-chat-avatar {
  display: block;
  flex: none;
  object-fit: contain;
  border-radius: 50%;
  background: #f6e9d9;
}
.clinic-chat-launch img { width: 40px; height: 40px; }
.clinic-chat-launch:hover, .clinic-chat-launch:focus-visible { background: #f9f4ed; transform: scale(1.035); box-shadow: 0 10px 28px #0e2a4033; }
.clinic-chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto;
  width: min(400px, 100%);
  height: min(560px, calc(100vh - var(--chat-bottom) - 24px));
  height: min(560px, calc(100dvh - var(--chat-bottom) - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 16px 54px #0e2a403d;
}
.clinic-chat.is-open {
  top: 20px;
  bottom: 20px;
  z-index: 1001;
  align-content: end;
}
.clinic-chat.is-open .clinic-chat-launch { display: none; }
.clinic-chat.is-open .clinic-chat-panel {
  height: min(560px, calc(100vh - 40px));
  height: min(560px, calc(100dvh - 40px));
}
.clinic-chat.is-open .clinic-chat-panel:has(.clinic-chat-verification:not([hidden])) { height: auto; max-height:calc(100dvh - 40px); overflow-y:auto; }
body.chat-widget-open .wa-float { visibility: hidden; opacity: 0; pointer-events: none; }
.clinic-chat-verification { padding: 10px 12px; border-top: 1px solid var(--chat-line); background: #fff; }
.clinic-chat-verification p { margin: 0 0 7px; font-size: 13px; }
.clinic-chat-verification [data-chat-honeypot] { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.clinic-chat-followup { padding: 9px 12px; border-top: 1px solid var(--chat-line); background: #fff; font-size: 13px; }
.clinic-chat-followup p { margin: 0 0 6px; }
.clinic-chat-followup a { color: #075e54; font-weight: 700; }
.clinic-chat-direct-whatsapp { display: inline-block; margin-top: 6px; color: #075e54; font-size: 12px; font-weight: 650; }
.clinic-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: #fff;
  background: var(--chat-navy);
}
.clinic-chat-header h2 {
  margin: 0;
  color: inherit;
  font: 700 17px/1.25 "DM Sans", system-ui, sans-serif;
  letter-spacing: normal;
}
.clinic-chat-header p { margin: 1px 0 0; color: #e5eff4; font-size: 12px; }
.clinic-chat-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 26px !important;
}
.clinic-chat-close:hover { background: #ffffff26; }
.clinic-chat-close:focus-visible { outline-color: #fff; outline-offset: 0; }
.clinic-chat-log {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  background: #f4f7f8;
}
.clinic-chat-exchange { margin-top: 9px; }
.clinic-chat-message {
  width: fit-content;
  max-width: 96%;
  margin: 0 0 8px;
  padding: 9px 11px;
  border: 1px solid var(--chat-line);
  border-radius: 4px 12px 12px;
  background: #fff;
  overflow-wrap: anywhere;
}
.clinic-chat-message-user {
  margin-left: auto;
  border-color: var(--chat-navy);
  border-radius: 12px 4px 12px 12px;
  color: #fff;
  background: var(--chat-navy);
}
.clinic-chat-message p { margin: 0; }
.clinic-chat-message ul { margin: 4px 0 0; padding-left: 17px; }
.clinic-chat-message li + li, .clinic-chat-message ul + p { margin-top: 5px; }
.clinic-chat-message a {
  color: #0b5778;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.clinic-chat-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 88px;
  overflow-y: auto;
  padding: 7px 9px;
  border-top: 1px solid var(--chat-line);
}
.clinic-chat-topics button {
  min-height: 32px;
  padding: 3px 8px;
  border: 1px solid #b8cad6;
  border-radius: 20px;
  color: var(--chat-ink);
  background: #fff;
  font-size: 13px;
  font-weight: 650;
}
.clinic-chat-topics button:hover { background: #eef5f8; }
.clinic-chat-form { display: flex; gap: 7px; padding: 8px 9px; border-top: 1px solid var(--chat-line); }
.clinic-chat-form input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #a6bbc8;
  border-radius: 8px;
  color: var(--chat-ink);
  background: #fff;
  font-size: 16px;
}
.clinic-chat-form button {
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: var(--chat-navy);
  font-weight: 700;
}
.clinic-chat-form button:hover { background: #1c4e69; }
body.doctor-profile-page .clinic-chat { --chat-bottom: max(18px, env(safe-area-inset-bottom)); }
@media (max-width: 520px) {
  .clinic-chat {
    --chat-right: max(12px, env(safe-area-inset-right));
    --chat-bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .clinic-chat-launch { gap: 6px; min-height: 46px; padding: 2px 10px 2px 2px; font-size: 14px; }
  .clinic-chat-launch img { width: 40px; height: 40px; }
  .clinic-chat-panel { width: min(400px, calc(100vw - 24px)); border-radius: 15px; }
  .clinic-chat.is-open {
    top: calc(88px + env(safe-area-inset-top));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .clinic-chat.is-open .clinic-chat-panel:not(:has(.clinic-chat-verification:not([hidden]))) {
    height: min(560px, calc(100dvh - 116px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  .wa-float { right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
}
@media (max-height: 560px) {
  .clinic-chat.is-open {
    top: max(8px, env(safe-area-inset-top));
    bottom: max(8px, env(safe-area-inset-bottom));
  }
  .clinic-chat.is-open .clinic-chat-panel:not(:has(.clinic-chat-verification:not([hidden]))) {
    height: min(560px, calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
}
.clinic-chat .clinic-chat-safety { margin:0; padding:8px 14px; background:#f5f1e7; color:#17394f; font-size:11px; line-height:1.4; }
@media (max-width:520px) {
  .clinic-chat.is-open .clinic-chat-panel:has(.clinic-chat-verification:not([hidden])) { max-height:calc(100dvh - 116px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
