/* AI Buddy: glowing stage, animated robot (faces, moods, accessories) and the customize panel. */
.bb-top { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 18px; margin-bottom: 16px; }
.bb-stage {
  --bt: #2f9bff;
  position: relative; overflow: hidden; border-radius: 22px; padding: 22px 22px 18px;
  border: 1px solid color-mix(in srgb, var(--bt) 40%, transparent);
  background:
    radial-gradient(60% 45% at 50% 72%, color-mix(in srgb, var(--bt) 32%, transparent), transparent 70%),
    radial-gradient(80% 60% at 20% 0%, rgba(120, 60, 255, .18), transparent 60%),
    linear-gradient(180deg, #071233, #040a1f);
  box-shadow: 0 0 40px color-mix(in srgb, var(--bt) 18%, transparent) inset;
  display: flex; flex-direction: column;
}
.bb-hello { display: flex; gap: 12px; align-items: flex-start; position: relative; z-index: 2; }
.bb-hello h1 { margin: 0; font: 800 clamp(26px, 3.4vw, 36px)/1.1 var(--font-head); }
.bb-hello p { margin: 4px 0 0; color: #cfdcf5; max-width: 32ch; }
.bb-hello > div:nth-child(2) { flex: 1; }
.bb-wave { font-size: 40px; display: inline-block; transform-origin: 70% 80%; animation: bb-hand 2.4s ease-in-out infinite; }
@keyframes bb-hand { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(16deg); } 20%, 40% { transform: rotate(-8deg); } }

.bb-lang { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: rgba(5, 12, 34, .8); border: 1px solid var(--line); flex: none; }
.bb-lang button { border: 0; border-radius: 999px; padding: 6px 12px; font: 800 14px var(--font-body); color: var(--muted); background: transparent; cursor: pointer; min-height: 36px; }
.bb-lang button[aria-pressed="true"] { background: linear-gradient(180deg, #ffd650, #f5b52e); color: #1b1300; }
.bb-lang { align-items: center; padding: 4px 6px 4px 12px; font-size: 16px; }
.bb-lang select { border: 0; border-radius: 999px; padding: 6px 10px; font: 800 14px var(--font-body); color: #1b1300; background: linear-gradient(180deg, #ffd650, #f5b52e); cursor: pointer; min-height: 36px; max-width: 210px; }
.auth-card .bb-lang { align-self: center; margin-top: 8px; }

.bb-arena { position: relative; flex: 1; min-height: 330px; display: grid; place-items: center; }
.bb-rings { position: absolute; left: 50%; bottom: 6px; width: min(78%, 440px); aspect-ratio: 4 / 1; transform: translateX(-50%); }
.bb-rings i { position: absolute; inset: 0; margin: auto; border-radius: 50%; border: 3px solid var(--bt); box-shadow: 0 0 18px var(--bt), 0 0 18px var(--bt) inset; opacity: .75; }
.bb-rings i:nth-child(2) { width: 66%; height: 66%; opacity: .6; }
.bb-rings i:nth-child(3) { width: 34%; height: 34%; background: color-mix(in srgb, var(--bt) 45%, transparent); opacity: .9; }
.bb-stage[data-mode="talking"] .bb-rings i, .bb-stage[data-mode="listening"] .bb-rings i { animation: bb-ring 1.2s ease-in-out infinite; }
.bb-rings i:nth-child(2) { animation-delay: .2s !important; } .bb-rings i:nth-child(3) { animation-delay: .4s !important; }
@keyframes bb-ring { 50% { transform: scale(1.06); opacity: 1; } }

.bb-star { position: absolute; color: #ffd650; font-size: 38px; text-shadow: 0 0 16px rgba(255, 214, 80, .8); animation: bb-twinkle 2.6s ease-in-out infinite; }
.bb-star.s1 { left: 14%; top: 26%; } .bb-star.s2 { right: 24%; top: 58%; font-size: 30px; animation-delay: 1.1s; }
@keyframes bb-twinkle { 50% { transform: scale(.7) rotate(20deg); opacity: .6; } }

.bb-bot { position: relative; z-index: 1; width: min(62%, 300px); padding: 0; margin: 0 0 18px; border: 0; background: none; cursor: pointer; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .45)); -webkit-tap-highlight-color: transparent; }
.bb-bot:focus-visible { outline: 3px solid var(--gold); outline-offset: 6px; border-radius: 24px; }
.bb-bot .bb-svg { display: block; width: 100%; height: auto; animation: bb-float 3.2s ease-in-out infinite; }
.bb-bot.boing .bb-svg { animation: bb-boing .7s cubic-bezier(.3, 1.6, .5, 1), bb-float 3.2s .7s ease-in-out infinite; }
@keyframes bb-float { 50% { transform: translateY(-10px); } }
@keyframes bb-boing { 0% { transform: scale(1, 1); } 30% { transform: scale(1.12, .88) translateY(6px); } 60% { transform: scale(.92, 1.1) translateY(-22px); } 100% { transform: none; } }

/* Robot parts */
.bb-svg .bb-face { filter: drop-shadow(0 0 4px currentColor); }
.bb-svg .bb-ear, .bb-svg .bb-ant { filter: drop-shadow(0 0 5px currentColor); }
.bb-svg .bb-eyes { transform-box: fill-box; transform-origin: center; animation: bb-blink 4.5s infinite; }
@keyframes bb-blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.bb-svg .bb-mouth-open { opacity: 0; transform-box: fill-box; transform-origin: 50% 20%; }
.bb-svg .bb-arm-r { transform-box: fill-box; transform-origin: 0% 100%; animation: bb-armwave 2.4s ease-in-out infinite; }
@keyframes bb-armwave { 0%, 60%, 100% { transform: rotate(0); } 15%, 45% { transform: rotate(-14deg); } 30% { transform: rotate(8deg); } }
.bb-svg .bb-fx > * { opacity: 0; }

/* Talking: the mouth opens and closes (also while thinking: an "ooh" shape). */
.bb-stage[data-mode="talking"] .bb-mouth-closed, .bb-stage[data-mode="thinking"] .bb-mouth-closed { opacity: 0; }
.bb-stage[data-mode="talking"] .bb-mouth-open { opacity: 1; animation: bb-jaw .26s ease-in-out infinite alternate; }
.bb-stage[data-mode="thinking"] .bb-mouth-open { opacity: 1; animation: bb-ooh 1s ease-in-out infinite alternate; }
@keyframes bb-jaw { from { transform: scale(.85, .25); } to { transform: scale(1, 1.05); } }
@keyframes bb-ooh { from { transform: scale(.55, .55); } to { transform: scale(.7, .8); } }
.bb-stage[data-mode="thinking"] .bb-head { transform-box: fill-box; transform-origin: 50% 100%; animation: bb-think 1.6s ease-in-out infinite; }
@keyframes bb-think { 50% { transform: rotate(-6deg); } }
.bb-stage[data-mode="listening"] .bb-ear { animation: bb-earglow .7s ease-in-out infinite alternate; }
@keyframes bb-earglow { to { opacity: .4; } }
.bb-stage[data-mode="talking"] .bb-svg { animation-duration: 1.4s; }

/* Moods */
.bb-stage[data-mood="happy"] .bb-blush { opacity: .6; }
.bb-stage:not([data-mood="happy"]):not([data-mood="silly"]) .bb-blush { opacity: .25; }
.bb-stage[data-mood="excited"] .bb-bot .bb-svg { animation: bb-bounce .9s ease-in-out infinite; }
@keyframes bb-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px) scale(1.02); } 60% { transform: translateY(0) scale(1.04, .96); } }
.bb-stage[data-mood="excited"] .bb-fx-star, .bb-stage[data-mood="proud"] .bb-fx-star { opacity: 1; animation: bb-twinkle 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.bb-stage[data-mood="excited"] .bb-fx-star.s2 { animation-delay: .5s; }
.bb-stage[data-mood="calm"] .bb-bot .bb-svg { animation-duration: 6s; }
.bb-stage[data-mood="calm"] .bb-rings i { animation: bb-ring 4s ease-in-out infinite; }
.bb-stage[data-mood="silly"] .bb-bot .bb-svg { animation: bb-wiggle 1.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes bb-wiggle { 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
.bb-stage[data-mood="silly"] .bb-fx-note { opacity: 1; animation: bb-rise 2s ease-in-out infinite; }
.bb-stage[data-mood="curious"] .bb-head { transform-box: fill-box; transform-origin: 50% 100%; transform: rotate(-9deg); }
.bb-stage[data-mood="curious"] .bb-fx-q { opacity: 1; animation: bb-rise 2.4s ease-in-out infinite; }
.bb-stage[data-mood="proud"] .bb-bot .bb-svg { animation: bb-proud 2.4s ease-in-out infinite; }
@keyframes bb-proud { 50% { transform: translateY(-8px) scale(1.04); } }
.bb-stage[data-mood="proud"] .bb-heart { filter: drop-shadow(0 0 6px #ffc72c); }
@keyframes bb-rise { 0% { transform: translateY(8px); opacity: 0; } 30%, 70% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }

/* Speech bubble */
.bb-speech {
  position: absolute; z-index: 2; right: 2%; top: 4%; max-width: min(46%, 270px);
  padding: 14px 18px; border-radius: 22px; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bt) 85%, #fff 10%), color-mix(in srgb, var(--bt) 65%, #001));
  border: 2px solid color-mix(in srgb, var(--bt) 60%, #fff);
  box-shadow: 0 0 24px color-mix(in srgb, var(--bt) 60%, transparent);
}
.bb-speech::after { content: ''; position: absolute; left: -12px; bottom: 22px; border: 12px solid transparent; border-right-color: color-mix(in srgb, var(--bt) 70%, #001); border-left: 0; }
.bb-speech b { display: block; font: 800 clamp(20px, 2.4vw, 26px)/1.15 var(--font-head); }
.bb-speech span { display: block; font-weight: 700; font-size: 15.5px; line-height: 1.35; margin-top: 2px; }
.bb-speech.pop { animation: bb-pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bb-pop { from { transform: scale(.8); opacity: 0; } }
.bb-stage[data-mode="thinking"] .bb-speech b::after { content: ' 💭'; }

/* Big microphone with sound waves */
.bb-micbox { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.bb-micbox > b { font-size: 17px; color: #dbe6ff; }
.bb-micbox .mic-note { margin: 0; min-height: 1.3em; color: var(--muted); font-size: 14px; }
.bb-microw { display: flex; align-items: center; gap: 14px; }
.bb-mic {
  width: 92px; height: 92px; border-radius: 50%; font-size: 38px; cursor: pointer; color: #fff;
  border: 3px solid color-mix(in srgb, var(--bt) 70%, #fff);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--bt) 80%, #fff 10%), color-mix(in srgb, var(--bt) 50%, #001) 75%);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--bt) 18%, transparent), 0 0 34px var(--bt);
  transition: transform .15s;
}
.bb-mic:hover { transform: scale(1.05); }
.bb-mic:active { transform: scale(.95); }
.bb-mic.mic-on { border-color: #ff8a8a; background: radial-gradient(circle at 50% 35%, #ff7b7b, #a61b1b 75%); box-shadow: 0 0 0 8px rgba(239, 68, 68, .2), 0 0 34px #ef4444; animation: bb-micpulse 1.1s ease-in-out infinite; }
@keyframes bb-micpulse { 50% { box-shadow: 0 0 0 16px rgba(239, 68, 68, .08), 0 0 44px #ef4444; } }
.bb-waves { display: flex; align-items: center; gap: 4px; height: 50px; }
.bb-waves i { width: 4px; height: 10px; border-radius: 4px; background: var(--bt); box-shadow: 0 0 8px var(--bt); opacity: .7; }
.bb-waves i:nth-child(3n) { height: 22px; } .bb-waves i:nth-child(4n) { height: 32px; } .bb-waves i:nth-child(5n+2) { height: 16px; }
.bb-stage[data-mode="listening"] .bb-waves i, .bb-stage[data-mode="talking"] .bb-waves i { animation: bb-eq .5s ease-in-out infinite alternate; opacity: 1; }
@keyframes bb-eq { from { transform: scaleY(.35); } to { transform: scaleY(1.5); } }

/* Customize panel */
.bb-custom { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.bb-custom-head { display: flex; align-items: center; gap: 12px; }
.bb-custom-head h2 { margin: 0; font: 800 21px/1.15 var(--font-head); }
.bb-custom-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.bb-custom-ava { width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-items: center; background: #0a1a42; border: 2px solid var(--line); box-shadow: 0 0 16px var(--glow); }
.bb-custom-ava svg { width: 44px; }
.bb-custom h3 { margin: 6px 0 0; font: 800 16px var(--font-body); }
.bb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: rgba(5, 12, 34, .7); border: 1px solid var(--line); }
.bb-tabs button { border: 0; border-radius: 10px; padding: 10px 6px; font: 800 14.5px var(--font-body); color: var(--muted); background: transparent; cursor: pointer; }
.bb-tabs button[aria-pressed="true"] { color: #fff; background: linear-gradient(180deg, #1d5fd6, #123c8f); box-shadow: 0 0 14px var(--glow); }
.bb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bb-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  aspect-ratio: 1.15; padding: 6px; border-radius: 16px; cursor: pointer; color: var(--ink);
  background: linear-gradient(180deg, #0f2150, #0a1638); border: 2px solid rgba(82, 150, 255, .22);
  transition: transform .12s, border-color .12s;
}
.bb-card:hover { transform: translateY(-2px); border-color: rgba(82, 150, 255, .6); }
.bb-card[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 199, 44, .25), 0 0 18px rgba(255, 199, 44, .35); }
.bb-card[aria-pressed="true"]::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--gold); color: #1b1300; font: 900 13px/22px var(--font-body); text-align: center; }
.bb-card small { font-size: 12.5px; font-weight: 800; color: var(--muted); }
.bb-mini { display: block; width: 72%; }
.bb-mini svg { display: block; width: 100%; height: auto; }
.bb-grid-acc .bb-mini { width: 48%; }
.bb-emoji { font-size: 34px; line-height: 1.2; }
.bb-colors { display: flex; gap: 14px; flex-wrap: wrap; padding: 2px 4px; }
.bb-dot { width: 36px; height: 36px; border-radius: 50%; cursor: pointer; background: var(--c); border: 3px solid rgba(255, 255, 255, .15); box-shadow: 0 0 12px var(--c); }
.bb-dot[aria-pressed="true"] { outline: 3px solid var(--gold); outline-offset: 3px; }
.bb-pers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bb-pers button { border-radius: 999px; padding: 9px 6px; font: 800 14px var(--font-body); cursor: pointer; color: var(--ink); background: #0f2150; border: 1px solid var(--line); }
.bb-pers button[aria-pressed="true"] { background: linear-gradient(180deg, #ffd650, #f5b52e); color: #1b1300; border-color: transparent; }
.bb-save { align-self: flex-end; min-width: 180px; margin-top: 4px; }
.bb-save.is-saved { opacity: .75; }

/* Chat messages with Buddy's own face */
.bb-chat .msg-ava-bot { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #0a1a42; border: 2px solid var(--line); }
.bb-chat .msg-ava-bot svg { width: 36px; }
.bb-chat .msg-user .msg-ava { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #1b3a7a; font: 800 18px var(--font-head); }
.msg-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-name { display: flex; gap: 10px; align-items: baseline; font: 800 14px var(--font-body); color: #dbe6ff; }
.msg-name time { color: var(--muted); font-weight: 700; font-size: 12px; }
.bb-locked { width: 150px; align-self: center; }
.bb-locked svg { width: 100%; height: auto; }

@media (max-width: 960px) {
  .bb-top { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .bb-stage { padding: 16px 14px 14px; }
  .bb-hello { flex-wrap: wrap; }
  .bb-wave { font-size: 30px; }
  .bb-lang { order: -1; margin-left: auto; }
  .bb-arena { min-height: 280px; }
  .bb-bot { width: 58%; align-self: end; justify-self: start; margin-left: 4%; }
  .bb-speech { max-width: 46%; padding: 10px 12px; right: 0; }
  .bb-speech span { font-size: 14px; }
  .bb-mic { width: 78px; height: 78px; font-size: 32px; }
  .bb-waves { gap: 3px; }
  .bb-waves i:nth-child(n+8) { display: none; }
  .bb-pers { grid-template-columns: repeat(2, 1fr); }
  .bb-save { align-self: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .bb-stage *, .bb-wave { animation: none !important; }
  .bb-stage[data-mode="talking"] .bb-mouth-open { transform: scale(.9, .7); }
}

/* 🎄 Christmas season: the extra 🎅 Santa personality gets its own full-width row. */
.bb-pers button:nth-child(5):last-child { grid-column: 1 / -1; }
