* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --blue: #0071e3;
  --blue-2: #0a84ff;
  --orange: #ff7a00;
  --text: #111827;
  --muted: #60636f;
  --line: #e2e4ea;
  --panel: #ffffff;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  color: var(--text);
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.page {
  width: min(430px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}

.experience {
  display: grid;
  min-height: 100%;
}

.stage {
  width: 100%;
  min-height: calc(100vh - 20px);
  min-height: calc(100dvh - 20px);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 20px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .06);
  text-align: center;
}

.empty-state {
  min-height: 62vh;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.empty-state h1 {
  margin: 0;
  color: #1d1d1f;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 740;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

.intro-stage h1 {
  width: min(356px, 100%);
  font-size: clamp(24px, 7vw, 29px);
  line-height: 1.18;
  font-weight: 730;
}

.sync-stage h1 {
  width: min(340px, 100%);
  font-size: 25px;
  line-height: 1.25;
  font-weight: 620;
}

.sync-stage h1 strong {
  color: var(--blue);
  font-weight: 700;
}

.player-stage h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 720;
}

.player-stage h2 {
  width: min(348px, 100%);
  color: #1d1d1f;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 650;
}

.translation-art {
  width: 100%;
  height: 292px;
  position: relative;
  display: grid;
  place-items: center;
  margin-top: -4px;
}

.airpods {
  width: 230px;
  height: 230px;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #ffffff 0 26%, #f4f5f8 58%, #eceef3 100%);
  box-shadow: inset 0 24px 54px rgba(255, 255, 255, .9), 0 18px 42px rgba(15, 23, 42, .08);
}

.pod {
  position: absolute;
  top: 68px;
  width: 54px;
  height: 74px;
  border-radius: 42px 42px 30px 30px;
  background:
    radial-gradient(circle at 56% 26%, #ffffff 0 20%, transparent 22%),
    linear-gradient(145deg, #ffffff 0%, #f1f2f5 72%, #d9dce2 100%);
  box-shadow: inset -8px -12px 18px rgba(134, 139, 150, .16), 0 14px 24px rgba(15, 23, 42, .12);
}

.pod::after {
  content: "";
  position: absolute;
  top: 50px;
  left: 19px;
  width: 18px;
  height: 102px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(90deg, #f8f9fb 0%, #ffffff 52%, #d7dae1 100%);
  box-shadow: inset -4px 0 7px rgba(68, 76, 91, .12), 0 10px 18px rgba(15, 23, 42, .08);
}

.pod b {
  position: absolute;
  top: 28px;
  width: 8px;
  height: 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, #0f172a, #2b313d);
}

.pod-left {
  left: 54px;
  transform: rotate(-4deg);
}

.pod-left b {
  right: 12px;
}

.pod-right {
  right: 54px;
  transform: rotate(4deg);
}

.pod-right b {
  left: 12px;
}

.incoming,
.outgoing {
  position: absolute;
  z-index: 2;
}

.incoming {
  left: 0;
  top: 108px;
  width: 118px;
  display: grid;
  justify-items: start;
  gap: 12px;
  color: var(--blue);
}

.incoming strong {
  padding-left: 2px;
  font-size: 16px;
  font-weight: 500;
}

.incoming i {
  width: 84px;
  height: 2px;
  position: relative;
  display: block;
  background: linear-gradient(90deg, transparent, rgba(0, 113, 227, .45));
}

.incoming i::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -5px;
  border: 6px solid transparent;
  border-left-color: var(--blue);
}

.bars {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.bars span,
.listen-wave span,
.playback-wave span {
  width: 3px;
  border-radius: 999px;
  background: var(--blue-2);
}

.bars span:nth-child(1) { height: 16px; opacity: .55; }
.bars span:nth-child(2) { height: 30px; opacity: .75; }
.bars span:nth-child(3) { height: 42px; }
.bars span:nth-child(4) { height: 26px; opacity: .75; }
.bars span:nth-child(5) { height: 48px; }
.bars span:nth-child(6) { height: 25px; opacity: .7; }
.bars span:nth-child(7) { height: 18px; opacity: .55; }

.outgoing {
  right: -2px;
  top: 86px;
  display: grid;
  gap: 8px;
  justify-items: start;
  transform: rotate(-14deg);
}

.outgoing::before,
.outgoing::after {
  content: "";
  position: absolute;
  left: -54px;
  width: 105px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 122, 0, .1), rgba(255, 122, 0, .65));
}

.outgoing::before {
  top: 12px;
}

.outgoing::after {
  bottom: 11px;
}

.outgoing span {
  font-size: 16px;
  line-height: 1;
  font-weight: 500;
}

.outgoing span:nth-child(odd) {
  color: var(--orange);
}

.outgoing span:nth-child(even) {
  color: var(--blue);
}

.live-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
}

.live-label::before,
.live-dot,
.recording-pill span {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue);
}

