.mhc-chat {
  --mhc-chat-bottom: 86px;
  --mhc-chat-right: 22px;
  --mhc-chat-top-safe: 112px;
  --mhc-chat-navy: #0b2341;
  --mhc-chat-blue: #0057b8;
  --mhc-chat-gold: #f6b53c;
  --mhc-chat-border: rgba(11, 35, 65, 0.14);
  --mhc-chat-shadow: 0 22px 60px rgba(5, 20, 38, 0.22);
  position: fixed;
  right: var(--mhc-chat-right);
  bottom: var(--mhc-chat-bottom);
  z-index: 997;
  font-family: inherit;
}

.mhc-chat *,
.mhc-chat *::before,
.mhc-chat *::after {
  box-sizing: border-box;
}

.mhc-chat__launcher {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--mhc-chat-blue), var(--mhc-chat-navy));
  box-shadow: 0 16px 34px rgba(0, 87, 184, 0.34);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mhc-chat__launcher:hover,
.mhc-chat__launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(0, 87, 184, 0.42);
}

.mhc-chat__launcher svg {
  width: 30px;
  height: 30px;
}

.mhc-chat__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #25d366;
  border: 3px solid #fff;
}

.mhc-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(380px, calc(100vw - 34px));
  height: min(560px, calc(100vh - var(--mhc-chat-top-safe) - var(--mhc-chat-bottom) - 16px));
  min-height: 0;
  background: #fff;
  border: 1px solid var(--mhc-chat-border);
  border-radius: 24px;
  box-shadow: var(--mhc-chat-shadow);
  overflow: hidden;
  display: none;
  grid-template-rows: auto 1fr auto;
}

.mhc-chat.is-open .mhc-chat__panel {
  display: grid;
}

.mhc-chat.is-open .mhc-chat__launcher {
  display: none;
}

.mhc-chat__header {
  padding: 18px;
  background:
    radial-gradient(circle at 12% 12%, rgba(246, 181, 60, 0.28), transparent 32%),
    linear-gradient(135deg, var(--mhc-chat-navy), #123d68);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mhc-chat__avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.mhc-chat__avatar svg {
  width: 24px;
  height: 24px;
}

.mhc-chat__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  font-weight: 800;
}

.mhc-chat__status {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.78);
}

.mhc-chat__close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.mhc-chat__messages {
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(245, 249, 253, 0.92), #fff 42%),
    #fff;
}

.mhc-chat__message {
  display: flex;
  margin: 0 0 12px;
}

.mhc-chat__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 0.91rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.mhc-chat__message--bot .mhc-chat__bubble {
  color: #18314f;
  background: #eef5fb;
  border-bottom-left-radius: 5px;
}

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

.mhc-chat__message--user .mhc-chat__bubble {
  color: #fff;
  background: var(--mhc-chat-blue);
  border-bottom-right-radius: 5px;
}

.mhc-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mhc-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #6c7d90;
  animation: mhc-chat-typing 1s infinite ease-in-out;
}

.mhc-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.mhc-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.mhc-chat__form {
  padding: 14px;
  border-top: 1px solid var(--mhc-chat-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
}

.mhc-chat__input {
  flex: 1;
  min-height: 44px;
  max-height: 110px;
  resize: none;
  border: 1px solid rgba(11, 35, 65, 0.18);
  border-radius: 14px;
  padding: 12px 13px;
  font: inherit;
  font-size: 0.92rem;
  color: #122844;
  outline: none;
}

.mhc-chat__input:focus {
  border-color: var(--mhc-chat-blue);
  box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.12);
}

.mhc-chat__send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--mhc-chat-gold);
  color: var(--mhc-chat-navy);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mhc-chat__send:hover,
.mhc-chat__send:focus-visible {
  transform: translateY(-1px);
}

.mhc-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.mhc-chat__send svg {
  width: 21px;
  height: 21px;
}

@keyframes mhc-chat-typing {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .mhc-chat {
    --mhc-chat-right: 14px;
  }

  .mhc-chat__launcher {
    width: 56px;
    height: 56px;
  }

  .mhc-chat__panel {
    width: calc(100vw - 28px);
    height: min(520px, calc(100vh - var(--mhc-chat-top-safe) - var(--mhc-chat-bottom) - 12px));
    min-height: 0;
    border-radius: 20px;
  }

  .mhc-chat__header {
    padding: 15px;
  }

  .mhc-chat__messages {
    padding: 14px;
  }
}

@media (max-width: 420px) {
  .mhc-chat__bubble {
    max-width: 92%;
    font-size: 0.88rem;
  }
}
