:root {
  --bg-top: #061117;
  --bg-bottom: #071822;
  --accent: #8bf1ff;
  --accent-soft: rgba(139, 241, 255, 0.16);
  --accent-border: rgba(201, 251, 255, 0.22);
  --text: #edf8fb;
  --muted: rgba(237, 248, 251, 0.7);
  --panel: rgba(6, 18, 25, 0.88);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(101, 218, 236, 0.14), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(33, 105, 126, 0.2), transparent 42%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
}

.topbar {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 22px;
}

.fps-counter {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 2;
  padding: 10px 14px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.46);
  color: rgba(237, 248, 251, 0.78);
  backdrop-filter: blur(18px);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.voice-access {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.46);
  color: rgba(237, 248, 251, 0.82);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.voice-access.hidden {
  display: none;
}

.voice-access-label,
.voice-access-timer,
.voice-access-status {
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.voice-access-timer {
  color: rgba(139, 241, 255, 0.94);
}

.voice-access-status {
  color: rgba(237, 248, 251, 0.64);
}

.avatar-debug-chip {
  position: absolute;
  top: 62px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(540px, calc(100vw - 44px));
  padding: 8px 12px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.42);
  color: rgba(237, 248, 251, 0.82);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.avatar-debug-chip.hidden {
  display: none;
}

.avatar-debug-label,
.avatar-debug-value {
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.avatar-debug-value {
  color: rgba(139, 241, 255, 0.94);
  text-transform: none;
}

.debug-panel {
  position: absolute;
  top: 96px;
  right: 22px;
  z-index: 2;
  width: min(320px, calc(100vw - 44px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 18px;
  background: rgba(8, 24, 32, 0.46);
  backdrop-filter: blur(18px);
}

.debug-panel.memory-only {
  top: 88px;
  width: min(280px, calc(100vw - 44px));
}

.debug-panel.memory-only .debug-section-full {
  display: none;
}

.debug-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.debug-text {
  color: rgba(237, 248, 251, 0.76);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.debug-transcript {
  max-height: 188px;
  overflow: auto;
  padding-right: 4px;
}

.debug-divider {
  height: 1px;
  margin: 4px 0 2px;
  background: rgba(201, 251, 255, 0.1);
}

.unsupported-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(139, 241, 255, 0.08), transparent 34%),
    rgba(3, 10, 14, 0.74);
  backdrop-filter: blur(18px);
}

.unsupported-card {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(139, 241, 255, 0.08), transparent 34%),
    rgba(8, 24, 32, 0.88);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.unsupported-kicker {
  margin: 0 0 8px;
  color: rgba(139, 241, 255, 0.82);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.unsupported-title {
  margin: 0;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.unsupported-text,
.unsupported-help {
  margin: 10px 0 0;
  color: rgba(237, 248, 251, 0.76);
  line-height: 1.5;
}

.unsupported-help {
  color: var(--muted);
}

.site-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 22px;
  pointer-events: none;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  pointer-events: auto;
}

.site-footer-link {
  padding: 10px 14px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.46);
  color: rgba(237, 248, 251, 0.78);
  text-decoration: none;
  backdrop-filter: blur(18px);
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease;
}

.site-footer-link:hover,
.site-footer-link:focus-visible {
  border-color: rgba(139, 241, 255, 0.34);
  background: rgba(11, 32, 42, 0.68);
  color: var(--text);
}

.panel-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.46);
  color: rgba(237, 248, 251, 0.82);
  backdrop-filter: blur(18px);
}

.panel-toggle-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.controls-panel.is-hidden {
  width: auto;
  min-width: 0;
  padding: 12px;
}

.controls-panel.is-hidden > :not(.controls-panel-header) {
  display: none;
}

.auth-button,
.panel-button,
.mic-button,
.landing-audio-button,
.about-button {
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: rgba(8, 24, 32, 0.7);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.auth-button {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(18px);
}

.landing-audio-button {
  min-width: 124px;
  height: 54px;
  padding: 0 18px;
  backdrop-filter: blur(18px);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about-button {
  height: 54px;
  padding: 0 18px;
  backdrop-filter: blur(18px);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-audio-button.is-playing {
  border-color: rgba(139, 241, 255, 0.54);
  background: rgba(18, 60, 71, 0.84);
  box-shadow: 0 0 38px rgba(78, 217, 244, 0.18);
}

.landing-audio-button.is-attention {
  animation: landing-audio-attention 1.45s ease-in-out infinite;
}

.landing-audio-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  animation: none;
}

.auth-button:hover,
.panel-button:hover,
.mic-button:hover,
.landing-audio-button:hover,
.about-button:hover {
  transform: translateY(-1px);
}

@keyframes landing-audio-attention {
  0%,
  100% {
    border-color: rgba(201, 251, 255, 0.22);
    background: rgba(8, 24, 32, 0.7);
    box-shadow: 0 0 0 rgba(78, 217, 244, 0);
  }
  50% {
    border-color: rgba(139, 241, 255, 0.72);
    background: rgba(18, 60, 71, 0.88);
    box-shadow:
      0 0 0 1px rgba(139, 241, 255, 0.18),
      0 0 28px rgba(78, 217, 244, 0.26);
  }
}

.auth-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.auth-button.is-signed-in {
  border-color: rgba(109, 241, 188, 0.52);
  box-shadow: 0 0 30px rgba(109, 241, 188, 0.12);
}

.auth-button.is-unavailable {
  border-color: rgba(255, 122, 122, 0.34);
  color: rgba(255, 210, 210, 0.82);
}

.mic-button {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 2;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(18px);
}

.mic-button::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  border: 1px solid rgba(201, 251, 255, 0.08);
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.mic-button.is-live {
  border-color: rgba(139, 241, 255, 0.54);
  background: rgba(18, 60, 71, 0.84);
  box-shadow: 0 0 38px rgba(78, 217, 244, 0.18);
}

.mic-button.is-live::after {
  opacity: 1;
  transform: scale(1);
}

.mic-button.is-busy {
  cursor: progress;
  opacity: 0.82;
}

.mic-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.mic-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.remote-audio-debug {
  position: absolute;
  right: 22px;
  bottom: 88px;
  z-index: 2;
  width: min(280px, calc(100vw - 44px));
  opacity: 0.9;
}

.controls-panel {
  position: absolute;
  left: 22px;
  bottom: 22px;
  z-index: 2;
  width: min(320px, calc(100vw - 44px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 22px;
  background: rgba(8, 24, 32, 0.5);
  backdrop-filter: blur(18px);
}

.controls-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.controls-panel-title {
  color: rgba(237, 248, 251, 0.8);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls-panel.is-hidden .controls-panel-title {
  display: none;
}

.editor-section {
  border: 1px solid rgba(201, 251, 255, 0.08);
  border-radius: 16px;
  background: rgba(5, 16, 23, 0.34);
  overflow: hidden;
}

.editor-section[open] {
  background: rgba(6, 19, 26, 0.42);
}

.editor-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.editor-section-summary::-webkit-details-marker {
  display: none;
}

.editor-section-title {
  color: rgba(237, 248, 251, 0.9);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-section-icon {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-right: 1px solid rgba(237, 248, 251, 0.72);
  border-bottom: 1px solid rgba(237, 248, 251, 0.72);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 180ms ease;
}

.editor-section[open] .editor-section-icon {
  transform: rotate(225deg) translateY(-1px);
}

.editor-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 14px;
}

.studio-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio-panel.hidden {
  display: none;
}

.studio-input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 14px;
  background: rgba(6, 18, 25, 0.96);
  color: var(--text);
}

.studio-input::placeholder {
  color: rgba(237, 248, 251, 0.44);
}

.studio-status {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.4;
}

.control-row {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.mode-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meter-row {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.control-label,
.control-value {
  color: rgba(237, 248, 251, 0.76);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.control-value {
  text-align: right;
}

.control-input {
  width: 100%;
  accent-color: #8bf1ff;
}

.device-select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 12px;
  background: rgba(6, 18, 25, 0.96);
  color: var(--text);
}

.meter-track {
  position: relative;
  height: 10px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 999px;
  background: rgba(6, 18, 25, 0.96);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(95, 220, 255, 0.82), rgba(248, 226, 255, 0.92));
  box-shadow: 0 0 18px rgba(95, 220, 255, 0.24);
}

.audio-viz {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(201, 251, 255, 0.1);
}

.viz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.waveform-canvas {
  width: 100%;
  height: 84px;
  display: block;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(4, 15, 21, 0.92), rgba(7, 22, 31, 0.96)),
    radial-gradient(circle at 50% 50%, rgba(53, 157, 219, 0.12), transparent 58%);
}

.feature-row {
  display: grid;
  grid-template-columns: 42px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.feature-label {
  color: rgba(237, 248, 251, 0.72);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.feature-track {
  position: relative;
  height: 8px;
  border: 1px solid rgba(201, 251, 255, 0.12);
  border-radius: 999px;
  background: rgba(6, 18, 25, 0.94);
  overflow: hidden;
}

.feature-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(26, 111, 255, 0.86), rgba(99, 244, 255, 0.9));
  box-shadow: 0 0 16px rgba(46, 169, 255, 0.22);
}

.tts-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(201, 251, 255, 0.1);
}

.tts-input {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 16px;
  background: rgba(6, 18, 25, 0.96);
  color: var(--text);
  line-height: 1.45;
}

.tts-input::placeholder {
  color: rgba(237, 248, 251, 0.44);
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  min-height: 100vh;
}

.scene-shell {
  position: absolute;
  inset: 0;
}

.scene-root {
  position: absolute;
  inset: 0;
}

.scene-root canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 4;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 10, 14, 0.56);
  backdrop-filter: blur(12px);
}

.auth-panel {
  position: absolute;
  top: 82px;
  right: 22px;
  width: min(420px, calc(100vw - 28px));
  padding: 18px;
  border: 1px solid var(--accent-border);
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(139, 241, 255, 0.08), transparent 34%),
    var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-panel-header {
  margin-bottom: 14px;
}

.auth-kicker {
  margin: 0 0 8px;
  color: rgba(139, 241, 255, 0.82);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-button {
  width: 100%;
  padding: 13px 16px;
}

.panel-button.subtle {
  color: var(--muted);
}

.email-auth {
  display: flex;
  gap: 10px;
}

.email-auth .panel-button {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

.email-input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(201, 251, 255, 0.14);
  border-radius: 18px;
  background: rgba(6, 18, 25, 0.96);
  color: var(--text);
}

.email-input::placeholder {
  color: rgba(237, 248, 251, 0.44);
}

.auth-status {
  min-height: 1.4em;
  margin: 12px 4px 0;
  color: var(--muted);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.profile-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.about-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(520px, calc(100vw - 28px));
}

.about-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-section {
  padding: 14px 15px;
  border: 1px solid rgba(201, 251, 255, 0.1);
  border-radius: 18px;
  background: rgba(5, 16, 23, 0.34);
}

.about-heading {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.about-copy {
  margin: 0;
  color: rgba(237, 248, 251, 0.74);
  line-height: 1.55;
}

.profile-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-name-row {
  grid-template-columns: 52px 1fr auto;
}

.profile-save-button {
  width: auto;
  padding-inline: 14px;
}

.profile-status {
  margin: 0;
}

.profile-section #profile-billing-button {
  width: auto;
  align-self: flex-start;
}

.profile-memories {
  max-height: min(48vh, 420px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.profile-memory-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(201, 251, 255, 0.1);
  border-radius: 16px;
  background: rgba(5, 16, 23, 0.34);
}

.profile-memory-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-memory-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-memory-summary {
  min-height: 76px;
  resize: vertical;
}

.profile-memory-actions {
  display: flex;
  gap: 10px;
}

.profile-memory-actions .panel-button {
  width: auto;
  padding: 10px 14px;
}

.hidden {
  display: none;
}

.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: 720px) {
  .topbar {
    padding: 16px;
  }

  .site-footer {
    padding: 16px;
  }

  .site-footer-link {
    padding: 9px 12px;
    font-size: 0.88rem;
  }

  .auth-button {
    width: 50px;
    height: 50px;
  }

  .landing-audio-button {
    min-width: 112px;
    height: 50px;
    padding: 0 16px;
  }

  .about-button {
    height: 50px;
    padding: 0 16px;
  }

  .fps-counter {
    top: 16px;
    left: 16px;
  }

  .voice-access {
    top: 16px;
    max-width: calc(100vw - 120px);
    gap: 8px;
    padding: 9px 12px;
  }

  .debug-panel {
    top: 88px;
  }

  .auth-panel {
    top: 72px;
    right: 14px;
  }

  .controls-panel {
    left: 16px;
    bottom: 16px;
    width: min(280px, calc(100vw - 86px));
  }

  .mic-button {
    right: 16px;
    bottom: 16px;
  }

  .remote-audio-debug {
    right: 16px;
    bottom: 80px;
    width: min(280px, calc(100vw - 32px));
  }

  .email-auth {
    flex-direction: column;
  }

  .profile-name-row {
    grid-template-columns: 1fr;
  }

  .profile-memory-actions {
    flex-direction: column;
  }
}
