.chat-launcher,
.chat-preview {
  --chat-edge: max(18px, env(safe-area-inset-right));
  --chat-bottom: max(18px, env(safe-area-inset-bottom));
  --chat-accent: #173e37;
  position: fixed;
  right: var(--chat-edge);
  font: 15px/1.5 system-ui, sans-serif;
}

.chat-launcher {
  z-index: 10;
  bottom: var(--chat-bottom);
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 5px 20px #102e3a42;
}
.chat-launcher:hover { background: #28594e; }
.chat-launcher:focus-visible,
.chat-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -5px;
}
.chat-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 25px;
  height: 19px;
  border: 2px solid currentColor;
  border-radius: 7px;
}
.chat-icon::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  background: var(--chat-accent);
  rotate: -20deg;
}
.chat-launcher:hover .chat-icon::after { background: #28594e; }
.chat-icon::before {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: -5px 0 currentColor, 5px 0 currentColor;
}
.chat-preview {
  inset: auto var(--chat-edge) calc(var(--chat-bottom) + 66px) auto;
  width: min(340px, calc(100% - var(--chat-edge) - 12px));
  max-height: calc(100dvh - var(--chat-bottom) - 80px);
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid #dce7e1;
  border-radius: 16px;
  background: #fff;
  color: #172f2b;
  box-shadow: 0 14px 44px #102e3a38;
}
.chat-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  background: var(--chat-accent);
  color: #fff;
}
.chat-preview-heading h2 { margin: 0; font: 700 16px/1.3 system-ui, sans-serif; letter-spacing: normal; }
.chat-close {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: 25px/1 system-ui, sans-serif;
  cursor: pointer;
}
.chat-close:hover { background: #ffffff24; }
.chat-preview-body { padding: 18px; }
.chat-message {
  width: fit-content;
  margin: 0 16px 20px 0;
  padding: 11px 13px;
  border-radius: 5px 14px 14px 14px;
  background: #ebf2ef;
}
.chat-compose {
  padding: 10px 12px;
  border: 1px solid #e0e8e3;
  border-radius: 8px;
  color: #50675f;
}
@media (prefers-reduced-motion: no-preference) {
  .chat-preview:popover-open { animation: chat-enter 180ms ease-out; }
  @keyframes chat-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }
}
