:root {
  color-scheme: dark;
  --bg: #041226;
  --ink: #f7fbff;
  --muted: #d5e4f2;
  --line: rgba(255, 255, 255, 0.28);
  --danger: #ffb4a8;
  --glass: rgba(255, 255, 255, 0.14);
  --glass-strong: rgba(255, 255, 255, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

button, input { font: inherit; color: inherit; }

button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.lava {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 100%, #06315f 0%, #03101f 55%, #020814 100%);
  perspective: 900px;
}

.blob {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.9;
  mix-blend-mode: screen;
  will-change: transform, border-radius;
}

.b1 {
  width: 46vw;
  height: 46vw;
  left: -8vw;
  top: 8vh;
  background: #2f7dff;
  animation: lava-a 22s ease-in-out infinite;
}

.b2 {
  width: 38vw;
  height: 42vw;
  right: -6vw;
  top: 18vh;
  background: #49d4ff;
  animation: lava-b 26s ease-in-out infinite;
}

.b3 {
  width: 34vw;
  height: 34vw;
  left: 28vw;
  bottom: -8vh;
  background: #1746c9;
  animation: lava-c 19s ease-in-out infinite;
}

.b4 {
  width: 22vw;
  height: 28vw;
  right: 18vw;
  bottom: 12vh;
  background: #8ae7ff;
  filter: blur(36px);
  animation: lava-d 16s ease-in-out infinite;
}

.b5 {
  width: 28vw;
  height: 24vw;
  left: 12vw;
  top: 42vh;
  background: #0a2f86;
  filter: blur(60px);
  animation: lava-e 28s ease-in-out infinite;
}

.lava-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 60% at 50% 40%, transparent 0%, rgba(2, 8, 20, 0.28) 100%);
  pointer-events: none;
}

@keyframes lava-a {
  0%, 100% { transform: translate3d(0, 0, 40px) scale(1); border-radius: 48% 52% 46% 54%; }
  50% { transform: translate3d(18vw, 16vh, 80px) scale(1.15); border-radius: 60% 40% 55% 45%; }
}

@keyframes lava-b {
  0%, 100% { transform: translate3d(0, 0, 20px) scale(1); border-radius: 55% 45% 50% 50%; }
  50% { transform: translate3d(-16vw, 10vh, 90px) scale(1.2); border-radius: 40% 60% 42% 58%; }
}

@keyframes lava-c {
  0%, 100% { transform: translate3d(0, 0, 10px) scale(1.05); border-radius: 50%; }
  50% { transform: translate3d(8vw, -18vh, 60px) scale(0.9); border-radius: 62% 38% 58% 42%; }
}

@keyframes lava-d {
  0%, 100% { transform: translate3d(0, 0, 120px) scale(1); border-radius: 46% 54% 60% 40%; }
  50% { transform: translate3d(-10vw, -12vh, 140px) scale(1.25); border-radius: 58% 42% 40% 60%; }
}

@keyframes lava-e {
  0%, 100% { transform: translate3d(0, 0, -40px) scale(1); }
  50% { transform: translate3d(14vw, -8vh, 30px) scale(1.3); }
}

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: fit-content;
  max-width: calc(100% - 2rem);
  margin: 1rem 1rem 0;
  padding: 0.7rem 1.15rem 0.7rem 0.7rem;
  border-radius: 32px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 16px 40px rgba(0, 20, 50, 0.2);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
}

.logo {
  width: 104px;
  height: 104px;
  padding: 10px;
  object-fit: contain;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.who { min-width: 0; }

.name {
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.position {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.25;
}

.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2.5rem 8vw 8.5rem;
  overflow: hidden;
}

.glow {
  position: absolute;
  width: min(70vw, 640px);
  height: min(40vw, 360px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.07), transparent 68%);
  filter: blur(8px);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

body.is-thinking .glow,
body.is-speaking .glow {
  opacity: 1;
  transform: scale(1);
}

body.is-thinking .glow {
  animation: glow-breathe 1.8s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.55; }
  50% { transform: scale(1.06); opacity: 1; }
}

.hint {
  position: relative;
  z-index: 1;
  max-width: 16em;
  margin: 0;
  padding: 1.15rem 1.5rem;
  border-radius: 30px;
  font-size: clamp(1.45rem, 2.6vw, 2.05rem);
  line-height: 1.3;
  color: #fff;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 24px 50px rgba(0, 24, 60, 0.22);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
}

.hint.is-in { animation: answer-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both; }
.hint.is-out { animation: line-out 0.4s ease both; pointer-events: none; }

.question {
  position: relative;
  z-index: 1;
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2.7rem, 7vw, 6.4rem);
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.98;
  min-height: 0;
}