.event-meta {
  width: 100%;
  min-height: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e9e9ee;
  color: #686b76;
  font-size: 16px;
  line-height: 1.35;
}

.intro-status,
.player-mode,
.player-subtitle,
.language-line,
.sync {
  width: min(352px, 100%);
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.intro-status,
.player-mode,
.sync-steps,
.progress-track {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sync {
  width: min(352px, 100%);
  min-height: 50px;
  color: #424752;
  font-size: 17px;
  line-height: 1.42;
}

.primary-button,
.resync-button,
.cancel-button,
.source {
  min-height: 58px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 20px;
  font-size: 17px;
  font-weight: 650;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(180deg, #0a84ff, #006fe6);
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(0, 113, 227, .24);
}

.source {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--blue);
  background: transparent;
}

.privacy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6b6e78;
  font-size: 15px;
}

.privacy span,
.tip-panel > span {
  width: 15px;
  height: 15px;
  position: relative;
  display: inline-block;
}

.privacy span::before,
.tip-panel > span::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 9px;
  height: 7px;
  border-radius: 2px;
  background: #6b6e78;
}

.privacy span::after,
.tip-panel > span::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 7px;
  height: 8px;
  border: 2px solid #6b6e78;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}

.countdown-ring {
  width: 214px;
  height: 214px;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  border: 8px solid #ededf0;
  isolation: isolate;
}

.ring-segments {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  transform-origin: 50% 50%;
}

.ring-segments i {
  width: 12px;
  height: 28px;
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  background: #e1e5ec;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-111px);
  transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.ring-segments i.is-done {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(10, 132, 255, .12);
}

.sync-stage.is-listening .ring-segments,
.sync-stage.is-analyzing .ring-segments {
  animation: ringSpin 2.8s linear infinite;
}

.sync-stage.is-analyzing .ring-segments i {
  background: var(--blue);
  animation: ringPulse 1.1s ease-in-out infinite;
  animation-delay: var(--pulse-delay);
}

.countdown-ring span {
  position: relative;
  z-index: 1;
  color: var(--blue);
  font-size: 92px;
  font-weight: 610;
  line-height: 1;
}

.sync-stage.is-analyzing .countdown-ring span {
  margin-top: -14px;
  font-size: 68px;
  letter-spacing: 4px;
}

.recording-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #30323b;
  font-size: 18px;
}

.recording-pill span {
  background: #ff2d20;
  box-shadow: 0 0 0 6px rgba(255, 45, 32, .1);
}

.listen-wave,
.playback-wave {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
}

.listen-wave span,
.playback-wave span {
  width: 4px;
  background: #8fc2ff;
}

.sync-stage.is-listening .listen-wave span,
.sync-stage.is-analyzing .listen-wave span,
.player-stage:not([hidden]) .playback-wave span {
  animation: wavePulse .92s ease-in-out infinite;
  animation-delay: var(--wave-delay, 0ms);
}

