:root {
  --mua-forest: #20301c;
  --mua-forest-soft: #31432b;
  --mua-cream: #fbf7ef;
  --mua-paper: #fffdf8;
  --mua-border: #e4dac8;
  --mua-gold: #b98e52;
  --mua-ink: #2a2620;
  --mua-muted: #6c6255;
  --mua-danger: #8c2f25;
  --mua-success: #2f6a3a;
  --mua-shadow: 0 22px 70px rgba(32, 48, 28, 0.22);
}

.mua-root,
.mua-root * {
  box-sizing: border-box;
}

.mua-root {
  position: fixed;
  inset: auto max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) auto;
  z-index: 2147482000;
  color: var(--mua-ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

.mua-root button,
.mua-root input,
.mua-root textarea {
  font: inherit;
}

.mua-root button {
  -webkit-tap-highlight-color: transparent;
}

.mua-root [hidden] {
  display: none !important;
}

.mua-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 18px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: var(--mua-forest);
  color: var(--mua-cream);
  box-shadow: 0 12px 34px rgba(32, 48, 28, 0.28);
  cursor: pointer;
}

.mua-launcher:hover {
  background: var(--mua-forest-soft);
}

.mua-launcher:focus-visible,
.mua-root button:focus-visible,
.mua-root input:focus-visible,
.mua-root textarea:focus-visible {
  outline: 3px solid rgba(185, 142, 82, 0.48);
  outline-offset: 3px;
}

.mua-launcher__mark,
.mua-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, #caa36f, var(--mua-gold));
  color: #fffdf8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
}

.mua-launcher__label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mua-nudge {
  position: absolute;
  right: 0;
  bottom: 70px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(290px, calc(100vw - 36px));
  padding: 13px 12px 13px 16px;
  border: 1px solid var(--mua-border);
  border-radius: 16px;
  background: var(--mua-paper);
  box-shadow: var(--mua-shadow);
  cursor: pointer;
}

.mua-nudge::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -7px;
  width: 13px;
  height: 13px;
  border-right: 1px solid var(--mua-border);
  border-bottom: 1px solid var(--mua-border);
  background: var(--mua-paper);
  transform: rotate(45deg);
}

.mua-nudge__text {
  flex: 1;
  font-weight: 650;
}

.mua-nudge__close,
.mua-icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: currentColor;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.mua-nudge__close {
  width: 34px;
  height: 34px;
  font-size: 21px;
  color: var(--mua-muted);
}

.mua-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  width: min(410px, calc(100vw - 36px));
  height: min(700px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid rgba(185, 142, 82, 0.38);
  border-radius: 22px;
  background: var(--mua-cream);
  box-shadow: var(--mua-shadow);
}

.mua-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 14px 14px 16px;
  background: var(--mua-forest);
  color: var(--mua-cream);
}

.mua-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.mua-avatar {
  width: 42px;
  height: 42px;
  font-size: 20px;
}

.mua-identity__text {
  min-width: 0;
}

.mua-title,
.mua-subtitle,
.mua-footer,
.mua-lead-form__title,
.mua-lead-form__hint,
.mua-error__text,
.mua-success {
  margin: 0;
}

.mua-title {
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mua-subtitle {
  margin-top: 2px;
  overflow: hidden;
  color: rgba(251, 247, 239, 0.74);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mua-transcript {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 12px;
  scrollbar-color: rgba(32, 48, 28, 0.28) transparent;
}

.mua-message {
  display: flex;
  margin-bottom: 12px;
}

.mua-message--user {
  justify-content: flex-end;
}

.mua-message__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border: 1px solid var(--mua-border);
  border-radius: 16px 16px 16px 5px;
  background: var(--mua-paper);
  color: var(--mua-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mua-message--user .mua-message__bubble {
  border-color: transparent;
  border-radius: 16px 16px 5px 16px;
  background: var(--mua-forest);
  color: var(--mua-cream);
}

.mua-message__meta {
  align-self: flex-end;
  margin: 0 4px 2px;
  color: var(--mua-muted);
  font-size: 11px;
}

.mua-status {
  min-height: 20px;
  padding: 0 16px;
  color: var(--mua-muted);
  font-size: 12px;
}

.mua-root[data-busy="true"] .mua-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--mua-gold);
  animation: mua-pulse 1s ease-in-out infinite;
}

.mua-composer {
  padding: 10px 12px 8px;
  border-top: 1px solid var(--mua-border);
  background: var(--mua-paper);
}

.mua-composer__input {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  padding: 12px 13px;
  border: 1px solid var(--mua-border);
  border-radius: 14px;
  background: #fff;
  color: var(--mua-ink);
}

.mua-composer__input::placeholder {
  color: #8a8175;
}

.mua-composer__controls,
.mua-lead-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 9px;
}

