/* AI consultant drawer and launcher. Extracted from storefront-live.css without changing rule order. */
body.has-cart-open .product-consultant-card,
body.has-cart-open .ai-chat-drawer {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.ai-chat-launcher {
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: var(--bodycare-z-ai-launcher, var(--bodycare-z-menu, 170));
  display: inline-flex;
  width: 58px;
  height: 58px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--pink);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 18px 34px rgba(var(--theme-accent-rgb), 0.28);
}

.ai-chat-launcher svg {
  width: 24px;
  height: 24px;
}

.ai-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--bodycare-z-ai-backdrop, calc(var(--bodycare-z-ai, 730) - 1));
  background:
    linear-gradient(90deg, rgba(37, 12, 29, 0.42), rgba(17, 17, 17, 0.28));
  opacity: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: opacity 220ms ease;
}

.ai-chat-backdrop.is-visible {
  opacity: 1;
}

.ai-chat-backdrop[hidden] {
  display: none;
}

.ai-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--bodycare-z-ai, 730);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(500px, 100%);
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-left: 1px solid rgba(var(--theme-accent-rgb), 0.14);
  border-radius: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--pink-soft) 78%, #ffffff) 0%, #ffffff 26%, #ffffff 100%);
  opacity: 0;
  box-shadow:
    -26px 24px 80px rgba(41, 14, 31, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.72) inset;
  pointer-events: none;
  transform: translateX(104%);
  visibility: hidden;
  transition:
    transform 220ms ease,
    opacity 160ms ease,
    visibility 0s linear 220ms;
  will-change: transform, opacity;
}

.ai-chat-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
  transition:
    transform 220ms ease,
    opacity 160ms ease;
}

.ai-chat-drawer[hidden] {
  display: none;
}

html.is-locked:has(body.has-ai-chat-open) {
  overflow: hidden;
  overscroll-behavior: none;
}

body.has-ai-chat-open {
  overflow: hidden;
  overscroll-behavior: none;
}

:is(html, body).is-resizing .ai-chat-drawer,
:is(html, body).is-resizing .ai-chat-backdrop {
  transition: none;
}

.ai-chat-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(var(--theme-accent-rgb), 0.12);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.ai-chat-head > div {
  display: flex;
  min-height: 44px;
  align-items: center;
}

.ai-chat-head__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.ai-chat-head .eyebrow {
  margin: 0;
  color: var(--pink);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.ai-chat-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
  color: #171116;
  font-size: 14px;
  font-weight: 950;
  line-height: 1.04;
  text-transform: uppercase;
}

.ai-chat-head .icon-button {
  flex: 0 0 auto;
  border: 1px solid rgba(17, 17, 17, 0.08);
  background: #ffffff;
  color: #171116;
}

.ai-chat-head .icon-button:hover {
  border-color: rgba(var(--theme-accent-rgb), 0.28);
  color: var(--pink);
}

.ai-chat-messages {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 22px 24px 18px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--pink-soft) 62%, #ffffff) 0%, rgba(255, 255, 255, 0.96) 42%, #ffffff 100%);
  scrollbar-color: rgba(var(--theme-accent-rgb), 0.35) transparent;
}

.ai-chat-message {
  flex: 0 0 auto;
  max-width: 86%;
  min-height: auto;
  padding: 16px 18px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.52;
  overflow: visible;
}

.ai-chat-message p {
  margin: 0;
}

