*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: #F5EFE6;
  background: transparent;
}
.stage { display: none; }
button, input { font-family: inherit; }

.launcher {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 64px; height: 64px; padding: 0; border: 0; border-radius: 999px;
  background: transparent; cursor: pointer;
  animation: mere-pulse-ring 2.6s ease-out infinite;
}
.launcher img { width: 64px; height: 64px; display: block; border-radius: 999px; }
.launcher:hover { transform: scale(1.05); }
.launcher:active { transform: scale(0.95); }
.launcher[aria-expanded="true"] { visibility: hidden; pointer-events: none; }

.panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  width: min(360px, calc(100vw - 24px));
  height: min(520px, calc(100dvh - 24px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 22px;
  border: 1px solid #C9A24B;
  background: linear-gradient(165deg, #3a1760 0%, #6b2fa0 55%, #8a4fb8 100%);
  box-shadow: rgba(20, 5, 40, 0.55) 0 24px 60px, rgba(107, 47, 160, 0.35) 0 0 40px, inset 0 0 1px #C9A24B;
  animation: mere-panel-in .32s ease both;
}
.panel[hidden] { display: none; }

.sparkles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.spark {
  position: absolute; border-radius: 999px;
  animation: mere-twinkle var(--tw, 3.6s) ease-in-out var(--d, 0s) infinite,
             mere-float var(--fl, 7s) ease-in-out var(--d, 0s) infinite;
}

.head {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 999px; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(201, 162, 75, 0.7);
}
.head-copy { min-width: 0; flex: 1; }
.head-name {
  margin: 0; font-family: "Playfair Display", Georgia, serif;
  font-size: 16px; font-weight: 600; color: #F5EFE6; line-height: 1.1;
}
.star { color: #E6C877; font-size: 11px; animation: mere-star 2.4s ease-in-out infinite; }
.head-sub { margin: 3px 0 0; font-size: 12px; color: rgba(245, 239, 230, 0.72); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 999px; background: #86efac; display: inline-block; }
.dot.thinking { background: #E6C877; animation: mere-twinkle 2.4s ease-in-out infinite; }
.close {
  width: 28px; height: 28px; border: 0; border-radius: 999px;
  background: transparent; color: rgba(245, 239, 230, 0.8);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.close:hover { color: #fff; }
.gold-line { height: 1px; background: rgba(201, 162, 75, 0.55); position: relative; z-index: 1; }

.thread {
  position: relative; z-index: 1;
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.row { display: flex; animation: mere-bubble-in .28s ease both; }
.row.user { justify-content: flex-end; }
.bubble {
  max-width: 80%;
  color: #2A0F3F;
  background: rgba(245, 239, 230, 0.94);
  border: 1px solid #C9A24B;
  border-radius: 16px 16px 16px 4px;
  padding: 9px 14px;
  font-size: 13px; line-height: 1.5;
  box-shadow: rgba(20, 5, 40, 0.25) 0 4px 14px, 0 0 1px #C9A24B;
  white-space: pre-line;
}
.bubble.user {
  color: #F5EFE6;
  background: rgba(20, 5, 40, 0.35);
  border-radius: 16px 16px 4px 16px;
}
.closing-note {
  font-size: 11px; font-style: italic; color: #E6C877; padding-left: 4px;
}
.closing-note a { color: inherit; }

.card, .pcard, .hcard, .promo {
  max-width: 92%;
  border: 1px solid rgba(201, 162, 75, 0.55);
  border-radius: 16px;
  background: rgba(20, 5, 40, 0.28);
  color: #F5EFE6;
  padding: 10px 12px;
  font-size: 12.5px;
  animation: mere-bubble-in .28s ease both;
}
.card-label { font-size: 11px; color: #E6C877; letter-spacing: .04em; text-transform: uppercase; }
.card-value { font-weight: 600; margin-top: 2px; }
.card + .card, .row + .card { margin-top: 0; }
.sizes { display: flex; gap: 6px; flex-wrap: wrap; max-width: 92%; }
.size {
  min-width: 40px; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  border: 1px solid #C9A24B; background: rgba(20, 5, 40, 0.3); color: #E6C877; font-size: 12px;
}
.size.on, .size:hover { background: linear-gradient(135deg, #E6C877, #C9A24B); color: #2A0F3F; }
.pbtn, .promo a {
  display: inline-block; margin-top: 8px; border: 0; cursor: pointer; text-decoration: none;
  border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 600;
  background: linear-gradient(135deg, #E6C877, #C9A24B); color: #2A0F3F;
}
.status { display: inline-block; margin-top: 6px; font-size: 11px; color: #E6C877; }

.chips {
  position: relative; z-index: 1;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 14px 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: 0 0 auto; white-space: nowrap; cursor: pointer;
  border: 1px solid #C9A24B; border-radius: 999px;
  background: rgba(20, 5, 40, 0.3); color: #E6C877;
  padding: 6px 13px; font-size: 12px;
  box-shadow: inset 0 0 6px rgba(201, 162, 75, 0.12);
}
.chip:hover { transform: scale(1.03); }
.chip:disabled { opacity: .4; cursor: default; transform: none; }

.composer {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
}
.composer input {
  flex: 1; min-width: 0; outline: none;
  color: #F5EFE6; font-size: 13.5px;
  background: rgba(245, 239, 230, 0.06);
  border: 1px solid rgba(201, 162, 75, 0.35);
  border-radius: 999px; padding: 9px 14px;
  caret-color: #C9A24B;
}
.composer input::placeholder { color: rgba(245, 239, 230, 0.45); }
.composer input:focus { box-shadow: 0 0 0 2px rgba(201, 162, 75, 0.33), 0 0 12px rgba(201, 162, 75, 0.33); }
.send {
  width: 40px; height: 40px; border: 0; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #E6C877, #C9A24B);
  box-shadow: rgba(201, 162, 75, 0.45) 0 4px 14px;
}
.send:hover { transform: scale(1.05); }

.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing span {
  width: 6px; height: 6px; border-radius: 999px; background: #C9A24B;
  animation: mere-dot 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes mere-twinkle { 0%, 100% { opacity: .15; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes mere-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px) translateX(4px); } }
@keyframes mere-panel-in { 0% { opacity: 0; transform: translateY(18px) scale(.96); } 100% { opacity: 1; transform: none; } }
@keyframes mere-bubble-in { 0% { opacity: 0; transform: translateY(8px) scale(.97); } 100% { opacity: 1; transform: none; } }
@keyframes mere-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes mere-pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(201, 162, 75, .45); } 70% { box-shadow: 0 0 0 16px rgba(201, 162, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(201, 162, 75, 0); } }
@keyframes mere-star { 0%, 100% { opacity: .2; } 50% { opacity: .9; } }
@media (prefers-reduced-motion: reduce) {
  .mere-anim, .mere-anim *, .spark, .star, .typing span { animation: none !important; }
}
