.chat-widget {
  position: fixed;
  top: auto;
  left: auto;
  right: clamp(18px, 2vw, 28px);
  bottom: clamp(18px, 2vw, 28px);
  z-index: 80;
  display: block;
}

.chat-widget-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid rgba(126, 221, 168, 0.2);
  border-radius: 999px;
  background: rgba(8, 23, 35, 0.92);
  color: #f4fbf9;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.chat-widget-launcher:hover {
  transform: translateY(-1px);
  border-color: rgba(126, 221, 168, 0.34);
  background: rgba(9, 28, 42, 0.96);
}

.chat-widget-launcher__icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #86dda8 0%, #7fc8db 100%);
  box-shadow: 0 0 0 5px rgba(126, 221, 168, 0.12);
}

.chat-widget-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  width: min(398px, calc(100vw - 28px));
  min-height: 560px;
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: linear-gradient(180deg, #f7f3fb 0%, #ffffff 72%);
  box-shadow: 0 30px 90px rgba(13, 17, 28, 0.34);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom right;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.chat-widget.is-open .chat-widget-panel {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-widget-panel__hero {
  padding: 18px 18px 20px;
  background:
    linear-gradient(180deg, rgba(91, 19, 192, 0.98) 0%, rgba(111, 25, 224, 0.94) 64%, rgba(186, 150, 238, 0.56) 100%);
  color: #ffffff;
  transition:
    padding 200ms ease,
    background 200ms ease;
}

.chat-widget-panel__topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat-widget-brand strong {
  display: block;
  font-size: 1.15rem;
  color: #ffffff;
}

.chat-widget-brand span {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.76);
}

.chat-widget-panel__actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chat-widget-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(196, 174, 255, 0.9));
  box-shadow: 0 8px 20px rgba(14, 8, 33, 0.18);
}

.chat-widget-avatar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.92) 0 18%, transparent 19%),
    radial-gradient(circle at 50% 72%, rgba(255, 255, 255, 0.88) 0 32%, transparent 33%),
    linear-gradient(160deg, #8e5af4 0%, #7334e5 100%);
}

.chat-widget-panel__actions button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.3rem;
  cursor: pointer;
}

.chat-widget-panel__intro {
  padding-top: 30px;
  transition:
    padding-top 200ms ease,
    opacity 180ms ease,
    transform 180ms ease,
    max-height 200ms ease,
    margin 200ms ease;
  max-height: 320px;
  overflow: hidden;
}

.chat-widget-greeting {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  font-weight: 700;
}

.chat-widget-panel__intro h3 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.chat-widget-intro-copy {
  margin: 14px 0 0;
  max-width: 290px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
  line-height: 1.55;
}

.chat-widget-team {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    margin-top 180ms ease,
    opacity 180ms ease,
    transform 180ms ease,
    max-height 180ms ease,
    padding 180ms ease,
    border-color 180ms ease;
  max-height: 120px;
  overflow: hidden;
}

.chat-widget-team__label {
  display: block;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-widget-team__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-widget-team__list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
}

.chat-widget-team__list span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c0ff8e;
  box-shadow: 0 0 0 4px rgba(192, 255, 142, 0.14);
}

.chat-widget-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, #ffffff 100%);
}

.chat-widget-gate {
  padding: 16px 18px 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, #ffffff 100%);
}

.chat-widget-gate[hidden] {
  display: none;
}

.chat-widget-gate__card {
  padding: 18px;
  border: 1px solid rgba(38, 43, 66, 0.08);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(38, 42, 60, 0.08);
}

.chat-widget-gate__card strong {
  display: block;
  color: #1d2032;
  font-size: 1rem;
}

.chat-widget-gate__card p {
  margin: 8px 0 0;
  color: #566079;
  line-height: 1.55;
  font-size: 0.92rem;
}

.chat-widget-gate__form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.chat-widget-gate__form label {
  display: grid;
  gap: 6px;
}

.chat-widget-gate__form span {
  color: #566079;
  font-size: 0.8rem;
  font-weight: 700;
}

.chat-widget-gate__form input {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(37, 43, 66, 0.12);
  border-radius: 14px;
  background: #ffffff;
  color: #1d2032;
  outline: none;
}

.chat-widget-gate__form input:focus {
  border-color: rgba(111, 25, 224, 0.5);
  box-shadow: 0 0 0 3px rgba(111, 25, 224, 0.1);
}

.chat-widget-gate__form button {
  padding: 13px 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #6f19e0 0%, #8a5af1 100%);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(111, 25, 224, 0.24);
}