.ai-chat-recommendations {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ai-chat-product {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  min-width: min(320px, 100%);
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  text-decoration: none;
}

.ai-chat-product__media {
  display: block;
  min-height: 112px;
  background: color-mix(in srgb, var(--pink-soft) 72%, #ffffff);
}

.ai-chat-product__media img {
  width: 100%;
  height: 100%;
  min-height: 112px;
  object-fit: cover;
}

.ai-chat-product__body {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  padding: 10px 12px 10px 0;
}

.ai-chat-product__body span {
  overflow: hidden;
  color: #8d7f88;
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ai-chat-product__body strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink, #111111);
  font-size: 15px;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ai-chat-product__body em {
  display: -webkit-box;
  overflow: hidden;
  color: #5a5056;
  font-size: 13px;
  font-style: normal;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ai-chat-product__body b {
  color: var(--pink);
  font-size: 16px;
  line-height: 1;
}

.ai-chat-product:hover {
  border-color: rgba(var(--theme-accent-rgb), 0.38);
  box-shadow: 0 10px 24px rgba(41, 14, 31, 0.08);
}

.ai-chat-message--bot {
  position: relative;
  align-self: flex-start;
  justify-self: start;
  border: 1px solid rgba(var(--theme-accent-rgb), 0.18);
  background: linear-gradient(180deg, #ffffff 0%, color-mix(in srgb, var(--pink-soft) 42%, #ffffff) 100%);
  color: #4f454b;
  box-shadow: 0 16px 32px rgba(41, 14, 31, 0.06);
}

.ai-chat-message--user {
  align-self: flex-end;
  justify-self: end;
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(var(--theme-accent-rgb), 0.2);
}

.ai-chat-status {
  min-height: 24px;
  padding: 0 22px;
  color: #8d7f88;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.ai-chat-status.is-error {
  color: #b52561;
}

.ai-chat-quick {
  display: grid;
  gap: 8px;
  padding: 16px 24px 12px;
  border-top: 1px solid rgba(var(--theme-accent-rgb), 0.1);
  background: rgba(255, 255, 255, 0.94);
}

.ai-chat-quick[hidden],
.ai-chat-quick.is-hidden {
  display: none;
}

.ai-chat-quick button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid rgba(var(--theme-accent-rgb), 0.12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #ffffff 0%, color-mix(in srgb, var(--pink-soft) 42%, #ffffff) 100%);
  color: #2b2529;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(41, 14, 31, 0.035);
  transition:
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.ai-chat-quick button::after {
  color: #9d8f98;
  font-size: 20px;
  line-height: 1;
  content: "\203A";
}

.ai-chat-quick button:hover {
  border-color: rgba(var(--theme-accent-rgb), 0.38);
  color: var(--pink);
  box-shadow: 0 12px 24px rgba(var(--theme-accent-rgb), 0.08);
  transform: translateY(-1px);
}

.ai-chat-form {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 54px;
  gap: 10px;
  margin-top: 8px;
  padding: 14px 24px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(17, 17, 17, 0.06);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -18px 36px rgba(41, 14, 31, 0.055);
}

.ai-chat-form label {
  display: grid;
  min-width: 0;
}

.ai-chat-form label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ai-chat-form input {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(var(--theme-accent-rgb), 0.18);
  border-radius: var(--radius-pill, 999px);
  padding: 0 18px;
  background: linear-gradient(180deg, #ffffff 0%, color-mix(in srgb, var(--pink-soft) 42%, #ffffff) 100%);
  color: var(--ink, #111111);
  font: inherit;
  font-size: 16px;
  font-weight: 750;
  outline: 0;
}

.ai-chat-form input:focus {
  border-color: var(--pink);
  background: #ffffff;
  box-shadow:
    0 0 0 3px rgba(var(--theme-accent-rgb), 0.12),
    0 12px 22px rgba(41, 14, 31, 0.06);
}

.ai-chat-form button {
  display: inline-flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(var(--theme-accent-rgb), 0.24);
  transition:
    box-shadow 160ms ease,
    transform 160ms ease;
}

.ai-chat-form .ai-chat-voice {
  border: 1px solid rgba(var(--theme-accent-rgb), 0.2);
  background: #ffffff;
  color: var(--pink);
  box-shadow: 0 10px 20px rgba(41, 14, 31, 0.045);
}

.ai-chat-form .ai-chat-voice.is-recording {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-dark) 100%);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(var(--theme-accent-rgb), 0.2);
}

.ai-chat-form button svg {
  width: 22px;
  height: 22px;
}

.ai-chat-form button:disabled,
.ai-chat-form input:disabled {
  cursor: wait;
  opacity: 0.62;
}

/* AI consultant accent elements. */
.ai-chat-drawer::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1;
  height: 4px;
  background: linear-gradient(90deg, var(--pink) 0%, var(--pink-dark) 52%, var(--pink) 100%);
  content: "";
}

.ai-chat-head__title {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 12px;
}

.ai-chat-head__mark {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(var(--theme-accent-rgb), 0.72);
  box-shadow: none;
}

.ai-chat-head__mark svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.4;
}

.ai-chat-form button:hover {
  box-shadow: 0 18px 34px rgba(var(--theme-accent-rgb), 0.3);
  transform: translateY(-1px);
}

@media (max-width: 720px) {
  .ai-chat-drawer {
    border: 0;
  }

  .ai-chat-head__mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }
}

body.has-ai-chat-open .bottom-nav,
body.product-page.has-ai-chat-open .product-purchase,
body.has-ai-chat-open .ai-chat-launcher {
  opacity: 0;
  pointer-events: none;
}

body.has-ai-chat-keyboard .ai-chat-quick {
  display: none;
}

@media (max-width: 1279px) {
  .ai-chat-launcher {
    display: none;
  }
}

@media (max-width: 720px) {
  .ai-chat-launcher {
    right: 18px;
    bottom: calc(118px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
  }

  body.home-page .ai-chat-launcher {
    right: 18px;
    bottom: calc(250px + env(safe-area-inset-bottom));
  }

  .ai-chat-drawer {
    top: var(--ai-chat-viewport-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--ai-chat-viewport-height, 100dvh);
    min-height: var(--ai-chat-viewport-height, 100svh);
    max-height: var(--ai-chat-viewport-height, 100dvh);
    border-radius: 0;
    box-shadow: 0 -20px 48px rgba(41, 14, 31, 0.22);
    overscroll-behavior: contain;
    transform: translateX(104%);
  }

  .ai-chat-head,
  .ai-chat-status,
  .ai-chat-quick,
  .ai-chat-form {
    flex: 0 0 auto;
  }

  .ai-chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: scroll;
  }

  .ai-chat-drawer.is-open {
    transform: translateX(0);
  }

  .ai-chat-head {
    padding: 18px 16px 14px;
  }

  .ai-chat-messages,
  .ai-chat-quick {
    padding-right: 16px;
    padding-left: 16px;
  }

  .ai-chat-form {
    grid-template-columns: minmax(0, 1fr) 50px 50px;
    margin-top: 0;
    padding-top: 10px;
    padding-right: 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    padding-left: 16px;
  }

  .ai-chat-form button {
    width: 50px;
    height: 50px;
  }

  body.has-ai-chat-keyboard .ai-chat-messages {
    padding-bottom: 12px;
  }
}

@media (min-width: 900px) and (max-width: 1279px) {
  body.product-page .ai-chat-launcher {
    bottom: calc(190px + env(safe-area-inset-bottom));
  }

  body.product-page.is-purchase-collapsed .ai-chat-launcher {
    bottom: calc(104px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 899px) {
  body.product-page .ai-chat-launcher {
    bottom: calc(174px + env(safe-area-inset-bottom));
  }

  body.product-page.is-purchase-collapsed .ai-chat-launcher {
    bottom: calc(118px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 1279px), (pointer: coarse) {
  .ai-chat-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .ai-chat-head {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .ai-chat-launcher {
    box-shadow: 0 8px 18px rgba(var(--theme-accent-rgb), 0.18);
  }

  .ai-chat-drawer {
    box-shadow: -10px 0 28px rgba(41, 14, 31, 0.12);
    will-change: auto;
  }

  .ai-chat-message--bot,
  .ai-chat-message--user,
  .ai-chat-quick button,
  .ai-chat-form,
  .ai-chat-form button,
  .ai-chat-form .ai-chat-voice.is-recording {
    box-shadow: none;
  }
}

/* Stability guards: long AI copy must not expand the drawer. */
.ai-chat-drawer,
.ai-chat-head,
.ai-chat-head__title,
.ai-chat-messages,
.ai-chat-message,
.ai-chat-message p,
.ai-chat-recommendations,
.ai-chat-product,
.ai-chat-product__body,
.ai-chat-status,
.ai-chat-quick,
.ai-chat-quick button,
.ai-chat-form,
.ai-chat-form label,
.ai-chat-form input {
  min-width: 0;
  max-width: 100%;
}

.ai-chat-drawer {
  overflow-x: hidden;
}

.ai-chat-head,
.ai-chat-status,
.ai-chat-quick button,
.ai-chat-form input {
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-chat-logo,
.ai-chat-message p,
.ai-chat-product__body span,
.ai-chat-product__body strong,
.ai-chat-product__body em,
.ai-chat-product__body b {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-chat-product__body b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-form button {
  flex: 0 0 auto;
}
