/* Web voice call page — real-call feel, mobile-first, theme-driven.
 *
 * Visual hierarchy (top → bottom):
 *   1. Hub chip   — small pill with clinic name + e2e-encrypted shield
 *   2. Avatar     — big circular portrait with theme glow + state-driven ring
 *   3. Identity   — name + role ("AI receptionist")
 *   4. Waveform   — 32 thin bars driven by Web Audio AnalyserNode frequencies
 *   5. Status     — "Tap to call" / "Connecting…" / "Connected" / etc.
 *   6. Timer      — small monospace; only renders during a call
 *   7. Controls   — single CTA in idle; 3 icon-stacks (mute / speaker / end) in-call
 *   8. Disclaimer — small caps, neutral
 */

:root {
  --wc-bg: #0a0d14;
  --wc-bg-soft: rgba(14, 18, 28, 0.85);
  --wc-fg: #f1f4fb;
  --wc-fg-soft: rgba(241, 244, 251, 0.72);
  --wc-fg-dim: rgba(241, 244, 251, 0.42);
  --wc-fg-faint: rgba(241, 244, 251, 0.18);
  --wc-control-bg: rgba(255, 255, 255, 0.06);
  --wc-control-hover: rgba(255, 255, 255, 0.12);
  --wc-control-border: rgba(255, 255, 255, 0.10);
  --wc-danger: #ef4444;
  --wc-danger-soft: rgba(239, 68, 68, 0.18);
  --wc-danger-soft-hover: rgba(239, 68, 68, 0.30);
}

* { box-sizing: border-box; }

.wc-body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--wc-bg);
  color: var(--wc-fg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle radial gradient that picks up the agent's theme color */
.wc-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--wc-theme) 25%, transparent) 0%, transparent 60%),
    radial-gradient(circle at 70% 80%, color-mix(in srgb, var(--wc-theme) 18%, transparent) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wc-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(0.75rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  max-width: 32rem;
  margin: 0 auto;
}

/* ── Top bar — minimal chrome ──────────────────────────────────── */
.wc-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin: 0.25rem 0 0.5rem;
  min-height: 28px;
}
.wc-clinic-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--wc-control-bg);
  padding: 4px;
  flex: 0 0 auto;
}
.wc-secure {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--wc-control-border);
  background: rgba(255, 255, 255, 0.04);
  color: color-mix(in srgb, var(--wc-theme) 85%, white);
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.wc-secure .wc-icon { width: 13px; height: 13px; }

/* ── Stage — the agent's "presence" ─────────────────────────────── */
.wc-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.1rem;
}

.wc-avatar-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.25rem 0 0.25rem;
}

.wc-avatar-glow {
  position: absolute;
  inset: -34px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--wc-theme) 50%, transparent) 0%, transparent 65%);
  filter: blur(10px);
  opacity: 0.45;
  animation: wc-breathe 5.5s ease-in-out infinite;
  transition: opacity 240ms ease;
  z-index: 0;
}

.wc-avatar-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--wc-theme) 55%, transparent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transition: border-color 240ms ease;
  z-index: 1;
}

.wc-avatar {
  position: relative;
  z-index: 2;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.10), transparent 55%),
    color-mix(in srgb, var(--wc-theme) 22%, #1a1f2e);
  box-shadow: 0 24px 60px -20px color-mix(in srgb, var(--wc-theme) 50%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: wc-avatar-float 7s ease-in-out infinite;
}
.wc-avatar-initial {
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--wc-fg);
  display: none;
}
.wc-avatar--fallback .wc-avatar-initial {
  display: block;
}

