.mg-public-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147482500;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eaf4ff;
}

.mg-public-chat * {
  box-sizing: border-box;
}

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

.mg-public-chat-launcher {
  position: relative;
  min-width: 148px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f8fbd, #14b8a6);
  color: #06111d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  box-shadow: 0 20px 44px rgba(2, 12, 27, 0.36);
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.mg-public-chat-launcher:hover,
.mg-public-chat-launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 24px 50px rgba(2, 12, 27, 0.44);
  filter: saturate(1.08);
  outline: 3px solid rgba(20, 184, 166, 0.3);
  outline-offset: 3px;
}

.mg-public-chat-launcher-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  color: #0d5268;
  font-size: 18px;
  font-weight: 900;
}

.mg-public-chat-unread {
  position: absolute;
  right: 4px;
  top: 0;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffb020;
  color: #111827;
  border: 2px solid #06111d;
  font-size: 12px;
  font-weight: 900;
}

.mg-public-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(430px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 44px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto auto;
  overflow: hidden;
  padding: 0 !important;
  margin: 0;
  background: #0f1f35;
  border: 1px solid rgba(169, 205, 230, 0.18);
  border-radius: 10px;
  box-shadow: 0 28px 70px rgba(2, 12, 27, 0.48);
}

.mg-public-chat.is-open .mg-public-chat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.96);
}

.mg-public-chat-panel[hidden] {
  display: none;
}

body.mg-pro-page .mg-public-chat .mg-public-chat-panel,
.mg-pro-page .mg-public-chat .mg-public-chat-panel,
.mg-public-chat .mg-public-chat-panel {
  padding: 0 !important;
  border: 1px solid rgba(169, 205, 230, 0.18) !important;
}

.mg-public-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 20px 20px 18px;
  background: linear-gradient(135deg, #0c2238, #123f4d);
  border-bottom: 1px solid rgba(169, 205, 230, 0.14);
}

.mg-public-chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mg-public-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #14b8a6;
  color: #06242b;
  font-size: 13px;
  font-weight: 900;
}

.mg-public-chat-header strong {
  display: block;
  color: #ffffff;
  font-size: 18px;
  line-height: 1.2;
}

.mg-public-chat-header span {
  display: block;
  color: #9fd7d0;
  font-size: 13px;
  margin-top: 6px;
}

.mg-public-chat-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #d9f3ff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.mg-public-chat-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.mg-public-chat-thread-action {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f3fbff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.mg-public-chat-thread-action:hover,
.mg-public-chat-thread-action:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: 3px solid rgba(20, 184, 166, 0.28);
}

.mg-public-chat-thread-action[disabled] {
  opacity: .62;
  cursor: wait;
}

.mg-public-chat-close:hover,
.mg-public-chat-close:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: 3px solid rgba(20, 184, 166, 0.28);
}

.mg-public-chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(10, 28, 48, 0.78), rgba(12, 24, 40, 0.95)),
    #0d1a2d;
}

.mg-public-chat-message {
  display: grid;
  gap: 4px;
  max-width: 86%;
}

.mg-public-chat-message[data-author="visitor"] {
  align-self: flex-end;
}

.mg-public-chat-message[data-author="visitor"] .mg-public-chat-bubble {
  background: #14b8a6;
  color: #041418;
}

.mg-public-chat-message[data-author="support"] .mg-public-chat-bubble {
  background: #eaf7ff;
  color: #0d2036;
}

.mg-public-chat-message[data-author="bot"] .mg-public-chat-bubble,
.mg-public-chat-message[data-author="system"] .mg-public-chat-bubble {
  background: #172d4b;
  color: #ecf7ff;
  border: 1px solid rgba(169, 205, 230, 0.16);
}

.mg-public-chat-bubble {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  word-break: break-word;
}

.mg-public-chat-bubble-text {
  white-space: pre-wrap;
}

.mg-public-chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}

.mg-public-chat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  background: #ffb020;
  color: #111827;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
}

.mg-public-chat-link:hover,
.mg-public-chat-link:focus-visible {
  background: #ffc44d;
  color: #06111d;
  text-decoration: none;
  outline: 3px solid rgba(255, 176, 32, 0.24);
  outline-offset: 2px;
}

.mg-public-chat-meta {
  color: #87a0bb;
  font-size: 11px;
  padding: 0 4px;
}

.mg-public-chat-message[data-author="visitor"] .mg-public-chat-meta {
  text-align: right;
}

.mg-public-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 92px;
  padding: 12px 16px;
  overflow-y: auto;
  background: #10223a;
  border-top: 1px solid rgba(169, 205, 230, 0.12);
}

.mg-public-chat-chips[hidden],
.mg-public-chat-form[hidden],
.mg-public-chat-thread-action[hidden] {
  display: none !important;
}

.mg-public-chat-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(20, 184, 166, 0.45);
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: #bff7ee;
  min-height: 36px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.mg-public-chat-chip:hover,
.mg-public-chat-chip:focus-visible {
  background: rgba(20, 184, 166, 0.22);
  outline: 2px solid rgba(20, 184, 166, 0.26);
}

.mg-public-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #0f1f35;
  border-top: 1px solid rgba(169, 205, 230, 0.14);
}