.listen-wave span:nth-child(1),
.playback-wave span:nth-child(1) { --wave-delay: 0ms; }
.listen-wave span:nth-child(2),
.playback-wave span:nth-child(2) { --wave-delay: 80ms; }
.listen-wave span:nth-child(3),
.playback-wave span:nth-child(3) { --wave-delay: 160ms; }
.listen-wave span:nth-child(4),
.playback-wave span:nth-child(4) { --wave-delay: 240ms; }
.listen-wave span:nth-child(5),
.playback-wave span:nth-child(5) { --wave-delay: 320ms; }
.listen-wave span:nth-child(6),
.playback-wave span:nth-child(6) { --wave-delay: 400ms; }
.listen-wave span:nth-child(7),
.playback-wave span:nth-child(7) { --wave-delay: 480ms; }
.listen-wave span:nth-child(8),
.playback-wave span:nth-child(8) { --wave-delay: 560ms; }
.listen-wave span:nth-child(9),
.playback-wave span:nth-child(9) { --wave-delay: 640ms; }
.listen-wave span:nth-child(10),
.playback-wave span:nth-child(10) { --wave-delay: 720ms; }
.listen-wave span:nth-child(11),
.playback-wave span:nth-child(11) { --wave-delay: 800ms; }
.listen-wave span:nth-child(12),
.playback-wave span:nth-child(12) { --wave-delay: 880ms; }
.playback-wave span:nth-child(13) { --wave-delay: 960ms; }
.playback-wave span:nth-child(14) { --wave-delay: 1040ms; }
.playback-wave span:nth-child(15) { --wave-delay: 1120ms; }
.playback-wave span:nth-child(16) { --wave-delay: 1200ms; }

.listen-wave span:nth-child(1),
.listen-wave span:nth-child(8),
.playback-wave span:nth-child(2),
.playback-wave span:nth-child(11) { height: 20px; opacity: .75; }
.listen-wave span:nth-child(2),
.listen-wave span:nth-child(9),
.playback-wave span:nth-child(1),
.playback-wave span:nth-child(14) { height: 30px; opacity: .85; }
.listen-wave span:nth-child(3),
.listen-wave span:nth-child(10),
.playback-wave span:nth-child(4),
.playback-wave span:nth-child(13) { height: 42px; }
.listen-wave span:nth-child(4),
.listen-wave span:nth-child(11),
.playback-wave span:nth-child(5),
.playback-wave span:nth-child(15) { height: 24px; opacity: .75; }
.listen-wave span:nth-child(5),
.listen-wave span:nth-child(12),
.playback-wave span:nth-child(7),
.playback-wave span:nth-child(16) { height: 48px; }
.listen-wave span:nth-child(6),
.playback-wave span:nth-child(3),
.playback-wave span:nth-child(10) { height: 18px; opacity: .72; }
.listen-wave span:nth-child(7),
.playback-wave span:nth-child(6),
.playback-wave span:nth-child(8),
.playback-wave span:nth-child(9),
.playback-wave span:nth-child(12) { height: 36px; opacity: .88; }

.playback-wave span:nth-child(n+9) {
  background: #ff9f4d;
}

.tip-panel {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid #dbe8fb;
  border-radius: 8px;
  background: #f3f8ff;
  color: #1d1d1f;
  text-align: left;
}

.tip-panel > span {
  width: 34px;
  height: 34px;
}

.tip-panel > span::before {
  width: 15px;
  height: 15px;
  left: 4px;
  top: 10px;
  background: var(--blue);
  clip-path: polygon(0 30%, 40% 30%, 75% 0, 75% 100%, 40% 70%, 0 70%);
}

.tip-panel > span::after {
  width: 9px;
  height: 19px;
  left: 23px;
  top: 7px;
  border: 2px solid var(--blue);
  border-left: 0;
  border-radius: 0 18px 18px 0;
}

.tip-panel p {
  display: grid;
  gap: 5px;
  font-size: 17px;
  line-height: 1.34;
}

.tip-panel strong {
  font-size: 18px;
}

.sync-stage.is-analyzing .tip-panel {
  display: none;
}

.sync-stage.has-error .countdown-ring,
.sync-stage.has-error .recording-pill,
.sync-stage.has-error .listen-wave,
.sync-stage.has-error .tip-panel,
.sync-stage.has-error .cancel-button {
  display: none;
}

.sync-stage.has-error .sync {
  min-height: auto;
  padding: 16px 18px;
  border: 1px solid #ffd2cc;
  border-radius: 8px;
  background: #fff5f4;
  color: #8a1f13;
}

.sync-retry-button {
  margin-top: 2px;
}

.cancel-button {
  min-height: 38px;
  background: transparent;
  color: var(--blue);
  padding: 0;
}

.checkmark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eaf4ff;
}

.checkmark::before {
  content: "";
  width: 24px;
  height: 13px;
  border-left: 4px solid var(--blue);
  border-bottom: 4px solid var(--blue);
  transform: rotate(-45deg) translate(2px, -2px);
}

