:root {
  --bg: #000000;
  --green-core: #8bff6a;
  --green-mid: #48ff56;
  --green-glow: rgba(72, 255, 86, 0.35);
  --green-soft: rgba(72, 255, 86, 0.14);
  --pixel-size: clamp(8px, 1.25vw, 14px);
  --pixel-gap: calc(var(--pixel-size) * 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: monospace;
}

body {
  display: grid;
  place-items: center;
}

.screen {
  position: relative;
  width: min(100vw, 740px);
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(circle at 50% 35%, rgba(72, 255, 86, 0.11), transparent 28%),
    radial-gradient(circle at 50% 70%, rgba(72, 255, 86, 0.08), transparent 24%),
    #000;
  isolation: isolate;
  cursor: pointer;
}

.system-state {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 3;
  color: rgba(139, 255, 106, 0.74);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-shadow: 0 0 10px rgba(72, 255, 86, 0.42);
  pointer-events: none;
}

.user-badge,
.logout-toggle {
  position: absolute;
  z-index: 4;
  transition: opacity 160ms ease;
}

.logout-toggle,
.user-badge {
  opacity: 0;
  pointer-events: none;
}

.user-badge {
  top: 18px;
  left: 104px;
  max-width: min(42vw, 280px);
  color: rgba(139, 255, 106, 0.84);
  font-size: 11px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 10px rgba(72, 255, 86, 0.42);
}

.logout-toggle {
  top: 16px;
  right: 184px;
  min-width: 96px;
  padding: 7px 10px 6px;
  border: 1px solid rgba(139, 255, 106, 0.45);
  background: rgba(0, 0, 0, 0.72);
  color: rgba(139, 255, 106, 0.92);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(72, 255, 86, 0.4);
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.08) inset,
    0 0 14px rgba(72, 255, 86, 0.14);
  cursor: pointer;
}

.logout-toggle.is-visible,
.user-badge.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.mute-toggle {
  position: absolute;
  top: 16px;
  right: 82px;
  z-index: 4;
  min-width: 90px;
  padding: 7px 10px 6px;
  border: 1px solid rgba(139, 255, 106, 0.45);
  background: rgba(0, 0, 0, 0.72);
  color: rgba(139, 255, 106, 0.92);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(72, 255, 86, 0.4);
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.08) inset,
    0 0 14px rgba(72, 255, 86, 0.14);
  cursor: pointer;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.mute-toggle:hover,
.mute-toggle:focus-visible {
  outline: none;
  color: #d6ffc9;
  border-color: rgba(139, 255, 106, 0.78);
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.16) inset,
    0 0 18px rgba(72, 255, 86, 0.24);
  transform: translateY(-1px);
}

.logout-toggle:hover,
.logout-toggle:focus-visible {
  outline: none;
  color: #d6ffc9;
  border-color: rgba(139, 255, 106, 0.78);
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.16) inset,
    0 0 18px rgba(72, 255, 86, 0.24);
}

.mute-toggle:disabled {
  opacity: 0.32;
  cursor: default;
  transform: none;
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.05) inset,
    0 0 10px rgba(72, 255, 86, 0.08);
}

.mute-toggle.is-muted {
  border-color: rgba(255, 151, 98, 0.64);
  color: rgba(255, 186, 150, 0.94);
  text-shadow: 0 0 8px rgba(255, 151, 98, 0.32);
  box-shadow:
    0 0 0 1px rgba(255, 151, 98, 0.1) inset,
    0 0 14px rgba(255, 151, 98, 0.18);
}

.listen-indicator {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 54px;
  height: 34px;
  border: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0.64;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(72, 255, 86, 0.25));
}

.listen-indicator::before {
  content: "RX";
  position: absolute;
  left: 0;
  bottom: 0;
  color: rgba(139, 255, 106, 0.82);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px rgba(72, 255, 86, 0.5);
}

.listen-antenna,
.listen-core,
.listen-wave {
  position: absolute;
  display: block;
  background: var(--green-mid);
  box-shadow:
    0 0 8px rgba(139, 255, 106, 0.95),
    0 0 18px var(--green-glow);
}

