.bb-chat {
  --bb-dark: #1d261d;
  --bb-olive: #385136;
  --bb-cream: #fbf8ef;
  --bb-line: #e1e1d4;
  --bb-accent: #f5ce77;
  position: fixed;
  z-index: 100000;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 10px;
  font: 15px/1.45 system-ui, -apple-system, sans-serif;
  color: var(--bb-dark);
}
.bb-chat *, .bb-chat *::before, .bb-chat *::after { box-sizing: border-box; }
.bb-chat [hidden] { display: none !important; }
.bb-chat button { font: inherit; font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: normal; }
.bb-chat button:disabled { cursor: wait; opacity: .65; }
.bb-chat button:focus-visible, .bb-chat input:focus-visible, .bb-chat a:focus-visible { outline: 3px solid #a85e20; outline-offset: 2px; }
.bb-chat a { color: #324f33; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.bb-chat .bb-chat-launch {
  display: inline-flex; align-items: center; gap: 9px; padding: 11px 16px; min-height: 48px;
  color: #fff; background: var(--bb-dark); border: 1px solid #52634a; border-radius: 999px;
  box-shadow: 0 6px 20px #13191139;
}
.bb-chat-launch svg { width: 24px; height: 24px; stroke: var(--bb-accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bb-chat .bb-chat-panel {
  display: flex; flex-direction: column; width: min(370px, calc(100vw - 36px)); height: min(550px, calc(100dvh - 105px));
  background: var(--bb-cream); border: 1px solid var(--bb-line); border-radius: 20px;
  overflow: hidden; box-shadow: 0 16px 50px #1820163d;
}
.bb-chat-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 13px; flex-shrink: 0;
  background: var(--bb-dark); color: #fff;
}
.bb-chat-logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  color: #233121; background: var(--bb-accent); font-size: 14px; font-weight: 900;
}
.bb-chat-brand { flex: 1; min-width: 0; }
.bb-chat-brand strong { display: block; font-size: 16px; color: #fff; }
.bb-chat-status { display: block; font-size: 12px; color: #ecdfb9; }
.bb-chat .bb-chat-dismiss {
  padding: 0; width: 40px; min-height: 40px; border: 1px solid #64725e; border-radius: 50%;
  background: transparent; color: #fff; font-size: 24px; line-height: 1;
}
.bb-chat-log { display: flex; flex-direction: column; gap: 9px; flex: 1; overflow-y: auto; min-height: 0; padding: 14px 13px 10px; }
.bb-chat-message {
  align-self: flex-start; max-width: 92%; padding: 9px 11px; border-radius: 11px 11px 11px 3px;
  background: #fff; border: 1px solid var(--bb-line); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--bb-dark);
}
.bb-chat-message p { margin: 0; font: inherit; color: inherit; }
.bb-chat-message a { display: inline-block; margin-top: 5px; }
.bb-chat-message strong { display: block; font-size: 12px; margin-bottom: 2px; }
.bb-chat .bb-chat-message-customer { align-self: flex-end; border-radius: 11px 11px 3px 11px; background: var(--bb-olive); color: #fff; border-color: var(--bb-olive); }
.bb-chat .bb-chat-message-system { background: #f9e9c4; border-color: #eddaa7; }
.bb-chat .bb-chat-message-team { background: #eef3e9; border-color: #c3d2bb; }
.bb-chat-quick { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 13px 9px; }
.bb-chat .bb-chat-quick button, .bb-chat .bb-chat-human, .bb-chat .bb-chat-resume, .bb-chat .bb-chat-retry, .bb-chat .bb-chat-restart {
  background: #fff; color: #31472d; border: 1px solid #a8b59e; border-radius: 9px; padding: 6px 9px; min-height: 33px; font-size: 12px;
}
.bb-chat .bb-chat-human, .bb-chat .bb-chat-resume, .bb-chat .bb-chat-restart { width: 100%; margin-bottom: 6px; min-height: 38px; }
.bb-chat .bb-chat-retry { margin-bottom: 6px; }
.bb-chat .bb-chat-waiting-hint { margin: 0 0 5px; font-size: 12px; color: #50584a; }
.bb-chat-bottom { border-top: 1px solid var(--bb-line); padding: 9px 13px; background: #fffdf7; }
.bb-chat .bb-chat-form { display: flex; align-items: center; gap: 6px; margin: 0; }
.bb-chat .bb-chat-form input {
  flex: 1; width: 0; min-height: 41px; padding: 8px; margin: 0; border: 1px solid #aeb9a5; border-radius: 8px;
  background: #fff; color: var(--bb-dark); font: inherit; font-size: 16px;
}
.bb-chat .bb-chat-form button { padding: 7px 12px; min-height: 41px; background: var(--bb-olive); color: #fff; border: 0; border-radius: 8px; }
.bb-chat-notice, .bb-chat .bb-chat-error { font-size: 11px; line-height: 1.35; margin: 6px 0 0; color: #50584a; }
.bb-chat .bb-chat-error { color: #852b1c; margin: 0 0 6px; }
@media (max-width: 480px) {
  .bb-chat { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
  .bb-chat .bb-chat-panel { width: min(370px, calc(100vw - 20px)); height: min(520px, calc(100dvh - 80px)); }
}
