.mws-talk-chat {
  position: fixed;
  right: var(--spacing-2xl);
  bottom: var(--spacing-2xl);
  z-index: 1000;
  display: flex;
  width: min(420px, calc(100vw - (var(--spacing-base) * 2)));
  height: min(768px, calc(100dvh - (var(--spacing-2xl) * 2)));
  align-items: flex-start;
  padding-bottom: 50px;
  filter: drop-shadow(0 2px 8px rgb(0 0 0 / 7%));
}

.mws-talk-chat__panel {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--semantic-white);
}

.mws-talk-chat__header {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 68px;
  flex: 0 0 68px;
  align-items: center;
  padding: 0 var(--spacing-lg);
  border-bottom: var(--stroke-1) solid var(--semantic-border);
  background: var(--semantic-white);
}

.mws-talk-chat__back {
  position: relative;
  display: flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  padding-top: 2px;
}

.mws-talk-chat__back img {
  width: 7px;
  margin-left: 6px;
}

.mws-talk-chat__heading {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--spacing-micro);
}

.mws-talk-chat__badge {
  padding: 0 var(--spacing-3xs);
  border: var(--stroke-1) solid var(--semantic-border);
  border-radius: var(--radius-xs);
  color: var(--neutral-tx3-sub);
  font-size: 9px;
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-14);
}

.mws-talk-chat__heading h2 {
  overflow: hidden;
  color: var(--neutral-tx2-title);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-20);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mws-talk-chat__header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.mws-talk-chat__reservation {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xs) var(--spacing-base);
  border: var(--stroke-1) solid var(--brand-primary);
  border-radius: var(--radius-sm);
  color: var(--semantic-white);
  background: var(--brand-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-16);
  text-decoration: none;
}

.mws-talk-chat__options {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-3xs);
  border-radius: var(--radius-xs);
}

.mws-talk-chat__options img {
  width: 24px;
}

.mws-talk-chat__scroll {
  position: relative;
  z-index: 1;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.mws-talk-chat__messages {
  display: flex;
  width: 100%;
  min-height: 100%;
  flex-direction: column;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0 var(--spacing-xl);
}

.mws-talk-chat__messages::before {
  margin-top: auto;
  content: "";
}

.chat-message {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: var(--spacing-3xs);
  padding: var(--spacing-sm);
}

.chat-message--received {
  padding-right: var(--spacing-3xl);
}

.chat-message--sent {
  justify-content: flex-end;
  padding-left: var(--spacing-5xl);
}

.chat-message__avatar {
  display: block;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--spacing-base);
  object-fit: cover;
}

.chat-message__body {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-3xs);
  padding: var(--spacing-micro) 0;
}

.chat-message--sent .chat-message__body {
  flex: 0 1 100%;
  align-items: flex-end;
}

.chat-message__name {
  width: 100%;
  padding-left: 12px;
  color: var(--neutral-tx1-hero);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-16);
}

.chat-message__group {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--spacing-2xs);
}

.chat-bubble-row {
  position: relative;
  display: flex;
  max-width: 100%;
  align-items: flex-start;
}

.chat-bubble-row--received {
  width: 100%;
  justify-content: flex-start;
}

.chat-bubble-row--sent {
  width: fit-content;
  max-width: 100%;
  justify-content: flex-end;
}

.chat-bubble__tail {
  display: block;
  width: 12px;
  height: 24px;
  flex: 0 0 12px;
}

.chat-bubble-stack {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--spacing-micro);
}

.chat-bubble {
  width: fit-content;
  max-width: 100%;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  color: var(--neutral-tx2-title);
  background: var(--semantic-bg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-20);
  overflow-wrap: anywhere;
}

.chat-bubble-row--received .chat-bubble-stack,
.chat-bubble-row--received > .chat-bubble {
  width: 100%;
}

.chat-bubble-row--sent .chat-bubble {
  background: rgb(192 237 233 / 60%);
}

.chat-bubble p + p {
  margin-top: var(--spacing-xl);
}

.chat-bubble--photo {
  overflow: hidden;
  padding: 0;
}

.chat-bubble-row--received .chat-bubble--photo {
  width: 160px;
  height: 120px;
}

.chat-bubble-row--sent .chat-bubble--photo {
  width: 120px;
  height: 160px;
}

.chat-bubble--photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-message__time {
  padding: 0 var(--spacing-3xs);
  color: var(--neutral-tx3-sub);
  font-size: 9px;
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-14);
  white-space: nowrap;
}

.mws-talk-chat__composer {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 56px;
  flex: 0 0 56px;
  align-items: center;
  padding: 0 var(--spacing-xs);
  background: var(--semantic-white);
}

.mws-talk-chat__input-wrap {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-sm);
  border: var(--stroke-1) solid var(--semantic-input-border);
  border-radius: var(--radius-sm);
  background: var(--semantic-white);
}

.mws-talk-chat__input-wrap input {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  color: var(--neutral-tx2-title);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-20);
  background: transparent;
}

.mws-talk-chat__input-wrap input::placeholder {
  color: var(--neutral-tx4-dissolved);
}

.mws-talk-chat__input-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.mws-talk-chat__input-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mws-talk-chat__input-actions button:first-child {
  width: 18px;
  height: 18px;
}

.mws-talk-chat__input-actions button:last-child {
  width: 20px;
  height: 20px;
}

.mws-talk-chat__input-actions img {
  width: 100%;
}

.mws-talk-chat .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.mws-talk-chat a:focus-visible,
.mws-talk-chat button:focus-visible,
.mws-talk-chat__scroll:focus-visible,
.mws-talk-chat__input-wrap:focus-within {
  outline: var(--stroke-2) solid var(--brand-primary-dark);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .mws-talk-chat {
    right: var(--spacing-base);
    bottom: var(--spacing-base);
    height: min(768px, calc(100dvh - (var(--spacing-base) * 2)));
  }
}

@media (max-width: 479px) {
  .mws-talk-chat__header {
    padding-right: var(--spacing-base);
    padding-left: var(--spacing-base);
  }

  .mws-talk-chat__reservation {
    padding-right: var(--spacing-md);
    padding-left: var(--spacing-md);
  }

  .chat-message--received {
    padding-right: var(--spacing-xl);
  }

  .chat-message--sent {
    padding-left: var(--spacing-3xl);
  }
}