.time-row {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr 66px;
  align-items: center;
  gap: 10px;
  color: #20242e;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.time-row span:last-child {
  text-align: right;
}

.timeline {
  height: 3px;
  position: relative;
  border-radius: 999px;
  background: #dfe2e8;
}

.timeline span {
  display: block;
  width: 0;
  height: 100%;
  position: relative;
  border-radius: inherit;
  background: var(--blue);
}

.timeline span::after {
  content: "";
  position: absolute;
  right: -9px;
  top: -8px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--blue);
}

.player-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 116px 1fr;
  align-items: center;
  gap: 14px;
}

.pause-button {
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #0a84ff, #006ce5);
  color: #ffffff;
  box-shadow: 0 22px 42px rgba(0, 113, 227, .3);
}

.pause-button svg {
  width: 54px;
  height: 54px;
}

.step-button {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  gap: 1px;
  justify-self: center;
  border: 1px solid #dfe2e8;
  border-radius: 999px;
  background: #ffffff;
  color: #111827;
  box-shadow: 0 9px 22px rgba(15, 23, 42, .05);
}

.step-button span {
  width: 25px;
  height: 18px;
  display: block;
  position: relative;
}

.step-button span::before,
.step-button span::after {
  content: "";
  position: absolute;
  top: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.step-button span::before {
  left: 0;
  border-right: 12px solid #111827;
}

.step-button span::after {
  left: 12px;
  border-right: 12px solid #111827;
}

.step-button.forward span::before,
.step-button.forward span::after {
  border-right: 0;
  border-left: 12px solid #111827;
}

.step-button b {
  font-size: 15px;
  line-height: 1;
}

.volume-row {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr 24px;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
}

.volume-row input {
  width: 100%;
  accent-color: var(--blue);
}

.speaker-select {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
}

.speaker-select span {
  padding-left: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #667085;
}

.speaker-select select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d7deea;
  border-radius: 14px;
  background: white;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.speaker {
  width: 22px;
  height: 22px;
  position: relative;
  display: block;
}

.speaker::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 12px;
  height: 9px;
  background: #5f6673;
  clip-path: polygon(0 25%, 42% 25%, 100% 0, 100% 100%, 42% 75%, 0 75%);
}

.speaker::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 5px;
  width: 8px;
  height: 12px;
  border: 2px solid #5f6673;
  border-left: 0;
  border-radius: 0 14px 14px 0;
}

.speaker.low::after {
  width: 5px;
}

.resync-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-color: var(--blue);
  background: #ffffff;
  color: var(--blue);
}

.resync-button span {
  width: 24px;
  height: 24px;
  position: relative;
  display: inline-block;
  border: 3px solid var(--blue);
  border-right-color: transparent;
  border-radius: 50%;
}

.resync-button span::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 0;
  border: 6px solid transparent;
  border-left-color: var(--blue);
  transform: rotate(-28deg);
}

.live-dot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

audio[data-audio] {
  display: none;
}

.debug {
  display: none;
  white-space: pre-wrap;
  margin: 14px 0 0;
  background: #1d1d1f;
  color: #d8f3ff;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
}

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

@keyframes ringPulse {
  0%, 100% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-111px) scale(.92);
  }
  50% {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-111px) scale(1.08);
  }
}

@keyframes wavePulse {
  0%, 100% {
    transform: scaleY(.55);
    opacity: .58;
  }
  50% {
    transform: scaleY(1.18);
    opacity: 1;
  }
}

@media (min-width: 960px) {
  .page {
    width: 430px;
  }
}

@media (max-width: 380px) {
  .page {
    padding-left: 8px;
    padding-right: 8px;
  }

  .stage {
    padding-left: 18px;
    padding-right: 18px;
  }

  .translation-art {
    height: 264px;
  }

  .airpods {
    width: 208px;
    height: 208px;
  }

  .incoming {
    left: -4px;
    transform: scale(.9);
    transform-origin: left center;
  }

  .outgoing {
    right: -8px;
    transform: rotate(-14deg) scale(.9);
    transform-origin: right center;
  }

  .player-controls {
    grid-template-columns: 1fr 104px 1fr;
    gap: 10px;
  }

  .pause-button {
    width: 104px;
    height: 104px;
  }

  .step-button {
    width: 68px;
    height: 68px;
  }
}
