#matachin-chatbot.matachin-chatbot {
  --matachin-ink: #10232b;
  --matachin-text: #33464d;
  --matachin-muted: #748087;
  --matachin-line: #dfe3e1;
  --matachin-surface: #ffffff;
  --matachin-soft: #f2f4f4;
  --matachin-soft-2: #e8ebeb;
  position: fixed;
  right: 16px;
  bottom: 24px;
  z-index: 2147483000;
  color: var(--matachin-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
}

#matachin-chatbot.matachin-chatbot--position-left {
  right: auto;
  left: 18px;
}

#matachin-chatbot.matachin-chatbot--position-left .matachin-chatbot__panel {
  right: auto;
  left: 0;
}

#matachin-chatbot *,
#matachin-chatbot *::before,
#matachin-chatbot *::after {
  box-sizing: border-box;
}

#matachin-chatbot [hidden] {
  display: none !important;
}

.matachin-chatbot__toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 8px 12px rgba(16, 35, 43, 0.14));
}

.matachin-chatbot__toggle span {
  order: 1;
  margin: 0 0 5px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--matachin-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.matachin-chatbot__toggle img {
  order: 2;
  display: block;
  width: 56px;
  height: 61px;
  object-fit: contain;
  transition: transform 180ms ease;
}

.matachin-chatbot--pet-small .matachin-chatbot__toggle img {
  width: 50px;
  height: 54px;
}

.matachin-chatbot--pet-large .matachin-chatbot__toggle img {
  width: 68px;
  height: 74px;
}

.matachin-chatbot__toggle:hover img,
.matachin-chatbot__toggle:focus-visible img {
  transform: translateY(-2px);
}

.matachin-chatbot__close:focus-visible,
.matachin-chatbot__reset:focus-visible,
.matachin-chatbot__message a:focus-visible,
.matachin-chatbot__form button:focus-visible {
  outline: 2px solid #66747a;
  outline-offset: 3px;
}

.matachin-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(340px, calc(100vw - 24px));
  height: min(520px, calc(100dvh - 104px));
  min-height: 400px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--matachin-line);
  border-radius: 24px;
  background: var(--matachin-surface);
  box-shadow: 0 18px 48px rgba(16, 35, 43, 0.16);
  animation: matachin-chatbot-in 180ms ease-out;
}

.matachin-chatbot--chat-compact .matachin-chatbot__panel {
  width: min(320px, calc(100vw - 24px));
  height: min(460px, calc(100dvh - 104px));
}

.matachin-chatbot--chat-large .matachin-chatbot__panel {
  width: min(380px, calc(100vw - 24px));
  height: min(610px, calc(100dvh - 104px));
}

.matachin-chatbot__header {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 104px 12px 14px;
  border-bottom: 1px solid var(--matachin-line);
  background: var(--matachin-soft);
  color: var(--matachin-ink);
}

.matachin-chatbot__avatar {
  width: 40px;
  height: 44px;
  display: grid;
  flex: 0 0 40px;
  place-items: center;
}

.matachin-chatbot__avatar img {
  width: 40px;
  height: 44px;
  object-fit: contain;
}

.matachin-chatbot__header strong,
.matachin-chatbot__header small {
  display: block;
}

.matachin-chatbot__header strong {
  margin-bottom: 2px;
  color: var(--matachin-ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}

.matachin-chatbot__header small {
  color: var(--matachin-muted);
  font-size: 10px;
  font-weight: 500;
}

.matachin-chatbot__close,
.matachin-chatbot__reset {
  position: absolute;
  top: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #657279;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}

.matachin-chatbot__close {
  right: 9px;
  padding-bottom: 2px;
  font-size: 23px;
}

.matachin-chatbot__reset {
  right: 51px;
  font-size: 19px;
  font-weight: 700;
}

.matachin-chatbot__close:hover,
.matachin-chatbot__reset:hover {
  background: #e4e8e8;
  color: var(--matachin-ink);
}

.matachin-chatbot__messages {
  overflow-y: auto;
  padding: 18px;
  background: #fff;
  scrollbar-color: #cbd1d2 transparent;
  scrollbar-width: thin;
}

.matachin-chatbot__message {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
}

.matachin-chatbot__message > span {
  display: none;
}

.matachin-chatbot__message > div {
  max-width: 100%;
}

.matachin-chatbot__message p,
.matachin-chatbot__message > div p {
  max-width: 100%;
  margin: 0;
  padding: 13px 15px;
  border-radius: 17px 17px 17px 5px;
  background: #dde2e2;
  color: #273a42;
  box-shadow: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
}

.matachin-chatbot__message--user {
  justify-content: flex-end;
}

.matachin-chatbot__message--user p {
  max-width: calc(100% - 44px);
  margin-left: auto;
  border-radius: 17px 17px 5px 17px;
  background: #f3f4f4;
  color: var(--matachin-ink);
}

#matachin-chatbot .matachin-chatbot__message--assistant p {
  background: #dde2e2 !important;
  color: #273a42 !important;
}

#matachin-chatbot .matachin-chatbot__message--user p {
  background: #f3f4f4 !important;
  color: var(--matachin-ink) !important;
}

