:root {
  color-scheme: dark;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --paper: #f3f1ec;
  --paper-muted: rgba(243, 241, 236, 0.68);
  --plate-ratio: 0.707579;
  --nose-x: 50%;
  --nose-y: 38.1%;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: #050606;
}

body {
  min-height: 100svh;
  overflow: hidden;
  color: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.stage {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: #050606;
}

.portrait {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(calc((100svh - 16px) * var(--plate-ratio)), calc(100vw - 16px), 1055px);
  aspect-ratio: 1055 / 1491;
  overflow: hidden;
  background: #050606;
  box-shadow: 0 24px 84px rgba(0, 0, 0, 0.58);
}

.portrait__image,
.master-plate,
.living-plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.portrait__image {
  z-index: 0;
  overflow: hidden;
  background: #050606;
}

.master-plate,
.living-plate {
  display: block;
  object-fit: contain;
  object-position: 50% 50%;
  transform: none;
  user-select: none;
  pointer-events: none;
}

.master-plate {
  z-index: 0;
}

.living-plate {
  z-index: 1;
  opacity: 0;
  background: #050606;
  pointer-events: none;
}

.portrait[data-living-ready="true"] .living-plate {
  opacity: 1;
}

.answer {
  position: absolute;
  z-index: 7;
  top: calc(var(--nose-y) + 4.7%);
  left: var(--nose-x);
  width: min(74%, 42rem);
  min-height: 2rem;
  color: var(--paper);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.46rem, 0.98cqw, 0.68rem);
  font-variant-ligatures: none;
  font-weight: 400;
  letter-spacing: 0.025em;
  line-height: 1.36;
  text-align: center;
  text-wrap: balance;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 420ms ease;
  pointer-events: none;
}

.portrait:is([data-state="streaming"], [data-state="holding"]) .answer {
  opacity: 1;
}

.thinking-status {
  position: absolute;
  z-index: 7;
  top: calc(var(--nose-y) + 4.7%);
  left: var(--nose-x);
  display: flex;
  align-items: center;
  gap: 0.32em;
  color: rgba(243, 241, 236, 0.78);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.27rem, 0.9cqw, 0.64rem);
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 320ms ease;
  pointer-events: none;
}

.thinking-status i {
  width: 0.28em;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  animation: thinking-dot 1.3s ease-in-out infinite;
}

.thinking-status i:nth-child(3) {
  animation-delay: 160ms;
}

.thinking-status i:nth-child(4) {
  animation-delay: 320ms;
}

.portrait[data-thinking="true"] .thinking-status {
  opacity: 1;
}

.session-clock {
  position: absolute;
  z-index: 8;
  top: 4.1%;
  right: 4.2%;
  color: rgba(243, 241, 236, 0.64);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.32rem, 0.92cqw, 0.66rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  opacity: 0;
  transition: opacity 360ms ease;
}

.portrait[data-timer="running"] .session-clock {
  opacity: 1;
}

.portrait[data-state="holding"] .answer {
  pointer-events: auto;
}

.answer__cursor {
  display: inline-block;
  width: 1px;
  height: 0.9em;
  margin-left: 0.07em;
  background: currentColor;
  opacity: 0.72;
  vertical-align: -0.07em;
  animation: cursor 820ms step-end infinite;
}

.interaction {
  position: absolute;
  z-index: 8;
  top: 76.1%;
  left: 19.2%;
  width: 61.6%;
  height: 4.95%;
}

