:root {
  --mati-accent: #b8ed47;
  --mati-bg: #111310;
  --mati-line: rgba(255, 255, 255, 0.14);
  --mati-text: #f6f7f0;
  --mati-muted: #b7bdb2;
  --mati-cyan: #54c8d1;
}

.mati-root,
.mati-root * {
  box-sizing: border-box;
}

.mati-root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  z-index: 2147482000;
}

.mati-launcher[hidden],
.mati-panel[hidden] {
  display: none !important;
}

.mati-launcher {
  align-items: center;
  background: rgba(14, 17, 14, 0.97);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  bottom: max(var(--mati-launcher-bottom, 70px), calc(env(safe-area-inset-bottom) + 54px));
  box-shadow: 0 18px 55px rgba(16, 17, 15, 0.28);
  cursor: pointer;
  display: flex;
  gap: 11px;
  min-height: 64px;
  min-width: 218px;
  padding: 7px 17px 7px 7px;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  isolation: isolate;
  transition: background 0.25s ease, box-shadow 0.28s ease, transform 0.28s ease;
  z-index: 2147482001;
}

.mati-launcher__halo {
  animation: mati-launcher-orbit 2s linear infinite;
  background: conic-gradient(
    from var(--mati-orbit-angle),
    transparent 0 81%,
    rgba(255, 255, 255, 0.14) 85%,
    rgba(255, 255, 255, 0.96) 89%,
    rgba(255, 255, 255, 0.34) 91%,
    transparent 95% 100%
  );
  border-radius: inherit;
  inset: -1px;
  padding: 1px;
  pointer-events: none;
  position: absolute;
  z-index: 2;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.mati-launcher__visual {
  background: #050605;
  border-radius: 50%;
  display: grid;
  flex: 0 0 50px;
  height: 50px;
  isolation: isolate;
  overflow: hidden;
  place-items: center;
  position: relative;
  width: 50px;
}

.mati-launcher__visual::before {
  animation: mati-launcher-core-glow 3.2s ease-in-out infinite;
  background: conic-gradient(
    from 30deg,
    rgba(240, 194, 40, 0.72),
    rgba(83, 187, 128, 0.68),
    rgba(47, 151, 198, 0.76),
    rgba(207, 95, 143, 0.62),
    rgba(240, 194, 40, 0.72)
  );
  border-radius: 50%;
  content: "";
  filter: blur(8px);
  inset: 8px;
  opacity: 0.18;
  position: absolute;
}

.mati-launcher__mark {
  animation: mati-launcher-logo-alive 3.2s ease-in-out infinite;
  display: block;
  height: 42px;
  overflow: visible;
  position: relative;
  transform-origin: center;
  width: 45px;
  z-index: 1;
}

.mati-launcher__copy {
  color: #fff;
  display: block;
  line-height: 1.1;
  min-width: 0;
  text-align: left;
}

.mati-launcher__copy strong {
  display: block;
  font-size: 13px;
  font-weight: 760;
}

.mati-launcher__copy small {
  color: rgba(255, 255, 255, 0.58);
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 4px;
  white-space: nowrap;
}

.mati-launcher:hover {
  background: #20231d;
  box-shadow: 0 22px 62px rgba(16, 17, 15, 0.36);
  transform: translateY(-3px);
}

.mati-launcher:focus-visible,
.mati-head__copy:focus-visible,
.mati-panel button:focus-visible,
.mati-panel input:focus-visible,
.mati-booking-dialog button:focus-visible,
.mati-booking-dialog a:focus-visible {
  outline: 3px solid var(--mati-cyan);
  outline-offset: 3px;
}

.mati-panel {
  background: #111310;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 25px 25px 5px 25px;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
  box-shadow: 0 28px 85px rgba(0, 0, 0, 0.46), 0 0 0 1px rgba(184, 237, 71, 0.05);
  color: var(--mati-text);
  display: grid;
  grid-template-rows: auto auto minmax(170px, 1fr) auto auto;
  height: min(680px, calc(100dvh - 34px));
  max-height: 680px;
  overflow: hidden;
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  max-inline-size: calc(100% - 32px);
  width: min(410px, calc(100vw - 32px));
  z-index: 2147482002;
}

.mati-panel > *,
.mati-head > *,
.mati-form > * {
  min-width: 0;
}

.mati-panel::before {
  background: linear-gradient(90deg, #f5d553, #8ed36b, #28c3c8, #4aa2ed);
  content: "";
  height: 3px;
  inset: 0 0 auto;
  position: absolute;
}

.mati-panel--positioned {
  bottom: auto;
  left: var(--mati-panel-left);
  right: auto;
  top: var(--mati-panel-top);
}

.mati-panel--dragging {
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.54), 0 0 0 2px rgba(84, 200, 209, 0.28);
  user-select: none;
}

.mati-head {
  align-items: center;
  border-bottom: 1px solid var(--mati-line);
  cursor: grab;
  display: grid;
  gap: 9px;
  grid-template-columns: auto minmax(76px, 1fr) auto;
  min-height: 74px;
  padding: 13px 14px 11px;
  touch-action: none;
}

.mati-head:active {
  cursor: grabbing;
}

.mati-avatar {
  background: #080a08;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  display: grid;
  height: 44px;
  place-items: center;
  width: 44px;
}

.mati-avatar__mark {
  height: 29px;
  width: 36px;
}

.mati-head__copy {
  border-radius: 8px;
  cursor: grab;
  display: grid;
  line-height: 1.08;
  padding: 4px;
}

.mati-head__copy strong {
  color: #fff;
  font-size: 16px;
  font-weight: 760;
}

.mati-head__copy small {
  color: var(--mati-muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  margin-top: 4px;
  text-transform: uppercase;
}

.mati-head button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--mati-text);
  cursor: pointer;
  font: inherit;
}