.matachin-chatbot__message-time {
  display: block;
  margin-top: 4px;
  padding: 0 4px;
  color: #8c969a;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.matachin-chatbot__message--user .matachin-chatbot__message-time {
  text-align: right;
}

.matachin-chatbot__sources {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}

.matachin-chatbot__sources > strong {
  color: var(--matachin-muted);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.matachin-chatbot__message a {
  width: fit-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #e0e4e4;
  border-radius: 999px;
  background: #f5f6f6;
  color: var(--matachin-ink);
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
}

.matachin-chatbot__message a:hover,
.matachin-chatbot__message a:focus-visible {
  border-color: #cbd1d2;
  background: #e9ecec;
}

.matachin-chatbot__thinking p {
  display: flex;
  gap: 4px;
  padding: 15px 17px;
}

.matachin-chatbot__thinking i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7f8b90;
  animation: matachin-chatbot-dot 1s ease-in-out infinite;
}

.matachin-chatbot__thinking i:nth-child(2) { animation-delay: 150ms; }
.matachin-chatbot__thinking i:nth-child(3) { animation-delay: 300ms; }

.matachin-chatbot__controls {
  padding: 10px 18px 15px;
  border-top: 1px solid #edf0ef;
  background: #fafbfb;
}

.matachin-chatbot__prompts {
  display: none;
}

.matachin-chatbot__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 7px;
  padding: 5px 5px 5px 14px;
  border: 1px solid #cfd5d6;
  border-radius: 999px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.matachin-chatbot__form:focus-within {
  border-color: #7f8b90;
  box-shadow: 0 0 0 2px rgba(127, 139, 144, 0.14);
}

.matachin-chatbot__form input {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--matachin-ink);
  font-family: inherit;
  font-size: 13px;
}

.matachin-chatbot__form button {
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50% !important;
  background: var(--matachin-ink);
  color: #fff;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.matachin-chatbot__form button:hover {
  background: #263a42;
}

.matachin-chatbot__form button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.matachin-chatbot__note {
  display: block;
  margin-top: 8px;
  color: #899499;
  font-size: 8px;
  text-align: center;
}

.matachin-chatbot__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Aislamiento frente a los estilos globales de botones, enlaces y formularios del tema. */
#matachin-chatbot .matachin-chatbot__toggle,
#matachin-chatbot .matachin-chatbot__toggle:hover,
#matachin-chatbot .matachin-chatbot__toggle:focus,
#matachin-chatbot .matachin-chatbot__toggle:focus-visible,
#matachin-chatbot .matachin-chatbot__toggle:active {
  width: auto !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 18px !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: inherit !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

#matachin-chatbot .matachin-chatbot__toggle span {
  position: static !important;
  display: block !important;
  margin: 0 0 7px !important;
  padding: 7px 11px !important;
  border: 0 !important;
  border-radius: 999px !important;
  outline: 0 !important;
  background: var(--matachin-ink) !important;
  box-shadow: none !important;
  color: #fff !important;
  transform: translateY(-3px);
}

#matachin-chatbot .matachin-chatbot__toggle:focus-visible span {
  box-shadow: 0 0 0 2px #7c888d !important;
}

#matachin-chatbot.matachin-chatbot--open .matachin-chatbot__toggle {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

