/* Global AI concierge widget (loaded on every page). */
.ai-root {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 940;
  font-family: inherit;
}

.ai-fab {
  position: relative;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #3b6bff, #7a4dff 58%, #b44dff);
  box-shadow: 0 16px 38px -14px rgba(59, 107, 255, .85), 0 3px 10px rgba(10, 17, 34, .16);
  transition: transform .22s ease, box-shadow .22s ease;
}
.ai-fab svg { width: 26px; height: 26px; }
.ai-fab:hover { transform: translateY(-2px) scale(1.04); }
.ai-fab:active { transform: scale(.96); }
.ai-fab.is-open { transform: scale(.9); opacity: .9; }
.ai-fab-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(122, 77, 255, .5);
  animation: ai-pulse 2.6s ease-out infinite;
}
@keyframes ai-pulse {
  0% { transform: scale(.92); opacity: .75; }
  70% { transform: scale(1.18); opacity: 0; }
  100% { opacity: 0; }
}
.ai-fab-dot {
  position: absolute;
  top: 8px; right: 9px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.ai-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(392px, calc(100vw - 36px));
  height: min(584px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(16, 26, 51, .09);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 34px 80px -34px rgba(10, 17, 34, .55), 0 8px 24px rgba(10, 17, 34, .08);
  transform-origin: bottom right;
  animation: ai-in .24s cubic-bezier(.2, .9, .3, 1.05);
}
.ai-panel.hidden { display: none; }
@keyframes ai-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 13px;
  background: linear-gradient(140deg, #3b6bff, #7a4dff);
  color: #fff;
}
.ai-head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .18);
  flex: 0 0 auto;
}
.ai-avatar svg { width: 19px; height: 19px; }
.ai-head b { display: block; font-size: 13.5px; letter-spacing: -.01em; }
.ai-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; opacity: .88;
}
.ai-status i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .28);
}
.ai-close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  color: #fff; cursor: pointer;
  flex: 0 0 auto;
}
.ai-close:hover { background: rgba(255, 255, 255, .26); }
.ai-close svg { width: 16px; height: 16px; }

.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f7f8fc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ai-body::-webkit-scrollbar { width: 8px; }
.ai-body::-webkit-scrollbar-thumb { background: rgba(16, 26, 51, .14); border-radius: 99px; }

.ai-empty { padding: 12px 4px; text-align: center; }
.ai-empty-art {
  width: 52px; height: 52px;
  margin: 6px auto 12px;
  display: grid; place-items: center;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(140deg, #3b6bff, #7a4dff);
  box-shadow: 0 14px 30px -14px rgba(59, 107, 255, .9);
}
.ai-empty-art svg { width: 25px; height: 25px; }
.ai-empty b { font-size: 14px; }
.ai-empty p {
  margin: 6px 6px 14px;
  font-size: 12.4px; line-height: 1.6;
  color: #5d6880;
}
.ai-starters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-start {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 10px;
  border: 1px solid rgba(16, 26, 51, .1);
  border-radius: 12px;
  background: #fff;
  color: #0a1122;
  font-size: 12px; text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.ai-start:hover {
  border-color: rgba(59, 107, 255, .5);
  box-shadow: 0 8px 18px -12px rgba(59, 107, 255, .8);
  transform: translateY(-1px);
}
.ai-start svg { width: 15px; height: 15px; color: #3b6bff; flex: 0 0 auto; }
.ai-start span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg--user { justify-content: flex-end; }
.ai-msg-avatar {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, #3b6bff, #7a4dff);
  color: #fff; flex: 0 0 auto;
}
.ai-msg-avatar svg { width: 14px; height: 14px; }
.ai-bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 5px;
  background: #fff;
  border: 1px solid rgba(16, 26, 51, .08);
  font-size: 12.8px;
  line-height: 1.62;
  color: #17223b;
  word-break: break-word;
}
.ai-msg--user .ai-bubble {
  border-radius: 14px 14px 5px 14px;
  background: linear-gradient(140deg, #3b6bff, #6a55ff);
  border-color: transparent;
  color: #fff;
}
.ai-bullet { color: #3b6bff; font-weight: 700; }
.ai-typing { display: flex; gap: 4px; align-items: center; padding: 13px 14px; }
.ai-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9aa4bb;
  animation: ai-blink 1.2s infinite;
}
.ai-typing i:nth-child(2) { animation-delay: .18s; }
.ai-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes ai-blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.ai-products { display: grid; gap: 7px; padding-left: 34px; }
.ai-product {
  display: block;
  padding: 9px 11px;
  border: 1px solid rgba(16, 26, 51, .09);
  border-radius: 11px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.ai-product:hover {
  border-color: rgba(59, 107, 255, .45);
  box-shadow: 0 8px 20px -14px rgba(59, 107, 255, .8);
}
.ai-product b { display: block; font-size: 12.2px; line-height: 1.45; font-weight: 600; }
.ai-product-meta { display: block; margin-top: 3px; font-size: 11.4px; color: #2f5bff; font-weight: 600; }

.ai-actions { display: flex; flex-wrap: wrap; gap: 7px; padding-left: 34px; }
.ai-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(59, 107, 255, .34);
  background: #fff;
  color: #2f5bff;
  font-size: 11.8px; font-weight: 600;
  text-decoration: none;
}
.ai-action:hover { background: rgba(59, 107, 255, .08); }
.ai-action svg { width: 13px; height: 13px; }

.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 34px; }
.ai-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px dashed rgba(16, 26, 51, .18);
  background: transparent;
  color: #5d6880;
  font-size: 11.4px;
  cursor: pointer;
}
.ai-chip:hover { border-color: #3b6bff; color: #2f5bff; }

.ai-compose {
  display: flex; gap: 8px; align-items: center;
  padding: 11px 12px;
  border-top: 1px solid rgba(16, 26, 51, .08);
  background: #fff;
}
.ai-input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(16, 26, 51, .13);
  border-radius: 999px;
  font-size: 12.8px;
  font-family: inherit;
  color: #0a1122;
  background: #f7f8fc;
  outline: none;
  transition: border-color .18s ease, background .18s ease;
}
.ai-input:focus { border-color: #3b6bff; background: #fff; }
.ai-send {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: linear-gradient(140deg, #3b6bff, #7a4dff);
  color: #fff; cursor: pointer;
  flex: 0 0 auto;
  transition: transform .18s ease, opacity .18s ease;
}
.ai-send:hover { transform: scale(1.06); }
.ai-send:active { transform: scale(.94); }
.ai-send svg { width: 17px; height: 17px; }

/* Keep the launcher clear of the mobile tab bar / cart bar. */
@media (max-width: 640px) {
  .ai-root { right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); }
  .ai-fab { width: 52px; height: 52px; }
  .ai-panel {
    position: fixed;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: min(86vh, 640px);
    border-radius: 20px 20px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-fab-ring, .ai-typing i { animation: none; }
  .ai-panel { animation: none; }
}
