:root {
  --chat-ink: #1d2a2b;
  --chat-muted: #64716f;
  --chat-paper: #ffffff;
  --chat-page: #f2f5f3;
  --chat-line: rgba(29, 42, 43, 0.14);
  --chat-teal: #087f72;
  --chat-teal-dark: #075e55;
}

.pb-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 180;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--chat-teal);
  color: #fff;
  box-shadow: 0 12px 32px rgba(18, 46, 41, 0.24);
  font: 700 14px/1 Manrope, sans-serif;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.pb-chat-launcher:hover {
  background: var(--chat-teal-dark);
  box-shadow: 0 16px 36px rgba(18, 46, 41, 0.3);
  transform: translateY(-2px);
}

.pb-chat-launcher:focus-visible,
.pb-chat-window button:focus-visible,
.pb-chat-window input:focus-visible {
  outline: 3px solid #bd7040;
  outline-offset: 3px;
}

.pb-chat-launcher svg { width: 20px; height: 20px; flex: none; }

.pb-chat-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  overflow: visible;
}

.pb-chat-dialog[open] {
  display: grid;
  place-items: end;
}

.pb-chat-dialog::backdrop {
  background: rgba(16, 29, 28, 0.42);
  backdrop-filter: blur(3px);
}

.pb-chat-window {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  width: min(420px, calc(100vw - 48px));
  height: min(660px, calc(100dvh - 48px));
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: var(--chat-paper);
  color: var(--chat-ink);
  box-shadow: 0 24px 70px rgba(15, 33, 31, 0.24);
  font-family: Manrope, sans-serif;
}

.pb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 0;
  padding: 18px 20px;
  background: #1d2a2b;
  color: #fff;
}

.pb-chat-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pb-chat-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid rgba(114, 215, 194, 0.38);
  border-radius: 5px;
  background: rgba(8, 127, 114, 0.2);
  color: #72d7c2;
}
.pb-chat-mark svg { width: 20px; height: 20px; }
.pb-chat-title { margin: 0; color: #fff; font: 700 16px/1.25 'Space Grotesk', Manrope, sans-serif; }
.pb-chat-subtitle { margin: 4px 0 0; color: #c5d2ce; font-size: 11px; line-height: 1.4; }
.pb-chat-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--chat-teal);
  border-radius: 4px;
  background: var(--chat-teal);
  color: #fff;
  cursor: pointer;
}
.pb-chat-close:hover { background: var(--chat-teal-dark); }
.pb-chat-close svg { width: 18px; height: 18px; }

.pb-chat-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 20px 0;
  color: #56635f;
  font-size: 11px;
  font-weight: 600;
}
.pb-chat-status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #bd7040; }
.pb-chat-status--online .pb-chat-status-dot { background: #087f72; }
.pb-chat-status--error .pb-chat-status-dot { background: #b64637; }
.pb-chat-model-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 20px 12px;
}
.pb-chat-model-label { color: #465350; font-size: 11px; font-weight: 700; }
.pb-chat-model {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--chat-line);
  border-radius: 4px;
  background: #f8faf9;
  color: var(--chat-ink);
  font: 500 11px Manrope, sans-serif;
}
.pb-chat-model:disabled { color: #64716f; opacity: 0.8; }
.pb-chat-status--error + .pb-chat-model-row .pb-chat-model { border-color: rgba(182, 70, 55, 0.4); }

.pb-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--chat-page);
}
.pb-chat-message {
  max-width: 90%;
  padding: 11px 13px;
  border: 1px solid var(--chat-line);
  border-radius: 5px 12px 12px 12px;
  background: #fff;
  color: var(--chat-ink);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.pb-chat-message p { margin: 0; }
.pb-chat-message--user {
  align-self: flex-end;
  border-color: var(--chat-teal);
  border-radius: 12px 5px 12px 12px;
  background: var(--chat-teal);
  color: #fff;
}
.pb-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 14px;
  background: var(--chat-page);
}
.pb-chat-suggestions[hidden] { display: none; }
.pb-chat-suggestion {
  padding: 8px 10px;
  border: 1px solid rgba(8, 127, 114, 0.3);
  border-radius: 4px;
  background: #fff;
  color: #075e55;
  font: 600 11px/1.35 Manrope, sans-serif;
  text-align: left;
  cursor: pointer;
}
.pb-chat-suggestion:hover { background: #e5f2ee; }
.pb-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  padding: 14px 16px 10px;
  border-top: 1px solid var(--chat-line);
  background: #fff;
}
.pb-chat-input {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--chat-line);
  border-radius: 4px;
  background: #f8faf9;
  color: var(--chat-ink);
  font: 500 13px Manrope, sans-serif;
}
.pb-chat-input::placeholder { color: #5f6b67; opacity: 1; }
.pb-chat-send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 4px;
  background: var(--chat-teal);
  color: #fff;
  cursor: pointer;
}
.pb-chat-send:hover { background: var(--chat-teal-dark); }
.pb-chat-send svg { width: 19px; height: 19px; }
.pb-chat-note {
  margin: 0;
  padding: 0 16px 12px;
  background: #fff;
  color: #5f6b67;
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 520px) {
  .pb-chat-launcher { right: 14px; bottom: 14px; min-height: 50px; padding: 0 15px; }
  .pb-chat-dialog { padding: 8px; }
  .pb-chat-dialog[open] { place-items: end center; }
  .pb-chat-window { width: 100%; height: min(720px, calc(100dvh - 16px)); border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .pb-chat-launcher { transition: none; }
}
