.mmx-chat-root {
  position: fixed;
  z-index: 99990;
  right: 16px;
  bottom: 84px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.mmx-chat-bubble {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #6d5efc 0%, #4b7bff 100%);
  box-shadow: 0 8px 22px rgba(75, 123, 255, 0.42);
  position: relative;
  touch-action: none;
  transition: transform 0.15s ease;
}

.mmx-chat-bubble:active {
  transform: scale(0.94);
}

.mmx-chat-bubble svg {
  width: 26px;
  height: 26px;
  pointer-events: none;
}

.mmx-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff3b5c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  display: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.mmx-chat-badge.show {
  display: block;
}

.mmx-chat-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 320px;
  max-width: calc(100vw - 24px);
  height: 440px;
  max-height: calc(100vh - 140px);
  background: #14161c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  color: #eef1f6;
}

.mmx-chat-root.open .mmx-chat-panel {
  display: flex;
}

.mmx-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #6d5efc 0%, #4b7bff 100%);
  color: #fff;
}

.mmx-chat-header strong {
  font-size: 14px;
  flex: 1;
}

.mmx-chat-header .mmx-chat-sub {
  font-size: 11px;
  opacity: 0.85;
  display: block;
  font-weight: 400;
}

.mmx-chat-header button {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.mmx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0f1116;
}

.mmx-chat-msg {
  max-width: 88%;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  align-self: flex-start;
  background: transparent;
  padding: 0;
}

.mmx-chat-msg-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mmx-chat-msg-row.mine-row {
  justify-content: flex-end;
}

.mmx-chat-bubble-inner {
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 12px;
  background: #262a33;
}

.mmx-chat-msg .mmx-chat-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
  opacity: 0.85;
}

.mmx-chat-msg.mine {
  align-self: flex-end;
  color: #fff;
}

.mmx-chat-msg.mine .mmx-chat-bubble-inner {
  background: linear-gradient(135deg, #6d5efc 0%, #4b7bff 100%);
}

.mmx-chat-msg.admin {
  align-self: flex-start;
}

.mmx-chat-msg.admin .mmx-chat-bubble-inner {
  background: #2e2416;
  border: 1px solid #b7791f;
}

.mmx-chat-msg.admin .mmx-chat-name {
  color: #f6c453;
  opacity: 1;
}

.mmx-chat-msg.flash .mmx-chat-bubble-inner {
  outline: 1px solid #4b7bff;
}

.mmx-chat-reply {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #9aa2b1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  padding: 0;
}

.mmx-chat-msg:hover .mmx-chat-reply,
.mmx-chat-reply:focus {
  opacity: 1;
}

.mmx-chat-reply:hover {
  background: rgba(75, 123, 255, 0.25);
  color: #cdd8ff;
}

.mmx-chat-quote {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0 0 6px;
  padding: 5px 7px;
  border: none;
  border-left: 3px solid rgba(255, 255, 255, 0.45);
  border-radius: 0 8px 8px 0;
  background: rgba(0, 0, 0, 0.22);
  color: inherit;
  cursor: pointer;
}

.mmx-chat-quote-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 1px;
  opacity: 0.95;
}

.mmx-chat-quote-body {
  display: block;
  font-size: 11px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mmx-chat-reply-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #181b22;
}

.mmx-chat-reply-bar.show {
  display: flex;
}

.mmx-chat-reply-main {
  flex: 1;
  min-width: 0;
}

.mmx-chat-reply-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #9ec1ff;
  margin-bottom: 2px;
}

.mmx-chat-reply-text {
  display: block;
  font-size: 11px;
  color: #9aa2b1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mmx-chat-reply-cancel {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #cdd5e1;
  cursor: pointer;
}

.mmx-chat-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #14161c;
}

.mmx-chat-input input {
  flex: 1;
  background: #1e222b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 9px 12px;
  color: #eef1f6;
  font-size: 13px;
  outline: none;
}

.mmx-chat-input input:focus {
  border-color: #4b7bff;
}

.mmx-chat-input button {
  background: linear-gradient(135deg, #6d5efc 0%, #4b7bff 100%);
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.mmx-chat-name-row {
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #14161c;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #9aa2b1;
}

.mmx-chat-name-row input {
  flex: 1;
  background: #1e222b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  color: #eef1f6;
  font-size: 12px;
  outline: none;
}

.mmx-chat-empty {
  margin: auto;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
}

.mmx-chat-note {
  display: none;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #14161c;
  color: #f6c453;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.mmx-chat-root.locked .mmx-chat-note {
  display: block;
}

.mmx-chat-root.locked .mmx-chat-input,
.mmx-chat-root.locked .mmx-chat-name-row,
.mmx-chat-root.locked .mmx-chat-reply-bar {
  display: none;
}

.mmx-chat-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 22, 28, 0.96);
  border: 1px solid #b7791f;
  color: #f6c453;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.mmx-chat-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .mmx-chat-root.open {
    position: fixed !important;
    inset: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 100000;
  }

  .mmx-chat-root.open .mmx-chat-panel {
    position: fixed;
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .mmx-chat-root.open .mmx-chat-bubble {
    display: none;
  }

  .mmx-chat-root.open .mmx-chat-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .mmx-chat-root.open .mmx-chat-input {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .mmx-chat-reply {
    opacity: 0.9;
  }
}

@media (max-width: 480px) {
  .mmx-chat-root:not(.open) .mmx-chat-panel {
    width: calc(100vw - 24px);
    height: 60vh;
  }
}
