/* ============================================================
   Yuchen's Assistant — floating gradient-blob chat widget
   Self-contained: remove assistant.css + assistant.js + /api and
   the main site is unaffected. Tokens mirror the site palette.
   ============================================================ */
.asst{
  --asst-cream:#F7F2E9; --asst-cream-2:#EFE7DA; --asst-ink:#0E0E0E; --asst-muted:#6E6A62;
  --asst-line:#D8CFC1; --asst-accent:#B8654A; --asst-card:#F7F2E9;
  --asst-pink:#E91E78; --asst-orange:#F8951A;
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 4vh, 32px);
  z-index: 9999;
  font-family: 'Switzer', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5;
}
.asst *{ box-sizing: border-box; }

/* ---------- the blob button ---------- */
.asst__blob{
  position: relative;
  width: 72px; height: 72px;
  border: none; padding: 0; cursor: pointer;
  background: transparent;
  display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.asst__blob-shape{
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 120% at 78% 22%, var(--asst-pink) 0%, var(--asst-orange) 58%, var(--asst-orange) 100%);
  border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
  box-shadow: 0 10px 30px -6px rgba(233,30,120,.5), 0 6px 18px -8px rgba(248,149,26,.6);
  animation: asstMorph 12s ease-in-out infinite, asstFloat 4s ease-in-out infinite;
  transition: transform .35s ease, box-shadow .35s ease;
}
/* grain overlay (inline feTurbulence noise) */
.asst__blob-shape::after{
  content:""; position:absolute; inset:0; border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay; opacity: .12;
}
.asst__blob-glyph{ position: relative; z-index:1; font-size: 26px; line-height:1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.asst__blob:hover .asst__blob-shape{ transform: scale(1.06); box-shadow: 0 14px 38px -6px rgba(233,30,120,.6), 0 8px 22px -8px rgba(248,149,26,.7); }
.asst__blob:focus-visible{ outline: none; }
.asst__blob:focus-visible .asst__blob-shape{ outline: 2px solid var(--asst-ink); outline-offset: 4px; }

@keyframes asstFloat{ 0%,100%{ translate: 0 -6px; } 50%{ translate: 0 6px; } }
@keyframes asstMorph{
  0%,100%{ border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; }
  33%{ border-radius: 60% 40% 42% 58% / 56% 39% 61% 44%; }
  66%{ border-radius: 38% 62% 56% 44% / 49% 56% 44% 51%; }
}

/* ---------- idle hint bubble ---------- */
.asst__hint{
  position: absolute; right: 4px; bottom: 84px;
  width: max-content; max-width: min(240px, 72vw);
  background: var(--asst-card); color: var(--asst-ink);
  border: 1px solid var(--asst-line); border-radius: 16px;
  padding: .6rem .85rem; padding-right: 1.8rem;
  box-shadow: 0 8px 24px -10px rgba(14,14,14,.3);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .4s ease, transform .4s ease;
  font-size: 14px;
}
.asst__hint.is-shown{ opacity: 1; transform: translateY(0); pointer-events: auto; }
.asst__hint::after{
  content:""; position:absolute; right: 28px; bottom: -7px;
  width: 14px; height: 14px; background: var(--asst-card);
  border-right: 1px solid var(--asst-line); border-bottom: 1px solid var(--asst-line);
  transform: rotate(45deg);
}
.asst__hint-text{ transition: opacity .25s ease; }
.asst__hint-x{
  position:absolute; top: 4px; right: 6px;
  border:none; background:none; cursor:pointer;
  color: var(--asst-muted); font-size: 14px; line-height:1; padding: 2px;
}
.asst__hint-x:hover{ color: var(--asst-ink); }

/* ---------- chat panel ---------- */
.asst__panel{
  position: absolute; right: 0; bottom: 84px;
  width: min(360px, calc(100vw - 32px));
  height: min(70vh, 560px);
  background: var(--asst-cream-2);
  border: 1px solid var(--asst-line); border-radius: 20px;
  box-shadow: 0 24px 60px -12px rgba(14,14,14,.35);
  display: none; flex-direction: column; overflow: hidden;
}
.asst__panel.is-open{ display: flex; animation: asstPanelIn .3s cubic-bezier(.2,.8,.2,1); }
@keyframes asstPanelIn{ from{ opacity:0; transform: translateY(14px) scale(.98); } to{ opacity:1; transform:none; } }

.asst__head{
  display:flex; align-items:center; gap:.6rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--asst-line);
  background: var(--asst-card);
}
.asst__avatar{
  width: 28px; height: 28px; flex:0 0 auto;
  background: radial-gradient(120% 120% at 75% 25%, var(--asst-pink), var(--asst-orange));
  border-radius: 50% 60% 55% 45% / 55% 45% 60% 50%;
}
.asst__title{ font-weight: 600; font-size: 14px; flex:1; }
.asst__close{
  border:none; background:none; cursor:pointer; color: var(--asst-muted);
  font-size: 16px; line-height:1; padding: 4px; border-radius: 6px;
}
.asst__close:hover{ color: var(--asst-ink); }

