{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"kanban-drag-columns","type":"registry:component","title":"Kanban Drag Columns","description":"A dependency-free kanban board: lift a card and a lifted copy follows your pointer while the columns light up as drop targets and the cards glide out of the way on a spring. Count badges roll, touch scrolls sideways with snap, and a full keyboard path moves cards between columns.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/kanban-drag-columns.tsx","content":"\"use client\";\n\n/*\n * Kanban drag columns: a small board where cards drag within and across columns, no dependencies.\n *\n * Mouse and pen: press a card and drag. Touch: drag by the grip (the board still scrolls sideways\n * under your finger everywhere else). The card you hold floats above the board as a lifted copy\n * while its slot stays behind as a dashed placeholder; the cards around it glide out of the way on\n * a spring and the column under the pointer lights up as the drop target. Keyboard: focus a grip,\n * press Space to pick the card up, move with the arrow keys (Up and Down reorder, Left and Right\n * change column, Home and End jump to the ends), Space to drop, Escape to cancel. Every step is\n * announced through an aria-live region. Positions are measured in layout pixels and animated\n * with FLIP (Web Animations API), so it stays correct inside scaled previews.\n */\n\nimport {\n  useCallback,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type CSSProperties,\n  type KeyboardEvent as ReactKeyboardEvent,\n  type PointerEvent as ReactPointerEvent,\n} from \"react\";\n\nexport type KanbanPriority = \"low\" | \"medium\" | \"high\" | \"urgent\";\n\nexport type KanbanCard = {\n  id: string;\n  label: string;\n  /** Small label above the title, for example \"Design\". */\n  tag?: string;\n  /** Shown as a priority glyph at the bottom left of the card. */\n  priority?: KanbanPriority;\n  /** Initials for the avatar at the bottom right, for example \"MK\". */\n  assignee?: string;\n};\n\nexport type KanbanColumns = Record<string, KanbanCard[]>;\n\nexport type KanbanDragColumnsProps = {\n  /** The starting board: column name to cards. Column names must be unique. Read once on mount. */\n  initialColumns?: KanbanColumns;\n  /** Called with the whole board after every committed move (on drop, or on each keyboard step). */\n  onChange?: (columns: KanbanColumns) => void;\n  /** Surface of the board: dark glass or white paper. */\n  tone?: \"dark\" | \"light\";\n  /** Classes for the root. The default sets the width; pass your own to replace it. */\n  className?: string;\n};\n\nconst DEFAULT_COLUMNS: KanbanColumns = {\n  Todo: [\n    { id: \"t1\", label: \"Wireframe hero\", tag: \"Design\", priority: \"medium\", assignee: \"MK\" },\n    { id: \"t2\", label: \"Write copy\", tag: \"Content\", priority: \"low\", assignee: \"JA\" },\n    { id: \"t3\", label: \"Audit colour tokens\", tag: \"Design\", priority: \"low\" },\n  ],\n  Doing: [\n    { id: \"d1\", label: \"Build nav\", tag: \"Frontend\", priority: \"high\", assignee: \"RS\" },\n    { id: \"d3\", label: \"Fix checkout bug\", tag: \"Bug\", priority: \"urgent\", assignee: \"TL\" },\n  ],\n  Done: [\n    { id: \"d2\", label: \"Set up repo\", tag: \"Infra\", priority: \"low\", assignee: \"DN\" },\n    { id: \"d4\", label: \"Pick type scale\", tag: \"Design\", priority: \"medium\", assignee: \"MK\" },\n  ],\n};\n\nconst COLUMN_DOTS = [\"150,160,185\", \"120,160,255\", \"90,220,160\", \"240,180,90\", \"200,140,255\"];\nconst FALLBACK_EASE = \"cubic-bezier(0.34, 1.3, 0.64, 1)\";\nconst FLIP_MS = 460;\nconst LAND_MS = 400;\nconst useIsoLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/* A damped spring (stiffness 380, damping 26) sampled into a CSS linear() curve, with a cubic-bezier fallback. */\nconst SPRING =\n  \"linear(0, 0.046, 0.156, 0.299, 0.452, 0.597, 0.726, 0.832, 0.916, 0.977, 1.018, 1.044, 1.057, 1.06, 1.057, 1.051, 1.042, 1.033, 1.024, 1.016, 1.01, 1.005, 1.001, 0.999, 0.997, 0.997, 0.996, 0.997, 0.997, 0.997, 0.998, 0.999, 0.999, 0.999, 1, 1, 1)\";\n\nconst CSS = [\n  \".kb{--kb-ease:\" + FALLBACK_EASE + \";position:relative;box-sizing:border-box;font-size:14px;color:var(--kb-text);text-align:left;-webkit-tap-highlight-color:transparent}\",\n  \"@supports (transition-timing-function:linear(0,1)){.kb{--kb-ease:\" + SPRING + \"}}\",\n  \".kb *,.kb *::before,.kb *::after{box-sizing:border-box}\",\n  \".kb[data-tone=dark]{--kb-col-bg:rgba(255,255,255,.03);--kb-col-line:rgba(255,255,255,.08);--kb-text:rgba(255,255,255,.92);--kb-muted:rgba(255,255,255,.46);--kb-faint:rgba(255,255,255,.3);--kb-card-bg:linear-gradient(180deg,#22242b,#181a20);--kb-card-line:rgba(255,255,255,.1);--kb-card-hi:rgba(255,255,255,.3);--kb-hl:rgba(255,255,255,.07);--kb-pill:rgba(255,255,255,.08);--kb-sh:0 1px 0 rgba(0,0,0,.4),0 8px 16px -10px rgba(0,0,0,.7);--kb-lift:0 30px 50px -14px rgba(0,0,0,.9),0 12px 20px -10px rgba(0,0,0,.7);--kb-accent:132,164,255;--kb-ring:rgba(255,255,255,.9);--kb-av-bg-c:38% 26%;--kb-av-fg-c:80% 86%;--kb-tag-c:75% 70%;--kb-bar:rgba(255,255,255,.2);--kb-bar-on:rgba(255,255,255,.82)}\",\n  \".kb[data-tone=light]{--kb-col-bg:rgba(15,23,42,.04);--kb-col-line:rgba(15,23,42,.09);--kb-text:#171717;--kb-muted:#737373;--kb-faint:#a3a3a3;--kb-card-bg:linear-gradient(180deg,#ffffff,#fafafa);--kb-card-line:rgba(15,23,42,.11);--kb-card-hi:rgba(15,23,42,.34);--kb-hl:rgba(255,255,255,.9);--kb-pill:rgba(15,23,42,.07);--kb-sh:0 1px 2px rgba(15,23,42,.06),0 6px 14px -8px rgba(15,23,42,.12);--kb-lift:0 28px 44px -16px rgba(15,23,42,.34),0 10px 18px -10px rgba(15,23,42,.2);--kb-accent:59,91,255;--kb-ring:#171717;--kb-av-bg-c:80% 91%;--kb-av-fg-c:55% 28%;--kb-tag-c:55% 38%;--kb-bar:rgba(15,23,42,.18);--kb-bar-on:#262626}\",\n  \".kb-scroll{display:flex;align-items:flex-start;gap:12px;overflow-x:auto;overflow-y:hidden;padding:6px;margin:-6px;scroll-snap-type:x proximity;scroll-padding:0 6px;overscroll-behavior-x:contain;scrollbar-width:none}\",\n  \".kb-scroll::-webkit-scrollbar{display:none}\",\n  \"@media (pointer:coarse){.kb-scroll{scroll-snap-type:x mandatory}}\",\n  \".kb-col{position:relative;flex:1 0 min(248px,84%);min-width:0;scroll-snap-align:start;padding:10px;border-radius:18px;border:1px solid var(--kb-col-line);background:var(--kb-col-bg);transition:border-color .25s ease,background-color .25s ease,box-shadow .35s ease}\",\n  \".kb-col::before{content:\\\"\\\";position:absolute;left:18px;right:18px;top:-1px;height:2px;border-radius:2px;background:rgb(var(--kb-accent));opacity:0;transform:scaleX(.4);transition:opacity .25s ease,transform .4s var(--kb-ease)}\",\n  \".kb-col[data-over]{border-color:rgba(var(--kb-accent),.5);background:rgba(var(--kb-accent),.065);box-shadow:0 0 0 3px rgba(var(--kb-accent),.12),0 24px 60px -30px rgba(var(--kb-accent),.6)}\",\n  \".kb-col[data-over]::before{opacity:1;transform:scaleX(1)}\",\n  \".kb-head{display:flex;align-items:center;gap:8px;padding:3px 4px 11px}\",\n  \".kb-dot{flex:none;width:8px;height:8px;border-radius:50%;background:rgb(var(--kb-dot));box-shadow:0 0 10px rgba(var(--kb-dot),.55)}\",\n  \".kb-name{flex:1 1 auto;min-width:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:600;letter-spacing:-.005em;line-height:1.2;color:var(--kb-text)}\",\n  \".kb-count{flex:none;display:inline-grid;place-items:center;min-width:24px;height:20px;padding:0 7px;border-radius:999px;background:var(--kb-pill);color:var(--kb-muted);font:500 11px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-variant-numeric:tabular-nums;overflow:hidden}\",\n  \".kb-roll{display:inline-grid;overflow:hidden}\",\n  \".kb-roll>span{grid-area:1/1;display:block;text-align:center}\",\n  \".kb-roll-in[data-roll=up]{animation:kb-in-up .46s var(--kb-ease) both}\",\n  \".kb-roll-in[data-roll=down]{animation:kb-in-down .46s var(--kb-ease) both}\",\n  \".kb-roll-out[data-roll=up]{animation:kb-out-up .3s ease-in both}\",\n  \".kb-roll-out[data-roll=down]{animation:kb-out-down .3s ease-in both}\",\n  \"@keyframes kb-in-up{from{transform:translateY(100%);opacity:0}to{transform:translateY(0);opacity:1}}\",\n  \"@keyframes kb-in-down{from{transform:translateY(-100%);opacity:0}to{transform:translateY(0);opacity:1}}\",\n  \"@keyframes kb-out-up{from{transform:translateY(0);opacity:1}to{transform:translateY(-100%);opacity:0}}\",\n  \"@keyframes kb-out-down{from{transform:translateY(0);opacity:1}to{transform:translateY(100%);opacity:0}}\",\n  \".kb-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;position:relative;min-height:64px}\",\n  \".kb-list[data-empty]::before{content:\\\"No cards\\\";display:grid;place-items:center;height:64px;border-radius:12px;border:1px dashed var(--kb-col-line);color:var(--kb-faint);font-size:12px}\",\n  \".kb-li{position:relative;margin:0;padding:0}\",\n  \".kb-li[data-placeholder]::after{content:\\\"\\\";position:absolute;inset:0;border-radius:12px;border:1.5px dashed rgba(var(--kb-accent),.6);background:rgba(var(--kb-accent),.08);animation:kb-ph .3s ease-out}\",\n  \"@keyframes kb-ph{from{opacity:0}to{opacity:1}}\",\n  \".kb-li[data-placeholder] .kb-card{visibility:hidden}\",\n  \".kb-card{position:relative;display:flex;flex-direction:column;gap:8px;min-height:64px;padding:11px 12px 10px;border-radius:12px;border:1px solid var(--kb-card-line);background:var(--kb-card-bg);color:var(--kb-text);box-shadow:var(--kb-sh),inset 0 1px 0 var(--kb-hl);transition:border-color .2s ease,box-shadow .3s ease,transform .34s var(--kb-ease)}\",\n  \"@media (hover:hover){.kb-card{cursor:grab}.kb-li:not([data-placeholder]) .kb-card:hover{border-color:var(--kb-card-hi)}.kb-card:hover .kb-grip{color:var(--kb-muted)}}\",\n  \".kb-li[data-picked] .kb-card{border-color:var(--kb-card-hi);box-shadow:var(--kb-lift),inset 0 1px 0 var(--kb-hl);transform:scale(1.025)}\",\n  \".kb-li[data-settled] .kb-card{animation:kb-settle .9s ease-out}\",\n  \"@keyframes kb-settle{0%{border-color:rgba(var(--kb-accent),.95);box-shadow:0 0 0 4px rgba(var(--kb-accent),.22),var(--kb-sh)}100%{border-color:var(--kb-card-line);box-shadow:0 0 0 0 rgba(var(--kb-accent),0),var(--kb-sh)}}\",\n  \".kb-tag{display:flex;align-items:center;gap:6px;margin:0;padding-right:30px;min-width:0;font-size:11px;font-weight:500;letter-spacing:.01em;line-height:1;color:var(--kb-muted)}\",\n  \".kb-tag i{flex:none;width:6px;height:6px;border-radius:50%;background:hsl(var(--kb-h) var(--kb-tag-c))}\",\n  \".kb-tag span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\",\n  \".kb-title{margin:0;font-size:13.5px;font-weight:500;letter-spacing:-.005em;line-height:1.35;color:var(--kb-text);overflow-wrap:anywhere}\",\n  \".kb-card[data-notag] .kb-title{padding-right:30px}\",\n  \".kb-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:22px}\",\n  \".kb-prio{display:block;width:16px;height:16px;flex:none}\",\n  \".kb-avatar{display:grid;place-items:center;flex:none;width:22px;height:22px;border-radius:50%;background:hsl(var(--kb-h) var(--kb-av-bg-c));color:hsl(var(--kb-h) var(--kb-av-fg-c));font:600 9.5px/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.02em}\",\n  \".kb-grip{appearance:none;-webkit-appearance:none;position:absolute;top:6px;right:6px;display:grid;place-items:center;width:28px;height:28px;margin:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--kb-faint);cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;transition:color .2s ease,background-color .2s ease}\",\n  \".kb-grip::before{content:\\\"\\\";position:absolute;inset:-6px}\",\n  \".kb-grip:hover{background:var(--kb-pill)}\",\n  \".kb-li[data-picked] .kb-grip{color:var(--kb-text)}\",\n  \".kb-grip:focus-visible{outline:2px solid var(--kb-ring);outline-offset:2px;border-radius:8px}\",\n  \"@media (pointer:coarse){.kb-grip{top:2px;right:2px;width:40px;height:40px}}\",\n  \".kb-grip svg{display:block;width:14px;height:14px}\",\n  \".kb-ghost{position:absolute;left:0;top:0;z-index:30;margin:0;pointer-events:none;will-change:translate,scale,rotate;transform-origin:50% 40%;transition:scale .34s var(--kb-ease),rotate .3s ease-out}\",\n  \".kb-ghost .kb-card{border-color:var(--kb-card-hi);box-shadow:var(--kb-lift),inset 0 1px 0 var(--kb-hl);cursor:grabbing;transition:box-shadow .4s ease,border-color .4s ease}\",\n  \".kb-ghost[data-landing] .kb-card{border-color:var(--kb-card-line);box-shadow:var(--kb-sh),inset 0 1px 0 var(--kb-hl)}\",\n  \".kb[data-dragging],.kb[data-dragging] *{user-select:none;-webkit-user-select:none}\",\n  \".kb[data-dragging] *{cursor:grabbing!important}\",\n  \".kb[data-dragging] .kb-scroll{scroll-snap-type:none}\",\n  \".kb-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\",\n  \"@media (prefers-reduced-motion:reduce){.kb-card{transition:box-shadow .15s ease,border-color .15s ease}.kb-li[data-picked] .kb-card{transform:none}.kb-li[data-settled] .kb-card,.kb-li[data-placeholder]::after{animation:none}.kb-roll-in,.kb-roll-out{animation:none!important}.kb-roll-out{display:none}.kb-col::before{transition:none}}\",\n].join(\"\\n\");\n\nconst PRIORITY_LABEL: Record<KanbanPriority, string> = {\n  low: \"Low priority\",\n  medium: \"Medium priority\",\n  high: \"High priority\",\n  urgent: \"Urgent\",\n};\n\nfunction hueOf(text: string): number {\n  let h = 0;\n  for (let i = 0; i < text.length; i++) h = (h * 31 + text.charCodeAt(i)) % 360;\n  return h;\n}\n\nfunction cloneColumns(src: KanbanColumns): KanbanColumns {\n  const out: KanbanColumns = {};\n  for (const name of Object.keys(src)) out[name] = (src[name] ?? []).map((c) => ({ ...c }));\n  return out;\n}\n\nfunction PriorityIcon({ level }: { level: KanbanPriority }) {\n  if (level === \"urgent\") {\n    return (\n      <svg className=\"kb-prio\" viewBox=\"0 0 16 16\" role=\"img\" aria-label={PRIORITY_LABEL.urgent}>\n        <rect x=\"1.5\" y=\"1.5\" width=\"13\" height=\"13\" rx=\"4\" fill=\"#ff7a59\" />\n        <rect x=\"7.2\" y=\"4.2\" width=\"1.6\" height=\"4.8\" rx=\".8\" fill=\"#fff\" />\n        <circle cx=\"8\" cy=\"11.2\" r=\".95\" fill=\"#fff\" />\n      </svg>\n    );\n  }\n  const on = level === \"high\" ? 3 : level === \"medium\" ? 2 : 1;\n  return (\n    <svg className=\"kb-prio\" viewBox=\"0 0 16 16\" role=\"img\" aria-label={PRIORITY_LABEL[level]}>\n      {[0, 1, 2].map((i) => (\n        <rect\n          key={i}\n          x={2 + i * 4.4}\n          y={10 - i * 3}\n          width=\"3\"\n          height={4 + i * 3}\n          rx=\"1\"\n          style={{ fill: i < on ? \"var(--kb-bar-on)\" : \"var(--kb-bar)\" }}\n        />\n      ))}\n    </svg>\n  );\n}\n\nfunction CardFace({ card }: { card: KanbanCard }) {\n  const hasFoot = Boolean(card.priority || card.assignee);\n  return (\n    <>\n      {card.tag ? (\n        <p className=\"kb-tag\" style={{ \"--kb-h\": hueOf(card.tag) } as CSSProperties}>\n          <i aria-hidden=\"true\" />\n          <span>{card.tag}</span>\n        </p>\n      ) : null}\n      <p className=\"kb-title\">{card.label}</p>\n      {hasFoot ? (\n        <div className=\"kb-foot\">\n          {card.priority ? <PriorityIcon level={card.priority} /> : <span />}\n          {card.assignee ? (\n            <span\n              className=\"kb-avatar\"\n              style={{ \"--kb-h\": hueOf(card.assignee) } as CSSProperties}\n              role=\"img\"\n              aria-label={\"Assigned to \" + card.assignee}\n            >\n              {card.assignee.slice(0, 2).toUpperCase()}\n            </span>\n          ) : null}\n        </div>\n      ) : null}\n    </>\n  );\n}\n\n/* The count badge: the old number rolls out and the new one rolls in. */\nfunction Roll({ value }: { value: number }) {\n  const [s, setS] = useState({ to: value, from: value, n: 0, dir: \"up\" });\n  if (s.to !== value) setS({ to: value, from: s.to, n: s.n + 1, dir: value > s.to ? \"up\" : \"down\" });\n  const rolling = s.n > 0;\n  return (\n    <span className=\"kb-roll\" aria-hidden=\"true\">\n      {rolling ? (\n        <span key={\"o\" + s.n} className=\"kb-roll-out\" data-roll={s.dir}>\n          {s.from}\n        </span>\n      ) : null}\n      <span key={\"i\" + s.n} className=\"kb-roll-in\" data-roll={rolling ? s.dir : undefined}>\n        {s.to}\n      </span>\n    </span>\n  );\n}\n\ntype Session = {\n  id: string;\n  pointerId: number;\n  startX: number;\n  startY: number;\n  started: boolean;\n  offX: number;\n  offY: number;\n  px: number;\n  py: number;\n  lastX: number;\n  origin: KanbanColumns;\n};\n\ntype Drag = { id: string; w: number; h: number };\ntype Where = { name: string; index: number };\n\nconst clamp = (n: number, lo: number, hi: number) => Math.min(Math.max(n, lo), hi);\n\nexport function KanbanDragColumns({\n  initialColumns = DEFAULT_COLUMNS,\n  onChange,\n  tone = \"dark\",\n  className = \"w-full\",\n}: KanbanDragColumnsProps) {\n  const [cols, setCols] = useState<KanbanColumns>(() => cloneColumns(initialColumns));\n  const [drag, setDrag] = useState<Drag | null>(null);\n  const [landing, setLanding] = useState(false);\n  const [over, setOver] = useState<string | null>(null);\n  const [picked, setPicked] = useState<string | null>(null);\n  const [settled, setSettled] = useState<string | null>(null);\n  const [message, setMessage] = useState(\"\");\n  const uid = useId().replace(/[^a-zA-Z0-9]/g, \"\");\n\n  const rootRef = useRef<HTMLDivElement>(null);\n  const scrollRef = useRef<HTMLDivElement>(null);\n  const ghostRef = useRef<HTMLDivElement>(null);\n  const colsRef = useRef(cols);\n  const pickedRef = useRef<string | null>(null);\n  const dragIdRef = useRef<string | null>(null);\n  const sessionRef = useRef<Session | null>(null);\n  const pendingRef = useRef<Map<string, { x: number; y: number }> | null>(null);\n  const keyOriginRef = useRef<KanbanColumns | null>(null);\n  const cancelRef = useRef(false);\n  const focusAfterRef = useRef<string | null>(null);\n  const ghostPosRef = useRef({ x: 0, y: 0 });\n  const reducedRef = useRef(false);\n  const onChangeRef = useRef(onChange);\n  const retargetRef = useRef<() => void>(() => {});\n  const cleanupRef = useRef<(() => void) | null>(null);\n  const tiltTimer = useRef(0);\n  const landTimer = useRef(0);\n  const settleTimer = useRef(0);\n\n  useIsoLayoutEffect(() => {\n    colsRef.current = cols;\n    pickedRef.current = picked;\n    dragIdRef.current = drag ? drag.id : null;\n    onChangeRef.current = onChange;\n  });\n\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const sync = () => {\n      reducedRef.current = mq.matches;\n    };\n    sync();\n    mq.addEventListener(\"change\", sync);\n    return () => mq.removeEventListener(\"change\", sync);\n  }, []);\n\n  useEffect(\n    () => () => {\n      window.clearTimeout(tiltTimer.current);\n      window.clearTimeout(landTimer.current);\n      window.clearTimeout(settleTimer.current);\n      cleanupRef.current?.();\n    },\n    [],\n  );\n\n  /* ---- Measuring -------------------------------------------------------- */\n\n  const scaleOf = useCallback((): number => {\n    const r = rootRef.current;\n    if (!r) return 1;\n    const b = r.getBoundingClientRect();\n    return b.width ? r.offsetWidth / b.width : 1;\n  }, []);\n\n  const lis = useCallback((): HTMLElement[] => {\n    const r = rootRef.current;\n    return r ? Array.from(r.querySelectorAll<HTMLElement>(\"[data-cid]\")) : [];\n  }, []);\n\n  const liFor = useCallback(\n    (id: string): HTMLElement | undefined => lis().find((el) => el.dataset.cid === id),\n    [lis],\n  );\n\n  /* Where every card visually is right now, in layout pixels from the root's corner. */\n  const captureAll = useCallback((): Map<string, { x: number; y: number }> => {\n    const out = new Map<string, { x: number; y: number }>();\n    const root = rootRef.current;\n    if (!root) return out;\n    const rb = root.getBoundingClientRect();\n    const s = scaleOf();\n    for (const li of lis()) {\n      const id = li.dataset.cid;\n      if (!id) continue;\n      const b = li.getBoundingClientRect();\n      out.set(id, { x: (b.left - rb.left) * s, y: (b.top - rb.top) * s });\n    }\n    return out;\n  }, [lis, scaleOf]);\n\n  const locate = useCallback((id: string, from?: KanbanColumns): Where | null => {\n    const board = from ?? colsRef.current;\n    for (const name of Object.keys(board)) {\n      const index = (board[name] ?? []).findIndex((c) => c.id === id);\n      if (index >= 0) return { name, index };\n    }\n    return null;\n  }, []);\n\n  const say = useCallback(\n    (text: string) => setMessage((prev) => (prev === text ? text + \" \" : text)),\n    [],\n  );\n\n  const flash = useCallback((id: string) => {\n    setSettled(id);\n    window.clearTimeout(settleTimer.current);\n    settleTimer.current = window.setTimeout(() => setSettled(null), 900);\n  }, []);\n\n  const emit = useCallback((board: KanbanColumns) => {\n    onChangeRef.current?.(cloneColumns(board));\n  }, []);\n\n  /* Move a card in the board, remembering where everything was so the layout effect can FLIP it. */\n  const moveTo = useCallback(\n    (id: string, to: string, toIndex: number): boolean => {\n      const prev = colsRef.current;\n      const at = locate(id, prev);\n      const card = at ? (prev[at.name] ?? [])[at.index] : undefined;\n      if (!at || !card) return false;\n      const target = (prev[to] ?? []).filter((c) => c.id !== id);\n      const idx = clamp(toIndex, 0, target.length);\n      if (at.name === to && at.index === idx) return false;\n      const next: KanbanColumns = {};\n      for (const name of Object.keys(prev)) {\n        const list = (prev[name] ?? []).filter((c) => c.id !== id);\n        if (name === to) list.splice(idx, 0, card);\n        next[name] = list;\n      }\n      pendingRef.current = captureAll();\n      colsRef.current = next;\n      setCols(next);\n      return true;\n    },\n    [captureAll, locate],\n  );\n\n  const revealColumn = useCallback((name: string) => {\n    const sc = scrollRef.current;\n    const root = rootRef.current;\n    if (!sc || !root) return;\n    const el = Array.from(root.querySelectorAll<HTMLElement>(\"[data-col]\")).find((c) => c.dataset.col === name);\n    if (!el) return;\n    const sb = sc.getBoundingClientRect();\n    const cb = el.getBoundingClientRect();\n    const k = scaleOf();\n    let dx = 0;\n    if (cb.left < sb.left + 4) dx = (cb.left - sb.left - 8) * k;\n    else if (cb.right > sb.right - 4) dx = (cb.right - sb.right + 8) * k;\n    if (dx) sc.scrollBy({ left: dx, behavior: reducedRef.current ? \"auto\" : \"smooth\" });\n  }, [scaleOf]);\n\n  /* FLIP after every commit; refocus the held card's grip, which remounts when it changes column. */\n  useIsoLayoutEffect(() => {\n    const from = pendingRef.current;\n    pendingRef.current = null;\n    if (from && !reducedRef.current) {\n      const root = rootRef.current;\n      if (root) {\n        const ease = getComputedStyle(root).getPropertyValue(\"--kb-ease\").trim() || FALLBACK_EASE;\n        const els = lis();\n        els.forEach((li) => li.getAnimations().forEach((a) => a.cancel()));\n        const rb = root.getBoundingClientRect();\n        const s = scaleOf();\n        for (const li of els) {\n          const id = li.dataset.cid;\n          const was = id ? from.get(id) : undefined;\n          if (!was || typeof li.animate !== \"function\") continue;\n          const b = li.getBoundingClientRect();\n          const dx = was.x - (b.left - rb.left) * s;\n          const dy = was.y - (b.top - rb.top) * s;\n          if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5) continue;\n          li.animate(\n            [{ transform: \"translate3d(\" + dx + \"px,\" + dy + \"px,0)\" }, { transform: \"translate3d(0,0,0)\" }],\n            { duration: FLIP_MS, easing: ease },\n          );\n        }\n      }\n    }\n    const held = pickedRef.current ?? focusAfterRef.current;\n    focusAfterRef.current = null;\n    if (held) {\n      const grip = liFor(held)?.querySelector<HTMLElement>(\"button\");\n      if (grip && document.activeElement !== grip) grip.focus({ preventScroll: true });\n    }\n  }, [cols, lis, liFor, scaleOf]);\n\n  /* ---- The floating copy ------------------------------------------------ */\n\n  const applyGhost = useCallback(() => {\n    const g = ghostRef.current;\n    if (!g) return;\n    g.style.translate = ghostPosRef.current.x + \"px \" + ghostPosRef.current.y + \"px\";\n  }, []);\n\n  useIsoLayoutEffect(() => {\n    const g = ghostRef.current;\n    if (!g || !drag) return;\n    g.style.translate = ghostPosRef.current.x + \"px \" + ghostPosRef.current.y + \"px\";\n    g.style.scale = \"1\";\n    g.style.rotate = \"0deg\";\n    if (reducedRef.current) {\n      g.style.transition = \"none\";\n      return;\n    }\n    void g.offsetWidth;\n    g.style.scale = \"1.035\";\n  }, [drag]);\n\n  /* ---- Pointer dragging ------------------------------------------------- */\n\n  const retarget = useCallback(() => {\n    const s = sessionRef.current;\n    const root = rootRef.current;\n    if (!s || !s.started || !root) return;\n    let best: HTMLElement | null = null;\n    let bestD = Infinity;\n    for (const el of Array.from(root.querySelectorAll<HTMLElement>(\"[data-col]\"))) {\n      const r = el.getBoundingClientRect();\n      const d = s.px < r.left ? r.left - s.px : s.px > r.right ? s.px - r.right : 0;\n      if (d < bestD) {\n        bestD = d;\n        best = el;\n      }\n    }\n    const name = best?.dataset.col;\n    const ul = best?.querySelector<HTMLElement>(\"ul\");\n    if (!best || !name || !ul) return;\n    setOver(name);\n    const ub = ul.getBoundingClientRect();\n    const k = ub.height ? ul.offsetHeight / ub.height : 1;\n    let count = 0;\n    for (const li of Array.from(ul.children) as HTMLElement[]) {\n      const cid = li.dataset.cid;\n      if (!cid || cid === s.id) continue;\n      const mid = ub.top + (li.offsetTop + li.offsetHeight / 2) / k;\n      if (mid < s.py) count++;\n    }\n    moveTo(s.id, name, count);\n  }, [moveTo]);\n\n  useIsoLayoutEffect(() => {\n    retargetRef.current = retarget;\n  }, [retarget]);\n\n  const dragging = drag !== null && !landing;\n  useEffect(() => {\n    if (!dragging) return;\n    let raf = 0;\n    const tick = () => {\n      const s = sessionRef.current;\n      const sc = scrollRef.current;\n      if (s && s.started && sc) {\n        const r = sc.getBoundingClientRect();\n        const zone = 64;\n        let v = 0;\n        if (s.px < r.left + zone) v = -(1 - clamp(s.px - r.left, 0, zone) / zone);\n        else if (s.px > r.right - zone) v = 1 - clamp(r.right - s.px, 0, zone) / zone;\n        if (v) {\n          const before = sc.scrollLeft;\n          sc.scrollLeft += v * 16;\n          if (sc.scrollLeft !== before) retargetRef.current();\n        }\n      }\n      raf = requestAnimationFrame(tick);\n    };\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [dragging]);\n\n  /* Release (or cancel): fly the copy into its slot, then swap it for the real card. */\n  useIsoLayoutEffect(() => {\n    if (!landing) return;\n    const id = dragIdRef.current;\n    const g = ghostRef.current;\n    const root = rootRef.current;\n    if (!id || !g || !root) return;\n    const li = liFor(id);\n    if (li) {\n      li.getAnimations().forEach((a) => a.cancel());\n      const rb = root.getBoundingClientRect();\n      const b = li.getBoundingClientRect();\n      const s = scaleOf();\n      ghostPosRef.current = { x: (b.left - rb.left) * s, y: (b.top - rb.top) * s };\n    }\n    const reduced = reducedRef.current;\n    if (!reduced) {\n      const ease = getComputedStyle(root).getPropertyValue(\"--kb-ease\").trim() || FALLBACK_EASE;\n      const t = LAND_MS / 1000 + \"s \" + ease;\n      g.style.transition = \"translate \" + t + \", scale \" + t + \", rotate \" + t;\n    }\n    g.dataset.landing = \"\";\n    g.style.translate = ghostPosRef.current.x + \"px \" + ghostPosRef.current.y + \"px\";\n    g.style.scale = \"1\";\n    g.style.rotate = \"0deg\";\n    window.clearTimeout(landTimer.current);\n    landTimer.current = window.setTimeout(\n      () => {\n        const board = colsRef.current;\n        const origin = keyOriginRef.current;\n        keyOriginRef.current = null;\n        setDrag(null);\n        setLanding(false);\n        flash(id);\n        const at = locate(id, board);\n        const card = at ? (board[at.name] ?? [])[at.index] : undefined;\n        if (at && card) {\n          if (origin && !sameBoard(origin, board)) emit(board);\n          say(cancelRef.current ? \"Cancelled. \" + card.label + \" returned to \" + at.name + \".\" : card.label + \" dropped in \" + at.name + \", position \" + (at.index + 1) + \" of \" + (board[at.name] ?? []).length + \".\");\n        }\n      },\n      reduced ? 0 : LAND_MS,\n    );\n  }, [landing, liFor, scaleOf, flash, locate, emit, say]);\n\n  const finish = useCallback(\n    (cancel: boolean) => {\n      const s = sessionRef.current;\n      if (!s) return;\n      sessionRef.current = null;\n      cleanupRef.current?.();\n      cleanupRef.current = null;\n      window.clearTimeout(tiltTimer.current);\n      setOver(null);\n      if (!s.started) return;\n      keyOriginRef.current = s.origin;\n      cancelRef.current = cancel;\n      if (cancel) {\n        pendingRef.current = captureAll();\n        colsRef.current = s.origin;\n        setCols(s.origin);\n      }\n      setLanding(true);\n    },\n    [captureAll],\n  );\n\n  const onGripDown = (e: ReactPointerEvent<HTMLElement>, id: string) => {\n    if (sessionRef.current || pickedRef.current || dragIdRef.current) return;\n    if (e.pointerType === \"mouse\" && e.button !== 0) return;\n    const onGrip = Boolean((e.target as HTMLElement).closest(\".kb-grip\"));\n    if (e.pointerType === \"touch\" && !onGrip) return;\n    if (e.pointerType === \"mouse\") e.preventDefault();\n    sessionRef.current = {\n      id,\n      pointerId: e.pointerId,\n      startX: e.clientX,\n      startY: e.clientY,\n      started: false,\n      offX: 0,\n      offY: 0,\n      px: e.clientX,\n      py: e.clientY,\n      lastX: e.clientX,\n      origin: cloneColumns(colsRef.current),\n    };\n    const onMove = (ev: PointerEvent) => {\n      const s = sessionRef.current;\n      if (!s || ev.pointerId !== s.pointerId) return;\n      if (!s.started) {\n        if (Math.hypot(ev.clientX - s.startX, ev.clientY - s.startY) < 4) return;\n        const li = liFor(s.id);\n        const root = rootRef.current;\n        const card = li?.querySelector<HTMLElement>(\".kb-card\");\n        if (!li || !root || !card) return;\n        const k = scaleOf();\n        const cb = card.getBoundingClientRect();\n        s.started = true;\n        s.offX = (s.startX - cb.left) * k;\n        s.offY = (s.startY - cb.top) * k;\n        li.getAnimations().forEach((a) => a.cancel());\n        root.dataset.dragging = \"\";\n        setDrag({ id: s.id, w: card.offsetWidth, h: card.offsetHeight });\n        const at = locate(s.id);\n        if (at) say(\"Dragging \" + (colsRef.current[at.name] ?? [])[at.index]?.label + \".\");\n      }\n      s.px = ev.clientX;\n      s.py = ev.clientY;\n      const root = rootRef.current;\n      if (root) {\n        const rb = root.getBoundingClientRect();\n        const k = scaleOf();\n        ghostPosRef.current = { x: (ev.clientX - rb.left) * k - s.offX, y: (ev.clientY - rb.top) * k - s.offY };\n        applyGhost();\n      }\n      const g = ghostRef.current;\n      if (g && !reducedRef.current) {\n        g.style.rotate = clamp((ev.clientX - s.lastX) * 0.6, -6, 6) + \"deg\";\n        window.clearTimeout(tiltTimer.current);\n        tiltTimer.current = window.setTimeout(() => {\n          if (ghostRef.current) ghostRef.current.style.rotate = \"0deg\";\n        }, 90);\n      }\n      s.lastX = ev.clientX;\n      retarget();\n    };\n    const onUp = (ev: PointerEvent) => {\n      const s = sessionRef.current;\n      if (!s || ev.pointerId !== s.pointerId) return;\n      finish(ev.type === \"pointercancel\");\n    };\n    const onKey = (ev: KeyboardEvent) => {\n      if (ev.key === \"Escape\" && sessionRef.current?.started) {\n        ev.preventDefault();\n        finish(true);\n      }\n    };\n    window.addEventListener(\"pointermove\", onMove);\n    window.addEventListener(\"pointerup\", onUp);\n    window.addEventListener(\"pointercancel\", onUp);\n    window.addEventListener(\"keydown\", onKey);\n    cleanupRef.current = () => {\n      window.removeEventListener(\"pointermove\", onMove);\n      window.removeEventListener(\"pointerup\", onUp);\n      window.removeEventListener(\"pointercancel\", onUp);\n      window.removeEventListener(\"keydown\", onKey);\n    };\n  };\n\n  /* ---- Keyboard --------------------------------------------------------- */\n\n  const describe = (id: string): string => {\n    const at = locate(id);\n    const card = at ? (colsRef.current[at.name] ?? [])[at.index] : undefined;\n    if (!at || !card) return \"\";\n    return card.label + \", \" + at.name + \", position \" + (at.index + 1) + \" of \" + (colsRef.current[at.name] ?? []).length + \".\";\n  };\n\n  const focusGrip = (id: string) => liFor(id)?.querySelector<HTMLElement>(\"button\")?.focus();\n\n  const keyMove = (id: string, to: string, index: number) => {\n    const at = locate(id);\n    if (!at) return;\n    if (moveTo(id, to, index)) {\n      revealColumn(to);\n      say(describe(id));\n    } else {\n      say(describe(id).replace(/\\.$/, \"\") + \". Can't move further.\");\n    }\n  };\n\n  const dropKey = (id: string) => {\n    const board = colsRef.current;\n    const origin = keyOriginRef.current;\n    keyOriginRef.current = null;\n    pickedRef.current = null;\n    setPicked(null);\n    flash(id);\n    say(\"Dropped. \" + describe(id));\n    if (origin && !sameBoard(origin, board)) emit(board);\n  };\n\n  const onGripKey = (e: ReactKeyboardEvent<HTMLButtonElement>, id: string) => {\n    if (sessionRef.current || dragIdRef.current) return;\n    const names = Object.keys(colsRef.current);\n    const at = locate(id);\n    if (!at) return;\n    const k = e.key;\n    const colIdx = names.indexOf(at.name);\n    const isPicked = pickedRef.current === id;\n    if (!isPicked) {\n      if (k === \" \" || k === \"Enter\") {\n        e.preventDefault();\n        keyOriginRef.current = cloneColumns(colsRef.current);\n        pickedRef.current = id;\n        setPicked(id);\n        say(\"Picked up \" + describe(id) + \" Arrow keys move it, left and right change column, space drops, escape cancels.\");\n        return;\n      }\n      let dest: KanbanCard | undefined;\n      if (k === \"ArrowUp\" || k === \"ArrowDown\") {\n        dest = (colsRef.current[at.name] ?? [])[at.index + (k === \"ArrowUp\" ? -1 : 1)];\n      } else if (k === \"ArrowLeft\" || k === \"ArrowRight\") {\n        const step = k === \"ArrowLeft\" ? -1 : 1;\n        for (let c = colIdx + step; c >= 0 && c < names.length && !dest; c += step) {\n          const list = colsRef.current[names[c] ?? \"\"] ?? [];\n          dest = list[Math.min(at.index, list.length - 1)];\n        }\n      } else return;\n      e.preventDefault();\n      if (dest) focusGrip(dest.id);\n      return;\n    }\n    const lastIdx = (colsRef.current[at.name] ?? []).length - 1;\n    if (k === \"ArrowUp\") {\n      e.preventDefault();\n      keyMove(id, at.name, at.index - 1);\n    } else if (k === \"ArrowDown\") {\n      e.preventDefault();\n      keyMove(id, at.name, at.index + 1);\n    } else if (k === \"ArrowLeft\" || k === \"ArrowRight\") {\n      e.preventDefault();\n      const dest = names[colIdx + (k === \"ArrowLeft\" ? -1 : 1)];\n      if (dest) keyMove(id, dest, at.index);\n      else say(describe(id).replace(/\\.$/, \"\") + \". No column that way.\");\n    } else if (k === \"Home\") {\n      e.preventDefault();\n      keyMove(id, at.name, 0);\n    } else if (k === \"End\") {\n      e.preventDefault();\n      keyMove(id, at.name, lastIdx);\n    } else if (k === \" \" || k === \"Enter\") {\n      e.preventDefault();\n      dropKey(id);\n    } else if (k === \"Escape\") {\n      e.preventDefault();\n      const origin = keyOriginRef.current;\n      keyOriginRef.current = null;\n      pickedRef.current = null;\n      setPicked(null);\n      if (origin) {\n        focusAfterRef.current = id;\n        pendingRef.current = captureAll();\n        colsRef.current = origin;\n        setCols(origin);\n        say(\"Cancelled. \" + (locate(id, origin) ? describeIn(origin, id) : \"\"));\n      }\n    }\n  };\n\n  const onGripBlur = (id: string) => {\n    window.setTimeout(() => {\n      if (pickedRef.current !== id) return;\n      const grip = liFor(id)?.querySelector(\"button\");\n      if (grip && document.activeElement === grip) return;\n      dropKey(id);\n    }, 0);\n  };\n\n  const names = Object.keys(cols);\n  const safeTone = tone === \"light\" ? \"light\" : \"dark\";\n  const dragged = drag ? findCard(cols, drag.id) : null;\n\n  return (\n    <div ref={rootRef} className={\"kb \" + className} data-tone={safeTone}>\n      <style>{CSS}</style>\n      <div ref={scrollRef} className=\"kb-scroll\" role=\"group\" aria-label=\"Kanban board\">\n        {names.map((name, ci) => {\n          const cards = cols[name] ?? [];\n          return (\n            <section\n              key={name}\n              className=\"kb-col\"\n              data-col={name}\n              data-over={over === name ? \"\" : undefined}\n              aria-labelledby={\"kb-h-\" + uid + \"-\" + ci}\n              style={{ \"--kb-dot\": COLUMN_DOTS[ci % COLUMN_DOTS.length] } as CSSProperties}\n            >\n              <header className=\"kb-head\">\n                <span className=\"kb-dot\" aria-hidden=\"true\" />\n                <h3 className=\"kb-name\" id={\"kb-h-\" + uid + \"-\" + ci}>\n                  {name}\n                  <span className=\"kb-sr\">{\", \" + cards.length + (cards.length === 1 ? \" card\" : \" cards\")}</span>\n                </h3>\n                <span className=\"kb-count\">\n                  <Roll value={cards.length} />\n                </span>\n              </header>\n              <ul className=\"kb-list\" data-empty={cards.length === 0 ? \"\" : undefined} aria-label={name + \" cards\"}>\n                {cards.map((card, i) => (\n                  <li\n                    key={card.id}\n                    className=\"kb-li\"\n                    data-cid={card.id}\n                    data-placeholder={drag && drag.id === card.id ? \"\" : undefined}\n                    data-picked={picked === card.id ? \"\" : undefined}\n                    data-settled={settled === card.id ? \"\" : undefined}\n                  >\n                    <div className=\"kb-card\" data-notag={card.tag ? undefined : \"\"} onPointerDown={(e) => onGripDown(e, card.id)}>\n                      <CardFace card={card} />\n                      <button\n                        type=\"button\"\n                        className=\"kb-grip\"\n                        aria-label={\"Move \" + card.label + \", \" + name + \", position \" + (i + 1) + \" of \" + cards.length}\n                        aria-pressed={picked === card.id}\n                        aria-describedby={\"kb-help-\" + uid}\n                        onKeyDown={(e) => onGripKey(e, card.id)}\n                        onBlur={() => onGripBlur(card.id)}\n                      >\n                        <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\">\n                          <circle cx=\"5.5\" cy=\"3.5\" r=\"1.3\" />\n                          <circle cx=\"10.5\" cy=\"3.5\" r=\"1.3\" />\n                          <circle cx=\"5.5\" cy=\"8\" r=\"1.3\" />\n                          <circle cx=\"10.5\" cy=\"8\" r=\"1.3\" />\n                          <circle cx=\"5.5\" cy=\"12.5\" r=\"1.3\" />\n                          <circle cx=\"10.5\" cy=\"12.5\" r=\"1.3\" />\n                        </svg>\n                      </button>\n                    </div>\n                  </li>\n                ))}\n              </ul>\n            </section>\n          );\n        })}\n      </div>\n      {drag && dragged ? (\n        <div ref={ghostRef} className=\"kb-ghost\" aria-hidden=\"true\" style={{ width: drag.w }}>\n          <div className=\"kb-card\" data-notag={dragged.tag ? undefined : \"\"}>\n            <CardFace card={dragged} />\n          </div>\n        </div>\n      ) : null}\n      <div id={\"kb-help-\" + uid} className=\"kb-sr\">\n        Press space to pick up a card, the arrow keys to move it, space to drop and escape to cancel.\n      </div>\n      <div className=\"kb-sr\" role=\"status\" aria-live=\"assertive\" aria-atomic=\"true\">\n        {message}\n      </div>\n    </div>\n  );\n}\n\nfunction findCard(board: KanbanColumns, id: string): KanbanCard | null {\n  for (const name of Object.keys(board)) {\n    const hit = (board[name] ?? []).find((c) => c.id === id);\n    if (hit) return hit;\n  }\n  return null;\n}\n\nfunction describeIn(board: KanbanColumns, id: string): string {\n  for (const name of Object.keys(board)) {\n    const list = board[name] ?? [];\n    const i = list.findIndex((c) => c.id === id);\n    const card = list[i];\n    if (card) return card.label + \" returned to \" + name + \", position \" + (i + 1) + \" of \" + list.length + \".\";\n  }\n  return \"\";\n}\n\nfunction sameBoard(a: KanbanColumns, b: KanbanColumns): boolean {\n  const an = Object.keys(a);\n  if (an.length !== Object.keys(b).length) return false;\n  for (const name of an) {\n    const x = a[name] ?? [];\n    const y = b[name] ?? [];\n    if (x.length !== y.length) return false;\n    for (let i = 0; i < x.length; i++) if (x[i]?.id !== y[i]?.id) return false;\n  }\n  return true;\n}\n","type":"registry:component","target":"components/viberdy/kanban-drag-columns.tsx"}],"meta":{"tier":"free","tags":["kanban","drag","board","columns","keyboard","accessible"],"href":"https://viberdy.dev/library/kanban-drag-columns","aiPrompt":"Build a dependency-free React + CSS kanban board as one \"use client\" file (React only; no Framer Motion, no dnd library, no icon package). Export `KanbanDragColumns` and the types `KanbanCard`, `KanbanColumns`, `KanbanPriority`, `KanbanDragColumnsProps`.\n\nProps (all optional): initialColumns: Record<string, KanbanCard[]> (column name to cards; names unique; read once on mount; default a Todo / Doing / Done board with 7 cards); onChange(columns) called with a copy of the whole board after each committed move; tone: \"dark\" | \"light\" = \"dark\"; className: string = \"w-full\" (sets the root width; passing a value replaces it). KanbanCard = { id: string; label: string; tag?: string; priority?: \"low\" | \"medium\" | \"high\" | \"urgent\"; assignee?: string (initials) }.\n\nMarkup: root div.kb (data-tone, position relative) with a plain <style> element (static CSS string), a div.kb-scroll (role group, aria-label \"Kanban board\": flex row, gap 12px, overflow-x auto, hidden scrollbar, scroll-snap-type x proximity (mandatory on coarse pointers, none while dragging), padding 6px with margin -6px). Each column is a section.kb-col (flex 1 0 min(248px, 84%), padding 10px, radius 18px, 1px border, translucent fill, aria-labelledby its h3) with a header (8px dot in a per-column colour from a five-colour palette with a soft glow, h3 name 13px/600 plus an sr-only \", N cards\", and a pill count badge 20px high, mono 11px) and a ul.kb-list (flex column, gap 8px, min-height 64px, position relative; an empty list shows a dashed \"No cards\" box). Each card is li[data-cid] > div.kb-card (padding 11px 12px 10px, radius 12px, 1px border, gradient #22242b to #181a20 in dark and #fff to #fafafa in light, resting shadow plus inset top highlight) containing: optional tag (6px dot with a hue hashed from the text, 11px muted text), title (13.5px / 500), and a footer row with a priority glyph (three rising bars with 1, 2 or 3 filled for low, medium, high; urgent is a 13px orange #ff7a59 rounded square with a white exclamation) on the left and a 22px avatar circle with the initials on the right (background and text hsl from a hash of the initials, tone-specific lightness). A 28px grip button (40px on coarse pointers, ::before extending the hit area by 6px, touch-action none) sits top right with a six-dot icon.\n\nCount badge: when the number changes the old value rolls out and the new one rolls in (translateY 100%, .46s spring in, .3s ease-in out), direction by increase or decrease; implemented by a render-time state adjustment, not an effect.\n\nSpring: damped spring (stiffness 380, damping 26, ~0.6s) as a CSS linear() curve in --kb-ease with cubic-bezier(.34,1.3,.64,1) as the fallback.\n\nPointer drag: pointerdown on a card (mouse, pen) or on its grip (touch; touch elsewhere keeps scrolling) registers window pointermove/up/cancel/keydown listeners. After 4px of movement the drag starts: measure everything in LAYOUT pixels (scale = root.offsetWidth / getBoundingClientRect().width), set data-dragging on the root, render a floating copy (position absolute in the root, width of the card, individual transform properties translate / scale / rotate, pointer-events none) that follows the pointer keeping the grab offset; it lifts to scale 1.035 with a deep shadow and tilts by clamp(dx*0.6, -6, 6) degrees, easing back to 0 after 90ms without movement. The real card stays in the data as a placeholder: card hidden, dashed 1.5px accent outline with an 8% accent fill. On every pointer move choose the column nearest horizontally (distance to its rect), set it as the drop target (accent border, 6.5% accent fill, 3px glow, a 2px accent line on top), and compute the slot: count the other cards whose layout midpoint (ul client top + (offsetTop + offsetHeight/2) / scale) is above the pointer. If column or index changed, record every card's root-relative position, commit the move, then in a layout effect FLIP-animate every card from its old to new position (translate3d via li.animate, 460ms, the spring); cards that change column remount, so animate from the recorded position. Within 64px of the scroller's left/right edge auto-scroll up to 16px per frame (rAF loop in an effect while dragging) and retarget. On release (or Escape, which restores the board from pickup) fly the copy to the placeholder's position over 400ms with scale 1 and rotation 0, then remove it, pulse a 4px accent ring on the card for .9s, call onChange if the board differs from pickup.\n\nKeyboard (grip button: aria-label \"Move <label>, <column>, position i of n\", aria-pressed, aria-describedby help text): not picked up: Space/Enter picks up (card lifts to scale 1.025), arrows move focus to the neighbouring grip (Left/Right to the nearest non-empty column at the same row). Picked up: Up/Down reorder, Left/Right move to the neighbouring column at the same index, Home/End to the ends, Space/Enter drop, Escape restores, blur (checked after a tick, because moving columns remounts the button) drops. Each move uses the same capture + FLIP commit, refocuses the grip, scrolls the column into view, and announces \"<label>, <column>, position i of n.\" in an assertive aria-live region; repeated messages get a trailing space.\n\nFocus ring: 2px solid, offset 2px, written as .kb-grip:focus-visible. Hover (hover-capable devices) brightens the card border and grip. prefers-reduced-motion: no tilt, no scale on the copy, no FLIP, no transitions, the copy snaps into its slot, badges change without rolling.","license":"https://viberdy.dev/license"}}