:root {
  --mmw-navy: #0b2038;
  --mmw-blue: #2d6fa5;
  --mmw-ice: #eaf4fa;
  --mmw-paper: #fffdf9;
  --mmw-ink: #10243b;
  --mmw-muted: #60758a;
  --mmw-line: rgba(11, 32, 56, 0.14);
  --mmw-orange: #dc713c;
}

#__mb_bubble {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 99990;
  display: grid;
  width: 64px;
  height: 64px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  background: var(--mmw-navy);
  color: #fff;
  box-shadow: 0 15px 42px rgba(11, 32, 56, 0.3);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

#__mb_bubble::after {
  content: "";
  position: absolute;
  top: 11px;
  right: 11px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--mmw-navy);
  border-radius: 50%;
  background: #63c88a;
}

#__mb_bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 48px rgba(11, 32, 56, 0.36);
}

#__mb_bubble:focus-visible,
#__mb_panel button:focus-visible,
#__mb_panel a:focus-visible,
#__mb_panel textarea:focus-visible {
  outline: 3px solid #65b6ee;
  outline-offset: 3px;
}

#__mb_panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 76px);
  z-index: 99991;
  display: none;
  width: min(410px, calc(100vw - 36px));
  height: min(660px, calc(100dvh - 118px));
  min-height: 440px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--mmw-line);
  border-radius: 24px;
  background: var(--mmw-paper);
  color: var(--mmw-ink);
  box-shadow: 0 25px 75px rgba(11, 32, 56, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 180ms ease, transform 180ms ease;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#__mb_panel.mbopen {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#__mb_hdr {
  position: relative;
  display: grid;
  padding: 20px 58px 18px 20px;
  gap: 3px;
  flex: 0 0 auto;
  background:
    radial-gradient(circle at 88% 0%, rgba(101, 182, 238, 0.3), transparent 38%),
    var(--mmw-navy);
  color: #fff;
}

#__mb_htitle {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

#__mb_hsub {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#__mb_close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

#__mb_msgs {
  display: flex;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.mb-rb,
.mb-ru {
  display: flex;
}

.mb-ru {
  justify-content: flex-end;
}

.mb-b {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 17px;
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.mb-bb {
  border-bottom-left-radius: 5px;
  background: var(--mmw-ice);
  color: var(--mmw-ink);
}

.mb-bu {
  border-bottom-right-radius: 5px;
  background: var(--mmw-navy);
  color: #fff;
}

#__mb_suggestions {
  display: flex;
  padding: 0 16px 12px;
  overflow-x: auto;
  gap: 7px;
  flex: 0 0 auto;
  scrollbar-width: none;
}

#__mb_suggestions::-webkit-scrollbar {
  display: none;
}

.mb-suggestion {
  min-height: 38px;
  padding: 8px 11px;
  flex: 0 0 auto;
  border: 1px solid var(--mmw-line);
  border-radius: 999px;
  background: #fff;
  color: var(--mmw-navy);
  font: 600 0.74rem/1.2 inherit;
  cursor: pointer;
}

#__mb_bar {
  display: flex;
  padding: 11px 14px;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  border-top: 1px solid var(--mmw-line);
  background: #fff;
}

#__mb_inp {
  min-width: 0;
  max-height: 100px;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
  resize: none;
  border: 1px solid var(--mmw-line);
  border-radius: 13px;
  background: #f8fafc;
  color: var(--mmw-ink);
  font: 0.86rem/1.45 inherit;
}

#__mb_snd {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 13px;
  background: var(--mmw-orange);
  color: #fff;
  cursor: pointer;
}

#__mb_snd:disabled {
  opacity: 0.45;
  cursor: default;
}

#__mb_boundary {
  padding: 9px 14px 5px;
  flex: 0 0 auto;
  color: var(--mmw-muted);
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: center;
}

#__mb_actions {
  display: grid;
  padding: 8px 14px 14px;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 0 0 auto;
  background: #fff;
}

#__mb_actions a {
  display: flex;
  min-height: 42px;
  padding: 8px 10px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mmw-navy);
  border-radius: 12px;
  color: var(--mmw-navy);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

#__mb_actions a:first-child {
  background: var(--mmw-navy);
  color: #fff;
}

.mb-td {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8da0b2;
  animation: mb-bounce 1s infinite ease-in-out;
}

.mb-dot:nth-child(2) { animation-delay: 150ms; }
.mb-dot:nth-child(3) { animation-delay: 300ms; }

@keyframes mb-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
}

@media (max-width: 520px) {
  #__mb_bubble {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 58px;
    height: 58px;
    border-radius: 19px;
  }

  #__mb_panel {
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 68px);
    width: calc(100vw - 16px);
    height: min(650px, calc(100dvh - 84px));
    min-height: 0;
    border-radius: 18px;
  }

  #__mb_actions {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 650px) {
  #__mb_panel {
    bottom: 8px;
    height: calc(100dvh - 16px);
  }

  #__mb_actions,
  #__mb_boundary {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #__mb_bubble,
  #__mb_panel {
    transition: none;
  }

  .mb-dot {
    animation: none;
  }
}
