/* Mimoup AI chat — shared home preview + embed (v4) */
.mai-chat {
  --mai-accent: #6d28d9;
  --mai-ink: #0a0f1c;
  --mai-muted: #6b7280;
  --mai-line: rgba(15, 23, 42, 0.08);
  --mai-bg: #eef1f7;
  --mai-surface: #ffffff;
  --mai-radius: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 392px;
  height: 540px;
  max-height: min(74vh, 580px);
  border-radius: var(--mai-radius);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(165deg, #ffffff 0%, #f8f9fc 100%);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.04),
    0 2px 3px rgba(15, 23, 42, 0.03),
    0 28px 64px -12px rgba(15, 23, 42, 0.28),
    0 48px 100px -24px color-mix(in srgb, var(--mai-accent) 35%, transparent);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  color: var(--mai-ink);
  -webkit-font-smoothing: antialiased;
}

.mai-chat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(
    90deg,
    #6366f1 0%,
    var(--mai-accent) 40%,
    #ec4899 75%,
    #38bdf8 100%
  );
  background-size: 200% 100%;
  animation: mai-sheen 6s linear infinite;
  z-index: 3;
}

.mai-chat *,
.mai-chat *::before,
.mai-chat *::after {
  box-sizing: border-box;
}

/* —— Header —— */
.mai-chat__head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.05rem 1.05rem 1rem;
  background:
    radial-gradient(
      120% 140% at 0% 0%,
      color-mix(in srgb, var(--mai-accent) 14%, transparent),
      transparent 55%
    ),
    linear-gradient(180deg, #fff 0%, #fafbff 100%);
  border-bottom: 1px solid var(--mai-line);
  backdrop-filter: blur(8px);
}

.mai-chat__identity {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.mai-chat__avatar {
  position: relative;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 45%),
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--mai-accent) 75%, #818cf8) 0%,
      var(--mai-accent) 45%,
      color-mix(in srgb, var(--mai-accent) 55%, #0f172a) 100%
    );
  border: 2.5px solid #fff;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--mai-accent) 22%, transparent),
    0 10px 22px color-mix(in srgb, var(--mai-accent) 32%, transparent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 1px rgba(15, 23, 42, 0.2);
}

.mai-chat__online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.mai-chat__avatar--sm {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.56rem;
  border-width: 2px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--mai-accent) 16%, transparent),
    0 6px 14px color-mix(in srgb, var(--mai-accent) 18%, transparent);
}

.mai-chat__avatar--sm .mai-chat__online {
  display: none;
}

.mai-chat__meta {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.mai-chat__meta strong {
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--mai-ink);
}

.mai-chat__meta small {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: #16a34a;
}

.mai-chat__status {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
  animation: mai-pulse 2.2s ease-in-out infinite;
}

.mai-chat__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin-left: 0.15rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mai-accent) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--mai-accent) 18%, #e2e8f0);
  color: color-mix(in srgb, var(--mai-accent) 85%, #0f172a);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.mai-chat__close {
  appearance: none;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 999px;
  border: 1px solid var(--mai-line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--mai-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease,
    border-color 0.15s ease;
}

.mai-chat__close:hover {
  background: #f1f5f9;
  color: var(--mai-ink);
  border-color: #d5dce6;
  transform: rotate(90deg);
}

/* —— Messages —— */
.mai-chat__body {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem 1rem 0.7rem;
  background-color: var(--mai-bg);
  background-image:
    radial-gradient(
      ellipse 85% 50% at 100% 0%,
      color-mix(in srgb, var(--mai-accent) 12%, transparent),
      transparent 58%
    ),
    radial-gradient(
      ellipse 70% 45% at 0% 100%,
      color-mix(in srgb, #38bdf8 10%, transparent),
      transparent 55%
    ),
    radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.035) 1px, transparent 0);
  background-size: auto, auto, 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scrollbar-width: thin;
  scrollbar-color: #c4cddb transparent;
}

.mai-chat__row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 88%;
  animation: mai-chat-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mai-chat__row:nth-child(1) {
  animation-delay: 0.05s;
}
.mai-chat__row:nth-child(2) {
  animation-delay: 0.18s;
}
.mai-chat__row:nth-child(3) {
  animation-delay: 0.32s;
}
.mai-chat__row:nth-child(4) {
  animation-delay: 0.42s;
}

.mai-chat__row.is-bot {
  align-self: flex-start;
}

.mai-chat__row.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.mai-chat__bubble {
  position: relative;
  padding: 0.8rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  line-height: 1.55;
  letter-spacing: -0.011em;
  white-space: pre-wrap;
  word-break: break-word;
}

.mai-chat__row.is-bot .mai-chat__bubble {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.05);
  color: var(--mai-ink);
  border-bottom-left-radius: 6px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 10px 24px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(6px);
}

