.chat-widget {
  position: fixed;
  left: 16px;
  bottom: 18px;
  z-index: 1090;
  pointer-events: none;
}

.chat-widget,
.chat-widget * {
  box-sizing: border-box;
}

.chat-widget__launcher,
.chat-widget__close,
.chat-widget__submit {
  font: inherit;
}

.chat-widget__launcher {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #f7fbff;
  background: #1668c7;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 160ms ease, background-color 160ms ease;
}

.chat-widget__launcher:hover {
  background: #0f57ac;
  transform: translateY(-2px);
}

.chat-widget__launcher:focus-visible,
.chat-widget__close:focus-visible,
.chat-widget__input:focus-visible,
.chat-widget__submit:focus-visible {
  outline: 3px solid rgba(255, 209, 102, 0.95);
  outline-offset: 3px;
}

.chat-widget__icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.chat-widget__panel[hidden] {
  display: none !important;
}

.chat-widget__panel {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(430px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 24px));
  height: min(680px, calc(100dvh - 24px));
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(84px, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #f7fbff;
  background: #101d2d;
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.38);
  pointer-events: auto;
}

.chat-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.chat-widget__title {
  margin: 0;
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.chat-widget__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: #f7fbff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.chat-widget__messages {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 84px;
  padding: 14px 16px;
  overflow: auto;
}

.chat-widget__message {
  max-width: 86%;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 0.94rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-widget__message--user {
  justify-self: end;
  color: #101d2d;
  background: #ffd166;
}

.chat-widget__message--system,
.chat-widget__message--error {
  justify-self: start;
  color: #f7fbff;
  background: rgba(255, 255, 255, 0.1);
}

.chat-widget__message--error {
  color: #ffcbc4;
}

.chat-widget__form[hidden] {
  display: none !important;
}

.chat-widget__form {
  display: grid;
  gap: 9px;
  padding: 0 16px 16px;
}

.chat-widget__label {
  color: rgba(247, 251, 255, 0.88);
  font-size: 0.9rem;
  line-height: 1.3;
  font-weight: 600;
}

.chat-widget__input {
  width: 100%;
  min-height: 84px;
  max-height: 160px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #101d2d;
  background: #fff;
  font: inherit;
  line-height: 1.35;
}

.chat-widget__status {
  min-height: 1.3em;
  margin: 0;
  color: rgba(247, 251, 255, 0.82);
  font-size: 0.88rem;
  line-height: 1.3;
}

.chat-widget__status--error {
  color: #ffb1a6;
}

.chat-widget__submit {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #1668c7;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.chat-widget__submit:hover:not(:disabled) {
  background: #0f57ac;
}

.chat-widget__submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media (max-width: 767px) {
  .chat-widget__launcher {
    display: none;
  }

  .chat-widget__panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .chat-widget__input {
    min-height: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget__launcher {
    transition: none;
  }

  .chat-widget__launcher:hover {
    transform: none;
  }
}

.chat-widget__attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-widget__attach {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #f7fbff;
  background: rgba(255, 255, 255, 0.08);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-widget__attach:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.chat-widget__attach:disabled {
  cursor: wait;
  opacity: 0.72;
}

.chat-widget__file-name {
  min-width: 0;
  overflow: hidden;
  color: rgba(247, 251, 255, 0.82);
  font-size: 0.84rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-widget__message-text + .chat-widget__attachment {
  margin-top: 7px;
}

.chat-widget__attachment {
  max-width: 100%;
}

.chat-widget__attachment a {
  color: inherit;
}

.chat-widget__attachment-image {
  display: block;
  width: auto;
  max-width: 220px;
  max-height: 180px;
  border-radius: 7px;
  object-fit: cover;
}

.chat-widget__attachment-file {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}



.chat-widget__launcher-text {
  position: relative;
  z-index: 2;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}

.chat-widget__launcher .chat-widget__icon {
  position: relative;
  z-index: 2;
}

.chat-widget__wave {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(22, 104, 199, 0.58);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  animation: chat-widget-wave 3s ease-out infinite;
}

.chat-widget__wave--2 {
  animation-delay: 1s;
}

.chat-widget__wave--3 {
  animation-delay: 1.8s;
}

@keyframes chat-widget-wave {
  0% {
    transform: scale(0.92);
    opacity: 0.55;
  }
  75%,
  100% {
    transform: scale(1.32);
    opacity: 0;
  }
}

.chat-widget__start {
  padding: 20px 18px 18px;
  overflow: auto;
}

.chat-widget__start[hidden] {
  display: none !important;
}

.chat-widget__start-title {
  margin: 0 0 8px;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1.25;
  font-weight: 700;
}

.chat-widget__start-text {
  margin: 0 0 18px;
  color: rgba(247, 251, 255, 0.72);
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-widget__contact-form {
  display: grid;
  gap: 9px;
}

.chat-widget__contact-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 8px;
  color: #101d2d;
  background: #fff;
  font: inherit;
}

.chat-widget__contact-input:focus-visible {
  outline: 3px solid rgba(255, 209, 102, 0.95);
  outline-offset: 2px;
}

.chat-widget__start-status {
  min-height: 1.3em;
  margin: 2px 0;
  color: rgba(247, 251, 255, 0.82);
  font-size: 0.9rem;
  line-height: 1.35;
}

.chat-widget__start-status--error {
  color: #ffb1a6;
}

.chat-widget__start-submit,
.chat-widget__skip {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.chat-widget__start-submit {
  border: 0;
  color: #101d2d;
  background: #ffd166;
}

.chat-widget__start-submit:hover:not(:disabled) {
  background: #f2bd3d;
}

.chat-widget__skip {
  border: 1px solid rgba(255, 255, 255, 0.20);
  color: #f7fbff;
  background: rgba(255, 255, 255, 0.07);
}

.chat-widget__skip:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
}

.chat-widget__start-submit:disabled,
.chat-widget__skip:disabled {
  cursor: wait;
  opacity: 0.66;
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget__wave {
    animation: none;
  }
}

.chat-widget__step {
  display: grid;
  gap: 12px;
}

.chat-widget__step[hidden] {
  display: none !important;
}