#matachin-chatbot.matachin-chatbot--open .matachin-chatbot__toggle span {
  display: none !important;
}

#matachin-chatbot .matachin-chatbot__reset,
#matachin-chatbot .matachin-chatbot__close,
#matachin-chatbot .matachin-chatbot__reset:focus,
#matachin-chatbot .matachin-chatbot__close:focus,
#matachin-chatbot .matachin-chatbot__reset:active,
#matachin-chatbot .matachin-chatbot__close:active {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #657279 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

#matachin-chatbot .matachin-chatbot__reset:hover,
#matachin-chatbot .matachin-chatbot__close:hover {
  border: 0 !important;
  background: #e4e8e8 !important;
  box-shadow: none !important;
  color: var(--matachin-ink) !important;
}

#matachin-chatbot .matachin-chatbot__reset:focus-visible,
#matachin-chatbot .matachin-chatbot__close:focus-visible {
  outline: 2px solid #7c888d !important;
  outline-offset: 0 !important;
}

#matachin-chatbot button::before,
#matachin-chatbot button::after {
  display: none !important;
  content: none !important;
}

#matachin-chatbot .matachin-chatbot__form,
#matachin-chatbot .matachin-chatbot__form:hover {
  border: 1px solid #cfd5d6 !important;
  outline: 0 !important;
  background: #fff !important;
  box-shadow: none !important;
}

#matachin-chatbot .matachin-chatbot__form:focus-within {
  border-color: #7f8b90 !important;
  outline: 0 !important;
  box-shadow: 0 0 0 2px rgba(127, 139, 144, 0.14) !important;
}

#matachin-chatbot .matachin-chatbot__form input,
#matachin-chatbot .matachin-chatbot__form input:hover,
#matachin-chatbot .matachin-chatbot__form input:focus,
#matachin-chatbot .matachin-chatbot__form input:focus-visible,
#matachin-chatbot .matachin-chatbot__form input:active {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--matachin-ink) !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

#matachin-chatbot .matachin-chatbot__form button,
#matachin-chatbot .matachin-chatbot__form button:hover,
#matachin-chatbot .matachin-chatbot__form button:focus,
#matachin-chatbot .matachin-chatbot__form button:active {
  border: 0 !important;
  outline: 0 !important;
  background: var(--matachin-ink) !important;
  box-shadow: none !important;
  color: #fff !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

#matachin-chatbot .matachin-chatbot__form button:hover {
  background: #263a42 !important;
}

#matachin-chatbot .matachin-chatbot__form button:focus-visible {
  outline: 2px solid #7c888d !important;
  outline-offset: 2px !important;
}

#matachin-chatbot .matachin-chatbot__message a,
#matachin-chatbot .matachin-chatbot__message a:hover,
#matachin-chatbot .matachin-chatbot__message a:focus,
#matachin-chatbot .matachin-chatbot__message a:active {
  border: 1px solid #d8dddd !important;
  outline: 0 !important;
  background: #f4f5f5 !important;
  box-shadow: none !important;
  color: var(--matachin-ink) !important;
  text-decoration: none !important;
}

#matachin-chatbot .matachin-chatbot__message a:hover {
  border-color: #c8cecf !important;
  background: #e9ecec !important;
}

#matachin-chatbot .matachin-chatbot__message a:focus-visible {
  outline: 2px solid #7c888d !important;
  outline-offset: 2px !important;
}

@keyframes matachin-chatbot-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes matachin-chatbot-dot {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

@media (max-width: 600px) {
  #matachin-chatbot.matachin-chatbot {
    right: 10px;
    bottom: max(18px, env(safe-area-inset-bottom));
  }

  #matachin-chatbot.matachin-chatbot--position-left {
    left: 10px;
  }

  .matachin-chatbot__panel {
    position: fixed;
    right: 10px;
    bottom: calc(90px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    height: min(560px, calc(100dvh - 108px - env(safe-area-inset-bottom)));
    max-height: calc(100dvh - 108px - env(safe-area-inset-bottom));
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .matachin-chatbot__panel,
  .matachin-chatbot__toggle img,
  .matachin-chatbot__thinking i {
    animation: none;
    transition: none;
  }
}