.listen-antenna {
  left: 31px;
  top: 2px;
  width: 4px;
  height: 16px;
}

.listen-core {
  left: 25px;
  top: 19px;
  width: 14px;
  height: 10px;
}

.listen-wave {
  width: 6px;
  height: 6px;
  opacity: 0.42;
}

.listen-wave-one {
  left: 15px;
  top: 14px;
}

.listen-wave-two {
  right: 5px;
  top: 14px;
}

.screen.state-listening .listen-indicator {
  opacity: 1;
  animation: listenPulse 900ms steps(2, end) infinite;
}

.screen.state-listening .listen-wave {
  opacity: 1;
  animation: waveBlink 650ms steps(2, end) infinite;
}

.screen.state-talking .listen-indicator {
  opacity: 0.78;
}

.screen.mic-muted .listen-indicator {
  opacity: 0.24;
  filter: grayscale(1) drop-shadow(0 0 5px rgba(255, 151, 98, 0.12));
}

.screen.mic-muted .listen-indicator::before {
  content: "MUT";
  color: rgba(255, 186, 150, 0.84);
  text-shadow: 0 0 8px rgba(255, 151, 98, 0.28);
}

.screen.auth-locked .face,
.screen.auth-locked .reply-caption,
.screen.auth-locked .listen-indicator,
.screen.auth-locked .mute-toggle {
  filter: saturate(0.7) brightness(0.72);
}

.screen.auth-locked .face {
  opacity: 0.58;
}

.reply-caption {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  max-height: 28vh;
  overflow: auto;
  padding: 0 0 0 58px;
  border: 0;
  background: transparent;
  color: #b8ff9f;
  font-size: clamp(13px, 2.2vw, 17px);
  line-height: 1.45;
  letter-spacing: 0.01em;
  white-space: pre-wrap;
  text-shadow: 0 0 10px rgba(72, 255, 86, 0.42);
  box-shadow: none;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.reply-caption::before {
  content: "pxil>";
  position: absolute;
  left: 0;
  top: 0.08em;
  color: var(--green-mid);
  font-size: 0.86em;
  letter-spacing: 0.1em;
  text-shadow:
    0 0 8px rgba(139, 255, 106, 0.75),
    0 0 18px rgba(72, 255, 86, 0.35);
}

.reply-caption.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.screen.state-talking .reply-caption.is-visible {
  animation: captionGlow 760ms steps(2, end) infinite;
}

.reply-caption.is-typing::after {
  content: "_";
  display: inline-block;
  margin-left: 3px;
  color: var(--green-core);
  animation: cursorBlink 700ms steps(2, end) infinite;
}

.crt,
.crt::before,
.crt::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.crt::before {
  content: "";
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 2px,
      transparent 2px,
      transparent 6px
    );
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: scanDrift 9s linear infinite;
}

.crt::after {
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.04)),
    radial-gradient(circle at center, transparent 58%, rgba(0, 0, 0, 0.5) 100%);
  opacity: 0.8;
  animation: crtBreath 5.5s ease-in-out infinite;
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(72px, 10vh, 110px);
  transform: translateY(-7vh);
}

.eyes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(42px, 8vw, 90px);
  transform: translate3d(var(--eyes-x, 0), var(--eyes-y, 0), 0);
  transition: transform 260ms ease;
  filter: drop-shadow(0 0 22px var(--green-glow));
}

.screen.state-idle .eyes {
  animation: eyeGlowBreath 4.8s ease-in-out infinite;
}

.eye {
  display: grid;
  grid-template-columns: repeat(10, var(--pixel-size));
  grid-template-rows: repeat(10, var(--pixel-size));
  gap: var(--pixel-gap);
  padding: calc(var(--pixel-size) * 0.2);
  transform-origin: center;
  transition: transform 140ms ease;
}

.eye.pixel-blink {
  transform: scaleY(0.08);
}

