.logos-chat {
  --chat-purple: #4f0b69;
  --chat-purple-dark: #310044;
  --chat-gold: #f4b72f;
  position: fixed;
  z-index: 1100;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 12px;
  font-family: inherit;
}

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

.logos-chat__launcher {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 19px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--chat-purple), var(--chat-purple-dark));
  box-shadow: 0 14px 36px rgba(42, 0, 58, .28);
  font: inherit;
  font-size: .95rem;
  font-weight: 850;
  cursor: pointer;
}

.logos-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(42, 0, 58, .34); }
.logos-chat__launcher svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.logos-chat.is-open .logos-chat__launcher { display: none; }

.logos-chat__launcher:focus-visible,
.logos-chat__option:focus-visible,
.logos-chat__whatsapp:focus-visible,
.logos-chat__restart:focus-visible,
.logos-chat__back:focus-visible,
.logos-chat__close:focus-visible,
.logos-chat__invite-button:focus-visible,
.logos-chat__invite-close:focus-visible,
.logos-chat__input:focus-visible,
.logos-chat__send:focus-visible,
.logos-chat__ai-fallback:focus-visible {
  outline: 3px solid #ffd777;
  outline-offset: 3px;
}

.logos-chat__invite {
  position: relative;
  width: min(318px, calc(100vw - 28px));
  display: grid;
  gap: 12px;
  padding: 20px 46px 18px 20px;
  border: 1px solid #e7dce9;
  border-radius: 18px 18px 4px 18px;
  color: #2f1e35;
  background: #fff;
  box-shadow: 0 18px 48px rgba(38, 0, 52, .2);
  animation: logos-chat-enter .25s ease-out;
}

.logos-chat__invite strong { line-height: 1.35; }

.logos-chat__invite-close,
.logos-chat__close {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.logos-chat__invite-close { position: absolute; top: 7px; right: 7px; color: #6e6471; background: transparent; }

.logos-chat__invite-button {
  width: fit-content;
  padding: 9px 15px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--chat-purple);
  font: inherit;
  font-size: .86rem;
  font-weight: 850;
  cursor: pointer;
}

.logos-chat__panel {
  width: min(430px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 100px));
  overflow: hidden;
  border: 1px solid #dfd2e3;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(34, 0, 47, .28);
  animation: logos-chat-enter .22s ease-out;
}

.logos-chat__header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 15px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--chat-purple-dark), var(--chat-purple));
}

.logos-chat__identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.logos-chat__identity > div { min-width: 0; }
.logos-chat__identity strong, .logos-chat__identity small { display: block; }
.logos-chat__identity strong { font-size: 1rem; }
.logos-chat__identity small { margin-top: 2px; overflow: hidden; color: rgba(255,255,255,.74); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }

.logos-chat__avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 50%;
  color: #371246;
  background: var(--chat-gold);
  font-weight: 950;
}

