:root {
  --rw-chat-blue: #21376F;
  --rw-chat-blue-hover: #395CA3;
  --rw-chat-orange: #F37847;
  --rw-chat-orange-hover: #F37847;
  --rw-chat-text: #1f2937;
  --rw-chat-muted: #6b7280;
  --rw-chat-bg: #ffffff;
  --rw-chat-soft-bg: #f7f7f5;
  --rw-chat-border: rgba(17, 24, 39, 0.12);
}

.rw-chat {
  position: fixed;
  right: 24px;
  bottom: 90px;
  top: auto;
  left: auto;
  z-index: 9999;
  font-family: inherit;
}

.rw-chat * {
  box-sizing: border-box;
}

.rw-chat [hidden] {
  display: none !important;
}

.rw-chat__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: var(--rw-chat-blue);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(57, 92, 163, 0.28);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.rw-chat__button:hover {
  background: var(--rw-chat-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 18px 44px rgba(57, 92, 163, 0.34);
}

.rw-chat__button:active {
  transform: translateY(0);
}

.rw-chat__button-text {
  white-space: nowrap;
}

.rw-chat__window {
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  background: var(--rw-chat-bg);
  border: 1px solid var(--rw-chat-border);
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
}

.rw-chat__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  background: var(--rw-chat-blue);
  color: #ffffff;
}

.rw-chat__title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.rw-chat__status {
  margin-top: 4px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

.rw-chat__close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.rw-chat__close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.rw-chat__messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  background: var(--rw-chat-soft-bg);
}

.rw-chat__message {
  width: fit-content;
  max-width: 88%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.rw-chat__message--bot {
  background: #ffffff;
  color: var(--rw-chat-text);
  border-top-left-radius: 6px;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.06);
}

.rw-chat__message--user {
  margin-left: auto;
  background: var(--rw-chat-blue);
  color: #ffffff;
  border-top-right-radius: 6px;
}

.rw-chat__message--system {
  margin-inline: auto;
  background: transparent;
  color: var(--rw-chat-muted);
  font-size: 13px;
  text-align: center;
  padding: 6px 8px;
}

.rw-chat__form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 14px;
  background: #ffffff;
  border-top: 1px solid var(--rw-chat-border);
}

.rw-chat__textarea {
  width: 100%;
  resize: none;
  border: 1px solid rgba(17, 24, 39, 0.16);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--rw-chat-text);
  outline: none;
  background: #ffffff;
}

.rw-chat__textarea:focus {
  border-color: var(--rw-chat-blue);
  box-shadow: 0 0 0 3px rgba(57, 92, 163, 0.12);
}

.rw-chat__textarea::placeholder {
  color: #9ca3af;
}

.rw-chat .rw-chat__send {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  min-width: 0 !important;
  margin-top: 10px !important;
  border: 0 !important;
  border-radius: 999px !important;
  padding: 12px 22px !important;
  background: var(--rw-chat-orange) !important;
  color: #ffffff !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  text-decoration: none !important;
  box-shadow: none !important;
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  transition: background 0.2s ease, transform 0.2s ease !important;
}

.rw-chat .rw-chat__send:hover {
  background: var(--rw-chat-orange-hover) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
}

.rw-chat .rw-chat__send:active {
  background: var(--rw-chat-orange-hover) !important;
  color: #ffffff !important;
  transform: translateY(0) !important;
}

.rw-chat .rw-chat__send:focus {
  background: var(--rw-chat-orange) !important;
  color: #ffffff !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(242, 140, 40, 0.22) !important;
}

.rw-chat .rw-chat__send:disabled {
  background: var(--rw-chat-orange) !important;
  color: #ffffff !important;
  cursor: not-allowed !important;
  opacity: 0.65 !important;
  transform: none !important;
}

.rw-chat__note {
  padding: 0 16px 14px;
  background: #ffffff;
  color: var(--rw-chat-muted);
  font-size: 12px;
  line-height: 1.35;
}

/* Планшеты */
@media screen and (max-width: 768px) {
  .rw-chat {
    position: fixed !important;
    top: auto !important;
    right: auto !important;
    left: 16px !important;
    bottom: 26px !important;
    z-index: 99999 !important;
  }

  .rw-chat__button {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    padding: 13px 18px;
    font-size: 14px;
  }

  .rw-chat__window {
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 96px);
  }
}

/* Телефоны */
@media screen and (max-width: 520px) {
  .rw-chat {
    position: fixed !important;
    top: auto !important;
    right: auto !important;
    left: 12px !important;
    bottom: 26px !important;
    z-index: 99999 !important;
    width: auto !important;
    height: auto !important;
  }

  .rw-chat__button {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    display: inline-flex !important;
    width: auto !important;
    max-width: calc(100vw - 24px);
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: 0 12px 30px rgba(57, 92, 163, 0.26);
  }

  .rw-chat__window {
    position: fixed !important;
    top: auto !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 82px !important;
    width: auto !important;
    height: calc(100vh - 150px);
    max-width: none;
    max-height: none;
    border-radius: 20px;
  }

  .rw-chat__header {
    padding: 16px;
  }

  .rw-chat__messages {
    padding: 14px;
  }

  .rw-chat__message {
    max-width: 92%;
    font-size: 14px;
  }

  .rw-chat__form {
    padding: 12px;
  }

  .rw-chat .rw-chat__send {
    padding: 11px 20px !important;
    font-size: 14px !important;
    background: var(--rw-chat-orange) !important;
    color: #ffffff !important;
  }

  .rw-chat__note {
    padding: 0 14px 12px;
  }
}

/* Очень маленькие экраны */
@media screen and (max-width: 380px) {
  .rw-chat {
    position: fixed !important;
    top: auto !important;
    left: 10px !important;
    right: auto !important;
    bottom: 24px !important;
  }

  .rw-chat__button {
    padding: 11px 14px;
    font-size: 13px;
  }

  .rw-chat__window {
    left: 10px !important;
    right: 10px !important;
    bottom: 78px !important;
    height: calc(100vh - 104px);
  }

  .rw-chat .rw-chat__send {
    padding: 10px 18px !important;
    font-size: 13px !important;
    background: var(--rw-chat-orange) !important;
    color: #ffffff !important;
  }
}