#demi-widget {
  position: fixed; right: 22px; bottom: 22px; z-index: 9990;   /* under the lantern */
  font-family: "Open Sans", Arial, sans-serif; color: var(--espresso);
}
#demi-launcher {
  position: relative; display: grid; place-items: center;
  width: 66px; height: 66px; padding: 4px; border-radius: 50%;
  background: var(--cream);
  border: 1px solid rgba(60, 40, 20, 0.14);
  box-shadow: 0 12px 26px -12px rgba(60, 40, 20, 0.45), 0 0 0 5px rgba(255, 201, 74, 0.14);
  cursor: pointer;
  opacity: 0; transform: translateY(10px);
  animation: demi-arrive 0.9s cubic-bezier(.2,.8,.2,1) 5.6s forwards;   /* after the intro */
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), box-shadow 0.35s ease;
}
#demi-launcher img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform 0.35s cubic-bezier(.34,1.56,.64,1); }
#demi-launcher:hover img, #demi-launcher:focus-visible img { transform: rotate(-6deg) translateY(-2px); }
#demi-launcher:hover { box-shadow: 0 14px 30px -12px rgba(60, 40, 20, 0.5), 0 0 0 7px rgba(255, 201, 74, 0.22); }
#demi-launcher:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
/* the yellow dot: a small lantern glow on Demi's shoulder */
#demi-launcher::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2c2 0%, var(--yellow-warm) 35%, var(--yellow) 80%);
  box-shadow: 0 0 8px rgba(255, 201, 74, 0.7);
  animation: demi-glow 4.8s ease-in-out infinite;
}
#demi-widget.is-open #demi-launcher::after { display: none; }
@keyframes demi-arrive { to { opacity: 1; transform: none; } }
@keyframes demi-glow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

#demi-panel {
  position: absolute; right: 0; bottom: 82px;
  width: min(372px, calc(100vw - 32px)); height: min(540px, calc(100vh - 130px));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-2) 100%);
  border: 1px solid rgba(60, 40, 20, 0.12); border-radius: 16px;
  box-shadow: 0 28px 60px -24px rgba(60, 40, 20, 0.55), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  transform-origin: bottom right;
  animation: demi-open 0.32s cubic-bezier(.2,.8,.2,1);
}
#demi-panel[hidden] { display: none; }
/* brass pin, like the contact card */
#demi-panel::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 13px; height: 13px; transform: translateX(-50%);
  border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 35% 35%, #fff2c2 0%, var(--yellow-warm) 30%, var(--yellow) 75%, #b87f12 100%);
  box-shadow: 0 0 8px rgba(255, 201, 74, 0.6), 0 1px 3px rgba(60, 40, 20, 0.45);
}
@keyframes demi-open { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }

.demi-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px; border-bottom: 1px dashed rgba(60, 40, 20, 0.18);
}
.demi-head img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.demi-head-text { flex: 1; min-width: 0; }
.demi-head-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 17px; line-height: 1.1; margin: 0; }
.demi-head-sub { font-family: "Caveat", cursive; font-weight: 500; font-size: 17px; color: var(--espresso-2); margin: 0; line-height: 1.1; }
#demi-close {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent;
  color: var(--espresso-2); font-size: 22px; line-height: 1; cursor: pointer;
}
#demi-close:hover, #demi-close:focus-visible { background: rgba(60, 40, 20, 0.07); outline: none; }

#demi-log {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(60, 40, 20, 0.2) transparent;
}
.demi-msg {
  max-width: 84%; padding: 9px 13px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.demi-msg.from-demi {
  align-self: flex-start; background: #fffdf8; border: 1px solid rgba(60, 40, 20, 0.1);
  border-bottom-left-radius: 4px;
}
.demi-msg.from-you {
  align-self: flex-end; background: var(--espresso); color: var(--cream);
  border-bottom-right-radius: 4px;
}
.demi-msg a { color: inherit; border-bottom: 1px solid rgba(255, 127, 106, 0.6); }
.demi-typing { display: inline-flex; align-items: center; gap: 5px; padding: 11px 14px; }
.demi-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--yellow);
  box-shadow: 0 0 6px rgba(255, 201, 74, 0.6);
  animation: demi-dot 1.2s ease-in-out infinite;
}
.demi-typing span:nth-child(2) { animation-delay: 0.15s; }
.demi-typing span:nth-child(3) { animation-delay: 0.3s; }
.demi-typing em { font-family: "Caveat", cursive; font-style: normal; font-size: 16px; line-height: 7px; color: var(--espresso-2); margin-left: 4px; }
@keyframes demi-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

