.chat {
  max-height: calc(100dvh - max(10px, var(--bb-safe-top, 0px)) - max(10px, var(--bb-safe-bottom, 0px)));
  transform: scale(.965);
  transform-origin: 100% 100%;
}
.chat.open { transform: scale(1); }
.chat .chat-stage { min-height: 0; }
.chat .chat-intake { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat .chat-conversation { min-height: 0; overflow: hidden; }
.chat .messages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat .chat-start-form { display: block; }
.chat-channel-choice { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
.chat-channel-choice legend { width: 100%; margin-bottom: 7px; color: #555; font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.chat-channel-choice > label { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) 18px; gap: 10px; align-items: center; min-height: 68px; margin: 0; padding: 11px 12px; border: 1px solid #cbc9c2; border-radius: 7px; background: rgba(255, 255, 255, .54); color: #111; cursor: pointer; }
.chat-channel-choice > label:hover { border-color: #8b8a84; background: #fff; }
.chat-channel-choice > label:has(input:checked) { border-color: #151515; background: #111; color: #fff; box-shadow: 0 8px 25px rgba(0, 0, 0, .12); }
.chat-channel-choice input { width: 17px; height: 17px; margin: 0; padding: 0; accent-color: #6fd697; }
.chat-channel-choice span { display: flex; min-width: 0; flex-direction: column; }
.chat-channel-choice b { font-size: 11px; }
.chat-channel-choice small { margin-top: 4px; color: #626560; font-size: 9px; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: 0; }
.chat-channel-choice label:has(input:checked) small { color: #aaa; }
.chat-channel-choice > label > i { font-style: normal; }
.chat-channel-state { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 9px 18px; border-bottom: 1px solid #d6d4ce; background: #e8e7e1; }
.chat-channel-state > span { display: flex; min-width: 0; flex-direction: column; }
.chat-channel-state small { color: #5d605c; font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.chat-channel-state b { margin-top: 2px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-channel-state button { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #bbb9b2; border-radius: 5px; background: transparent; color: #444; font-size: 8px; font-weight: 700; cursor: pointer; }
.chat[data-channel="human"] header .status { background: #6fd697; box-shadow: 0 0 0 5px rgba(111, 214, 151, .1); }
.chat[data-channel="human"] .messages { background: linear-gradient(#f0efea, #e8e7e2); }
.chat[data-channel="human"] .quick { display: none !important; }
.chat .bot[data-human-agent="true"] { border: 1px solid rgba(38, 117, 76, .14); border-left: 3px solid #5fca89; }
.chat .bot .chat-message-meta, .chat .user-msg .chat-message-meta { display: block; margin-top: 5px; color: #626560; font-size: 7px; }
.chat .user-msg .chat-message-meta { color: #aaa; text-align: right; }
.chat .user-msg.is-pending { opacity: .7; }
.chat .user-msg.is-failed { outline: 1px solid #c85c57; }
.chat-human-status { min-height: 14px; margin: 0; padding: 4px 20px 7px; color: #755a1b; background: #e8e7e2; font-size: 8px; text-align: center; }
.chat-human-status[data-tone="closed"] { padding-block: 9px; color: #3e4240; background: #dedfdc; font-weight: 700; letter-spacing: .02em; }
.chat[data-channel="human"] .chat-reset { font-weight: 700; }
.chat[data-channel="human"]:not(.is-human-closed) .chat-reset { color: #7b342d; }
.chat.is-human-closed .chat-message-form { background: #e3e4e1; }
.chat.is-human-closed .chat-message-form input { color: #656965; cursor: not-allowed; }
.chat.is-human-closed .chat-message-form button { opacity: .45; cursor: not-allowed; }
.chat-channel-choice input:focus-visible, .chat-channel-state button:focus-visible { outline: 3px solid #58bf7f; outline-offset: 3px; }
.chat-human-turnstile { min-height: 65px; margin: 4px 0 12px; }
.chat-human-turnstile[hidden] { display: none !important; }
.chat .demo { color: #626560; }
.chat-network-status { flex: 0 0 auto; margin: 0; padding: 9px 18px; border-bottom: 1px solid #cfc8aa; background: #fff6d8; color: #594815; font-size: 9px; font-weight: 650; line-height: 1.45; text-align: center; }
.chat-network-status[hidden] { display: none !important; }
.chat.is-ai-conversation-loading .chat-message-form input { cursor: progress; }
.chat.is-ai-conversation-loading .chat-message-form button { cursor: progress; opacity: .58; }

.chat-ai-history[hidden], .chat-ai-history__panel[hidden] { display: none !important; }
.chat-ai-history { position: relative; z-index: 2; flex: 0 0 auto; border-bottom: 1px solid #d5d4cf; background: #f5f4f0; }
.chat-ai-history__toolbar { display: flex; min-height: 52px; align-items: center; padding: 4px 18px; }
.chat-ai-history__toggle { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; padding: 5px 11px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: #454743; font: 700 9px/1.2 DM Sans, sans-serif; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.chat-ai-history__toggle:hover, .chat-ai-history__toggle[aria-expanded="true"] { border-color: #c6c9c4; background: #fff; color: #111; }
.chat-ai-history__toggle small { display: grid; min-width: 18px; height: 18px; place-items: center; border-radius: 50%; background: #19231d; color: #dff4e7; font-size: 8px; letter-spacing: 0; }
.chat-ai-history__toggle small:empty { display: none; }
.chat-ai-history__panel { max-height: min(320px, 42dvh); overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 14px; border-top: 1px solid #dcdbd6; background: #eeede8; scrollbar-width: thin; }
.chat-ai-history__heading { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 10px; background: linear-gradient(#eeede8 82%, rgba(238, 237, 232, 0)); }
.chat-ai-history__heading > b { color: #151715; font: 650 14px/1.2 Manrope, sans-serif; letter-spacing: -.02em; }
.chat-ai-history__new { min-height: 44px; padding: 7px 12px; border: 0; border-radius: 5px; background: #17231c; color: #f1f6f2; font: 700 9px/1 DM Sans, sans-serif; cursor: pointer; }
.chat-ai-history__policy { margin: 0 4px 10px; color: #686b67; font-size: 9px; line-height: 1.55; }
.chat-ai-history__status { min-height: 0; margin: 0 4px 8px; color: #59605b; font-size: 9px; line-height: 1.45; }
.chat-ai-history__status:empty { display: none; }
.chat-ai-history__status[data-tone="error"] { color: #9a3731; }
.chat-ai-history__list { display: grid; gap: 7px; }
.chat-ai-history__empty { margin: 0; padding: 17px 12px; border: 1px dashed #c4c5c0; border-radius: 7px; color: #6a6c68; background: rgba(255, 255, 255, .42); font-size: 10px; line-height: 1.5; text-align: center; }
.chat-ai-history__item { display: grid; grid-template-columns: minmax(0, 1fr); align-items: stretch; border: 1px solid #d0d1cc; border-radius: 7px; background: rgba(255, 255, 255, .68); overflow: hidden; }
.chat-ai-history__open { display: grid; min-width: 0; min-height: 44px; gap: 5px; padding: 10px 11px; border: 0; background: transparent; color: #171917; text-align: left; cursor: pointer; }
.chat-ai-history__open:hover { background: #fff; }
.chat-ai-history__open[aria-current="true"] { box-shadow: inset 3px 0 #57be7e; background: #f7fff9; }
.chat-ai-history__open > span:first-child { display: grid; min-width: 0; gap: 3px; }
.chat-ai-history__open b, .chat-ai-history__open small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ai-history__open b { font-size: 10px; }
.chat-ai-history__open small { color: #6f716d; font-size: 8px; }
.chat-ai-history__open > span:last-child { color: #5e615d; font-size: 7px; }
.chat-ai-history__actions { display: flex; justify-content: flex-end; gap: 2px; padding: 3px 5px; border-top: 1px solid #dedfda; }
.chat-ai-history__actions button, .chat-ai-history__actions a { display: grid; min-height: 44px; place-items: center; padding: 5px 7px; border: 0; border-radius: 4px; background: transparent; color: #555954; font: 650 7px/1 DM Sans, sans-serif; text-align: center; text-decoration: none; cursor: pointer; }
.chat-ai-history__actions button:hover, .chat-ai-history__actions a:hover { background: #e4e7e3; color: #101210; }
.chat-ai-history__actions button[data-ai-delete] { color: #943c36; }
.chat-ai-history[aria-busy="true"] { opacity: .78; }
.chat-ai-history button:disabled { cursor: wait; opacity: .55; }
.chat-ai-history button:focus-visible, .chat-ai-history a:focus-visible { outline: 3px solid #58bf7f; outline-offset: 2px; }
.chat.is-offline .chat-ai-history__toggle::before { width: 6px; height: 6px; border-radius: 50%; background: #bd574f; content: ''; }
.chat .bot[data-ai-message="true"] { border-left: 3px solid #6e8074; }
.chat.has-ai-account-history .messages { min-height: 120px; }

.newsletter-link-status { position: fixed; z-index: 260; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; width: min(470px, calc(100vw - 36px)); grid-template-columns: 42px minmax(0, 1fr) 38px; gap: 13px; align-items: start; padding: 16px; border: 1px solid rgba(224, 239, 229, .18); border-radius: 13px; outline: 0; background: #101713; color: #f4f6f2; box-shadow: 0 24px 70px rgba(0, 0, 0, .34); }
.newsletter-link-status[hidden] { display: none !important; }
.newsletter-link-status__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #dff7e8; color: #165f37; font: 800 19px/1 Manrope, sans-serif; }
.newsletter-link-status[data-tone="error"] .newsletter-link-status__icon { background: #f8dfdc; color: #8e302b; }
.newsletter-link-status small { display: block; margin: 2px 0 5px; color: #90a097; font-size: 8px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.newsletter-link-status h2 { margin: 0; font: 650 16px/1.2 Manrope, sans-serif; letter-spacing: -.025em; }
.newsletter-link-status p { margin: 7px 0 0; color: #b3beb7; font-size: 10px; line-height: 1.55; }
.newsletter-link-status[data-tone="success"] p { color: #a9dfbd; }
.newsletter-link-status[data-tone="error"] p { color: #f2aaa5; }
.newsletter-link-status__close { display: grid; width: 38px; height: 38px; place-items: center; padding: 0; border: 1px solid rgba(255, 255, 255, .14); border-radius: 50%; background: transparent; color: #eef2ed; font: 400 20px/1 Arial, sans-serif; cursor: pointer; }
.newsletter-link-status__close:hover { border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .06); }
.newsletter-link-status:focus-visible, .newsletter-link-status__close:focus-visible { outline: 3px solid rgba(111, 214, 151, .55); outline-offset: 3px; }

@media (max-width: 480px) {
  .chat-channel-choice > label { min-height: 62px; }
  .chat-channel-state { padding-inline: 14px; }
  .newsletter-link-status { right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: calc(100vw - 20px); grid-template-columns: 38px minmax(0, 1fr) 34px; gap: 10px; padding: 13px; }
  .newsletter-link-status__icon { width: 38px; height: 38px; }
  .newsletter-link-status__close { width: 34px; height: 34px; }
  .chat-ai-history__toolbar { padding-inline: 12px; }
  .chat-ai-history__panel { max-height: min(285px, 40dvh); padding-inline: 10px; }
  .chat-ai-history__toggle, .chat-ai-history__new, .chat-ai-history__actions button, .chat-ai-history__actions a { min-height: 44px; }
}

@media (max-width: 340px) {
  .chat-ai-history__heading { align-items: flex-start; flex-direction: column; }
  .chat-ai-history__new { width: 100%; }
  .chat-ai-history__actions { justify-content: stretch; }
  .chat-ai-history__actions button, .chat-ai-history__actions a { flex: 1; padding-inline: 3px; }
}

@media (min-width: 1200px) and (min-height: 800px) {
  .chat-ai-history__toolbar { min-height: 46px; padding-inline: 22px; }
  .chat-ai-history__toggle { font-size: 11px; }
  .chat-ai-history__panel { max-height: min(390px, 42dvh); padding: 6px 18px 18px; }
  .chat-ai-history__heading > b { font-size: 17px; }
  .chat-ai-history__new { min-height: 42px; font-size: 10px; }
  .chat-ai-history__policy, .chat-ai-history__status { font-size: 11px; }
  .chat-ai-history__open { min-height: 72px; padding: 13px 14px; }
  .chat-ai-history__open b { font-size: 12px; }
  .chat-ai-history__open small { font-size: 10px; }
  .chat-ai-history__open > span:last-child, .chat-ai-history__actions button, .chat-ai-history__actions a { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-channel-choice > label, .newsletter-link-status__close { transition: none !important; }
}