.prompt {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.prompt::before,
.prompt::after {
  position: absolute;
  content: "";
  pointer-events: none;
  transition: opacity 360ms ease;
}

.prompt::before {
  z-index: 1;
  top: 7%;
  right: 48%;
  bottom: 7%;
  left: 10.4%;
  border-radius: 999px;
  background: rgb(22, 22, 22);
  opacity: 1;
}

.prompt:focus-within::before {
  opacity: 1;
}

.prompt__birdgraph {
  position: absolute;
  z-index: 6;
  top: 46.5%;
  left: 3.4%;
  display: block;
  width: 5%;
  aspect-ratio: 1;
  transform: translateY(-50%);
  contain: strict;
  isolation: isolate;
  pointer-events: none;
}

.prompt__birdgraph::before,
.prompt__birdgraph::after {
  position: absolute;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.prompt__birdgraph::before {
  inset: -13%;
  background: radial-gradient(
    circle,
    rgb(22, 22, 21) 0%,
    rgb(22, 22, 21) 78%,
    rgba(22, 22, 21, 0) 100%
  );
}

.prompt__birdgraph::after {
  inset: 12%;
  background: rgba(89, 230, 220, 0.045);
  filter: blur(3px);
}

.prompt__birdgraph canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.prompt::after {
  z-index: 4;
  inset: -4%;
  border-radius: 999px;
  background: rgba(4, 5, 5, 0.82);
  opacity: 0;
}

.prompt__input {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 11.5%;
  bottom: 0;
  left: 11.5%;
  width: 77%;
  height: 100%;
  min-width: 0;
  margin: 0;
  border: 0;
  outline: 0;
  padding: 0;
  appearance: none;
  background: transparent;
  color: var(--paper);
  font-size: max(0.5rem, 1.05cqw);
  font-weight: 350;
  letter-spacing: -0.01em;
  line-height: 1;
}

.prompt__input::placeholder {
  color: rgba(243, 241, 236, 0.62);
  font-size: 100%;
  letter-spacing: 0.01em;
}

.prompt__input:focus::placeholder {
  color: rgba(243, 241, 236, 0.62);
  font-size: 100%;
}

.prompt__voice,
.prompt__send {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  width: 12%;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.prompt__voice {
  left: 0;
}

.prompt__send {
  right: 0;
}

.prompt__voice:focus-visible,
.prompt__send:focus-visible {
  outline: 1px solid rgba(243, 241, 236, 0.95);
  outline-offset: 2px;
}

.prompt__input:focus,
.prompt__input:focus-visible {
  outline: 0;
  box-shadow: none;
}

.prompt__voice[data-listening="true"] {
  box-shadow: inset 0 0 0 1px rgba(243, 241, 236, 0.72);
  animation: listen 1.55s ease-in-out infinite;
}

.portrait:is([data-state="preparing"], [data-state="streaming"], [data-state="holding"], [data-state="dissolving"]) .prompt::after {
  opacity: 1;
}

.portrait:is([data-state="preparing"], [data-state="streaming"], [data-state="holding"], [data-state="dissolving"]) .prompt__input,
.portrait:is([data-state="preparing"], [data-state="streaming"], [data-state="holding"], [data-state="dissolving"]) .prompt__voice,
.portrait:is([data-state="preparing"], [data-state="streaming"], [data-state="holding"], [data-state="dissolving"]) .prompt__send {
  opacity: 0;
  pointer-events: none;
}

.begin {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(243, 241, 236, 0.8);
  border-radius: 999px;
  background: rgba(5, 6, 6, 0.86);
  color: var(--paper);
  font-size: clamp(0.7rem, 1.8cqw, 0.88rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  cursor: pointer;
}

.portrait[data-stage="genesis-ready"] .prompt {
  display: none;
}

.portrait[data-stage="genesis-ready"] .begin {
  display: block;
  animation: reveal 850ms ease both;
}

.genesis-plate {
  position: absolute;
  z-index: 6;
  top: 63.5%;
  right: 17%;
  left: 17%;
  display: none;
  padding: 2.5% 2%;
  background: radial-gradient(ellipse, rgba(3, 4, 4, 0.98) 0%, rgba(3, 4, 4, 0.88) 64%, transparent 100%);
  text-align: center;
}

.genesis-plate p {
  margin: 0 0 1.2%;
  color: var(--paper-muted);
  font-size: clamp(0.58rem, 1.55cqw, 0.74rem);
  letter-spacing: 0.21em;
}

.genesis-plate h2 {
  margin: 0;
  font-size: clamp(1.45rem, 7.2cqw, 3.45rem);
  font-weight: 320;
  letter-spacing: 0.22em;
}

.portrait[data-stage="genesis"] .genesis-plate {
  display: block;
}

.portrait[data-stage="genesis"] .prompt__voice,
.portrait[data-stage="genesis"] .prompt__send {
  display: none;
}

.portrait[data-stage="genesis"] .prompt__input {
  right: 5%;
  left: 5%;
  width: 90%;
  text-align: center;
}

.genesis-invitation {
  position: absolute;
  z-index: 18;
  top: 43.5%;
  right: 12.5%;
  left: 12.5%;
  display: grid;
  justify-items: center;
  padding: 6.2% 5.2% 5.6%;
  border: 1px solid rgba(243, 241, 236, 0.28);
  background: rgba(8, 9, 9, 0.93);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72), inset 0 0 44px rgba(243, 241, 236, 0.025);
  text-align: center;
  backdrop-filter: blur(18px);
  animation: invitation-rise 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.genesis-invitation[hidden] {
  display: none;
}

.genesis-invitation__eyebrow {
  margin: 0 0 2%;
  color: rgba(243, 241, 236, 0.56);
  font-size: clamp(0.34rem, 1.1cqw, 0.73rem);
  letter-spacing: 0.2em;
}

.genesis-invitation h2 {
  margin: 0;
  color: var(--paper);
  font-size: clamp(0.98rem, 4.2cqw, 2.5rem);
  font-weight: 340;
  letter-spacing: -0.025em;
}

.genesis-invitation > p:not(.genesis-invitation__eyebrow) {
  margin: 2.2% 0 4.5%;
  color: rgba(243, 241, 236, 0.72);
  font-size: clamp(0.42rem, 1.45cqw, 0.92rem);
}

.genesis-invitation__qr {
  display: block;
  width: 23%;
  min-width: 64px;
  max-width: 150px;
  padding: 1.3%;
  border: 1px solid rgba(243, 241, 236, 0.24);
  background: #f3f1ec;
}

.genesis-invitation__qr img {
  display: block;
  width: 100%;
  height: auto;
}

.genesis-invitation__action {
  margin-top: 4.4%;
  color: var(--paper);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: clamp(0.4rem, 1.2cqw, 0.78rem);
  letter-spacing: 0.12em;
  text-underline-offset: 0.3em;
}

.genesis-invitation small {
  margin-top: 3.2%;
  color: rgba(243, 241, 236, 0.5);
  font-size: clamp(0.32rem, 1cqw, 0.64rem);
  line-height: 1.45;
}

.portrait[data-stage="invitation"] .interaction,
.portrait[data-stage="invitation"] .answer,
.portrait[data-stage="invitation"] .thinking-status,
.portrait[data-stage="invitation"] .session-clock {
  opacity: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  z-index: 9;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hotspot--privacy {
  top: 2.3%;
  left: 3.2%;
  width: 15%;
  height: 8%;
}

.hotspot--hello {
  right: 3.2%;
  bottom: 3.2%;
  width: 10.5%;
  height: 8%;
}

.hotspot:focus-visible {
  outline: 1px solid var(--paper);
  outline-offset: 2px;
}

.disclosure {
  width: min(calc(100% - 2rem), 31rem);
  margin: auto;
  padding: clamp(1.35rem, 5vw, 2.4rem);
  border: 1px solid rgba(243, 241, 236, 0.23);
  background: rgba(12, 13, 13, 0.96);
  color: var(--paper);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(18px);
}

.disclosure::backdrop {
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px);
}

.disclosure__close {
  position: absolute;
  top: 0.5rem;
  right: 0.65rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: none;
  color: var(--paper-muted);
  font-size: 1.55rem;
  font-weight: 250;
  cursor: pointer;
}

.disclosure__label {
  margin: 0 0 0.65rem;
  color: var(--paper-muted);
  font-size: 0.68rem;
  letter-spacing: 0.17em;
}

.disclosure h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.4rem, 5vw, 2.05rem);
  font-weight: 410;
  letter-spacing: -0.025em;
}

.disclosure p:last-child {
  margin: 0;
  color: rgba(243, 241, 236, 0.78);
  font-size: 1rem;
  line-height: 1.55;
}

.noscript {
  position: absolute;
  z-index: 30;
  top: 48%;
  right: 15%;
  left: 15%;
  padding: 1rem;
  background: #0b0c0c;
  color: var(--paper);
  text-align: center;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes cursor {
  0%,
  45% {
    opacity: 0.75;
  }
  46%,
  100% {
    opacity: 0;
  }
}

@keyframes listen {
  0%,
  100% {
    box-shadow: inset 0 0 0 0 rgba(243, 241, 236, 0);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(243, 241, 236, 0.78);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes thinking-dot {
  0%,
  70%,
  100% {
    opacity: 0.22;
    transform: translateY(0);
  }
  35% {
    opacity: 0.92;
    transform: translateY(-0.2em);
  }
}

@keyframes invitation-rise {
  from {
    opacity: 0;
    transform: translateY(2.2%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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