.chat-widget.has-conversation .chat-widget-panel__hero {
  padding: 16px 18px 14px;
  background:
    linear-gradient(180deg, rgba(91, 19, 192, 0.98) 0%, rgba(111, 25, 224, 0.9) 100%);
}

.chat-widget.is-gated .chat-widget-messages,
.chat-widget.is-gated .chat-widget-form {
  display: none;
}

.chat-widget.has-conversation .chat-widget-panel__intro {
  padding-top: 12px;
}

.chat-widget.has-conversation .chat-widget-greeting,
.chat-widget.has-conversation .chat-widget-intro-copy {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  margin: 0;
}

.chat-widget.has-conversation .chat-widget-panel__intro h3 {
  font-size: 1.28rem;
  line-height: 1.15;
}

.chat-widget.has-conversation .chat-widget-team {
  margin-top: 10px;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
}

.chat-widget-message {
  max-width: 92%;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 0.96rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.chat-widget-message__sender {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chat-widget-message--assistant {
  align-self: flex-start;
  border: 1px solid rgba(38, 43, 66, 0.08);
  background: #ffffff;
  color: #1d2032;
  box-shadow: 0 10px 26px rgba(38, 42, 60, 0.08);
}

.chat-widget-message--user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(104, 39, 216, 0.9), rgba(132, 79, 234, 0.86));
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(107, 52, 214, 0.22);
}

.chat-widget-message--operator {
  border-color: rgba(104, 39, 216, 0.12);
  background: linear-gradient(180deg, rgba(245, 238, 255, 0.95) 0%, #ffffff 100%);
}

.chat-widget-message--operator .chat-widget-message__sender {
  color: #6f19e0;
}

.chat-widget-message--loading {
  color: rgba(47, 52, 80, 0.72);
  font-style: italic;
}

.chat-widget-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(32, 37, 61, 0.08);
  background: #ffffff;
}

.chat-widget-form input {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid rgba(37, 43, 66, 0.12);
  border-radius: 14px;
  background: #ffffff;
  color: #1d2032;
  outline: none;
}

.chat-widget-form input::placeholder {
  color: rgba(65, 72, 103, 0.56);
}

.chat-widget-form button {
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #6f19e0 0%, #8a5af1 100%);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(111, 25, 224, 0.24);
}

.chat-widget-form button:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 767px) {
  .chat-widget {
    right: 10px;
    bottom: 10px;
  }

  .chat-widget-launcher {
    padding: 12px 16px;
    border-radius: 18px;
  }

  .chat-widget-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    min-height: min(700px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
    border-radius: 28px;
    transform-origin: bottom center;
  }

  .chat-widget-panel__hero {
    padding: 16px 16px 18px;
  }

  .chat-widget-panel__intro {
    padding-top: 24px;
  }

  .chat-widget-panel__intro h3 {
    font-size: 1.75rem;
  }

  .chat-widget-intro-copy {
    max-width: none;
  }

  .chat-widget-messages {
    padding: 16px;
  }

  .chat-widget-form {
    padding: 14px 16px 16px;
  }
}

@media (max-width: 520px) {
  .chat-widget {
    right: 8px;
    bottom: 8px;
  }

  .chat-widget-launcher {
    width: calc(100vw - 16px);
    justify-content: center;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
  }

  .chat-widget-panel {
    left: 4px;
    right: 4px;
    bottom: 4px;
    min-height: calc(100dvh - 8px);
    max-height: calc(100dvh - 8px);
    border-radius: 24px;
  }

  .chat-widget-panel__hero {
    padding: 14px 14px 16px;
  }

  .chat-widget-panel__intro {
    padding-top: 22px;
  }

  .chat-widget-panel__intro h3 {
    font-size: 1.55rem;
  }

  .chat-widget-team {
    margin-top: 14px;
    padding: 12px;
    border-radius: 18px;
  }

  .chat-widget-team__list {
    gap: 6px;
  }

  .chat-widget-team__list span {
    padding: 7px 10px;
    font-size: 0.74rem;
  }

  .chat-widget-gate,
  .chat-widget-messages {
    padding-left: 14px;
    padding-right: 14px;
  }

  .chat-widget-form {
    grid-template-columns: 1fr;
    padding: 12px 14px 14px;
  }

  .chat-widget-form button,
  .chat-widget-gate__form button {
    min-height: 50px;
  }

  .chat-widget-message {
    max-width: 100%;
    padding: 13px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
  }
}