.mai-chat__row.is-user .mai-chat__bubble {
  background: linear-gradient(
    155deg,
    color-mix(in srgb, var(--mai-accent) 78%, #a78bfa) 0%,
    var(--mai-accent) 55%,
    color-mix(in srgb, var(--mai-accent) 78%, #4c1d95) 100%
  );
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow:
    0 12px 28px color-mix(in srgb, var(--mai-accent) 36%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.25) inset;
}

.mai-chat__row.is-thinking .mai-chat__bubble {
  display: inline-flex;
  align-items: center;
  min-height: 2.55rem;
  padding: 0.75rem 1rem;
  color: var(--mai-muted);
}

.mai-chat__dots {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mai-chat__dots i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mai-accent) 60%, #94a3b8);
  animation: mai-dot 1.1s ease-in-out infinite;
}

.mai-chat__dots i:nth-child(2) {
  animation-delay: 0.14s;
}
.mai-chat__dots i:nth-child(3) {
  animation-delay: 0.28s;
}

.mai-chat__time {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #94a3b8;
}

.mai-chat__row.is-user .mai-chat__time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

/* Quick replies */
.mai-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.15rem;
  background: transparent;
  animation: mai-chat-in 0.45s 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mai-chat__suggestions button {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--mai-accent) 22%, #e2e8f0);
  background: #fff;
  color: color-mix(in srgb, var(--mai-accent) 80%, #0f172a);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.mai-chat__suggestions button:hover {
  background: color-mix(in srgb, var(--mai-accent) 8%, #fff);
  border-color: color-mix(in srgb, var(--mai-accent) 40%, #e2e8f0);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--mai-accent) 14%, transparent);
}

/* —— Composer —— */
.mai-chat__composer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.55rem 0.85rem 0.35rem;
  padding: 0.4rem 0.4rem 0.4rem 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 10px 28px rgba(15, 23, 42, 0.06);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.mai-chat__composer:focus-within {
  border-color: color-mix(in srgb, var(--mai-accent) 45%, #e2e8f0);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--mai-accent) 12%, transparent),
    0 12px 30px rgba(15, 23, 42, 0.08);
}

.mai-chat__composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--mai-ink);
  background: transparent;
  outline: none;
}

.mai-chat__composer input::placeholder {
  color: #9aa3b2;
}

.mai-chat__send {
  appearance: none;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--mai-accent) 70%, #c4b5fd),
    var(--mai-accent) 45%,
    color-mix(in srgb, var(--mai-accent) 70%, #312e81)
  );
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow:
    0 10px 24px color-mix(in srgb, var(--mai-accent) 38%, transparent),
    0 1px 0 rgba(255, 255, 255, 0.28) inset;
  transition:
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.18s ease;
}

.mai-chat__send:hover {
  filter: brightness(1.06);
  transform: scale(1.06);
}

.mai-chat__send:active {
  transform: scale(0.96);
}

.mai-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.mai-chat__send svg {
  width: 1.05rem;
  height: 1.05rem;
}

.mai-chat__brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 0.25rem 0.75rem 0.85rem;
  background: transparent;
}

.mai-chat__brand::before,
.mai-chat__brand::after {
  content: "";
  width: 1.1rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d5dce8, transparent);
}

.mai-chat__brand[hidden] {
  display: none !important;
}

/* Embed launcher + shell */
.mai-root {
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: #0a0f1c;
  position: fixed;
  z-index: 2147483000;
  right: 1.2rem;
  bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9rem;
  isolation: isolate;
}

.mai-root *,
.mai-root *::before,
.mai-root *::after {
  box-sizing: border-box;
}

.mai-launcher {
  position: relative;
  width: 3.9rem;
  height: 3.9rem;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--mai-accent, #6d28d9) 70%, #c4b5fd),
    var(--mai-accent, #6d28d9) 50%,
    color-mix(in srgb, var(--mai-accent, #6d28d9) 70%, #312e81)
  );
  box-shadow:
    0 0 0 7px color-mix(in srgb, var(--mai-accent, #6d28d9) 12%, transparent),
    0 16px 36px color-mix(in srgb, var(--mai-accent, #6d28d9) 42%, transparent),
    0 2px 6px rgba(15, 23, 42, 0.14);
  display: grid;
  place-items: center;
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.2s ease;
}

.mai-launcher::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  border: 2px solid color-mix(in srgb, var(--mai-accent, #6d28d9) 35%, transparent);
  animation: mai-ring 2.4s ease-out infinite;
  pointer-events: none;
}

.mai-launcher:hover {
  filter: brightness(1.06);
  transform: translateY(-4px) scale(1.05);
}

.mai-launcher:active {
  transform: translateY(-1px) scale(0.97);
}

.mai-launcher svg {
  width: 1.45rem;
  height: 1.45rem;
  position: relative;
  z-index: 1;
}

.mai-root .mai-chat {
  display: none;
  width: min(392px, calc(100vw - 1.75rem));
}

.mai-root .mai-chat.is-open {
  display: flex;
  animation: mai-chat-pop 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes mai-chat-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes mai-chat-pop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes mai-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.05);
  }
}

@keyframes mai-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0) scale(0.9);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px) scale(1.05);
  }
}

@keyframes mai-sheen {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

@keyframes mai-ring {
  0% {
    transform: scale(0.92);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}

@media (max-width: 420px) {
  .mai-root {
    right: 0.75rem;
    bottom: 0.75rem;
  }
  .mai-chat {
    height: min(74vh, 580px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mai-chat::before,
  .mai-chat__status,
  .mai-chat__dots i,
  .mai-launcher::before,
  .mai-chat__row,
  .mai-chat__suggestions,
  .mai-root .mai-chat.is-open {
    animation: none !important;
  }
}
