:root {
  --bud-chat-navy: #062c4f;
  --bud-chat-blue: #0b426f;
  --bud-chat-orange: #f36a21;
  --bud-chat-gold: #fcc401;
  --bud-chat-ink: #102a43;
  --bud-chat-muted: #60758a;
  --bud-chat-mist: #f3f7fa;
  --bud-chat-ring: rgba(6, 44, 79, 0.14);
}

.bud-chat,
.bud-chat * {
  box-sizing: border-box;
}

.bud-chat [hidden] {
  display: none !important;
}

.bud-chat {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  left: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 99999;
  font-family: Montserrat, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--bud-chat-ink);
}

.bud-chat button,
.bud-chat input {
  font: inherit;
}

.bud-chat__launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 7px 17px 7px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--bud-chat-navy);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(6, 44, 79, 0.28);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.bud-chat__launcher:hover {
  background: var(--bud-chat-blue);
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(6, 44, 79, 0.34);
}

.bud-chat__launcher:focus-visible,
.bud-chat button:focus-visible,
.bud-chat input:focus-visible,
.bud-chat a:focus-visible {
  outline: 3px solid var(--bud-chat-gold);
  outline-offset: 2px;
}

.bud-chat__launcher-mark,
.bud-chat__mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--bud-chat-gold);
  color: var(--bud-chat-navy);
  font-family: Georgia, serif;
  font-weight: 900;
  font-style: italic;
}

.bud-chat__launcher-mark {
  width: 36px;
  height: 36px;
  font-size: 25px;
}

.bud-chat__panel {
  position: absolute;
  right: 0;
  left: auto;
  bottom: 64px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - 112px);
  overflow: hidden;
  border: 1px solid var(--bud-chat-ring);
  border-radius: 22px;
  background: #fff;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  box-shadow: 0 26px 70px rgba(6, 44, 79, 0.24), 0 3px 12px rgba(6, 44, 79, 0.1);
  transition: opacity 180ms ease, transform 180ms ease;
}

.bud-chat.is-product .bud-chat__panel {
  height: min(610px, calc(100vh - 112px));
}

.bud-chat.is-open .bud-chat__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.bud-chat__header {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 68px;
  padding: 12px 14px;
  background: var(--bud-chat-navy);
  color: #fff;
}

.bud-chat__mark {
  width: 40px;
  height: 40px;
  font-size: 28px;
}

.bud-chat__header h2,
.bud-chat__header p {
  margin: 0;
  color: inherit;
}

.bud-chat__header h2 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.15;
}

.bud-chat__header p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
}

.bud-chat__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #62d98b;
  box-shadow: 0 0 0 3px rgba(98, 217, 139, 0.16);
}