.wc-avatar-wrap[data-wc-state="connected"] .wc-avatar-glow,
.wc-avatar-wrap[data-wc-state="speaking"] .wc-avatar-glow {
  opacity: 0.85;
  animation: wc-breathe 2.4s ease-in-out infinite;
}
.wc-avatar-wrap[data-wc-state="connecting"] .wc-avatar-ring,
.wc-avatar-wrap[data-wc-state="ringing"] .wc-avatar-ring {
  border-color: color-mix(in srgb, var(--wc-theme) 90%, transparent);
  animation: wc-pulse-ring 1.4s ease-out infinite;
}
.wc-avatar-wrap[data-wc-state="ended"] .wc-avatar-glow,
.wc-avatar-wrap[data-wc-state="cap_exceeded"] .wc-avatar-glow,
.wc-avatar-wrap[data-wc-state="error"] .wc-avatar-glow {
  opacity: 0.12;
  animation: none;
  transition: opacity 600ms ease;
}
/* "The line went dead" — desaturate + dim the avatar, soften the ring. */
.wc-avatar-wrap[data-wc-state="ended"] .wc-avatar,
.wc-avatar-wrap[data-wc-state="cap_exceeded"] .wc-avatar,
.wc-avatar-wrap[data-wc-state="error"] .wc-avatar {
  filter: saturate(0.55) brightness(0.72);
  transition: filter 600ms ease;
}
.wc-avatar-wrap[data-wc-state="ended"] .wc-avatar-ring,
.wc-avatar-wrap[data-wc-state="cap_exceeded"] .wc-avatar-ring,
.wc-avatar-wrap[data-wc-state="error"] .wc-avatar-ring {
  border-color: color-mix(in srgb, var(--wc-theme) 20%, transparent);
  transition: border-color 600ms ease;
}

/* ── Identity ──────────────────────────────────────────────────────
 * Hierarchy:
 *   - wc-name      → who you're calling (hub > label > agent fallback)
 *   - wc-subtitle  → "with Elena Dragomir · AI Receptionist" (muted)
 * If no hub/label, agent name is the H1 and the subtitle is just the role.
 */
.wc-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  max-width: 24rem;
}
.wc-name {
  margin: 0;
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--wc-fg);
  text-wrap: balance;
}
.wc-subtitle {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--wc-fg-soft);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.wc-subtitle-with {
  color: var(--wc-fg-dim);
  font-weight: 400;
}
.wc-subtitle-agent {
  color: var(--wc-fg);
  font-weight: 600;
}
.wc-subtitle-sep { color: var(--wc-fg-faint); }
.wc-subtitle-role {
  color: var(--wc-fg-soft);
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* ── Live waveform (32 bars) ───────────────────────────────────── */
.wc-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
  width: 100%;
  max-width: 22rem;
  margin: 0.15rem 0;
  padding: 0 0.25rem;
}
.wc-wave-bar {
  flex: 1 1 0;
  height: 100%;
  max-width: 6px;
  border-radius: 3px;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--wc-theme) 95%, white 5%),
    color-mix(in srgb, var(--wc-theme) 65%, transparent));
  transform: scaleY(0.08);
  transform-origin: center;
  transition: transform 70ms cubic-bezier(.2,.7,.3,1), opacity 200ms ease;
  opacity: 0.5;
  will-change: transform;
}
.wc-avatar-wrap[data-wc-state="connected"] ~ .wc-waveform .wc-wave-bar,
.wc-avatar-wrap[data-wc-state="speaking"] ~ .wc-waveform .wc-wave-bar {
  opacity: 1;
}
/* Symmetric idle "neutral" breathing — bars near center bigger than edges */
.wc-avatar-wrap[data-wc-state="idle"] ~ .wc-waveform .wc-wave-bar { opacity: 0.35; }

/* ── Status text + timer ───────────────────────────────────────── */
.wc-status {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--wc-fg);
  min-height: 1.3em;
  letter-spacing: 0.01em;
}
.wc-timer {
  margin: 0;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--wc-fg-dim);
  letter-spacing: 0.06em;
  min-height: 1em;
  transition: font-size 220ms ease, color 220ms ease, opacity 220ms ease;
}
/* Promote the call-duration recap so the user clearly sees how long the
 * call lasted after it ends. */
body[data-wc-state="ended"] .wc-timer,
body[data-wc-state="cap_exceeded"] .wc-timer,
body[data-wc-state="error"] .wc-timer {
  font-size: 1rem;
  color: var(--wc-fg-soft);
}
body[data-wc-state="ended"] .wc-status,
body[data-wc-state="cap_exceeded"] .wc-status,
body[data-wc-state="error"] .wc-status {
  color: var(--wc-fg-soft);
}

