.btx-assistant {
  --btx-chat-ink: #241f20;
  --btx-chat-muted: #746b66;
  --btx-chat-cream: #fff8ec;
  --btx-chat-paper: #fffdf8;
  --btx-chat-plum: #702a55;
  --btx-chat-plum-dark: #54203f;
  --btx-chat-line: rgba(86, 55, 67, 0.14);
  --btx-chat-visual-height: 100dvh;
  --btx-chat-visual-top: 0px;
  position: fixed;
  right: 22px;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 2147480000;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--btx-chat-ink);
}

.btx-assistant *,
.btx-assistant *::before,
.btx-assistant *::after {
  box-sizing: border-box;
}

.btx-assistant__launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-left: auto;
  padding: 3px;
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: var(--btx-chat-plum);
  box-shadow: 0 14px 36px rgba(70, 30, 52, 0.28);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.btx-assistant__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 17px 40px rgba(70, 30, 52, 0.34);
}

.btx-assistant__launcher:focus-visible,
.btx-assistant button:focus-visible,
.btx-assistant textarea:focus-visible,
.btx-assistant a:focus-visible {
  outline: 3px solid rgba(112, 42, 85, 0.3);
  outline-offset: 3px;
}

.btx-assistant__launcher-avatar,
.btx-assistant__avatar,
.btx-assistant__message-avatar {
  display: block;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.btx-assistant__launcher-avatar {
  width: 54px;
  height: 54px;
}

.btx-assistant__status {
  position: absolute;
  right: 0;
  bottom: 3px;
  width: 15px;
  height: 15px;
  border: 3px solid var(--btx-chat-paper);
  border-radius: 50%;
  background: #27a66a;
}

.btx-assistant__launcher-label {
  position: absolute;
  right: 72px;
  max-width: 130px;
  padding: 8px 11px;
  border: 1px solid var(--btx-chat-line);
  border-radius: 999px;
  background: var(--btx-chat-paper);
  box-shadow: 0 8px 24px rgba(70, 30, 52, 0.14);
  color: var(--btx-chat-plum-dark);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.btx-assistant.is-open .btx-assistant__launcher-label {
  opacity: 0;
  transform: translateX(8px);
}

.btx-assistant__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 120px));
  max-height: 72dvh;
  overflow: hidden;
  border: 1px solid var(--btx-chat-line);
  border-radius: 22px;
  background: var(--btx-chat-paper);
  box-shadow: 0 22px 70px rgba(61, 30, 45, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.btx-assistant.is-open .btx-assistant__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.btx-assistant__header {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--btx-chat-line);
  background: linear-gradient(135deg, #fff8ec 0%, #f8e9dd 100%);
}

.btx-assistant__avatar {
  width: 44px;
  height: 44px;
  border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(78, 43, 58, 0.16);
}

.btx-assistant__identity {
  display: grid;
  min-width: 0;
  flex: 1;
  line-height: 1.15;
}

.btx-assistant__title {
  color: var(--btx-chat-plum-dark);
  font-size: 1rem;
  font-weight: 800;
}

.btx-assistant__subtitle {
  margin-top: 4px;
  color: var(--btx-chat-muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.btx-assistant__reset,
.btx-assistant__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--btx-chat-plum-dark);
  font: inherit;
  font-size: 1.28rem;
  line-height: 1;
  cursor: pointer;
}

.btx-assistant__reset:hover,
.btx-assistant__close:hover {
  background: rgba(112, 42, 85, 0.09);
}

.btx-assistant__messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 17px 14px 10px;
  background:
    radial-gradient(circle at 90% 10%, rgba(231, 207, 189, 0.24), transparent 35%),
    var(--btx-chat-paper);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(112, 42, 85, 0.25) transparent;
}

.btx-assistant__row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-bottom: 12px;
}

.btx-assistant__row--user {
  justify-content: flex-end;
}

.btx-assistant__message-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
}

.btx-assistant__bubble {
  max-width: 82%;
}

