:root {
  color-scheme: dark;
  --bg: #050609;
  --bg-2: #090d12;
  --ink: #f7f7f4;
  --muted: #9aa4ae;
  --muted-2: #707b87;
  --line: rgba(255, 255, 255, 0.1);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.11);
  --cyan: #9de8ff;
  --cyan-soft: rgba(157, 232, 255, 0.28);
  --green: #10a37f;
  --green-soft: rgba(16, 163, 127, 0.32);
  --red: #ff4f5e;
  --amber: #f2b84b;
  --voice-level: 0;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-fast: cubic-bezier(0.25, 1, 0.5, 1);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at 50% 9%, rgba(157, 232, 255, 0.14), transparent 25%),
    radial-gradient(circle at 50% 52%, rgba(157, 232, 255, 0.08), transparent 31%),
    radial-gradient(circle at 16% 82%, rgba(16, 163, 127, 0.06), transparent 30%),
    linear-gradient(180deg, #0c1117 0%, var(--bg) 58%, #030405 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.call {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.call-screen {
  width: min(100%, 430px);
  height: min(860px, calc(100dvh - 28px));
  min-height: 620px;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 188px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 43%, rgba(157, 232, 255, 0.13), transparent 36%),
    linear-gradient(180deg, rgba(17, 22, 29, 0.96), rgba(5, 6, 9, 0.98));
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52);
}

.call-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
  opacity: 0.42;
}

.call-screen::after {
  content: "";
  position: absolute;
  inset: auto -20% -28% -20%;
  height: 46%;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(157, 232, 255, 0.1), transparent 62%);
  pointer-events: none;
}

.call-header {
  padding: 30px 24px 8px;
  text-align: center;
}

.status-line {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 620;
  letter-spacing: 0;
}

.stage {
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 8px 28px 0;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(72vw, 330px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(157, 232, 255, 0.12);
  pointer-events: none;
}

.stage::after {
  width: min(56vw, 248px);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 60px rgba(157, 232, 255, 0.05);
}

.camera-preview {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  background: #05070a;
  filter: saturate(0.94) contrast(1.05);
  opacity: 0.78;
}

.camera-preview[hidden] {
  display: none;
}

.call-screen.video-on::before {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 46%, rgba(157, 232, 255, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.56), rgba(0, 0, 0, 0.18) 34%, rgba(0, 0, 0, 0.7)),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: auto, auto, 42px 42px, 42px 42px;
  mask-image: none;
  opacity: 1;
}

.call-screen.video-on .call-header,
.call-screen.video-on .call-actions {
  position: relative;
  z-index: 5;
}

.call-screen.video-on .stage {
  position: relative;
  z-index: 2;
}

.call-screen.video-on .camera-preview {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  filter: saturate(0.9) contrast(1.08) brightness(0.9);
  animation: cameraReveal 320ms var(--ease-out) both;
}

.call-screen.video-on .wave {
  position: relative;
  z-index: 3;
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.call-screen.video-on .stage::before,
.call-screen.video-on .stage::after {
  opacity: 0;
}

.call-screen.video-on .caption {
  position: relative;
  z-index: 3;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.52);
}

.call-screen.video-on .status-line {
  color: rgba(232, 241, 247, 0.78);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.62);
}

.call-screen.video-on h1 {
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.6);
}

.call-screen.video-on .call-actions::before {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(4, 7, 10, 0.2), rgba(0, 0, 0, 0.28));
  border-color: rgba(255, 255, 255, 0.12);
}

.wave {
  width: min(74vw, 328px);
  aspect-ratio: 1;
  align-self: center;
  position: relative;
  display: grid;
  place-items: center;
  opacity: 0.94;
  transition: opacity 180ms ease, transform 220ms ease;
}

.wave::before,
.wave::after {
  content: "";
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  border: 1px solid rgba(157, 232, 255, 0.2);
  background:
    radial-gradient(circle at 50% 50%, rgba(157, 232, 255, 0.08), rgba(157, 232, 255, 0.025) 45%, transparent 72%);
  box-shadow:
    0 0 52px rgba(157, 232, 255, 0.11),
    inset 0 0 42px rgba(255, 255, 255, 0.035);
  transform: scale(calc(1 + var(--voice-level) * 0.12));
}

.wave::after {
  inset: 43%;
  border-color: rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle, rgba(247, 247, 244, 0.08), rgba(157, 232, 255, 0.018) 58%, transparent 72%);
  transform: scale(calc(0.92 + var(--voice-level) * 0.18));
}

.wave span {
  position: absolute;
  width: calc(44% + var(--voice-level) * 7%);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(157, 232, 255, 0.16);
  box-shadow: 0 0 30px rgba(157, 232, 255, 0.06);
  transform: rotate(calc(var(--i, 0) * 28deg)) scale(calc(0.9 + var(--voice-level) * 0.16));
  animation: fieldDrift 6.4s ease-in-out infinite;
}

.wave span:nth-child(1) {
  --i: 1;
}

.wave span:nth-child(2) {
  --i: 2;
  width: 56%;
  animation-delay: -1.4s;
}