/* ── Controls ──────────────────────────────────────────────────── */
.wc-controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding-top: 1rem;
}

.wc-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  transition: transform 140ms cubic-bezier(.2,.7,.3,1), background 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.wc-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--wc-theme) 80%, white);
  outline-offset: 3px;
}

.wc-btn--primary {
  width: 100%;
  min-height: 64px;
  border-radius: 18px;
  font-size: 1.05rem;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--wc-theme) 100%, white 10%),
    var(--wc-theme));
  color: #fff;
  box-shadow:
    0 20px 40px -16px color-mix(in srgb, var(--wc-theme) 70%, transparent),
    0 1px 0 0 rgba(255, 255, 255, 0.20) inset;
}
.wc-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 24px 48px -16px color-mix(in srgb, var(--wc-theme) 80%, transparent), 0 1px 0 0 rgba(255, 255, 255, 0.24) inset; }
.wc-btn--primary:active { transform: translateY(1px); }
.wc-btn--primary:disabled { opacity: 0.7; cursor: wait; transform: none; }

body[data-wc-state="connected"] .wc-btn--primary { display: none; }

/* In-call: 3 stacked icon buttons (mute / speaker / hangup) */
.wc-incall {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.5rem 0;
}
.wc-icon-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
.wc-icon-btn {
  appearance: none;
  border: 1px solid var(--wc-control-border);
  background: var(--wc-control-bg);
  color: var(--wc-fg);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 140ms cubic-bezier(.2,.7,.3,1), background 160ms ease, border-color 160ms ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
}
.wc-icon-btn:hover { background: var(--wc-control-hover); transform: translateY(-1px); }
.wc-icon-btn:active { transform: translateY(1px); }
.wc-icon-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--wc-theme) 80%, white);
  outline-offset: 3px;
}
.wc-icon-btn .wc-icon { width: 24px; height: 24px; }

.wc-icon-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--wc-fg-dim);
  letter-spacing: 0.02em;
}

/* Mute toggle */
.wc-icon-btn--mute .wc-icon--mic { display: block; }
.wc-icon-btn--mute .wc-icon--mic-off { display: none; }
.wc-icon-btn--mute[aria-pressed="true"] .wc-icon--mic { display: none; }
.wc-icon-btn--mute[aria-pressed="true"] .wc-icon--mic-off { display: block; }
.wc-icon-btn--mute[aria-pressed="true"] {
  background: color-mix(in srgb, var(--wc-theme) 22%, transparent);
  border-color: color-mix(in srgb, var(--wc-theme) 40%, transparent);
  color: color-mix(in srgb, var(--wc-theme) 80%, white);
}

/* Speaker toggle —
 *   aria-pressed="true"  → speakerphone is ON   (active, tinted with theme)
 *   aria-pressed="false" → earpiece (private)   (neutral, no danger styling)
 * No red anywhere — this is a routing choice, not a destructive action. */
.wc-icon-btn--speaker .wc-icon--speaker-on { display: block; }
.wc-icon-btn--speaker .wc-icon--speaker-off { display: none; }
.wc-icon-btn--speaker[aria-pressed="false"] .wc-icon--speaker-on { display: none; }
.wc-icon-btn--speaker[aria-pressed="false"] .wc-icon--speaker-off { display: block; }
.wc-icon-btn--speaker[aria-pressed="true"] {
  background: color-mix(in srgb, var(--wc-theme) 22%, transparent);
  border-color: color-mix(in srgb, var(--wc-theme) 40%, transparent);
  color: color-mix(in srgb, var(--wc-theme) 80%, white);
}

/* End-call — solid red, the obvious "stop the call" target. Sized larger
 * than the toggle buttons so it reads as the primary destructive action. */
