{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "record-detail-drawer",
  "title": "Record Detail Drawer",
  "description": "A CRM-style accounts table with a record drawer that slides in from the right: next and previous with J / K, a stage picker that logs to the activity feed, click-to-edit fields that save on Enter, copy email, call and email shortcuts, and Overview / Activity / Notes tabs with a note composer.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/record-detail-drawer/record-detail-drawer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/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 Stage = \"Lead\" | \"Qualified\" | \"Proposal\" | \"Won\" | \"Lost\";\ntype Field = \"email\" | \"phone\" | \"owner\" | \"value\" | \"location\";\nexport interface DrawerRecord {\n  id: string;\n  name: string;\n  company: string;\n  stage: Stage;\n  value: number;\n  owner: string;\n  email: string;\n  phone: string;\n  location: string;\n  lastContact: string;\n  color: string;\n  activity: { id: string; kind: \"email\" | \"call\" | \"meeting\" | \"stage\"; text: string; when: string }[];\n  notes: { id: string; text: string; when: string; by: string }[];\n}\n\nexport interface RecordDetailDrawerProps {\n  records?: DrawerRecord[];\n  owners?: string[];\n  defaultOpenId?: string | null;\n  onRecordChange?: (record: DrawerRecord) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", panel: \"#111111\", row: \"rgba(255,255,255,0.03)\", sel: \"rgba(255,255,255,0.06)\", border: \"rgba(255,255,255,0.08)\", input: \"#0D0D0D\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", ring: \"rgba(245,244,241,0.6)\", scrim: \"rgba(0,0,0,0.45)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", panel: \"#FFFFFF\", row: \"rgba(10,10,10,0.02)\", sel: \"rgba(10,10,10,0.05)\", border: \"rgba(10,10,10,0.09)\", input: \"#FAFAF8\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", ring: \"rgba(10,10,10,0.5)\", scrim: \"rgba(10,10,10,0.18)\" },\n};\nconst STAGES: Stage[] = [\"Lead\", \"Qualified\", \"Proposal\", \"Won\", \"Lost\"];\nconst STAGE_COLOR: Record<Stage, string> = { Lead: \"#A1A1AA\", Qualified: \"#60A5FA\", Proposal: \"#FBBF24\", Won: \"#34D399\", Lost: \"#F87171\" };\nconst OWNERS = [\"Lena Brandt\", \"Daniel Reyes\", \"Mia Okafor\", \"Tomás Ferreira\"];\nconst rec = (id: string, name: string, company: string, stage: Stage, value: number, owner: string, location: string, lastContact: string, color: string): DrawerRecord => ({\n  id,\n  name,\n  company,\n  stage,\n  value,\n  owner,\n  email: `${name.split(\" \")[0].toLowerCase()}@${company.toLowerCase().replace(/[^a-z]/g, \"\")}.com`,\n  phone: `+1 415 555 0${id.padStart(3, \"1\").slice(-3)}`,\n  location,\n  lastContact,\n  color,\n  activity: [\n    { id: `${id}a1`, kind: \"email\", text: `Sent pricing for ${company}`, when: \"2h ago\" },\n    { id: `${id}a2`, kind: \"call\", text: \"Discovery call, 32 min\", when: \"Yesterday\" },\n    { id: `${id}a3`, kind: \"stage\", text: `Moved to ${stage}`, when: \"Nov 6\" },\n    { id: `${id}a4`, kind: \"meeting\", text: \"Demo with their ops team\", when: \"Nov 3\" },\n  ],\n  notes: [{ id: `${id}n1`, text: \"Budget is approved for Q1. Decision maker is the COO; legal review takes about two weeks.\", when: \"Nov 8\", by: owner }],\n});\nconst RECORDS: DrawerRecord[] = [\n  rec(\"1\", \"Amara Osei\", \"Kestrel Labs\", \"Proposal\", 48000, \"Lena Brandt\", \"Oakland, CA\", \"2h ago\", \"#60A5FA\"),\n  rec(\"2\", \"Jonas Weber\", \"Ferro & Co\", \"Qualified\", 22000, \"Daniel Reyes\", \"Berlin, DE\", \"Yesterday\", \"#F472B6\"),\n  rec(\"3\", \"Priya Raman\", \"Atlas Freight\", \"Won\", 76000, \"Mia Okafor\", \"Austin, TX\", \"Nov 9\", \"#34D399\"),\n  rec(\"4\", \"Luca Moretti\", \"Vento Bikes\", \"Lead\", 9000, \"Tomás Ferreira\", \"Milan, IT\", \"Nov 8\", \"#FBBF24\"),\n  rec(\"5\", \"Hana Sato\", \"Mirai Health\", \"Proposal\", 54000, \"Lena Brandt\", \"Osaka, JP\", \"Nov 7\", \"#A78BFA\"),\n  rec(\"6\", \"Diego Alvarez\", \"Solaria Energy\", \"Lost\", 31000, \"Daniel Reyes\", \"Madrid, ES\", \"Nov 2\", \"#F87171\"),\n  rec(\"7\", \"Grace Kim\", \"Northpine Studio\", \"Qualified\", 18500, \"Mia Okafor\", \"Seattle, WA\", \"Oct 30\", \"#2DD4BF\"),\n];\nconst money = (n: number) => `$${n.toLocaleString(\"en-US\")}`;\nconst initials = (n: string) =>\n  n\n    .split(\" \")\n    .map((w) => w[0])\n    .join(\"\");\nconst ACT_ICON = { email: \"M3 7l9 6 9-6M3 6h18v12H3z\", call: \"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2\", meeting: \"M4 5h16v14H4zM4 10h16M9 3v4M15 3v4\", stage: \"M5 12h14m-5-5 5 5-5 5\" } as const;\n\nexport function RecordDetailDrawer({ records: initial = RECORDS, owners = OWNERS, defaultOpenId = \"1\", onRecordChange, theme = \"dark\", className }: RecordDetailDrawerProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [records, setRecords] = React.useState(initial);\n  const [openId, setOpenId] = React.useState<string | null>(defaultOpenId);\n  const [tab, setTab] = React.useState<\"overview\" | \"activity\" | \"notes\">(\"overview\");\n  const [editing, setEditing] = React.useState<Field | null>(null);\n  const [draft, setDraft] = React.useState(\"\");\n  const [saved, setSaved] = React.useState<Field | \"stage\" | null>(null);\n  const [note, setNote] = React.useState(\"\");\n  const [copied, setCopied] = React.useState(false);\n  const rootRef = React.useRef<HTMLElement>(null);\n  const counter = React.useRef(0);\n  const focusSelect = React.useCallback((el: HTMLInputElement | HTMLSelectElement | null) => {\n    el?.focus({ preventScroll: true });\n    if (el instanceof HTMLInputElement) el.select();\n  }, []);\n\n  const idx = records.findIndex((r) => r.id === openId);\n  const r = idx >= 0 ? records[idx] : null;\n\n  React.useEffect(() => {\n    if (!saved && !copied) return;\n    const t = setTimeout(() => {\n      setSaved(null);\n      setCopied(false);\n    }, 1400);\n    return () => clearTimeout(t);\n  }, [saved, copied]);\n  React.useEffect(() => {\n    if (!openId) return;\n    const onKey = (e: KeyboardEvent) => {\n      const typing = (e.target as HTMLElement).closest(\"input, textarea, select\");\n      if (e.key === \"Escape\" && !typing) setOpenId(null);\n      if (typing || !rootRef.current?.contains(document.activeElement ?? null)) return;\n      if (e.key === \"j\" || e.key === \"k\") {\n        setOpenId((cur) => {\n          const i = records.findIndex((x) => x.id === cur);\n          return records[(i + (e.key === \"j\" ? 1 : -1) + records.length) % records.length].id;\n        });\n        setEditing(null);\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [openId, records]);\n\n  const update = (patch: Partial<DrawerRecord>, flag?: Field | \"stage\") => {\n    if (!r) return;\n    const next = { ...r, ...patch };\n    setRecords((rs) => rs.map((x) => (x.id === r.id ? next : x)));\n    if (flag) setSaved(flag);\n    onRecordChange?.(next);\n  };\n  const commit = () => {\n    if (!r || !editing) return;\n    const v = draft.trim();\n    if (editing === \"value\") {\n      const n = Number(v.replace(/[^0-9.]/g, \"\"));\n      if (!Number.isNaN(n) && n !== r.value) update({ value: n }, \"value\");\n    } else if (v && v !== r[editing]) update({ [editing]: v } as Partial<DrawerRecord>, editing);\n    setEditing(null);\n  };\n  const open = (id: string) => {\n    setOpenId(id);\n    setEditing(null);\n  };\n  const go = (d: number) => open(records[(idx + d + records.length) % records.length].id);\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.panel } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const iconBtn = cn(\"grid h-8 w-8 shrink-0 cursor-pointer place-items-center rounded-lg border bg-transparent\", focus);\n  const pill = (s: Stage) => (\n    <span className=\"inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11.5px] font-medium\" style={{ background: `${STAGE_COLOR[s]}1f`, color: STAGE_COLOR[s] }}>\n      <span className=\"h-1.5 w-1.5 rounded-full\" style={{ background: STAGE_COLOR[s] }} />\n      {s}\n    </span>\n  );\n  const avatar = (x: DrawerRecord, size = 32) => (\n    <span className=\"grid shrink-0 place-items-center rounded-full font-semibold\" style={{ width: size, height: size, fontSize: size * 0.36, background: `${x.color}2e`, color: x.color }}>\n      {initials(x.name)}\n    </span>\n  );\n  const field = (k: Field, label: string, display: string) => (\n    <div className=\"grid grid-cols-[96px_minmax(0,1fr)] items-center gap-3 py-1.5\">\n      <span className=\"text-[12.5px]\" style={{ color: p.faint }}>\n        {label}\n      </span>\n      {editing === k ? (\n        k === \"owner\" ? (\n          <select ref={focusSelect} value={draft} onChange={(e) => setDraft(e.target.value)} onBlur={commit} onKeyDown={(e) => (e.key === \"Enter\" ? commit() : e.key === \"Escape\" && setEditing(null))} aria-label={label} className={cn(\"h-8 w-full rounded-md border px-2 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.input, color: p.text, ...ring }}>\n            {owners.map((o) => (\n              <option key={o}>{o}</option>\n            ))}\n          </select>\n        ) : (\n          <input ref={focusSelect} value={draft} onChange={(e) => setDraft(e.target.value)} onBlur={commit} onKeyDown={(e) => (e.key === \"Enter\" ? commit() : e.key === \"Escape\" && setEditing(null))} aria-label={label} inputMode={k === \"value\" ? \"numeric\" : undefined} className={cn(\"h-8 w-full min-w-0 rounded-md border px-2 text-[13px]\", focus)} style={{ borderColor: p.border, background: p.input, color: p.text, ...ring }} />\n        )\n      ) : (\n        <button\n          type=\"button\"\n          onClick={() => {\n            setEditing(k);\n            setDraft(k === \"value\" ? String(r?.value ?? \"\") : (r?.[k] as string));\n          }}\n          className={cn(\"group flex h-8 min-w-0 cursor-text items-center justify-between gap-2 rounded-md border border-transparent bg-transparent px-2 text-left text-[13px] hover:border-[var(--b)]\", focus)}\n          style={{ color: p.text, [\"--b\" as string]: p.border, ...ring }}\n          aria-label={`${label}: ${display}. Edit`}\n        >\n          <span className=\"truncate\">{display}</span>\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            {saved === k ? (\n              <motion.span key=\"s\" initial={reduce ? false : { opacity: 0, scale: 0.8 }} animate={{ opacity: 1, scale: 1 }} exit={reduce ? undefined : { opacity: 0 }} className=\"shrink-0 text-[11.5px]\" style={{ color: p.green }}>\n                Saved\n              </motion.span>\n            ) : (\n              <motion.svg key=\"e\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.faint} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"shrink-0 opacity-0 group-hover:opacity-100\" aria-hidden=\"true\">\n                <path d=\"M4 20h4L19 9l-4-4L4 16v4Z\" />\n              </motion.svg>\n            )}\n          </AnimatePresence>\n        </button>\n      )}\n    </div>\n  );\n\n  return (\n    <section ref={rootRef} className={cn(\"@container relative h-[640px] w-full overflow-hidden\", className)} style={{ background: p.bg, color: p.text }}>\n      {/* Table */}\n      <div className={cn(\"flex h-full flex-col px-4 py-6 transition-[padding] duration-300 @[640px]:px-6\", r && \"@[1000px]:pr-[444px]\")}>\n        <div className=\"flex items-end justify-between gap-3\">\n          <div>\n            <h2 className=\"m-0 text-[20px] font-semibold tracking-[-0.01em]\">Accounts</h2>\n            <p className=\"m-0 mt-1 text-[13px]\" style={{ color: p.muted }}>\n              {records.length} accounts · {money(records.filter((x) => x.stage !== \"Lost\").reduce((s, x) => s + x.value, 0))} open pipeline\n            </p>\n          </div>\n          <p className=\"m-0 hidden text-[12px] @[640px]:block\" style={{ color: p.faint }}>\n            Click a row · J / K to move · Esc to close\n          </p>\n        </div>\n        <div className=\"mt-5 min-h-0 flex-1 overflow-auto rounded-xl border\" style={{ borderColor: p.border }}>\n          <table className=\"w-full border-collapse text-left text-[13px]\">\n            <thead className=\"sticky top-0 z-[1]\" style={{ background: p.bg }}>\n              <tr style={{ color: p.faint }}>\n                {[\"Contact\", \"Stage\", \"Value\", \"Owner\", \"Last contact\"].map((h, i) => (\n                  <th key={h} className={cn(\"border-b px-3 py-2.5 text-[11.5px] font-medium tracking-[0.04em] uppercase\", i > 1 && \"hidden @[640px]:table-cell\", i === 4 && \"@[640px]:hidden @[900px]:table-cell\")} style={{ borderColor: p.border }}>\n                    {h}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {records.map((x) => (\n                <tr\n                  key={x.id}\n                  tabIndex={0}\n                  onClick={() => open(x.id)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\" || e.key === \" \") {\n                      e.preventDefault();\n                      open(x.id);\n                    } else if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n                      e.preventDefault();\n                      ((e.key === \"ArrowDown\" ? e.currentTarget.nextElementSibling : e.currentTarget.previousElementSibling) as HTMLElement | null)?.focus();\n                    }\n                  }}\n                  aria-selected={openId === x.id}\n                  className=\"cursor-pointer outline-none focus-visible:bg-[var(--s)]\"\n                  style={{ background: openId === x.id ? p.sel : \"transparent\", [\"--s\" as string]: p.sel }}\n                >\n                  <td className=\"border-b px-3 py-2.5\" style={{ borderColor: p.border }}>\n                    <span className=\"flex items-center gap-2.5\">\n                      {avatar(x, 28)}\n                      <span className=\"min-w-0\">\n                        <span className=\"block truncate font-medium\">{x.name}</span>\n                        <span className=\"block truncate text-[12px]\" style={{ color: p.faint }}>\n                          {x.company}\n                        </span>\n                      </span>\n                    </span>\n                  </td>\n                  <td className=\"border-b px-3 py-2.5\" style={{ borderColor: p.border }}>\n                    {pill(x.stage)}\n                  </td>\n                  <td className=\"hidden border-b px-3 py-2.5 tabular-nums @[640px]:table-cell\" style={{ borderColor: p.border }}>\n                    {money(x.value)}\n                  </td>\n                  <td className=\"hidden border-b px-3 py-2.5 @[640px]:table-cell\" style={{ borderColor: p.border, color: p.muted }}>\n                    {x.owner}\n                  </td>\n                  <td className=\"hidden border-b px-3 py-2.5 @[900px]:table-cell\" style={{ borderColor: p.border, color: p.faint }}>\n                    {x.lastContact}\n                  </td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </div>\n      </div>\n\n      {/* Drawer */}\n      <AnimatePresence>\n        {r && (\n          <>\n            <motion.div key=\"scrim\" className=\"absolute inset-0 z-10 @[1000px]:hidden\" style={{ background: p.scrim }} initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} exit={reduce ? undefined : { opacity: 0 }} onClick={() => setOpenId(null)} aria-hidden=\"true\" />\n            <motion.aside\n              key=\"drawer\"\n              role=\"dialog\"\n              aria-labelledby={`${uid}-t`}\n              initial={reduce ? false : { x: \"100%\" }}\n              animate={{ x: 0 }}\n              exit={reduce ? undefined : { x: \"100%\" }}\n              transition={{ type: \"spring\", stiffness: 380, damping: 38 }}\n              className=\"absolute inset-y-0 right-0 z-20 flex w-full max-w-[420px] flex-col border-l shadow-[-24px_0_60px_-30px_rgba(0,0,0,0.6)]\"\n              style={{ background: p.panel, borderColor: p.border }}\n            >\n              <div className=\"flex items-center gap-2 border-b px-4 py-3\" style={{ borderColor: p.border }}>\n                <button type=\"button\" onClick={() => go(-1)} aria-label=\"Previous record (K)\" className={iconBtn} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                  <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"m18 15-6-6-6 6\" />\n                  </svg>\n                </button>\n                <button type=\"button\" onClick={() => go(1)} aria-label=\"Next record (J)\" className={iconBtn} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                  <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"m6 9 6 6 6-6\" />\n                  </svg>\n                </button>\n                <span className=\"text-[12px] tabular-nums\" style={{ color: p.faint }}>\n                  {idx + 1} of {records.length}\n                </span>\n                <button type=\"button\" onClick={() => setOpenId(null)} aria-label=\"Close (Esc)\" className={cn(iconBtn, \"ml-auto border-0\")} style={{ color: p.muted, ...ring }}>\n                  <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                    <path d=\"M6 6l12 12M18 6 6 18\" />\n                  </svg>\n                </button>\n              </div>\n\n              <motion.div key={r.id} initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.2 }} className=\"flex min-h-0 flex-1 flex-col\">\n                  <div className=\"px-5 pt-5\">\n                    <div className=\"flex items-start gap-3\">\n                      {avatar(r, 48)}\n                      <div className=\"min-w-0 flex-1\">\n                        <h3 id={`${uid}-t`} className=\"m-0 truncate text-[17px] font-semibold\">\n                          {r.name}\n                        </h3>\n                        <p className=\"m-0 truncate text-[13px]\" style={{ color: p.muted }}>\n                          {r.company} · {r.location}\n                        </p>\n                      </div>\n                    </div>\n                    <div className=\"mt-4 flex flex-wrap items-center gap-2\">\n                      <label className=\"relative\">\n                        <span className=\"sr-only\">Stage</span>\n                        <select value={r.stage} onChange={(e) => update({ stage: e.target.value as Stage, activity: [{ id: `s${++counter.current}`, kind: \"stage\", text: `Moved to ${e.target.value}`, when: \"just now\" }, ...r.activity] }, \"stage\")} className={cn(\"h-8 cursor-pointer appearance-none rounded-full border-0 pr-7 pl-3 text-[12.5px] font-medium\", focus)} style={{ background: `${STAGE_COLOR[r.stage]}1f`, color: STAGE_COLOR[r.stage], ...ring }}>\n                          {STAGES.map((s) => (\n                            <option key={s}>{s}</option>\n                          ))}\n                        </select>\n                        <svg className=\"pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2\" width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={STAGE_COLOR[r.stage]} strokeWidth=\"3\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                          <path d=\"m6 9 6 6 6-6\" />\n                        </svg>\n                      </label>\n                      <span className=\"text-[13px] font-semibold tabular-nums\">{money(r.value)}</span>\n                      {saved === \"stage\" && (\n                        <span className=\"text-[11.5px]\" style={{ color: p.green }} role=\"status\">\n                          Stage saved\n                        </span>\n                      )}\n                      <div className=\"ml-auto flex gap-1.5\">\n                        <a href={`mailto:${r.email}`} aria-label={`Email ${r.name}`} className={iconBtn} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                          <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                            <path d={ACT_ICON.email} />\n                          </svg>\n                        </a>\n                        <a href={`tel:${r.phone.replace(/\\s/g, \"\")}`} aria-label={`Call ${r.name}`} className={iconBtn} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                          <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                            <path d={ACT_ICON.call} />\n                          </svg>\n                        </a>\n                      </div>\n                    </div>\n                    <div role=\"tablist\" aria-label=\"Record sections\" className=\"mt-5 flex gap-1 border-b\" style={{ borderColor: p.border }}>\n                      {([\"overview\", \"activity\", \"notes\"] as const).map((k) => (\n                        <button key={k} type=\"button\" role=\"tab\" aria-selected={tab === k} onClick={() => setTab(k)} className={cn(\"relative cursor-pointer border-0 bg-transparent px-2.5 pb-2.5 text-[13px] capitalize\", focus)} style={{ color: tab === k ? p.text : p.muted, fontWeight: tab === k ? 500 : 400, ...ring }}>\n                          {k}\n                          {k === \"notes\" && <span className=\"ml-1 text-[11px] tabular-nums\" style={{ color: p.faint }}>{r.notes.length}</span>}\n                          {tab === k && <motion.span layoutId={`${uid}-tab`} className=\"absolute inset-x-1 -bottom-px h-[2px] rounded-full\" style={{ background: p.on }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 40 }} />}\n                        </button>\n                      ))}\n                    </div>\n                  </div>\n\n                  <div role=\"tabpanel\" className=\"min-h-0 flex-1 overflow-y-auto px-5 py-4\">\n                    {tab === \"overview\" && (\n                      <div>\n                        <div className=\"relative\">\n                          {field(\"email\", \"Email\", r.email)}\n                          {editing !== \"email\" && (\n                            <button\n                              type=\"button\"\n                              onClick={() => {\n                                navigator.clipboard?.writeText(r.email).catch(() => {});\n                                setCopied(true);\n                              }}\n                              aria-label=\"Copy email\"\n                              className={cn(\"absolute top-1/2 right-0 grid h-7 w-7 -translate-y-1/2 cursor-pointer place-items-center rounded-md border-0 bg-transparent text-[11px]\", focus)}\n                              style={{ color: copied ? p.green : p.faint, ...ring }}\n                            >\n                              {copied ? \"✓\" : (\n                                <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                  <rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2\" />\n                                  <path d=\"M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3\" />\n                                </svg>\n                              )}\n                            </button>\n                          )}\n                        </div>\n                        {field(\"phone\", \"Phone\", r.phone)}\n                        {field(\"owner\", \"Owner\", r.owner)}\n                        {field(\"value\", \"Deal value\", money(r.value))}\n                        {field(\"location\", \"Location\", r.location)}\n                        <div className=\"mt-4 rounded-xl p-3.5\" style={{ background: p.row }}>\n                          <p className=\"m-0 text-[12px]\" style={{ color: p.faint }}>\n                            Latest note\n                          </p>\n                          <p className=\"m-0 mt-1 text-[13px] leading-[1.5]\" style={{ color: p.muted }}>\n                            {r.notes[0]?.text ?? \"No notes yet.\"}\n                          </p>\n                        </div>\n                      </div>\n                    )}\n                    {tab === \"activity\" && (\n                      <ol className=\"relative m-0 list-none p-0\">\n                        <span className=\"absolute top-2 bottom-2 left-[13px] w-px\" style={{ background: p.border }} aria-hidden=\"true\" />\n                        <AnimatePresence initial={false}>\n                          {r.activity.map((a) => (\n                            <motion.li key={a.id} layout={!reduce} initial={reduce ? false : { opacity: 0, x: -6 }} animate={{ opacity: 1, x: 0 }} className=\"relative flex gap-3 pb-4\">\n                              <span className=\"relative grid h-7 w-7 shrink-0 place-items-center rounded-full border\" style={{ borderColor: p.border, background: p.panel, color: a.kind === \"stage\" ? STAGE_COLOR[r.stage] : p.muted }}>\n                                <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                  <path d={ACT_ICON[a.kind]} />\n                                </svg>\n                              </span>\n                              <span className=\"min-w-0 pt-1\">\n                                <span className=\"block text-[13px]\">{a.text}</span>\n                                <span className=\"block text-[11.5px]\" style={{ color: p.faint }}>\n                                  {a.when}\n                                </span>\n                              </span>\n                            </motion.li>\n                          ))}\n                        </AnimatePresence>\n                      </ol>\n                    )}\n                    {tab === \"notes\" && (\n                      <div>\n                        <form\n                          onSubmit={(e) => {\n                            e.preventDefault();\n                            if (!note.trim()) return;\n                            update({ notes: [{ id: `n${++counter.current}`, text: note.trim(), when: \"just now\", by: \"You\" }, ...r.notes] });\n                            setNote(\"\");\n                          }}\n                        >\n                          <label htmlFor={`${uid}-note`} className=\"sr-only\">\n                            Add a note\n                          </label>\n                          <textarea id={`${uid}-note`} value={note} onChange={(e) => setNote(e.target.value)} onKeyDown={(e) => (e.metaKey || e.ctrlKey) && e.key === \"Enter\" && e.currentTarget.form?.requestSubmit()} rows={3} placeholder=\"Add a note… (⌘↵ to save)\" className={cn(\"block w-full resize-none rounded-xl border px-3 py-2.5 text-[13px] leading-[1.5]\", focus)} style={{ borderColor: p.border, background: p.input, color: p.text, ...ring }} />\n                          <div className=\"mt-2 flex justify-end\">\n                            <button type=\"submit\" disabled={!note.trim()} className={cn(\"h-8 cursor-pointer rounded-lg border-0 px-3 text-[12.5px] font-medium disabled:opacity-40\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                              Add note\n                            </button>\n                          </div>\n                        </form>\n                        <ul className=\"m-0 mt-3 flex list-none flex-col gap-2.5 p-0\">\n                          <AnimatePresence initial={false}>\n                            {r.notes.map((n) => (\n                              <motion.li key={n.id} layout={!reduce} initial={reduce ? false : { opacity: 0, y: -6 }} animate={{ opacity: 1, y: 0 }} className=\"rounded-xl border p-3\" style={{ borderColor: p.border }}>\n                                <p className=\"m-0 text-[13px] leading-[1.5]\">{n.text}</p>\n                                <p className=\"m-0 mt-1.5 text-[11.5px]\" style={{ color: p.faint }}>\n                                  {n.by} · {n.when}\n                                </p>\n                              </motion.li>\n                            ))}\n                          </AnimatePresence>\n                        </ul>\n                      </div>\n                    )}\n                  </div>\n                </motion.div>\n            </motion.aside>\n          </>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default RecordDetailDrawer;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}