.question .word {
  display: inline-block;
  white-space: pre;
  animation: word-in 0.72s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.question.is-live {
  animation: live-in 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.question.is-leaving .word,
.question.is-leaving {
  animation: line-out 0.38s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes word-in {
  from { opacity: 0; transform: translateY(0.42em); filter: blur(14px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes live-in {
  from { opacity: 0; filter: blur(10px); }
  to { opacity: 1; filter: none; }
}

@keyframes line-out {
  to { opacity: 0; transform: translateY(-0.35em); filter: blur(16px); }
}

.loader {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.45rem;
  height: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transition: height 0.35s ease, opacity 0.35s ease, margin 0.35s ease;
}

.loader i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(6px) scale(0.6);
  opacity: 0.25;
}

.loader.is-on {
  height: 18px;
  margin: 1.4rem 0 0.2rem;
  opacity: 1;
}

.loader.is-on i {
  animation: dot 1s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.loader.is-on i:nth-child(2) { animation-delay: 0.12s; }
.loader.is-on i:nth-child(3) { animation-delay: 0.24s; }

@keyframes dot {
  0%, 100% { transform: translateY(4px) scale(0.7); opacity: 0.25; }
  40% { transform: translateY(-3px) scale(1); opacity: 1; }
}

.answer {
  position: relative;
  z-index: 1;
  max-width: 42rem;
  margin: 1.15rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  line-height: 1.45;
  font-weight: 450;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(8px);
}

.answer.is-in {
  animation: answer-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.answer.is-leaving {
  animation: line-out 0.34s ease both;
}

.question:empty,
.answer:empty {
  display: none;
}

@keyframes answer-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(10px); }
  to { opacity: 1; transform: none; filter: none; }
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.35rem;
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
}

.mic {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.45);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 16px 40px rgba(0, 30, 70, 0.28);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.mic svg { width: 34px; height: 34px; }

.mic.is-on {
  background: rgba(255, 255, 255, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 0 0 10px rgba(140, 210, 255, 0.12), 0 0 40px rgba(80, 180, 255, 0.35);
  animation: mic-listen 1.8s ease-in-out infinite;
}

.mic.is-thinking {
  background: transparent;
  color: #f4f1ea;
  box-shadow: none;
  animation: none;
}

.mic.is-thinking::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1.5px solid rgba(244, 241, 234, 0.18);
  border-top-color: #f4f1ea;
  animation: mic-spin 0.9s linear infinite;
}

.mic.is-speaking {
  animation: mic-speak 0.7s ease-in-out infinite;
}

.mic:active { transform: scale(0.96); }

@keyframes mic-listen {
  0%, 100% { box-shadow: 0 0 0 8px rgba(244, 241, 234, 0.06), 0 0 36px rgba(244, 241, 234, 0.16); }
  50% { box-shadow: 0 0 0 16px rgba(244, 241, 234, 0.03), 0 0 56px rgba(244, 241, 234, 0.28); }
}

@keyframes mic-spin {
  to { transform: rotate(360deg); }
}

@keyframes mic-speak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.key {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  display: grid;
  place-items: center;
}

.key svg { width: 20px; height: 20px; }

.key.is-open {
  background: rgba(255, 255, 255, 0.72);
  color: #102033;
}

.keys {
  position: fixed;
  left: 50%;
  bottom: 8rem;
  z-index: 6;
  width: min(640px, calc(100% - 2rem));
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.45s;
}

.keys.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

#composerInput {
  width: 100%;
  padding: 0.95rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 24, 48, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  outline: none;
  font-size: 1.15rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 8.4rem;
  z-index: 7;
  transform: translateX(-50%) translateY(8px);
  max-width: min(520px, calc(100% - 2rem));
  margin: 0;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(40, 16, 14, 0.92);
  color: var(--danger);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sheet {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100% - 2rem));
  max-height: calc(100% - 8rem);
  overflow: auto;
  padding: 1rem 1rem 1.2rem;
  border-radius: 28px;
  background: rgba(10, 28, 52, 0.42);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 30px 80px rgba(0, 10, 30, 0.35);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  transform: translate(-50%, -46%) scale(0.98);
  animation: sheet-in 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translate(-50%, -42%) scale(0.96); filter: blur(8px); }
  to { opacity: 1; transform: translate(-50%, -46%) scale(1); filter: none; }
}

.sheet-head, .sheet-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.sheet-close, .quiet {
  color: var(--muted);
  font-size: 0.85rem;
}

.sheet img, .sheet video, #appFrame, .demo-cam {
  width: 100%;
  margin-top: 0.8rem;
  border-radius: 14px;
  background: #000;
}

#appFrame { height: min(62vh, 560px); border: 0; }

#phoneInput {
  width: 100%;
  margin: 0.45rem 0 0.8rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.2rem;
}

.sheet button[type="submit"], #photoShutter, .file-label {
  border-radius: 999px;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.82);
  color: #102033;
}

.file-label input { display: none; }
.form-error { color: var(--danger); min-height: 1.2rem; font-size: 0.85rem; }

.debug-toggle {
  position: fixed;
  left: 0.7rem;
  bottom: 0.7rem;
  z-index: 30;
  width: 28px;
  height: 22px;
  padding: 0;
  color: rgba(255, 255, 255, 0.28);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.debug-toggle.has-alert { color: var(--danger); }

.debug {
  position: fixed;
  left: 0.7rem;
  bottom: 7.2rem;
  z-index: 30;
  width: min(380px, calc(100% - 1.4rem));
  max-height: min(62vh, 520px);
  overflow: auto;
  padding: 0.8rem;
  border-radius: 16px;
  background: rgba(8, 22, 44, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 18px 50px rgba(0, 10, 30, 0.35);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  font-size: 0.75rem;
  animation: menu-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.debug-row, .debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.debug-actions { margin-top: 0.6rem; }

.debug-actions button {
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.75rem;
}

.debug-error { color: var(--danger); min-height: 0; }
.debug-note { color: #d7b15a; min-height: 0; }

.history {
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.history li { margin: 0.28rem 0; }
.history b { color: var(--ink); font-weight: 600; }

.log {
  margin: 0.7rem 0 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  color: #d5ddd4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
}

.hidden { display: none !important; }