.wc-icon-btn--hangup {
  background: linear-gradient(180deg, #ff5d5d 0%, var(--wc-danger) 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 72px;
  height: 72px;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45),
              inset 0 1px 0 rgba(255, 255, 255, 0.20);
}
.wc-icon-btn--hangup:hover {
  background: linear-gradient(180deg, #ff7373 0%, #d44141 100%);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.55),
              inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.wc-icon-btn--hangup:active {
  background: linear-gradient(180deg, #e84a4a 0%, #c33b3b 100%);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45),
              inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.wc-icon-btn--hangup .wc-icon { width: 28px; height: 28px; }

.wc-disclaimer {
  margin: 0.85rem 0 0;
  font-size: 0.72rem;
  color: var(--wc-fg-faint);
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wc-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

/* ── Post-call CTA ─────────────────────────────────────────────── */
.wc-cta {
  margin-top: 0.85rem;
  padding: 1rem 1.25rem 1.1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--wc-control-border);
  border-radius: 18px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  /* Slide+fade in when revealed at end-of-call. */
  animation: wc-cta-in 420ms cubic-bezier(.2,.7,.3,1) both;
}
@keyframes wc-cta-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wc-cta-text { margin: 0 0 0.85rem; color: var(--wc-fg); font-size: 0.98rem; }
.wc-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.25rem;
  background: var(--wc-theme);
  color: #fff;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 140ms ease;
  box-shadow: 0 12px 24px -10px color-mix(in srgb, var(--wc-theme) 60%, transparent);
}
.wc-cta-btn:hover { transform: translateY(-1px); }
.wc-cta-btn .wc-icon { width: 18px; height: 18px; }

/* ── State-derived overlays ────────────────────────────────────── */
body[data-wc-state="requesting_mic"] .wc-btn--primary,
body[data-wc-state="connecting"] .wc-btn--primary { cursor: wait; }
body[data-wc-state="ended"] .wc-stage,
body[data-wc-state="cap_exceeded"] .wc-stage,
body[data-wc-state="error"] .wc-stage { opacity: 0.95; }

/* ── Desktop polish (≥ 1024px) ─────────────────────────────────── */
@media (min-width: 1024px) {
  .wc-main { padding-top: 2rem; padding-bottom: 2.5rem; }
  .wc-avatar-wrap, .wc-avatar { width: 200px; height: 200px; }
  .wc-avatar-glow { inset: -38px; }
  .wc-name { font-size: 2.45rem; line-height: 1.1; }
  .wc-subtitle { font-size: 0.95rem; }
  .wc-subtitle-role { font-size: 0.78rem; }
  .wc-waveform { height: 56px; gap: 4px; max-width: 26rem; }
  .wc-wave-bar { max-width: 7px; }
  .wc-btn--primary { min-height: 68px; font-size: 1.1rem; max-width: 28rem; margin: 0 auto; }
  .wc-icon-btn { width: 72px; height: 72px; }
  .wc-icon-btn .wc-icon { width: 28px; height: 28px; }
  .wc-icon-btn--hangup .wc-icon { width: 30px; height: 30px; }
  .wc-incall { gap: 2rem; }
}

/* ── Short-height phones (e.g. iPhone SE) ──────────────────────── */
@media (max-height: 660px) {
  .wc-topbar { margin-bottom: 0.3rem; }
  .wc-stage { gap: 0.7rem; }
  .wc-avatar-wrap, .wc-avatar { width: 120px; height: 120px; }
  .wc-avatar-glow { inset: -20px; }
  .wc-name { font-size: 1.45rem; }
  .wc-subtitle { font-size: 0.82rem; }
  .wc-subtitle-role { font-size: 0.68rem; }
  .wc-waveform { height: 32px; }
  .wc-btn--primary { min-height: 54px; font-size: 0.98rem; }
  .wc-icon-btn { width: 56px; height: 56px; }
}

/* ── Animations ────────────────────────────────────────────────── */
/* Black overlay painted when the proximity sensor reports phone-to-ear.
 * Sits above everything (z above the body mesh, modals, and audio sink).
 * The wake-lock release happens in JS so the OS can also sleep the display
 * naturally; this overlay just guarantees the call UI visually disappears
 * even when the OS keeps the screen on for a few extra frames. */
#wc-screen-off {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
#wc-screen-off.wc-screen-off--active {
  opacity: 1;
  pointer-events: auto;
}

@keyframes wc-breathe {
  0%, 100% { transform: scale(1); opacity: var(--_op, 0.45); }
  50%      { transform: scale(1.06); opacity: calc(var(--_op, 0.45) + 0.2); }
}
@keyframes wc-pulse-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--wc-theme) 60%, transparent); }
  100% { box-shadow: 0 0 0 28px color-mix(in srgb, var(--wc-theme) 0%, transparent); }
}
@keyframes wc-avatar-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-2px) scale(1.015); }
}
/* Idle — a gentle breathing wave. Combined with the radial animation-delay
 * pattern below, the scale shift visibly ripples from the center out to the
 * edges so the bars feel alive without competing with the live active state. */
