{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "appearance-settings",
  "type": "registry:block",
  "title": "Appearance Settings",
  "description": "Theme cards with miniature previews above a compact live app that re-themes with a circular wipe, eases into your accent colour and glides between densities as you change them.",
  "categories": [
    "screen",
    "Settings"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/radio-group.json",
    "https://coss.com/ui/r/segmented-control.json",
    "https://coss.com/ui/r/slider.json",
    "https://coss.com/ui/r/switch.json"
  ],
  "files": [
    {
      "path": "registry/devl/appearance-settings.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowLeftIcon,\n  BellIcon,\n  CheckIcon,\n  CreditCardIcon,\n  FileTextIcon,\n  FolderIcon,\n  InboxIcon,\n  KeyRoundIcon,\n  ListTodoIcon,\n  MoonIcon,\n  PaletteIcon,\n  PlusIcon,\n  SearchIcon,\n  SettingsIcon,\n  ShieldIcon,\n  SunIcon,\n  UserIcon,\n  UsersIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, MotionConfig, motion, useReducedMotion } from \"motion/react\";\nimport { type ComponentType, type CSSProperties, type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport { RadioGroupPrimitive, RadioPrimitive } from \"@/components/ui/radio-group\";\nimport { SegmentedControl, SegmentedControlItem } from \"@/components/ui/segmented-control\";\nimport { Slider } from \"@/components/ui/slider\";\nimport { Switch } from \"@/components/ui/switch\";\n\nexport type ThemeChoice = \"system\" | \"light\" | \"dark\";\nexport type Density = \"compact\" | \"default\" | \"comfortable\";\nexport type AccentName = \"indigo\" | \"violet\" | \"rose\" | \"orange\" | \"emerald\" | \"sky\";\n\nexport interface AppearancePrefs {\n  theme: ThemeChoice;\n  accent: AccentName;\n  density: Density;\n  textSize: number;\n  reduceMotion: boolean;\n  sidebarIcons: boolean;\n}\n\nexport interface AppearanceTask {\n  id: string;\n  title: string;\n  owner: string;\n  due: string;\n  done?: boolean;\n}\n\nexport interface AppearanceSettingsProps {\n  className?: string;\n  defaultPrefs?: AppearancePrefs;\n  workspace?: string;\n  tasks?: AppearanceTask[];\n  onChange?: (prefs: AppearancePrefs) => void;\n  onNavigate?: (section: string) => void;\n}\n\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst spring = { type: \"spring\", stiffness: 520, damping: 40 } as const;\nconst press = \"transition-[background-color,color,box-shadow,scale] duration-150 ease-out motion-safe:active:scale-[0.97]\";\nconst textSizes = [12, 13, 14, 15, 16, 17, 18];\nconst tintTransition = \"transition-[background-color,color,border-color] duration-300 ease-out\";\n\nconst factoryPrefs: AppearancePrefs = {\n  theme: \"system\",\n  accent: \"indigo\",\n  density: \"default\",\n  textSize: 14,\n  reduceMotion: false,\n  sidebarIcons: true,\n};\n\nconst accents: Record<\n  AccentName,\n  { label: string; swatch: string; light: { solid: string; ink: string }; dark: { solid: string; ink: string } }\n> = {\n  indigo: {\n    label: \"Indigo\",\n    swatch: \"bg-indigo-600 dark:bg-indigo-500\",\n    light: { solid: \"var(--color-indigo-600)\", ink: \"var(--color-indigo-700)\" },\n    dark: { solid: \"var(--color-indigo-500)\", ink: \"var(--color-indigo-300)\" },\n  },\n  violet: {\n    label: \"Violet\",\n    swatch: \"bg-violet-600 dark:bg-violet-500\",\n    light: { solid: \"var(--color-violet-600)\", ink: \"var(--color-violet-700)\" },\n    dark: { solid: \"var(--color-violet-500)\", ink: \"var(--color-violet-300)\" },\n  },\n  rose: {\n    label: \"Rose\",\n    swatch: \"bg-rose-600 dark:bg-rose-500\",\n    light: { solid: \"var(--color-rose-600)\", ink: \"var(--color-rose-700)\" },\n    dark: { solid: \"var(--color-rose-500)\", ink: \"var(--color-rose-300)\" },\n  },\n  orange: {\n    label: \"Orange\",\n    swatch: \"bg-orange-600 dark:bg-orange-500\",\n    light: { solid: \"var(--color-orange-600)\", ink: \"var(--color-orange-700)\" },\n    dark: { solid: \"var(--color-orange-500)\", ink: \"var(--color-orange-300)\" },\n  },\n  emerald: {\n    label: \"Emerald\",\n    swatch: \"bg-emerald-600 dark:bg-emerald-500\",\n    light: { solid: \"var(--color-emerald-600)\", ink: \"var(--color-emerald-700)\" },\n    dark: { solid: \"var(--color-emerald-600)\", ink: \"var(--color-emerald-300)\" },\n  },\n  sky: {\n    label: \"Sky\",\n    swatch: \"bg-sky-600 dark:bg-sky-500\",\n    light: { solid: \"var(--color-sky-600)\", ink: \"var(--color-sky-700)\" },\n    dark: { solid: \"var(--color-sky-600)\", ink: \"var(--color-sky-300)\" },\n  },\n};\n\nconst lightScope = {\n  \"--background\": \"var(--color-white)\",\n  \"--foreground\": \"var(--color-neutral-800)\",\n  \"--card\": \"var(--color-white)\",\n  \"--card-foreground\": \"var(--color-neutral-800)\",\n  \"--muted\": \"color-mix(in srgb, var(--color-black) 4%, transparent)\",\n  \"--muted-foreground\": \"color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-black))\",\n  \"--accent\": \"color-mix(in srgb, var(--color-black) 4%, transparent)\",\n  \"--border\": \"color-mix(in srgb, var(--color-black) 8%, transparent)\",\n  \"--input\": \"color-mix(in srgb, var(--color-black) 10%, transparent)\",\n  \"--primary\": \"var(--color-neutral-800)\",\n  \"--primary-foreground\": \"var(--color-neutral-50)\",\n} as CSSProperties;\n\nconst navGroups: { label: string; items: { id: string; label: string; icon: ComponentType<{ className?: string }> }[] }[] = [\n  {\n    label: \"Account\",\n    items: [\n      { id: \"profile\", label: \"Profile\", icon: UserIcon },\n      { id: \"appearance\", label: \"Appearance\", icon: PaletteIcon },\n      { id: \"notifications\", label: \"Notifications\", icon: BellIcon },\n      { id: \"security\", label: \"Security\", icon: ShieldIcon },\n    ],\n  },\n  {\n    label: \"Workspace\",\n    items: [\n      { id: \"general\", label: \"General\", icon: SettingsIcon },\n      { id: \"members\", label: \"Members & roles\", icon: UsersIcon },\n      { id: \"billing\", label: \"Billing\", icon: CreditCardIcon },\n    ],\n  },\n  {\n    label: \"Developer\",\n    items: [{ id: \"api\", label: \"API keys & webhooks\", icon: KeyRoundIcon }],\n  },\n];\n\nconst defaultTasks: AppearanceTask[] = [\n  { id: \"t1\", title: \"Finalize pricing page copy\", owner: \"Ravi Chen\", due: \"Today\", done: true },\n  { id: \"t2\", title: \"QA the onboarding emails\", owner: \"Mina Kova\", due: \"Tomorrow\" },\n  { id: \"t3\", title: \"Record the walkthrough video\", owner: \"Ada Lindqvist\", due: \"Fri\" },\n  { id: \"t4\", title: \"Sign-off on terms with legal\", owner: \"Theo Banks\", due: \"Nov 3\", done: true },\n  { id: \"t5\", title: \"Prep the launch-day status page\", owner: \"Ines Abara\", due: \"Nov 4\" },\n  { id: \"t6\", title: \"Write the changelog entry\", owner: \"Ada Lindqvist\", due: \"Nov 5\" },\n];\n\nconst ownerHues = [\n  \"bg-teal-700 text-white\",\n  \"bg-amber-500 text-amber-950\",\n  \"bg-fuchsia-600 text-white\",\n  \"bg-sky-700 text-white\",\n  \"bg-lime-500 text-lime-950\",\n];\n\nconst densityRow: Record<Density, string> = {\n  compact: \"py-[0.35em]\",\n  default: \"py-[0.55em]\",\n  comfortable: \"py-[0.8em]\",\n};\n\nconst densityNav: Record<Density, string> = {\n  compact: \"py-[0.25em]\",\n  default: \"py-[0.38em]\",\n  comfortable: \"py-[0.52em]\",\n};\n\nconst themeOptions: { value: ThemeChoice; label: string }[] = [\n  { value: \"system\", label: \"System\" },\n  { value: \"light\", label: \"Light\" },\n  { value: \"dark\", label: \"Dark\" },\n];\n\nfunction useReducedMotionSafe() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nfunction initialsOf(name: string) {\n  return name\n    .split(/\\s+/)\n    .map((p) => p[0])\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nfunction samePrefs(a: AppearancePrefs, b: AppearancePrefs) {\n  return (Object.keys(a) as (keyof AppearancePrefs)[]).every((k) => a[k] === b[k]);\n}\n\nfunction tintStyle(theme: \"light\" | \"dark\", accent: AccentName): CSSProperties {\n  const tint = accents[accent][theme];\n  return {\n    ...(theme === \"light\" ? lightScope : {}),\n    \"--tint\": tint.solid,\n    \"--tint-ink\": tint.ink,\n  } as CSSProperties;\n}\n\nfunction SettingsShell({\n  active,\n  account,\n  onNavigate,\n  children,\n}: {\n  active: string;\n  account: ReactNode;\n  onNavigate?: (section: string) => void;\n  children: ReactNode;\n}) {\n  const items = navGroups.flatMap((g) => g.items);\n  return (\n    <>\n      <aside className=\"hidden w-60 shrink-0 flex-col border-r bg-muted/30 px-3 py-4 md:flex\">\n        <button\n          className=\"flex h-8 items-center gap-2 rounded-md px-2 text-muted-foreground text-sm outline-none ring-ring/24 transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px]\"\n          type=\"button\"\n        >\n          <ArrowLeftIcon className=\"size-4\" />\n          Back to Ridgeline\n        </button>\n        <nav aria-label=\"Settings\">\n          {navGroups.map((group) => (\n            <div key={group.label}>\n              <div className=\"px-2 pt-5 pb-1.5 font-medium text-muted-foreground text-xs\">{group.label}</div>\n              <div className=\"flex flex-col gap-0.5\">\n                {group.items.map((item) => {\n                  const current = item.id === active;\n                  const Icon = item.icon;\n                  return (\n                    <button\n                      aria-current={current ? \"page\" : undefined}\n                      className={cn(\n                        \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm outline-none ring-ring/24 transition-colors focus-visible:ring-[3px]\",\n                        current ? \"bg-accent font-medium text-foreground\" : \"text-foreground/80 hover:bg-accent/60\",\n                      )}\n                      key={item.id}\n                      onClick={() => onNavigate?.(item.id)}\n                      type=\"button\"\n                    >\n                      <Icon className=\"size-4 shrink-0 text-muted-foreground\" />\n                      <span className=\"truncate\">{item.label}</span>\n                    </button>\n                  );\n                })}\n              </div>\n            </div>\n          ))}\n        </nav>\n        <div className=\"mt-auto flex items-center gap-2.5 px-2 pt-4\">{account}</div>\n      </aside>\n      <div className=\"relative flex min-w-0 flex-1 flex-col\">\n        <div className=\"md:hidden\">\n          <div className=\"flex h-12 items-center gap-2 border-b px-4\">\n            <button\n              aria-label=\"Back to Ridgeline\"\n              className=\"-ms-1.5 flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none ring-ring/24 hover:bg-accent/60 hover:text-foreground focus-visible:ring-[3px]\"\n              type=\"button\"\n            >\n              <ArrowLeftIcon className=\"size-4\" />\n            </button>\n            <span className=\"font-medium text-sm\">Settings</span>\n          </div>\n          <nav\n            aria-label=\"Settings\"\n            className=\"flex gap-1.5 overflow-x-auto border-b px-4 py-2.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\"\n          >\n            {items.map((item) => {\n              const current = item.id === active;\n              return (\n                <button\n                  aria-current={current ? \"page\" : undefined}\n                  className={cn(\n                    \"h-7 shrink-0 rounded-full px-3 text-xs outline-none ring-ring/24 transition-colors focus-visible:ring-[3px]\",\n                    current ? \"bg-foreground font-medium text-background\" : \"bg-muted text-muted-foreground hover:text-foreground\",\n                  )}\n                  key={item.id}\n                  onClick={() => onNavigate?.(item.id)}\n                  type=\"button\"\n                >\n                  {item.label}\n                </button>\n              );\n            })}\n          </nav>\n        </div>\n        <div className=\"min-h-0 flex-1 overflow-y-auto\">\n          <div className=\"mx-auto w-full max-w-2xl px-6 py-10 md:px-10\">{children}</div>\n        </div>\n      </div>\n    </>\n  );\n}\n\nfunction MiniApp({\n  theme,\n  prefs,\n  tasks,\n  onToggleTask,\n  workspace,\n}: {\n  theme: \"light\" | \"dark\";\n  prefs: AppearancePrefs;\n  tasks: AppearanceTask[];\n  onToggleTask: (id: string) => void;\n  workspace: string;\n}) {\n  const done = tasks.filter((t) => t.done).length;\n  const owners = [...new Set(tasks.map((t) => t.owner))];\n  return (\n    <div\n      className={cn(\n        \"@container/app flex size-full flex-col overflow-hidden bg-background text-foreground leading-normal\",\n        theme === \"dark\" && \"dark\",\n      )}\n      style={{ ...tintStyle(theme, prefs.accent), fontSize: `${prefs.textSize * 0.86}px` }}\n    >\n      <div className=\"flex h-[2.5em] shrink-0 items-center gap-[0.6em] border-b px-[0.9em]\">\n        <span className=\"flex gap-[0.35em]\">\n          <span className=\"size-[0.55em] rounded-full bg-foreground/16\" />\n          <span className=\"size-[0.55em] rounded-full bg-foreground/16\" />\n          <span className=\"size-[0.55em] rounded-full bg-foreground/16\" />\n        </span>\n        <span className=\"mx-auto flex h-[1.75em] w-full max-w-[18em] items-center gap-[0.4em] rounded-[calc(var(--radius)*0.5)] bg-muted px-[0.6em] text-[0.8em] text-muted-foreground\">\n          <SearchIcon className=\"size-[1.1em]\" />\n          Search {workspace}\n        </span>\n        <span className=\"flex size-[1.6em] items-center justify-center text-muted-foreground\">\n          {theme === \"dark\" ? <MoonIcon className=\"size-[1em]\" /> : <SunIcon className=\"size-[1em]\" />}\n        </span>\n      </div>\n      <div className=\"flex min-h-0 flex-1\">\n        <div className=\"hidden w-[12em] shrink-0 flex-col gap-[0.15em] border-r bg-muted/50 p-[0.6em] @lg/app:flex\">\n          <div className=\"mb-[0.4em] flex items-center gap-[0.5em] px-[0.4em] pt-[0.2em]\">\n            <span\n              className={cn(\n                \"flex size-[1.5em] items-center justify-center rounded-[calc(var(--radius)*0.4)] bg-(--tint) font-semibold text-[0.85em] text-white\",\n                tintTransition,\n              )}\n            >\n              {workspace[0]}\n            </span>\n            <span className=\"truncate font-semibold text-[0.9em]\">{workspace}</span>\n          </div>\n          {[\n            { label: \"Inbox\", icon: <InboxIcon />, count: 4 },\n            { label: \"My tasks\", icon: <ListTodoIcon />, active: true },\n            { label: \"Projects\", icon: <FolderIcon /> },\n            { label: \"Docs\", icon: <FileTextIcon /> },\n          ].map((item) => (\n            <span\n              className={cn(\n                \"flex items-center gap-[0.55em] rounded-[calc(var(--radius)*0.5)] px-[0.5em] text-[0.88em] [&_svg]:size-[1.05em] [&_svg]:shrink-0\",\n                densityNav[prefs.density],\n                item.active\n                  ? \"bg-[color-mix(in_srgb,var(--tint)_14%,transparent)] font-medium text-(--tint-ink)\"\n                  : \"text-muted-foreground\",\n                tintTransition,\n              )}\n              key={item.label}\n            >\n              {prefs.sidebarIcons && item.icon}\n              {item.label}\n              {item.count && (\n                <span\n                  className={cn(\n                    \"ms-auto rounded-full bg-(--tint) px-[0.45em] font-medium text-[0.78em] text-white tabular-nums\",\n                    tintTransition,\n                  )}\n                >\n                  {item.count}\n                </span>\n              )}\n            </span>\n          ))}\n        </div>\n        <div className=\"flex min-w-0 flex-1 flex-col\">\n          <div className=\"flex flex-col gap-[0.6em] border-b px-[1em] pt-[0.9em]\">\n            <div className=\"flex items-center gap-[0.6em]\">\n              <span className=\"truncate font-semibold text-[1.1em] tracking-tight\">Launch plan</span>\n              <span className=\"hidden shrink-0 text-[0.8em] text-muted-foreground tabular-nums @sm/app:inline\">\n                {done} of {tasks.length} done\n              </span>\n              <span\n                className={cn(\n                  \"ms-auto inline-flex shrink-0 items-center gap-[0.3em] rounded-[calc(var(--radius)*0.5)] bg-(--tint) px-[0.7em] py-[0.3em] font-medium text-[0.82em] text-white\",\n                  tintTransition,\n                )}\n              >\n                <PlusIcon className=\"size-[1.05em]\" />\n                New task\n              </span>\n            </div>\n            <div className=\"h-[0.28em] overflow-hidden rounded-full bg-muted\">\n              <motion.div\n                animate={{ scaleX: done / tasks.length }}\n                className={cn(\"h-full origin-left rounded-full bg-(--tint)\", tintTransition)}\n                initial={false}\n                transition={spring}\n              />\n            </div>\n            <div className=\"flex gap-[1.2em] text-[0.85em]\">\n              {[\"List\", \"Board\", \"Timeline\"].map((tab, i) => (\n                <span\n                  className={cn(\"relative pb-[0.55em]\", i === 0 ? \"font-medium text-foreground\" : \"text-muted-foreground\")}\n                  key={tab}\n                >\n                  {tab}\n                  {i === 0 && (\n                    <span className={cn(\"absolute inset-x-0 -bottom-px h-[0.14em] rounded-full bg-(--tint)\", tintTransition)} />\n                  )}\n                </span>\n              ))}\n            </div>\n          </div>\n          <div className=\"min-h-0 flex-1 overflow-hidden px-[0.5em] py-[0.3em]\">\n            {tasks.map((task) => (\n              <motion.div\n                className={cn(\n                  \"flex items-center gap-[0.7em] rounded-[calc(var(--radius)*0.5)] px-[0.6em] transition-[padding] duration-200 ease-out\",\n                  densityRow[prefs.density],\n                )}\n                key={task.id}\n                layout=\"position\"\n                layoutDependency={prefs.density}\n                transition={spring}\n              >\n                <button\n                  aria-label={`${task.done ? \"Reopen\" : \"Complete\"} “${task.title}” in the preview`}\n                  aria-pressed={Boolean(task.done)}\n                  className={cn(\n                    \"relative flex size-[1.15em] shrink-0 items-center justify-center rounded-[calc(var(--radius)*0.4)] border outline-none ring-(--tint)/40 focus-visible:ring-[3px]\",\n                    task.done ? \"border-transparent bg-(--tint) text-white\" : \"border-foreground/24 bg-background\",\n                    tintTransition,\n                  )}\n                  onClick={() => onToggleTask(task.id)}\n                  type=\"button\"\n                >\n                  <AnimatePresence initial={false}>\n                    {task.done && (\n                      <motion.span\n                        animate={{ opacity: 1, scale: 1 }}\n                        className=\"absolute inset-0 flex items-center justify-center\"\n                        exit={{ opacity: 0, scale: 0.6 }}\n                        initial={{ opacity: 0, scale: 0.6 }}\n                        transition={{ type: \"spring\", stiffness: 600, damping: 30 }}\n                      >\n                        <CheckIcon className=\"size-[0.8em]\" strokeWidth={3.2} />\n                      </motion.span>\n                    )}\n                  </AnimatePresence>\n                </button>\n                <span\n                  className={cn(\n                    \"min-w-0 flex-1 truncate text-[0.92em] transition-colors duration-200\",\n                    task.done && \"text-muted-foreground line-through decoration-foreground/24\",\n                  )}\n                >\n                  {task.title}\n                </span>\n                <span\n                  className={cn(\n                    \"hidden shrink-0 rounded-[calc(var(--radius)*0.4)] px-[0.45em] py-[0.1em] text-[0.75em] @md/app:inline\",\n                    task.due === \"Today\"\n                      ? cn(\"bg-[color-mix(in_srgb,var(--tint)_14%,transparent)] font-medium text-(--tint-ink)\", tintTransition)\n                      : \"bg-muted text-muted-foreground\",\n                  )}\n                >\n                  {task.due}\n                </span>\n                <span\n                  aria-hidden\n                  className={cn(\n                    \"flex size-[1.55em] shrink-0 items-center justify-center rounded-full\",\n                    ownerHues[owners.indexOf(task.owner) % ownerHues.length],\n                  )}\n                >\n                  <span className=\"font-semibold text-[0.6em] leading-none\">{initialsOf(task.owner)}</span>\n                </span>\n              </motion.div>\n            ))}\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction ThemePreview({\n  resolved,\n  prefs,\n  tasks,\n  onToggleTask,\n  workspace,\n  calm,\n}: {\n  resolved: \"light\" | \"dark\";\n  prefs: AppearancePrefs;\n  tasks: AppearanceTask[];\n  onToggleTask: (id: string) => void;\n  workspace: string;\n  calm: boolean;\n}) {\n  const [layers, setLayers] = useState<{ key: number; theme: \"light\" | \"dark\"; animate: boolean }[]>([\n    { key: 0, theme: resolved, animate: false },\n  ]);\n  const settled = useRef(false);\n\n  useEffect(() => {\n    const id = requestAnimationFrame(() => {\n      settled.current = true;\n    });\n    return () => cancelAnimationFrame(id);\n  }, []);\n\n  useEffect(() => {\n    setLayers((current) => {\n      const top = current[current.length - 1];\n      if (top.theme === resolved) return current;\n      if (!settled.current) return [{ key: top.key + 1, theme: resolved, animate: false }];\n      return [...current.slice(-1), { key: top.key + 1, theme: resolved, animate: true }];\n    });\n  }, [resolved]);\n\n  const origin = \"calc(100% - 1.4em) 1.25em\";\n\n  return (\n    <div\n      className=\"relative size-full overflow-hidden rounded-lg border shadow-xs/5\"\n      style={{ fontSize: `${prefs.textSize * 0.86}px` }}\n    >\n      {layers.map((layer, i) => {\n        const top = i === layers.length - 1;\n        return (\n          <motion.div\n            animate={calm ? { opacity: 1 } : { clipPath: `circle(150% at ${origin})` }}\n            className=\"absolute inset-0\"\n            initial={layer.animate ? (calm ? { opacity: 0 } : { clipPath: `circle(0% at ${origin})` }) : false}\n            key={layer.key}\n            onAnimationComplete={() => {\n              if (top) setLayers((current) => (current.length > 1 ? current.slice(-1) : current));\n            }}\n            transition={calm ? { duration: 0.2, ease: \"linear\" } : { duration: 0.55, ease: easeOut }}\n          >\n            <MiniApp onToggleTask={onToggleTask} prefs={prefs} tasks={tasks} theme={layer.theme} workspace={workspace} />\n          </motion.div>\n        );\n      })}\n    </div>\n  );\n}\n\nfunction ThemeThumb({ variant, accent }: { variant: \"light\" | \"dark\"; accent: AccentName }) {\n  return (\n    <span\n      className={cn(\"flex size-full bg-background\", variant === \"dark\" && \"dark\")}\n      style={tintStyle(variant, accent)}\n    >\n      <span className=\"flex w-[26%] flex-col gap-[6%] border-r bg-muted px-[5%] pt-[9%]\">\n        <span className={cn(\"size-2.5 rounded-[calc(var(--radius)*0.3)] bg-(--tint)\", tintTransition)} />\n        <span className=\"h-1 w-4/5 rounded-full bg-foreground/20\" />\n        <span className=\"h-1 w-3/5 rounded-full bg-foreground/12\" />\n        <span className=\"h-1 w-4/5 rounded-full bg-foreground/12\" />\n      </span>\n      <span className=\"flex flex-1 flex-col gap-[7%] px-[8%] pt-[9%]\">\n        <span className=\"flex items-center justify-between\">\n          <span className=\"h-1.5 w-2/5 rounded-full bg-foreground/56\" />\n          <span className={cn(\"h-2.5 w-1/4 rounded-[calc(var(--radius)*0.3)] bg-(--tint)\", tintTransition)} />\n        </span>\n        {[0, 1, 2, 3].map((row) => (\n          <span className=\"flex items-center gap-[6%] border-b pb-[5%] last:border-b-0\" key={row}>\n            <span className=\"size-1.5 shrink-0 rounded-[calc(var(--radius)*0.2)] border border-foreground/24\" />\n            <span className={cn(\"h-1 rounded-full bg-foreground/16\", row % 2 ? \"w-1/2\" : \"w-3/4\")} />\n          </span>\n        ))}\n      </span>\n    </span>\n  );\n}\n\nfunction ThemeCard({ value, label, accent }: { value: ThemeChoice; label: string; accent: AccentName }) {\n  return (\n    <RadioPrimitive.Root\n      className=\"group flex min-w-0 cursor-pointer flex-col items-center gap-2 outline-none\"\n      value={value}\n    >\n      <span\n        className={cn(\n          \"relative block aspect-[16/11] w-full overflow-hidden rounded-lg border ring-offset-2 ring-offset-background transition-[box-shadow,scale] duration-150 ease-out group-active:scale-[0.98] group-focus-visible:ring-2 group-focus-visible:ring-ring\",\n          \"group-data-checked:ring-2 group-data-checked:ring-foreground [@media(hover:hover)]:group-hover:not-group-data-checked:border-foreground/24\",\n        )}\n      >\n        {value === \"system\" ? (\n          <>\n            <span className=\"absolute inset-0\">\n              <ThemeThumb accent={accent} variant=\"light\" />\n            </span>\n            <span className=\"absolute inset-0 [clip-path:inset(0_0_0_50%)]\">\n              <ThemeThumb accent={accent} variant=\"dark\" />\n            </span>\n          </>\n        ) : (\n          <ThemeThumb accent={accent} variant={value} />\n        )}\n        <RadioPrimitive.Indicator\n          className=\"absolute top-1.5 right-1.5 flex size-4.5 items-center justify-center rounded-full bg-foreground text-background shadow-xs/5 transition-[opacity,scale] duration-150 ease-out data-starting-style:scale-75 data-starting-style:opacity-0\"\n          keepMounted={false}\n        >\n          <CheckIcon className=\"size-3\" strokeWidth={3} />\n        </RadioPrimitive.Indicator>\n      </span>\n      <span className=\"text-muted-foreground text-sm transition-colors group-data-checked:font-medium group-data-checked:text-foreground\">\n        {label}\n      </span>\n    </RadioPrimitive.Root>\n  );\n}\n\nfunction Section({\n  title,\n  description,\n  aside,\n  children,\n}: {\n  title: string;\n  description?: string;\n  aside?: ReactNode;\n  children: ReactNode;\n}) {\n  return (\n    <section className=\"mt-10\">\n      <div className=\"flex items-end justify-between gap-4\">\n        <div className=\"min-w-0\">\n          <h2 className=\"font-medium text-sm\">{title}</h2>\n          {description && <p className=\"text-pretty text-muted-foreground text-sm\">{description}</p>}\n        </div>\n        {aside}\n      </div>\n      {children}\n    </section>\n  );\n}\n\nfunction RowText({ label, help }: { label: string; help: string }) {\n  return (\n    <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n      <span className=\"font-medium text-sm\">{label}</span>\n      <span className=\"text-pretty text-muted-foreground text-xs\">{help}</span>\n    </span>\n  );\n}\n\nexport function AppearanceSettings({\n  className,\n  defaultPrefs = factoryPrefs,\n  workspace = \"Ridgeline\",\n  tasks: initialTasks = defaultTasks,\n  onChange,\n  onNavigate,\n}: AppearanceSettingsProps) {\n  const osReduce = useReducedMotionSafe();\n  const [prefs, setPrefs] = useState(defaultPrefs);\n  const [system, setSystem] = useState<\"light\" | \"dark\">(\"light\");\n  const [tasks, setTasks] = useState(initialTasks);\n  const [saveState, setSaveState] = useState<\"idle\" | \"saving\" | \"saved\">(\"idle\");\n  const saveTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const resolved = prefs.theme === \"system\" ? system : prefs.theme;\n  const calm = osReduce || prefs.reduceMotion;\n\n  useEffect(() => {\n    const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n    const sync = () => setSystem(query.matches ? \"dark\" : \"light\");\n    sync();\n    query.addEventListener(\"change\", sync);\n    return () => query.removeEventListener(\"change\", sync);\n  }, []);\n\n  useEffect(\n    () => () => {\n      if (saveTimer.current) clearTimeout(saveTimer.current);\n    },\n    [],\n  );\n\n  const update = (patch: Partial<AppearancePrefs>) => {\n    const next = { ...prefs, ...patch };\n    if (samePrefs(next, prefs)) return;\n    setPrefs(next);\n    onChange?.(next);\n    setSaveState(\"saving\");\n    if (saveTimer.current) clearTimeout(saveTimer.current);\n    saveTimer.current = setTimeout(() => setSaveState(\"saved\"), 450);\n  };\n\n  const toggleTask = (id: string) => setTasks((all) => all.map((t) => (t.id === id ? { ...t, done: !t.done } : t)));\n  const sizeIndex = Math.max(0, textSizes.indexOf(prefs.textSize));\n\n  return (\n    <MotionConfig reducedMotion={prefs.reduceMotion ? \"always\" : \"user\"}>\n      <div className={cn(\"flex h-[760px] w-full bg-background text-foreground\", className)}>\n        <SettingsShell\n          account={\n            <>\n              <span className=\"flex size-7 shrink-0 items-center justify-center rounded-full bg-foreground font-medium text-[11px] text-background\">\n                AL\n              </span>\n              <div className=\"flex min-w-0 flex-col\">\n                <span className=\"truncate font-medium text-sm\">Ada Lindqvist</span>\n                <span className=\"truncate text-muted-foreground text-xs\">ada@ridgeline.app</span>\n              </div>\n            </>\n          }\n          active=\"appearance\"\n          onNavigate={onNavigate}\n        >\n          <div className=\"flex items-start justify-between gap-4\">\n            <div className=\"min-w-0\">\n              <h1 className=\"font-semibold text-2xl tracking-tight\">Appearance</h1>\n              <p className=\"mt-1 text-pretty text-muted-foreground text-sm\">\n                Customise how {workspace} looks on this device.\n              </p>\n            </div>\n            <div className=\"flex shrink-0 items-center gap-1 pt-1\">\n              <span aria-live=\"polite\" className=\"hidden h-7 items-center px-1 text-muted-foreground text-xs sm:flex\">\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  {saveState !== \"idle\" && (\n                    <motion.span\n                      animate={{ opacity: 1, y: 0 }}\n                      className=\"flex items-center gap-1.5\"\n                      exit={{ opacity: 0, y: -4 }}\n                      initial={{ opacity: 0, y: 4 }}\n                      key={saveState}\n                      transition={{ duration: 0.16, ease: easeOut }}\n                    >\n                      {saveState === \"saving\" ? (\n                        <span className=\"size-1.5 animate-pulse rounded-full bg-muted-foreground\" />\n                      ) : (\n                        <CheckIcon className=\"size-3.5 text-success-foreground\" />\n                      )}\n                      {saveState === \"saving\" ? \"Saving…\" : \"Saved\"}\n                    </motion.span>\n                  )}\n                </AnimatePresence>\n              </span>\n              <Button\n                className={press}\n                disabled={samePrefs(prefs, factoryPrefs)}\n                onClick={() => update(factoryPrefs)}\n                size=\"sm\"\n                variant=\"ghost\"\n              >\n                Reset\n              </Button>\n            </div>\n          </div>\n\n          <Section\n            description={\n              prefs.theme === \"system\"\n                ? `Follows your device setting, currently ${system}.`\n                : \"Pick a theme, or follow your device setting.\"\n            }\n            title=\"Theme\"\n          >\n            <RadioGroupPrimitive\n              aria-label=\"Theme\"\n              className=\"mt-4 grid grid-cols-3 gap-3 sm:gap-4\"\n              onValueChange={(value) => update({ theme: value as ThemeChoice })}\n              value={prefs.theme}\n            >\n              {themeOptions.map((option) => (\n                <ThemeCard accent={prefs.accent} key={option.value} label={option.label} value={option.value} />\n              ))}\n            </RadioGroupPrimitive>\n\n            <div className=\"mt-6 rounded-xl border bg-muted/40 p-2\">\n              <div className=\"h-56 sm:h-64\">\n                <ThemePreview\n                  calm={calm}\n                  onToggleTask={toggleTask}\n                  prefs={prefs}\n                  resolved={resolved}\n                  tasks={tasks}\n                  workspace={workspace}\n                />\n              </div>\n              <div className=\"flex items-center justify-between gap-3 px-1.5 pt-2 pb-0.5 text-muted-foreground text-xs\">\n                <span className=\"truncate\">Preview. Tick a task to try it.</span>\n                <span className=\"flex shrink-0 items-center gap-1.5 capitalize tabular-nums\">\n                  {resolved === \"dark\" ? <MoonIcon className=\"size-3.5\" /> : <SunIcon className=\"size-3.5\" />}\n                  {resolved} · {prefs.textSize}px\n                </span>\n              </div>\n            </div>\n          </Section>\n\n          <Section\n            aside={<span className=\"text-muted-foreground text-sm\">{accents[prefs.accent].label}</span>}\n            description=\"Used for buttons, links and highlights.\"\n            title=\"Accent colour\"\n          >\n            <RadioGroupPrimitive\n              aria-label=\"Accent colour\"\n              className=\"mt-3 flex flex-wrap gap-1.5\"\n              onValueChange={(value) => update({ accent: value as AccentName })}\n              value={prefs.accent}\n            >\n              {(Object.keys(accents) as AccentName[]).map((name) => (\n                <RadioPrimitive.Root\n                  aria-label={accents[name].label}\n                  className=\"group relative flex size-9 cursor-pointer items-center justify-center rounded-full outline-none\"\n                  key={name}\n                  value={name}\n                >\n                  <span className=\"absolute inset-0 rounded-full border-2 border-transparent transition-[border-color,scale] duration-200 ease-out group-focus-visible:border-ring group-data-checked:border-foreground/80\" />\n                  <span\n                    className={cn(\n                      \"flex size-6.5 items-center justify-center rounded-full text-white shadow-xs/5 transition-transform duration-150 ease-out group-active:scale-90\",\n                      accents[name].swatch,\n                    )}\n                  >\n                    <RadioPrimitive.Indicator\n                      className=\"transition-[opacity,scale] duration-150 ease-out data-starting-style:scale-50 data-starting-style:opacity-0\"\n                      keepMounted={false}\n                    >\n                      <CheckIcon className=\"size-3.5\" strokeWidth={3} />\n                    </RadioPrimitive.Indicator>\n                  </span>\n                </RadioPrimitive.Root>\n              ))}\n            </RadioGroupPrimitive>\n          </Section>\n\n          <Section description=\"Spacing and type across lists, tables and the sidebar.\" title=\"Layout\">\n            <div className=\"mt-3 divide-y rounded-xl border bg-card\">\n              <div className=\"flex flex-col gap-3 px-4 py-3.5 sm:flex-row sm:items-center sm:gap-4\">\n                <RowText help=\"How much room rows and lists get.\" label=\"Density\" />\n                <SegmentedControl aria-label=\"Density\" className=\"w-full sm:w-auto\" role=\"radiogroup\" size=\"sm\">\n                  {([\"compact\", \"default\", \"comfortable\"] as Density[]).map((d) => (\n                    <SegmentedControlItem\n                      aria-checked={prefs.density === d}\n                      className=\"flex-1 capitalize sm:flex-none text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                      data-checked={prefs.density === d ? \"\" : undefined}\n                      key={d}\n                      onClick={() => update({ density: d })}\n                      role=\"radio\"\n                    >\n                      {d}\n                    </SegmentedControlItem>\n                  ))}\n                </SegmentedControl>\n              </div>\n              <div className=\"flex flex-col gap-3 px-4 py-3.5\">\n                <div className=\"flex items-center gap-4\">\n                  <RowText help=\"Scales text everywhere in the app.\" label=\"Font size\" />\n                  <span className=\"font-mono text-muted-foreground text-xs tabular-nums\">{prefs.textSize}px</span>\n                </div>\n                <div className=\"flex items-center gap-3\">\n                  <span aria-hidden className=\"w-3 text-center text-muted-foreground text-xs\">\n                    A\n                  </span>\n                  <Slider\n                    getAriaLabel={() => \"Font size\"}\n                    max={textSizes.length - 1}\n                    min={0}\n                    onValueChange={(v) => {\n                      const i = Array.isArray(v) ? v[0] : v;\n                      update({ textSize: textSizes[i] ?? 14 });\n                    }}\n                    step={1}\n                    value={sizeIndex}\n                  />\n                  <span aria-hidden className=\"w-3 text-center text-base text-muted-foreground\">\n                    A\n                  </span>\n                </div>\n                <p\n                  className=\"truncate rounded-lg bg-muted/60 px-3 py-2 text-foreground/90\"\n                  style={{ fontSize: `${prefs.textSize}px` }}\n                >\n                  Release notes are ready for review.\n                </p>\n              </div>\n            </div>\n          </Section>\n\n          <Section description=\"Fine-tune motion and navigation.\" title=\"Accessibility\">\n            <div className=\"mt-3 divide-y rounded-xl border bg-card\">\n              <label className=\"flex cursor-pointer items-center gap-4 px-4 py-3.5\">\n                <RowText\n                  help={\n                    osReduce\n                      ? \"Your device already asks for less motion, so this is on.\"\n                      : \"Replace slides and springs with simple fades.\"\n                  }\n                  label=\"Reduce motion\"\n                />\n                <Switch\n                  checked={prefs.reduceMotion || osReduce}\n                  disabled={osReduce}\n                  onCheckedChange={(checked) => update({ reduceMotion: checked })}\n                />\n              </label>\n              <label className=\"flex cursor-pointer items-center gap-4 px-4 py-3.5\">\n                <RowText help=\"Show icons next to items in the sidebar.\" label=\"Show sidebar icons\" />\n                <Switch checked={prefs.sidebarIcons} onCheckedChange={(checked) => update({ sidebarIcons: checked })} />\n              </label>\n            </div>\n          </Section>\n        </SettingsShell>\n      </div>\n    </MotionConfig>\n  );\n}\n"
    }
  ]
}