:root {
  --espresso: #2b1a12;
  --roast: #4a2c1d;
  --crema: #c8915a;
  --gold: #d9a35f;
  --cream: #f8f1e7;
  --paper: #fffaf3;
  --ink: #2a211c;
  --muted: #7d6b5f;
  --line: #eadccb;
  --ok: #3f8a5a;
  --shadow: 0 10px 30px rgba(43, 26, 18, .18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--cream);
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; }

/* ───────── Launcher (bottom-right barista) ───────── */
.launcher {
  position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); z-index: 50;
  width: 72px; height: 72px; border-radius: 50%; padding: 0; border: 3px solid var(--paper);
  background: var(--espresso); box-shadow: var(--shadow);
  animation: popIn .7s cubic-bezier(.2,1.4,.4,1) .6s both;
}
.launcher img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; position: relative; z-index: 1; }
.launcher .launcher-video { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 25%; z-index: 1; opacity: 0; transition: opacity .4s; }
.launcher .launcher-video.ready { opacity: 1; }
.launcher .dot { position: absolute; z-index: 2; right: 2px; bottom: 4px; width: 15px; height: 15px; border-radius: 50%; background: #4cc472; border: 3px solid var(--paper); }
.launcher .ring { position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--gold); animation: ripple 2.4s ease-out infinite; }
.launcher .ring.r2 { animation-delay: 1.2s; }
@keyframes ripple { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
@keyframes popIn { from { transform: scale(0) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
body.chat-open .launcher, body.chat-open .bubble { opacity: 0; pointer-events: none; transform: scale(.6); transition: .25s; }

.bubble {
  position: fixed; right: 18px; bottom: calc(102px + var(--safe-b)); z-index: 50;
  max-width: 250px; background: var(--paper); border-radius: 18px 18px 4px 18px; padding: 12px 30px 12px 14px;
  box-shadow: var(--shadow); font-size: 14px; line-height: 1.4; display: flex; flex-direction: column; gap: 2px;
  animation: popIn .6s cubic-bezier(.2,1.4,.4,1) 1.6s both; transform-origin: bottom right;
}
.bubble.hide { display: none; }
.bubble-x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 18px; color: var(--muted); }

/* ───────── Chat panel ───────── */
.panel {
  position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
  height: min(86dvh, 720px); display: flex; flex-direction: column;
  background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(43,26,18,.3);
  transform: translateY(105%); transition: transform .45s cubic-bezier(.2,1,.3,1);
  padding-bottom: var(--safe-b);
}
.panel.open { transform: none; }
@media (min-width: 720px) {
  .panel {
    left: auto; right: 24px; bottom: 24px; width: 400px; height: min(680px, calc(100dvh - 48px));
    border-radius: 26px; transform: translateY(30px) scale(.9); opacity: 0; pointer-events: none;
    transform-origin: bottom right; transition: transform .4s cubic-bezier(.2,1.2,.3,1), opacity .25s;
  }
  .panel.open { transform: none; opacity: 1; pointer-events: auto; }
}

/* ───────── Video stage (Bella) ───────── */
.stage {
  position: relative; flex: none; height: min(36dvh, 300px); overflow: hidden;
  border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
  background: var(--espresso); color: var(--cream);
}
@media (min-width: 720px) { .stage { height: 280px; } }
.stage-photo, .clip {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%;
}
.stage-photo { transition: transform .12s ease-out; }
.stage-photo.word { transform: scale(1.012); }
.clip { opacity: 0; transition: opacity .35s ease; }
.clip.ready.show { opacity: 1; }
/* Photo-only mode (no clips yet): gentle "breathing" so she never looks frozen. */
.stage:not(.has-video) .stage-photo { animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.025) translateY(-1px); } }
.stage-shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.35), transparent 28%, transparent 55%, rgba(30,16,10,.85));
}
.stage-top { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 3; }
.stage .who { position: absolute; left: 18px; bottom: 14px; z-index: 3; }
.stage::after { /* soft glow ring while speaking / listening */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .3s;
}
.speaking .stage::after { box-shadow: inset 0 0 0 3px rgba(217,163,95,.85); }
.listening .stage::after { box-shadow: inset 0 0 0 3px rgba(76,196,114,.85); }
.thinking .stage-photo { animation: think 1.4s ease-in-out infinite; }
@keyframes think { 50% { transform: scale(1.02); } }

