/* MadeByMe assistant: the chat in the corner. */

.ai-open {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 18px 13px 15px;
  border: 1px solid rgba(190,183,255,.35);
  border-radius: 999px;
  background: linear-gradient(155deg, #2a2850, #16152a);
  color: #f7f7fa;
  font: 600 14px/1 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  box-shadow: 0 14px 40px #000a, 0 0 28px #8582e22e;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s;
}
.ai-open:hover { transform: translateY(-3px); border-color: rgba(190,183,255,.7); }
.ai-open[hidden] { display: none; }
.ai-open img { width: 24px; height: 24px; margin: -3px 0; }
.ai-open:focus-visible, .ai-close:focus-visible, .ai-send:focus-visible, .ai-ideas button:focus-visible { outline: 2px solid #bdb8ff; outline-offset: 3px; }

.ai {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1001;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 44px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: linear-gradient(160deg, #12142a, #08080f 70%);
  box-shadow: 0 30px 80px #000c, 0 0 40px #258ff51f;
  color: #f7f7fa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  transform-origin: bottom right;
  animation: aiIn .3s cubic-bezier(.2,.8,.2,1);
}
.ai[hidden] { display: none; }
@keyframes aiIn { from { opacity: 0; transform: scale(.92) translateY(10px); } }

/* Starry sky behind the chat: fixed stars plus a shooting star that crosses now and then. */
.ai > * { position: relative; z-index: 1; }
.ai::before, .ai::after { content: ""; position: absolute; pointer-events: none; }
.ai::before {
  inset: 0;
  background:
    radial-gradient(1.8px 1.8px at 12% 14%, #fffc, transparent),
    radial-gradient(1.5px 1.5px at 34% 30%, #fff9, transparent),
    radial-gradient(2.1px 2.1px at 78% 9%, #fffd, transparent),
    radial-gradient(1.5px 1.5px at 63% 42%, #fff8, transparent),
    radial-gradient(1.8px 1.8px at 88% 37%, #cfe8ffcc, transparent),
    radial-gradient(1.5px 1.5px at 20% 58%, #fff8, transparent),
    radial-gradient(1.9px 1.9px at 47% 66%, #fffb, transparent),
    radial-gradient(1.5px 1.5px at 82% 71%, #fff9, transparent),
    radial-gradient(1.8px 1.8px at 9% 84%, #cfe8ffcc, transparent),
    radial-gradient(1.5px 1.5px at 56% 89%, #fff8, transparent),
    radial-gradient(2.1px 2.1px at 93% 92%, #fffc, transparent),
    radial-gradient(1.5px 1.5px at 29% 95%, #fff7, transparent);
}
.ai::after {
  top: 70px;
  right: -20px;
  width: 110px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #e0f2fe, #7dd3fc 25%, transparent);
  box-shadow: 0 0 8px #7dd3fc88;
  transform: rotate(-32deg);
  opacity: 0;
  animation: aiShoot 9s 1.5s infinite;
}
@keyframes aiShoot {
  0% { opacity: 0; translate: 0 0; }
  2% { opacity: .9; }
  10% { opacity: 0; translate: -260px 160px; }
  100% { opacity: 0; translate: -260px 160px; }
}

.ai-head { display: flex; align-items: center; gap: 10px; padding: 15px 14px 14px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.ai-head b { font-size: 15px; letter-spacing: -.01em; }
.ai-head small { display: block; color: #9899a8; font-size: 12px; margin-top: 2px; }
.ai-avatar { position: relative; flex: none; }
.ai-avatar img { display: block; width: 34px; height: 34px; }
.ai-dot { position: absolute; right: -1px; bottom: 1px; width: 9px; height: 9px; border: 2px solid #18182a; border-radius: 50%; background: #5be3a8; box-shadow: 0 0 10px #5be3a8; }
.ai-dot.off { background: #686977; box-shadow: none; }
.ai-close { margin-left: auto; width: 32px; height: 32px; border: 0; border-radius: 10px; background: none; color: #9899a8; font-size: 20px; cursor: pointer; }
.ai-close:hover { background: #ffffff12; color: #f7f7fa; }

.ai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 86%; padding: 10px 13px; border-radius: 15px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-msg.bot { align-self: flex-start; background: #171b33d9; border: 1px solid #ffffff14; border-bottom-left-radius: 5px; }
.ai-msg.me { align-self: flex-end; background: #4b48a8; border-bottom-right-radius: 5px; }
.ai-msg.err { color: #ffb3c0; }
.ai-msg a { color: #c3c1ff; }
.ai-typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #9899a8; animation: aiDot 1s infinite alternate; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDot { to { opacity: .2; transform: translateY(-3px); } }

.ai-ideas { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.ai-ideas[hidden] { display: none; }
.ai-ideas button { border: 1px solid #ffffff21; border-radius: 999px; background: none; color: #c3c1ff; font: inherit; font-size: 12.5px; padding: 6px 11px; cursor: pointer; }
.ai-ideas button:hover { border-color: rgba(190,183,255,.6); background: #ffffff0a; }

.ai-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.ai-form textarea { flex: 1; resize: none; height: 42px; padding: 11px 13px; border: 1px solid #ffffff1f; border-radius: 13px; background: #00000040; color: #f7f7fa; font: inherit; font-size: 14px; }
.ai-form textarea:focus { outline: none; border-color: rgba(190,183,255,.6); }
.ai-send { width: 42px; border: 0; border-radius: 13px; background: #6d6af0; color: #fff; cursor: pointer; display: grid; place-items: center; }
.ai-send:disabled { opacity: .45; cursor: default; }
.ai-send svg { width: 18px; height: 18px; }

@media (max-width: 600px) {
  .ai-open { right: 14px; bottom: 14px; }
  .ai { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100dvh - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .ai, .ai-typing span { animation: none; }
  .ai::after { animation: none; opacity: .8; translate: -120px 230px; }
  .ai-open { transition: none; }
}
