{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "video-call",
  "type": "registry:block",
  "title": "Video Call",
  "description": "A video call where the grid reflows as people drop in and out, whoever is talking gets a soft ring and a pulse, reactions float up the stage, and chat and people slide in beside it.",
  "categories": [
    "screen",
    "Comms"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/input-group.json",
    "https://coss.com/ui/r/kbd.json",
    "https://coss.com/ui/r/menu.json",
    "https://coss.com/ui/r/popover.json",
    "https://coss.com/ui/r/tooltip.json"
  ],
  "files": [
    {
      "path": "registry/devl/video-call.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  CheckIcon,\n  ChevronUpIcon,\n  CopyIcon,\n  EllipsisIcon,\n  HandIcon,\n  LayoutGridIcon,\n  MessageSquareIcon,\n  MicIcon,\n  MicOffIcon,\n  MonitorUpIcon,\n  PhoneOffIcon,\n  PresentationIcon,\n  SendHorizontalIcon,\n  SmilePlusIcon,\n  ThumbsDownIcon,\n  ThumbsUpIcon,\n  UsersIcon,\n  VideoIcon,\n  VideoOffIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { type CSSProperties, type ReactNode, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Button } from \"@/components/ui/button\";\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@/components/ui/input-group\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport {\n  Menu,\n  MenuGroup,\n  MenuGroupLabel,\n  MenuItem,\n  MenuPopup,\n  MenuRadioGroup,\n  MenuRadioItem,\n  MenuSeparator,\n  MenuTrigger,\n} from \"@/components/ui/menu\";\nimport { Popover, PopoverPopup, PopoverTrigger } from \"@/components/ui/popover\";\nimport { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger } from \"@/components/ui/tooltip\";\n\nfunction useReducedMotionSafe() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nexport type CallHue = \"rose\" | \"amber\" | \"emerald\" | \"sky\" | \"violet\" | \"orange\" | \"teal\" | \"indigo\";\n\nexport interface CallPerson {\n  id: string;\n  name: string;\n  title?: string;\n  hue: CallHue;\n  muted?: boolean;\n  cameraOff?: boolean;\n  host?: boolean;\n}\n\nexport interface CallMessage {\n  id: string;\n  authorId: string;\n  text: string;\n  time: string;\n}\n\nexport interface VideoCallProps {\n  className?: string;\n  title?: string;\n  you?: CallPerson;\n  participants?: CallPerson[];\n  dropIns?: CallPerson[];\n  messages?: CallMessage[];\n  scriptedMessages?: { authorId: string; text: string }[];\n  elapsedSeconds?: number;\n  autoplay?: boolean;\n  startTime?: string;\n  meetingCode?: string;\n}\n\nconst spring = { type: \"spring\", stiffness: 420, damping: 40, mass: 1 } as const;\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst press = \"transition-[color,background-color,box-shadow,scale] duration-150 ease-out active:scale-[0.97]\";\nconst menuPop =\n  \"transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 data-ending-style:duration-100\";\nconst REACTIONS = [\"👏\", \"🎉\", \"❤️\", \"😂\", \"👍\", \"🤔\"];\n\nconst hues: Record<CallHue, { wash: string; glowA: string; glowB: string; avatar: string; solid: string }> = {\n  rose: {\n    wash: \"bg-rose-50 dark:bg-rose-950/60\",\n    glowA: \"bg-rose-300/55 dark:bg-rose-500/22\",\n    glowB: \"bg-orange-200/70 dark:bg-orange-400/14\",\n    avatar: \"bg-rose-500/15 text-rose-700 dark:bg-rose-400/20 dark:text-rose-200\",\n    solid: \"bg-rose-600 text-white dark:bg-rose-500\",\n  },\n  amber: {\n    wash: \"bg-amber-50 dark:bg-amber-950/60\",\n    glowA: \"bg-amber-300/55 dark:bg-amber-500/22\",\n    glowB: \"bg-orange-200/70 dark:bg-orange-400/14\",\n    avatar: \"bg-amber-500/15 text-amber-700 dark:bg-amber-400/20 dark:text-amber-200\",\n    solid: \"bg-amber-600 text-white dark:bg-amber-500\",\n  },\n  emerald: {\n    wash: \"bg-emerald-50 dark:bg-emerald-950/60\",\n    glowA: \"bg-emerald-300/55 dark:bg-emerald-500/22\",\n    glowB: \"bg-teal-200/70 dark:bg-teal-400/14\",\n    avatar: \"bg-emerald-500/15 text-emerald-700 dark:bg-emerald-400/20 dark:text-emerald-200\",\n    solid: \"bg-emerald-600 text-white dark:bg-emerald-500\",\n  },\n  sky: {\n    wash: \"bg-sky-50 dark:bg-sky-950/60\",\n    glowA: \"bg-sky-300/55 dark:bg-sky-500/22\",\n    glowB: \"bg-indigo-200/70 dark:bg-indigo-400/14\",\n    avatar: \"bg-sky-500/15 text-sky-700 dark:bg-sky-400/20 dark:text-sky-200\",\n    solid: \"bg-sky-600 text-white dark:bg-sky-500\",\n  },\n  violet: {\n    wash: \"bg-violet-50 dark:bg-violet-950/60\",\n    glowA: \"bg-violet-300/55 dark:bg-violet-500/22\",\n    glowB: \"bg-fuchsia-200/70 dark:bg-fuchsia-400/14\",\n    avatar: \"bg-violet-500/15 text-violet-700 dark:bg-violet-400/20 dark:text-violet-200\",\n    solid: \"bg-violet-600 text-white dark:bg-violet-500\",\n  },\n  orange: {\n    wash: \"bg-orange-50 dark:bg-orange-950/60\",\n    glowA: \"bg-orange-300/55 dark:bg-orange-500/22\",\n    glowB: \"bg-rose-200/70 dark:bg-rose-400/14\",\n    avatar: \"bg-orange-500/15 text-orange-700 dark:bg-orange-400/20 dark:text-orange-200\",\n    solid: \"bg-orange-600 text-white dark:bg-orange-500\",\n  },\n  teal: {\n    wash: \"bg-teal-50 dark:bg-teal-950/60\",\n    glowA: \"bg-teal-300/55 dark:bg-teal-500/22\",\n    glowB: \"bg-cyan-200/70 dark:bg-cyan-400/14\",\n    avatar: \"bg-teal-500/15 text-teal-700 dark:bg-teal-400/20 dark:text-teal-200\",\n    solid: \"bg-teal-600 text-white dark:bg-teal-500\",\n  },\n  indigo: {\n    wash: \"bg-indigo-50 dark:bg-indigo-950/60\",\n    glowA: \"bg-indigo-300/55 dark:bg-indigo-500/22\",\n    glowB: \"bg-violet-200/70 dark:bg-violet-400/14\",\n    avatar: \"bg-indigo-500/15 text-indigo-700 dark:bg-indigo-400/20 dark:text-indigo-200\",\n    solid: \"bg-indigo-600 text-white dark:bg-indigo-500\",\n  },\n};\n\nconst defaultYou: CallPerson = { id: \"you\", name: \"Noor Haddad\", title: \"Product design\", hue: \"teal\" };\n\nconst defaultParticipants: CallPerson[] = [\n  { id: \"tomas\", name: \"Tomás Aguilar\", title: \"Design lead\", hue: \"sky\", host: true },\n  { id: \"priya\", name: \"Priya Raman\", title: \"Product\", hue: \"violet\" },\n  { id: \"kenji\", name: \"Kenji Mori\", title: \"Engineering\", hue: \"amber\", cameraOff: true },\n  { id: \"ada\", name: \"Ada Okoye\", title: \"Research\", hue: \"emerald\", muted: true },\n  { id: \"lena\", name: \"Lena Fischer\", title: \"Engineering\", hue: \"rose\" },\n];\n\nconst defaultDropIns: CallPerson[] = [\n  { id: \"felix\", name: \"Felix Brandt\", title: \"Support\", hue: \"orange\", muted: true },\n  { id: \"sol\", name: \"Sol Marín\", title: \"Marketing\", hue: \"indigo\" },\n  { id: \"ines\", name: \"Inês Duarte\", title: \"Data\", hue: \"rose\", cameraOff: true, muted: true },\n];\n\nconst defaultMessages: CallMessage[] = [\n  { id: \"m1\", authorId: \"tomas\", text: \"Agenda: onboarding v3 flows, then empty states. Figma link in the invite.\", time: \"10:31\" },\n  { id: \"m2\", authorId: \"priya\", text: \"Can we look at step 3 first? Support flagged it twice this week.\", time: \"10:33\" },\n];\n\nconst defaultScript = [\n  { authorId: \"lena\", text: \"The skip link on step 2 is tiny on mobile, fwiw\" },\n  { authorId: \"ada\", text: \"Agree. 4 of 6 interviewees missed it entirely.\" },\n  { authorId: \"tomas\", text: \"Let's take that as an action item. Noor, can you own it?\" },\n];\n\nconst dropScript: { op: \"join\" | \"leave\"; index: number }[] = [\n  { op: \"join\", index: 0 },\n  { op: \"join\", index: 1 },\n  { op: \"leave\", index: 0 },\n  { op: \"join\", index: 2 },\n  { op: \"leave\", index: 1 },\n  { op: \"leave\", index: 2 },\n];\n\nfunction initials(name: string) {\n  return name\n    .split(/\\s+/)\n    .map((p) => p[0])\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nfunction firstName(name: string) {\n  return name.split(\" \")[0];\n}\n\nfunction clock(total: number) {\n  const h = Math.floor(total / 3600);\n  const m = Math.floor((total % 3600) / 60);\n  const s = total % 60;\n  const mm = String(m).padStart(h ? 2 : 1, \"0\");\n  return `${h ? `${h}:` : \"\"}${mm}:${String(s).padStart(2, \"0\")}`;\n}\n\nfunction timeLabel(start: string, elapsed: number) {\n  const [h, m] = start.split(\":\").map(Number);\n  const mins = (h * 60 + m + Math.floor(elapsed / 60)) % (24 * 60);\n  return `${String(Math.floor(mins / 60)).padStart(2, \"0\")}:${String(mins % 60).padStart(2, \"0\")}`;\n}\n\nfunction gridShape(n: number) {\n  const wide = n <= 1 ? 1 : n <= 4 ? 2 : n <= 9 ? 3 : 4;\n  const narrow = n <= 2 ? 1 : 2;\n  return { c: wide, r: Math.ceil(n / wide), cs: narrow, rs: Math.ceil(n / narrow) };\n}\n\ntype Live = CallPerson & { hand?: boolean };\n\nfunction PersonAvatar({ person, size = 7, className }: { person: CallPerson; size?: 6 | 7 | 8 | 16; className?: string }) {\n  const sizes = {\n    6: \"[--avatar-size:--spacing(6)]\",\n    7: \"[--avatar-size:--spacing(7)]\",\n    8: \"[--avatar-size:--spacing(8)]\",\n    16: \"[--avatar-size:--spacing(16)]\",\n  };\n  return (\n    <Avatar className={cn(sizes[size], className)}>\n      <AvatarFallback className={cn(\"font-semibold\", hues[person.hue].avatar)}>{initials(person.name)}</AvatarFallback>\n    </Avatar>\n  );\n}\n\nfunction SpeakingBars({ reduce }: { reduce: boolean | null }) {\n  return (\n    <span aria-hidden className=\"flex h-3 items-center gap-[2px]\">\n      {[0, 1, 2].map((i) => (\n        <motion.span\n          animate={reduce ? { scaleY: 0.7 } : { scaleY: [0.35, 1, 0.5, 0.85, 0.35] }}\n          className=\"h-3 w-[3px] origin-center rounded-full bg-emerald-500 dark:bg-emerald-400\"\n          key={i}\n          transition={reduce ? { duration: 0 } : { duration: 0.9, repeat: Infinity, ease: \"easeInOut\", delay: i * 0.15 }}\n        />\n      ))}\n    </span>\n  );\n}\n\nfunction Ambient({ hue }: { hue: CallHue }) {\n  return (\n    <div aria-hidden className={cn(\"absolute inset-0\", hues[hue].wash)}>\n      <div className={cn(\"absolute -top-1/3 -left-1/4 h-full w-3/4 rounded-full blur-3xl\", hues[hue].glowA)} />\n      <div className={cn(\"absolute -right-1/4 -bottom-1/2 h-full w-3/4 rounded-full blur-3xl\", hues[hue].glowB)} />\n    </div>\n  );\n}\n\nfunction TileAvatar({ person, live, speaking, compact }: { person: CallPerson; live: boolean; speaking: boolean; compact?: boolean }) {\n  const reduce = useReducedMotionSafe();\n  return (\n    <div className=\"relative flex items-center justify-center\">\n      {speaking &&\n        !reduce &&\n        [0, 1].map((i) => (\n          <motion.span\n            animate={{ opacity: [0.45, 0], scale: [1, 1.45] }}\n            aria-hidden\n            className={cn(\"absolute inset-0 rounded-full\", live ? hues[person.hue].solid : \"bg-emerald-500/40\")}\n            key={i}\n            transition={{ duration: 1.6, repeat: Infinity, ease: \"easeOut\", delay: i * 0.8 }}\n          />\n        ))}\n      <span\n        className={cn(\n          \"relative flex size-12 items-center justify-center rounded-full font-semibold text-base tracking-tight\",\n          !compact && \"@[15rem]/tile:size-18 @[15rem]/tile:text-2xl @[26rem]/tile:size-22 @[26rem]/tile:text-3xl\",\n          live ? hues[person.hue].solid : hues[person.hue].avatar,\n        )}\n      >\n        {initials(person.name)}\n      </span>\n    </div>\n  );\n}\n\nfunction ScreenShare() {\n  return (\n    <div className=\"absolute inset-0 flex items-center justify-center bg-muted p-[6%]\">\n      <div className=\"flex aspect-video max-h-full w-full max-w-full flex-col gap-[5%] overflow-hidden rounded-lg border bg-card p-[4%] shadow-xs/5\">\n        <div className=\"flex items-center gap-2\">\n          <span className=\"size-2 rounded-full bg-orange-500 dark:bg-orange-400\" />\n          <span className=\"truncate font-medium text-[clamp(9px,1.6cqw,14px)]\">Onboarding v3 · flow review</span>\n        </div>\n        <div className=\"flex flex-1 items-center gap-[4%]\">\n          {[\"Welcome\", \"Workspace\", \"Invite\", \"Done\"].map((step, i) => (\n            <div className=\"flex flex-1 flex-col gap-[8%] self-stretch rounded-md border bg-background p-[4%]\" key={step}>\n              <span className=\"truncate text-[clamp(7px,1.1cqw,11px)] text-muted-foreground\">\n                {i + 1}. {step}\n              </span>\n              <span className=\"h-[10%] w-3/4 rounded-sm bg-muted\" />\n              <span className=\"h-[10%] w-1/2 rounded-sm bg-muted\" />\n              <span\n                className={cn(\n                  \"mt-auto h-[14%] rounded-sm\",\n                  i === 2 ? \"bg-orange-500/70 dark:bg-orange-400/60\" : \"bg-primary/15\",\n                )}\n              />\n            </div>\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n}\n\ntype Tile = { kind: \"person\"; person: Live; isYou: boolean } | { kind: \"screen\" };\n\nfunction tileKey(t: Tile) {\n  return t.kind === \"screen\" ? \"screen\" : t.person.id;\n}\n\nfunction useThemeRadius(scale: number) {\n  const probe = useRef<HTMLSpanElement>(null);\n  const [radius, setRadius] = useState(scale * 10);\n  useLayoutEffect(() => {\n    const el = probe.current;\n    if (!el) return;\n    const read = () => setRadius(el.offsetWidth);\n    read();\n    const observer = new ResizeObserver(read);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n  const marker = (\n    <span\n      aria-hidden\n      className=\"pointer-events-none invisible absolute h-0\"\n      ref={probe}\n      style={{ width: `calc(var(--radius) * ${scale})` }}\n    />\n  );\n  return [radius, marker] as const;\n}\n\nfunction CallTile({\n  tile,\n  speaking,\n  compact,\n  style,\n  className,\n  you,\n  ns,\n}: {\n  tile: Tile;\n  speaking: boolean;\n  compact?: boolean;\n  style?: CSSProperties;\n  className?: string;\n  you: CallPerson;\n  ns?: string;\n}) {\n  const reduce = useReducedMotionSafe();\n  const [radius, radiusProbe] = useThemeRadius(1.6);\n  const p = tile.kind === \"person\" ? tile.person : null;\n  const label = tile.kind === \"screen\" ? `${firstName(you.name)}'s screen` : tile.isYou ? \"You\" : p?.name;\n\n  return (\n    <motion.div\n      animate={{ opacity: 1, scale: 1 }}\n      aria-label={tile.kind === \"screen\" ? \"Your shared screen\" : `${p?.name}${p?.muted ? \", muted\" : \"\"}${speaking ? \", speaking\" : \"\"}`}\n      className={cn(\"relative shrink-0\", className)}\n      exit={{ opacity: 0, scale: 0.96, transition: { duration: 0.16, ease: easeOut } }}\n      initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96 }}\n      layout={!reduce && !!ns}\n      layoutId={ns ? `${ns}-${tileKey(tile)}` : undefined}\n      role=\"group\"\n      style={{ borderRadius: radius, ...style }}\n      transition={reduce ? { duration: 0.15 } : spring}\n    >\n      {radiusProbe}\n      <div className=\"@container/tile absolute inset-0 overflow-hidden rounded-[inherit] bg-muted\">\n        {tile.kind === \"screen\" ? (\n          <ScreenShare />\n        ) : p ? (\n          <>\n            {!p.cameraOff && <Ambient hue={p.hue} />}\n            <motion.div className=\"absolute inset-0 flex items-center justify-center\" layout={!reduce}>\n              <TileAvatar compact={compact} live={!p.cameraOff} person={p} speaking={speaking} />\n            </motion.div>\n          </>\n        ) : null}\n\n        {p?.hand && (\n          <motion.span\n            animate={{ opacity: 1, y: 0 }}\n            className=\"absolute top-2 left-2 flex h-6 items-center gap-1 rounded-full bg-amber-400 px-2 font-medium text-amber-950 text-xs\"\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n            layout={!reduce}\n            transition={{ duration: 0.2, ease: easeOut }}\n          >\n            <HandIcon className=\"size-3.5\" />\n            {!compact && <span className=\"hidden @[10rem]/tile:inline\">Hand raised</span>}\n          </motion.span>\n        )}\n\n        {p && (p.muted || p.cameraOff) && (\n          <motion.span className=\"absolute top-2 right-2 flex items-center gap-1\" layout={!reduce}>\n            {p.cameraOff && !compact && (\n              <span className=\"flex size-6 items-center justify-center rounded-full bg-background/85 text-muted-foreground shadow-xs/5 backdrop-blur-sm\">\n                <VideoOffIcon aria-hidden className=\"size-3.5\" />\n              </span>\n            )}\n            {p.muted && (\n              <span className=\"flex size-6 items-center justify-center rounded-full bg-background/85 text-destructive-foreground shadow-xs/5 backdrop-blur-sm\">\n                <MicOffIcon aria-hidden className=\"size-3.5\" />\n              </span>\n            )}\n          </motion.span>\n        )}\n\n        <motion.span\n          className=\"absolute bottom-2 left-2 flex h-6 max-w-[calc(100%-1rem)] items-center gap-1.5 rounded-md bg-background/85 px-2 font-medium text-foreground text-xs shadow-xs/5 backdrop-blur-sm\"\n          layout={!reduce}\n        >\n          {tile.kind === \"screen\" && <MonitorUpIcon className=\"size-3.5 shrink-0 text-muted-foreground\" />}\n          {speaking && <SpeakingBars reduce={reduce} />}\n          <span className={cn(\"truncate\", compact && \"max-w-16\")}>{label}</span>\n        </motion.span>\n      </div>\n      <motion.span\n        animate={{ opacity: speaking ? 1 : 0 }}\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 z-10 rounded-[inherit] ring-2 ring-emerald-500 ring-inset dark:ring-emerald-400\"\n        initial={false}\n        transition={{ duration: reduce ? 0 : 0.2, ease: easeOut }}\n      />\n    </motion.div>\n  );\n}\n\nfunction ControlButton({\n  label,\n  shortcut,\n  onClick,\n  tone = \"default\",\n  children,\n  badge,\n  className,\n  pressed,\n}: {\n  label: string;\n  shortcut?: string;\n  onClick?: () => void;\n  tone?: \"default\" | \"off\" | \"on\";\n  children: ReactNode;\n  badge?: number;\n  className?: string;\n  pressed?: boolean;\n}) {\n  return (\n    <Tooltip>\n      <TooltipTrigger\n        render={\n          <button\n            aria-label={label}\n            aria-pressed={pressed}\n            className={cn(\n              \"relative flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background [&_svg]:size-[18px]\",\n              press,\n              tone === \"off\" && \"bg-destructive text-white hover:bg-destructive/90\",\n              tone === \"on\" && \"bg-primary text-primary-foreground hover:bg-primary/90\",\n              tone === \"default\" && \"bg-secondary text-secondary-foreground hover:bg-accent\",\n              className,\n            )}\n            onClick={onClick}\n            type=\"button\"\n          />\n        }\n      >\n        {children}\n        <AnimatePresence>\n          {badge ? (\n            <motion.span\n              animate={{ opacity: 1, scale: 1 }}\n              className=\"absolute -top-0.5 -right-0.5 flex h-4.5 min-w-4.5 items-center justify-center rounded-full bg-primary px-1 font-medium text-[10px] text-primary-foreground tabular-nums ring-2 ring-background\"\n              exit={{ opacity: 0, scale: 0.9 }}\n              initial={{ opacity: 0, scale: 0.9 }}\n              transition={{ duration: 0.15, ease: easeOut }}\n            >\n              {badge}\n            </motion.span>\n          ) : null}\n        </AnimatePresence>\n      </TooltipTrigger>\n      <TooltipPopup className=\"flex items-center gap-2\" side=\"top\" sideOffset={8}>\n        <span className=\"flex items-center gap-2\">\n          {label}\n          {shortcut && <Kbd className=\"h-4 min-w-4 text-[10px]\">{shortcut}</Kbd>}\n        </span>\n      </TooltipPopup>\n    </Tooltip>\n  );\n}\n\nconst MICS = [\"Studio Display microphone\", \"MacBook Pro microphone\", \"AirPods Pro\"];\nconst CAMERAS = [\"FaceTime HD camera\", \"Studio Display camera\"];\n\nfunction DeviceSplit({ kind, devices, children }: { kind: string; devices: string[]; children: ReactNode }) {\n  const [device, setDevice] = useState(devices[0]);\n  return (\n    <div className=\"flex shrink-0 items-center rounded-full bg-secondary\">\n      {children}\n      <Menu>\n        <MenuTrigger\n          aria-label={`${kind} settings`}\n          className={cn(\n            \"-ms-0.5 hidden h-10 w-7 cursor-pointer items-center justify-center rounded-e-full pe-1 text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-popup-open:text-foreground @md:flex [&_svg]:size-4\",\n          )}\n        >\n          <ChevronUpIcon />\n        </MenuTrigger>\n        <MenuPopup align=\"start\" className={cn(\"w-60\", menuPop)} side=\"top\" sideOffset={10}>\n          <MenuGroup>\n            <MenuGroupLabel>{kind}</MenuGroupLabel>\n            <MenuRadioGroup onValueChange={(v) => setDevice(v as string)} value={device}>\n              {devices.map((d) => (\n                <MenuRadioItem key={d} value={d}>\n                  {d}\n                </MenuRadioItem>\n              ))}\n            </MenuRadioGroup>\n          </MenuGroup>\n        </MenuPopup>\n      </Menu>\n    </div>\n  );\n}\n\ntype Reaction = { id: number; emoji: string; name: string; x: number };\ntype Toast = { id: number; text: string; person?: CallPerson; icon?: ReactNode };\n\nexport function VideoCall({\n  className,\n  title = \"Design crit · Onboarding v3\",\n  you = defaultYou,\n  participants = defaultParticipants,\n  dropIns = defaultDropIns,\n  messages: initialMessages = defaultMessages,\n  scriptedMessages = defaultScript,\n  elapsedSeconds = 1453,\n  autoplay = true,\n  startTime = \"10:20\",\n  meetingCode = \"kst-wqpf-ndr\",\n}: VideoCallProps) {\n  const reduce = useReducedMotionSafe();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const chatEndRef = useRef<HTMLDivElement>(null);\n  const sheetRef = useRef<HTMLElement>(null);\n  const counter = useRef(0);\n\n  const [people, setPeople] = useState<Record<string, Live>>(() =>\n    Object.fromEntries([you, ...participants, ...dropIns].map((p) => [p.id, { ...p }])),\n  );\n  const [inCall, setInCall] = useState<string[]>(() => [...participants.map((p) => p.id), you.id]);\n  const [speakerId, setSpeakerId] = useState<string | null>(participants.find((p) => !p.muted)?.id ?? null);\n  const [layout, setLayout] = useState<\"grid\" | \"spotlight\">(\"grid\");\n  const [panel, setPanel] = useState<null | \"chat\" | \"people\">(null);\n  const [messages, setMessages] = useState(initialMessages);\n  const [unread, setUnread] = useState(0);\n  const [draft, setDraft] = useState(\"\");\n  const [reactions, setReactions] = useState<Reaction[]>([]);\n  const [toast, setToast] = useState<Toast | null>(null);\n  const [elapsed, setElapsed] = useState(elapsedSeconds);\n  const [sharing, setSharing] = useState(false);\n  const [left, setLeft] = useState(false);\n  const [feedback, setFeedback] = useState<null | \"up\" | \"down\">(null);\n  const [reactOpen, setReactOpen] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const [wide, setWide] = useState(true);\n\n  const me = people[you.id];\n  const nextId = () => {\n    counter.current += 1;\n    return counter.current;\n  };\n\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => setWide(entry.contentRect.width >= 896));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  const showToast = (t: Omit<Toast, \"id\">) => setToast({ ...t, id: nextId() });\n\n  useEffect(() => {\n    if (!toast) return;\n    const t = setTimeout(() => setToast(null), 2600);\n    return () => clearTimeout(t);\n  }, [toast]);\n\n  useEffect(() => {\n    if (!copied) return;\n    const t = setTimeout(() => setCopied(false), 1800);\n    return () => clearTimeout(t);\n  }, [copied]);\n\n  const addReaction = (emoji: string, name: string) => {\n    const r = { id: nextId(), emoji, name, x: 8 + Math.random() * 30 };\n    setReactions((all) => [...all.slice(-7), r]);\n  };\n\n  const tickRef = useRef(0);\n  const state = useRef({ inCall, people, panel });\n  const elapsedRef = useRef(elapsed);\n  elapsedRef.current = elapsed;\n  state.current = { inCall, people, panel };\n\n  useEffect(() => {\n    if (left) return;\n    const t = setInterval(() => {\n      setElapsed((e) => e + 1);\n      if (!autoplay) return;\n      tickRef.current += 1;\n      const tick = tickRef.current;\n      const { inCall: ids, people: ppl, panel: openPanel } = state.current;\n\n      if (tick % 3 === 0) {\n        const talkers = ids.filter((id) => id !== you.id && !ppl[id]?.muted);\n        if (talkers.length) {\n          setSpeakerId((cur) => {\n            const pool = talkers.filter((id) => id !== cur);\n            return pool.length ? pool[Math.floor(Math.random() * pool.length)] : talkers[0];\n          });\n        } else setSpeakerId(null);\n      }\n\n      if (tick % 8 === 4 && dropIns.length) {\n        const step = dropScript[Math.floor(tick / 8) % dropScript.length];\n        const person = dropIns[step.index % dropIns.length];\n        if (step.op === \"join\" && !ids.includes(person.id)) {\n          setInCall((cur) => [...cur.filter((id) => id !== you.id), person.id, you.id]);\n          showToast({ text: `${firstName(person.name)} joined`, person });\n        } else if (step.op === \"leave\" && ids.includes(person.id)) {\n          setInCall((cur) => cur.filter((id) => id !== person.id));\n          setSpeakerId((cur) => (cur === person.id ? null : cur));\n          showToast({ text: `${firstName(person.name)} left`, person });\n        }\n      }\n\n      if (tick % 5 === 2) {\n        const others = ids.filter((id) => id !== you.id);\n        const who = ppl[others[Math.floor(Math.random() * others.length)]];\n        if (who) addReaction(REACTIONS[Math.floor(Math.random() * 5)], firstName(who.name));\n      }\n\n      const line = tick % 14 === 10 ? scriptedMessages[Math.floor(tick / 14)] : undefined;\n      if (line && ids.includes(line.authorId)) {\n        setMessages((m) => [...m, { id: `s${tick}`, authorId: line.authorId, text: line.text, time: timeLabel(startTime, elapsedRef.current) }]);\n        if (openPanel !== \"chat\") setUnread((u) => u + 1);\n      }\n    }, 1000);\n    return () => clearInterval(t);\n  }, [left, autoplay]);\n\n  const sheetOpen = !wide && !!panel && !left;\n  useEffect(() => {\n    if (sheetOpen) sheetRef.current?.focus({ preventScroll: true });\n  }, [sheetOpen]);\n\n  useEffect(() => {\n    if (panel === \"chat\") {\n      setUnread(0);\n      const box = chatEndRef.current?.parentElement;\n      box?.scrollTo({ top: box.scrollHeight });\n    }\n  }, [panel, messages.length]);\n\n  const patchMe = (patch: Partial<Live>) => setPeople((p) => ({ ...p, [you.id]: { ...p[you.id], ...patch } }));\n  const toggleMic = () => patchMe({ muted: !me.muted });\n  const toggleCam = () => patchMe({ cameraOff: !me.cameraOff });\n  const toggleHand = () => {\n    patchMe({ hand: !me.hand });\n    if (!me.hand) showToast({ text: \"You raised your hand\", icon: <HandIcon className=\"size-3.5\" /> });\n  };\n  const toggleShare = () => {\n    setSharing((s) => !s);\n    if (!sharing) {\n      setLayout(\"spotlight\");\n      showToast({ text: \"You're presenting to everyone\", icon: <MonitorUpIcon className=\"size-3.5\" /> });\n    } else setLayout(\"grid\");\n  };\n  const muteAll = () => {\n    setPeople((p) =>\n      Object.fromEntries(Object.entries(p).map(([id, v]) => [id, id === you.id ? v : { ...v, muted: true }])),\n    );\n    setSpeakerId(null);\n    showToast({ text: \"Everyone else is muted\", icon: <MicOffIcon className=\"size-3.5\" /> });\n  };\n  const removePerson = (id: string) => {\n    setInCall((cur) => cur.filter((x) => x !== id));\n    setSpeakerId((cur) => (cur === id ? null : cur));\n    showToast({ text: `${firstName(people[id].name)} was removed`, person: people[id] });\n  };\n  const send = () => {\n    const text = draft.trim();\n    if (!text) return;\n    setMessages((m) => [...m, { id: `u${nextId()}`, authorId: you.id, text, time: timeLabel(startTime, elapsed) }]);\n    setDraft(\"\");\n  };\n  const leave = () => {\n    setLeft(true);\n    setPanel(null);\n    setSharing(false);\n    setReactions([]);\n    setToast(null);\n  };\n  const rejoin = () => {\n    setLeft(false);\n    setFeedback(null);\n    setLayout(\"grid\");\n  };\n\n  const ordered = [...inCall].sort((a, b) => Number(!!people[b]?.hand) - Number(!!people[a]?.hand));\n  const tiles: Tile[] = [\n    ...(sharing ? [{ kind: \"screen\" } as Tile] : []),\n    ...ordered.map((id) => ({ kind: \"person\", person: people[id], isYou: id === you.id }) as Tile),\n  ];\n  const shape = gridShape(tiles.length);\n  const spotKey = sharing ? \"screen\" : speakerId && inCall.includes(speakerId) ? speakerId : ordered[0];\n  const spotTile = tiles.find((t) => tileKey(t) === spotKey) ?? tiles[0];\n  const stripTiles = tiles.filter((t) => t !== spotTile);\n  const host = participants.find((p) => p.host);\n\n  const panelBody =\n    panel === \"chat\" ? (\n      <div className=\"flex min-h-0 flex-1 flex-col\">\n        <div className=\"min-h-0 flex-1 overflow-y-auto px-4 py-3\">\n          {messages.length === 0 ? (\n            <div className=\"flex h-full flex-col items-center justify-center gap-2 px-6 text-center\">\n              <span className=\"flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground\">\n                <MessageSquareIcon className=\"size-4.5\" />\n              </span>\n              <span className=\"font-medium\">No messages yet</span>\n              <span className=\"text-pretty text-muted-foreground text-xs\">\n                Only people in the call can see chat. It disappears when the call ends.\n              </span>\n            </div>\n          ) : (\n            <ul className=\"flex flex-col gap-4\">\n              <AnimatePresence initial={false}>\n                {messages.map((m, i) => {\n                  const author = people[m.authorId];\n                  const grouped = messages[i - 1]?.authorId === m.authorId;\n                  return (\n                    <motion.li\n                      animate={{ opacity: 1, y: 0 }}\n                      className={cn(\"flex gap-2.5\", grouped && \"-mt-3\")}\n                      initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6 }}\n                      key={m.id}\n                      transition={{ duration: 0.2, ease: easeOut }}\n                    >\n                      {grouped ? (\n                        <span className=\"w-7 shrink-0\" />\n                      ) : author ? (\n                        <PersonAvatar person={author} />\n                      ) : null}\n                      <div className=\"flex min-w-0 flex-col gap-0.5\">\n                        {!grouped && (\n                          <span className=\"flex items-baseline gap-2\">\n                            <span className=\"font-medium text-xs\">\n                              {m.authorId === you.id ? \"You\" : author?.name}\n                            </span>\n                            <span className=\"text-muted-foreground text-xs tabular-nums\">{m.time}</span>\n                          </span>\n                        )}\n                        <p className=\"text-pretty break-words\">{m.text}</p>\n                      </div>\n                    </motion.li>\n                  );\n                })}\n              </AnimatePresence>\n            </ul>\n          )}\n          <div ref={chatEndRef} />\n        </div>\n        <form\n          className=\"border-t p-3\"\n          onSubmit={(e) => {\n            e.preventDefault();\n            send();\n          }}\n        >\n          <InputGroup>\n            <InputGroupInput\n              aria-label=\"Message everyone\"\n              onChange={(e) => setDraft(e.target.value)}\n              placeholder=\"Message everyone\"\n              value={draft}\n            />\n            <InputGroupAddon align=\"inline-end\">\n              <Button aria-label=\"Send message\" disabled={!draft.trim()} size=\"icon-xs\" type=\"submit\" variant=\"ghost\">\n                <SendHorizontalIcon />\n              </Button>\n            </InputGroupAddon>\n          </InputGroup>\n        </form>\n      </div>\n    ) : (\n      <div className=\"flex min-h-0 flex-1 flex-col\">\n        <div className=\"flex items-center justify-between px-4 pt-3 pb-1\">\n          <span className=\"font-medium text-muted-foreground text-xs\">\n            In call · <span className=\"tabular-nums\">{inCall.length}</span>\n          </span>\n          <Button className={press} onClick={muteAll} size=\"xs\" variant=\"outline\">\n            <MicOffIcon /> Mute all\n          </Button>\n        </div>\n        <ul className=\"min-h-0 flex-1 overflow-y-auto px-2 py-1\">\n          <AnimatePresence initial={false}>\n            {ordered.map((id) => {\n              const p = people[id];\n              const isYou = id === you.id;\n              return (\n                <motion.li\n                  animate={{ opacity: 1 }}\n                  className=\"flex items-center gap-3 rounded-lg px-2 py-2\"\n                  exit={{ opacity: 0, transition: { duration: 0.12 } }}\n                  initial={{ opacity: 0 }}\n                  key={id}\n                  layout={reduce ? false : \"position\"}\n                  transition={spring}\n                >\n                  <PersonAvatar person={p} size={8} />\n                  <div className=\"flex min-w-0 flex-1 flex-col\">\n                    <span className=\"flex items-center gap-1.5 truncate font-medium\">\n                      <span className=\"truncate\">{p.name}</span>\n                      {isYou && <span className=\"font-normal text-muted-foreground text-xs\">you</span>}\n                      {p.host && (\n                        <span className=\"rounded-full bg-muted px-1.5 py-px font-medium text-[10px] text-muted-foreground\">\n                          Host\n                        </span>\n                      )}\n                    </span>\n                    <span className=\"truncate text-muted-foreground text-xs\">{p.title}</span>\n                  </div>\n                  <span className=\"flex items-center gap-1.5 text-muted-foreground [&_svg]:size-4\">\n                    {p.hand && <HandIcon aria-label=\"Hand raised\" className=\"text-amber-500 dark:text-amber-400\" />}\n                    {p.cameraOff && <VideoOffIcon aria-label=\"Camera off\" />}\n                    {p.muted ? (\n                      <MicOffIcon aria-label=\"Muted\" className=\"text-destructive-foreground\" />\n                    ) : speakerId === id ? (\n                      <span className=\"flex size-4 items-center justify-center\">\n                        <SpeakingBars reduce={reduce} />\n                      </span>\n                    ) : (\n                      <MicIcon aria-label=\"Mic on\" />\n                    )}\n                  </span>\n                  {!isYou && (\n                    <Menu>\n                      <MenuTrigger\n                        aria-label={`Options for ${p.name}`}\n                        render={<Button className=\"-me-1\" size=\"icon-sm\" variant=\"ghost\" />}\n                      >\n                        <EllipsisIcon />\n                      </MenuTrigger>\n                      <MenuPopup align=\"end\" className={cn(\"w-44\", menuPop)}>\n                        <MenuItem\n                          disabled={p.muted}\n                          onClick={() => setPeople((all) => ({ ...all, [id]: { ...all[id], muted: true } }))}\n                        >\n                          <MicOffIcon /> Mute\n                        </MenuItem>\n                        <MenuItem onClick={() => setSpeakerId(id)}>\n                          <PresentationIcon /> Spotlight\n                        </MenuItem>\n                        <MenuSeparator />\n                        <MenuItem onClick={() => removePerson(id)} variant=\"destructive\">\n                          <XIcon /> Remove from call\n                        </MenuItem>\n                      </MenuPopup>\n                    </Menu>\n                  )}\n                </motion.li>\n              );\n            })}\n          </AnimatePresence>\n        </ul>\n        <div className=\"border-t p-3\">\n          <Button className={cn(\"w-full\", press)} onClick={() => setCopied(true)} variant=\"outline\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              <motion.span\n                animate={{ opacity: 1, scale: 1 }}\n                className=\"flex items-center gap-2\"\n                exit={{ opacity: 0, scale: 0.95 }}\n                initial={{ opacity: 0, scale: 0.95 }}\n                key={copied ? \"copied\" : \"copy\"}\n                transition={{ duration: 0.15, ease: easeOut }}\n              >\n                {copied ? <CheckIcon className=\"size-4\" /> : <CopyIcon className=\"size-4\" />}\n                {copied ? \"Link copied\" : \"Copy invite link\"}\n              </motion.span>\n            </AnimatePresence>\n          </Button>\n        </div>\n      </div>\n    );\n\n  return (\n    <TooltipProvider delay={500}>\n      <div\n        className={cn(\n          \"@container relative isolate flex h-[760px] w-full flex-col overflow-hidden bg-background text-foreground text-sm\",\n          className,\n        )}\n        onKeyDown={(e) => {\n          if (e.key === \"Escape\" && panel && !wide) setPanel(null);\n          const target = e.target as HTMLElement;\n          if (left || e.metaKey || e.ctrlKey || e.altKey || target.closest(\"input, textarea\")) return;\n          if (e.key === \"m\") toggleMic();\n          if (e.key === \"v\") toggleCam();\n        }}\n        ref={rootRef}\n      >\n        <header className=\"flex h-14 shrink-0 items-center gap-3 px-4\">\n          <div className=\"flex min-w-0 flex-1 items-center gap-3\">\n            <div className=\"flex min-w-0 flex-col\">\n              <span className=\"truncate font-heading font-semibold\">{title}</span>\n              <span className=\"flex items-center gap-1.5 text-muted-foreground text-xs\">\n                <span className=\"tabular-nums\">{timeLabel(startTime, elapsed)}</span>\n                <span aria-hidden>·</span>\n                <span className=\"truncate\">\n                  {left ? \"You left\" : <><span className=\"tabular-nums\">{inCall.length}</span> in call</>}\n                </span>\n              </span>\n            </div>\n            {!left && (\n              <span className=\"flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-destructive/10 px-2 font-medium text-destructive-foreground text-xs tabular-nums\">\n                <span className=\"relative flex size-1.5\">\n                  {!reduce && <span className=\"absolute inset-0 animate-ping rounded-full bg-destructive/60\" />}\n                  <span className=\"relative size-1.5 rounded-full bg-destructive\" />\n                </span>\n                {clock(elapsed)}\n              </span>\n            )}\n          </div>\n          {!left && (\n            <div className=\"flex items-center gap-2\">\n              <div aria-label=\"Layout\" className=\"relative hidden h-8 items-center rounded-lg bg-muted p-0.5 @md:flex\" role=\"radiogroup\">\n                {(\n                  [\n                    { value: \"grid\", label: \"Grid\", icon: <LayoutGridIcon /> },\n                    { value: \"spotlight\", label: \"Spotlight\", icon: <PresentationIcon /> },\n                  ] as const\n                ).map((o) => (\n                  <button\n                    aria-checked={layout === o.value}\n                    aria-label={`${o.label} layout`}\n                    className=\"relative flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2.5 font-medium text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5\"\n                    key={o.value}\n                    onClick={() => setLayout(o.value)}\n                    role=\"radio\"\n                    type=\"button\"\n                  >\n                    {layout === o.value && (\n                      <motion.span\n                        className=\"absolute inset-0 rounded-md bg-background shadow-xs/5 dark:bg-input\"\n                        layoutId=\"vc-layout-pill\"\n                        transition={reduce ? { duration: 0 } : spring}\n                      />\n                    )}\n                    <span\n                      className={cn(\n                        \"relative flex items-center gap-1.5 transition-colors\",\n                        layout === o.value ? \"text-foreground\" : \"text-muted-foreground\",\n                      )}\n                    >\n                      {o.icon}\n                      <span className=\"hidden @3xl:inline\">{o.label}</span>\n                    </span>\n                  </button>\n                ))}\n              </div>\n            </div>\n          )}\n        </header>\n\n        <div className=\"flex min-h-0 flex-1 gap-3 px-3 pb-0 @md:px-4\">\n          <LayoutGroup id=\"vc-stage\">\n            <section aria-label=\"Participants\" className=\"@container/stage relative min-w-0 flex-1\">\n              {left ? (\n                <motion.div\n                  animate={{ opacity: 1, y: 0 }}\n                  className=\"flex h-full flex-col items-center justify-center gap-6 rounded-2xl border bg-card px-6 text-center\"\n                  initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8 }}\n                  transition={{ duration: 0.25, ease: easeOut }}\n                >\n                  <span className=\"flex size-12 items-center justify-center rounded-2xl bg-muted text-muted-foreground\">\n                    <PhoneOffIcon className=\"size-5\" />\n                  </span>\n                  <div className=\"flex flex-col gap-1\">\n                    <h2 className=\"text-balance font-heading font-semibold text-lg\">You left the call</h2>\n                    <p className=\"text-muted-foreground\">\n                      {title} · <span className=\"tabular-nums\">{clock(elapsed)}</span>\n                    </p>\n                  </div>\n                  <Button className={press} onClick={rejoin}>\n                    Rejoin\n                  </Button>\n                  <div className=\"flex min-h-9 flex-col items-center gap-2\">\n                    <AnimatePresence initial={false} mode=\"popLayout\">\n                      {feedback ? (\n                        <motion.span\n                          animate={{ opacity: 1, scale: 1 }}\n                          className=\"flex h-9 items-center gap-1.5 text-muted-foreground text-xs\"\n                          initial={{ opacity: 0, scale: 0.97 }}\n                          key=\"thanks\"\n                          transition={{ duration: 0.2, ease: easeOut }}\n                        >\n                          <CheckIcon className=\"size-3.5 text-success-foreground\" /> Thanks, that helps us tune call quality.\n                        </motion.span>\n                      ) : (\n                        <motion.div\n                          className=\"flex items-center gap-2 text-muted-foreground text-xs\"\n                          exit={{ opacity: 0, scale: 0.97, transition: { duration: 0.12 } }}\n                          key=\"ask\"\n                        >\n                          How was the audio and video?\n                          <Button aria-label=\"Good\" className={press} onClick={() => setFeedback(\"up\")} size=\"icon-sm\" variant=\"outline\">\n                            <ThumbsUpIcon />\n                          </Button>\n                          <Button aria-label=\"Poor\" className={press} onClick={() => setFeedback(\"down\")} size=\"icon-sm\" variant=\"outline\">\n                            <ThumbsDownIcon />\n                          </Button>\n                        </motion.div>\n                      )}\n                    </AnimatePresence>\n                  </div>\n                </motion.div>\n              ) : (\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  <motion.div\n                    animate={{ opacity: 1, scale: 1 }}\n                    className=\"size-full\"\n                    exit={{ opacity: 0, transition: { duration: 0.12, ease: easeOut } }}\n                    initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.985 }}\n                    key={layout}\n                    transition={{ duration: 0.2, ease: easeOut }}\n                  >\n                    {layout === \"grid\" ? (\n                      <div\n                        className=\"flex h-full flex-wrap content-center justify-center gap-2 [--cc:var(--cs)] [--rr:var(--rs)] @xl/stage:[--cc:var(--c)] @xl/stage:[--rr:var(--r)]\"\n                        style={{ \"--c\": shape.c, \"--r\": shape.r, \"--cs\": shape.cs, \"--rs\": shape.rs } as CSSProperties}\n                      >\n                        <AnimatePresence initial={false} mode=\"popLayout\">\n                          {tiles.map((t) => (\n                            <CallTile\n                              key={tileKey(t)}\n                              ns=\"grid\"\n                              speaking={t.kind === \"person\" && t.person.id === speakerId && !t.person.muted}\n                              style={{\n                                width: \"calc((100% - (var(--cc) - 1) * var(--spacing) * 2) / var(--cc))\",\n                                height: \"calc((100% - (var(--rr) - 1) * var(--spacing) * 2) / var(--rr))\",\n                              }}\n                              tile={t}\n                              you={you}\n                            />\n                          ))}\n                        </AnimatePresence>\n                      </div>\n                    ) : (\n                      <div className=\"flex h-full flex-col gap-2\">\n                        <div className=\"relative min-h-0 flex-1\">\n                          <AnimatePresence initial={false} mode=\"popLayout\">\n                            {spotTile && (\n                              <CallTile\n                                className=\"size-full\"\n                                key={tileKey(spotTile)}\n                                speaking={spotTile.kind === \"person\" && spotTile.person.id === speakerId && !spotTile.person.muted}\n                                tile={spotTile}\n                                you={you}\n                              />\n                            )}\n                          </AnimatePresence>\n                        </div>\n                        <div className=\"-mx-1 -mb-1 flex h-26 shrink-0 justify-center-safe gap-2 overflow-x-auto p-1 [scrollbar-width:none] @xl/stage:h-30\">\n                          <AnimatePresence initial={false} mode=\"popLayout\">\n                            {stripTiles.map((t) => (\n                              <CallTile\n                                className=\"aspect-[4/3] h-full\"\n                                compact\n                                key={tileKey(t)}\n                                ns=\"strip\"\n                                speaking={t.kind === \"person\" && t.person.id === speakerId && !t.person.muted}\n                                tile={t}\n                                you={you}\n                              />\n                            ))}\n                          </AnimatePresence>\n                        </div>\n                      </div>\n                    )}\n                  </motion.div>\n                </AnimatePresence>\n              )}\n\n              <div aria-hidden className=\"pointer-events-none absolute inset-0 z-20 overflow-hidden rounded-2xl\">\n                <AnimatePresence>\n                  {reactions.map((r) => (\n                    <motion.div\n                      animate={\n                        reduce\n                          ? { opacity: [0, 1, 1, 0] }\n                          : { opacity: [0, 1, 1, 0], y: -260, x: [0, 10, -6, 4], scale: [0.9, 1.05, 1, 1] }\n                      }\n                      className=\"absolute bottom-3 flex flex-col items-center gap-1\"\n                      initial={{ opacity: 0, y: 0, scale: 0.9 }}\n                      key={r.id}\n                      onAnimationComplete={() => setReactions((all) => all.filter((x) => x.id !== r.id))}\n                      style={{ left: `${r.x}%` }}\n                      transition={{ duration: reduce ? 1.6 : 2.4, ease: easeOut, times: [0, 0.12, 0.7, 1] }}\n                    >\n                      <span className=\"text-3xl leading-none drop-shadow-sm\">{r.emoji}</span>\n                      <span className=\"rounded-md bg-background/85 px-1.5 py-px font-medium text-[10px] text-foreground shadow-xs/5 backdrop-blur-sm\">{r.name}</span>\n                    </motion.div>\n                  ))}\n                </AnimatePresence>\n              </div>\n\n              <div aria-live=\"polite\" className=\"pointer-events-none absolute inset-x-0 top-3 z-30 flex justify-center px-3\">\n                <AnimatePresence mode=\"popLayout\">\n                  {toast && (\n                    <motion.div\n                      animate={{ opacity: 1, y: 0, scale: 1 }}\n                      className=\"flex h-8 max-w-full items-center gap-2 rounded-full border bg-popover ps-1 pe-3 text-popover-foreground text-xs shadow-lg/5\"\n                      exit={{ opacity: 0, y: -4, scale: 0.97, transition: { duration: 0.15, ease: easeOut } }}\n                      initial={reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.97 }}\n                      key={toast.id}\n                      transition={{ duration: 0.22, ease: easeOut }}\n                    >\n                      {toast.person ? (\n                        <PersonAvatar person={toast.person} size={6} />\n                      ) : (\n                        <span className=\"flex size-6 items-center justify-center rounded-full bg-muted text-muted-foreground\">\n                          {toast.icon}\n                        </span>\n                      )}\n                      <span className=\"truncate font-medium\">{toast.text}</span>\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </div>\n            </section>\n          </LayoutGroup>\n\n          <AnimatePresence initial={false}>\n            {wide && panel && !left && (\n              <motion.aside\n                animate={{ opacity: 1, x: 0 }}\n                aria-label={panel === \"chat\" ? \"Chat\" : \"People\"}\n                className=\"flex w-80 shrink-0 flex-col overflow-hidden rounded-2xl border bg-card\"\n                exit={{ opacity: 0, x: 16, transition: { duration: 0.15, ease: easeOut } }}\n                initial={reduce ? { opacity: 0 } : { opacity: 0, x: 16 }}\n                key=\"dock\"\n                transition={{ duration: 0.22, ease: easeOut }}\n              >\n                <PanelHeader messages={messages.length} onClose={() => setPanel(null)} onTab={setPanel} panel={panel} people={inCall.length} />\n                {panelBody}\n              </motion.aside>\n            )}\n          </AnimatePresence>\n        </div>\n\n        <footer className=\"flex h-[72px] shrink-0 items-center gap-3 px-4\">\n          <div className=\"hidden min-w-0 flex-1 items-center gap-2 text-muted-foreground text-xs @4xl:flex\">\n            <button\n              className=\"flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-2 font-mono outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n              onClick={() => setCopied(true)}\n              type=\"button\"\n            >\n              {copied ? <CheckIcon className=\"size-3.5 text-success-foreground\" /> : <CopyIcon className=\"size-3.5\" />}\n              {meetingCode}\n            </button>\n            <span className=\"truncate\">\n              Hosted by {host ? (host.id === you.id ? \"you\" : firstName(host.name)) : \"you\"}\n            </span>\n          </div>\n          {left ? (\n            <div className=\"flex-1\" />\n          ) : (\n            <div className=\"mx-auto flex items-center gap-2 @4xl:mx-0\" role=\"toolbar\" aria-label=\"Call controls\">\n              <DeviceSplit devices={MICS} kind=\"Microphone\">\n                <ControlButton\n                  className={me.muted ? undefined : \"bg-transparent\"}\n                  label={me.muted ? \"Unmute\" : \"Mute\"}\n                  onClick={toggleMic}\n                  pressed={me.muted}\n                  shortcut=\"M\"\n                  tone={me.muted ? \"off\" : \"default\"}\n                >\n                  {me.muted ? <MicOffIcon /> : <MicIcon />}\n                </ControlButton>\n              </DeviceSplit>\n              <DeviceSplit devices={CAMERAS} kind=\"Camera\">\n                <ControlButton\n                  className={me.cameraOff ? undefined : \"bg-transparent\"}\n                  label={me.cameraOff ? \"Turn camera on\" : \"Turn camera off\"}\n                  onClick={toggleCam}\n                  pressed={me.cameraOff}\n                  shortcut=\"V\"\n                  tone={me.cameraOff ? \"off\" : \"default\"}\n                >\n                  {me.cameraOff ? <VideoOffIcon /> : <VideoIcon />}\n                </ControlButton>\n              </DeviceSplit>\n              <ControlButton\n                className=\"hidden @md:flex\"\n                label={sharing ? \"Stop presenting\" : \"Present screen\"}\n                onClick={toggleShare}\n                pressed={sharing}\n                tone={sharing ? \"on\" : \"default\"}\n              >\n                <MonitorUpIcon />\n              </ControlButton>\n              <Popover onOpenChange={setReactOpen} open={reactOpen}>\n                <PopoverTrigger\n                  aria-label=\"Send a reaction\"\n                  className={cn(\n                    \"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full bg-secondary text-secondary-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-popup-open:bg-accent [&_svg]:size-[18px]\",\n                    press,\n                  )}\n                >\n                  <SmilePlusIcon />\n                </PopoverTrigger>\n                <PopoverPopup className={cn(\"rounded-full before:rounded-full\", menuPop)} side=\"top\" sideOffset={10} tooltipStyle>\n                  <div aria-label=\"Reactions\" className=\"flex items-center gap-0.5 py-0.5\" role=\"group\">\n                    {REACTIONS.map((emoji) => (\n                      <button\n                        aria-label={`React ${emoji}`}\n                        className=\"flex size-9 cursor-pointer items-center justify-center rounded-full text-xl outline-none transition-[background-color,scale] duration-150 ease-out hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.92]\"\n                        key={emoji}\n                        onClick={() => addReaction(emoji, \"You\")}\n                        type=\"button\"\n                      >\n                        {emoji}\n                      </button>\n                    ))}\n                  </div>\n                </PopoverPopup>\n              </Popover>\n              <ControlButton\n                className=\"hidden @md:flex\"\n                label={me.hand ? \"Lower hand\" : \"Raise hand\"}\n                onClick={toggleHand}\n                pressed={!!me.hand}\n                tone={me.hand ? \"on\" : \"default\"}\n              >\n                <HandIcon />\n              </ControlButton>\n              <ControlButton\n                badge={panel === \"chat\" ? 0 : unread}\n                className=\"@4xl:hidden\"\n                label=\"Chat\"\n                onClick={() => setPanel(panel === \"chat\" ? null : \"chat\")}\n                pressed={panel === \"chat\"}\n                tone={panel === \"chat\" ? \"on\" : \"default\"}\n              >\n                <MessageSquareIcon />\n              </ControlButton>\n              <Menu>\n                <MenuTrigger\n                  aria-label=\"More options\"\n                  className={cn(\n                    \"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full bg-secondary text-secondary-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-popup-open:bg-accent [&_svg]:size-[18px]\",\n                    press,\n                  )}\n                >\n                  <EllipsisIcon />\n                </MenuTrigger>\n                <MenuPopup align=\"center\" className={cn(\"w-52\", menuPop)} side=\"top\" sideOffset={10}>\n                  <div className=\"@md:hidden\">\n                    <MenuItem onClick={toggleShare}>\n                      <MonitorUpIcon /> {sharing ? \"Stop presenting\" : \"Present screen\"}\n                    </MenuItem>\n                    <MenuItem onClick={toggleHand}>\n                      <HandIcon /> {me.hand ? \"Lower hand\" : \"Raise hand\"}\n                    </MenuItem>\n                  </div>\n                  <MenuItem onClick={() => setPanel(\"people\")}>\n                    <UsersIcon /> People\n                  </MenuItem>\n                  <MenuSeparator />\n                  <MenuGroup>\n                    <MenuGroupLabel>Layout</MenuGroupLabel>\n                    <MenuRadioGroup onValueChange={(v) => setLayout(v as \"grid\" | \"spotlight\")} value={layout}>\n                      <MenuRadioItem value=\"grid\">Grid</MenuRadioItem>\n                      <MenuRadioItem value=\"spotlight\">Spotlight</MenuRadioItem>\n                    </MenuRadioGroup>\n                  </MenuGroup>\n                </MenuPopup>\n              </Menu>\n              <Tooltip>\n                <TooltipTrigger\n                  render={\n                    <button\n                      aria-label=\"Leave call\"\n                      className={cn(\n                        \"ms-1 flex h-10 shrink-0 cursor-pointer items-center justify-center gap-2 rounded-full bg-destructive px-3.5 font-medium text-white outline-none hover:bg-destructive/90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background @md:px-4\",\n                        press,\n                      )}\n                      onClick={leave}\n                      type=\"button\"\n                    />\n                  }\n                >\n                  <PhoneOffIcon className=\"size-[18px]\" />\n                  <span className=\"hidden @md:inline\">Leave</span>\n                </TooltipTrigger>\n                <TooltipPopup side=\"top\" sideOffset={8}>\n                  Leave call\n                </TooltipPopup>\n              </Tooltip>\n            </div>\n          )}\n          <div className=\"hidden flex-1 items-center justify-end gap-2 @4xl:flex\">\n            {!left && (\n              <>\n                <ControlButton\n                  badge={panel === \"chat\" ? 0 : unread}\n                  label=\"Chat\"\n                  onClick={() => setPanel(panel === \"chat\" ? null : \"chat\")}\n                  pressed={panel === \"chat\"}\n                  tone={panel === \"chat\" ? \"on\" : \"default\"}\n                >\n                  <MessageSquareIcon />\n                </ControlButton>\n                <ControlButton\n                  label=\"People\"\n                  onClick={() => setPanel(panel === \"people\" ? null : \"people\")}\n                  pressed={panel === \"people\"}\n                  tone={panel === \"people\" ? \"on\" : \"default\"}\n                >\n                  <UsersIcon />\n                </ControlButton>\n              </>\n            )}\n          </div>\n        </footer>\n\n        <AnimatePresence>\n          {!wide && panel && !left && (\n            <>\n              <motion.div\n                animate={{ opacity: 1 }}\n                aria-hidden\n                className=\"absolute inset-0 z-40 bg-black/32\"\n                exit={{ opacity: 0 }}\n                initial={{ opacity: 0 }}\n                key=\"scrim\"\n                onClick={() => setPanel(null)}\n                transition={{ duration: 0.2, ease: easeOut }}\n              />\n              <motion.aside\n                animate={{ y: 0 }}\n                aria-label={panel === \"chat\" ? \"Chat\" : \"People\"}\n                aria-modal\n                ref={sheetRef}\n                tabIndex={-1}\n                className=\"absolute inset-x-0 top-16 bottom-0 z-50 flex flex-col overflow-hidden rounded-t-2xl border-t bg-card shadow-lg/10 outline-none\"\n                exit={{ y: \"100%\", transition: { duration: 0.2, ease: easeOut } }}\n                initial={{ y: \"100%\" }}\n                key=\"sheet\"\n                role=\"dialog\"\n                transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 42 }}\n              >\n                <PanelHeader messages={messages.length} onClose={() => setPanel(null)} onTab={setPanel} panel={panel} people={inCall.length} />\n                {panelBody}\n              </motion.aside>\n            </>\n          )}\n        </AnimatePresence>\n      </div>\n    </TooltipProvider>\n  );\n}\n\nfunction PanelHeader({\n  panel,\n  onTab,\n  onClose,\n  messages,\n  people,\n}: {\n  panel: \"chat\" | \"people\";\n  onTab: (p: \"chat\" | \"people\") => void;\n  onClose: () => void;\n  messages: number;\n  people: number;\n}) {\n  const reduce = useReducedMotionSafe();\n  return (\n    <div className=\"flex h-13 shrink-0 items-center gap-2 border-b ps-2 pe-2\">\n      <div className=\"flex items-center gap-0.5\" role=\"tablist\">\n        {(\n          [\n            { value: \"chat\", label: \"Chat\", count: messages },\n            { value: \"people\", label: \"People\", count: people },\n          ] as const\n        ).map((t) => (\n          <button\n            aria-selected={panel === t.value}\n            className=\"relative flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-2.5 font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n            key={t.value}\n            onClick={() => onTab(t.value)}\n            role=\"tab\"\n            type=\"button\"\n          >\n            {panel === t.value && (\n              <motion.span\n                className=\"absolute inset-0 rounded-lg bg-accent\"\n                layoutId=\"vc-panel-tab\"\n                transition={reduce ? { duration: 0 } : spring}\n              />\n            )}\n            <span className={cn(\"relative transition-colors\", panel === t.value ? \"text-foreground\" : \"text-muted-foreground\")}>\n              {t.label}\n            </span>\n            <span className=\"relative text-muted-foreground text-xs tabular-nums\">{t.count}</span>\n          </button>\n        ))}\n      </div>\n      <Button aria-label=\"Close panel\" className=\"ms-auto\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n        <XIcon />\n      </Button>\n    </div>\n  );\n}\n"
    }
  ]
}