/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --ring:    #6366f1;
  --glow:    rgba(99, 102, 241, 0.45);
  --glow-lg: rgba(99, 102, 241, 0.18);
  --text:    #e2e8f0;
  --muted:   #475569;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* svh for iOS safe-area-aware viewport height */
  min-height: 100svh;
  min-height: 100vh; /* fallback */
  padding: 2rem 1.5rem;
  gap: 2rem;
  text-align: center;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
h1 {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #f1f5f9;
}

.subtitle {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Main button ─────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  width:  clamp(160px, 46vw, 200px);
  height: clamp(160px, 46vw, 200px);
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  outline: none;
  touch-action: manipulation;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Outer pulse ring */
.btn::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--ring);
  opacity: 0;
  transition: opacity 0.4s ease, inset 0.4s ease;
  pointer-events: none;
}

.btn.on {
  border-color: var(--ring);
  box-shadow: 0 0 28px 8px var(--glow), 0 0 70px 24px var(--glow-lg);
  animation: breathe 4s ease-in-out infinite;
}

.btn.on::after {
  opacity: 0.55;
  animation: ring-pulse 4s ease-in-out infinite;
}

.btn:active { transform: scale(0.94); }

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 28px 8px var(--glow), 0 0 70px 24px var(--glow-lg); }
  50%       { box-shadow: 0 0 42px 14px var(--glow), 0 0 100px 36px var(--glow-lg); }
}

@keyframes ring-pulse {
  0%, 100% { inset: -10px; opacity: 0.55; }
  50%       { inset: -18px; opacity: 0.2; }
}

/* ── Button icons (play / pause) ─────────────────────────────────────────── */
.btn-icon {
  width: 2.2rem;
  height: 2.2rem;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* Show play by default, pause when .on */
.pause-icon          { display: none; }
.btn.on .play-icon   { display: none; }
.btn.on .pause-icon  { display: block; }

/* ── Button label ────────────────────────────────────────────────────────── */
.btn-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s;
}

.btn.on .btn-label { color: var(--text); }

/* ── Status line ─────────────────────────────────────────────────────────── */
.status {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  min-height: 1.2em;
  transition: color 0.3s;
}

/* ── Waveform bars ───────────────────────────────────────────────────────── */
.bars {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 44px;
}

.bar {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--ring);
  transform: scaleY(0.1);
  transform-origin: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.bars.active .bar {
  opacity: 1;
  animation: dance 1s ease-in-out infinite alternate;
}

/* Stagger timing so bars look organic */
.bars.active .bar:nth-child(1) { animation-duration: 1.10s; animation-delay: 0.00s; }
.bars.active .bar:nth-child(2) { animation-duration: 0.85s; animation-delay: 0.12s; }
.bars.active .bar:nth-child(3) { animation-duration: 1.30s; animation-delay: 0.05s; }
.bars.active .bar:nth-child(4) { animation-duration: 0.95s; animation-delay: 0.22s; }
.bars.active .bar:nth-child(5) { animation-duration: 1.20s; animation-delay: 0.17s; }
.bars.active .bar:nth-child(6) { animation-duration: 0.78s; animation-delay: 0.08s; }
.bars.active .bar:nth-child(7) { animation-duration: 1.05s; animation-delay: 0.30s; }

@keyframes dance {
  from { transform: scaleY(0.12); }
  to   { transform: scaleY(1.0);  }
}

/* ── Volume row ──────────────────────────────────────────────────────────── */
.volume-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--muted);
}

input[type='range'] {
  -webkit-appearance: none;
  width: 130px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface);
  outline: none;
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ring);
  cursor: pointer;
  box-shadow: 0 0 8px var(--glow);
}

input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ring);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 8px var(--glow);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: max(1.2rem, env(safe-area-inset-bottom, 1.2rem));
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 1.5rem;
}

footer p {
  font-size: 0.62rem;
  color: var(--muted);
  opacity: 0.5;
  line-height: 1.6;
}

/* ── Accessibility: reduce motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .btn, .btn::after, .bar { animation: none !important; transition: none !important; }
  .bars.active .bar { transform: scaleY(0.5); }
}
