.site-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.site-chat-label {
  margin: 0 0 6px;
  width: 64px;
  padding: 3px 0;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.site-chat:has(.site-chat-open[aria-expanded="true"]) .site-chat-label {
  display: none;
}

.site-chat-open {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  overflow: hidden;
  background: var(--brand);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  cursor: pointer;
}

.site-chat-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-chat-open[aria-expanded="true"] {
  background: #111827;
}

.site-chat-open[aria-expanded="true"] img {
  visibility: hidden;
}

.site-chat-open[aria-expanded="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(45deg);
  box-shadow: 0 0 0 0 #fff;
}

.site-chat-open[aria-expanded="true"]::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: #fff;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.site-chat-open:focus-visible,
.site-chat-close:focus-visible,
.site-chat-ask button:focus-visible,
.site-chat-quick button:focus-visible,
.site-chat-to-lead:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 2px;
}

.site-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 112px));
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.site-chat-panel[hidden] {
  display: none !important;
}

.site-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid #eee;
}

.site-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.site-chat-id {
  min-width: 0;
  flex: 1;
}

.site-chat-id h2,
.site-chat-id p,
.site-chat-msg,
.site-chat-error {
  margin: 0;
}

.site-chat-id h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.site-chat-id p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.site-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.site-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px 16px 8px;
}

.site-chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-chat-msg {
  align-self: flex-start;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 4px;
  background: #f3f4f6;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.site-chat-msg strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.site-chat-msg.is-user {
  align-self: flex-end;
  border: 1px solid #e5e7eb;
  border-radius: 16px 16px 4px 16px;
  background: #fff;
  color: var(--ink);
}

.site-chat-quick {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.site-chat-quick button,
.site-chat-to-lead {
  width: auto;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.site-chat-to-lead {
  margin-top: 8px;
  border-color: var(--brand);
  background: #e8f8ee;
  color: var(--brand-dark);
  font-weight: 700;
}

.site-chat-ask {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 12px;
  padding: 4px 4px 4px 14px;
  border-radius: 24px;
  background: #f3f4f6;
}

.site-chat-ask input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.site-chat-ask button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

.site-chat-lead {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 16px;
}

.site-chat-lead label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
}

.site-chat-lead input,
.site-chat-lead select,
.site-chat-lead textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.site-chat-consent {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 8px !important;
  font-weight: 400 !important;
  line-height: 1.45;
}

.site-chat-consent input {
  width: auto;
  margin-top: 2px;
}

.site-chat-back {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.site-chat-lead button[type="submit"] {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.site-chat-error {
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.45;
}

.site-chat-body[hidden],
.site-chat-lead[hidden],
.site-chat-ask[hidden],
.site-chat-quick[hidden],
.site-chat-to-lead[hidden],
.site-chat-error[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .site-chat {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  body.has-mobile-cta .site-chat {
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
}
