:root {
  --bg: #0d0d0f;
  --fg: #ececf1;
  --muted: #8e8ea0;
  --panel: #1b1b1f;
  --line: #2a2a30;
  --accent: #4f8cff;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

/* login */
#login { align-items: center; justify-content: center; }
.card { width: min(320px, 86vw); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.card h1 { margin: 0 0 8px; font-weight: 600; font-size: 22px; }
.card .logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c9e0ff, #4f8cff 45%, #1b3b8f); }
.card input { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); font-size: 16px; outline: none; }
.card input:focus { border-color: var(--accent); }
.primary { padding: 14px; border: 0; border-radius: 14px; background: var(--fg); color: var(--bg); font-weight: 600; }
.err { color: #ff7a7a; min-height: 1.2em; margin: 0; font-size: 14px; }

/* header */
header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 16px; }
.seg { display: flex; background: var(--panel); border-radius: 999px; padding: 3px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; transition: background .2s, color .2s; }
.seg button.on { background: #34343b; color: var(--fg); }
.seg.locked button:not(.on) { opacity: .4; pointer-events: none; }
#voice { background: var(--panel); color: var(--fg); border: 0; border-radius: 999px; padding: 8px 12px; font-size: 14px; max-width: 42vw; }

/* stage + orb */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; min-height: 0; }
.orb { --lvl: 0; width: min(56vw, 240px); aspect-ratio: 1; display: grid; place-items: center; }
.blob {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #e4efff 0%, #8fb8ff 22%, #4f8cff 48%, #2353c9 72%, #13306f 100%);
  box-shadow: 0 0 60px rgba(79, 140, 255, .25);
  transform: scale(calc(1 + var(--lvl) * .28));
  transition: transform .08s linear, filter .4s, opacity .4s;
}
.orb.idle .blob { filter: saturate(.5) brightness(.75); }
.orb.connecting .blob { animation: breathe 1.4s ease-in-out infinite; }
.orb.listening .blob { animation: drift 6s ease-in-out infinite; }
.orb.thinking .blob { animation: breathe .9s ease-in-out infinite; filter: brightness(1.1); }
.orb.speaking .blob { box-shadow: 0 0 90px rgba(79, 140, 255, .45); }
.orb.muted .blob { filter: grayscale(.8) brightness(.6); }
@keyframes breathe { 50% { transform: scale(.9); } }
@keyframes drift { 0%,100% { border-radius: 50%; } 33% { border-radius: 47% 53% 51% 49% / 52% 48% 52% 48%; } 66% { border-radius: 53% 47% 48% 52% / 48% 53% 47% 52%; } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none !important; transition: none; } }
.status { margin: 0; color: var(--muted); font-size: 15px; min-height: 1.4em; text-align: center; padding: 0 24px; }
.latency { margin: -14px 0 0; color: #5d5d6b; font-size: 12px; min-height: 1em; font-variant-numeric: tabular-nums; }

/* captions */
.captions { max-height: 38vh; overflow-y: auto; padding: 4px 18px 8px; display: flex; flex-direction: column; gap: 8px; mask-image: linear-gradient(to bottom, transparent, #000 24px); }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 18px; font-size: 15px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #2f2f36; }
.msg.assistant { align-self: flex-start; background: transparent; padding-left: 0; color: #d6d6de; }
.msg.partial { opacity: .55; }
.msg.error { align-self: center; color: #ff8a8a; font-size: 13px; }

/* text bar */
.textbar { display: flex; gap: 8px; padding: 6px 16px; }
.textbar input { flex: 1; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); font-size: 16px; outline: none; }
.textbar button { width: 44px; border: 0; border-radius: 50%; background: var(--fg); color: var(--bg); font-size: 20px; font-weight: 700; }

/* footer */
footer { display: flex; justify-content: center; align-items: center; gap: 22px; padding: 14px 16px 22px; }
.round { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--panel); display: grid; place-items: center; transition: background .2s, transform .1s; }
.round:active { transform: scale(.94); }
.round:disabled { opacity: .35; pointer-events: none; }
.round.on { background: #3a3a44; }
.round svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round.big { width: 72px; height: 72px; }
.round.big.start { background: var(--fg); color: var(--bg); }
.round.big.end { background: #e5484d; color: #fff; }
.round.big .i-end, .round.big.end .i-start { display: none; }
.round.big.end .i-end { display: block; }
#micBtn .mic-off, #micBtn.off .mic-on { display: none; }
#micBtn.off .mic-off { display: block; }
#micBtn.off { background: #fff; color: #111; }

/* avatares */
.avpick { display: flex; justify-content: center; gap: 10px; padding: 0 16px 4px; }
.avpick button { width: 46px; height: 46px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--panel); overflow: hidden; display: grid; place-items: center; opacity: .6; transition: opacity .2s, border-color .2s; }
.avpick button.on { border-color: var(--fg); opacity: 1; }
.avpick img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; transform: scale(1.6); transform-origin: 50% 18%; }
.mini-orb { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c9e0ff, #4f8cff 45%, #1b3b8f); }
.avatar { width: min(92vw, 420px); flex: 1; min-height: 0; max-height: 52vh; position: relative; }
.avatar canvas { width: 100% !important; height: 100% !important; display: block; }
.avatar.loading::after { content: 'Cargando avatar…'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
