.mley-chatbot {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1055;
}

.mley-chatbot {
  --mley-chatbot-launcher-bg: linear-gradient(135deg, #133b5c, #1d5f7a);
  --mley-chatbot-launcher-bg-hover: linear-gradient(135deg, #0f304b, #1a536b);
  --mley-chatbot-panel-bg: rgba(247, 249, 252, 0.98);
  --mley-chatbot-panel-border: rgba(19, 59, 92, 0.14);
  --mley-chatbot-panel-shadow: 0 20px 60px rgba(16, 42, 67, 0.22);
  --mley-chatbot-title: #102a43;
  --mley-chatbot-muted: #486581;
  --mley-chatbot-soft-muted: #627d98;
  --mley-chatbot-intro-bg: #eef4f8;
  --mley-chatbot-intro-text: #243b53;
  --mley-chatbot-assistant-bg: #f0f4f8;
  --mley-chatbot-user-bg: #133b5c;
  --mley-chatbot-user-text: #fff;
  --mley-chatbot-source-bg: rgba(19, 59, 92, 0.06);
  --mley-chatbot-source-bg-hover: rgba(19, 59, 92, 0.1);
  --mley-chatbot-source-text: #133b5c;
  --mley-chatbot-source-muted: #486581;
  --mley-chatbot-chip-bg: #e6edf4;
  --mley-chatbot-chip-bg-hover: #d9e5ef;
  --mley-chatbot-chip-text: #133b5c;
  --mley-chatbot-input-bg: #fff;
  --mley-chatbot-input-border: rgba(19, 59, 92, 0.18);
  --mley-chatbot-input-focus: rgba(19, 59, 92, 0.4);
  --mley-chatbot-input-shadow: rgba(19, 59, 92, 0.12);
  --mley-chatbot-submit-bg: #133b5c;
  --mley-chatbot-submit-bg-hover: #0f304b;
  --mley-chatbot-typing: #486581;
}

.mley-chatbot__launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1rem;
  background: var(--mley-chatbot-launcher-bg);
  color: #fff;
  box-shadow: 0 18px 40px rgba(16, 42, 67, 0.28);
}

.mley-chatbot__launcher:hover,
.mley-chatbot__launcher:focus {
  background: var(--mley-chatbot-launcher-bg-hover);
  color: #fff;
  outline: 0;
  box-shadow: 0 22px 46px rgba(16, 42, 67, 0.36);
}

.mley-chatbot__launcher-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1rem;
}

.mley-chatbot__launcher-copy {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.mley-chatbot__launcher-copy small {
  opacity: 0.82;
}

.mley-chatbot__panel {
  width: min(380px, calc(100vw - 1.5rem));
  max-height: min(78vh, 720px);
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: 1.2rem;
  background: var(--mley-chatbot-panel-bg);
  box-shadow: var(--mley-chatbot-panel-shadow);
  border: 1px solid var(--mley-chatbot-panel-border);
  display: none;
  flex-direction: column;
  gap: 0.9rem;
  backdrop-filter: blur(12px);
}

.mley-chatbot--open .mley-chatbot__panel {
  display: flex;
}

.mley-chatbot__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.mley-chatbot__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--mley-chatbot-muted);
}

.mley-chatbot__title {
  font-size: 1.1rem;
  color: var(--mley-chatbot-title);
}

.mley-chatbot__close {
  border: 0;
  background: transparent;
  color: var(--mley-chatbot-muted);
  font-size: 1rem;
  padding: 0.2rem 0.3rem;
}

.mley-chatbot__close:hover,
.mley-chatbot__close:focus {
  color: var(--mley-chatbot-title);
  outline: 0;
}

.mley-chatbot__intro {
  padding: 0.85rem 0.9rem;
  border-radius: 1rem;
  background: var(--mley-chatbot-intro-bg);
  color: var(--mley-chatbot-intro-text);
  font-size: 0.94rem;
  border: 1px solid rgba(120, 152, 182, 0.12);
}

.mley-chatbot__messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 100px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.mley-chatbot__message {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.8rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.92rem;
  color: var(--mley-chatbot-title);
}

.mley-chatbot__message--assistant {
  background: var(--mley-chatbot-assistant-bg);
  border-top-left-radius: 0.35rem;
  border: 1px solid rgba(120, 152, 182, 0.12);
}