@keyframes wc-wave-idle {
  0%, 100% { transform: scaleY(0.16); }
  50%      { transform: scaleY(0.34); }
}
.wc-wave-bar {
  animation: wc-wave-idle 2.4s ease-in-out infinite;
}
/* Radial wave — center pair starts the cycle, outer pairs lag in 0.075s
 * steps so the ripple emanates from the middle and reaches the margins
 * last. 16 pairs × 0.075s = 1.2s spread, fits inside the 2.4s cycle. */
.wc-wave-bar:nth-child(16), .wc-wave-bar:nth-child(17) { animation-delay: -0.000s; }
.wc-wave-bar:nth-child(15), .wc-wave-bar:nth-child(18) { animation-delay: -0.075s; }
.wc-wave-bar:nth-child(14), .wc-wave-bar:nth-child(19) { animation-delay: -0.150s; }
.wc-wave-bar:nth-child(13), .wc-wave-bar:nth-child(20) { animation-delay: -0.225s; }
.wc-wave-bar:nth-child(12), .wc-wave-bar:nth-child(21) { animation-delay: -0.300s; }
.wc-wave-bar:nth-child(11), .wc-wave-bar:nth-child(22) { animation-delay: -0.375s; }
.wc-wave-bar:nth-child(10), .wc-wave-bar:nth-child(23) { animation-delay: -0.450s; }
.wc-wave-bar:nth-child(9),  .wc-wave-bar:nth-child(24) { animation-delay: -0.525s; }
.wc-wave-bar:nth-child(8),  .wc-wave-bar:nth-child(25) { animation-delay: -0.600s; }
.wc-wave-bar:nth-child(7),  .wc-wave-bar:nth-child(26) { animation-delay: -0.675s; }
.wc-wave-bar:nth-child(6),  .wc-wave-bar:nth-child(27) { animation-delay: -0.750s; }
.wc-wave-bar:nth-child(5),  .wc-wave-bar:nth-child(28) { animation-delay: -0.825s; }
.wc-wave-bar:nth-child(4),  .wc-wave-bar:nth-child(29) { animation-delay: -0.900s; }
.wc-wave-bar:nth-child(3),  .wc-wave-bar:nth-child(30) { animation-delay: -0.975s; }
.wc-wave-bar:nth-child(2),  .wc-wave-bar:nth-child(31) { animation-delay: -1.050s; }
.wc-wave-bar:nth-child(1),  .wc-wave-bar:nth-child(32) { animation-delay: -1.125s; }

/* When JS is driving the bars (connected/speaking) or the call has ended,
 * stop the CSS idle animation so JS-set inline transform (or "frozen" bars
 * in the ended/error states) takes precedence. */
.wc-avatar-wrap[data-wc-state="connected"] ~ .wc-waveform .wc-wave-bar,
.wc-avatar-wrap[data-wc-state="speaking"]  ~ .wc-waveform .wc-wave-bar,
.wc-avatar-wrap[data-wc-state="ended"]     ~ .wc-waveform .wc-wave-bar,
.wc-avatar-wrap[data-wc-state="cap_exceeded"] ~ .wc-waveform .wc-wave-bar,
.wc-avatar-wrap[data-wc-state="error"]     ~ .wc-waveform .wc-wave-bar {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .wc-avatar-glow,
  .wc-avatar img,
  .wc-wave-bar,
  .wc-btn,
  .wc-icon-btn { animation: none !important; transition: none !important; }
  .wc-avatar-wrap[data-wc-state="idle"] ~ .wc-waveform .wc-wave-bar { transform: scaleY(0.18); }
}
