:root {
  --pink: #FF6FA5;
  --pink-dark: #E5578D;
  --purple: #8B6CF6;
  --green: #2BB673;
  --orange: #F5A524;
  --text: #4A3B5C;
  --soft: #9A8AAE;
  --state: #8B6CF6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
/* Safari điện thoại: nền phủ cả vùng dưới thanh công cụ (không bị dải trắng) */
html { background: linear-gradient(#FFE9F3, #E3F2FF) fixed; min-height: 100dvh; }
body {
  font-family: -apple-system, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(#FFE9F3, #E3F2FF);
  user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- điện thoại ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
  height: 100dvh;
}
/* iPhone làm mờ một dải dưới thanh trạng thái / thanh địa chỉ: đẩy tiêu đề xuống khỏi dải đó */
@media (pointer: coarse) {
  #mobile { padding-top: calc(env(safe-area-inset-top) + 34px); }
}
.bubbles i {
  position: absolute; border-radius: 50%; opacity: .7;
  animation: float 4.5s ease-in-out infinite;
}
.bubbles i:nth-child(1) { width: 46px; height: 46px; left: 6%; top: 18%; background: #FFD3E6; }
.bubbles i:nth-child(2) { width: 30px; height: 30px; right: 10%; top: 12%; background: #D9CCFF; animation-delay: -1s; }
.bubbles i:nth-child(3) { width: 54px; height: 54px; right: 4%; top: 55%; background: #CDEBFF; animation-delay: -2s; }
.bubbles i:nth-child(4) { width: 26px; height: 26px; left: 3%; top: 62%; background: #FFE7B8; animation-delay: -3s; }
@keyframes float { 50% { transform: translateY(-10px); } }

.top { position: relative; width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 1; }
.brand { font-size: 22px; font-weight: 900; color: var(--pink); }
.chip {
  background: #fff; border-radius: 16px; padding: 6px 12px; font-size: 14px; font-weight: 700;
  color: var(--purple); box-shadow: 0 2px 8px #8b6cf622;
}

.status {
  position: relative; margin-top: 8px; z-index: 1;
  background: #fff; border: 2px solid var(--state); color: var(--state);
  border-radius: 20px; padding: 6px 16px; font-weight: 800; font-size: 15px;
  display: flex; gap: 8px; align-items: center; transition: border-color .25s, color .25s;
}
.status.listening, .status.speaking { }
.status.listening .ico, .status.speaking .ico { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }

.stage { position: relative; flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; }
.ring {
  position: absolute; width: min(78vw, 46vh); aspect-ratio: 1; border-radius: 50%;
  background: #fff; border: 5px solid color-mix(in srgb, var(--state) 45%, white);
  transition: border-color .25s;
}
.face {
  position: relative; width: min(74vw, 44vh); aspect-ratio: 1;
  border-radius: 50%; overflow: hidden;
  transform-origin: 50% 100%;
}
.face .img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .32s; }
.face .img.b { opacity: 0; }
.face .mouth {
  position: absolute; left: 38.28%; top: 49.32%; width: 23.44%; height: 13.67%;
  display: none;
}
.face.pop { animation: pop .5s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { 20% { transform: scale(.9); } }
.face.breath { animation: breath 3.2s ease-in-out infinite; }
@keyframes breath { 50% { transform: scale(1.025); } }
.face.talk { animation: bob .44s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-7px) rotate(1.5deg); } }
.face.ear { animation: tilt 2.4s ease-in-out infinite; }
@keyframes tilt { 30%, 60% { transform: rotate(7deg); } }
.face.search { animation: sway 2.8s ease-in-out infinite; }
@keyframes sway { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.face.shake { animation: shake .2s 2; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.fx { position: absolute; inset: 0; pointer-events: none; }
.fx span {
  position: absolute; font-size: 28px; opacity: 0;
  animation: rise 1.9s ease-out forwards;
}
@keyframes rise {
  15% { opacity: 1; transform: translateY(-10px) scale(1.15); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}
.fx span.drop { animation-name: drop; }
@keyframes drop { 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(60px); } }

.bubble {
  position: relative; width: 100%; max-width: 520px; margin-top: 12px;
  background: #fff; border: 2px solid #F3D9E8; border-radius: 22px;
  min-height: 80px; display: grid; place-items: center; padding: 10px 16px;
}
.bubble::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 16px; height: 16px;
  background: #fff; border-left: 2px solid #F3D9E8; border-top: 2px solid #F3D9E8;
  transform: translateX(-50%) rotate(45deg);
}
.bubble p { margin: 0; font-size: 19px; font-weight: 700; text-align: center; line-height: 1.3; }

.buttons { display: flex; gap: 10px; margin-top: 14px; }
.round { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 78px; }
.round span {
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; border: 3px solid #fff; box-shadow: 0 4px 10px #0001;
  transition: transform .12s;
}
.round:active span { transform: scale(.9); }
.round small { font-size: 13px; font-weight: 800; }
.round.green span { background: var(--green); }
.round.pink span { background: var(--pink); }
.round.orange span { background: var(--orange); }
.round.purple span { background: var(--purple); }
.round.muted span { background: #B9AECB; }  /* nút tắt giữ màu, chỉ thêm gạch chéo */
/* Đang tắt: gạch chéo đỏ trên nút tròn */
.round span { position: relative; overflow: hidden; }
.round.off span::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 120%; height: 5px;
  background: #F53F3F; border-radius: 3px; box-shadow: 0 0 0 2px #fff;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.round:disabled { opacity: .45; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; background: #4a3b5c66; display: grid; place-items: center; z-index: 10; padding: 20px; }
.card { background: #fff; border-radius: 26px; padding: 24px; max-width: 380px; text-align: center; box-shadow: 0 10px 40px #0003; }
.card h2 { margin: 6px 0 10px; color: var(--pink); }
.card p { margin: 0 0 14px; line-height: 1.45; }
.hello { font-size: 64px; }
.code { font-size: 44px; font-weight: 900; letter-spacing: 6px; color: var(--purple); margin: 6px 0 16px; }
.wide { width: 100%; padding: 14px; border-radius: 16px; background: var(--pink); color: #fff; font-weight: 800; font-size: 17px; }

/* ---------- Hologram ---------- */
#holo { background: #000; padding: 0; }
.holo-stage {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  --holo-size: 78vmin;
}
.holo-stage.flip-y { transform: scaleY(-1); }
.holo-stage.flip-x { transform: scaleX(-1); }
.holo-stage.flip-y.flip-x { transform: scale(-1, -1); }
.holo-face {
  width: var(--holo-size); border-radius: 0; overflow: visible;
  filter: drop-shadow(0 0 14px #7cc8ff88) brightness(1.15) saturate(1.2);
}
.holo-caption {
  margin: 2vmin 6vw 0; color: #fff; font-size: 6vmin; font-weight: 800; text-align: center;
  text-shadow: 0 0 12px #7cc8ff; min-height: 1.3em;
}
.holo-hint {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  color: #fff9; font-size: 14px; text-align: center; transition: opacity .6s;
}
.holo-hint p { margin: 4px 0; }
.holo-hint.fade { opacity: 0; pointer-events: none; }
.holo-tools { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.holo-tools button { border: 1px solid #fff5; border-radius: 14px; padding: 8px 12px; color: #fff; }
