#exw-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10001;
  font-family: "Outfit", sans-serif;
}

#exw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #2977f5;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px 10px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(41, 119, 245, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#exw-toggle[hidden] {
  display: none;
}

#exw-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(41, 119, 245, 0.45);
}

.exw-toggle__avatars {
  display: inline-flex;
  align-items: center;
}

.exw-toggle__avatars .exw-ava {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #2977f5;
  margin-left: -9px;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.exw-toggle__avatars .exw-ava:first-child {
  margin-left: 0;
}

.exw-toggle__avatars img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#exw-popup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 140px));
  min-height: 0;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.3);
  display: flex;
  overflow: hidden;
  font-family: inherit;
}

#exw-popup[hidden] {
  display: none;
}

#exw-backdrop[hidden] {
  display: none;
}

#exw-backdrop {
  display: none;
}

#exw-popup,
#exw-popup * {
  box-sizing: border-box;
}

.exw-thread__msgs,
.exw-list__items {
  min-width: 0;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.exw-msg {
  min-width: 0;
  max-width: 100%;
}

.exw-msg .bubble {
  min-width: 0;
  overflow-wrap: anywhere;
}

.exw-msg .bubble p,
.exw-msg .bubble ul,
.exw-msg .bubble ol,
.exw-msg .bubble li {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.exw-msg.bot .bubble code,
.exw-msg.bot .bubble a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.exw-edit {
  min-width: 0;
}

.exw-edit textarea {
  box-sizing: border-box;
  max-width: 100%;
}

.exw-suggest {
  max-width: 100%;
}

.exw-suggest__chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exw-convo {
  min-width: 0;
  max-width: 100%;
}

.exw-thread__input {
  min-width: 0;
}

.exw-list {
  width: 100%;
  min-width: 0;
  border-right: none;
  display: flex;
  flex-direction: column;
  background: #fafbfc;
}

#exw-popup.show-thread .exw-list {
  display: none;
}

#exw-popup:not(.show-thread) .exw-thread {
  display: none;
}

.exw-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px 18px;
}

.exw-list__title {
  font-size: 19px;
  font-weight: 600;
  color: #111827;
}

.exw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.exw-icon-btn:hover {
  background: rgba(41, 119, 245, 0.12);
  color: #2977f5;
}

.exw-list__items {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exw-convo {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease;
}

.exw-convo:hover {
  background: rgba(15, 23, 42, 0.05);
}

.exw-convo.active {
  background: rgba(41, 119, 245, 0.12);
}

.exw-ava {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}

.exw-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exw-convo__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exw-convo__title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exw-convo__sub {
  font-size: 13px;
  color: #6b7280;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.exw-convo__time {
  font-size: 12px;
  opacity: 0.75;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.exw-thread {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.exw-thread__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.exw-traffic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  flex-shrink: 0;
}

.exw-traffic button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
}

#exw-close,
#exw-l-close {
  background: #ff5f57;
}

#exw-min,
#exw-l-min {
  background: #febc2e;
}

#exw-max,
#exw-l-max {
  background: #28c840;
}

#exw-popup.minimized .exw-thread__msgs,
#exw-popup.minimized .exw-thread__input,
#exw-popup.minimized .exw-list {
  display: none;
}

#exw-popup.minimized {
  height: auto;
  min-height: 0;
}

#exw-popup.zoomed {
  width: min(760px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 110px));
}

.exw-thread__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.exw-thread__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f4f5f7;
}

.exw-thread__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.exw-thread__title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exw-thread__status {
  font-size: 13px;
  color: #2977f5;
}

.exw-thread__header .exw-icon-btn {
  width: 32px;
  height: 32px;
}

.exw-thread__header .exw-back {
  display: inline-flex;
}