.who { display: flex; flex-direction: column; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.who strong { font-family: Fraunces, Georgia, serif; font-size: 24px; }
.status { font-size: 12.5px; color: #f0e2d0; }
.eq { display: flex; gap: 3px; height: 14px; align-items: flex-end; margin-top: 4px; opacity: 0; transition: opacity .2s; }
.eq i { width: 3px; height: 4px; border-radius: 2px; background: var(--gold); }
.speaking .eq, .listening .eq { opacity: 1; }
.listening .eq i { background: #4cc472; }
.speaking .eq i, .listening .eq i { animation: eq .7s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .1s !important; } .eq i:nth-child(3) { animation-delay: .25s !important; }
.eq i:nth-child(4) { animation-delay: .05s !important; } .eq i:nth-child(5) { animation-delay: .2s !important; }
@keyframes eq { 50% { height: 14px; } }

.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(20,10,5,.45); backdrop-filter: blur(6px); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--cream); }
#muteBtn .ic-off, #muteBtn.muted .ic-on { display: none; }
#muteBtn.muted .ic-off { display: block; }

.log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; animation: rise .3s ease-out; }
.msg.bella { align-self: flex-start; background: #f2e6d7; border-bottom-left-radius: 6px; }
.msg.guest { align-self: flex-end; background: var(--espresso); color: var(--cream); border-bottom-right-radius: 6px; }
.msg.guest.interim { opacity: .55; font-style: italic; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--crema); animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 50% { transform: translateY(-5px); opacity: .5; } }

.minis { display: flex; gap: 8px; overflow-x: auto; align-self: stretch; padding: 2px 0 4px; scrollbar-width: none; animation: rise .35s ease-out; }
.mini {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; text-align: left; font-size: 13px;
}
.mini .e { font-size: 22px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #f3e3cf; }
.mini b { display: block; font-weight: 600; } .mini span { color: var(--muted); }

.booking-card {
  align-self: stretch; border-radius: 16px; padding: 14px; background: linear-gradient(150deg, #fff6e6, #f6e6cc);
  border: 1px solid #ecd2a6; font-size: 14px; animation: rise .35s ease-out;
}
.booking-card h4 { margin: 0 0 8px; font-family: Fraunces, Georgia, serif; font-size: 17px; color: var(--ok); }
.booking-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.booking-card dt { color: var(--muted); } .booking-card dd { margin: 0; font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; color: var(--roast); }

.talk-zone { display: flex; flex-direction: column; align-items: center; padding: 4px 0 6px; }
.mic {
  position: relative; width: 68px; height: 68px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 30% 30%, #6b4128, var(--espresso)); box-shadow: 0 6px 18px rgba(43,26,18,.35);
  display: grid; place-items: center; transition: transform .15s, background .2s;
}
.mic:active { transform: scale(.94); }
.mic svg { width: 30px; height: 30px; fill: var(--cream); position: relative; z-index: 1; }
.mic-wave { position: absolute; inset: 0; border-radius: 50%; }
.mic.on { background: radial-gradient(circle at 30% 30%, #55d07e, #2f9a55); }
.mic.on .mic-wave { animation: micwave 1.2s ease-out infinite; box-shadow: 0 0 0 0 rgba(76,196,114,.6); }
@keyframes micwave { to { box-shadow: 0 0 0 22px rgba(76,196,114,0); } }
.mic.unsupported { opacity: .45; }
.mic-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); min-height: 1em; text-align: center; padding: 0 16px; }

.composer { display: flex; gap: 8px; padding: 6px 12px 12px; }
.composer input {
  flex: 1; min-width: 0; height: 44px; border-radius: 999px; border: 1px solid var(--line); padding: 0 16px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink); outline: none;
}
.composer input:focus { border-color: var(--crema); }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--crema); display: grid; place-items: center; }
.send svg { width: 20px; height: 20px; fill: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Tavus live video Bella is active: hide the built-in launcher so there's only one Bella. */
body.tavus-on .launcher, body.tavus-on .bubble { display: none; }

/* Food photos in Bella's suggestion chips */
img.e { object-fit: cover; padding: 0; }

/* Order cards in Bella's chat (basket summary and "pay now") */
.order-card {
  align-self: stretch; border-radius: 16px; padding: 14px; background: #fff; border: 1px solid var(--line);
  font-size: 14px; animation: rise .35s ease-out;
}
.order-card h4 { margin: 0 0 8px; font-family: Fraunces, Georgia, serif; font-size: 17px; color: var(--roast); }
.order-card h4 span { font-family: Inter, system-ui, sans-serif; font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.order-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.order-card li { display: flex; justify-content: space-between; gap: 12px; }
.order-card li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.order-total { display: flex; justify-content: space-between; margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); }
.order-note { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.order-btn {
  display: block; width: 100%; margin-top: 10px; padding: 10px 14px; border: 0; border-radius: 999px;
  background: var(--espresso); color: var(--cream); font: inherit; font-size: 14px; font-weight: 600; text-align: center; text-decoration: none;
}
.order-card.pay { background: linear-gradient(150deg, #fff6e6, #f6e6cc); border-color: #ecd2a6; }
.order-card.pay .order-btn { background: var(--ok); color: #fff; }