.mati-head__close {
  border-radius: 50%;
  display: grid;
  font-size: 18px !important;
  height: 30px;
  place-items: center;
  width: 30px;
}

.mati-head__close {
  font-size: 24px !important;
}

.mati-head__close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.mati-status {
  align-items: center;
  background: #151813;
  color: var(--mati-muted);
  display: flex;
  font-size: 11px;
  gap: 8px;
  padding: 8px 16px;
}

.mati-status > span:first-child {
  animation: mati-status-pulse 1s ease-in-out infinite;
  background: var(--mati-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(184, 237, 71, 0.42);
  height: 8px;
  width: 8px;
}

.mati-thread {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.018), transparent 55%);
  display: flex;
  flex-direction: column;
  gap: 13px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.mati-message {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.mati-message--user {
  align-items: flex-end;
  align-self: flex-end;
}

.mati-message__bubble {
  background: #20241e;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 5px 17px 17px 17px;
  color: #edf0e8;
  font-size: 14px;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 11px 13px;
  white-space: pre-wrap;
}

.mati-message--user .mati-message__bubble {
  background: var(--mati-accent);
  border: 0;
  border-radius: 17px 5px 17px 17px;
  color: #161a12;
  font-weight: 620;
}

.mati-message__link {
  color: var(--mati-accent);
  font-size: 12px;
  margin: 7px 4px 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-underline-offset: 3px;
}

.mati-message__inline-link {
  color: var(--mati-accent);
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.mati-message__action {
  background: transparent;
  border: 1px solid rgba(184, 237, 71, 0.58);
  border-radius: 999px;
  color: var(--mati-accent);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.3;
  margin-top: 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 8px 12px;
  white-space: normal;
}

.mati-message--typing .mati-message__bubble {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}

.mati-message--typing span {
  animation: mati-typing 900ms ease-in-out infinite;
  background: var(--mati-accent);
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.mati-message--typing span:nth-child(2) { animation-delay: 120ms; }
.mati-message--typing span:nth-child(3) { animation-delay: 240ms; }

.mati-suggestions {
  border-top: 1px solid var(--mati-line);
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px 12px;
}

.mati-suggestions :is(button, a) {
  align-items: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #dce0d7;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 11px;
  justify-content: center;
  line-height: 1.3;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 8px 10px;
  text-align: center;
  text-decoration: none;
  white-space: normal;
}

.mati-suggestions .mati-suggestion--calendar {
  animation: mati-cta-pulse 2.2s ease-in-out infinite;
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}

.mati-suggestions :is(button, a):hover {
  border-color: var(--mati-accent);
  color: var(--mati-accent);
}

.mati-form {
  align-items: center;
  background: #0d0f0c;
  border-top: 1px solid var(--mati-line);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.mati-form input {
  background: #20241e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-size: 14px;
  min-width: 0;
  padding: 12px 15px;
  width: 100%;
}

.mati-form input::placeholder {
  color: #93998f;
}

.mati-form button {
  background: var(--mati-accent);
  border: 0;
  border-radius: 50%;
  color: #161a12;
  cursor: pointer;
  display: grid;
  font-size: 20px;
  font-weight: 800;
  height: 42px;
  place-items: center;
  width: 42px;
}

.mati-form button:disabled,
.mati-form input:disabled {
  cursor: wait;
  opacity: 0.58;
}

.mati-booking-dialog {
  background: transparent;
  border: 0;
  color: var(--mati-text);
  height: min(780px, calc(100dvh - 32px));
  max-width: 1000px;
  padding: 0;
  width: min(1000px, calc(100vw - 32px));
}

.mati-booking-dialog::backdrop {
  background: rgba(2, 5, 4, 0.74);
  backdrop-filter: blur(5px);
}

.mati-booking-panel {
  background: var(--mati-bg);
  border: 1px solid var(--mati-line);
  border-radius: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  overflow: hidden;
}

.mati-booking-head {
  align-items: center;
  border-bottom: 1px solid var(--mati-line);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.mati-booking-head span {
  color: var(--mati-accent);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mati-booking-head h2 {
  color: #fff;
  font-size: clamp(18px, 3vw, 26px);
  margin: 4px 0 0;
}

.mati-booking-head button {
  background: transparent;
  border: 1px solid var(--mati-line);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  padding: 8px 12px;
}

.mati-booking-frame {
  background: #fff;
  border: 0;
  height: 100%;
  width: 100%;
}

.mati-booking-panel > p {
  color: var(--mati-muted);
  font-size: 12px;
  margin: 0;
  padding: 10px 16px;
  text-align: center;
}

.mati-booking-panel a {
  color: var(--mati-accent);
}

.mati-sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@property --mati-orbit-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes mati-launcher-orbit {
  to { --mati-orbit-angle: 360deg; }
}

@keyframes mati-launcher-logo-alive {
  0%, 100% { filter: brightness(0.92) saturate(0.9); transform: scale(0.98); }
  50% { filter: brightness(1.15) saturate(1.22) drop-shadow(0 0 5px rgba(255, 255, 255, 0.2)); transform: scale(1.055); }
}

@keyframes mati-launcher-core-glow {
  0%, 100% { opacity: 0.12; transform: scale(0.94) rotate(-8deg); }
  50% { opacity: 0.3; transform: scale(1.06) rotate(8deg); }
}

@keyframes mati-cta-pulse {
  0%, 100% { border-color: rgba(255, 255, 255, 0.28); }
  50% { border-color: rgba(184, 237, 71, 0.92); }
}

@keyframes mati-status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 237, 71, 0.18); opacity: 0.62; transform: scale(0.82); }
  50% { box-shadow: 0 0 0 6px rgba(184, 237, 71, 0); opacity: 1; transform: scale(1.18); }
}

@keyframes mati-status-heartbeat-desktop {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 237, 71, 0.18), 0 0 8px rgba(184, 237, 71, 0.18); opacity: 0.52; filter: brightness(0.9); }
  48% { box-shadow: 0 0 0 7px rgba(184, 237, 71, 0), 0 0 14px rgba(184, 237, 71, 0.78); opacity: 1; filter: brightness(1.35); }
}

@keyframes mati-typing {
  0%, 100% { opacity: 0.32; transform: translateY(1px); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 620px) {
  .mati-launcher {
    bottom: max(var(--mati-launcher-bottom, 62px), calc(env(safe-area-inset-bottom) + 46px));
    min-height: 58px;
    min-width: 198px;
    padding-right: 14px;
    right: max(12px, env(safe-area-inset-right));
  }

  .mati-launcher.mati-launcher--compact {
    border-color: rgba(255, 255, 255, 0.82);
    border-radius: 50%;
    box-shadow: 0 12px 34px rgba(8, 10, 8, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.12);
    gap: 0;
    height: 52px;
    min-height: 52px;
    min-width: 52px;
    padding: 3px;
    right: max(8px, env(safe-area-inset-right));
    width: 52px;
  }

  /* El estado visual también depende de la raíz cerrada. Esto evita que una
     restauración tardía del estado quite la clase compacta en Safari móvil. */
  .mati-root:not(.mati-root--open) .mati-launcher {
    border-color: rgba(255, 255, 255, 0.82);
    border-radius: 50%;
    box-shadow: 0 12px 34px rgba(8, 10, 8, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.12);
    gap: 0;
    height: 52px;
    min-height: 52px;
    min-width: 52px;
    padding: 3px;
    right: max(8px, env(safe-area-inset-right));
    width: 52px;
  }

  .mati-launcher--compact .mati-launcher__copy {
    display: none;
  }

  .mati-root:not(.mati-root--open) .mati-launcher__copy {
    display: none;
  }

  .mati-launcher--compact .mati-launcher__visual {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .mati-root:not(.mati-root--open) .mati-launcher__visual {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .mati-launcher--compact .mati-launcher__mark {
    animation-duration: 2.2s;
    height: 36px;
    width: 39px;
  }

  .mati-root:not(.mati-root--open) .mati-launcher__mark {
    animation-duration: 2.2s;
    height: 36px;
    width: 39px;
  }

  .mati-launcher--compact:hover {
    transform: none;
  }

  .mati-root:not(.mati-root--open) .mati-launcher:hover {
    transform: none;
  }

  .mati-launcher__visual {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .mati-launcher__mark {
    height: 37px;
    width: 40px;
  }

  .mati-panel {
    border-radius: 20px 20px 4px 20px;
    bottom: max(10px, env(safe-area-inset-bottom));
    height: calc(100dvh - 20px);
    left: max(10px, env(safe-area-inset-left));
    max-inline-size: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
    right: max(10px, env(safe-area-inset-right));
    width: auto;
  }

  .mati-panel.mati-panel--positioned {
    bottom: auto;
    left: var(--mati-panel-left);
    right: auto;
    top: var(--mati-panel-top);
    width: min(410px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  .mati-head {
    gap: 6px;
    grid-template-columns: auto minmax(60px, 1fr) auto;
    padding: 11px 10px 9px;
  }

  .mati-head__close {
    height: 28px;
    width: 28px;
  }

  .mati-thread {
    padding: 14px 12px;
  }

  .mati-message {
    max-width: 94%;
  }

  .mati-suggestions {
    grid-template-columns: minmax(0, 1fr);
    padding: 9px 10px;
  }

  .mati-suggestions :is(button, a) {
    min-height: 40px;
    padding: 9px 12px;
  }

  .mati-form {
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 44px;
    max-width: 100%;
    overflow: hidden;
    padding: 10px;
  }

  .mati-form input {
    font-size: 16px;
    padding: 11px 13px;
  }

  .mati-form button {
    height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    width: 44px;
  }

  .mati-message__action {
    min-height: 40px;
    text-align: center;
    width: 100%;
  }

  .mati-booking-dialog {
    height: calc(100dvh - 16px);
    max-width: calc(100% - 16px);
    width: calc(100% - 16px);
  }

  .mati-booking-head {
    align-items: flex-start;
    gap: 10px;
    padding: 13px 12px;
  }

  .mati-booking-head > div {
    min-width: 0;
  }

  .mati-booking-head h2,
  .mati-booking-panel > p {
    overflow-wrap: anywhere;
  }

  .mati-booking-head button {
    flex: 0 0 auto;
  }
}

@media (min-width: 681px) {
  .mati-status > span:first-child {
    animation: mati-status-heartbeat-desktop 1.55s ease-in-out infinite !important;
    flex: 0 0 9px;
    height: 9px;
    width: 9px;
  }
}


@media (max-width: 390px) {
  .mati-head__copy small {
    display: none;
  }

  .mati-avatar {
    height: 38px;
    width: 38px;
  }

  .mati-avatar__mark {
    height: 25px;
    width: 31px;
  }
}
