/* "Speak with our AI": the helper button in the corner and its chat panel (helper.js). */
.ai-helper {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;   /* under pop-ups (100) and toasts (200) */
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none;
  transition: bottom 0.25s ease;
}
.ai-helper > * { pointer-events: auto; }
body.has-tray .ai-helper { bottom: 96px; }

/* ---------- launcher ---------- */
.ai-launch {
  display: flex; align-items: center; gap: 10px; padding: 7px 18px 7px 7px; border-radius: 999px; cursor: pointer; text-align: left;
  color: #fff; border: 1px solid rgba(255, 220, 255, 0.55);
  background: linear-gradient(135deg, #ff8be8 0%, #b678ff 45%, #6b2bd6 100%);
  box-shadow: 0 0 0 4px rgba(182, 120, 255, 0.18), 0 14px 34px rgba(110, 40, 200, 0.55), 0 0 30px rgba(255, 140, 230, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: ai-glow 3.2s ease-in-out infinite;
  transition: transform 0.18s ease, filter 0.2s;
}
.ai-launch:hover { transform: translateY(-2px); filter: brightness(1.08); }
.ai-launch-icon { position: relative; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #3a1d63, #12042a 75%); border: 1.5px solid rgba(255, 255, 255, 0.6); }
.ai-launch-icon svg { width: 36px; height: 36px; }
.ai-spark { position: absolute; top: -4px; right: -3px; font-style: normal; font-size: 0.9rem; color: #fff6c9; text-shadow: 0 0 8px #ffd98a; animation: ai-twinkle 2.4s ease-in-out infinite; }
.ai-launch-text { display: grid; line-height: 1.15; }
.ai-launch-text small { font-weight: 700; font-size: 0.74rem; opacity: 0.92; }
.ai-launch-text b { font-family: var(--font-label); font-weight: 900; font-size: 0.86rem; letter-spacing: 0.08em; text-transform: uppercase; text-shadow: 0 1px 2px rgba(40, 0, 70, 0.6); }
.ai-helper.open .ai-launch { animation: none; padding-right: 7px; }
.ai-helper.open .ai-launch-text { display: none; }
@keyframes ai-glow { 50% { box-shadow: 0 0 0 7px rgba(182, 120, 255, 0.12), 0 14px 34px rgba(110, 40, 200, 0.55), 0 0 44px rgba(255, 140, 230, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5); } }
@keyframes ai-twinkle { 50% { transform: scale(1.35) rotate(20deg); opacity: 0.7; } }
.ai-eyes { transform-box: fill-box; transform-origin: center; animation: cat-blink 4.6s infinite; }
@keyframes cat-blink { 0%, 90%, 100% { transform: scaleY(1); } 93% { transform: scaleY(0.08); } }

/* ---------- panel ---------- */
.ai-panel {
  width: min(390px, calc(100vw - 32px)); height: min(590px, calc(100vh - 130px)); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 24px; border: 1px solid var(--line);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(182, 120, 255, 0.24), transparent 60%),
    linear-gradient(180deg, rgba(30, 9, 56, 0.97), rgba(12, 3, 26, 0.98));
  box-shadow: 0 0 0 4px rgba(18, 4, 36, 0.75), 0 0 0 5px rgba(182, 120, 255, 0.25), 0 30px 70px rgba(0, 0, 0, 0.65), 0 0 50px rgba(150, 70, 255, 0.25);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transform-origin: 100% 100%; animation: ai-pop 0.28s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.ai-panel[hidden] { display: none; }
@keyframes ai-pop { from { opacity: 0; transform: translateY(14px) scale(0.92); } }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line-soft); background: rgba(10, 2, 24, 0.35); }
.ai-avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #3a1d63, #12042a 75%); border: 1.5px solid rgba(255, 200, 250, 0.6); box-shadow: 0 0 16px rgba(255, 140, 230, 0.45); }
.ai-avatar svg { width: 34px; height: 34px; }
.ai-title { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.ai-title b { font-family: var(--font-label); font-weight: 900; letter-spacing: 0.06em; font-size: 0.98rem; }
.ai-title span { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); flex: none; }
.ai-x { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: rgba(10, 2, 24, 0.7); cursor: pointer; }
.ai-x:hover { background: rgba(182, 120, 255, 0.3); }
.ai-new { font-size: 1.1rem; line-height: 1; }

.ai-body { flex: 1; overflow-y: auto; padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; overscroll-behavior: contain; }
.ai-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; animation: ai-in 0.25s ease both; }
.ai-msg.me { justify-content: flex-end; }
@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } }
.ai-mini { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #12042a; border: 1px solid rgba(255, 200, 250, 0.4); }
.ai-mini svg { width: 22px; height: 22px; }
.ai-bubble { max-width: 82%; padding: 10px 13px; border-radius: 18px; font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.ai-msg.bot .ai-bubble { background: rgba(232, 210, 255, 0.1); border: 1px solid rgba(232, 210, 255, 0.18); border-bottom-left-radius: 6px; }
.ai-msg.me .ai-bubble { color: #fff; background: linear-gradient(180deg, #c58bff, #7a2fe0); border-bottom-right-radius: 6px; box-shadow: 0 4px 14px rgba(122, 47, 224, 0.4); }
.ai-msg.err .ai-bubble { border-color: rgba(255, 143, 168, 0.45); }
.ai-bubble a { color: #ffc7f3; text-decoration: underline; text-underline-offset: 2px; }
.ai-bubble b { color: #fff; }
.ai-typing { display: flex; gap: 5px; align-items: center; padding: 13px 15px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--lilac); animation: ai-dots 1.1s ease-in-out infinite; }
.ai-typing i:nth-child(2) { animation-delay: 0.15s; }
.ai-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dots { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-5px); opacity: 1; } }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.ai-suggest button {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 0.82rem; font-weight: 700; color: var(--lilac);
  border: 1px solid var(--line); background: rgba(182, 120, 255, 0.08); transition: background 0.15s;
}
.ai-suggest button:hover { background: rgba(182, 120, 255, 0.22); color: #fff; }

.ai-offer {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin-left: 36px; padding: 11px 12px; border-radius: 16px;
  background: linear-gradient(90deg, rgba(255, 134, 230, 0.16), rgba(182, 120, 255, 0.1)); border: 1px solid rgba(255, 170, 240, 0.45); animation: ai-in 0.3s ease both;
}
.ai-offer > span svg { width: 22px; height: 22px; color: #ffb3f0; display: block; }
.ai-offer div { display: grid; line-height: 1.3; font-size: 0.88rem; }
.ai-offer small { color: var(--muted); font-size: 0.78rem; }
.ai-offer .btn { grid-column: 1 / -1; justify-self: start; }

.ai-foot { padding: 10px 12px 10px; border-top: 1px solid var(--line-soft); background: rgba(10, 2, 24, 0.35); }
.ai-foot[hidden] { display: none; }
.ai-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-form textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 110px; padding: 11px 14px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(8, 2, 20, 0.75); color: var(--ink); font: inherit; font-size: 0.92rem; line-height: 1.4;
}
.ai-form textarea:focus { outline: none; border-color: rgba(182, 120, 255, 0.9); box-shadow: 0 0 0 3px rgba(182, 120, 255, 0.2); }
.ai-send {
  width: 44px; height: 44px; flex: none; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45); background: linear-gradient(180deg, #ff8be8, #b678ff 55%, #7a2fe0);
  box-shadow: 0 6px 16px rgba(122, 47, 224, 0.45);
}
.ai-send svg { width: 19px; height: 19px; margin-left: 2px; }
.ai-send:hover { filter: brightness(1.1); }
.ai-human { display: flex; align-items: center; gap: 6px; margin: 8px auto 0; padding: 0; border: 0; background: none; cursor: pointer; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.ai-human svg { width: 15px; height: 15px; }
.ai-human:hover { color: #fff; }

/* report + done */
.ai-card { display: grid; gap: 12px; padding: 16px; border-radius: 18px; background: rgba(232, 210, 255, 0.07); border: 1px solid var(--line); animation: ai-in 0.25s ease both; }
.ai-card-head { display: flex; gap: 10px; align-items: flex-start; }
.ai-card-head > svg { width: 26px; height: 26px; flex: none; color: #ffb3f0; margin-top: 2px; }
.ai-card-head div { display: grid; line-height: 1.35; }
.ai-card-head span { color: var(--muted); font-size: 0.84rem; }
.ai-report { margin: 0; padding: 12px 14px; border-radius: 14px; background: rgba(10, 2, 24, 0.5); border: 1px solid var(--line-soft); display: grid; gap: 4px; }
.ai-report dt { font-family: var(--font-label); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2); margin-top: 6px; }
.ai-report dt:first-child { margin-top: 0; }
.ai-report dd { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.ai-extra { display: grid; gap: 6px; font-weight: 800; font-size: 0.88rem; }
.ai-extra em { font-style: normal; color: var(--faint); font-weight: 600; }
.ai-extra textarea { resize: vertical; min-height: 70px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(8, 2, 20, 0.75); color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 400; }
.ai-extra textarea:focus { outline: none; border-color: rgba(182, 120, 255, 0.9); }
.ai-error { margin: 0; color: var(--bad); font-size: 0.86rem; font-weight: 700; }
.ai-card .btn { width: 100%; }
.ai-back { justify-self: center; font-size: 0.85rem; }
.ai-wait { justify-items: center; text-align: center; padding: 30px 16px; }
.ai-done { justify-items: center; text-align: center; padding: 26px 18px; }
.ai-done h3 { font-family: var(--font-display); font-size: 1.9rem; font-weight: 900; }
.ai-done p { margin: 0; }
.ai-done-icon { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; color: #ffd2f6; background: radial-gradient(circle at 40% 35%, rgba(255, 180, 240, 0.4), rgba(182, 120, 255, 0.15) 70%); box-shadow: 0 0 34px rgba(255, 140, 230, 0.5); animation: float 3.5s ease-in-out infinite; }
.ai-done-icon svg { width: 36px; height: 36px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .ai-helper { right: 12px; bottom: 12px; }
  body.has-tray .ai-helper { bottom: 84px; }
  .ai-launch { padding: 5px 14px 5px 5px; gap: 8px; }
  .ai-launch-icon { width: 40px; height: 40px; }
  .ai-launch-icon svg { width: 31px; height: 31px; }
  .ai-launch-text small { font-size: 0.68rem; }
  .ai-launch-text b { font-size: 0.74rem; }
  .ai-helper.open { left: 8px; right: 8px; bottom: 8px; }
  .ai-helper.open .ai-launch { display: none; }
  .ai-panel { width: 100%; height: min(640px, calc(100vh - 16px)); height: min(640px, calc(100dvh - 16px)); }
}