.wave span:nth-child(3) {
  --i: 3;
  width: 70%;
  border-color: rgba(255, 255, 255, 0.11);
  animation-delay: -2.7s;
}

.wave span:nth-child(4) {
  --i: 4;
  width: 84%;
  animation-delay: -3.9s;
}

.wave span:nth-child(5) {
  --i: 5;
  width: 96%;
  border-color: rgba(157, 232, 255, 0.1);
  animation-delay: -5.2s;
}

.caption {
  width: min(100%, 340px);
  min-height: 76px;
  margin: 0;
  color: rgba(247, 247, 244, 0.88);
  font-size: 16px;
  line-height: 1.42;
  text-align: center;
  overflow-wrap: anywhere;
  display: grid;
  place-items: start center;
  text-wrap: balance;
}

.call-actions {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 58px 132px 58px;
  gap: 28px;
  place-items: center;
  justify-content: center;
  align-content: center;
  min-height: 188px;
  padding: 0 18px calc(22px + env(safe-area-inset-bottom));
}

.call-actions::before {
  content: "";
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: calc(26px + env(safe-area-inset-bottom));
  height: 72px;
  border: 1px solid rgba(157, 232, 255, 0.08);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(157, 232, 255, 0.035), rgba(9, 12, 16, 0.18), rgba(157, 232, 255, 0.035));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 16px 48px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(18px);
}

.orb {
  width: 132px;
  aspect-ratio: 1;
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 48%, rgba(247, 247, 244, 0.92), rgba(176, 195, 205, 0.44) 18%, rgba(57, 75, 84, 0.2) 48%, rgba(157, 232, 255, 0.1) 72%, rgba(255, 255, 255, 0.02));
  box-shadow:
    inset 0 0 24px rgba(255, 255, 255, 0.32),
    inset 0 0 52px rgba(157, 232, 255, 0.08),
    0 0 58px rgba(157, 232, 255, 0.1),
    0 18px 54px rgba(0, 0, 0, 0.38);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease, opacity 180ms ease;
  pointer-events: none;
}

.orb::before,
.orb::after {
  content: "";
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  border: 1px solid rgba(157, 232, 255, 0.12);
  opacity: 0.42;
}

.orb::after {
  inset: -18%;
  border-color: rgba(255, 255, 255, 0.06);
}

.orb span,
.orb i {
  position: absolute;
  border-radius: 50%;
}

.orb span {
  inset: 17%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  animation: breathe 4.2s ease-in-out infinite;
}

.orb span:nth-child(2) {
  inset: 30%;
  border-color: rgba(157, 232, 255, 0.22);
  animation-delay: -1.3s;
}

.orb span:nth-child(3) {
  inset: 43%;
  background: rgba(255, 255, 255, 0.48);
  animation-delay: -2.4s;
}

.orb i {
  inset: 47%;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.46);
}

.round {
  border: 0;
  cursor: pointer;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  position: relative;
  z-index: 5;
  display: grid;
  place-items: center;
  color: var(--ink);
  overflow: hidden;
  transition:
    transform 140ms var(--ease-fast),
    background 180ms var(--ease-out),
    opacity 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    filter 180ms var(--ease-out);
  backdrop-filter: blur(14px);
}

.round::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.32), transparent 62%);
  opacity: 0;
  transform: scale(0.58);
  transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-out);
}

.round:active {
  transform: scale(0.95);
}

.round:active::after {
  opacity: 0.5;
  transform: scale(1);
  transition-duration: 80ms;
}

.round:focus-visible {
  outline: 2px solid rgba(157, 232, 255, 0.78);
  outline-offset: 4px;
}

@media (hover: hover) {
  .round:not(.primary):hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
  }

  .round:not(.primary):active {
    transform: translateY(0) scale(0.95);
  }
}

.secondary {
  grid-column: 1;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.secondary.active {
  background: rgba(157, 232, 255, 0.18);
  border-color: rgba(157, 232, 255, 0.42);
  box-shadow:
    0 0 0 7px rgba(157, 232, 255, 0.035),
    0 0 24px rgba(157, 232, 255, 0.2);
}

.primary {
  position: absolute;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 132px;
  height: 132px;
  background: transparent;
  color: transparent;
  box-shadow: none;
  border: 0;
  overflow: visible;
}

.primary:active {
  transform: translateX(-50%) scale(0.97);
}

.primary::before,
.primary::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.primary::before {
  border: 1px solid rgba(157, 232, 255, 0.22);
  transform: scale(0.84);
  transition: opacity 180ms var(--ease-out), transform 220ms var(--ease-out);
}

.primary::after {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 64%);
  transform: scale(0.7);
  transition: opacity 150ms var(--ease-out), transform 180ms var(--ease-out);
}

.primary:active::before,
.primary:active::after {
  opacity: 1;
  transform: scale(1.08);
}

.primary.listening,
.primary.busy {
  background: transparent;
  box-shadow: none;
}

.video svg {
  width: 25px;
  height: 25px;
  display: block;
  fill: none;
  stroke: #fff;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms var(--ease-out), stroke 180ms var(--ease-out);
}

.video.active svg {
  transform: scale(0.92);
  stroke: #fff;
}

