.mt-chat {
  --mt-red: #9f2f24;
  --mt-ink: #201816;
  --mt-cream: #fff8ec;
  --mt-border: #e3d6c2;
  color: var(--mt-ink);
  font-family: Arial, Helvetica, sans-serif;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999999;
}

.mt-chat__launcher,
.mt-chat__send,
.mt-chat__close {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.mt-chat__launcher {
  align-items: center;
  background: transparent;
  color: var(--mt-ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  padding: 0;
  text-align: center;
  width: 132px;
}

.mt-chat__launcher[hidden],
.mt-chat__panel[hidden] {
  display: none;
}

.mt-chat__avatar-wrap {
  background: #fff;
  border: 4px solid #fff;
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(32, 24, 22, 0.24);
  display: grid;
  height: 92px;
  overflow: hidden;
  place-items: center;
  width: 92px;
}

.mt-chat__avatar {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.mt-chat__avatar-fallback {
  background: var(--mt-red);
  color: white;
  display: none;
  font-size: 42px;
  height: 100%;
  line-height: 84px;
  width: 100%;
}

.mt-chat--avatar-missing .mt-chat__avatar {
  display: none;
}

.mt-chat--avatar-missing .mt-chat__avatar-fallback {
  display: block;
}

.mt-chat__greeting {
  background: #fff;
  border: 1px solid var(--mt-border);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(32, 24, 22, 0.16);
  color: var(--mt-ink);
  font-size: 14px;
  line-height: 1.2;
  padding: 8px 10px;
  width: 100%;
}

.mt-chat__panel {
  background: var(--mt-cream);
  border: 1px solid var(--mt-border);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(32, 24, 22, 0.28);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: min(620px, calc(100vh - 36px));
  overflow: hidden;
  width: min(380px, calc(100vw - 36px));
}

.mt-chat__header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--mt-border);
  display: flex;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 14px;
}

.mt-chat__title {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.mt-chat__header-avatar-wrap {
  background: #fff;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(32, 24, 22, 0.18);
  display: grid;
  flex: 0 0 auto;
  height: 38px;
  overflow: hidden;
  place-items: center;
  width: 38px;
}

.mt-chat__header-avatar {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.mt-chat__header-avatar-fallback {
  background: var(--mt-red);
  color: white;
  display: none;
  font-size: 18px;
  font-weight: 700;
  height: 100%;
  line-height: 34px;
  text-align: center;
  width: 100%;
}

.mt-chat--avatar-missing .mt-chat__header-avatar {
  display: none;
}

.mt-chat--avatar-missing .mt-chat__header-avatar-fallback {
  display: block;
}

.mt-chat__close {
  background: transparent;
  color: var(--mt-ink);
  font-size: 28px;
  line-height: 1;
  width: 36px;
}

.mt-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
}

.mt-chat__prompts {
  background: var(--mt-cream);
  border-top: 1px solid var(--mt-border);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
}

.mt-chat__prompts button {
  background: #fff;
  border: 1px solid var(--mt-border);
  border-radius: 999px;
  color: var(--mt-ink);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  min-height: 34px;
  padding: 0 12px;
}

.mt-chat__bubble {
  border-radius: 8px;
  line-height: 1.4;
  max-width: 86%;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.mt-chat__bubble--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--mt-border);
}

.mt-chat__bubble--thinking {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-height: 22px;
  min-width: 48px;
}

.mt-chat__typing-dot {
  animation: mt-chat-typing-dot 0.95s ease-in-out infinite;
  background: var(--mt-red);
  border-radius: 999px;
  display: block;
  height: 7px;
  opacity: 0.35;
  width: 7px;
}

.mt-chat__typing-dot:nth-child(2) {
  animation-delay: 0.14s;
}

.mt-chat__typing-dot:nth-child(3) {
  animation-delay: 0.28s;
}

.mt-chat__bubble--typing::after {
  animation: mt-chat-caret 0.8s steps(2, start) infinite;
  color: var(--mt-red);
  content: "";
  display: inline-block;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  width: 2px;
}

.mt-chat__bubble--user {
  align-self: flex-end;
  background: var(--mt-red);
  color: #fff;
}

.mt-chat__actions {
  align-self: flex-start;
  display: flex;
  max-width: 86%;
}

.mt-chat__action {
  background: var(--mt-red);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  line-height: 1.2;
  min-height: 38px;
  padding: 10px 12px;
  text-decoration: none;
}

.mt-chat__action:focus,
.mt-chat__action:hover {
  background: #81251c;
}

.mt-chat__form {
  background: #fff;
  border-top: 1px solid var(--mt-border);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 10px;
}

.mt-chat__input {
  border: 1px solid var(--mt-border);
  border-radius: 6px;
  font: inherit;
  min-height: 42px;
  min-width: 0;
  padding: 0 10px;
}

.mt-chat__send {
  background: var(--mt-red);
  border-radius: 6px;
  color: white;
  font-weight: 700;
  min-height: 42px;
  padding: 0 14px;
}

.mt-chat--loading .mt-chat__send {
  opacity: 0.7;
}

@keyframes mt-chat-typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes mt-chat-caret {
  0%,
  45% {
    box-shadow: inset 2px 0 0 var(--mt-red);
  }

  46%,
  100% {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mt-chat__typing-dot,
  .mt-chat__bubble--typing::after {
    animation: none;
  }
}

@media (max-width: 520px) {
  .mt-chat {
    right: 12px;
    bottom: 12px;
  }

  .mt-chat__launcher {
    width: 118px;
  }

  .mt-chat__avatar-wrap {
    height: 78px;
    width: 78px;
  }

  .mt-chat__greeting {
    font-size: 13px;
  }
}