#demi-form {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px 12px; border-top: 1px dashed rgba(60, 40, 20, 0.18);
}
#demi-input {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px;
  border: 1px solid rgba(60, 40, 20, 0.18); background: #fffdf8;
  font: inherit; font-size: 16px; color: var(--espresso);   /* 16px: no iOS zoom */
}
#demi-input::placeholder { color: rgba(90, 66, 50, 0.6); }
#demi-input:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 201, 74, 0.25); }
#demi-send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--espresso); color: var(--cream); display: grid; place-items: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
#demi-send:hover:not(:disabled), #demi-send:focus-visible { background: var(--coral-deep); outline: none; }
#demi-send:disabled { opacity: 0.4; cursor: default; }
#demi-send svg { width: 17px; height: 17px; }

/* "ring Demi" link on the contact card */
.contact-card .contact-list button.chat-link {
  font: inherit; color: var(--espresso); background: none; border: 0; padding: 0 0 1px; cursor: pointer;
  border-bottom: 1px solid rgba(255, 127, 106, 0.4);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.contact-card .contact-list button.chat-link:hover { color: var(--coral-deep); border-color: var(--coral-deep); }

/* quick replies under the greeting */
.demi-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 4px; }
.demi-chips button {
  font: inherit; font-size: 13px; color: var(--espresso); cursor: pointer;
  padding: 6px 11px; border-radius: 999px; background: rgba(255, 201, 74, 0.16);
  border: 1px solid rgba(240, 181, 40, 0.45);
  transition: background 0.2s ease, transform 0.2s ease;
}
.demi-chips button:hover, .demi-chips button:focus-visible { background: rgba(255, 201, 74, 0.34); transform: translateY(-1px); outline: none; }

/* "psst" teaser: Demi calls out once per visit */
#demi-teaser {
  position: absolute; right: 6px; bottom: 80px; width: max-content; max-width: 220px;
  padding: 9px 13px; border-radius: 14px 14px 4px 14px;
  background: #fffdf8; border: 1px solid rgba(60, 40, 20, 0.12);
  box-shadow: 0 10px 24px -12px rgba(60, 40, 20, 0.45);
  font-family: "Caveat", cursive; font-size: 19px; line-height: 1.15; color: var(--espresso);
  cursor: pointer; opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.2,.8,.2,1);
}
#demi-teaser.is-shown { opacity: 1; transform: none; pointer-events: auto; }

/* the order ticket, printed when a note reaches Hannah */
.demi-ticket {
  align-self: center; width: 86%; margin: 4px 0; padding: 12px 14px 10px;
  background: #fffdf8; color: var(--espresso);
  border: 1px dashed rgba(60, 40, 20, 0.35); border-radius: 4px;
  box-shadow: 0 8px 18px -12px rgba(60, 40, 20, 0.5);
  transform: rotate(-1.2deg);
  font-size: 13px; line-height: 1.45;
}
.demi-ticket-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: "Fraunces", serif; font-weight: 600; font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--coral-deep); padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px dashed rgba(60, 40, 20, 0.25);
}
.demi-ticket dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.demi-ticket dt { color: var(--espresso-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 2px; }
.demi-ticket dd { margin: 0; overflow-wrap: anywhere; }
.demi-ticket-foot { font-family: "Caveat", cursive; font-size: 17px; text-align: right; margin-top: 6px; color: var(--espresso-2); }

@media (max-width: 520px) {
  #demi-widget { right: 16px; bottom: 16px; }
  #demi-teaser { bottom: 70px; }
  #demi-launcher { width: 58px; height: 58px; }
  #demi-panel { position: fixed; left: 12px; right: 12px; bottom: 86px; width: auto; height: min(560px, calc(100dvh - 110px)); }
}
@media (prefers-reduced-motion: reduce) {
  #demi-launcher { animation: none; opacity: 1; transform: none; }
  #demi-launcher::after, .demi-typing span, #demi-panel { animation: none; }
  #demi-teaser { transition: none; }
}

/* Interior pages: no intro to wait for, so Demi arrives sooner. */
body.inner #demi-launcher { animation-delay: 1.2s; }