.mua-uopd-link {
  width: 100%;
  color: var(--mua-forest);
  font-size: 13px;
  line-height: 1.4;
  text-align: right;
}

.mua-primary-button,
.mua-secondary-button,
.mua-send-button {
  min-height: 44px;
  padding: 9px 15px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mua-primary-button,
.mua-send-button {
  border: 1px solid var(--mua-forest);
  background: var(--mua-forest);
  color: var(--mua-cream);
}

.mua-primary-button:hover,
.mua-send-button:hover {
  background: var(--mua-forest-soft);
}

.mua-secondary-button {
  border: 1px solid var(--mua-border);
  background: var(--mua-cream);
  color: var(--mua-ink);
}

.mua-root button:disabled,
.mua-root textarea:disabled {
  cursor: wait;
  opacity: 0.58;
}

.mua-footer {
  padding: 0 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--mua-paper);
  color: var(--mua-muted);
  font-size: 11px;
}

.mua-error {
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid rgba(140, 47, 37, 0.28);
  border-radius: 14px;
  background: #fff4f1;
  color: var(--mua-danger);
}

.mua-error .mua-secondary-button {
  margin-top: 8px;
}

.mua-lead-region {
  max-height: 52dvh;
  overflow-y: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--mua-border);
  background: #f7f0e4;
}

.mua-lead-form__title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
}

.mua-lead-form__hint {
  margin-top: 4px;
  color: var(--mua-muted);
  font-size: 12px;
}

.mua-lead-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.mua-field {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.mua-lead-form__grid .mua-field {
  margin-top: 0;
}

.mua-field__label {
  color: var(--mua-muted);
  font-size: 12px;
  font-weight: 700;
}

.mua-field__input {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--mua-border);
  border-radius: 11px;
  background: #fff;
  color: var(--mua-ink);
}

.mua-field__textarea {
  resize: vertical;
}

.mua-lead-form > .mua-primary-button {
  width: 100%;
  margin-top: 12px;
}

.mua-success {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(47, 106, 58, 0.28);
  border-radius: 12px;
  background: #eef8ef;
  color: var(--mua-success);
  font-weight: 700;
}

@keyframes mua-pulse {
  0%, 100% { opacity: 0.42; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (max-width: 640px) {
  html.mua-widget-open,
  html.mua-widget-open body {
    overflow: hidden;
  }

  .mua-root {
    inset: auto max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) auto;
  }

  .mua-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .mua-header {
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .mua-lead-form__grid {
    grid-template-columns: 1fr;
  }

  .mua-launcher__label {
    display: none;
  }

  .mua-launcher {
    width: 58px;
    height: 58px;
    padding: 8px;
  }

  .mua-launcher__mark {
    width: 40px;
    height: 40px;
  }
}

.mua-root[data-preview-mode="mobile"] .mua-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  border: 0;
  border-radius: 0;
}

.mua-root[data-preview-mode="mobile"] .mua-lead-form__grid {
  grid-template-columns: 1fr;
}

@media (prefers-reduced-motion: reduce) {
  .mua-root *,
  .mua-root *::before,
  .mua-root *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  .mua-panel,
  .mua-message__bubble,
  .mua-composer__input,
  .mua-field__input {
    border: 1px solid CanvasText;
  }
}
