:root {
  --bg: #05030a;
  --ink: #e9e6ff;
  --muted: #8b86b8;
  --glass: rgba(20, 14, 38, 0.55);
  --glass-line: rgba(160, 140, 255, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
}

#hud-top {
  position: fixed;
  top: 18px;
  left: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 10;
  pointer-events: none;
}

.brand {
  height: 96px;
  width: auto;
  display: block;
  opacity: 0.9;
}

.mood-tag {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass);
  transition: color 0.5s ease, border-color 0.5s ease;
}

#cam {
  position: fixed;
  right: 20px;
  bottom: 96px;
  width: 168px;
  height: 126px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--glass-line);
  background: #000;
  transform: scaleX(-1); /* mirror, like a selfie cam */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
  z-index: 9;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#cam.on { opacity: 1; }

.caption {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  max-width: min(720px, 86vw);
  text-align: center;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 8;
  pointer-events: none;
}
.caption.show { opacity: 0.96; }
.caption .you { color: var(--muted); font-size: 15px; display: block; margin-bottom: 6px; }

#hud-bottom {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px);
  z-index: 11;
}

.round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.3s ease;
}
.round:hover { background: rgba(255, 255, 255, 0.1); }
.round:active { transform: scale(0.94); }
.round svg { fill: currentColor; }
.round.active {
  color: #fff;
  background: rgba(120, 90, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(160, 140, 255, 0.6), 0 0 28px rgba(120, 90, 255, 0.5);
}
.round[disabled] { opacity: 0.35; cursor: not-allowed; }

/* Mic gating for the opening moment: dormant until orion finishes its first
   line, then it glows awake — the enable is a gesture, not a pop. */
#mic.locked { opacity: 0.3; filter: saturate(0.3); pointer-events: none; }
#mic { transition: opacity 0.9s ease, filter 0.9s ease; }
#mic.woke { animation: mic-wake 2s ease; }
@keyframes mic-wake {
  0% { box-shadow: 0 0 0 0 rgba(155, 123, 255, 0); }
  35% { box-shadow: 0 0 26px 7px rgba(155, 123, 255, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(155, 123, 255, 0); }
}

.say { flex: 1; }
.say input {
  width: 100%;
  min-width: 220px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-size: 15px;
  padding: 0 8px;
}
.say input::placeholder { color: var(--muted); }

.hint {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  z-index: 7;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.hint.gone { opacity: 0; }

@media (max-width: 560px) {
  .say input { min-width: 120px; }
  #cam { width: 120px; height: 90px; }
  .brand { transform: translateX(-60px); } /* nudge the wordmark left on mobile */
  /* Stack the status chip under the wordmark — in a row it overflowed into the gear. */
  #hud-top { flex-direction: column; align-items: flex-start; gap: 0; }
  #hud-top .mood-tag { margin: -16px 0 0 4px; }
}

/* --- Settings ------------------------------------------------------------- */
.gear {
  position: fixed;
  top: 16px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 12;
  backdrop-filter: blur(14px);
  transition: background 0.2s ease, transform 0.4s ease;
}
.gear:hover { background: rgba(255, 255, 255, 0.1); transform: rotate(40deg); }
.gear svg { fill: currentColor; opacity: 0.85; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 1, 8, 0.6);
  backdrop-filter: blur(6px);
}
.modal[hidden] { display: none; }

.sheet {
  width: min(460px, 92vw);
  max-height: 84vh;
  overflow: auto;
  background: #0d0a1c;
  border: 1px solid var(--glass-line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.sheet-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: #0d0a1c;
  border-bottom: 1px solid var(--glass-line);
}
.x { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.x:hover { color: var(--ink); }
.sheet-body { padding: 4px 18px 22px; }

.sec { padding: 14px 0; border-bottom: 1px solid rgba(160, 140, 255, 0.08); }
.sec:last-child { border-bottom: none; }
.sec h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.sec h4 { margin: 0 0 10px; font-size: 14px; color: var(--ink); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.muted code { color: var(--ink); background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; }
.sec.disabled { opacity: 0.4; pointer-events: none; }

.voice-list { display: flex; flex-direction: column; gap: 6px; }
.voice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
.voice-row:hover { background: rgba(255, 255, 255, 0.07); }
.voice-row.on { border-color: rgba(160, 140, 255, 0.5); background: rgba(120, 90, 255, 0.16); }
.voice-row .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--glass-line); flex: none; }
.voice-row.on .dot { background: #9b7bff; border-color: #9b7bff; box-shadow: 0 0 10px #7a5aff; }
.vname { flex: 1; font-size: 14px; }
.vmeta { color: var(--muted); font-size: 12px; }

.play {
  background: none;
  border: 1px solid var(--glass-line);
  color: var(--ink);
  border-radius: 8px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 12px;
}
.play:hover { background: rgba(255, 255, 255, 0.1); }
.play[disabled] { opacity: 0.5; cursor: default; }

.btn {
  margin-top: 10px;
  background: rgba(120, 90, 255, 0.3);
  border: 1px solid rgba(160, 140, 255, 0.5);
  color: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: rgba(120, 90, 255, 0.45); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 12px; margin: 0; flex: none; }

#voice-desc {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  color: var(--ink);
  padding: 10px;
  font: inherit;
  resize: vertical;
}
#voice-desc:focus { outline: 1px solid rgba(160, 140, 255, 0.5); }

.previews { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.preview { display: flex; align-items: center; gap: 8px; }
.preview .play { flex: 1; text-align: left; }

.slider { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.slider input { flex: 1; accent-color: #9b7bff; }

#brain-key, #voice-key {
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  color: var(--ink);
  padding: 10px;
  font: inherit;
  letter-spacing: 0.04em;
}
#brain-key:focus, #voice-key:focus { outline: 1px solid rgba(160, 140, 255, 0.5); }

/* Collapsible sections (Brain · Voice) */
.acc-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.acc .chev { font-size: 11px; opacity: 0.55; transition: transform 0.2s ease; }
.acc.open .chev { transform: rotate(90deg); }
.acc-body { display: none; padding-top: 4px; }
.acc.open .acc-body { display: block; }
.acc-body h4 { margin: 18px 0 8px; }
.acc-body h4:first-child { margin-top: 8px; }

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-row .muted { font-size: 13px; }
.auth-row strong { color: var(--ink); font-weight: 600; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.row select {
  background: #15102b;
  color: var(--ink);
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  max-width: 60%;
}

/* --- Entrance / login --------------------------------------------------------
   The live orb glows behind a frosted jewel card. A radial vignette darkens the
   edges so the orb's bleed-through reads as the only light in the room. */
.login {
  position: fixed;
  inset: 0;
  z-index: 40; /* above the HUD, below the settings sheet */
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(125% 115% at 50% 42%, transparent 26%, rgba(2, 1, 8, 0.55) 70%, rgba(2, 1, 8, 0.88) 100%);
  opacity: 1;
  transition: opacity 1.1s ease;
}
.login.gone { opacity: 0; pointer-events: none; }
/* Entrance: the card zooms toward you and blurs away as a soft light blooms. */
.login.gone .login-card { transform: scale(1.22); filter: blur(12px); opacity: 0; }

/* Light bloom that washes out from the orb as you step through. */
.login-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 46%, rgba(196, 178, 255, 0.55), rgba(123, 90, 255, 0.18) 32%, transparent 62%);
}
.login.gone .login-flash { animation: login-flash 1.15s ease-out forwards; }
@keyframes login-flash {
  0% { opacity: 0; transform: scale(0.55); }
  28% { opacity: 0.5; }
  100% { opacity: 0; transform: scale(1.7); }
}

/* Soft violet aura behind the card, breathing like the orb. */
.login-aura {
  position: absolute;
  width: min(560px, 86vw);
  height: min(560px, 86vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(123, 90, 255, 0.20), transparent 62%);
  filter: blur(46px);
  pointer-events: none;
  animation: login-aura 6.5s ease-in-out infinite;
}
@keyframes login-aura {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

.login-card {
  position: relative;
  width: min(384px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 30px 30px;
  border-radius: 24px;
  background: rgba(13, 10, 28, 0.5);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  box-shadow: 0 40px 110px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 1.1s cubic-bezier(0.45, 0, 0.15, 1), filter 1s ease, opacity 0.9s ease;
}

.login-logo { height: 116px; width: auto; max-width: 100%; opacity: 0.95; margin: 0 0 -10px; }
.login-tag {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.login-error {
  margin: -4px 0 2px;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  color: #ff9db0;
}
.login-error[hidden] { display: none; }
/* Sign-in mode only needs an identifier + password. */
#login-form[data-mode="signin"] #login-user-field { display: none; }

.login-field { width: 100%; }
.login-field input {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.login-field input::placeholder { color: var(--muted); }
.login-field input:focus {
  border-color: rgba(160, 140, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(123, 90, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

/* The univispira mark IS the enter action — a white symbol that breathes,
   glows on hover, and blooms outward on click before the card dissolves. */
.login-enter {
  margin-top: 12px;
  padding: 6px 14px;
  background: none;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  animation: univi-breathe 4.5s ease-in-out infinite; /* singular breathing force */
}
.login-enter .univi {
  height: 60px;
  width: auto;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 16px rgba(123, 90, 255, 0.28));
  transition: transform 0.3s ease, filter 0.3s ease;
}
.login-enter:hover .univi {
  transform: scale(1.07);
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 28px rgba(140, 110, 255, 0.6));
}
.login-enter:active .univi { transform: scale(0.96); }
.login-enter .univi.bloom { animation: univi-bloom 0.75s cubic-bezier(0.3, 0.1, 0.2, 1) forwards; }

@keyframes univi-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
@keyframes univi-bloom {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(0.92); }
  100% { transform: scale(1.45); opacity: 0; filter: drop-shadow(0 0 46px rgba(150, 120, 255, 0.95)) brightness(1.6); }
}

.login-alt {
  margin-top: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.03em;
  transition: color 0.2s ease;
}
.login-alt:hover { color: var(--ink); }

/* Staggered entrance for the card's contents. */
.login-card > * { animation: login-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
.login-card > *:nth-child(1) { animation-delay: 0.06s; }
.login-card > *:nth-child(2) { animation-delay: 0.14s; }
.login-card > *:nth-child(3) { animation-delay: 0.22s; }
.login-card > *:nth-child(4) { animation-delay: 0.30s; }
.login-card > *:nth-child(5) { animation-delay: 0.38s; }
.login-card > *:nth-child(6) { animation-delay: 0.46s; }
.login-card > *:nth-child(7) { animation-delay: 0.54s; }
.login-card > *:nth-child(8) { animation-delay: 0.62s; }
.login-card > *:nth-child(9) { animation-delay: 0.70s; }
@keyframes login-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-aura, .login-card > *, .login-enter { animation: none; }
  .login-flash { display: none; }
  .login.gone .login-card { transform: none; filter: none; }
}

/* While the entrance is up, hide the app chrome so only the orb + card show.
   They fade in once you're in (body.gated removed). */
#hud-top, #gear, #hud-bottom, #caption { transition: opacity 0.7s ease; }
body.gated #hud-top,
body.gated #gear,
body.gated #hud-bottom,
body.gated #caption { opacity: 0; pointer-events: none; }