.end {
  grid-column: 3;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.12), transparent 34%),
    rgba(255, 255, 255, 0.072);
  border: 1px solid rgba(255, 126, 138, 0.28);
  box-shadow:
    0 0 0 7px rgba(255, 126, 138, 0.025),
    0 0 22px rgba(255, 126, 138, 0.12);
}

.end:not([hidden]) {
  animation: controlReveal 220ms var(--ease-out) both;
}

.end[hidden] {
  display: grid;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.end span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  background: #ff8c98;
  box-shadow: 0 0 18px rgba(255, 126, 138, 0.32);
}

.call-screen.listening .status-dot,
.call-screen.video-on .status-dot {
  background: var(--green);
  box-shadow: 0 0 18px rgba(16, 163, 127, 0.78);
}

.call-screen.listening .wave span {
  border-color: rgba(157, 232, 255, 0.22);
  animation-duration: 3.1s;
}

.call-screen.listening .orb {
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.38),
    0 0 78px rgba(157, 232, 255, 0.23),
    0 18px 54px rgba(0, 0, 0, 0.38);
}

.call-screen.listening .orb::before,
.call-screen.listening .orb::after {
  animation: pulseRing 1.75s ease-out infinite;
}

.call-screen.listening .orb::after {
  animation-delay: 0.58s;
}

.call-screen.thinking .status-dot {
  background: var(--amber);
  box-shadow: 0 0 18px rgba(242, 184, 75, 0.7);
}

.call-screen.thinking .wave {
  animation: slowSpin 8.5s linear infinite;
}

.call-screen.thinking .orb {
  filter: saturate(1.18);
  animation: focusGlow 2.4s ease-in-out infinite;
}

.call-screen.speaking .status-dot {
  background: var(--cyan);
  box-shadow: 0 0 20px rgba(157, 232, 255, 0.72);
}

.call-screen.speaking .wave span {
  animation: talkField 1.08s ease-in-out infinite;
}

.call-screen.speaking .wave span:nth-child(2) {
  animation-delay: -0.18s;
}

.call-screen.speaking .wave span:nth-child(3) {
  animation-delay: -0.34s;
}

.call-screen.speaking .wave span:nth-child(4) {
  animation-delay: -0.51s;
}

.call-screen.speaking .wave span:nth-child(5) {
  animation-delay: -0.67s;
}

.call-screen.speaking .orb span {
  animation-duration: 1.18s;
}

@media (max-width: 520px) {
  .call {
    padding: 0;
  }

  .call-screen {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}

@media (max-height: 720px) {
  .call-screen {
    grid-template-rows: auto minmax(0, 1fr) 164px;
  }

  .call-header {
    padding-top: 18px;
  }

  h1 {
    font-size: 25px;
  }

  .stage {
    gap: 10px;
    padding-bottom: 0;
  }

  .wave {
    width: min(66vw, 264px);
  }

  .caption {
    min-height: 58px;
    font-size: 14px;
  }

  .call-actions {
    min-height: 164px;
    grid-template-columns: 52px 114px 52px;
    gap: 24px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .call-actions::before {
    left: 28px;
    right: 28px;
    height: 66px;
    bottom: calc(26px + env(safe-area-inset-bottom));
  }

  .orb,
  .primary {
    width: 114px;
    height: 114px;
    bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .round {
    width: 50px;
    height: 50px;
  }

  .primary {
    width: 114px;
    height: 114px;
  }
}

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

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.48;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

@keyframes fieldDrift {
  0%,
  100% {
    transform: rotate(calc(var(--i, 0) * 28deg)) scale(0.92);
    opacity: 0.46;
  }
  50% {
    transform: rotate(calc(var(--i, 0) * 28deg + 18deg)) scale(1.04);
    opacity: 0.88;
  }
}

@keyframes pulseRing {
  0% {
    transform: scale(0.92);
    opacity: 0.38;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@keyframes cameraReveal {
  from {
    opacity: 0;
    filter: saturate(0.8) contrast(1) brightness(0.72) blur(10px);
    transform: scale(1.035);
  }
  to {
    opacity: 1;
    filter: saturate(0.9) contrast(1.08) brightness(0.9) blur(0);
    transform: scale(1);
  }
}

@keyframes controlReveal {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slowSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes focusGlow {
  0%,
  100% {
    box-shadow:
      inset 0 0 28px rgba(255, 255, 255, 0.32),
      0 0 58px rgba(242, 184, 75, 0.1),
      0 18px 54px rgba(0, 0, 0, 0.38);
  }
  50% {
    box-shadow:
      inset 0 0 30px rgba(255, 255, 255, 0.42),
      0 0 84px rgba(242, 184, 75, 0.18),
      0 18px 54px rgba(0, 0, 0, 0.38);
  }
}

@keyframes talkField {
  0%,
  100% {
    transform: rotate(calc(var(--i, 0) * 28deg)) scale(0.94);
    opacity: 0.46;
  }
  45% {
    transform: rotate(calc(var(--i, 0) * 28deg + 9deg)) scale(calc(1.02 + var(--voice-level) * 0.18));
    opacity: 1;
  }
}