.pixel {
  width: var(--pixel-size);
  height: var(--pixel-size);
  border-radius: 28%;
  background: transparent;
}

.pixel.on {
  background:
    radial-gradient(circle at 45% 35%, var(--green-core) 0 18%, #bfff98 19% 36%, var(--green-mid) 37% 100%);
  box-shadow:
    0 0 8px rgba(139, 255, 106, 0.95),
    0 0 18px var(--green-glow),
    0 0 30px var(--green-soft),
    inset 0 0 3px rgba(255, 255, 255, 0.55);
  transition: opacity 90ms steps(2, end), filter 90ms steps(2, end);
}

.mouth .pixel.on {
  animation: phosphorHold 420ms ease-out;
}

.screen.state-talking .mouth .pixel.on {
  animation: mouthPhosphor 260ms steps(2, end) infinite;
}

.mouth {
  display: grid;
  grid-template-columns: repeat(16, calc(var(--pixel-size) * 0.86));
  grid-template-rows: repeat(8, calc(var(--pixel-size) * 0.86));
  gap: calc(var(--pixel-gap) * 0.9);
  filter: drop-shadow(0 0 18px var(--green-glow));
  transition: transform 180ms ease;
}

.screen.state-talking .mouth {
  transform: translateY(3px);
}

.screen.expression-talking .eyes {
  transform: translate3d(var(--eyes-x, 0), var(--eyes-y, 0), 0);
}

.screen.state-happy .mouth {
  transform: translateY(-4px) scale(1.04);
}

.screen.expression-happy .eyes {
  transform: translate3d(var(--eyes-x, 0), var(--eyes-y, 0), 0) translateY(-2px) scaleY(0.98);
}

.screen.state-thinking .mouth {
  transform: translateX(6px);
}

.screen.expression-thinking .eyes {
  transform: translate3d(var(--eyes-x, 0), var(--eyes-y, 0), 0) scaleY(0.92);
}

.screen.expression-error .eyes {
  transform: translate3d(var(--eyes-x, 0), var(--eyes-y, 0), 0) scaleY(0.9);
  filter: drop-shadow(0 0 22px var(--green-glow));
}

.screen.expression-error .mouth {
  transform: translateY(2px) scaleX(0.96);
}

.screen.state-listening {
  background:
    radial-gradient(circle at 50% 35%, rgba(72, 255, 86, 0.15), transparent 28%),
    radial-gradient(circle at 50% 70%, rgba(72, 255, 86, 0.1), transparent 24%),
    #000;
}

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

@media (max-width: 520px) {
  .system-state {
    top: 12px;
    left: 12px;
    font-size: 11px;
  }

  .mute-toggle {
    top: 10px;
    right: 68px;
    min-width: 78px;
    padding: 7px 8px 6px;
    font-size: 10px;
  }

  .listen-indicator {
    top: 12px;
    right: 12px;
    width: 50px;
    height: 32px;
  }

  .listen-indicator::before {
    font-size: 10px;
  }

  .listen-antenna {
    left: 29px;
    top: 2px;
    width: 4px;
    height: 14px;
  }

  .listen-core {
    left: 23px;
    top: 18px;
    width: 13px;
    height: 9px;
  }

  .listen-wave-one {
    left: 13px;
    top: 13px;
  }

  .listen-wave-two {
    right: 4px;
    top: 13px;
  }

  .reply-caption {
    left: 16px;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    max-height: 32vh;
    padding: 0 0 0 52px;
    font-size: 14px;
  }

  .reply-caption::before {
    left: 0;
    top: 0.08em;
    font-size: 0.82em;
  }

  .face {
    gap: 64px;
    transform: translateY(-8vh);
  }

  .eyes {
    gap: 28px;
  }
}

@keyframes listenPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(72, 255, 86, 0.22));
  }

  50% {
    filter: drop-shadow(0 0 18px rgba(139, 255, 106, 0.55));
  }
}

@keyframes waveBlink {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.35);
  }
}