.logos-chat__close { flex: 0 0 auto; color: #fff; background: rgba(255,255,255,.12); }

.logos-chat__conversation {
  height: min(500px, calc(100vh - 275px));
  min-height: 300px;
  overflow-y: auto;
  padding: 20px;
  overscroll-behavior: contain;
  background: #faf7fb;
  scrollbar-color: #b79abe transparent;
  scrollbar-width: thin;
}

.logos-chat__bubble {
  width: fit-content;
  max-width: 90%;
  margin-bottom: 10px;
  padding: 11px 13px;
  border-radius: 15px;
  font-size: .9rem;
  line-height: 1.48;
  white-space: pre-line;
}

.logos-chat__bubble--bot { border: 1px solid #e6dce8; border-bottom-left-radius: 4px; color: #392c3d; background: #fff; }
.logos-chat__bubble--user { margin-left: auto; border-bottom-right-radius: 4px; color: #fff; background: var(--chat-purple); }
.logos-chat__bubble--thinking { color: #76697a; font-style: italic; }
.logos-chat__message-content { display: grid; gap: 8px; white-space: normal; }
.logos-chat__message-content p { margin: 0; }
.logos-chat__message-content ul { display: grid; gap: 6px; margin: 1px 0; padding-left: 19px; }
.logos-chat__message-content strong { color: #40124e; font-weight: 850; }

.logos-chat__options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 8px; }
.logos-chat__options--home { grid-template-columns: 1fr; }
.logos-chat__options--suggestions { grid-template-columns: 1fr; }

.logos-chat__option {
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid #d8c5dd;
  border-radius: 12px;
  color: #4b1b5b;
  background: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.28;
  cursor: pointer;
}

.logos-chat__options--home .logos-chat__option { min-height: 68px; padding: 13px 14px; text-align: left; }
.logos-chat__options--suggestions .logos-chat__option { min-height: 42px; text-align: left; font-weight: 750; }
.logos-chat__option strong { display: block; font-size: .86rem; }
.logos-chat__option small { display: block; margin-top: 4px; color: #756979; font-size: .7rem; font-weight: 600; line-height: 1.35; }
.logos-chat__option:hover { border-color: var(--chat-purple); background: #f7eef9; }

.logos-chat__navigation { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 10px; }
.logos-chat__back, .logos-chat__restart { padding: 7px 0; border: 0; color: #68157b; background: transparent; font: inherit; font-size: .79rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.logos-chat__summary { margin: 14px 0 4px; padding: 16px; border: 1px solid #decbe2; border-radius: 16px; background: #fff; }
.logos-chat__summary-title { display: block; margin-bottom: 12px; color: var(--chat-purple); font-size: .9rem; }
.logos-chat__summary-row { display: grid; grid-template-columns: 72px 1fr; gap: 8px; margin: 7px 0; color: #5e5361; font-size: .78rem; }
.logos-chat__summary-row strong { color: #312435; }

.logos-chat__whatsapp {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  color: #fff;
  background: #187b46;
  font-size: .87rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}
.logos-chat__whatsapp:hover { color: #fff; background: #11683a; }
.logos-chat__restart { width: 100%; margin-top: 7px; }

.logos-chat__ai-notice {
  margin: 10px 0 14px;
  padding: 11px 12px;
  border: 1px solid #ecdcae;
  border-radius: 12px;
  color: #624f25;
  background: #fff9e9;
  font-size: .7rem;
  line-height: 1.45;
}

.logos-chat__composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 14px; }
.logos-chat__input {
  width: 100%;
  min-height: 54px;
  max-height: 120px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid #cdb9d2;
  border-radius: 13px;
  color: #2f2432;
  background: #fff;
  font: inherit;
  font-size: .84rem;
  line-height: 1.4;
}
.logos-chat__input:focus { border-color: var(--chat-purple); box-shadow: 0 0 0 3px rgba(79,11,105,.08); }
.logos-chat__send {
  min-height: 48px;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--chat-purple);
  font: inherit;
  font-size: .8rem;
  font-weight: 900;
  cursor: pointer;
}
.logos-chat__send:disabled, .logos-chat__input:disabled { opacity: .6; cursor: wait; }

.logos-chat__sources { display: grid; gap: 5px; margin-top: 10px; padding-top: 9px; border-top: 1px solid #eee5ef; }
.logos-chat__sources strong { color: #6f6372; font-size: .67rem; }
.logos-chat__sources a { color: #651477; font-size: .68rem; font-weight: 750; text-decoration: underline; text-underline-offset: 2px; }

.logos-chat__ai-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.logos-chat__ai-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  border: 1px solid #d8c5dd;
  border-radius: 11px;
  color: #59116b;
  background: #fff;
  font-size: .72rem;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}
.logos-chat__ai-action--whatsapp { grid-column: 1 / -1; border-color: #187b46; color: #fff; background: #187b46; }
.logos-chat__ai-action--whatsapp:hover { color: #fff; background: #11683a; }

.logos-chat__ai-error { margin: 12px 0; padding: 12px; border: 1px solid #e5cfd2; border-radius: 13px; background: #fff4f5; }
.logos-chat__ai-error p { margin: 0; color: #70454a; font-size: .76rem; line-height: 1.45; }
.logos-chat__ai-fallback { margin-top: 9px; padding: 8px 11px; border: 0; border-radius: 9px; color: #fff; background: var(--chat-purple); font: inherit; font-size: .74rem; font-weight: 850; cursor: pointer; }

.logos-chat__footer { padding: 11px 16px 13px; border-top: 1px solid #e9e0eb; background: #fff; }
.logos-chat__footer p { margin: 0; color: #706873; font-size: .64rem; line-height: 1.45; }
.logos-chat__footer a { color: #621374; font-weight: 750; text-decoration: underline; text-underline-offset: 2px; }

@keyframes logos-chat-enter { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 540px) {
  .logos-chat { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); left: max(10px, env(safe-area-inset-left)); }
  .logos-chat__panel, .logos-chat__invite { width: 100%; }
  .logos-chat__panel { max-height: calc(100dvh - 86px - env(safe-area-inset-bottom)); border-radius: 20px; }
  .logos-chat__conversation { height: calc(100dvh - 300px - env(safe-area-inset-bottom)); min-height: 270px; padding: 16px; }
  .logos-chat__launcher { min-height: 50px; margin-left: auto; padding: 0 16px; }
  .logos-chat__composer { grid-template-columns: 1fr; }
  .logos-chat__send { width: 100%; }
  .logos-chat__footer { padding: 8px 12px 9px; }
  .logos-chat__footer p { font-size: .57rem; line-height: 1.3; }
}

@media (max-width: 370px) { .logos-chat__options { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .logos-chat__launcher, .logos-chat__invite, .logos-chat__panel { animation: none; transition: none; }
}