.btx-assistant__bubble p {
  margin: 0;
  padding: 10px 12px;
  border-radius: 15px 15px 15px 5px;
  background: #f3e9df;
  color: var(--btx-chat-ink);
  font-size: 0.875rem;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.btx-assistant__row--user .btx-assistant__bubble p {
  border-radius: 15px 15px 5px 15px;
  background: var(--btx-chat-plum);
  color: #fff;
}

.btx-assistant__action {
  display: block;
  width: fit-content;
  margin-top: 7px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--btx-chat-plum);
  color: #fff !important;
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none !important;
}

.btx-assistant__action:hover {
  background: var(--btx-chat-plum-dark);
}

.btx-assistant__typing {
  width: fit-content;
  margin: 0 0 12px 37px;
  padding: 8px 11px;
  border-radius: 12px;
  background: #f3e9df;
  color: var(--btx-chat-muted);
  font-size: 0.75rem;
}

.btx-assistant__quick {
  display: flex;
  gap: 7px;
  min-height: 45px;
  overflow-x: auto;
  padding: 7px 12px 6px;
  border-top: 1px solid rgba(86, 55, 67, 0.08);
  background: var(--btx-chat-paper);
  scrollbar-width: none;
}

.btx-assistant__quick::-webkit-scrollbar {
  display: none;
}

.btx-assistant__chip {
  min-height: 31px;
  padding: 6px 10px;
  flex: 0 0 auto;
  border: 1px solid rgba(112, 42, 85, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--btx-chat-plum-dark);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.btx-assistant__chip:hover {
  border-color: var(--btx-chat-plum);
  background: #fbf2ea;
}

.btx-assistant__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 11px;
  border-top: 1px solid var(--btx-chat-line);
  background: #fff;
}

.btx-assistant__input {
  width: 100%;
  min-height: 42px;
  max-height: 96px;
  resize: none;
  padding: 10px 11px;
  border: 1px solid rgba(87, 61, 70, 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--btx-chat-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
}

.btx-assistant__input::placeholder {
  color: #948a84;
}

.btx-assistant__send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--btx-chat-plum);
  color: #fff;
  cursor: pointer;
}

.btx-assistant__send svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.btx-assistant button:disabled,
.btx-assistant textarea:disabled {
  cursor: wait;
  opacity: 0.62;
}

.btx-assistant__privacy {
  margin: 0;
  padding: 0 12px 10px;
  background: #fff;
  color: #857a74;
  font-size: 0.66rem;
  line-height: 1.35;
}

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

@media (max-width: 680px) {
  .btx-assistant {
    right: 12px;
    bottom: max(13px, env(safe-area-inset-bottom));
  }

  .btx-assistant__launcher {
    width: 60px;
    height: 60px;
  }

  .btx-assistant__launcher-avatar {
    width: 50px;
    height: 50px;
  }

  .btx-assistant__launcher-label {
    display: none;
  }

  .btx-assistant__panel {
    position: fixed;
    right: 10px;
    bottom: calc(79px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    height: min(610px, calc(var(--btx-chat-visual-height) - 98px - env(safe-area-inset-bottom)));
    max-height: none;
    border-radius: 20px;
    transform-origin: bottom center;
  }

  .btx-assistant.is-keyboard-open .btx-assistant__panel {
    top: calc(var(--btx-chat-visual-top) + 8px);
    right: 8px;
    bottom: auto;
    left: 8px;
    height: calc(var(--btx-chat-visual-height) - 16px);
    min-height: 0;
    border-radius: 16px;
    transform-origin: center;
  }

  .btx-assistant.is-keyboard-open .btx-assistant__header {
    min-height: 62px;
    padding-block: 8px;
  }

  .btx-assistant.is-keyboard-open .btx-assistant__quick,
  .btx-assistant.is-keyboard-open .btx-assistant__privacy {
    display: none;
  }

  .btx-assistant.is-keyboard-open .btx-assistant__launcher {
    opacity: 0;
    pointer-events: none;
  }

  .btx-assistant__bubble {
    max-width: 86%;
  }

  .btx-assistant__privacy {
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .btx-assistant__panel {
    height: calc(100dvh - 24px);
    bottom: 12px;
  }

  .btx-assistant.is-open .btx-assistant__launcher {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btx-assistant__launcher,
  .btx-assistant__launcher-label,
  .btx-assistant__panel {
    transition: none;
  }
}