.mg-public-chat-form textarea,
.mg-public-chat-contact input,
.mg-public-chat-contact textarea {
  width: 100%;
  border: 1px solid rgba(169, 205, 230, 0.18);
  border-radius: 8px;
  background: #172d4b;
  color: #f4fbff;
  padding: 13px 14px;
  font: inherit;
  font-size: 14.5px;
  resize: none;
}

.mg-public-chat-form textarea {
  max-height: 132px;
  min-height: 56px;
}

.mg-public-chat-form textarea::placeholder,
.mg-public-chat-contact input::placeholder,
.mg-public-chat-contact textarea::placeholder {
  color: #88a4bf;
}

.mg-public-chat-form textarea:focus,
.mg-public-chat-contact input:focus,
.mg-public-chat-contact textarea:focus {
  border-color: #14b8a6;
  outline: 3px solid rgba(20, 184, 166, 0.18);
}

.mg-public-chat-form button,
.mg-public-chat-contact button {
  border: 0;
  border-radius: 8px;
  background: #ffb020;
  color: #111827;
  min-height: 56px;
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
}

.mg-public-chat-form button:hover,
.mg-public-chat-form button:focus-visible,
.mg-public-chat-contact button:hover,
.mg-public-chat-contact button:focus-visible {
  background: #ffc44d;
  outline: 3px solid rgba(255, 176, 32, 0.25);
}

.mg-public-chat-contact {
  padding: 16px;
  background: #122640;
  border-top: 1px solid rgba(169, 205, 230, 0.14);
  display: grid;
  gap: 11px;
}

.mg-public-chat-contact[hidden] {
  display: none;
}

.mg-public-chat-contact-title {
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
}

.mg-public-chat-contact label {
  display: grid;
  gap: 5px;
  margin: 0;
  color: #bed0e3;
  font-size: 12px;
  font-weight: 700;
}

.mg-public-chat-contact p {
  color: #ff8585;
  margin: 0;
  font-size: 12px;
}

html[data-mg-theme="light"] .mg-public-chat,
.mg-theme-light .mg-public-chat {
  color: #0f172a;
}

html[data-mg-theme="light"] .mg-public-chat-panel,
.mg-theme-light .mg-public-chat-panel {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.16);
}

html[data-mg-theme="light"] .mg-public-chat-header,
.mg-theme-light .mg-public-chat-header {
  background: linear-gradient(135deg, #075f7d, #0d9488);
}

html[data-mg-theme="light"] .mg-public-chat-messages,
.mg-theme-light .mg-public-chat-messages {
  background: #f3f8fb;
}

html[data-mg-theme="light"] .mg-public-chat-message[data-author="bot"] .mg-public-chat-bubble,
html[data-mg-theme="light"] .mg-public-chat-message[data-author="system"] .mg-public-chat-bubble,
.mg-theme-light .mg-public-chat-message[data-author="bot"] .mg-public-chat-bubble,
.mg-theme-light .mg-public-chat-message[data-author="system"] .mg-public-chat-bubble {
  background: #ffffff;
  color: #132238;
  border-color: rgba(15, 23, 42, 0.12);
}

html[data-mg-theme="light"] .mg-public-chat-chips,
html[data-mg-theme="light"] .mg-public-chat-form,
html[data-mg-theme="light"] .mg-public-chat-contact,
.mg-theme-light .mg-public-chat-chips,
.mg-theme-light .mg-public-chat-form,
.mg-theme-light .mg-public-chat-contact {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

html[data-mg-theme="light"] .mg-public-chat-form textarea,
html[data-mg-theme="light"] .mg-public-chat-contact input,
html[data-mg-theme="light"] .mg-public-chat-contact textarea,
.mg-theme-light .mg-public-chat-form textarea,
.mg-theme-light .mg-public-chat-contact input,
.mg-theme-light .mg-public-chat-contact textarea {
  background: #f6fafc;
  color: #111827;
  border-color: rgba(15, 23, 42, 0.16);
}

html[data-mg-theme="light"] .mg-public-chat-chip,
.mg-theme-light .mg-public-chat-chip {
  color: #075f7d;
  background: rgba(13, 148, 136, 0.08);
}

html[data-mg-theme="light"] .mg-public-chat-link,
.mg-theme-light .mg-public-chat-link {
  background: #075f7d;
  color: #ffffff;
}

html[data-mg-theme="light"] .mg-public-chat-thread-action,
.mg-theme-light .mg-public-chat-thread-action {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

html[data-mg-theme="light"] .mg-public-chat-link:hover,
html[data-mg-theme="light"] .mg-public-chat-link:focus-visible,
.mg-theme-light .mg-public-chat-link:hover,
.mg-theme-light .mg-public-chat-link:focus-visible {
  background: #0d9488;
  color: #ffffff;
}

@media (max-width: 560px) {
  .mg-public-chat {
    right: 14px;
    bottom: 14px;
  }

  .mg-public-chat-launcher {
    min-width: 56px;
    width: 56px;
    padding: 0;
  }

  .mg-public-chat-launcher-text {
    display: none;
  }

  .mg-public-chat-panel {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 14px;
    width: auto;
    height: min(660px, calc(100vh - 28px));
    min-height: 480px;
  }

  .mg-public-chat-header {
    gap: 10px;
    padding-left: 16px;
    padding-right: 12px;
  }

  .mg-public-chat-header-actions {
    gap: 6px;
  }

  .mg-public-chat-thread-action {
    min-height: 34px;
    max-width: 92px;
    padding: 0 9px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mg-public-chat-message {
    max-width: 92%;
  }
}
