.emma-widget {
  position: fixed;
  z-index: 60;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(var(--footer-height, 1.0625rem) + max(1rem, env(safe-area-inset-bottom)));
  font-family: "DM Sans", Arial, Helvetica, sans-serif;
  pointer-events: none;
}

.emma-launcher,
.emma-panel {
  pointer-events: auto;
}

.emma-launcher {
  display: inline-flex;
  min-width: 8.25rem;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  background: linear-gradient(135deg, #4826a8 0%, #7e239d 55%, #e91e63 100%);
  box-shadow: 0 0.75rem 2rem rgba(49, 24, 112, 0.3);
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: box-shadow 180ms ease, transform 180ms ease;
}

.emma-launcher img {
  width: 1.2rem;
  height: 1.2rem;
  filter: brightness(0) invert(1);
}

.emma-launcher:hover {
  box-shadow: 0 0.9rem 2.25rem rgba(49, 24, 112, 0.38);
  transform: translateY(-0.125rem);
}

.emma-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  width: min(23.75rem, calc(100vw - 2rem));
  height: min(37.5rem, calc(100vh - 7rem));
  height: min(37.5rem, calc(100dvh - 7rem - env(safe-area-inset-bottom)));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(72, 38, 168, 0.16);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 1.25rem 3.75rem rgba(25, 13, 56, 0.28);
  color: #17131f;
  isolation: isolate;
  overscroll-behavior: contain;
  touch-action: none;
}

.emma-panel[hidden] {
  display: none;
}

.emma-panel__header {
  display: flex;
  min-height: 4.25rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid #ece8f4;
  padding: 0.75rem 0.8rem 0.75rem 1rem;
  background: #ffffff;
}

.emma-panel__identity,
.emma-panel__actions {
  display: flex;
  align-items: center;
}

.emma-panel__identity {
  min-width: 0;
  gap: 0.7rem;
}

.emma-panel__identity > span:last-child {
  display: grid;
  min-width: 0;
  gap: 0.08rem;
}

.emma-panel__identity strong {
  font-size: 1rem;
  line-height: 1.2;
}

.emma-panel__identity small {
  color: #6f687b;
  font-size: 0.72rem;
  line-height: 1.25;
}

.emma-panel__avatar {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #f0ebff;
  place-items: center;
}

.emma-panel__avatar img {
  width: 1rem;
  height: 1rem;
}

.emma-panel__actions {
  flex: 0 0 auto;
  gap: 0.25rem;
}

.emma-panel__copy,
.emma-panel__close,
.emma-starters button,
.emma-composer__send {
  font: inherit;
  cursor: pointer;
}

.emma-panel__copy {
  min-height: 2.25rem;
  min-width: 5.15rem;
  border: 0;
  border-radius: 0.45rem;
  padding: 0.45rem 0.65rem;
  background: transparent;
  color: #4826a8;
  font-size: 0.75rem;
  font-weight: 700;
}

.emma-panel__copy:disabled {
  color: #9892a2;
  cursor: not-allowed;
}

.emma-panel__close {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: #332d3c;
  font-size: 1.55rem;
  font-weight: 400;
  line-height: 1;
  place-items: center;
}

.emma-panel__copy:not(:disabled):hover,
.emma-panel__close:hover {
  background: #f3effa;
}

.emma-panel__body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem;
  background: #fbf9fe;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
}

.emma-panel__transcript-heading {
  margin: 0 0 0.9rem;
  color: #777080;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.35;
}

.emma-welcome {
  margin-bottom: 1rem;
}

.emma-welcome[hidden] {
  display: none;
}

.emma-welcome > p {
  margin: 0;
  color: #4d4657;
  font-size: 0.84rem;
  line-height: 1.5;
}