.bud-chat__close {
  width: 36px;
  height: 36px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 27px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.bud-chat__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.bud-chat__back {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.bud-chat__back:hover {
  background: rgba(255, 255, 255, 0.2);
}

.bud-chat__menu {
  padding: 18px;
  background: linear-gradient(180deg, #f8fbfd 0, #fff 170px);
}

.bud-chat__menu-intro {
  margin: 0 0 12px;
  color: var(--bud-chat-ink);
  font-size: 14px;
  font-weight: 700;
}

.bud-chat__choice {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  margin: 0 0 10px;
  padding: 13px;
  border: 1px solid var(--bud-chat-ring);
  border-radius: 15px;
  background: #fff;
  color: var(--bud-chat-ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(6, 44, 79, 0.06);
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.bud-chat__choice:hover {
  border-color: rgba(243, 106, 33, 0.62);
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(6, 44, 79, 0.1);
}

.bud-chat__choice:disabled {
  cursor: wait;
  opacity: 0.62;
}

.bud-chat__choice-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(252, 196, 1, 0.2);
  color: var(--bud-chat-navy);
  font-size: 22px;
  font-weight: 900;
}

.bud-chat__choice-icon--support {
  background: rgba(243, 106, 33, 0.14);
  color: var(--bud-chat-orange);
}

.bud-chat__choice strong,
.bud-chat__choice small {
  display: block;
}

.bud-chat__choice strong {
  font-size: 13px;
  line-height: 1.25;
}

.bud-chat__choice small {
  margin-top: 3px;
  color: var(--bud-chat-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.35;
}

.bud-chat__choice-arrow {
  color: var(--bud-chat-orange);
  font-size: 18px;
  font-weight: 800;
}

.bud-chat__support-status,
.bud-chat__support-fallback,
.bud-chat__menu-note {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

.bud-chat__support-status {
  margin: 8px 3px;
  color: var(--bud-chat-ink);
}

.bud-chat__support-fallback {
  display: inline-block;
  margin: 0 3px 8px;
  color: var(--bud-chat-orange) !important;
  font-weight: 800;
  text-decoration: none !important;
}

.bud-chat__menu-note {
  margin: 13px 3px 0;
  color: var(--bud-chat-muted);
}

.bud-chat__product-view {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.bud-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #f8fbfd 0, #fff 150px);
  overscroll-behavior: contain;
}

.bud-chat__message {
  display: flex;
  margin-bottom: 11px;
}

.bud-chat__message--user {
  justify-content: flex-end;
}

.bud-chat__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 15px 15px 15px 4px;
  background: #fff;
  color: var(--bud-chat-ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.48;
  box-shadow: 0 2px 10px rgba(6, 44, 79, 0.08);
}

.bud-chat__message--user .bud-chat__bubble {
  border-radius: 15px 15px 4px 15px;
  background: var(--bud-chat-navy);
  color: #fff;
  box-shadow: none;
}

.bud-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 2px 0 12px;
}

.bud-chat__suggestions button {
  padding: 8px 10px;
  border: 1px solid rgba(6, 44, 79, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--bud-chat-navy);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.bud-chat__suggestions button:hover {
  border-color: var(--bud-chat-orange);
  color: var(--bud-chat-orange);
}

.bud-chat__products {
  display: grid;
  gap: 9px;
  margin: 2px 0 14px;
}

.bud-chat__product {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--bud-chat-ring);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(6, 44, 79, 0.06);
}

.bud-chat__product-image {
  position: relative;
  display: block;
  width: 76px;
  height: 76px;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  line-height: 0;
  isolation: isolate;
}

.bud-chat__product-image img {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
}

.bud-chat__product-body {
  min-width: 0;
}

.bud-chat__product-reason {
  margin: 0 0 3px;
  color: var(--bud-chat-orange);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bud-chat__product-title {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--bud-chat-ink) !important;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-decoration: none !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.bud-chat__product-title:hover {
  color: var(--bud-chat-orange) !important;
}

.bud-chat__product-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-size: 10px;
}

.bud-chat__product-meta strong {
  color: var(--bud-chat-navy);
  font-size: 13px;
}

.bud-chat__product-meta a,
.bud-chat__fallback {
  color: var(--bud-chat-orange) !important;
  font-weight: 800;
  text-decoration: none !important;
}

.bud-chat__fallback {
  display: inline-block;
  margin: 0 0 12px 4px;
  font-size: 12px;
}

.bud-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  padding: 11px 12px 7px;
  border-top: 1px solid var(--bud-chat-ring);
  background: #fff;
}

.bud-chat__form input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border: 1px solid rgba(6, 44, 79, 0.2);
  border-radius: 999px;
  background: var(--bud-chat-mist);
  color: var(--bud-chat-ink);
  font-size: 12px;
  font-weight: 500;
}

.bud-chat__form input::placeholder {
  color: #70859a;
  opacity: 1;
}

.bud-chat__form button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bud-chat-orange);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.bud-chat__form button:hover {
  background: #d95715;
}

.bud-chat__form button:disabled,
.bud-chat__form input:disabled {
  cursor: wait;
  opacity: 0.62;
}

.bud-chat__note {
  margin: 0;
  padding: 0 14px 10px;
  background: #fff;
  color: var(--bud-chat-muted);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.bud-chat__typing {
  display: flex;
  gap: 4px;
  align-items: center;
  min-height: 38px;
}

.bud-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bud-chat-muted);
  animation: bud-chat-bounce 900ms infinite ease-in-out;
}

.bud-chat__typing span:nth-child(2) { animation-delay: 120ms; }
.bud-chat__typing span:nth-child(3) { animation-delay: 240ms; }

@keyframes bud-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 767px) {
  .bud-chat {
    right: 12px;
    left: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .bud-chat__panel {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 70px));
    left: 10px;
    width: auto;
    height: auto;
    max-height: calc(100vh - 96px);
    border-radius: 18px;
    transform-origin: bottom right;
  }

  .bud-chat.is-product .bud-chat__panel {
    top: 10px;
    height: auto;
    max-height: none;
  }

  .bud-chat__launcher {
    min-height: 48px;
    padding-right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bud-chat__panel,
  .bud-chat__launcher {
    transition: none;
  }

  .bud-chat__typing span {
    animation: none;
  }
}
