.mw-chat-launcher {
  position: fixed;
  z-index: 1050;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3.5rem;
  padding: 0.7rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, #f5ca72, #b5853e);
  color: #15120c;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mw-chat-launcher svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.mw-chat-panel {
  position: fixed;
  z-index: 1051;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 4.25rem);
  display: flex;
  flex-direction: column;
  width: min(23rem, calc(100vw - 2rem));
  height: min(33rem, calc(100dvh - 7rem));
  min-height: 20rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.1rem;
  background: #101624;
  color: #f3f6ff;
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.48);
  font-family: inherit;
}

.mw-chat-panel[hidden],
.mw-chat-launcher[hidden] {
  display: none;
}

.mw-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mw-chat-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.mw-chat-header p {
  margin: 0.2rem 0 0;
  color: #b8c0d4;
  font-size: 0.78rem;
}

.mw-chat-close {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.mw-chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.7rem;
  overflow-y: auto;
  padding: 1rem;
  overscroll-behavior: contain;
}

.mw-chat-message {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.09);
  color: #f3f6ff;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mw-chat-message--user {
  align-self: flex-end;
  background: #c99d50;
  color: #17130c;
}

.mw-chat-message--error {
  border: 1px solid rgba(255, 120, 120, 0.38);
  color: #ffd1d1;
}

.mw-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mw-chat-input {
  flex: 1;
  min-width: 0;
  max-height: 6rem;
  resize: vertical;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.75rem;
  outline: none;
  background: #080c14;
  color: #f3f6ff;
  font: inherit;
  font-size: 0.9rem;
}

.mw-chat-input:focus {
  border-color: #d9af5d;
  box-shadow: 0 0 0 3px rgba(217, 175, 93, 0.18);
}

.mw-chat-send {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 0.75rem;
  background: #d9af5d;
  color: #15120c;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

.mw-chat-send:disabled,
.mw-chat-input:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 480px) {
  .mw-chat-panel {
    right: 0.65rem;
    bottom: calc(max(0.65rem, env(safe-area-inset-bottom)) + 4rem);
    width: calc(100vw - 1.3rem);
    height: min(36rem, calc(100dvh - 6rem));
  }

  .mw-chat-launcher {
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}