.mley-chatbot__message--user {
  background: var(--mley-chatbot-user-bg);
  color: var(--mley-chatbot-user-text);
  border-top-right-radius: 0.35rem;
  margin-left: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.mley-chatbot__message-meta {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.72;
}

.mley-chatbot__message-text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.mley-chatbot__message-text--streaming::after {
  content: "";
  display: inline-block;
  width: 0.38rem;
  height: 1em;
  margin-left: 0.14rem;
  vertical-align: text-bottom;
  background: currentColor;
  opacity: 0.85;
  animation: mley-chatbot-caret 0.9s steps(1) infinite;
}

.mley-chatbot__sources {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mley-chatbot__source {
  display: block;
  padding: 0.6rem 0.7rem;
  border-radius: 0.85rem;
  background: var(--mley-chatbot-source-bg);
  color: var(--mley-chatbot-source-text);
  text-decoration: none;
  border: 1px solid transparent;
}

.mley-chatbot__source:hover,
.mley-chatbot__source:focus {
  text-decoration: none;
  background: var(--mley-chatbot-source-bg-hover);
  color: var(--mley-chatbot-source-text);
  border-color: rgba(120, 152, 182, 0.16);
  outline: 0;
}

.mley-chatbot__source strong {
  display: block;
  font-size: 0.86rem;
}

.mley-chatbot__source small {
  display: block;
  margin-top: 0.2rem;
  color: var(--mley-chatbot-source-muted);
  line-height: 1.35;
}

.mley-chatbot__typing {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.mley-chatbot__typing-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--mley-chatbot-typing);
  animation: mley-chatbot-pulse 1.2s infinite ease-in-out;
}

.mley-chatbot__typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.mley-chatbot__typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

.mley-chatbot__suggestions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.mley-chatbot__suggestion {
  flex: 0 0 auto;
  max-width: 11rem;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: var(--mley-chatbot-chip-bg);
  color: var(--mley-chatbot-chip-text);
  font-size: 0.82rem;
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mley-chatbot__suggestion:hover,
.mley-chatbot__suggestion:focus {
  background: var(--mley-chatbot-chip-bg-hover);
  border-color: rgba(120, 152, 182, 0.18);
  outline: 0;
}

.mley-chatbot__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
}

.mley-chatbot__input {
  width: 100%;
  border: 1px solid var(--mley-chatbot-input-border);
  border-radius: 0.9rem;
  padding: 0.8rem 0.95rem;
  background: var(--mley-chatbot-input-bg);
  color: var(--mley-chatbot-title);
}

.mley-chatbot__input:focus {
  outline: 0;
  border-color: var(--mley-chatbot-input-focus);
  box-shadow: 0 0 0 0.15rem var(--mley-chatbot-input-shadow);
}

.mley-chatbot__input::placeholder {
  color: var(--mley-chatbot-soft-muted);
}

.mley-chatbot__submit {
  min-width: 3.2rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--mley-chatbot-submit-bg);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mley-chatbot__submit:hover,
.mley-chatbot__submit:focus {
  background: var(--mley-chatbot-submit-bg-hover);
  outline: 0;
}

@keyframes mley-chatbot-pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes mley-chatbot-caret {
  0%,
  49% {
    opacity: 0.9;
  }
  50%,
  100% {
    opacity: 0.15;
  }
}

:root[data-theme="dark"] .mley-chatbot {
  --mley-chatbot-launcher-bg: linear-gradient(135deg, #24496d, #3a6b93);
  --mley-chatbot-launcher-bg-hover: linear-gradient(135deg, #2d587f, #45779e);
  --mley-chatbot-panel-bg: rgba(20, 30, 40, 0.97);
  --mley-chatbot-panel-border: rgba(159, 179, 200, 0.16);
  --mley-chatbot-panel-shadow: 0 24px 64px rgba(0, 0, 0, 0.46);
  --mley-chatbot-title: #f2f7fb;
  --mley-chatbot-muted: #b5c5d6;
  --mley-chatbot-soft-muted: #91a7bb;
  --mley-chatbot-intro-bg: linear-gradient(180deg, rgba(39, 55, 71, 0.96), rgba(29, 43, 57, 0.96));
  --mley-chatbot-intro-text: #e6edf5;
  --mley-chatbot-assistant-bg: linear-gradient(180deg, rgba(37, 52, 67, 0.98), rgba(32, 46, 59, 0.98));
  --mley-chatbot-user-bg: linear-gradient(135deg, #335d90, #254d75);
  --mley-chatbot-user-text: #f7fbff;
  --mley-chatbot-source-bg: rgba(51, 93, 144, 0.16);
  --mley-chatbot-source-bg-hover: rgba(51, 93, 144, 0.24);
  --mley-chatbot-source-text: #dce9f7;
  --mley-chatbot-source-muted: #aac1d8;
  --mley-chatbot-chip-bg: rgba(42, 58, 74, 0.96);
  --mley-chatbot-chip-bg-hover: rgba(53, 72, 92, 0.96);
  --mley-chatbot-chip-text: #eef4fa;
  --mley-chatbot-input-bg: #1b2733;
  --mley-chatbot-input-border: #3a4d5f;
  --mley-chatbot-input-focus: #78aef7;
  --mley-chatbot-input-shadow: rgba(120, 174, 247, 0.2);
  --mley-chatbot-submit-bg: #335d90;
  --mley-chatbot-submit-bg-hover: #4270a7;
  --mley-chatbot-typing: #aac1d8;
}

:root[data-theme="dark"] .mley-chatbot__launcher {
  border: 1px solid rgba(159, 179, 200, 0.14);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] .mley-chatbot__launcher-icon {
  background: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .mley-chatbot__panel {
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .mley-chatbot__messages {
  scrollbar-color: #486581 rgba(23, 33, 43, 0.4);
}

:root[data-theme="dark"] .mley-chatbot__message-meta {
  opacity: 0.8;
}

:root[data-theme="dark"] .mley-chatbot__message--user .mley-chatbot__message-meta {
  color: rgba(247, 251, 255, 0.82);
}

:root[data-theme="dark"] .mley-chatbot__message--assistant .mley-chatbot__message-meta {
  color: #b5c5d6;
}

:root[data-theme="dark"] .mley-chatbot__source strong {
  color: #eef4fa;
}

:root[data-theme="dark"] .mley-chatbot__source small {
  color: #b5c5d6;
}

:root[data-theme="dark"] .mley-chatbot__input::placeholder {
  color: #8a97a5;
}

:root[data-theme="dark"] .mley-chatbot__submit {
  border: 1px solid rgba(159, 179, 200, 0.14);
}

:root[data-theme="dark"] .mley-chatbot__close:hover,
:root[data-theme="dark"] .mley-chatbot__close:focus {
  color: #f2f7fb;
}

@media (max-width: 767px) {
  .mley-chatbot {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
  }

  .mley-chatbot__launcher {
    width: 100%;
    justify-content: center;
  }

  .mley-chatbot__panel {
    width: 100%;
    max-height: 72vh;
  }

  .mley-chatbot__message--user {
    margin-left: 1rem;
  }
}
