:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #131313;
  color: #dfdfdf;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.chat {
  position: relative;
  display: grid;
  grid-template-rows: 66px 1fr auto;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
  background: #131313;
}

.chat__top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 15px 24px 0;
}

.chat__brand {
  margin: 0;
  color: #dfdfdf;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.chat__close {
  position: absolute;
  top: 15px;
  right: 18px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(223, 223, 223, 0.38);
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.chat__close:hover,
.chat__close:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: #dfdfdf;
  outline: none;
}

.chat__close span {
  position: absolute;
  top: 16px;
  left: 10px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.chat__close span:first-child {
  transform: rotate(45deg);
}

.chat__close span:last-child {
  transform: rotate(-45deg);
}

.chat__empty {
  position: absolute;
  top: 286px;
  left: 50%;
  z-index: 1;
  width: min(525px, calc(100% - 64px));
  transform: translateX(-50%);
  color: #dfdfdf;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  opacity: 1;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.chat__empty p {
  margin: 0;
}

.chat[data-empty="false"] .chat__empty {
  opacity: 0;
}

.chat__messages {
  position: relative;
  z-index: 2;
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  padding: 3px 34px 28px 36px;
}

.chat__messages::-webkit-scrollbar {
  width: 8px;
}

.chat__messages::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.chat__message {
  display: flex;
  margin: 0 0 13px;
}

.chat__message--visitor {
  justify-content: flex-end;
}

.chat__message--agent,
.chat__message--system {
  justify-content: flex-start;
}

.chat__bubble {
  max-width: min(444px, 78%);
  padding: 12px 16px;
  border-radius: 20px;
  background: #202020;
  color: #dfdfdf;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat__message--visitor .chat__bubble {
  max-width: min(255px, 58%);
  background: #343434;
}

.chat__message--system {
  display: none;
}

.chat__bottom {
  position: relative;
  z-index: 3;
  grid-row: 3;
  padding: 0 59px calc(10px + env(safe-area-inset-bottom));
}

.chat[data-empty="true"] .chat__bottom {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.chat__composer {
  display: grid;
  grid-template-columns: 1fr 27px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 51px;
  padding: 0 19px;
  border: 0;
  border-radius: 30px;
  background: #202020;
  overflow: hidden;
}

.chat[data-empty="true"] .chat__composer {
  position: fixed;
  left: 50%;
  top: 50%;
  bottom: auto;
  width: min(525px, calc(100% - 64px));
  transform: translate(-50%, -50%);
}

.chat__input {
  width: 100%;
  max-height: 112px;
  min-height: 24px;
  padding: 0;
  resize: none;
  border: 0;
  background: transparent;
  color: #dfdfdf;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.32;
  overflow: hidden;
}

.chat__input::placeholder {
  color: #616161;
  opacity: 1;
}

.chat__send {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  background: #616161;
  color: #131313;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.chat__send:hover,
.chat__send:focus-visible {
  background: #dfdfdf;
  color: #131313;
  outline: none;
}

.chat__send:disabled {
  opacity: 0.55;
  cursor: default;
}

.chat__note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin-top: 8px;
  color: #848484;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

.chat[data-empty="true"] .chat__note {
  position: fixed;
  left: 50%;
  bottom: 10px;
  width: min(446px, calc(100% - 64px));
  margin: 0;
  transform: translateX(-50%);
  gap: 8px;
}

.chat__note p {
  margin: 0;
}

@media (max-width: 520px) {
  .chat {
    grid-template-rows: calc(60px + env(safe-area-inset-top)) 1fr auto;
  }

  .chat__top {
    padding-top: calc(14px + env(safe-area-inset-top));
  }

  .chat__brand {
    font-size: 21px;
  }

  .chat__close {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    opacity: 1;
  }

  .chat__empty {
    top: 34%;
    width: min(320px, calc(100% - 38px));
    font-size: 15px;
  }

  .chat__messages {
    padding: 8px 14px 22px;
  }

  .chat__bubble {
    max-width: 82%;
    font-size: 14px;
  }

  .chat__message--visitor .chat__bubble {
    max-width: 76%;
  }

  .chat__bottom {
    padding: 0 14px calc(10px + env(safe-area-inset-bottom));
  }

  .chat[data-empty="true"] .chat__composer {
    top: 50%;
    bottom: auto;
    width: calc(100% - 32px);
    transform: translate(-50%, -50%);
  }

  .chat[data-empty="true"] .chat__note {
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100% - 38px);
  }

  .chat__note {
    font-size: 11px;
  }

  .chat__input {
    font-size: 14px;
  }
}

@media (max-height: 620px) {
  .chat__empty {
    top: 32%;
  }
}