.exw-thread__msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.exw-msg {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.exw-msg.user {
  justify-content: flex-end;
  align-items: flex-end;
}

.exw-msg.bot {
  align-items: flex-start;
}

.exw-msg.system {
  justify-content: center;
  align-items: center;
}

.exw-msg .bubble {
  max-width: 78%;
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.exw-msg.user .bubble {
  background: #2977f5;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.exw-msg.bot .bubble {
  background: #f4f5f7;
  color: #1f2937;
  border-bottom-left-radius: 6px;
}

.exw-msg.system {
  justify-content: center;
}

.exw-msg.system .bubble {
  background: rgba(41, 119, 245, 0.1);
  color: #1f66d6;
  font-size: 13px;
  border-radius: 12px;
  text-align: center;
}

.exw-approve__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.exw-approve__btn {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: rgba(41, 119, 245, 0.15);
  color: #1f66d6;
}

.exw-approve__btn.primary {
  background: #2977f5;
  color: #fff;
}

.exw-approve__btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.exw-msg.thinking .bubble {
  color: #6b7280;
  background-image: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.65) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: exw-gleam 1.6s ease-in-out infinite;
}

@keyframes exw-gleam {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .exw-msg.thinking .bubble {
    animation: none;
  }
}

.exw-msg .bubble p {
  margin: 0 0 8px;
}

.exw-msg .bubble p:last-child {
  margin-bottom: 0;
}

.exw-msg .bubble ul,
.exw-msg .bubble ol {
  margin: 6px 0 8px;
  padding-left: 20px;
}

.exw-msg .bubble li {
  margin: 2px 0;
}

.exw-msg.bot .bubble code {
  background: rgba(15, 23, 42, 0.08);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 13px;
}

.exw-msg.bot .bubble a {
  color: #1f66d6;
}

.exw-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 4px 0;
}

.exw-suggest__chip {
  border: 1px solid rgba(41, 119, 245, 0.4);
  background: #fff;
  color: #1f66d6;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.exw-suggest__chip:hover {
  background: rgba(41, 119, 245, 0.1);
}

.exw-versions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}

.exw-versions button {
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: #4b5563;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.exw-versions button:hover {
  background: rgba(41, 119, 245, 0.15);
  color: #1f66d6;
}

.exw-edit {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exw-edit textarea {
  width: 100%;
  border: 1px solid rgba(41, 119, 245, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  background: #fff;
}

.exw-edit__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.exw-thread__input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 16px 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.exw-thread__input input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #f4f5f7;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.exw-thread__input input:focus {
  outline: none;
  border-color: #2977f5;
  background: #fff;
}

#exw-send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: #2977f5;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 8px 18px rgba(41, 119, 245, 0.3);
}

#exw-send:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

#exw-send:not(:disabled):hover {
  transform: scale(1.06);
}

.exw-login {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

#exw-popup.logged-out .exw-list,
#exw-popup.logged-out .exw-thread {
  display: none;
}

#exw-popup.logged-out .exw-login {
  display: flex;
}

.exw-login__title {
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.exw-login__text {
  font-size: 15px;
  color: #6b7280;
  margin: 0;
  max-width: 320px;
}

.exw-login__btn {
  margin-top: 8px;
  background: #2977f5;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 36px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.exw-empty {
  padding: 24px 12px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

@media (max-width: 720px) {
  #exw-root {
    right: 14px;
    bottom: 14px;
  }

  body.exw-no-scroll {
    overflow: hidden;
  }

  #exw-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(244, 245, 247, 0.55);
    -webkit-backdrop-filter: blur(14px) saturate(1.25);
    backdrop-filter: blur(14px) saturate(1.25);
    z-index: 10000;
    cursor: pointer;
  }

  #exw-popup {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: min(640px, calc(100vh - 140px));
    height: min(640px, calc(100dvh - 140px));
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
    z-index: 10001;
    border-radius: 18px;
  }

  #exw-popup.minimized {
    left: auto;
    width: auto;
    max-width: calc(100vw - 24px);
  }

  #exw-popup.zoomed {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
  }

  .exw-toggle__label {
    display: none;
  }

  .exw-msg .bubble {
    max-width: 85%;
  }

  .exw-thread__msgs {
    padding: 14px 12px;
  }

  .exw-thread__input {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .exw-login {
    padding: 24px 20px;
  }
}