@keyframes captionGlow {
  0%,
  100% {
    text-shadow: 0 0 10px rgba(72, 255, 86, 0.42);
  }

  50% {
    text-shadow:
      0 0 12px rgba(139, 255, 106, 0.74),
      0 0 22px rgba(72, 255, 86, 0.38);
  }
}

@keyframes cursorBlink {
  0%,
  45% {
    opacity: 1;
  }

  46%,
  100% {
    opacity: 0;
  }
}

@keyframes scanDrift {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 12px;
  }
}

@keyframes crtBreath {
  0%,
  100% {
    opacity: 0.74;
  }

  50% {
    opacity: 0.86;
  }
}

@keyframes eyeGlowBreath {
  0%,
  100% {
    filter: drop-shadow(0 0 18px rgba(72, 255, 86, 0.25));
  }

  50% {
    filter: drop-shadow(0 0 28px rgba(139, 255, 106, 0.44));
  }
}

@keyframes phosphorHold {
  0% {
    filter: brightness(1.25);
  }

  100% {
    filter: brightness(1);
  }
}

@keyframes mouthPhosphor {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.24);
  }
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 18%, rgba(72, 255, 86, 0.08), transparent 28%),
    rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.auth-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-shell {
  width: min(100%, 420px);
  padding: 26px 22px 22px;
  border: 1px solid rgba(139, 255, 106, 0.38);
  background:
    linear-gradient(180deg, rgba(72, 255, 86, 0.04), rgba(72, 255, 86, 0.01)),
    rgba(0, 0, 0, 0.9);
  box-shadow:
    0 0 0 1px rgba(72, 255, 86, 0.08) inset,
    0 0 32px rgba(72, 255, 86, 0.12);
}

.auth-kicker,
.auth-title,
.auth-copy,
.auth-label,
.auth-input,
.auth-button,
.auth-link,
.auth-message {
  color: #b8ff9f;
  font-family: monospace;
  text-shadow: 0 0 10px rgba(72, 255, 86, 0.28);
}

.auth-kicker {
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(139, 255, 106, 0.72);
}

.auth-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1;
  letter-spacing: 0.14em;
}

.auth-copy {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(184, 255, 159, 0.82);
}

.auth-panel {
  display: none;
}

.auth-panel.is-visible {
  display: block;
}

.auth-label {
  display: block;
  margin: 14px 0 7px;
  font-size: 11px;
  letter-spacing: 0.14em;
}

.auth-input {
  width: 100%;
  padding: 12px 12px 11px;
  border: 1px solid rgba(139, 255, 106, 0.4);
  background: rgba(0, 0, 0, 0.76);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.auth-input:focus {
  outline: none;
  border-color: rgba(139, 255, 106, 0.8);
  box-shadow: 0 0 0 1px rgba(72, 255, 86, 0.16) inset;
}

.auth-button {
  width: 100%;
  margin-top: 18px;
  padding: 12px 14px 11px;
  border: 1px solid rgba(139, 255, 106, 0.55);
  background: rgba(72, 255, 86, 0.08);
  font-size: 13px;
  letter-spacing: 0.16em;
  cursor: pointer;
}

.auth-button:hover,
.auth-button:focus-visible,
.auth-link:hover,
.auth-link:focus-visible {
  outline: none;
  border-color: rgba(139, 255, 106, 0.82);
  color: #d6ffc9;
}

.auth-message {
  min-height: 22px;
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(184, 255, 159, 0.78);
}

.auth-bottom {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.auth-link {
  border: 0;
  background: transparent;
  font-size: 12px;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.auth-link--anchor {
  display: inline-block;
  text-decoration: none;
}

.auth-link.is-hidden {
  display: none;
}

@media (max-width: 560px) {
  .logout-toggle {
    right: 132px;
    min-width: 84px;
    padding: 7px 8px 6px;
  }

  .mute-toggle {
    right: 16px;
    min-width: 92px;
  }

  .user-badge {
    left: 18px;
    top: 42px;
    max-width: calc(100vw - 36px);
  }

  .auth-shell {
    padding: 22px 18px 18px;
  }
}
