.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-widget {
  position: fixed;
  z-index: 200;
  right: 1.5rem;
  bottom: 1.5rem;
  font-family: var(--font);
}

.chat-widget button,
.chat-widget input,
.chat-widget textarea {
  font: inherit;
}

.chat-widget button {
  cursor: pointer;
}

.chat-widget button:focus-visible,
.chat-widget input:focus-visible,
.chat-widget textarea:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.chat-launcher {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  padding: 0.85rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--navy-deep);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(16, 47, 58, 0.28);
}

.chat-launcher span {
  color: var(--mint);
  font-size: 1.2rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2rem));
  height: min(660px, calc(100dvh - 7rem));
  margin-bottom: 0.8rem;
  overflow: hidden;
  border: 1px solid rgba(16, 47, 58, 0.2);
  border-radius: 1.2rem;
  background: #f8f8f5;
  box-shadow: 0 22px 60px rgba(16, 47, 58, 0.28);
}

.chat-panel[hidden],
.chat-lead[hidden],
.chat-question[hidden],
.chat-suggestions[hidden],
.chat-transcript-section[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--navy-deep);
  color: #fff;
}

.chat-header strong,
.chat-header small {
  display: block;
}

.chat-header small {
  margin-top: 0.1rem;
  color: var(--mint);
  font-size: 0.78rem;
}

.chat-close {
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  font-size: 1.6rem !important;
  line-height: 1;
}

.chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 80px;
  padding: 1rem;
  overflow-y: auto;
}

.chat-bubble {
  align-self: flex-start;
  max-width: 92%;
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem 1rem 1rem 0.2rem;
  background: #e7efeb;
  color: var(--navy-deep);
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-line;
}

.chat-bubble-visitor {
  align-self: flex-end;
  border-radius: 1rem 1rem 0.2rem 1rem;
  background: var(--navy);
  color: #fff;
}

.chat-bubble-typing {
  color: var(--muted);
  font-style: italic;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.9rem 0.75rem;
}

.chat-suggestions button {
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 0.38rem 0.65rem;
  background: #fff;
  color: var(--navy-deep);
  font-size: 0.78rem;
}

.chat-question {
  display: flex;
  gap: 0.5rem;
  padding: 0.8rem;
  border-top: 1px solid #d5ddd9;
}

.chat-question input {
  flex: 1;
  min-width: 0;
  border: 1px solid #aebcb8;
  border-radius: 999px;
  padding: 0.65rem 0.85rem;
  background: #fff;
}

.chat-question button,
.chat-lead-actions button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 0.85rem;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.chat-lead {
  display: grid;
  flex: 1 1 auto;
  gap: 0.65rem;
  min-height: 0;
  padding: 0.9rem 1rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 1rem;
  border-top: 1px solid #d5ddd9;
}

.chat-panel.case-open .chat-messages {
  flex: 0 0 5rem;
  min-height: 0;
}

.chat-lead > p {
  margin: 0;
  font-size: 0.88rem;
}

.chat-lead label:not(.visually-hidden) {
  display: grid;
  gap: 0.25rem;
  color: var(--navy-deep);
  font-size: 0.82rem;
  font-weight: 600;
}

.chat-lead label span {
  font-weight: 400;
}

.chat-lead input:not([type="checkbox"]),
.chat-lead textarea {
  width: 100%;
  border: 1px solid #aebcb8;
  border-radius: 0.55rem;
  padding: 0.5rem 0.6rem;
  background: #fff;
}

.chat-lead .chat-consent {
  display: flex !important;
  align-items: flex-start;
  gap: 0.5rem !important;
  font-size: 0.76rem !important;
  font-weight: 400 !important;
}

.chat-transcript-section {
  display: grid;
  gap: 0.4rem;
  padding: 0.7rem;
  border: 1px solid #d5ddd9;
  border-radius: 0.65rem;
  background: #fff;
}

.chat-transcript-section p {
  margin: 0;
  color: var(--navy-deep);
  font-size: 0.8rem;
  font-weight: 600;
}

.chat-transcript-section pre {
  max-height: 7rem;
  margin: 0;
  padding: 0.55rem;
  overflow: auto;
  border-radius: 0.4rem;
  background: #edf2ef;
  color: var(--navy-deep);
  font: 0.74rem/1.4 var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-consent input {
  margin-top: 0.2rem;
}

.chat-lead-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-lead-actions button[type="button"] {
  border: 0;
  background: transparent;
  color: var(--navy);
}

.chat-form-status {
  color: var(--navy-deep);
}

.chat-widget button:disabled,
.contact-form button:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* Keep the assistant readable on both dark and light sections. */
.chat-widget { color: var(--ink); color-scheme: light; font-size: 14px; }
.chat-launcher { border: 1px solid var(--mint); border-radius: 6px; background: var(--mint); color: var(--ink); font-size: 12px; }
.chat-launcher span { color: var(--ink); }
.chat-panel { border-radius: 10px; }
.chat-widget input, .chat-widget textarea { color: var(--ink); }
.chat-bubble-typing { color: #52656b; }
.turnstile-host { width: 100%; min-height: 65px; }
@media (max-width: 620px) {
  .chat-widget { right: .75rem; bottom: max(.75rem, env(safe-area-inset-bottom)); }
  .chat-panel { height: min(660px, calc(100dvh - 5.5rem)); }
  .chat-panel.case-open .chat-messages { display: none; }
  .chat-panel.case-open .chat-lead { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}
