{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-answer-03",
  "title": "AI Answer 03",
  "description": "An agent-style AI answer card, a researching/reading/writing step tracker with a progress rail, markdown-style bold and bullet text, clickable inline citations, source cards, follow-up questions, and custom/sunset themes.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/ai-answer-03/ai-answer-03.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\ntype RGB = [number, number, number];\ntype Phase = \"searching\" | \"writing\" | \"done\";\ntype Preview = \"auto\" | Phase;\ntype Vote = \"up\" | \"down\" | null;\ntype Source = { title: string; domain: string };\ntype Tok = { text: string; bold: boolean; cite: string | null; punct: string };\ntype Block = { kind: \"p\" | \"li\"; words: Tok[] };\ntype ThemeName = \"custom\" | \"sunset\";\n\nexport interface AiAnswer03Props {\n  preview?: Preview;\n  autoPlay?: boolean;\n  loop?: boolean;\n  loopDelay?: number;\n  stepSeconds?: number;\n  wordsPerSecond?: number;\n  showQuestion?: boolean;\n  question?: string;\n  showSteps?: boolean;\n  steps?: string[];\n  answer?: string;\n  showSources?: boolean;\n  sources?: Source[];\n  showActions?: boolean;\n  showFollowUps?: boolean;\n  followUps?: string[];\n  showTimer?: boolean;\n  searchingText?: string;\n  writingText?: string;\n  doneText?: string;\n  lang?: string;\n  font?: React.CSSProperties;\n  textColor?: string;\n  mutedColor?: string;\n  glowColors?: string[];\n  ringIntensity?: number;\n  ringSize?: number;\n  ringSpeed?: number;\n  background?: string;\n  borderColor?: string;\n  radius?: number;\n  padding?: number;\n  gap?: number;\n  theme?: ThemeName;\n  onComplete?: () => void;\n  onStop?: () => void;\n  onRegenerate?: () => void;\n  onCopy?: () => void;\n  onFollowUp?: () => void;\n  className?: string;\n  style?: React.CSSProperties;\n}\n\nconst DOTS = 3;\nconst START_ANGLE = 40;\nconst STATIC_SHIMMER = 72;\nconst TAIL = 6;\nconst EASE = \"cubic-bezier(0.2, 0.8, 0.2, 1)\";\nconst FONT_FALLBACK = \"Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif\";\nconst HAIRLINE = \"rgba(255,255,255,0.14)\";\nconst HOVER_ON = \"inset 0 0 0 999px rgba(255,255,255,0.07)\";\nconst HOVER_OFF = \"inset 0 0 0 999px rgba(255,255,255,0)\";\nconst RING = \"0 0 0 2px rgba(255,255,255,0.35)\";\nconst NO_RING = \"0 0 0 0 rgba(255,255,255,0)\";\nconst CITE = /^\\[(\\d{1,2})\\]([.,;:!?]*)$/;\nconst WHITE: RGB = [255, 255, 255];\n\nconst DEFAULT_QUESTION = \"What makes a Framer component feel premium?\";\nconst DEFAULT_STEPS = [\"Searching\", \"Reading sources\", \"Writing\"];\nconst DEFAULT_ANSWER =\n  \"Premium UI is mostly **restraint**. The best components stay calm until you touch them.\\n- **Quiet surfaces.** Dark glass, hairline borders and a single accent colour [1].\\n- **Purposeful motion.** Animate only what needs attention, like a shimmer while the model works [2].\\n- **Cheap to run.** Pause off screen, honour reduced motion and clean up every timer [3].\";\nconst DEFAULT_SOURCES: Source[] = [\n  { title: \"Building performant code components\", domain: \"framer.com\" },\n  { title: \"prefers-reduced-motion\", domain: \"developer.mozilla.org\" },\n  { title: \"Optimize animations\", domain: \"web.dev\" },\n];\nconst DEFAULT_FOLLOWUPS = [\"Show me an example\", \"How do I test it?\"];\nconst DEFAULT_GLOW = [\"#7CF3FF\", \"#6EA8FF\", \"#9B7BFF\", \"#FF7BD5\", \"#FFB86B\"];\nconst SUNSET_GLOW = [\"#FFB86B\", \"#FF7BD5\", \"#9B7BFF\"];\n\nconst SR_ONLY: React.CSSProperties = {\n  position: \"absolute\",\n  width: 1,\n  height: 1,\n  overflow: \"hidden\",\n  clip: \"rect(0 0 0 0)\",\n  whiteSpace: \"nowrap\",\n};\n\ntype Live = {\n  phase: Phase;\n  energy: number;\n  time: number;\n  spin: number;\n  angle: number;\n  ringSpeed: number;\n};\n\nfunction clamp01(v: number) {\n  return Math.min(1, Math.max(0, v));\n}\n\nfunction parseRgb(input: string, fallback: RGB): RGB {\n  const s = (input || \"\").trim();\n  if (s.startsWith(\"#\")) {\n    let h = s.slice(1);\n    if (h.length === 3 || h.length === 4)\n      h = h\n        .split(\"\")\n        .map((c) => c + c)\n        .join(\"\");\n    const n = parseInt(h.slice(0, 6), 16);\n    if (h.length >= 6 && !Number.isNaN(n)) return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n  }\n  const m = s.match(/rgba?\\(\\s*([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)/i);\n  if (m) return [Math.round(+m[1]), Math.round(+m[2]), Math.round(+m[3])];\n  return fallback;\n}\n\nfunction mixRgb(a: RGB, b: RGB, t: number): RGB {\n  return [Math.round(a[0] + (b[0] - a[0]) * t), Math.round(a[1] + (b[1] - a[1]) * t), Math.round(a[2] + (b[2] - a[2]) * t)];\n}\n\nfunction cleanList(list: string[] | undefined, fallback: string[]) {\n  const out = (list ?? []).filter((s): s is string => typeof s === \"string\" && s.trim() !== \"\");\n  return out.length ? out : fallback;\n}\n\nfunction sourceHref(domain: string) {\n  const d = domain.trim();\n  if (!d) return \"\";\n  if (/^https?:\\/\\//i.test(d)) return d;\n  return `https://${d}`;\n}\n\nfunction buildGradient(colors: string[], spread: number) {\n  const arc = Math.max(0.15, Math.min(1, spread)) * 360;\n  const n = colors.length;\n  if (n === 0) return \"linear-gradient(transparent, transparent)\";\n  const stops = colors.map((c, i) => {\n    const at = n === 1 ? 0.5 : 0.1 + (0.8 * i) / (n - 1);\n    return `${c} ${(at * arc).toFixed(1)}deg`;\n  });\n  return `conic-gradient(from var(--gl-angle, ${START_ANGLE}deg), transparent 0deg, ${stops.join(\", \")}, transparent ${arc.toFixed(1)}deg, transparent 360deg)`;\n}\n\nfunction ringStyle(width: number): React.CSSProperties {\n  return {\n    position: \"absolute\",\n    inset: 0,\n    boxSizing: \"border-box\",\n    borderRadius: \"inherit\",\n    padding: width,\n    WebkitMask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n    WebkitMaskComposite: \"xor\",\n    mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n    maskComposite: \"exclude\",\n  };\n}\n\nfunction parseAnswer(text: string): Block[] {\n  const blocks: Block[] = [];\n  for (const line of (text || \"\").split(/\\n+/)) {\n    let src = line.trim();\n    if (!src) continue;\n    let kind: Block[\"kind\"] = \"p\";\n    if (/^[-•]\\s+/.test(src)) {\n      kind = \"li\";\n      src = src.replace(/^[-•]\\s+/, \"\");\n    }\n    const words: Tok[] = [];\n    let bold = false;\n    for (const raw of src.split(/\\s+/).filter(Boolean)) {\n      let t = raw;\n      if (t.startsWith(\"**\")) {\n        bold = true;\n        t = t.slice(2);\n      }\n      const close = t.match(/\\*\\*([.,;:!?)\"']*)$/);\n      const ends = close !== null;\n      if (close) t = t.slice(0, t.length - close[0].length) + close[1];\n      if (t) {\n        const m = t.match(CITE);\n        words.push({\n          text: t,\n          bold,\n          cite: m ? m[1] : null,\n          punct: m ? m[2] : \"\",\n        });\n      }\n      if (ends) bold = false;\n    }\n    if (words.length) blocks.push({ kind, words });\n  }\n  return blocks;\n}\n\nfunction useFocusVisible() {\n  const [focusVisible, setFocusVisible] = React.useState(false);\n  return {\n    focusVisible,\n    onFocus: (e: React.FocusEvent<HTMLElement>) => {\n      try {\n        setFocusVisible(e.currentTarget.matches(\":focus-visible\"));\n      } catch {\n        setFocusVisible(true);\n      }\n    },\n    onBlur: () => setFocusVisible(false),\n  };\n}\n\nfunction subscribeReducedMotion(callback: () => void) {\n  if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return () => undefined;\n  const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  if (typeof mq.addEventListener !== \"function\") return () => undefined;\n  mq.addEventListener(\"change\", callback);\n  return () => mq.removeEventListener(\"change\", callback);\n}\nfunction getReducedMotionSnapshot() {\n  return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\nfunction getReducedMotionServerSnapshot() {\n  return false;\n}\n\ntype IconProps = { size?: number; flip?: boolean; children: React.ReactNode };\n\nfunction Icon({ size = 15, flip = false, children }: IconProps) {\n  return (\n    <svg\n      width={size}\n      height={size}\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={2}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n      style={{ display: \"block\", transform: flip ? \"scaleY(-1)\" : \"none\" }}\n    >\n      {children}\n    </svg>\n  );\n}\n\nconst CopyIcon = () => (\n  <Icon>\n    <rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" />\n    <path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\" />\n  </Icon>\n);\nconst CheckIcon = ({ size = 15, width = 2 }: { size?: number; width?: number }) => (\n  <svg\n    width={size}\n    height={size}\n    viewBox=\"0 0 24 24\"\n    fill=\"none\"\n    stroke=\"currentColor\"\n    strokeWidth={width}\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n    aria-hidden=\"true\"\n    style={{ display: \"block\" }}\n  >\n    <path d=\"M20 6 9 17l-5-5\" />\n  </svg>\n);\nconst ThumbIcon = ({ flip = false }: { flip?: boolean }) => (\n  <Icon flip={flip}>\n    <path d=\"M7 10v12\" />\n    <path d=\"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z\" />\n  </Icon>\n);\nconst RefreshIcon = () => (\n  <Icon>\n    <path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\" />\n    <path d=\"M21 3v5h-5\" />\n  </Icon>\n);\n\nconst ReplyIcon = () => (\n  <Icon size={13}>\n    <path d=\"m15 10 5 5-5 5\" />\n    <path d=\"M4 4v7a4 4 0 0 0 4 4h12\" />\n  </Icon>\n);\nconst StopIcon = () => (\n  <svg width={10} height={10} viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\" style={{ display: \"block\" }}>\n    <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"4\" />\n  </svg>\n);\n\nfunction Spark({ color, size }: { color: string; size: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" aria-hidden=\"true\" style={{ display: \"block\", overflow: \"visible\" }}>\n      <path\n        d=\"M12 1.5c.7 6.1 4.4 9.8 10.5 10.5-6.1.7-9.8 4.4-10.5 10.5-.7-6.1-4.4-9.8-10.5-10.5C7.6 11.3 11.3 7.6 12 1.5Z\"\n        fill={color}\n      />\n    </svg>\n  );\n}\n\ntype IconButtonProps = {\n  label: string;\n  onClick: () => void;\n  color: string;\n  activeColor: string;\n  toggled?: boolean;\n  children: React.ReactNode;\n};\n\nfunction IconButton({ label, onClick, color, activeColor, toggled, children }: IconButtonProps) {\n  const [hover, setHover] = React.useState(false);\n  const [pressed, setPressed] = React.useState(false);\n  const focus = useFocusVisible();\n  const release = () => setPressed(false);\n  const on = toggled === true;\n  return (\n    <button\n      type=\"button\"\n      aria-label={label}\n      aria-pressed={toggled}\n      onClick={onClick}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n      onPointerDown={() => setPressed(true)}\n      onPointerUp={release}\n      onPointerLeave={release}\n      onPointerCancel={release}\n      onFocus={focus.onFocus}\n      onBlur={focus.onBlur}\n      style={{\n        width: 30,\n        height: 30,\n        flex: \"none\",\n        margin: 0,\n        padding: 0,\n        display: \"flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        borderRadius: \"50%\",\n        border: \"1px solid transparent\",\n        background: on ? \"rgba(255,255,255,0.12)\" : \"transparent\",\n        color: on || hover ? activeColor : color,\n        cursor: \"pointer\",\n        outline: \"none\",\n        transform: pressed ? \"scale(0.92)\" : \"scale(1)\",\n        boxShadow: `${hover ? HOVER_ON : HOVER_OFF}, ${focus.focusVisible ? RING : NO_RING}`,\n        transition: \"background-color 0.25s ease, color 0.25s ease, box-shadow 0.2s ease, transform 0.15s ease\",\n      }}\n    >\n      {children}\n    </button>\n  );\n}\n\ntype PillButtonProps = {\n  label: string;\n  onClick: () => void;\n  style: React.CSSProperties;\n  color: string;\n  icon?: React.ReactNode;\n};\n\nfunction PillButton({ label, onClick, style, color, icon }: PillButtonProps) {\n  const [hover, setHover] = React.useState(false);\n  const [pressed, setPressed] = React.useState(false);\n  const focus = useFocusVisible();\n  const release = () => setPressed(false);\n  return (\n    <button\n      type=\"button\"\n      onClick={onClick}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n      onPointerDown={() => setPressed(true)}\n      onPointerUp={release}\n      onPointerLeave={release}\n      onPointerCancel={release}\n      onFocus={focus.onFocus}\n      onBlur={focus.onBlur}\n      style={{\n        ...style,\n        flex: \"none\",\n        maxWidth: \"100%\",\n        height: 30,\n        margin: 0,\n        padding: \"0 13px 0 11px\",\n        display: \"flex\",\n        alignItems: \"center\",\n        gap: 7,\n        borderRadius: 999,\n        border: `1px solid ${HAIRLINE}`,\n        background: \"rgba(255,255,255,0.04)\",\n        color,\n        cursor: \"pointer\",\n        outline: \"none\",\n        whiteSpace: \"nowrap\",\n        transform: pressed ? \"scale(0.96)\" : \"scale(1)\",\n        boxShadow: `${hover ? HOVER_ON : HOVER_OFF}, ${focus.focusVisible ? RING : NO_RING}`,\n        transition: \"box-shadow 0.2s ease, transform 0.15s ease\",\n      }}\n    >\n      {icon}\n      <span style={{ minWidth: 0, overflow: \"hidden\", textOverflow: \"ellipsis\" }}>{label}</span>\n    </button>\n  );\n}\n\nexport function AiAnswer03(props: AiAnswer03Props) {\n  const {\n    preview = \"auto\",\n    autoPlay = true,\n    loop = true,\n    loopDelay = 3.5,\n    stepSeconds = 0.9,\n    wordsPerSecond = 12,\n    showQuestion = true,\n    question = DEFAULT_QUESTION,\n    showSteps = true,\n    steps = DEFAULT_STEPS,\n    answer = DEFAULT_ANSWER,\n    showSources = true,\n    sources = DEFAULT_SOURCES,\n    showActions = true,\n    showFollowUps = true,\n    followUps = DEFAULT_FOLLOWUPS,\n    showTimer = true,\n    searchingText = \"Researching\",\n    writingText = \"Writing\",\n    doneText = \"Answer\",\n    lang = \"en\",\n    font = { fontSize: 15, lineHeight: 1.6 },\n    textColor = \"#EDEDED\",\n    mutedColor = \"#6B6B6B\",\n    glowColors = DEFAULT_GLOW,\n    ringIntensity = 0.45,\n    ringSize = 8,\n    ringSpeed = 40,\n    background = \"rgba(255,255,255,0.035)\",\n    borderColor = \"rgba(255,255,255,0.08)\",\n    radius = 28,\n    padding = 22,\n    gap = 14,\n    theme = \"custom\",\n    onComplete,\n    onStop,\n    onRegenerate,\n    onCopy,\n    onFollowUp,\n    className,\n    style,\n  } = props;\n\n  const answerId = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const bodyRef = React.useRef<HTMLDivElement>(null);\n  const sparkRef = React.useRef<HTMLDivElement>(null);\n  const ringInnerRef = React.useRef<HTMLDivElement>(null);\n  const caretRef = React.useRef<HTMLSpanElement>(null);\n  const shimmerEls = React.useRef<(HTMLElement | null)[]>([]);\n  const dotEls = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const pulseEls = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const isVisibleRef = React.useRef(true);\n  const startRef = React.useRef(0);\n  const countRef = React.useRef(0);\n  const copyTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const stepTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const writeTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const clockTimer = React.useRef<ReturnType<typeof setInterval> | null>(null);\n  const loopTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const rafRef = React.useRef(0);\n  const prevPhase = React.useRef<Phase>(autoPlay ? \"searching\" : \"done\");\n\n  const [phase, setPhase] = React.useState<Phase>(autoPlay ? \"searching\" : \"done\");\n  const [step, setStep] = React.useState(0);\n  const [count, setCount] = React.useState(0);\n  const [run, setRun] = React.useState(0);\n  const [stopped, setStopped] = React.useState(false);\n  const [copied, setCopied] = React.useState(false);\n  const [vote, setVote] = React.useState<Vote>(null);\n  const [secs, setSecs] = React.useState(0);\n  const reduce = React.useSyncExternalStore(subscribeReducedMotion, getReducedMotionSnapshot, getReducedMotionServerSnapshot);\n\n  const isSunset = theme === \"sunset\";\n  const resolvedText = isSunset ? \"#DADADA\" : textColor;\n\n  const blocks = React.useMemo(() => parseAnswer(answer), [answer]);\n  const flat = React.useMemo(() => blocks.flatMap((b) => b.words), [blocks]);\n  const total = flat.length;\n  const offsets = React.useMemo(() => {\n    const result: number[] = [];\n    let n = 0;\n    for (const b of blocks) {\n      result.push(n);\n      n += b.words.length;\n    }\n    return result;\n  }, [blocks]);\n  const stepList = React.useMemo(() => cleanList(steps, []), [steps]);\n  const nSteps = Math.max(1, stepList.length);\n  const sourceList = React.useMemo(\n    () => (sources ?? []).filter((s): s is Source => !!s && ((s.title ?? \"\").trim() !== \"\" || (s.domain ?? \"\").trim() !== \"\")),\n    [sources],\n  );\n  const followList = React.useMemo(() => cleanList(followUps, []), [followUps]);\n  const glowList = React.useMemo(() => cleanList(isSunset ? SUNSET_GLOW : glowColors, DEFAULT_GLOW), [isSunset, glowColors]);\n  const glowGradient = React.useMemo(() => buildGradient(glowList, 0.55), [glowList]);\n  const accent = React.useMemo(() => parseRgb(glowList[0], [255, 184, 107]), [glowList]);\n  const accent2 = React.useMemo(() => parseRgb(glowList[1] ?? glowList[0], [255, 123, 213]), [glowList]);\n  const textRgb = React.useMemo(() => parseRgb(resolvedText, [218, 218, 218]), [resolvedText]);\n  const boldRgb = React.useMemo(() => mixRgb(textRgb, WHITE, 0.6), [textRgb]);\n  const dimRgb = React.useMemo(() => mixRgb(parseRgb(mutedColor, [107, 107, 107]), textRgb, 0.55), [mutedColor, textRgb]);\n  const dimColor = `rgb(${dimRgb.join(\",\")})`;\n  const railGradient = `linear-gradient(90deg, ${glowList.join(\", \")})`;\n\n  const plainAnswer = React.useMemo(\n    () =>\n      blocks\n        .map((b) => (b.kind === \"li\" ? \"- \" : \"\") + b.words.map((w) => (w.cite ? `[${w.cite}]${w.punct}` : w.text)).join(\" \"))\n        .join(\"\\n\"),\n    [blocks],\n  );\n\n  const fixed: Phase | null = preview !== \"auto\" ? preview : null;\n  const shownPhase: Phase = fixed ?? (reduce ? \"done\" : phase);\n  let shownCount = count;\n  if (fixed === \"searching\") shownCount = 0;\n  else if (fixed === \"writing\") shownCount = Math.max(1, Math.round(total * 0.55));\n  else if (shownPhase === \"done\" && !stopped) shownCount = total;\n  let shownStep = step;\n  if (shownPhase === \"done\") shownStep = nSteps;\n  else if (shownPhase === \"writing\") shownStep = nSteps - 1;\n  else if (fixed === \"searching\") shownStep = Math.min(nSteps - 1, Math.floor(nSteps / 2));\n\n  const estimate = stepSeconds * (nSteps - 1) + total / Math.max(1, wordsPerSecond);\n  const wps = Math.max(1, wordsPerSecond);\n  let timerValue = secs;\n  if (fixed === \"searching\") timerValue = stepSeconds * 1.5;\n  else if (fixed === \"writing\") timerValue = stepSeconds * (nSteps - 1) + (total * 0.55) / wps;\n  else if (fixed === \"done\" || reduce) timerValue = estimate;\n\n  let railPct = 100;\n  if (shownPhase === \"searching\") railPct = ((shownStep + 0.45) / nSteps) * 100;\n  else if (shownPhase === \"writing\") railPct = ((nSteps - 1 + (total ? shownCount / total : 1)) / nSteps) * 100;\n\n  const liveRef = React.useRef<Live>({\n    phase: shownPhase,\n    energy: shownPhase === \"done\" ? 0.05 : 1,\n    time: 0,\n    spin: 0,\n    angle: START_ANGLE,\n    ringSpeed,\n  });\n  React.useLayoutEffect(() => {\n    countRef.current = count;\n    liveRef.current.phase = shownPhase;\n    liveRef.current.ringSpeed = ringSpeed;\n  });\n\n  // Prop/state-driven reset, done during render rather than in an effect: no\n  // DOM work is needed here, just adjusting local state to match a changed input.\n  const resetKey = `${String(fixed)}|${reduce}|${autoPlay}|${run}`;\n  const [prevResetKey, setPrevResetKey] = React.useState(resetKey);\n  if (prevResetKey !== resetKey) {\n    setPrevResetKey(resetKey);\n    if (fixed === null && !reduce) {\n      setStopped(false);\n      setCount(0);\n      setStep(0);\n      setVote(null);\n      setCopied(false);\n      setSecs(0);\n      setPhase(!autoPlay && run === 0 ? \"done\" : \"searching\");\n    }\n  }\n\n  React.useEffect(() => {\n    if (fixed !== null || reduce) return;\n    if (!autoPlay && run === 0) return;\n    startRef.current = performance.now();\n    const ms = Math.max(0.2, stepSeconds) * 1000;\n    let s = 0;\n    const advance = () => {\n      s += 1;\n      if (s >= nSteps - 1) {\n        setStep(nSteps - 1);\n        setPhase(\"writing\");\n        return;\n      }\n      setStep(s);\n      if (stepTimer.current) clearTimeout(stepTimer.current);\n      stepTimer.current = setTimeout(advance, ms);\n    };\n    if (stepTimer.current) clearTimeout(stepTimer.current);\n    stepTimer.current = setTimeout(advance, ms);\n    return () => {\n      if (stepTimer.current) clearTimeout(stepTimer.current);\n    };\n  }, [fixed, reduce, autoPlay, run, stepSeconds, nSteps]);\n\n  React.useEffect(() => {\n    if (fixed !== null || reduce || phase !== \"writing\" || stopped) return;\n    let n = countRef.current;\n    const period = 1000 / Math.max(1, wordsPerSecond);\n    const stepFn = () => {\n      if (!isVisibleRef.current) {\n        if (writeTimer.current) clearTimeout(writeTimer.current);\n        writeTimer.current = setTimeout(stepFn, 200);\n        return;\n      }\n      n += 1;\n      setCount(n);\n      if (n >= total) {\n        setPhase(\"done\");\n        return;\n      }\n      const w = flat[n - 1].text + flat[n - 1].punct;\n      const jitter = 0.7 + 0.6 * Math.abs(Math.sin(n * 12.9898));\n      const pause = /[.!?]$/.test(w) ? 4 : /[,;:]$/.test(w) ? 1.5 : jitter;\n      if (writeTimer.current) clearTimeout(writeTimer.current);\n      writeTimer.current = setTimeout(stepFn, period * pause);\n    };\n    if (writeTimer.current) clearTimeout(writeTimer.current);\n    writeTimer.current = setTimeout(stepFn, period);\n    return () => {\n      if (writeTimer.current) clearTimeout(writeTimer.current);\n    };\n  }, [fixed, reduce, phase, stopped, wordsPerSecond, total, flat]);\n\n  React.useEffect(() => {\n    if (fixed !== null || reduce || phase === \"done\") return;\n    if (clockTimer.current) clearInterval(clockTimer.current);\n    clockTimer.current = setInterval(() => {\n      if (isVisibleRef.current) setSecs((performance.now() - startRef.current) / 1000);\n    }, 100);\n    return () => {\n      if (clockTimer.current) clearInterval(clockTimer.current);\n    };\n  }, [fixed, reduce, phase, run]);\n\n  React.useEffect(() => {\n    const prev = prevPhase.current;\n    prevPhase.current = phase;\n    if (fixed !== null || reduce) return;\n    if (prev === \"writing\" && phase === \"done\") {\n      setSecs((performance.now() - startRef.current) / 1000);\n      if (stopped) onStop?.();\n      else onComplete?.();\n    }\n  }, [phase, fixed, reduce, stopped, onStop, onComplete]);\n\n  React.useEffect(() => {\n    if (fixed !== null || reduce || !autoPlay || !loop) return;\n    if (phase !== \"done\" || stopped) return;\n    if (loopTimer.current) clearTimeout(loopTimer.current);\n    loopTimer.current = setTimeout(() => setRun((r) => r + 1), Math.max(0.5, loopDelay) * 1000);\n    return () => {\n      if (loopTimer.current) clearTimeout(loopTimer.current);\n    };\n  }, [fixed, reduce, autoPlay, loop, phase, stopped, loopDelay]);\n\n  React.useEffect(() => {\n    return () => {\n      if (copyTimer.current) clearTimeout(copyTimer.current);\n      if (stepTimer.current) clearTimeout(stepTimer.current);\n      if (writeTimer.current) clearTimeout(writeTimer.current);\n      if (clockTimer.current) clearInterval(clockTimer.current);\n      if (loopTimer.current) clearTimeout(loopTimer.current);\n      if (rafRef.current) cancelAnimationFrame(rafRef.current);\n    };\n  }, []);\n\n  React.useEffect(() => {\n    const el = bodyRef.current;\n    if (!el || shownPhase !== \"writing\" || fixed !== null) return;\n    if (el.scrollHeight > el.clientHeight) el.scrollTop = el.scrollHeight;\n  }, [count, shownPhase, fixed]);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      ([entry]) => {\n        isVisibleRef.current = entry.isIntersecting;\n      },\n      { threshold: 0 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n\n    const updateDom = (L: Live) => {\n      const t = L.time;\n      const pos = (100 - 100 * ((t / 2.4) % 1)).toFixed(2);\n      for (const node of shimmerEls.current) if (node) node.style.backgroundPosition = `${pos}% 50%`;\n      for (let i = 0; i < dotEls.current.length; i++) {\n        const node = dotEls.current[i];\n        if (!node) continue;\n        const d = i % DOTS;\n        node.style.opacity = (0.2 + 0.7 * (0.5 + 0.5 * Math.sin(t * 4.2 - d * 0.9))).toFixed(3);\n      }\n      const p = (t * 0.9) % 1;\n      for (const node of pulseEls.current) {\n        if (!node) continue;\n        node.style.transform = `scale(${(1 + 0.9 * p).toFixed(3)})`;\n        node.style.opacity = (0.45 * (1 - p)).toFixed(3);\n      }\n      if (ringInnerRef.current) ringInnerRef.current.style.opacity = (0.55 + 0.3 * Math.sin(t * 2.2)).toFixed(3);\n      if (caretRef.current) caretRef.current.style.opacity = (0.6 + 0.4 * Math.sin(t * 5)).toFixed(3);\n      if (sparkRef.current)\n        sparkRef.current.style.transform = `rotate(${L.spin.toFixed(1)}deg) scale(${(1 + 0.14 * L.energy * Math.sin(t * 3)).toFixed(3)})`;\n    };\n\n    if (reduce) {\n      root.style.setProperty(\"--gl-angle\", `${START_ANGLE}deg`);\n      return;\n    }\n\n    let last = performance.now();\n    const frame = (now: number) => {\n      const dt = Math.min((now - last) / 1000, 0.05);\n      last = now;\n      if (isVisibleRef.current) {\n        const L = liveRef.current;\n        L.time += dt;\n        const target = L.phase === \"done\" ? 0.05 : 1;\n        L.energy += (target - L.energy) * Math.min(1, dt * 3);\n        L.spin = (L.spin + dt * (6 + 70 * L.energy)) % 360;\n        L.angle = (L.angle + L.ringSpeed * (L.phase === \"done\" ? 0.5 : 1) * dt) % 360;\n        root.style.setProperty(\"--gl-angle\", `${L.angle.toFixed(2)}deg`);\n        updateDom(L);\n      }\n      rafRef.current = requestAnimationFrame(frame);\n    };\n    rafRef.current = requestAnimationFrame(frame);\n\n    return () => cancelAnimationFrame(rafRef.current);\n  }, [reduce]);\n\n  const handleStop = () => {\n    if (fixed !== null || phase !== \"writing\") return;\n    setStopped(true);\n    setPhase(\"done\");\n  };\n  const handleRegenerate = () => {\n    if (fixed !== null) return;\n    onRegenerate?.();\n    setRun((r) => r + 1);\n  };\n  const handleCopy = () => {\n    const text = blocks\n      .map((b) => (b.kind === \"li\" ? \"- \" : \"\") + b.words.map((w) => (w.cite ? `[${w.cite}]${w.punct}` : w.text)).join(\" \"))\n      .join(\"\\n\")\n      .replace(/\\s+([.,;:!?])/g, \"$1\");\n    onCopy?.();\n    try {\n      const cb = navigator.clipboard;\n      if (cb && typeof cb.writeText === \"function\")\n        void cb.writeText(text).then(\n          () => {\n            setCopied(true);\n            if (copyTimer.current) clearTimeout(copyTimer.current);\n            copyTimer.current = setTimeout(() => setCopied(false), 1600);\n          },\n          () => undefined,\n        );\n    } catch {\n      // clipboard can be blocked inside an embedded frame\n    }\n  };\n\n  const typography: React.CSSProperties = {\n    fontFamily: FONT_FALLBACK,\n    lineHeight: 1.6,\n    ...font,\n    margin: 0,\n  };\n  const chrome: React.CSSProperties = {\n    ...typography,\n    fontSize: 13,\n    lineHeight: 1.2,\n    fontWeight: 500,\n  };\n\n  const shimmerGradient = `linear-gradient(90deg, ${mutedColor} 0%, ${mutedColor} 32%, ${resolvedText} 50%, ${mutedColor} 68%, ${mutedColor} 100%)`;\n  const barGradient =\n    \"linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.05) 35%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.05) 65%, rgba(255,255,255,0.05) 100%)\";\n  const softRing = Math.max(2, Math.min(18, ringSize * 0.45));\n  const softBlur = ringSize * 0.7;\n  const ringActive = shownPhase !== \"done\";\n  const statusLine =\n    shownPhase === \"searching\" ? searchingText : shownPhase === \"writing\" ? writingText : stopped ? \"Response stopped\" : \"Answer ready\";\n  const accentCss = accent.join(\",\");\n  const accent2Css = accent2.join(\",\");\n\n  const ringNode = (\n    <div\n      aria-hidden=\"true\"\n      style={{\n        position: \"absolute\",\n        inset: 0,\n        borderRadius: \"inherit\",\n        pointerEvents: \"none\",\n        opacity: ringActive ? ringIntensity : 0,\n        transition: \"opacity 0.8s ease\",\n      }}\n    >\n      <div ref={ringInnerRef} style={{ position: \"absolute\", inset: 0, borderRadius: \"inherit\", opacity: 0.7 }}>\n        <div style={{ position: \"absolute\", inset: 0, borderRadius: \"inherit\", filter: `blur(${softBlur}px)` }}>\n          <div style={{ ...ringStyle(softRing), background: glowGradient }} />\n        </div>\n        <div style={{ ...ringStyle(1.5), background: glowGradient }} />\n      </div>\n    </div>\n  );\n\n  const labelItems = [\n    { text: searchingText, dots: true, shimmer: true },\n    { text: writingText, dots: true, shimmer: true },\n    { text: stopped ? \"Stopped\" : doneText, dots: false, shimmer: false },\n  ];\n  const labelIndex = shownPhase === \"searching\" ? 0 : shownPhase === \"writing\" ? 1 : 2;\n\n  const labelNode = (\n    <div aria-hidden=\"true\" style={{ display: \"flex\", alignItems: \"center\", minWidth: 0, overflow: \"hidden\" }}>\n      <div style={{ display: \"grid\", gridTemplateColumns: \"minmax(0, auto)\", minWidth: 0 }}>\n        {labelItems.map((item, i) => {\n          const on = i === labelIndex;\n          return (\n            <div\n              key={i}\n              style={{\n                gridArea: \"1 / 1\",\n                display: \"flex\",\n                alignItems: \"baseline\",\n                minWidth: 0,\n                opacity: on ? 1 : 0,\n                transform: on ? \"translateY(0px)\" : \"translateY(6px)\",\n                transition: `opacity 0.45s ease, transform 0.45s ${EASE}`,\n              }}\n            >\n              <span\n                ref={(el) => {\n                  shimmerEls.current[i] = item.shimmer ? el : null;\n                }}\n                style={\n                  item.shimmer\n                    ? {\n                        ...chrome,\n                        display: \"block\",\n                        minWidth: 0,\n                        whiteSpace: \"nowrap\",\n                        color: \"transparent\",\n                        backgroundImage: shimmerGradient,\n                        backgroundSize: \"300% 100%\",\n                        backgroundPosition: `${STATIC_SHIMMER}% 50%`,\n                        WebkitBackgroundClip: \"text\",\n                        backgroundClip: \"text\",\n                        WebkitTextFillColor: \"transparent\",\n                      }\n                    : {\n                        ...chrome,\n                        display: \"block\",\n                        minWidth: 0,\n                        whiteSpace: \"nowrap\",\n                        color: dimColor,\n                      }\n                }\n              >\n                {item.text}\n              </span>\n              {item.dots && (\n                <span style={{ ...chrome, display: \"flex\", flex: \"none\", color: resolvedText, marginLeft: 1 }}>\n                  {Array.from({ length: DOTS }, (_, d) => (\n                    <span\n                      key={d}\n                      ref={(el) => {\n                        dotEls.current[i * DOTS + d] = el;\n                      }}\n                      style={{ opacity: 0.55 }}\n                    >\n                      .\n                    </span>\n                  ))}\n                </span>\n              )}\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n\n  const stepperNode = (\n    <div style={{ flex: \"none\" }}>\n      <ol\n        aria-label=\"Research steps\"\n        style={{ listStyle: \"none\", margin: 0, padding: 0, display: \"flex\", flexWrap: \"wrap\", alignItems: \"center\", gap: \"6px 6px\" }}\n      >\n        {stepList.map((label, i) => {\n          const done = i < shownStep;\n          const active = i === shownStep;\n          return (\n            <li\n              key={i}\n              aria-current={active ? \"step\" : undefined}\n              style={{\n                ...chrome,\n                fontWeight: 400,\n                display: \"flex\",\n                alignItems: \"center\",\n                gap: 7,\n                minWidth: 0,\n                padding: \"5px 11px 5px 7px\",\n                borderRadius: 999,\n                border: `1px solid ${active ? `rgba(${accentCss},0.35)` : \"rgba(255,255,255,0.07)\"}`,\n                background: active ? `rgba(${accentCss},0.07)` : \"rgba(255,255,255,0.03)\",\n                transition: \"border-color 0.4s ease, background-color 0.4s ease\",\n              }}\n            >\n              <span\n                aria-hidden=\"true\"\n                style={{\n                  position: \"relative\",\n                  flex: \"none\",\n                  width: 16,\n                  height: 16,\n                  display: \"flex\",\n                  alignItems: \"center\",\n                  justifyContent: \"center\",\n                  borderRadius: \"50%\",\n                  color: `rgb(${accentCss})`,\n                  border: done ? \"none\" : `1px solid ${active ? `rgba(${accentCss},0.6)` : \"rgba(255,255,255,0.16)\"}`,\n                  background: done ? `rgba(${accentCss},0.16)` : \"transparent\",\n                }}\n              >\n                {done && <CheckIcon size={10} width={3} />}\n                {active && (\n                  <>\n                    <span\n                      ref={(el) => {\n                        pulseEls.current[i] = el;\n                      }}\n                      style={{ position: \"absolute\", inset: -1, borderRadius: \"50%\", border: `1px solid rgba(${accentCss},0.8)`, opacity: 0.3 }}\n                    />\n                    <span style={{ width: 6, height: 6, borderRadius: \"50%\", background: `rgb(${accentCss})` }} />\n                  </>\n                )}\n              </span>\n              <span\n                ref={(el) => {\n                  shimmerEls.current[3 + i] = active ? el : null;\n                }}\n                style={\n                  active\n                    ? {\n                        whiteSpace: \"nowrap\",\n                        color: \"transparent\",\n                        backgroundImage: shimmerGradient,\n                        backgroundSize: \"300% 100%\",\n                        backgroundPosition: `${STATIC_SHIMMER}% 50%`,\n                        WebkitBackgroundClip: \"text\",\n                        backgroundClip: \"text\",\n                        WebkitTextFillColor: \"transparent\",\n                      }\n                    : { whiteSpace: \"nowrap\", color: done ? dimColor : mutedColor }\n                }\n              >\n                {label}\n              </span>\n            </li>\n          );\n        })}\n      </ol>\n\n      <div\n        aria-hidden=\"true\"\n        style={{ position: \"relative\", height: 2, marginTop: 12, borderRadius: 2, overflow: \"hidden\", background: \"rgba(255,255,255,0.07)\" }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            top: 0,\n            bottom: 0,\n            width: `${railPct.toFixed(2)}%`,\n            borderRadius: 2,\n            backgroundImage: railGradient,\n            backgroundSize: `${(10000 / Math.max(1, railPct)).toFixed(0)}% 100%`,\n            opacity: shownPhase === \"done\" ? 0.45 : 1,\n            transition: \"width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.6s ease\",\n          }}\n        />\n      </div>\n    </div>\n  );\n\n  const caret = (\n    <span\n      ref={caretRef}\n      aria-hidden=\"true\"\n      style={{ display: \"inline-block\", position: \"relative\", width: 0, height: \"1em\", verticalAlign: \"text-bottom\" }}\n    >\n      <span\n        style={{\n          position: \"absolute\",\n          left: 4,\n          top: \"0.4em\",\n          width: 7,\n          height: 7,\n          borderRadius: \"50%\",\n          background: `rgb(${accentCss})`,\n          boxShadow: `0 0 8px rgba(${accentCss},0.5)`,\n        }}\n      />\n    </span>\n  );\n\n  const partial = stopped && shownPhase === \"done\";\n  const showCaret = shownPhase === \"writing\";\n\n  const textNode = (\n    <div itemProp=\"text\" style={{ ...typography, color: resolvedText }}>\n      {blocks.map((b, bi) => {\n        const first = offsets[bi];\n        const firstLead = shownPhase === \"done\" ? 99 : shownCount - first;\n        const Tag = b.kind === \"li\" ? \"li\" : \"p\";\n        const wrapStart = b.kind === \"li\";\n        return (\n          <Tag\n            key={bi}\n            style={{\n              ...typography,\n              position: \"relative\",\n              color: resolvedText,\n              listStyle: wrapStart ? \"none\" : undefined,\n              paddingLeft: wrapStart ? 18 : 0,\n              marginTop: bi === 0 ? 0 : wrapStart ? \"0.5em\" : \"0.75em\",\n            }}\n          >\n            {wrapStart && !(partial && first >= shownCount) && (\n              <span\n                aria-hidden=\"true\"\n                style={{\n                  position: \"absolute\",\n                  left: 3,\n                  top: \"0.72em\",\n                  width: 5,\n                  height: 5,\n                  borderRadius: \"50%\",\n                  background: `rgb(${accentCss})`,\n                  opacity: firstLead >= 1 ? 0.9 : 0,\n                  transition: \"opacity 0.3s ease, color 0.6s ease\",\n                }}\n              />\n            )}\n            {b.words.map((tok, wi) => {\n              const g = first + wi;\n              if (partial && g >= shownCount) return null;\n              const lead = shownPhase === \"done\" ? 99 : shownCount - g;\n              const base = tok.bold ? boldRgb : textRgb;\n              const col = lead >= 99 ? base : mixRgb(accent, base, clamp01((lead - 1) / TAIL));\n              return (\n                <React.Fragment key={wi}>\n                  {showCaret && g === shownCount ? caret : null}\n                  <span\n                    style={{\n                      opacity: lead >= 1 ? 1 : 0,\n                      color: `rgb(${col.join(\",\")})`,\n                      fontWeight: tok.bold ? 600 : undefined,\n                      transition: \"opacity 0.3s ease, color 0.6s ease\",\n                    }}\n                  >\n                    {tok.cite ? (\n                      <>\n                        <sup>\n                          <a\n                            href={`#${answerId}-source-${tok.cite}`}\n                            aria-label={`Source ${tok.cite}`}\n                            style={{\n                              display: \"inline-block\",\n                              minWidth: \"1.35em\",\n                              padding: \"0 0.35em\",\n                              boxSizing: \"border-box\",\n                              textAlign: \"center\",\n                              fontSize: \"0.72em\",\n                              fontWeight: 500,\n                              lineHeight: 1.5,\n                              verticalAlign: \"0.12em\",\n                              borderRadius: 999,\n                              border: `1px solid rgba(${accent2Css},0.4)`,\n                              background: \"rgba(255,255,255,0.07)\",\n                              color: resolvedText,\n                              textDecoration: \"none\",\n                            }}\n                          >\n                            {tok.cite}\n                          </a>\n                        </sup>\n                        {tok.punct}\n                      </>\n                    ) : (\n                      tok.text\n                    )}\n                  </span>\n                  {wi < b.words.length - 1 ? \" \" : null}\n                </React.Fragment>\n              );\n            })}\n          </Tag>\n        );\n      })}\n    </div>\n  );\n\n  const skeletonNode = (\n    <div\n      aria-hidden=\"true\"\n      style={{\n        ...typography,\n        gridArea: \"1 / 1\",\n        pointerEvents: \"none\",\n        display: \"flex\",\n        flexDirection: \"column\",\n        justifyContent: \"flex-start\",\n        gap: \"0.65em\",\n        width: \"100%\",\n        minHeight: \"3.2em\",\n        paddingTop: \"0.2em\",\n        boxSizing: \"border-box\",\n        opacity: shownPhase === \"searching\" ? 1 : 0,\n        transition: \"opacity 0.35s ease\",\n      }}\n    >\n      {[92, 100, 68].map((width, i) => (\n        <div\n          key={i}\n          ref={(el) => {\n            shimmerEls.current[8 + i] = el;\n          }}\n          style={{\n            width: `${width}%`,\n            height: \"0.7em\",\n            flex: \"none\",\n            borderRadius: 999,\n            backgroundImage: barGradient,\n            backgroundSize: \"300% 100%\",\n            backgroundPosition: `${STATIC_SHIMMER}% 50%`,\n          }}\n        />\n      ))}\n    </div>\n  );\n\n  const cols = Math.max(1, Math.min(3, sourceList.length));\n  const sourceCards = sourceList.map((src, i) => {\n    const letter = (src.domain || src.title || \"?\").trim().charAt(0).toUpperCase();\n    const tint = i % 2 === 0 ? accentCss : accent2Css;\n    const href = sourceHref(src.domain);\n    return (\n      <a\n        key={i}\n        id={`${answerId}-source-${i + 1}`}\n        role=\"listitem\"\n        itemProp=\"citation\"\n        itemScope\n        itemType=\"https://schema.org/CreativeWork\"\n        href={href || undefined}\n        target={href ? \"_blank\" : undefined}\n        rel={href ? \"noopener noreferrer nofollow\" : undefined}\n        style={{\n          ...chrome,\n          fontWeight: 400,\n          display: \"flex\",\n          flexDirection: \"column\",\n          gap: 7,\n          minWidth: 0,\n          padding: \"10px 12px\",\n          boxSizing: \"border-box\",\n          borderRadius: 14,\n          border: \"1px solid rgba(255,255,255,0.08)\",\n          background: \"rgba(255,255,255,0.035)\",\n          textDecoration: \"none\",\n          color: \"inherit\",\n          opacity: shownPhase === \"done\" ? 1 : 0,\n          transform: shownPhase === \"done\" ? \"translateY(0px)\" : \"translateY(6px)\",\n          transition: `opacity 450ms ease ${120 + i * 90}ms, transform 450ms ${EASE} ${120 + i * 90}ms`,\n        }}\n      >\n        <meta itemProp=\"url\" content={href} />\n        <div style={{ display: \"flex\", alignItems: \"center\", gap: 7, minWidth: 0 }}>\n          <span\n            aria-hidden=\"true\"\n            style={{\n              flex: \"none\",\n              width: 18,\n              height: 18,\n              display: \"flex\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n              borderRadius: 6,\n              fontSize: 10,\n              fontWeight: 600,\n              color: `rgb(${tint})`,\n              background: `rgba(${tint},0.14)`,\n              border: `1px solid rgba(${tint},0.28)`,\n            }}\n          >\n            {letter}\n          </span>\n          <cite\n            itemProp=\"publisher\"\n            style={{ flex: 1, minWidth: 0, overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", fontSize: 11.5, fontStyle: \"normal\", color: mutedColor }}\n          >\n            {src.domain}\n          </cite>\n          <span style={{ flex: \"none\", fontSize: 11, color: mutedColor }}>{i + 1}</span>\n        </div>\n        <div\n          itemProp=\"headline\"\n          style={{ color: dimColor, lineHeight: 1.35, display: \"-webkit-box\", WebkitLineClamp: 2, WebkitBoxOrient: \"vertical\", overflow: \"hidden\" }}\n        >\n          {src.title}\n        </div>\n      </a>\n    );\n  });\n  const timerText = `${timerValue.toFixed(1)}s`;\n  const stopVisible = shownPhase === \"writing\";\n  const footerReady = shownPhase === \"done\";\n\n  return (\n    <article\n      ref={rootRef}\n      lang={lang || undefined}\n      itemScope\n      itemType=\"https://schema.org/QAPage\"\n      aria-label=\"AI answer\"\n      className={cn(\"relative box-border h-full w-full overflow-hidden\", className)}\n      style={{\n        ...style,\n        display: \"flex\",\n        flexDirection: \"column\",\n        gap,\n        padding,\n        borderRadius: radius,\n        background,\n        backgroundImage: \"linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0) 60%)\",\n        border: `1px solid ${borderColor}`,\n        backdropFilter: \"blur(14px)\",\n        WebkitBackdropFilter: \"blur(14px)\",\n      }}\n    >\n      <div itemScope itemType=\"https://schema.org/Question\" itemProp=\"mainEntity\" style={{ display: \"contents\" }}>\n          <span role=\"status\" aria-live=\"polite\" style={SR_ONLY}>\n            {statusLine}\n          </span>\n          <span itemProp=\"text\" style={SR_ONLY}>\n            {plainAnswer}\n          </span>\n\n          {ringNode}\n\n          <header style={{ position: \"relative\", flex: \"none\", height: 28, display: \"flex\", alignItems: \"center\", gap: 9 }}>\n            <div\n              ref={sparkRef}\n              aria-hidden=\"true\"\n              style={{\n                flex: \"none\",\n                width: 20,\n                height: 20,\n                display: \"flex\",\n                alignItems: \"center\",\n                justifyContent: \"center\",\n                filter: `drop-shadow(0 0 5px rgba(${accentCss},0.35))`,\n              }}\n            >\n              <Spark color={`rgb(${accentCss})`} size={18} />\n            </div>\n            {labelNode}\n            {showTimer && (\n              <time\n                dateTime={`PT${Math.max(0, timerValue).toFixed(1)}S`}\n                aria-label={`Elapsed ${timerText}`}\n                style={{ ...chrome, fontSize: 12, fontWeight: 400, flex: \"none\", color: mutedColor, fontVariantNumeric: \"tabular-nums\" }}\n              >\n                {timerText}\n              </time>\n            )}\n            <div style={{ flex: 1 }} />\n            {stopVisible && (\n              <PillButton label=\"Stop\" onClick={handleStop} style={{ ...chrome, height: 28 }} color={resolvedText} icon={<StopIcon />} />\n            )}\n          </header>\n\n          {showQuestion && question.trim() !== \"\" && (\n            <h2\n              itemProp=\"name\"\n              style={{\n                ...typography,\n                flex: \"none\",\n                fontSize: 20,\n                lineHeight: 1.3,\n                fontWeight: 600,\n                letterSpacing: \"-0.01em\",\n                color: `rgb(${boldRgb.join(\",\")})`,\n              }}\n            >\n              {question}\n            </h2>\n          )}\n\n          {showSteps && stepList.length > 0 && stepperNode}\n\n          <section\n            itemScope\n            itemType=\"https://schema.org/Answer\"\n            itemProp=\"acceptedAnswer\"\n            ref={bodyRef}\n            aria-busy={shownPhase !== \"done\"}\n            aria-label=\"Answer\"\n            style={{\n              position: \"relative\",\n              flex: 1,\n              minHeight: 0,\n              overflowY: \"auto\",\n              scrollbarWidth: \"none\",\n              display: \"grid\",\n              gridTemplateColumns: \"minmax(0, 1fr)\",\n              alignContent: \"start\",\n            }}\n          >\n            <div style={{ gridArea: \"1 / 1\" }}>{textNode}</div>\n            {skeletonNode}\n          </section>\n\n          {(showSources || showActions || showFollowUps) && (\n            <footer\n              inert={footerReady ? undefined : true}\n              style={{\n                position: \"relative\",\n                flex: \"none\",\n                display: \"flex\",\n                flexDirection: \"column\",\n                gap: 12,\n                visibility: footerReady ? \"visible\" : \"hidden\",\n                opacity: footerReady ? 1 : 0,\n                transition: \"opacity 0.4s ease\",\n              }}\n            >\n              {showSources && sourceList.length > 0 && (\n                <div role=\"list\" aria-label=\"Sources\" style={{ display: \"grid\", gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gap: 8 }}>\n                  {sourceCards}\n                </div>\n              )}\n\n              {showActions && (\n                <div style={{ display: \"flex\", alignItems: \"center\" }}>\n                  <div\n                    role=\"group\"\n                    aria-label=\"Answer actions\"\n                    style={{\n                      display: \"flex\",\n                      alignItems: \"center\",\n                      gap: 2,\n                      padding: 3,\n                      borderRadius: 999,\n                      border: \"1px solid rgba(255,255,255,0.08)\",\n                      background: \"rgba(255,255,255,0.03)\",\n                    }}\n                  >\n                    <IconButton label={copied ? \"Copied\" : \"Copy answer\"} onClick={handleCopy} color={dimColor} activeColor={resolvedText}>\n                      {copied ? <CheckIcon /> : <CopyIcon />}\n                    </IconButton>\n                    <IconButton\n                      label=\"Good answer\"\n                      onClick={() => setVote(vote === \"up\" ? null : \"up\")}\n                      color={dimColor}\n                      activeColor={resolvedText}\n                      toggled={vote === \"up\"}\n                    >\n                      <ThumbIcon />\n                    </IconButton>\n                    <IconButton\n                      label=\"Bad answer\"\n                      onClick={() => setVote(vote === \"down\" ? null : \"down\")}\n                      color={dimColor}\n                      activeColor={resolvedText}\n                      toggled={vote === \"down\"}\n                    >\n                      <ThumbIcon flip />\n                    </IconButton>\n                    <IconButton label=\"Regenerate answer\" onClick={handleRegenerate} color={dimColor} activeColor={resolvedText}>\n                      <RefreshIcon />\n                    </IconButton>\n                  </div>\n                  <span style={{ ...chrome, fontSize: 12, fontWeight: 400, marginLeft: \"auto\", color: mutedColor, whiteSpace: \"nowrap\" }}>\n                    {stopped ? \"Stopped\" : `${sourceList.length} sources`}\n                  </span>\n                </div>\n              )}\n              {showFollowUps && followList.length > 0 && (\n                <nav aria-label=\"Follow-up questions\" style={{ display: \"flex\", flexWrap: \"wrap\", gap: 8, minWidth: 0 }}>\n                  {followList.map((text, i) => (\n                    <PillButton\n                      key={i}\n                      label={text}\n                      onClick={() => onFollowUp?.()}\n                      style={{ ...chrome, fontWeight: 400 }}\n                      color={dimColor}\n                      icon={<ReplyIcon />}\n                    />\n                  ))}\n                </nav>\n              )}\n            </footer>\n          )}\n        </div>\n    </article>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}