.emma-starters {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.emma-starters button {
  min-height: 2.75rem;
  border: 1px solid #d8cef0;
  border-radius: 0.7rem;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  color: #4826a8;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  touch-action: manipulation;
}

.emma-starters button:hover {
  border-color: #9e8bd2;
  background: #f5f1ff;
}

.emma-starters button:disabled {
  color: #918b9c;
  cursor: wait;
  opacity: 0.72;
}

.emma-messages {
  display: grid;
  gap: 0.9rem;
}

.emma-message {
  display: grid;
  max-width: 88%;
  gap: 0.25rem;
}

.emma-message--visitor {
  justify-self: end;
}

.emma-message--emma {
  justify-self: start;
}

.emma-message__speaker {
  color: #756e7f;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.2;
}

.emma-message--visitor .emma-message__speaker {
  justify-self: end;
}

.emma-message__bubble {
  min-width: 2.5rem;
  border-radius: 0.85rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.emma-message--visitor .emma-message__bubble {
  border-bottom-right-radius: 0.22rem;
  background: #4826a8;
  color: #ffffff;
}

.emma-message--emma .emma-message__bubble {
  border: 1px solid #e5e0ec;
  border-bottom-left-radius: 0.22rem;
  background: #ffffff;
  color: #27212f;
}

.emma-message__bubble p,
.emma-message__bubble ul,
.emma-message__bubble ol {
  margin: 0;
}

.emma-message__bubble p + p,
.emma-message__bubble p + ul,
.emma-message__bubble p + ol,
.emma-message__bubble ul + p,
.emma-message__bubble ol + p,
.emma-message__bubble ul + ul,
.emma-message__bubble ol + ol,
.emma-message__bubble ul + ol,
.emma-message__bubble ol + ul {
  margin-top: 0.55rem;
}

.emma-message__bubble ul,
.emma-message__bubble ol {
  padding-left: 1.15rem;
}

.emma-message__bubble li + li {
  margin-top: 0.3rem;
}

.emma-message__bubble a {
  color: #4826a8;
  font-weight: 650;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.12em;
}

.emma-message--visitor .emma-message__bubble a {
  color: #ffffff;
}

.emma-activity {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.9rem;
  color: #655d70;
  font-size: 0.75rem;
  line-height: 1.25;
}

.emma-activity[hidden] {
  display: none;
}

.emma-activity__dots {
  display: inline-flex;
  gap: 0.18rem;
}

.emma-activity__dots i {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: #7e66bd;
  animation: emma-dot 1s ease-in-out infinite;
}

.emma-activity__dots i:nth-child(2) {
  animation-delay: 120ms;
}

.emma-activity__dots i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes emma-dot {
  0%, 60%, 100% {
    opacity: 0.42;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-0.18rem);
  }
}

.emma-composer {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 0.55rem;
  border-top: 1px solid #ece8f4;
  padding: 0.75rem;
  background: #ffffff;
}

.emma-composer textarea {
  width: 100%;
  min-height: 2.75rem;
  max-height: 7.5rem;
  flex: 1 1 auto;
  resize: none;
  border: 1px solid #d8d1e1;
  border-radius: 0.75rem;
  padding: 0.68rem 0.75rem;
  color: #211b29;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.emma-composer textarea::placeholder {
  color: #8c8496;
}

.emma-composer textarea:disabled {
  background: #f5f2f8;
  color: #777080;
  cursor: wait;
}

.emma-composer__send {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: #4826a8;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  place-items: center;
  touch-action: manipulation;
}

.emma-composer__send:disabled {
  background: #c8c1d3;
  cursor: not-allowed;
}

.emma-launcher:focus-visible,
.emma-panel button:focus-visible,
.emma-panel textarea:focus-visible,
.emma-panel a:focus-visible {
  outline: 0.15rem solid #3b92ff;
  outline-offset: 0.15rem;
}

.emma-copy-helper {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 30rem) {
  .emma-widget {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: calc(var(--footer-height, 1.0625rem) + max(0.75rem, env(safe-area-inset-bottom)));
  }

  .emma-panel {
    width: calc(100vw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right));
    height: min(37.5rem, calc(100vh - 6.5rem));
    height: min(37.5rem, calc(100dvh - 6.5rem - env(safe-area-inset-bottom)));
  }

  .emma-launcher {
    min-width: 3.25rem;
    padding-right: 0.9rem;
    padding-left: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .emma-launcher {
    transition: none;
  }

  .emma-activity__dots i {
    animation: none;
    opacity: 0.72;
  }
}