.asst__log{
  flex:1; overflow-y:auto; padding: 1rem; display:flex; flex-direction:column; gap:.7rem;
  scroll-behavior: smooth;
}
.asst__row{ display:flex; gap:.5rem; align-items:flex-end; max-width: 90%; }
.asst__row--bot{ align-self:flex-start; }
.asst__row--user{ align-self:flex-end; flex-direction: row-reverse; }
.asst__row-avatar{
  width: 22px; height:22px; flex:0 0 auto; margin-bottom: 2px;
  background: radial-gradient(120% 120% at 75% 25%, var(--asst-pink), var(--asst-orange));
  border-radius: 50% 60% 55% 45% / 55% 45% 60% 50%;
}
.asst__bubble{
  padding: .55rem .8rem; border-radius: 14px; font-size: 14px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.asst__row--bot .asst__bubble{ background: var(--asst-card); color: var(--asst-ink); border:1px solid var(--asst-line); border-bottom-left-radius: 4px; }
.asst__row--user .asst__bubble{ background: color-mix(in srgb, var(--asst-accent) 16%, var(--asst-cream)); color: var(--asst-ink); border:1px solid color-mix(in srgb, var(--asst-accent) 30%, transparent); border-bottom-right-radius: 4px; }

/* typing indicator */
.asst__typing{ display:inline-flex; gap:4px; align-items:center; padding: .2rem 0; }
.asst__typing span{ width:6px; height:6px; border-radius:50%; background: var(--asst-muted); opacity:.5; animation: asstDot 1.2s infinite ease-in-out; }
.asst__typing span:nth-child(2){ animation-delay:.2s; }
.asst__typing span:nth-child(3){ animation-delay:.4s; }
@keyframes asstDot{ 0%,60%,100%{ transform: translateY(0); opacity:.35; } 30%{ transform: translateY(-4px); opacity:.9; } }

/* starter chips */
.asst__chips{ display:flex; flex-wrap:wrap; gap:.4rem; padding: 0 1rem .6rem; }
.asst__chip{
  border:1px solid var(--asst-line); background: var(--asst-card); color: var(--asst-ink);
  border-radius: 999px; padding: .4em .8em; font-size: 12.5px; cursor:pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.asst__chip:hover{ background: var(--asst-ink); color: var(--asst-cream); border-color: var(--asst-ink); }

/* input row */
.asst__input{
  display:flex; align-items:flex-end; gap:.5rem;
  padding: .7rem; border-top: 1px solid var(--asst-line); background: var(--asst-card);
}
.asst__field{
  flex:1; resize:none; border:1px solid var(--asst-line); border-radius: 12px;
  padding: .55rem .7rem; font: inherit; font-size: 14px; color: var(--asst-ink);
  background: var(--asst-cream-2); max-height: 96px; min-height: 40px;
}
.asst__field:focus-visible{ outline: 2px solid var(--asst-accent); outline-offset: 1px; }
.asst__send{
  flex:0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  border:1px solid var(--asst-ink); background: var(--asst-ink); color: var(--asst-cream);
  cursor:pointer; font-size: 16px; display:grid; place-items:center;
  transition: transform .25s ease, opacity .25s ease;
}
.asst__send:hover{ transform: translateX(1px) translateY(-1px); }
.asst__send:disabled{ opacity:.4; cursor:default; transform:none; }

@media (max-width: 480px){
  .asst__panel{ width: calc(100vw - 24px); height: min(72vh, 560px); }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .asst__blob-shape{ animation: none; }
  .asst__panel.is-open{ animation: none; }
  .asst__typing span{ animation: none; }
  .asst__hint{ transition: opacity .2s ease; }
}
