---
title: "File Explorer · UI SDK — StyleX Blocks"
description: "Cloud workspace file manager with a collapsible folder tree, breadcrumb trail, live search, list / grid / Miller-column view switcher, row actions menu, and a synchronized metadata inspector."
url: "https://stylexblocks.com/block/ui-sdk/file-explorer/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# File Explorer block

Cloud workspace file manager with a collapsible folder tree, breadcrumb trail, live search, list / grid / Miller-column view switcher, row actions menu, and a synchronized metadata inspector.

- Behavior engine: UI SDK
- Category: [App shells](https://stylexblocks.com/blocks/app-shells.md)
- Built with: [Avatar](https://stylexblocks.com/components/ui-sdk/avatar.md), [Badge](https://stylexblocks.com/components/ui-sdk/badge.md), [Breadcrumb](https://stylexblocks.com/components/ui-sdk/breadcrumb.md), [Button](https://stylexblocks.com/components/ui-sdk/button.md), [Center](https://stylexblocks.com/components/ui-sdk/center.md), [Data List](https://stylexblocks.com/components/ui-sdk/data-list.md), [Empty State](https://stylexblocks.com/components/ui-sdk/empty-state.md), [Grid](https://stylexblocks.com/components/ui-sdk/grid.md), [Icon Button](https://stylexblocks.com/components/ui-sdk/icon-button.md), [Input](https://stylexblocks.com/components/ui-sdk/input.md), [Menu](https://stylexblocks.com/components/ui-sdk/menu.md), [Progress](https://stylexblocks.com/components/ui-sdk/progress.md), [Segment Group](https://stylexblocks.com/components/ui-sdk/segment-group.md), [Separator](https://stylexblocks.com/components/ui-sdk/separator.md), [Splitter](https://stylexblocks.com/components/ui-sdk/splitter.md), [Stack](https://stylexblocks.com/components/ui-sdk/stack.md), [Table](https://stylexblocks.com/components/ui-sdk/table.md), [Text](https://stylexblocks.com/components/ui-sdk/text.md), [Toast](https://stylexblocks.com/components/ui-sdk/toast.md), [Toolbar](https://stylexblocks.com/components/ui-sdk/toolbar.md), [Tree View](https://stylexblocks.com/components/ui-sdk/tree-view.md)
- HTML page: https://stylexblocks.com/block/ui-sdk/file-explorer/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add file-explorer
```

Equivalent: `npx shadcn add @stylexblocks/file-explorer`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/file-explorer.json

## Usage

```tsx
import { FileExplorer } from "#components/blocks/ui-sdk/file-explorer.tsx";

export function Example() {
  return (
    <div style={{ height: "100dvh" }}>
      <FileExplorer />
    </div>
  );
}
```

## Source

`components/blocks/ui-sdk/file-explorer.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { Fragment, useCallback, useMemo, useState } from "react";
import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";
import { Badge } from "#components/ui/ui-sdk/badge.tsx";
import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";
import { Center, Square } from "#components/ui/ui-sdk/center.tsx";
import { DataList } from "#components/ui/ui-sdk/data-list.tsx";
import { EmptyState } from "#components/ui/ui-sdk/empty-state.tsx";
import { Grid } from "#components/ui/ui-sdk/grid.tsx";
import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";
import { Input } from "#components/ui/ui-sdk/input.tsx";
import { Menu } from "#components/ui/ui-sdk/menu.tsx";
import { Progress } from "#components/ui/ui-sdk/progress.tsx";
import { SegmentGroup } from "#components/ui/ui-sdk/segment-group.tsx";
import { Separator } from "#components/ui/ui-sdk/separator.tsx";
import { Splitter } from "#components/ui/ui-sdk/splitter.tsx";
import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";
import { Table } from "#components/ui/ui-sdk/table.tsx";
import { Text } from "#components/ui/ui-sdk/text.tsx";
import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";
import { Toolbar } from "#components/ui/ui-sdk/toolbar.tsx";
import { TreeView } from "#components/ui/ui-sdk/tree-view.tsx";
import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";
import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";
import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";
import {
  accentPalette,
  amberPalette,
  bluePalette,
  emeraldPalette,
  purplePalette,
  redPalette,
  tealPalette,
} from "@stylexblocks/ui/themes/palettes.ts";
import { durations } from "@stylexblocks/ui/tokens/durations.stylex.ts";
import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";
import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";
import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";
import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";
import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";
import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";

const NARROW_INSPECTOR = "@container file-explorer (max-width: 900px)";
const NARROW_RAIL = "@container file-explorer (max-width: 640px)";
const COMPACT_HEADER = "@container file-explorer (max-width: 720px)";
const HIDE_TABLE_META = "@container file-explorer-main (max-width: 520px)";

type ViewMode = "list" | "grid" | "columns";
type SmartFilter = "all" | "starred" | "shared" | "recent";
type SortField = "name" | "modified" | "size" | "kind";
type SortDir = "asc" | "desc";
type FileCategory = "folder" | "design" | "code" | "doc" | "sheet" | "media" | "deck";

interface OwnerInfo {
  name: string;
  initials: string;
  role: string;
  paletteKey: "accent" | "blue" | "emerald" | "purple" | "amber" | "teal";
}

interface DriveNode {
  id: string;
  parentId: string | null;
  name: string;
  type: "folder" | "file";
  category: FileCategory;
  kindLabel: string;
  extension?: string;
  sizeBytes: number;
  sizeLabel: string;
  owner: OwnerInfo;
  createdAt: string;
  modifiedAt: string;
  modifiedOrder: number;
  starred: boolean;
  shared: boolean;
  recent: boolean;
  access: string;
  tags: string[];
  summary: string;
  versionNote: string;
  collaborators: OwnerInfo[];
}

const OWNERS = {
  elena: { name: "Elena Vance", initials: "EV", role: "Staff Designer", paletteKey: "purple" },
  marcus: { name: "Marcus Chen", initials: "MC", role: "Principal Engineer", paletteKey: "blue" },
  priya: { name: "Priya Nair", initials: "PN", role: "Product Lead", paletteKey: "emerald" },
  soren: { name: "Soren Lindqvist", initials: "SL", role: "Brand Director", paletteKey: "amber" },
  nadia: { name: "Nadia Okafor", initials: "NO", role: "Systems Architect", paletteKey: "teal" },
  devon: { name: "Devon Park", initials: "DP", role: "Design Technologist", paletteKey: "accent" },
} as const satisfies Record<string, OwnerInfo>;

const OWNER_PALETTES = {
  accent: accentPalette,
  blue: bluePalette,
  emerald: emeraldPalette,
  purple: purplePalette,
  amber: amberPalette,
  teal: tealPalette,
} as const;

const CATEGORY_PALETTES = {
  folder: accentPalette,
  design: purplePalette,
  code: bluePalette,
  doc: tealPalette,
  sheet: emeraldPalette,
  media: amberPalette,
  deck: redPalette,
} as const;

const INITIAL_NODES: DriveNode[] = [
  // Top-level folders
  {
    id: "design-systems",
    parentId: null,
    name: "Design Systems",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 42_600_000,
    sizeLabel: "42.6 MB",
    owner: OWNERS.elena,
    createdAt: "Sep 14, 2026",
    modifiedAt: "Today, 10:42 AM",
    modifiedOrder: 100,
    starred: true,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Design", "v4"],
    summary: "Core foundations, semantic tokens, and component libraries for Kestrel Cloud.",
    versionNote: "Updated elevation scale and token exports for v4.2",
    collaborators: [OWNERS.elena, OWNERS.devon, OWNERS.marcus],
  },
  {
    id: "engineering",
    parentId: null,
    name: "Engineering",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 18_400_000,
    sizeLabel: "18.4 MB",
    owner: OWNERS.marcus,
    createdAt: "Aug 03, 2026",
    modifiedAt: "Today, 9:18 AM",
    modifiedOrder: 98,
    starred: false,
    shared: true,
    recent: true,
    access: "Engineering & Platform",
    tags: ["Platform", "RFC"],
    summary: "Architecture proposals, schema specs, deployment runbooks, and release telemetry.",
    versionNote: "Added RFC-045 realtime sync draft",
    collaborators: [OWNERS.marcus, OWNERS.nadia, OWNERS.devon],
  },
  {
    id: "launch-q4",
    parentId: null,
    name: "Launch Q4",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 164_200_000,
    sizeLabel: "164.2 MB",
    owner: OWNERS.priya,
    createdAt: "Oct 02, 2026",
    modifiedAt: "Yesterday, 6:15 PM",
    modifiedOrder: 93,
    starred: true,
    shared: true,
    recent: true,
    access: "Launch Core Team",
    tags: ["Q4", "Launch"],
    summary: "Keynote decks, press kit imagery, release timeline, and pricing models.",
    versionNote: "Finalized demo walkthrough cut 3",
    collaborators: [OWNERS.priya, OWNERS.soren, OWNERS.elena],
  },
  {
    id: "brand-assets",
    parentId: null,
    name: "Brand Assets",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 91_800_000,
    sizeLabel: "91.8 MB",
    owner: OWNERS.soren,
    createdAt: "Jul 19, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 76,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand", "Approved"],
    summary: "Official logomarks, typography licenses, print collateral, and color swatches.",
    versionNote: "Refreshed monochrome SVG wordmarks",
    collaborators: [OWNERS.soren, OWNERS.elena],
  },
  {
    id: "shared",
    parentId: null,
    name: "Shared",
    type: "folder",
    category: "folder",
    kindLabel: "Shared Folder",
    sizeBytes: 24_900_000,
    sizeLabel: "24.9 MB",
    owner: OWNERS.priya,
    createdAt: "Oct 12, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 84,
    starred: false,
    shared: true,
    recent: false,
    access: "External partners + Editors",
    tags: ["External", "Partner"],
    summary: "Cross-org memos, partner pilot documents, and customer advisory notes.",
    versionNote: "Shared Northstar Pilot SOW for signature",
    collaborators: [OWNERS.priya, OWNERS.nadia, OWNERS.marcus],
  },
  // Top-level files
  {
    id: "workspace-welcome",
    parentId: null,
    name: "Workspace-Welcome-Guide.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 2_480_000,
    sizeLabel: "2.4 MB",
    owner: OWNERS.priya,
    createdAt: "Aug 01, 2026",
    modifiedAt: "Nov 18, 2026",
    modifiedOrder: 62,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Handbook"],
    summary: "Onboarding guide for Kestrel Cloud workspace permissions, folder naming, and retention.",
    versionNote: "v2.1 · Added archive policy section",
    collaborators: [OWNERS.priya, OWNERS.elena],
  },
  {
    id: "q4-okr-tracker",
    parentId: null,
    name: "Q4-OKR-Tracker.xlsx",
    type: "file",
    category: "sheet",
    kindLabel: "Spreadsheet",
    extension: "XLSX",
    sizeBytes: 840_000,
    sizeLabel: "840 KB",
    owner: OWNERS.priya,
    createdAt: "Oct 01, 2026",
    modifiedAt: "Today, 8:50 AM",
    modifiedOrder: 96,
    starred: true,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Q4", "Metrics"],
    summary: "Weekly checkpoint scores across design, platform reliability, and enterprise adoption.",
    versionNote: "v14 · Updated week 9 velocity metrics",
    collaborators: [OWNERS.priya, OWNERS.marcus, OWNERS.elena],
  },
  {
    id: "readme-policy",
    parentId: null,
    name: "README-Drive-Policy.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 18_400,
    sizeLabel: "18 KB",
    owner: OWNERS.nadia,
    createdAt: "Jul 22, 2026",
    modifiedAt: "Nov 11, 2026",
    modifiedOrder: 54,
    starred: false,
    shared: false,
    recent: false,
    access: "Workspace editors",
    tags: ["Governance"],
    summary: "Security classification rules and external sharing expiry defaults for workspace folders.",
    versionNote: "v1.3 · Clarified 30-day link expiration",
    collaborators: [OWNERS.nadia],
  },

  // Design Systems children
  {
    id: "ds-tokens",
    parentId: "design-systems",
    name: "Tokens",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 4_850_000,
    sizeLabel: "4.8 MB",
    owner: OWNERS.devon,
    createdAt: "Sep 14, 2026",
    modifiedAt: "Today, 10:42 AM",
    modifiedOrder: 99,
    starred: true,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Tokens", "Production"],
    summary: "OKLCH color ramps, spacing scale definitions, and elevation geometry specs.",
    versionNote: "Synced semantic surface tokens with Figma",
    collaborators: [OWNERS.devon, OWNERS.elena],
  },
  {
    id: "ds-components",
    parentId: "design-systems",
    name: "Components",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 16_200_000,
    sizeLabel: "16.2 MB",
    owner: OWNERS.elena,
    createdAt: "Sep 15, 2026",
    modifiedAt: "Yesterday, 4:08 PM",
    modifiedOrder: 91,
    starred: false,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Components"],
    summary: "Interactive component specifications, motion curves, and accessibility reviews.",
    versionNote: "Added resizable split-pane keyboard spec",
    collaborators: [OWNERS.elena, OWNERS.devon, OWNERS.marcus],
  },
  {
    id: "kestrel-ui-v4",
    parentId: "design-systems",
    name: "kestrel-ui-v4.fig",
    type: "file",
    category: "design",
    kindLabel: "Figma Library",
    extension: "FIG",
    sizeBytes: 18_420_000,
    sizeLabel: "18.4 MB",
    owner: OWNERS.elena,
    createdAt: "Sep 18, 2026",
    modifiedAt: "Today, 10:15 AM",
    modifiedOrder: 97,
    starred: true,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Design", "Approved", "v4"],
    summary: "Master Figma component kit with dark/light variable modes, icon library, and app shells.",
    versionNote: "v4.2 · Published table density and inspector layouts",
    collaborators: [OWNERS.elena, OWNERS.devon, OWNERS.soren],
  },
  {
    id: "a11y-checklist",
    parentId: "design-systems",
    name: "accessibility-checklist.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 1_920_000,
    sizeLabel: "1.9 MB",
    owner: OWNERS.devon,
    createdAt: "Oct 05, 2026",
    modifiedAt: "Nov 27, 2026",
    modifiedOrder: 80,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["WCAG", "Approved"],
    summary: "WCAG 2.2 AA contrast, focus ring, and screen-reader sign-off checklist for all blocks.",
    versionNote: "v2.0 · Added roving tabindex audit notes",
    collaborators: [OWNERS.devon, OWNERS.elena],
  },
  {
    id: "icon-grid-template",
    parentId: "design-systems",
    name: "icon-grid-template.svg",
    type: "file",
    category: "design",
    kindLabel: "SVG Vector",
    extension: "SVG",
    sizeBytes: 312_000,
    sizeLabel: "312 KB",
    owner: OWNERS.soren,
    createdAt: "Sep 29, 2026",
    modifiedAt: "Nov 22, 2026",
    modifiedOrder: 70,
    starred: false,
    shared: true,
    recent: false,
    access: "Workspace editors",
    tags: ["Icons"],
    summary: "16px and 20px optical keyline templates with 1.5px stroke alignment guides.",
    versionNote: "v1.4 · Refined diagonal optical margin",
    collaborators: [OWNERS.soren, OWNERS.elena],
  },

  // Design Systems -> Tokens children
  {
    id: "color-primitives",
    parentId: "ds-tokens",
    name: "color-primitives.json",
    type: "file",
    category: "code",
    kindLabel: "JSON Token Set",
    extension: "JSON",
    sizeBytes: 94_000,
    sizeLabel: "94 KB",
    owner: OWNERS.devon,
    createdAt: "Sep 20, 2026",
    modifiedAt: "Today, 10:42 AM",
    modifiedOrder: 99,
    starred: true,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Tokens", "Production"],
    summary: "W3C Design Tokens format source for OKLCH neutral, accent, and status color ramps.",
    versionNote: "v3.4 · Adjusted dark mode muted border luminance",
    collaborators: [OWNERS.devon, OWNERS.elena, OWNERS.marcus],
  },
  {
    id: "spacing-scale",
    parentId: "ds-tokens",
    name: "spacing-scale.stylex.ts",
    type: "file",
    category: "code",
    kindLabel: "TypeScript Module",
    extension: "TS",
    sizeBytes: 14_200,
    sizeLabel: "14 KB",
    owner: OWNERS.devon,
    createdAt: "Sep 21, 2026",
    modifiedAt: "Nov 28, 2026",
    modifiedOrder: 82,
    starred: false,
    shared: true,
    recent: false,
    access: "Workspace editors",
    tags: ["StyleX", "Tokens"],
    summary: "Compiled StyleX variable sheet scaling rem increments with dynamic density factor.",
    versionNote: "v1.8 · Added 0.5 and 1.5 sub-grid steps",
    collaborators: [OWNERS.devon, OWNERS.marcus],
  },
  {
    id: "elevation-spec",
    parentId: "ds-tokens",
    name: "elevation-spec.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 3_150_000,
    sizeLabel: "3.1 MB",
    owner: OWNERS.elena,
    createdAt: "Oct 08, 2026",
    modifiedAt: "Nov 25, 2026",
    modifiedOrder: 74,
    starred: false,
    shared: true,
    recent: false,
    access: "Workspace editors",
    tags: ["Design"],
    summary: "Layered shadow and surface hierarchy guidelines across modals, popovers, and panels.",
    versionNote: "v2.0 · Updated dark mode rim highlight spec",
    collaborators: [OWNERS.elena],
  },
  {
    id: "typography-audit",
    parentId: "ds-tokens",
    name: "typography-audit.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 28_600,
    sizeLabel: "29 KB",
    owner: OWNERS.elena,
    createdAt: "Oct 16, 2026",
    modifiedAt: "Nov 20, 2026",
    modifiedOrder: 66,
    starred: false,
    shared: false,
    recent: false,
    access: "Workspace editors",
    tags: ["Audit"],
    summary: "Line-height, tabular numeral alignment, and tracking benchmarks across all UI surfaces.",
    versionNote: "v1.2 · Verified CJK fallback line metrics",
    collaborators: [OWNERS.elena, OWNERS.devon],
  },

  // Design Systems -> Components children
  {
    id: "nav-shell-fig",
    parentId: "ds-components",
    name: "navigation-shell.fig",
    type: "file",
    category: "design",
    kindLabel: "Figma File",
    extension: "FIG",
    sizeBytes: 11_400_000,
    sizeLabel: "11.4 MB",
    owner: OWNERS.elena,
    createdAt: "Oct 19, 2026",
    modifiedAt: "Yesterday, 4:08 PM",
    modifiedOrder: 91,
    starred: false,
    shared: true,
    recent: true,
    access: "Workspace editors",
    tags: ["Components", "Draft"],
    summary: "Responsive three-pane workspace layouts, collapsible rails, and toolbar overflow specs.",
    versionNote: "v2.3 · Added compact tablet breakpoints",
    collaborators: [OWNERS.elena, OWNERS.devon],
  },
  {
    id: "data-table-spec",
    parentId: "ds-components",
    name: "data-table-spec.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 42_100,
    sizeLabel: "42 KB",
    owner: OWNERS.devon,
    createdAt: "Oct 22, 2026",
    modifiedAt: "Nov 24, 2026",
    modifiedOrder: 73,
    starred: false,
    shared: true,
    recent: false,
    access: "Workspace editors",
    tags: ["Components"],
    summary: "Row selection, column sorting, inline menus, and virtual scroll thresholds.",
    versionNote: "v1.5 · Added sticky header elevation rule",
    collaborators: [OWNERS.devon, OWNERS.marcus],
  },
  {
    id: "motion-curves",
    parentId: "ds-components",
    name: "motion-curves.json",
    type: "file",
    category: "code",
    kindLabel: "JSON Config",
    extension: "JSON",
    sizeBytes: 19_500,
    sizeLabel: "20 KB",
    owner: OWNERS.devon,
    createdAt: "Nov 02, 2026",
    modifiedAt: "Nov 21, 2026",
    modifiedOrder: 68,
    starred: false,
    shared: false,
    recent: false,
    access: "Workspace editors",
    tags: ["Motion"],
    summary: "Standard cubic-bezier easing curves and reduced-motion fallbacks for overlays.",
    versionNote: "v1.1 · Tuned popover enter duration to 140ms",
    collaborators: [OWNERS.devon],
  },

  // Engineering children
  {
    id: "eng-rfcs",
    parentId: "engineering",
    name: "Architecture RFCs",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 5_100_000,
    sizeLabel: "5.1 MB",
    owner: OWNERS.nadia,
    createdAt: "Aug 10, 2026",
    modifiedAt: "Today, 9:18 AM",
    modifiedOrder: 98,
    starred: false,
    shared: true,
    recent: true,
    access: "Engineering & Platform",
    tags: ["RFC"],
    summary: "Technical design proposals under active architecture review.",
    versionNote: "Nadia posted comments on RFC-045",
    collaborators: [OWNERS.nadia, OWNERS.marcus],
  },
  {
    id: "eng-releases",
    parentId: "engineering",
    name: "Releases",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 6_400_000,
    sizeLabel: "6.4 MB",
    owner: OWNERS.marcus,
    createdAt: "Sep 01, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 86,
    starred: false,
    shared: true,
    recent: false,
    access: "Engineering & Platform",
    tags: ["Production"],
    summary: "Signed release notes, bundle budget snapshots, and post-deploy metrics.",
    versionNote: "Published v4.12 release bundle report",
    collaborators: [OWNERS.marcus, OWNERS.nadia],
  },
  {
    id: "workspace-schema",
    parentId: "engineering",
    name: "workspace-schema.sql",
    type: "file",
    category: "code",
    kindLabel: "SQL Schema",
    extension: "SQL",
    sizeBytes: 68_400,
    sizeLabel: "68 KB",
    owner: OWNERS.nadia,
    createdAt: "Aug 18, 2026",
    modifiedAt: "Yesterday, 11:30 AM",
    modifiedOrder: 89,
    starred: true,
    shared: false,
    recent: true,
    access: "Engineering & Platform",
    tags: ["Database", "Production"],
    summary: "Relational schema for drive nodes, ACL grants, audit trails, and version pointers.",
    versionNote: "v5.2 · Added composite index on parent_id + name",
    collaborators: [OWNERS.nadia, OWNERS.marcus],
  },
  {
    id: "api-rate-limits",
    parentId: "engineering",
    name: "api-rate-limits.yaml",
    type: "file",
    category: "code",
    kindLabel: "YAML Config",
    extension: "YAML",
    sizeBytes: 12_800,
    sizeLabel: "13 KB",
    owner: OWNERS.marcus,
    createdAt: "Sep 11, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 77,
    starred: false,
    shared: false,
    recent: false,
    access: "Engineering & Platform",
    tags: ["API"],
    summary: "Edge gateway token-bucket quotas for sync, search, and presigned upload endpoints.",
    versionNote: "v2.4 · Raised enterprise burst ceiling",
    collaborators: [OWNERS.marcus],
  },
  {
    id: "deploy-runbook",
    parentId: "engineering",
    name: "deploy-runbook.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 31_200,
    sizeLabel: "31 KB",
    owner: OWNERS.marcus,
    createdAt: "Aug 25, 2026",
    modifiedAt: "Nov 23, 2026",
    modifiedOrder: 72,
    starred: false,
    shared: true,
    recent: false,
    access: "Engineering & Platform",
    tags: ["Ops", "Approved"],
    summary: "Zero-downtime rollout checklist, canary rollback commands, and pager escalation.",
    versionNote: "v3.1 · Updated EU-central failover step",
    collaborators: [OWNERS.marcus, OWNERS.nadia],
  },

  // Engineering -> RFCs children
  {
    id: "rfc-042",
    parentId: "eng-rfcs",
    name: "rfc-042-edge-cache.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 54_000,
    sizeLabel: "54 KB",
    owner: OWNERS.nadia,
    createdAt: "Oct 14, 2026",
    modifiedAt: "Nov 28, 2026",
    modifiedOrder: 83,
    starred: false,
    shared: true,
    recent: false,
    access: "Engineering & Platform",
    tags: ["RFC", "Approved"],
    summary: "Regional read-through metadata cache cutting cold folder listings below 45ms p95.",
    versionNote: "Accepted · Ready for Q4 milestone 2",
    collaborators: [OWNERS.nadia, OWNERS.marcus],
  },
  {
    id: "rfc-045",
    parentId: "eng-rfcs",
    name: "rfc-045-realtime-sync.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 63_200,
    sizeLabel: "63 KB",
    owner: OWNERS.marcus,
    createdAt: "Nov 20, 2026",
    modifiedAt: "Today, 9:18 AM",
    modifiedOrder: 98,
    starred: true,
    shared: true,
    recent: true,
    access: "Engineering & Platform",
    tags: ["RFC", "Draft"],
    summary: "Delta-stream fanout protocol for live folder updates and collaborative presence cursors.",
    versionNote: "v0.9 · Open for architecture review",
    collaborators: [OWNERS.marcus, OWNERS.nadia, OWNERS.devon],
  },
  {
    id: "sharding-diagram",
    parentId: "eng-rfcs",
    name: "storage-sharding-diagram.svg",
    type: "file",
    category: "design",
    kindLabel: "SVG Vector",
    extension: "SVG",
    sizeBytes: 420_000,
    sizeLabel: "420 KB",
    owner: OWNERS.nadia,
    createdAt: "Nov 15, 2026",
    modifiedAt: "Nov 27, 2026",
    modifiedOrder: 79,
    starred: false,
    shared: true,
    recent: false,
    access: "Engineering & Platform",
    tags: ["Architecture"],
    summary: "Consistent hash ring topology for multi-region blob replication and cold tiering.",
    versionNote: "v1.2 · Added disaster-recovery replica zone",
    collaborators: [OWNERS.nadia],
  },

  // Engineering -> Releases children
  {
    id: "v412-changelog",
    parentId: "eng-releases",
    name: "v4.12-changelog.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 24_100,
    sizeLabel: "24 KB",
    owner: OWNERS.marcus,
    createdAt: "Nov 28, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 86,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Release"],
    summary: "Production changelog covering faster thumbnail streaming and keyboard tree focus.",
    versionNote: "Signed off for production cut",
    collaborators: [OWNERS.marcus, OWNERS.priya],
  },
  {
    id: "bundle-budget",
    parentId: "eng-releases",
    name: "bundle-budget-report.csv",
    type: "file",
    category: "sheet",
    kindLabel: "CSV Dataset",
    extension: "CSV",
    sizeBytes: 186_000,
    sizeLabel: "186 KB",
    owner: OWNERS.devon,
    createdAt: "Nov 29, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 85,
    starred: false,
    shared: false,
    recent: false,
    access: "Engineering & Platform",
    tags: ["Performance"],
    summary: "Gzipped route bundle sizes across desktop shell, mobile reader, and embedded previews.",
    versionNote: "All chunks within 120 KB budget",
    collaborators: [OWNERS.devon, OWNERS.marcus],
  },
  {
    id: "telemetry-snapshot",
    parentId: "eng-releases",
    name: "telemetry-snapshot.json",
    type: "file",
    category: "code",
    kindLabel: "JSON Snapshot",
    extension: "JSON",
    sizeBytes: 1_240_000,
    sizeLabel: "1.2 MB",
    owner: OWNERS.nadia,
    createdAt: "Nov 29, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 84,
    starred: false,
    shared: false,
    recent: false,
    access: "Engineering & Platform",
    tags: ["Metrics"],
    summary: "Anonymized p50/p95/p99 latency percentiles from the November canary rollout.",
    versionNote: "Zero error-budget regression",
    collaborators: [OWNERS.nadia],
  },

  // Launch Q4 children
  {
    id: "q4-press",
    parentId: "launch-q4",
    name: "Press Kit",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 48_200_000,
    sizeLabel: "48.2 MB",
    owner: OWNERS.soren,
    createdAt: "Oct 10, 2026",
    modifiedAt: "Yesterday, 2:10 PM",
    modifiedOrder: 90,
    starred: false,
    shared: true,
    recent: true,
    access: "Public link (view only)",
    tags: ["Press", "Approved"],
    summary: "High-resolution product stills, executive portraits, and embargoed fact sheets.",
    versionNote: "Replaced hero still with final dark-mode crop",
    collaborators: [OWNERS.soren, OWNERS.priya],
  },
  {
    id: "q4-deck",
    parentId: "launch-q4",
    name: "Deck & Copy",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 32_600_000,
    sizeLabel: "32.6 MB",
    owner: OWNERS.priya,
    createdAt: "Oct 12, 2026",
    modifiedAt: "Yesterday, 5:45 PM",
    modifiedOrder: 92,
    starred: false,
    shared: true,
    recent: true,
    access: "Launch Core Team",
    tags: ["Q4", "Copy"],
    summary: "Keynote narrative slides, announcement blog post, and social channel copy.",
    versionNote: "Final legal review completed",
    collaborators: [OWNERS.priya, OWNERS.soren, OWNERS.elena],
  },
  {
    id: "launch-timeline",
    parentId: "launch-q4",
    name: "launch-timeline-q4.xlsx",
    type: "file",
    category: "sheet",
    kindLabel: "Spreadsheet",
    extension: "XLSX",
    sizeBytes: 620_000,
    sizeLabel: "620 KB",
    owner: OWNERS.priya,
    createdAt: "Oct 02, 2026",
    modifiedAt: "Yesterday, 6:15 PM",
    modifiedOrder: 93,
    starred: true,
    shared: true,
    recent: true,
    access: "Launch Core Team",
    tags: ["Q4", "Schedule"],
    summary: "Hour-by-hour launch day run of show, owner sign-offs, and fallback triggers.",
    versionNote: "v9 · Locked T-minus 48h freeze window",
    collaborators: [OWNERS.priya, OWNERS.marcus, OWNERS.soren],
  },
  {
    id: "demo-walkthrough",
    parentId: "launch-q4",
    name: "demo-walkthrough-cut3.mov",
    type: "file",
    category: "media",
    kindLabel: "QuickTime Video",
    extension: "MOV",
    sizeBytes: 82_400_000,
    sizeLabel: "82.4 MB",
    owner: OWNERS.soren,
    createdAt: "Nov 24, 2026",
    modifiedAt: "Yesterday, 3:20 PM",
    modifiedOrder: 90,
    starred: false,
    shared: true,
    recent: true,
    access: "Launch Core Team",
    tags: ["Video", "Q4"],
    summary: "60fps 4K product sizzle reel showcasing workspace search, inspector, and live sync.",
    versionNote: "Cut 3 · Audio mastered to -14 LUFS",
    collaborators: [OWNERS.soren, OWNERS.elena, OWNERS.priya],
  },
  {
    id: "pricing-model",
    parentId: "launch-q4",
    name: "pricing-tier-model.csv",
    type: "file",
    category: "sheet",
    kindLabel: "CSV Dataset",
    extension: "CSV",
    sizeBytes: 148_000,
    sizeLabel: "148 KB",
    owner: OWNERS.priya,
    createdAt: "Oct 20, 2026",
    modifiedAt: "Nov 25, 2026",
    modifiedOrder: 75,
    starred: false,
    shared: false,
    recent: false,
    access: "Leadership only",
    tags: ["Finance", "Confidential"],
    summary: "Seat and storage tier scenarios modeling Team, Scale, and Enterprise gross margins.",
    versionNote: "v4 · Approved by finance",
    collaborators: [OWNERS.priya],
  },

  // Launch Q4 -> Press Kit children
  {
    id: "hero-keynote-still",
    parentId: "q4-press",
    name: "hero-keynote-still.png",
    type: "file",
    category: "media",
    kindLabel: "PNG Image",
    extension: "PNG",
    sizeBytes: 6_840_000,
    sizeLabel: "6.8 MB",
    owner: OWNERS.soren,
    createdAt: "Nov 18, 2026",
    modifiedAt: "Yesterday, 2:10 PM",
    modifiedOrder: 90,
    starred: true,
    shared: true,
    recent: true,
    access: "Public link (view only)",
    tags: ["Press", "Approved"],
    summary: "3840x2160 crisp desktop showcase render prepared for editorial press coverage.",
    versionNote: "Final export with Display P3 profile",
    collaborators: [OWNERS.soren, OWNERS.elena],
  },
  {
    id: "founder-portrait",
    parentId: "q4-press",
    name: "founder-portrait.jpg",
    type: "file",
    category: "media",
    kindLabel: "JPEG Image",
    extension: "JPG",
    sizeBytes: 4_120_000,
    sizeLabel: "4.1 MB",
    owner: OWNERS.soren,
    createdAt: "Oct 28, 2026",
    modifiedAt: "Nov 14, 2026",
    modifiedOrder: 58,
    starred: false,
    shared: true,
    recent: false,
    access: "Public link (view only)",
    tags: ["Press"],
    summary: "Studio editorial portrait cropped for conference bios and media kits.",
    versionNote: "Color-graded print & web master",
    collaborators: [OWNERS.soren],
  },
  {
    id: "product-fact-sheet",
    parentId: "q4-press",
    name: "product-fact-sheet.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 1_450_000,
    sizeLabel: "1.4 MB",
    owner: OWNERS.priya,
    createdAt: "Nov 05, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 78,
    starred: false,
    shared: true,
    recent: false,
    access: "Public link (view only)",
    tags: ["Press", "Approved"],
    summary: "Two-page overview of Kestrel Cloud architecture, security certifications, and metrics.",
    versionNote: "v2.2 · Added SOC 2 Type II confirmation",
    collaborators: [OWNERS.priya, OWNERS.soren],
  },

  // Launch Q4 -> Deck & Copy children
  {
    id: "q4-launch-deck",
    parentId: "q4-deck",
    name: "kestrel-q4-launch-deck.key",
    type: "file",
    category: "deck",
    kindLabel: "Keynote Presentation",
    extension: "KEY",
    sizeBytes: 28_900_000,
    sizeLabel: "28.9 MB",
    owner: OWNERS.priya,
    createdAt: "Oct 15, 2026",
    modifiedAt: "Yesterday, 5:45 PM",
    modifiedOrder: 92,
    starred: true,
    shared: true,
    recent: true,
    access: "Launch Core Team",
    tags: ["Keynote", "Q4"],
    summary: "42-slide keynote presentation with embedded product animations and speaker notes.",
    versionNote: "v11 · Rehearsed timing at 18 minutes",
    collaborators: [OWNERS.priya, OWNERS.soren, OWNERS.elena],
  },
  {
    id: "announcement-blog",
    parentId: "q4-deck",
    name: "announcement-blog-draft.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 22_400,
    sizeLabel: "22 KB",
    owner: OWNERS.priya,
    createdAt: "Nov 10, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 87,
    starred: false,
    shared: true,
    recent: false,
    access: "Launch Core Team",
    tags: ["Copy", "Approved"],
    summary: "Launch day engineering and design story explaining Kestrel Workspace Drive v4.",
    versionNote: "Copy-edited and queued for CMS publish",
    collaborators: [OWNERS.priya, OWNERS.marcus],
  },

  // Brand Assets children
  {
    id: "brand-logos",
    parentId: "brand-assets",
    name: "Logomarks",
    type: "folder",
    category: "folder",
    kindLabel: "Workspace Folder",
    sizeBytes: 1_240_000,
    sizeLabel: "1.2 MB",
    owner: OWNERS.soren,
    createdAt: "Jul 19, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 76,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand", "Approved"],
    summary: "Production vector marks for dark, light, and monochrome applications.",
    versionNote: "Standardized viewBox padding across marks",
    collaborators: [OWNERS.soren, OWNERS.elena],
  },
  {
    id: "brand-guidelines",
    parentId: "brand-assets",
    name: "brand-guidelines-2026.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 14_600_000,
    sizeLabel: "14.6 MB",
    owner: OWNERS.soren,
    createdAt: "Jul 20, 2026",
    modifiedAt: "Nov 15, 2026",
    modifiedOrder: 60,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand", "Approved"],
    summary: "Complete visual identity handbook: grids, type pairings, photography, and voice.",
    versionNote: "v3.0 · Added motion identity chapter",
    collaborators: [OWNERS.soren, OWNERS.elena],
  },
  {
    id: "palette-swatches",
    parentId: "brand-assets",
    name: "editorial-palette-swatches.ase",
    type: "file",
    category: "design",
    kindLabel: "Color Swatch Library",
    extension: "ASE",
    sizeBytes: 64_000,
    sizeLabel: "64 KB",
    owner: OWNERS.soren,
    createdAt: "Aug 12, 2026",
    modifiedAt: "Nov 12, 2026",
    modifiedOrder: 56,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand"],
    summary: "Print CMYK and Pantone equivalents matched to digital OKLCH accent hues.",
    versionNote: "v1.2 · Verified coated stock proofs",
    collaborators: [OWNERS.soren],
  },

  // Brand Assets -> Logomarks children
  {
    id: "logo-dark",
    parentId: "brand-logos",
    name: "kestrel-wordmark-dark.svg",
    type: "file",
    category: "design",
    kindLabel: "SVG Vector",
    extension: "SVG",
    sizeBytes: 16_400,
    sizeLabel: "16 KB",
    owner: OWNERS.soren,
    createdAt: "Jul 19, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 76,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand"],
    summary: "Primary horizontal wordmark for light surfaces with outlined curves.",
    versionNote: "Optimized SVG paths",
    collaborators: [OWNERS.soren],
  },
  {
    id: "logo-light",
    parentId: "brand-logos",
    name: "kestrel-wordmark-light.svg",
    type: "file",
    category: "design",
    kindLabel: "SVG Vector",
    extension: "SVG",
    sizeBytes: 16_200,
    sizeLabel: "16 KB",
    owner: OWNERS.soren,
    createdAt: "Jul 19, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 75,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand"],
    summary: "Inverted white wordmark for dark mode surfaces and photography overlays.",
    versionNote: "Optimized SVG paths",
    collaborators: [OWNERS.soren],
  },
  {
    id: "logo-monogram",
    parentId: "brand-logos",
    name: "kestrel-monogram.svg",
    type: "file",
    category: "design",
    kindLabel: "SVG Vector",
    extension: "SVG",
    sizeBytes: 9_800,
    sizeLabel: "10 KB",
    owner: OWNERS.soren,
    createdAt: "Jul 19, 2026",
    modifiedAt: "Nov 26, 2026",
    modifiedOrder: 74,
    starred: false,
    shared: true,
    recent: false,
    access: "Everyone in Kestrel",
    tags: ["Brand"],
    summary: "Square app-icon mark balanced for favicons and mobile launch screens.",
    versionNote: "v2.0 · Optical corner balance update",
    collaborators: [OWNERS.soren],
  },

  // Shared children
  {
    id: "shared-partners",
    parentId: "shared",
    name: "Partner Reviews",
    type: "folder",
    category: "folder",
    kindLabel: "Shared Folder",
    sizeBytes: 8_400_000,
    sizeLabel: "8.4 MB",
    owner: OWNERS.nadia,
    createdAt: "Oct 24, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 84,
    starred: false,
    shared: true,
    recent: false,
    access: "External partners + Editors",
    tags: ["Partner"],
    summary: "Security questionnaires and pilot statements of work with enterprise design partners.",
    versionNote: "Uploaded Northstar signed appendix",
    collaborators: [OWNERS.nadia, OWNERS.priya],
  },
  {
    id: "board-memo",
    parentId: "shared",
    name: "quarterly-board-memo.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 3_620_000,
    sizeLabel: "3.6 MB",
    owner: OWNERS.priya,
    createdAt: "Nov 21, 2026",
    modifiedAt: "Nov 28, 2026",
    modifiedOrder: 81,
    starred: false,
    shared: true,
    recent: false,
    access: "Board & Leadership",
    tags: ["Q4", "Approved"],
    summary: "Executive summary of Q3 retention, Q4 launch readiness, and 2027 roadmap priorities.",
    versionNote: "Final packet distributed",
    collaborators: [OWNERS.priya, OWNERS.marcus],
  },
  {
    id: "advisory-notes",
    parentId: "shared",
    name: "customer-advisory-notes.md",
    type: "file",
    category: "doc",
    kindLabel: "Markdown Note",
    extension: "MD",
    sizeBytes: 36_400,
    sizeLabel: "36 KB",
    owner: OWNERS.elena,
    createdAt: "Nov 14, 2026",
    modifiedAt: "Nov 27, 2026",
    modifiedOrder: 79,
    starred: false,
    shared: true,
    recent: false,
    access: "Workspace editors",
    tags: ["Research"],
    summary: "Synthesized interviews from 12 enterprise workspace admins on file search and tagging.",
    versionNote: "Added top 5 feature requests summary",
    collaborators: [OWNERS.elena, OWNERS.priya],
  },

  // Shared -> Partner Reviews children
  {
    id: "acme-security",
    parentId: "shared-partners",
    name: "acme-security-questionnaire.xlsx",
    type: "file",
    category: "sheet",
    kindLabel: "Spreadsheet",
    extension: "XLSX",
    sizeBytes: 512_000,
    sizeLabel: "512 KB",
    owner: OWNERS.nadia,
    createdAt: "Nov 12, 2026",
    modifiedAt: "Nov 29, 2026",
    modifiedOrder: 84,
    starred: false,
    shared: true,
    recent: false,
    access: "External partners + Editors",
    tags: ["Security", "Partner"],
    summary: "Completed 180-question enterprise security and encryption-at-rest assessment.",
    versionNote: "Signed off by Security Lead",
    collaborators: [OWNERS.nadia],
  },
  {
    id: "northstar-sow",
    parentId: "shared-partners",
    name: "northstar-pilot-sow.pdf",
    type: "file",
    category: "doc",
    kindLabel: "PDF Document",
    extension: "PDF",
    sizeBytes: 2_180_000,
    sizeLabel: "2.2 MB",
    owner: OWNERS.priya,
    createdAt: "Nov 19, 2026",
    modifiedAt: "Nov 28, 2026",
    modifiedOrder: 82,
    starred: false,
    shared: true,
    recent: false,
    access: "External partners + Editors",
    tags: ["Partner", "Approved"],
    summary: "90-day pilot scope, success criteria, and dedicated migration support terms.",
    versionNote: "Countersigned copy",
    collaborators: [OWNERS.priya, OWNERS.nadia],
  },
];

const SUGGESTED_TAGS = ["Reviewed", "Archive", "Priority", "Internal", "Shareable"];

/* -------------------------------------------------------------------------- */
/* Crisp inline SVG icons (zero external icon packages)                       */
/* -------------------------------------------------------------------------- */

function ChevronLeftIcon() {
  return (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M10 3.5 5.5 8l4.5 4.5"
        stroke="currentColor"
        strokeWidth="1.5"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function ChevronRightIcon({ size = 16 }: { size?: number }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M6 3.5 10.5 8 6 12.5"
        stroke="currentColor"
        strokeWidth="1.5"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function SidebarIcon() {
  return (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <rect x="2" y="2.5" width="12" height="11" rx="2" stroke="currentColor" strokeWidth="1.4" />
      <path d="M6 2.5v11" stroke="currentColor" strokeWidth="1.4" />
    </svg>
  );
}

function InspectorIcon() {
  return (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <rect x="2" y="2.5" width="12" height="11" rx="2" stroke="currentColor" strokeWidth="1.4" />
      <path d="M10 2.5v11" stroke="currentColor" strokeWidth="1.4" />
    </svg>
  );
}

function SearchIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <circle cx="7.25" cy="7.25" r="4.75" stroke="currentColor" strokeWidth="1.4" />
      <path d="m10.75 10.75 3 3" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" />
    </svg>
  );
}

function CloseIcon({ size = 14 }: { size?: number }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M4 4l8 8M12 4l-8 8"
        stroke="currentColor"
        strokeWidth="1.5"
        strokeLinecap="round"
      />
    </svg>
  );
}

function ListViewIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M2.5 4h11M2.5 8h11M2.5 12h11"
        stroke="currentColor"
        strokeWidth="1.4"
        strokeLinecap="round"
      />
    </svg>
  );
}

function GridViewIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <rect x="2.25" y="2.25" width="4.5" height="4.5" rx="1" stroke="currentColor" strokeWidth="1.4" />
      <rect x="9.25" y="2.25" width="4.5" height="4.5" rx="1" stroke="currentColor" strokeWidth="1.4" />
      <rect x="2.25" y="9.25" width="4.5" height="4.5" rx="1" stroke="currentColor" strokeWidth="1.4" />
      <rect x="9.25" y="9.25" width="4.5" height="4.5" rx="1" stroke="currentColor" strokeWidth="1.4" />
    </svg>
  );
}

function ColumnsViewIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <rect x="2" y="2.5" width="12" height="11" rx="1.5" stroke="currentColor" strokeWidth="1.4" />
      <path d="M6 2.5v11M10 2.5v11" stroke="currentColor" strokeWidth="1.4" />
    </svg>
  );
}

function SortIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M3 4.5h10M5 8h6M7 11.5h2"
        stroke="currentColor"
        strokeWidth="1.4"
        strokeLinecap="round"
      />
    </svg>
  );
}

function PlusIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path d="M8 3.25v9.5M3.25 8h9.5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
    </svg>
  );
}

function MoreIcon() {
  return (
    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <circle cx="3.5" cy="8" r="1.2" fill="currentColor" />
      <circle cx="8" cy="8" r="1.2" fill="currentColor" />
      <circle cx="12.5" cy="8" r="1.2" fill="currentColor" />
    </svg>
  );
}

function StarIcon({ filled }: { filled: boolean }) {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M8 2.25 9.75 5.8l3.9.56-2.83 2.76.67 3.88L8 11.16 4.51 13l.67-3.88L2.35 6.36l3.9-.56L8 2.25Z"
        fill={filled ? "currentColor" : "none"}
        stroke="currentColor"
        strokeWidth="1.35"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function ShareIcon() {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M8 2.5v7.25M5.25 5.25 8 2.5l2.75 2.75M3.5 9.25v3a1.25 1.25 0 0 0 1.25 1.25h6.5a1.25 1.25 0 0 0 1.25-1.25v-3"
        stroke="currentColor"
        strokeWidth="1.4"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function DownloadIcon() {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M8 2.5v7.25M5.25 7.25 8 10l2.75-2.75M3.5 11.5v1a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-1"
        stroke="currentColor"
        strokeWidth="1.4"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function DriveIcon() {
  return (
    <svg width="15" height="15" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M2.5 5.25 8 2.25l5.5 3v5.5L8 13.75l-5.5-3v-5.5Z"
        stroke="currentColor"
        strokeWidth="1.4"
        strokeLinejoin="round"
      />
      <path d="M2.5 5.25 8 8.25l5.5-3M8 8.25v5.5" stroke="currentColor" strokeWidth="1.4" />
    </svg>
  );
}

function UsersIcon() {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <circle cx="6" cy="5.5" r="2.25" stroke="currentColor" strokeWidth="1.35" />
      <path d="M2.25 13c.45-2.1 2-3.25 3.75-3.25S9.3 10.9 9.75 13" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" />
      <circle cx="11.25" cy="6.25" r="1.75" stroke="currentColor" strokeWidth="1.35" />
      <path d="M10.75 10.1c1.35.25 2.45 1.15 2.85 2.9" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" />
    </svg>
  );
}

function ClockIcon() {
  return (
    <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <circle cx="8" cy="8" r="5.75" stroke="currentColor" strokeWidth="1.35" />
      <path d="M8 4.75V8l2.25 1.5" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

function FolderGlyph({ size = 16, filled = false }: { size?: number; filled?: boolean }) {
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M1.75 4.25c0-.69.56-1.25 1.25-1.25h3.1c.33 0 .65.13.88.37l.92.93h5.1c.69 0 1.25.56 1.25 1.25v6.2c0 .69-.56 1.25-1.25 1.25H3c-.69 0-1.25-.56-1.25-1.25v-7.5Z"
        fill={filled ? "currentColor" : "none"}
        fillOpacity={filled ? 0.18 : 0}
        stroke="currentColor"
        strokeWidth="1.35"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function NodeGlyph({ category, size = 16 }: { category: FileCategory; size?: number }) {
  if (category === "folder") {
    return <FolderGlyph size={size} filled />;
  }
  if (category === "design") {
    return (
      <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
        <rect x="2.5" y="2.5" width="11" height="11" rx="2.25" stroke="currentColor" strokeWidth="1.35" />
        <circle cx="6.25" cy="6.25" r="1.5" stroke="currentColor" strokeWidth="1.3" />
        <path d="M5.5 11.5 9.25 7.75 12 10.5" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    );
  }
  if (category === "code") {
    return (
      <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
        <path d="M5.5 5 2.5 8l3 3M10.5 5l3 3-3 3M8.75 3.5l-1.5 9" stroke="currentColor" strokeWidth="1.35" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    );
  }
  if (category === "sheet") {
    return (
      <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
        <rect x="2.5" y="2.5" width="11" height="11" rx="1.75" stroke="currentColor" strokeWidth="1.35" />
        <path d="M2.5 6.25h11M2.5 9.75h11M6.5 2.5v11" stroke="currentColor" strokeWidth="1.25" />
      </svg>
    );
  }
  if (category === "media") {
    return (
      <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
        <rect x="2.25" y="3" width="11.5" height="10" rx="2" stroke="currentColor" strokeWidth="1.35" />
        <path d="m6.75 6.25 3.5 1.75-3.5 1.75v-3.5Z" fill="currentColor" />
      </svg>
    );
  }
  if (category === "deck") {
    return (
      <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
        <rect x="2.25" y="3" width="11.5" height="8" rx="1.5" stroke="currentColor" strokeWidth="1.35" />
        <path d="M8 11v2.5M5.5 13.5h5M5 6.5h6M5 8.5h3.5" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
      </svg>
    );
  }
  return (
    <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path d="M4 2.25h5.25L12.5 5.5v8.25H4V2.25Z" stroke="currentColor" strokeWidth="1.35" strokeLinejoin="round" />
      <path d="M9 2.25V5.75h3.5M6 8.25h4M6 10.75h3" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  );
}

/* -------------------------------------------------------------------------- */
/* Helpers                                                                    */
/* -------------------------------------------------------------------------- */

function getAncestorChain(nodes: DriveNode[], folderId: string | null): DriveNode[] {
  const byId = new Map(nodes.map((n) => [n.id, n]));
  const chain: DriveNode[] = [];
  let cursor = folderId;
  while (cursor) {
    const node = byId.get(cursor);
    if (!node) break;
    chain.unshift(node);
    cursor = node.parentId;
  }
  return chain;
}

function getLocationPath(nodes: DriveNode[], node: DriveNode, workspaceName: string): string {
  const ancestors = getAncestorChain(nodes, node.parentId);
  return [workspaceName, ...ancestors.map((a) => a.name)].join(" / ");
}

function sortNodes(items: DriveNode[], field: SortField, dir: SortDir): DriveNode[] {
  const factor = dir === "asc" ? 1 : -1;
  return [...items].sort((a, b) => {
    if (a.type !== b.type) {
      return a.type === "folder" ? -1 : 1;
    }
    if (field === "name") {
      return a.name.localeCompare(b.name) * factor;
    }
    if (field === "modified") {
      return (a.modifiedOrder - b.modifiedOrder) * factor;
    }
    if (field === "size") {
      return (a.sizeBytes - b.sizeBytes) * factor;
    }
    return a.kindLabel.localeCompare(b.kindLabel) * factor;
  });
}

/* -------------------------------------------------------------------------- */
/* Styles                                                                     */
/* -------------------------------------------------------------------------- */

const styles = stylex.create({
  root: {
    backgroundColor: semanticColors.bg,
    color: semanticColors.fg,
    containerName: "file-explorer",
    containerType: "inline-size",
    fontFamily: fonts.body,
    height: "100%",
    minHeight: "38rem",
    overflow: "hidden",
    width: "100%",
  },
  header: {
    backgroundColor: semanticColors.bgSurface,
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    flexShrink: 0,
    paddingBlock: spacing._2,
    paddingInline: spacing._3,
  },
  brandMark: {
    backgroundColor: semanticColors.accentSubtle,
    borderRadius: semanticRadii.control,
    color: semanticColors.accentFg,
    height: "1.75rem",
    width: "1.75rem",
  },
  brandTitle: {
    letterSpacing: "-0.01em",
    whiteSpace: "nowrap",
  },
  msAuto: {
    marginInlineStart: "auto",
  },
  searchWrap: {
    position: "relative",
    width: {
      default: "15rem",
      [COMPACT_HEADER]: "11rem",
    },
  },
  searchIcon: {
    color: semanticColors.fgMuted,
    display: "inline-flex",
    insetInlineStart: spacing._2_5,
    pointerEvents: "none",
    position: "absolute",
    zIndex: 1,
  },
  searchInput: {
    paddingInlineEnd: spacing._7,
    paddingInlineStart: spacing._8,
  },
  searchClear: {
    alignItems: "center",
    backgroundColor: {
      default: "transparent",
      ":hover": semanticColors.bgSubtle,
    },
    borderRadius: radii.full,
    borderWidth: 0,
    color: semanticColors.fgMuted,
    cursor: "pointer",
    display: "inline-flex",
    height: "1.25rem",
    insetInlineEnd: spacing._1_5,
    justifyContent: "center",
    paddingBlock: 0,
    paddingInline: 0,
    position: "absolute",
    width: "1.25rem",
  },
  segmentLabel: {
    display: {
      default: "inline",
      [COMPACT_HEADER]: "none",
    },
  },
  segmentItem: {
    gap: spacing._1_5,
    paddingInline: spacing._2_5,
  },
  workspace: {
    flexGrow: 1,
    minHeight: 0,
    width: "100%",
  },
  railSplitterPanel: {
    display: {
      default: "flex",
      [NARROW_RAIL]: "none",
    },
    flexDirection: "column",
    minHeight: 0,
    minWidth: 0,
  },
  centerSplitterPanel: {
    containerName: "file-explorer-main",
    containerType: "inline-size",
    display: "flex",
    flexDirection: "column",
    minHeight: 0,
    minWidth: 0,
  },
  inspectorSplitterPanel: {
    display: {
      default: "flex",
      [NARROW_INSPECTOR]: "none",
    },
    flexDirection: "column",
    minHeight: 0,
    minWidth: 0,
  },
  railHandle: {
    display: {
      default: "grid",
      [NARROW_RAIL]: "none",
    },
  },
  inspectorHandle: {
    display: {
      default: "grid",
      [NARROW_INSPECTOR]: "none",
    },
  },
  sidebar: {
    backgroundColor: semanticColors.bgSurface,
    flexGrow: 1,
    minHeight: 0,
    overflowY: "auto",
    paddingBlock: spacing._3,
    paddingInline: spacing._2_5,
  },
  sidebarSectionLabel: {
    paddingInline: spacing._2,
  },
  quickNavBtn: {
    alignItems: "center",
    backgroundColor: {
      default: "transparent",
      ":hover": semanticColors.bgMuted,
    },
    borderRadius: semanticRadii.control,
    borderWidth: 0,
    color: semanticColors.fgMuted,
    cursor: "pointer",
    display: "flex",
    fontFamily: "inherit",
    fontSize: fontSizes.sm,
    fontWeight: fontWeights.medium,
    gap: spacing._2,
    justifyContent: "space-between",
    lineHeight: lineHeights.sm,
    paddingBlock: spacing._1_5,
    paddingInline: spacing._2,
    textAlign: "start",
    transitionDuration: durations.fast,
    transitionProperty: "background-color, color",
    width: "100%",
  },
  quickNavBtnActive: {
    backgroundColor: {
      default: semanticColors.accentSubtle,
      ":hover": semanticColors.accentSubtle,
    },
    color: semanticColors.accentFg,
  },
  treeWrap: {
    flexGrow: 1,
    minHeight: 0,
  },
  treeIconAccent: {
    color: semanticColors.accentFg,
    display: "inline-flex",
    flexShrink: 0,
  },
  treeTextTruncate: {
    overflow: "hidden",
    textOverflow: "ellipsis",
    whiteSpace: "nowrap",
  },
  storageCard: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.borderSubtle,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    marginTop: "auto",
    paddingBlock: spacing._2_5,
    paddingInline: spacing._3,
  },
  mainPane: {
    backgroundColor: semanticColors.bg,
    flexGrow: 1,
    minHeight: 0,
  },
  pathBar: {
    backgroundColor: semanticColors.bg,
    borderBottomColor: semanticColors.borderSubtle,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    flexShrink: 0,
    minHeight: "2.625rem",
    paddingBlock: spacing._1_5,
    paddingInline: spacing._4,
  },
  breadcrumbBtn: {
    backgroundColor: "transparent",
    borderWidth: 0,
    cursor: "pointer",
    fontFamily: "inherit",
    fontSize: "inherit",
    paddingBlock: spacing._0_5,
    paddingInline: spacing._1,
  },
  browserViewport: {
    flexGrow: 1,
    minHeight: 0,
    overflowY: "auto",
  },
  tableWrap: {
    overflowX: "auto",
    width: "100%",
  },
  tableHeaderRow: {
    backgroundColor: semanticColors.bgSurface,
  },
  tableTh: {
    borderBottomColor: semanticColors.border,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    color: semanticColors.fgMuted,
    fontSize: fontSizes.xs,
    fontWeight: fontWeights.medium,
    paddingBlock: spacing._2,
    paddingInline: spacing._3,
    whiteSpace: "nowrap",
  },
  tableThResponsive: {
    display: {
      default: "table-cell",
      [HIDE_TABLE_META]: "none",
    },
  },
  tableThAlignEnd: {
    textAlign: "end",
  },
  tableRow: {
    backgroundColor: {
      default: "transparent",
      ":hover": semanticColors.bgSubtle,
    },
    cursor: "pointer",
    transitionDuration: durations.fast,
    transitionProperty: "background-color",
  },
  tableRowSelected: {
    backgroundColor: {
      default: semanticColors.accentSubtle,
      ":hover": semanticColors.accentSubtle,
    },
  },
  tableCell: {
    borderBottomColor: semanticColors.borderSubtle,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    paddingBlock: spacing._2,
    paddingInline: spacing._3,
    verticalAlign: "middle",
  },
  tableCellResponsive: {
    display: {
      default: "table-cell",
      [HIDE_TABLE_META]: "none",
    },
  },
  tableCellMuted: {
    color: semanticColors.fgMuted,
    fontSize: fontSizes.xs,
    whiteSpace: "nowrap",
  },
  tableCellSize: {
    color: semanticColors.fgMuted,
    fontSize: fontSizes.xs,
    fontVariantNumeric: "tabular-nums",
    textAlign: "end",
    whiteSpace: "nowrap",
  },
  tableCellActions: {
    textAlign: "end",
    width: "2.5rem",
  },
  itemIconBadge: {
    borderRadius: semanticRadii.control,
    height: "1.875rem",
    width: "1.875rem",
  },
  starMark: {
    color: semanticColors.warningFg,
    display: "inline-flex",
    flexShrink: 0,
  },
  ownerCell: {
    display: "inline-flex",
    whiteSpace: "nowrap",
  },
  gridContainer: {
    gridTemplateColumns: "repeat(auto-fill, minmax(11.5rem, 1fr))",
    paddingBlock: spacing._4,
    paddingInline: spacing._4,
  },
  gridCard: {
    backgroundColor: semanticColors.bgSurface,
    borderColor: {
      default: semanticColors.border,
      ":hover": semanticColors.borderEmphasized,
    },
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    cursor: "pointer",
    overflow: "hidden",
    transitionDuration: durations.fast,
    transitionProperty: "border-color, box-shadow, background-color",
  },
  gridCardSelected: {
    backgroundColor: semanticColors.accentMuted,
    borderColor: semanticColors.accentBorder,
    boxShadow: semanticShadows.xs,
  },
  gridThumb: {
    backgroundColor: semanticColors.bgMuted,
    borderBottomColor: semanticColors.borderSubtle,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    height: "6.5rem",
    position: "relative",
  },
  gridThumbCornerStart: {
    insetInlineStart: spacing._2,
    position: "absolute",
    top: spacing._2,
  },
  gridThumbCornerEnd: {
    insetInlineEnd: spacing._1_5,
    position: "absolute",
    top: spacing._1_5,
  },
  gridBody: {
    paddingBlock: spacing._2_5,
    paddingInline: spacing._3,
  },
  columnsViewport: {
    height: "100%",
    minHeight: 0,
    overflowX: "auto",
    overflowY: "hidden",
  },
  millerColumn: {
    borderInlineEndColor: semanticColors.borderSubtle,
    borderInlineEndStyle: "solid",
    borderInlineEndWidth: "1px",
    flexShrink: 0,
    height: "100%",
    minHeight: 0,
    overflowY: "auto",
    paddingBlock: spacing._2,
    paddingInline: spacing._2,
    width: "14.5rem",
  },
  millerColumnHeader: {
    paddingBlock: spacing._1,
    paddingInline: spacing._2,
  },
  millerRow: {
    alignItems: "center",
    backgroundColor: {
      default: "transparent",
      ":hover": semanticColors.bgMuted,
    },
    borderRadius: semanticRadii.control,
    borderWidth: 0,
    color: semanticColors.fg,
    cursor: "pointer",
    display: "flex",
    fontFamily: "inherit",
    fontSize: fontSizes.sm,
    gap: spacing._2,
    justifyContent: "space-between",
    lineHeight: lineHeights.sm,
    paddingBlock: spacing._1_5,
    paddingInline: spacing._2,
    textAlign: "start",
    width: "100%",
  },
  millerRowSelected: {
    backgroundColor: {
      default: semanticColors.accentSubtle,
      ":hover": semanticColors.accentSubtle,
    },
    color: semanticColors.accentFg,
    fontWeight: fontWeights.medium,
  },
  inheritColor: {
    color: "inherit",
  },
  millerChevron: {
    color: semanticColors.fgSubtle,
    display: "inline-flex",
    flexShrink: 0,
  },
  inspector: {
    backgroundColor: semanticColors.bgSurface,
    flexGrow: 1,
    minHeight: 0,
    overflowY: "auto",
  },
  inspectorHeader: {
    borderBottomColor: semanticColors.borderSubtle,
    borderBottomStyle: "solid",
    borderBottomWidth: "1px",
    flexShrink: 0,
    minHeight: "2.625rem",
    paddingBlock: spacing._1_5,
    paddingInline: spacing._3_5,
  },
  inspectorBody: {
    paddingBlock: spacing._4,
    paddingInline: spacing._4,
  },
  previewHero: {
    backgroundColor: semanticColors.bgMuted,
    borderColor: semanticColors.borderSubtle,
    borderRadius: semanticRadii.panel,
    borderStyle: "solid",
    borderWidth: "1px",
    paddingBlock: spacing._5,
    paddingInline: spacing._4,
    textAlign: "center",
  },
  previewGlyphWrap: {
    borderRadius: semanticRadii.panel,
    height: "3.75rem",
    width: "3.75rem",
  },
  breakWord: {
    wordBreak: "break-word",
  },
  inspectorActionBtn: {
    flexBasis: 0,
    flexGrow: 1,
  },
  dataListCompact: {
    "--label-width": "5.25rem",
  },
  versionCard: {
    backgroundColor: semanticColors.bgMuted,
    borderRadius: semanticRadii.control,
    paddingBlock: spacing._2,
    paddingInline: spacing._2_5,
  },
  iconToneFolder: {
    backgroundColor: semanticColors.accentSubtle,
    color: semanticColors.accentFg,
  },
  iconToneDesign: {
    backgroundColor: semanticColors.purpleSubtle,
    color: semanticColors.purpleFg,
  },
  iconToneCode: {
    backgroundColor: semanticColors.blueSubtle,
    color: semanticColors.blueFg,
  },
  iconToneDoc: {
    backgroundColor: semanticColors.tealSubtle,
    color: semanticColors.tealFg,
  },
  iconToneSheet: {
    backgroundColor: semanticColors.emeraldSubtle,
    color: semanticColors.emeraldFg,
  },
  iconToneMedia: {
    backgroundColor: semanticColors.amberSubtle,
    color: semanticColors.amberFg,
  },
  iconToneDeck: {
    backgroundColor: semanticColors.redSubtle,
    color: semanticColors.redFg,
  },
  starIconBtn: {
    color: semanticColors.fgMuted,
  },
  starIconBtnActive: {
    color: semanticColors.warningFg,
  },
});

const ICON_TONE_BY_CATEGORY = {
  folder: styles.iconToneFolder,
  design: styles.iconToneDesign,
  code: styles.iconToneCode,
  doc: styles.iconToneDoc,
  sheet: styles.iconToneSheet,
  media: styles.iconToneMedia,
  deck: styles.iconToneDeck,
} as const;

export interface FileExplorerProps extends StyleOverrideProps {
  /** Workspace title displayed in the header and root breadcrumb. */
  workspaceName?: string;
  /** Initial view layout mode. */
  defaultView?: ViewMode;
  /** Initial folder ID opened on mount (`null` opens the drive root). */
  defaultFolderId?: string | null;
}

/**
 * FileExplorer — cloud workspace file manager combining a collapsible folder
 * tree sidebar, breadcrumb navigation, live search, list / grid / Miller-column
 * views, row actions menu, and a synchronized detail inspector panel.
 */
export function FileExplorer({
  workspaceName = "Kestrel Drive",
  defaultView = "list",
  defaultFolderId = "design-systems",
  palette,
  style,
}: FileExplorerProps) {
  const queue = useMemo(() => Toast.createToaster(), []);

  const [nodes, setNodes] = useState<DriveNode[]>(INITIAL_NODES);
  const [viewMode, setViewMode] = useState<ViewMode>(defaultView);
  const [smartFilter, setSmartFilter] = useState<SmartFilter>("all");
  const [searchQuery, setSearchQuery] = useState("");
  const [sortField, setSortField] = useState<SortField>("name");
  const [sortDir, setSortDir] = useState<SortDir>("asc");

  // Navigation history stack (each entry is a folderId or null for root)
  const [history, setHistory] = useState<Array<string | null>>([defaultFolderId]);
  const [historyIndex, setHistoryIndex] = useState(0);

  const [selectedId, setSelectedId] = useState<string | null>("kestrel-ui-v4");
  const [expandedFolders, setExpandedFolders] = useState<string[]>([
    "design-systems",
    "engineering",
    "launch-q4",
  ]);
  const [showSidebar, setShowSidebar] = useState(true);
  const [showInspector, setShowInspector] = useState(true);
  const [createdCounter, setCreatedCounter] = useState(1);

  const currentFolderId = history[historyIndex] ?? null;

  const nodesById = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]);

  const navigateToFolder = useCallback(
    (folderId: string | null, nextSelectedId?: string | null) => {
      setSmartFilter("all");
      setSearchQuery("");
      setHistory((prev) => {
        const sliced = prev.slice(0, historyIndex + 1);
        if (sliced[sliced.length - 1] === folderId) {
          return sliced;
        }
        return [...sliced, folderId];
      });
      setHistoryIndex((prev) => {
        const current = history[prev];
        return current === folderId ? prev : prev + 1;
      });
      if (folderId) {
        const chain = getAncestorChain(nodes, folderId).map((n) => n.id);
        setExpandedFolders((prev) => Array.from(new Set([...prev, ...chain])));
      }
      if (nextSelectedId !== undefined) {
        setSelectedId(nextSelectedId);
      } else {
        setSelectedId(folderId);
      }
    },
    [history, historyIndex, nodes],
  );

  const canGoBack = historyIndex > 0;
  const canGoForward = historyIndex < history.length - 1;

  const goBack = useCallback(() => {
    if (!canGoBack) return;
    const nextIdx = historyIndex - 1;
    setSmartFilter("all");
    setHistoryIndex(nextIdx);
    setSelectedId(history[nextIdx] ?? null);
  }, [canGoBack, history, historyIndex]);

  const goForward = useCallback(() => {
    if (!canGoForward) return;
    const nextIdx = historyIndex + 1;
    setSmartFilter("all");
    setHistoryIndex(nextIdx);
    setSelectedId(history[nextIdx] ?? null);
  }, [canGoForward, history, historyIndex]);

  const breadcrumbs = useMemo(
    () => getAncestorChain(nodes, currentFolderId),
    [nodes, currentFolderId],
  );

  const folderChildrenMap = useMemo(() => {
    const map = new Map<string | null, DriveNode[]>();
    for (const node of nodes) {
      if (node.type !== "folder") continue;
      const list = map.get(node.parentId) ?? [];
      list.push(node);
      map.set(node.parentId, list);
    }
    for (const [key, list] of map.entries()) {
      map.set(
        key,
        [...list].sort((a, b) => a.name.localeCompare(b.name)),
      );
    }
    return map;
  }, [nodes]);

  const childCountByFolder = useMemo(() => {
    const counts = new Map<string, number>();
    for (const node of nodes) {
      if (node.parentId) {
        counts.set(node.parentId, (counts.get(node.parentId) ?? 0) + 1);
      }
    }
    return counts;
  }, [nodes]);

  const starredCount = useMemo(() => nodes.filter((n) => n.starred).length, [nodes]);
  const sharedCount = useMemo(() => nodes.filter((n) => n.shared).length, [nodes]);
  const recentCount = useMemo(() => nodes.filter((n) => n.recent).length, [nodes]);

  const trimmedQuery = searchQuery.trim().toLowerCase();

  const displayedItems = useMemo(() => {
    let list: DriveNode[];
    if (trimmedQuery.length > 0) {
      list = nodes.filter(
        (n) =>
          n.name.toLowerCase().includes(trimmedQuery) ||
          n.kindLabel.toLowerCase().includes(trimmedQuery) ||
          n.owner.name.toLowerCase().includes(trimmedQuery) ||
          n.tags.some((t) => t.toLowerCase().includes(trimmedQuery)),
      );
    } else if (smartFilter === "starred") {
      list = nodes.filter((n) => n.starred);
    } else if (smartFilter === "shared") {
      list = nodes.filter((n) => n.shared);
    } else if (smartFilter === "recent") {
      list = nodes.filter((n) => n.recent);
    } else {
      list = nodes.filter((n) => n.parentId === currentFolderId);
    }
    return sortNodes(list, sortField, sortDir);
  }, [nodes, trimmedQuery, smartFilter, currentFolderId, sortField, sortDir]);

  // Miller columns path derived from currentFolderId + selectedId
  const millerColumns = useMemo(() => {
    const cols: Array<{ title: string; parentId: string | null; items: DriveNode[]; activeId: string | null }> = [];
    const selectedNode = selectedId ? nodesById.get(selectedId) ?? null : null;
    const activeChainIds: string[] = [];

    if (selectedNode) {
      const chain = getAncestorChain(nodes, selectedNode.id);
      for (const item of chain) {
        activeChainIds.push(item.id);
      }
    } else if (currentFolderId) {
      const chain = getAncestorChain(nodes, currentFolderId);
      for (const item of chain) {
        activeChainIds.push(item.id);
      }
    }

    const rootItems = sortNodes(
      nodes.filter((n) => n.parentId === null),
      sortField,
      sortDir,
    );
    cols.push({
      title: workspaceName,
      parentId: null,
      items: rootItems,
      activeId: activeChainIds[0] ?? null,
    });

    for (let i = 0; i < activeChainIds.length; i++) {
      const id = activeChainIds[i];
      const node = nodesById.get(id);
      if (!node || node.type !== "folder") break;
      const children = sortNodes(
        nodes.filter((n) => n.parentId === node.id),
        sortField,
        sortDir,
      );
      cols.push({
        title: node.name,
        parentId: node.id,
        items: children,
        activeId: activeChainIds[i + 1] ?? null,
      });
    }

    return cols;
  }, [nodes, nodesById, selectedId, currentFolderId, sortField, sortDir, workspaceName]);

  const inspectedNode = useMemo(() => {
    if (selectedId) {
      const found = nodesById.get(selectedId);
      if (found) return found;
    }
    if (currentFolderId) {
      const folder = nodesById.get(currentFolderId);
      if (folder) return folder;
    }
    return displayedItems[0] ?? nodes[0] ?? null;
  }, [selectedId, nodesById, currentFolderId, displayedItems, nodes]);

  /* ------------------------------ Mutations ------------------------------ */

  const handleToggleStar = useCallback(
    (node: DriveNode) => {
      const nextStarred = !node.starred;
      setNodes((prev) =>
        prev.map((item) => (item.id === node.id ? { ...item, starred: nextStarred } : item)),
      );
      queue.info(nextStarred ? `Starred ${node.name}` : `Removed ${node.name} from Starred`);
    },
    [queue],
  );

  const handleShare = useCallback(
    (node: DriveNode) => {
      queue.success(`Share link copied for ${node.name}`, {
        description: `Access: ${node.access}`,
      });
    },
    [queue],
  );

  const handleDownload = useCallback(
    (node: DriveNode) => {
      queue.info(`Preparing download for ${node.name}`, {
        description: node.type === "folder" ? "Archiving folder as .zip" : `${node.sizeLabel} · ${node.kindLabel}`,
      });
    },
    [queue],
  );

  const handleDuplicate = useCallback(
    (node: DriveNode) => {
      const dot = node.name.lastIndexOf(".");
      const copyName =
        node.type === "file" && dot > 0
          ? `${node.name.slice(0, dot)} copy${node.name.slice(dot)}`
          : `${node.name} Copy`;
      const newId = `${node.id}-copy-${Date.now()}`;
      const copy: DriveNode = {
        ...node,
        id: newId,
        name: copyName,
        modifiedAt: "Just now",
        modifiedOrder: 101 + createdCounter,
        recent: true,
        starred: false,
      };
      setNodes((prev) => [copy, ...prev]);
      setSelectedId(newId);
      setCreatedCounter((c) => c + 1);
      queue.success(`Duplicated ${node.name}`, { description: `Created ${copyName}` });
    },
    [createdCounter, queue],
  );

  const handleDelete = useCallback(
    (node: DriveNode) => {
      const idsToRemove = new Set<string>([node.id]);
      let added = true;
      while (added) {
        added = false;
        for (const item of nodes) {
          if (item.parentId && idsToRemove.has(item.parentId) && !idsToRemove.has(item.id)) {
            idsToRemove.add(item.id);
            added = true;
          }
        }
      }
      const removed = nodes.filter((item) => idsToRemove.has(item.id));
      setNodes((prev) => prev.filter((item) => !idsToRemove.has(item.id)));
      if (selectedId && idsToRemove.has(selectedId)) {
        setSelectedId(node.parentId);
      }
      queue.warning(`Moved ${node.name} to Trash`, {
        description: removed.length > 1 ? `${removed.length} items removed from folder.` : undefined,
        action: {
          label: "Undo",
          onAction: () => {
            setNodes((prev) => [...removed, ...prev]);
            setSelectedId(node.id);
          },
        },
      });
    },
    [nodes, selectedId, queue],
  );

  const handleCreateFolder = useCallback(() => {
    const n = createdCounter;
    const newId = `new-folder-${Date.now()}`;
    const folderName = n === 1 ? "Sprint Archive" : `Sprint Archive ${n}`;
    const newNode: DriveNode = {
      id: newId,
      parentId: smartFilter === "all" ? currentFolderId : null,
      name: folderName,
      type: "folder",
      category: "folder",
      kindLabel: "Workspace Folder",
      sizeBytes: 0,
      sizeLabel: "0 KB",
      owner: OWNERS.elena,
      createdAt: "Just now",
      modifiedAt: "Just now",
      modifiedOrder: 105 + n,
      starred: false,
      shared: false,
      recent: true,
      access: "Workspace editors",
      tags: ["New"],
      summary: "Newly created workspace folder ready for project assets.",
      versionNote: "Created just now",
      collaborators: [OWNERS.elena],
    };
    setNodes((prev) => [newNode, ...prev]);
    setCreatedCounter((c) => c + 1);
    setSelectedId(newId);
    if (smartFilter !== "all") {
      setSmartFilter("all");
    }
    queue.success(`Created folder "${folderName}"`);
  }, [createdCounter, currentFolderId, smartFilter, queue]);

  const handleCreateDoc = useCallback(() => {
    const n = createdCounter;
    const newId = `new-doc-${Date.now()}`;
    const docName = n === 1 ? "meeting-notes.md" : `meeting-notes-${n}.md`;
    const newNode: DriveNode = {
      id: newId,
      parentId: smartFilter === "all" ? currentFolderId : null,
      name: docName,
      type: "file",
      category: "doc",
      kindLabel: "Markdown Note",
      extension: "MD",
      sizeBytes: 4_200,
      sizeLabel: "4 KB",
      owner: OWNERS.elena,
      createdAt: "Just now",
      modifiedAt: "Just now",
      modifiedOrder: 105 + n,
      starred: false,
      shared: false,
      recent: true,
      access: "Workspace editors",
      tags: ["Draft"],
      summary: "Collaborative workspace note created inside Kestrel Drive.",
      versionNote: "v0.1 · Draft initialized",
      collaborators: [OWNERS.elena],
    };
    setNodes((prev) => [newNode, ...prev]);
    setCreatedCounter((c) => c + 1);
    setSelectedId(newId);
    if (smartFilter !== "all") {
      setSmartFilter("all");
    }
    queue.success(`Created note "${docName}"`);
  }, [createdCounter, currentFolderId, smartFilter, queue]);

  const handleAddTag = useCallback(
    (node: DriveNode) => {
      const nextTag = SUGGESTED_TAGS.find((t) => !node.tags.includes(t));
      if (!nextTag) {
        queue.info(`All suggested tags are already on ${node.name}`);
        return;
      }
      setNodes((prev) =>
        prev.map((item) => (item.id === node.id ? { ...item, tags: [...item.tags, nextTag] } : item)),
      );
      queue.success(`Added "${nextTag}" tag to ${node.name}`);
    },
    [queue],
  );

  const handleOpenItem = useCallback(
    (node: DriveNode) => {
      if (node.type === "folder") {
        navigateToFolder(node.id, node.id);
      } else {
        setSelectedId(node.id);
        setShowInspector(true);
        queue.info(`Opening ${node.name}`, {
          description: `${node.kindLabel} · ${node.sizeLabel}`,
        });
      }
    },
    [navigateToFolder, queue],
  );

  /* ------------------------------ Sub-renders ---------------------------- */

  const renderItemActionsMenu = (node: DriveNode) => (
    <Menu.Root size="sm">
      <Menu.Trigger
        render={
          <IconButton
            variant="ghost"
            size="xs"
            aria-label={`Actions for ${node.name}`}
            onClick={(e) => e.stopPropagation()}
          />
        }
      >
        <MoreIcon />
      </Menu.Trigger>
      <Menu.Content align="end">
        <Menu.Item onSelect={() => handleOpenItem(node)}>
          <Menu.ItemText>{node.type === "folder" ? "Open folder" : "Quick preview"}</Menu.ItemText>
          <Menu.ItemCommand>↵</Menu.ItemCommand>
        </Menu.Item>
        <Menu.Item onSelect={() => handleShare(node)}>
          <Menu.ItemText>Copy share link</Menu.ItemText>
          <Menu.ItemCommand>⌘L</Menu.ItemCommand>
        </Menu.Item>
        <Menu.Item onSelect={() => handleToggleStar(node)}>
          <Menu.ItemText>{node.starred ? "Remove star" : "Add star"}</Menu.ItemText>
        </Menu.Item>
        <Menu.Item onSelect={() => handleDuplicate(node)}>
          <Menu.ItemText>Duplicate</Menu.ItemText>
          <Menu.ItemCommand>⌘D</Menu.ItemCommand>
        </Menu.Item>
        <Menu.Item onSelect={() => handleDownload(node)}>
          <Menu.ItemText>Download</Menu.ItemText>
        </Menu.Item>
        <Menu.Separator />
        <Menu.Item data-destructive="" onSelect={() => handleDelete(node)}>
          <Menu.ItemText>Move to trash</Menu.ItemText>
          <Menu.ItemCommand>⌫</Menu.ItemCommand>
        </Menu.Item>
      </Menu.Content>
    </Menu.Root>
  );

  const renderFolderTreeBranch = (folder: DriveNode) => {
    const subFolders = folderChildrenMap.get(folder.id) ?? [];
    const isActive = smartFilter === "all" && currentFolderId === folder.id;

    if (subFolders.length > 0) {
      return (
        <TreeView.Branch key={folder.id} value={folder.id}>
          <TreeView.BranchControl
            data-selected={isActive ? "true" : undefined}
            onClick={() => navigateToFolder(folder.id)}
          >
            <TreeView.BranchIndicator>
              <TreeView.Icon viewBox="0 0 16 16" fill="none">
                <path
                  d="M6 3.5 10.5 8 6 12.5"
                  stroke="currentColor"
                  strokeWidth="1.5"
                  strokeLinecap="round"
                  strokeLinejoin="round"
                />
              </TreeView.Icon>
            </TreeView.BranchIndicator>
            <span {...stylex.props(styles.treeIconAccent)}>
              <FolderGlyph size={14} filled={isActive} />
            </span>
            <TreeView.BranchText style={styles.treeTextTruncate}>{folder.name}</TreeView.BranchText>
          </TreeView.BranchControl>
          <TreeView.BranchContent>
            <TreeView.BranchIndentGuide />
            {subFolders.map(renderFolderTreeBranch)}
          </TreeView.BranchContent>
        </TreeView.Branch>
      );
    }

    return (
      <TreeView.Item
        key={folder.id}
        value={folder.id}
        data-selected={isActive ? "true" : undefined}
        onClick={() => navigateToFolder(folder.id)}
      >
        <span {...stylex.props(styles.treeIconAccent)}>
          <FolderGlyph size={14} filled={isActive} />
        </span>
        <TreeView.ItemText style={styles.treeTextTruncate}>{folder.name}</TreeView.ItemText>
      </TreeView.Item>
    );
  };

  const defaultSplitLayout =
    showSidebar && showInspector
      ? [22, 52, 26]
      : showSidebar
        ? [24, 76]
        : showInspector
          ? [72, 28]
          : [100];

  const smartFilterLabel =
    smartFilter === "starred"
      ? "Starred"
      : smartFilter === "shared"
        ? "Shared with me"
        : smartFilter === "recent"
          ? "Recent activity"
          : null;

  return (
    <VStack gap="0" palette={palette} style={[styles.root, style]}>
      {/* Top Toolbar */}
      <HStack render={<header />} gap="2" justify="between" wrap="wrap" style={styles.header}>
        <HStack gap="1.5">
          <Toolbar.Root variant="plain" size="sm" aria-label="Workspace navigation">
            <Toolbar.Group>
              <Toolbar.Button
                aria-label={showSidebar ? "Hide sidebar" : "Show sidebar"}
                aria-pressed={showSidebar}
                onClick={() => setShowSidebar((v) => !v)}
              >
                <SidebarIcon />
              </Toolbar.Button>
              <Toolbar.Button
                aria-label="Go back"
                disabled={!canGoBack}
                onClick={goBack}
              >
                <ChevronLeftIcon />
              </Toolbar.Button>
              <Toolbar.Button
                aria-label="Go forward"
                disabled={!canGoForward}
                onClick={goForward}
              >
                <ChevronRightIcon />
              </Toolbar.Button>
            </Toolbar.Group>
            <Toolbar.Separator />
          </Toolbar.Root>

          <Square render={<span />} style={styles.brandMark}>
            <DriveIcon />
          </Square>
          <Text render={<h1 />} size="sm" weight="semibold" style={styles.brandTitle}>
            {workspaceName}
          </Text>
        </HStack>

        <HStack gap="2" wrap="wrap" style={styles.msAuto}>
          <HStack gap="0" style={styles.searchWrap}>
            <span {...stylex.props(styles.searchIcon)}>
              <SearchIcon />
            </span>
            <Input
              size="sm"
              variant="subtle"
              value={searchQuery}
              onChange={(e) => setSearchQuery(e.target.value)}
              placeholder="Search files, owners, tags…"
              aria-label="Search workspace files"
              style={styles.searchInput}
            />
            {searchQuery.length > 0 ? (
              <button
                type="button"
                aria-label="Clear search"
                onClick={() => setSearchQuery("")}
                {...stylex.props(styles.searchClear)}
              >
                <CloseIcon size={12} />
              </button>
            ) : null}
          </HStack>

          <SegmentGroup.Root
            size="xs"
            value={viewMode}
            onValueChange={(next) => {
              if (next === "list" || next === "grid" || next === "columns") {
                setViewMode(next);
              }
            }}
            aria-label="View layout"
          >
            <SegmentGroup.Item value="list" style={styles.segmentItem}>
              <ListViewIcon />
              <span {...stylex.props(styles.segmentLabel)}>List</span>
            </SegmentGroup.Item>
            <SegmentGroup.Item value="grid" style={styles.segmentItem}>
              <GridViewIcon />
              <span {...stylex.props(styles.segmentLabel)}>Grid</span>
            </SegmentGroup.Item>
            <SegmentGroup.Item value="columns" style={styles.segmentItem}>
              <ColumnsViewIcon />
              <span {...stylex.props(styles.segmentLabel)}>Columns</span>
            </SegmentGroup.Item>
          </SegmentGroup.Root>

          <Menu.Root size="sm">
            <Menu.Trigger render={<Button variant="surface" size="sm" aria-label="Sort files" />}>
              <SortIcon />
              <span {...stylex.props(styles.segmentLabel)}>Sort</span>
            </Menu.Trigger>
            <Menu.Content align="end">
              <Menu.Group>
                <Menu.GroupLabel>Sort by</Menu.GroupLabel>
                <Menu.RadioGroup
                  value={sortField}
                  onValueChange={(val) => {
                    if (val === "name" || val === "modified" || val === "size" || val === "kind") {
                      setSortField(val);
                    }
                  }}
                >
                  <Menu.RadioItem value="name">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>Name</Menu.ItemText>
                  </Menu.RadioItem>
                  <Menu.RadioItem value="modified">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>Last modified</Menu.ItemText>
                  </Menu.RadioItem>
                  <Menu.RadioItem value="size">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>File size</Menu.ItemText>
                  </Menu.RadioItem>
                  <Menu.RadioItem value="kind">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>File kind</Menu.ItemText>
                  </Menu.RadioItem>
                </Menu.RadioGroup>
              </Menu.Group>
              <Menu.Separator />
              <Menu.Group>
                <Menu.GroupLabel>Order</Menu.GroupLabel>
                <Menu.RadioGroup
                  value={sortDir}
                  onValueChange={(val) => {
                    if (val === "asc" || val === "desc") {
                      setSortDir(val);
                    }
                  }}
                >
                  <Menu.RadioItem value="asc">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>Ascending</Menu.ItemText>
                  </Menu.RadioItem>
                  <Menu.RadioItem value="desc">
                    <Menu.ItemIndicator />
                    <Menu.ItemText>Descending</Menu.ItemText>
                  </Menu.RadioItem>
                </Menu.RadioGroup>
              </Menu.Group>
            </Menu.Content>
          </Menu.Root>

          <Menu.Root size="sm">
            <Menu.Trigger
              render={<Button variant="solid" size="sm" palette={accentPalette} />}
            >
              <PlusIcon />
              New
            </Menu.Trigger>
            <Menu.Content align="end">
              <Menu.Item onSelect={handleCreateFolder}>
                <Menu.ItemText>New folder</Menu.ItemText>
                <Menu.ItemCommand>⇧⌘N</Menu.ItemCommand>
              </Menu.Item>
              <Menu.Item onSelect={handleCreateDoc}>
                <Menu.ItemText>New Markdown note</Menu.ItemText>
              </Menu.Item>
              <Menu.Separator />
              <Menu.Item
                onSelect={() =>
                  queue.info("Upload picker ready", {
                    description: "Drop files anywhere into Kestrel Drive to sync.",
                  })
                }
              >
                <Menu.ItemText>Upload files…</Menu.ItemText>
                <Menu.ItemCommand>⌘U</Menu.ItemCommand>
              </Menu.Item>
            </Menu.Content>
          </Menu.Root>

          <IconButton
            variant={showInspector ? "subtle" : "ghost"}
            size="sm"
            palette={showInspector ? accentPalette : undefined}
            aria-label={showInspector ? "Hide details inspector" : "Show details inspector"}
            aria-pressed={showInspector}
            onClick={() => setShowInspector((v) => !v)}
          >
            <InspectorIcon />
          </IconButton>
        </HStack>
      </HStack>

      {/* Resizable 3-Pane Workspace */}
      <HStack gap="0" style={styles.workspace}>
        <Splitter.Root
          key={`${showSidebar}-${showInspector}`}
          defaultSize={defaultSplitLayout}
          minSize={15}
          style={styles.workspace}
        >
          {showSidebar ? (
            <>
              <Splitter.Panel style={styles.railSplitterPanel}>
                <VStack
                  render={<aside />}
                  gap="3"
                  aria-label="Workspace navigation"
                  style={styles.sidebar}
                >
                  <VStack render={<nav />} gap="0.5" aria-label="Quick views">
                    <button
                      type="button"
                      onClick={() => {
                        setSmartFilter("all");
                        setSearchQuery("");
                        navigateToFolder(null, null);
                      }}
                      {...stylex.props(
                        styles.quickNavBtn,
                        smartFilter === "all" && currentFolderId === null && styles.quickNavBtnActive,
                      )}
                    >
                      <HStack render={<span />} gap="2">
                        <DriveIcon />
                        All files
                      </HStack>
                      <Text render={<span />} size="xs" tone="subtle" tabular="true">
                        {nodes.length}
                      </Text>
                    </button>

                    <button
                      type="button"
                      onClick={() => {
                        setSmartFilter("starred");
                        setSearchQuery("");
                      }}
                      {...stylex.props(
                        styles.quickNavBtn,
                        smartFilter === "starred" && styles.quickNavBtnActive,
                      )}
                    >
                      <HStack render={<span />} gap="2">
                        <StarIcon filled={smartFilter === "starred"} />
                        Starred
                      </HStack>
                      <Text render={<span />} size="xs" tone="subtle" tabular="true">
                        {starredCount}
                      </Text>
                    </button>

                    <button
                      type="button"
                      onClick={() => {
                        setSmartFilter("shared");
                        setSearchQuery("");
                      }}
                      {...stylex.props(
                        styles.quickNavBtn,
                        smartFilter === "shared" && styles.quickNavBtnActive,
                      )}
                    >
                      <HStack render={<span />} gap="2">
                        <UsersIcon />
                        Shared
                      </HStack>
                      <Text render={<span />} size="xs" tone="subtle" tabular="true">
                        {sharedCount}
                      </Text>
                    </button>

                    <button
                      type="button"
                      onClick={() => {
                        setSmartFilter("recent");
                        setSearchQuery("");
                      }}
                      {...stylex.props(
                        styles.quickNavBtn,
                        smartFilter === "recent" && styles.quickNavBtnActive,
                      )}
                    >
                      <HStack render={<span />} gap="2">
                        <ClockIcon />
                        Recent
                      </HStack>
                      <Text render={<span />} size="xs" tone="subtle" tabular="true">
                        {recentCount}
                      </Text>
                    </button>
                  </VStack>

                  <Separator decorative />

                  <VStack gap="1.5" style={styles.treeWrap}>
                    <Text
                      render={<h2 />}
                      variant="overline"
                      tone="subtle"
                      style={styles.sidebarSectionLabel}
                    >
                      Folders
                    </Text>
                    <TreeView.Root
                      size="xs"
                      variant="subtle"
                      palette={accentPalette}
                      expandedValue={expandedFolders}
                      onExpandedChange={(details) => setExpandedFolders(details.expandedValue)}
                    >
                      <TreeView.Tree aria-label="Workspace folders">
                        {(folderChildrenMap.get(null) ?? []).map(renderFolderTreeBranch)}
                      </TreeView.Tree>
                    </TreeView.Root>
                  </VStack>

                  <VStack gap="2" style={styles.storageCard}>
                    <HStack gap="2" justify="between">
                      <Text render={<span />} size="xs" weight="medium">
                        Workspace Storage
                      </Text>
                      <Text render={<span />} size="xs" tone="muted" tabular="true">
                        42.8 / 100 GB
                      </Text>
                    </HStack>
                    <Progress.Root
                      value={42.8}
                      max={100}
                      size="xs"
                      shape="full"
                      palette={accentPalette}
                      aria-label="Workspace storage used"
                    >
                      <Progress.Track>
                        <Progress.Range />
                      </Progress.Track>
                    </Progress.Root>
                    <Text size="xs" tone="subtle">
                      Design 18.2 GB · Media 14.1 GB · Docs 10.5 GB
                    </Text>
                  </VStack>
                </VStack>
              </Splitter.Panel>

              <Splitter.ResizeTrigger
                aria-label="Resize folder sidebar"
                style={styles.railHandle}
              />
            </>
          ) : null}

          {/* Center Main Browser */}
          <Splitter.Panel style={styles.centerSplitterPanel}>
            <VStack render={<main />} gap="0" aria-label="File browser" style={styles.mainPane}>
              <HStack gap="2" justify="between" wrap="wrap" style={styles.pathBar}>
                <HStack gap="2">
                  {trimmedQuery.length > 0 ? (
                    <Breadcrumb.Root size="sm" variant="plain" aria-label="Search scope">
                      <Breadcrumb.List>
                        <Breadcrumb.Item>
                          <Breadcrumb.Link
                            render={<button type="button" />}
                            onClick={() => setSearchQuery("")}
                            style={styles.breadcrumbBtn}
                          >
                            {workspaceName}
                          </Breadcrumb.Link>
                        </Breadcrumb.Item>
                        <Breadcrumb.Separator aria-hidden="true">
                          <ChevronRightIcon size={12} />
                        </Breadcrumb.Separator>
                        <Breadcrumb.Item>
                          <Breadcrumb.CurrentLink aria-current="page">
                            Search: &ldquo;{searchQuery.trim()}&rdquo;
                          </Breadcrumb.CurrentLink>
                        </Breadcrumb.Item>
                      </Breadcrumb.List>
                    </Breadcrumb.Root>
                  ) : smartFilterLabel ? (
                    <Breadcrumb.Root size="sm" variant="plain" aria-label="Filtered view">
                      <Breadcrumb.List>
                        <Breadcrumb.Item>
                          <Breadcrumb.Link
                            render={<button type="button" />}
                            onClick={() => setSmartFilter("all")}
                            style={styles.breadcrumbBtn}
                          >
                            {workspaceName}
                          </Breadcrumb.Link>
                        </Breadcrumb.Item>
                        <Breadcrumb.Separator aria-hidden="true">
                          <ChevronRightIcon size={12} />
                        </Breadcrumb.Separator>
                        <Breadcrumb.Item>
                          <Breadcrumb.CurrentLink aria-current="page">
                            {smartFilterLabel}
                          </Breadcrumb.CurrentLink>
                        </Breadcrumb.Item>
                      </Breadcrumb.List>
                    </Breadcrumb.Root>
                  ) : (
                    <Breadcrumb.Root size="sm" variant="plain" aria-label="Folder path">
                      <Breadcrumb.List>
                        <Breadcrumb.Item>
                          {breadcrumbs.length === 0 ? (
                            <Breadcrumb.CurrentLink aria-current="page">
                              {workspaceName}
                            </Breadcrumb.CurrentLink>
                          ) : (
                            <Breadcrumb.Link
                              render={<button type="button" />}
                              onClick={() => navigateToFolder(null, null)}
                              style={styles.breadcrumbBtn}
                            >
                              {workspaceName}
                            </Breadcrumb.Link>
                          )}
                        </Breadcrumb.Item>
                        {breadcrumbs.map((crumb, idx) => {
                          const isLast = idx === breadcrumbs.length - 1;
                          return (
                            <Fragment key={crumb.id}>
                              <Breadcrumb.Separator aria-hidden="true">
                                <ChevronRightIcon size={12} />
                              </Breadcrumb.Separator>
                              <Breadcrumb.Item>
                                {isLast ? (
                                  <Breadcrumb.CurrentLink aria-current="page">
                                    {crumb.name}
                                  </Breadcrumb.CurrentLink>
                                ) : (
                                  <Breadcrumb.Link
                                    render={<button type="button" />}
                                    onClick={() => navigateToFolder(crumb.id)}
                                    style={styles.breadcrumbBtn}
                                  >
                                    {crumb.name}
                                  </Breadcrumb.Link>
                                )}
                              </Breadcrumb.Item>
                            </Fragment>
                          );
                        })}
                      </Breadcrumb.List>
                    </Breadcrumb.Root>
                  )}
                </HStack>

                <HStack gap="2">
                  <Badge variant="subtle" size="sm">
                    {displayedItems.length} {displayedItems.length === 1 ? "item" : "items"}
                  </Badge>
                  {trimmedQuery.length > 0 || smartFilter !== "all" ? (
                    <Button
                      variant="ghost"
                      size="xs"
                      onClick={() => {
                        setSearchQuery("");
                        setSmartFilter("all");
                      }}
                    >
                      Clear filter
                    </Button>
                  ) : null}
                </HStack>
              </HStack>

              <div {...stylex.props(styles.browserViewport)}>
                {viewMode === "columns" && trimmedQuery.length === 0 && smartFilter === "all" ? (
                  <HStack
                    gap="0"
                    align="stretch"
                    role="region"
                    aria-label="Column browser"
                    style={styles.columnsViewport}
                  >
                    {millerColumns.map((col, colIdx) => (
                      <VStack
                        key={`${col.parentId ?? "root"}-${colIdx}`}
                        render={<section />}
                        gap="0"
                        aria-label={col.title}
                        style={styles.millerColumn}
                      >
                        <Text
                          render={<h3 />}
                          variant="overline"
                          tone="subtle"
                          style={styles.millerColumnHeader}
                        >
                          {col.title}
                        </Text>
                        {col.items.length === 0 ? (
                          <EmptyState.Root size="sm">
                            <EmptyState.Content>
                              <EmptyState.Title>Empty folder</EmptyState.Title>
                              <EmptyState.Description>No files in this folder.</EmptyState.Description>
                            </EmptyState.Content>
                          </EmptyState.Root>
                        ) : (
                          col.items.map((item) => {
                            const isActive = col.activeId === item.id;
                            return (
                              <button
                                key={item.id}
                                type="button"
                                onClick={() => {
                                  setSelectedId(item.id);
                                  if (item.type === "folder") {
                                    navigateToFolder(item.id, item.id);
                                  }
                                }}
                                onDoubleClick={() => handleOpenItem(item)}
                                {...stylex.props(
                                  styles.millerRow,
                                  isActive && styles.millerRowSelected,
                                )}
                              >
                                <HStack render={<span />} gap="2">
                                  <Square
                                    render={<span />}
                                    style={[
                                      styles.itemIconBadge,
                                      ICON_TONE_BY_CATEGORY[item.category],
                                    ]}
                                  >
                                    <NodeGlyph category={item.category} size={14} />
                                  </Square>
                                  <Text
                                    render={<span />}
                                    size="sm"
                                    weight={isActive ? "medium" : "normal"}
                                    truncate="true"
                                    style={styles.inheritColor}
                                  >
                                    {item.name}
                                  </Text>
                                </HStack>
                                {item.type === "folder" ? (
                                  <span {...stylex.props(styles.millerChevron)}>
                                    <ChevronRightIcon size={13} />
                                  </span>
                                ) : null}
                              </button>
                            );
                          })
                        )}
                      </VStack>
                    ))}
                  </HStack>
                ) : displayedItems.length === 0 ? (
                  <EmptyState.Root size="md">
                    <EmptyState.Content>
                      <EmptyState.Indicator palette={accentPalette}>
                        <EmptyState.Icon viewBox="0 0 24 24" fill="none">
                          <path
                            d="M3 7.5A2.5 2.5 0 0 1 5.5 5h4l2 2h7A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5v-9Z"
                            stroke="currentColor"
                            strokeWidth="1.6"
                            strokeLinejoin="round"
                          />
                        </EmptyState.Icon>
                      </EmptyState.Indicator>
                      <EmptyState.Title>
                        {trimmedQuery.length > 0 ? "No matching files" : "This folder is empty"}
                      </EmptyState.Title>
                      <EmptyState.Description>
                        {trimmedQuery.length > 0
                          ? `Nothing in ${workspaceName} matched "${searchQuery.trim()}". Try another keyword or clear your search.`
                          : "Create a folder or add a new document to start organizing assets here."}
                      </EmptyState.Description>
                      <EmptyState.Actions>
                        {trimmedQuery.length > 0 || smartFilter !== "all" ? (
                          <Button
                            variant="surface"
                            size="sm"
                            onClick={() => {
                              setSearchQuery("");
                              setSmartFilter("all");
                            }}
                          >
                            Reset view
                          </Button>
                        ) : (
                          <Button
                            variant="solid"
                            size="sm"
                            palette={accentPalette}
                            onClick={handleCreateFolder}
                          >
                            <PlusIcon />
                            New folder
                          </Button>
                        )}
                      </EmptyState.Actions>
                    </EmptyState.Content>
                  </EmptyState.Root>
                ) : viewMode === "grid" ? (
                  <Grid gap="3" role="list" aria-label="Files grid" style={styles.gridContainer}>
                    {displayedItems.map((item) => {
                      const isSelected = inspectedNode?.id === item.id;
                      const childCount = childCountByFolder.get(item.id) ?? 0;
                      return (
                        <VStack
                          key={item.id}
                          gap="0"
                          role="listitem"
                          tabIndex={0}
                          onClick={() => setSelectedId(item.id)}
                          onDoubleClick={() => handleOpenItem(item)}
                          onKeyDown={(e) => {
                            if (e.key === "Enter") {
                              handleOpenItem(item);
                            } else if (e.key === " ") {
                              e.preventDefault();
                              setSelectedId(item.id);
                            }
                          }}
                          style={[
                            styles.gridCard,
                            isSelected && styles.gridCardSelected,
                          ]}
                        >
                          <Center style={styles.gridThumb}>
                            {item.extension ? (
                              <span {...stylex.props(styles.gridThumbCornerStart)}>
                                <Badge
                                  variant="subtle"
                                  size="xs"
                                  palette={CATEGORY_PALETTES[item.category]}
                                >
                                  {item.extension}
                                </Badge>
                              </span>
                            ) : null}

                            <HStack gap="0.5" style={styles.gridThumbCornerEnd}>
                              <IconButton
                                variant="ghost"
                                size="xs"
                                aria-label={item.starred ? `Unstar ${item.name}` : `Star ${item.name}`}
                                style={[
                                  styles.starIconBtn,
                                  item.starred && styles.starIconBtnActive,
                                ]}
                                onClick={(e) => {
                                  e.stopPropagation();
                                  handleToggleStar(item);
                                }}
                              >
                                <StarIcon filled={item.starred} />
                              </IconButton>
                              {renderItemActionsMenu(item)}
                            </HStack>

                            <Square
                              render={<span />}
                              style={[
                                styles.previewGlyphWrap,
                                ICON_TONE_BY_CATEGORY[item.category],
                              ]}
                            >
                              <NodeGlyph category={item.category} size={26} />
                            </Square>
                          </Center>

                          <VStack gap="1.5" style={styles.gridBody}>
                            <Text render={<span />} size="sm" weight="medium" truncate="true" title={item.name}>
                              {item.name}
                            </Text>
                            <HStack gap="2" justify="between">
                              <Text render={<span />} size="xs" tone="muted" tabular="true">
                                {item.type === "folder"
                                  ? `${childCount} ${childCount === 1 ? "item" : "items"}`
                                  : item.sizeLabel}
                              </Text>
                              <Avatar.Root
                                size="2xs"
                                variant="subtle"
                                palette={OWNER_PALETTES[item.owner.paletteKey]}
                              >
                                <Avatar.Fallback>{item.owner.initials}</Avatar.Fallback>
                              </Avatar.Root>
                            </HStack>
                          </VStack>
                        </VStack>
                      );
                    })}
                  </Grid>
                ) : (
                  <div {...stylex.props(styles.tableWrap)}>
                    <Table.Root size="sm" variant="line">
                      <Table.Header>
                        <Table.Row style={styles.tableHeaderRow}>
                          <Table.ColumnHeader style={styles.tableTh}>Name</Table.ColumnHeader>
                          <Table.ColumnHeader
                            style={[styles.tableTh, styles.tableThResponsive]}
                          >
                            Owner
                          </Table.ColumnHeader>
                          <Table.ColumnHeader
                            style={[styles.tableTh, styles.tableThResponsive]}
                          >
                            Modified
                          </Table.ColumnHeader>
                          <Table.ColumnHeader
                            style={[styles.tableTh, styles.tableThAlignEnd]}
                          >
                            Size
                          </Table.ColumnHeader>
                          <Table.ColumnHeader
                            style={[styles.tableTh, styles.tableThAlignEnd]}
                            aria-label="Actions"
                          />
                        </Table.Row>
                      </Table.Header>
                      <Table.Body>
                        {displayedItems.map((item) => {
                          const isSelected = inspectedNode?.id === item.id;
                          const childCount = childCountByFolder.get(item.id) ?? 0;
                          const showLocationHint = trimmedQuery.length > 0 || smartFilter !== "all";
                          return (
                            <Table.Row
                              key={item.id}
                              aria-selected={isSelected}
                              onClick={() => setSelectedId(item.id)}
                              onDoubleClick={() => handleOpenItem(item)}
                              style={[
                                styles.tableRow,
                                isSelected && styles.tableRowSelected,
                              ]}
                            >
                              <Table.Cell style={styles.tableCell}>
                                <HStack gap="2.5">
                                  <Square
                                    render={<span />}
                                    style={[
                                      styles.itemIconBadge,
                                      ICON_TONE_BY_CATEGORY[item.category],
                                    ]}
                                  >
                                    <NodeGlyph category={item.category} size={15} />
                                  </Square>
                                  <VStack gap="0">
                                    <HStack gap="1.5">
                                      <Text render={<span />} size="sm" weight="medium" truncate="true">
                                        {item.name}
                                      </Text>
                                      {item.starred ? (
                                        <span
                                          {...stylex.props(styles.starMark)}
                                          aria-label="Starred"
                                        >
                                          <StarIcon filled />
                                        </span>
                                      ) : null}
                                      {item.tags[0] ? (
                                        <Badge variant="subtle" size="xs">
                                          {item.tags[0]}
                                        </Badge>
                                      ) : null}
                                    </HStack>
                                    {showLocationHint ? (
                                      <Text render={<span />} size="xs" tone="subtle" truncate="true">
                                        {getLocationPath(nodes, item, workspaceName)}
                                      </Text>
                                    ) : null}
                                  </VStack>
                                </HStack>
                              </Table.Cell>

                              <Table.Cell
                                style={[
                                  styles.tableCell,
                                  styles.tableCellResponsive,
                                  styles.tableCellMuted,
                                ]}
                              >
                                <HStack render={<span />} gap="2" style={styles.ownerCell}>
                                  <Avatar.Root
                                    size="2xs"
                                    variant="subtle"
                                    palette={OWNER_PALETTES[item.owner.paletteKey]}
                                  >
                                    <Avatar.Fallback>{item.owner.initials}</Avatar.Fallback>
                                  </Avatar.Root>
                                  <span>{item.owner.name}</span>
                                </HStack>
                              </Table.Cell>

                              <Table.Cell
                                style={[
                                  styles.tableCell,
                                  styles.tableCellResponsive,
                                  styles.tableCellMuted,
                                ]}
                              >
                                {item.modifiedAt}
                              </Table.Cell>

                              <Table.Cell style={[styles.tableCell, styles.tableCellSize]}>
                                {item.type === "folder"
                                  ? `${childCount} ${childCount === 1 ? "item" : "items"}`
                                  : item.sizeLabel}
                              </Table.Cell>

                              <Table.Cell style={[styles.tableCell, styles.tableCellActions]}>
                                {renderItemActionsMenu(item)}
                              </Table.Cell>
                            </Table.Row>
                          );
                        })}
                      </Table.Body>
                    </Table.Root>
                  </div>
                )}
              </div>
            </VStack>
          </Splitter.Panel>

          {/* Right Detail Inspector */}
          {showInspector ? (
            <>
              <Splitter.ResizeTrigger
                aria-label="Resize detail inspector"
                style={styles.inspectorHandle}
              />

              <Splitter.Panel style={styles.inspectorSplitterPanel}>
                <VStack render={<aside />} gap="0" aria-label="Item details" style={styles.inspector}>
                  <HStack gap="2" justify="between" style={styles.inspectorHeader}>
                    <Text render={<h2 />} size="sm" weight="semibold">
                      Details
                    </Text>
                    <IconButton
                      variant="ghost"
                      size="xs"
                      aria-label="Close inspector"
                      onClick={() => setShowInspector(false)}
                    >
                      <CloseIcon size={14} />
                    </IconButton>
                  </HStack>

                  {inspectedNode ? (
                    <VStack gap="4" style={styles.inspectorBody}>
                      <VStack gap="2.5" align="center" justify="center" style={styles.previewHero}>
                        <Square
                          render={<span />}
                          style={[
                            styles.previewGlyphWrap,
                            ICON_TONE_BY_CATEGORY[inspectedNode.category],
                          ]}
                        >
                          <NodeGlyph category={inspectedNode.category} size={28} />
                        </Square>
                        <Text render={<h3 />} size="sm" weight="semibold" style={styles.breakWord}>
                          {inspectedNode.name}
                        </Text>
                        <HStack gap="1.5" justify="center" wrap="wrap">
                          <Badge
                            variant="subtle"
                            size="sm"
                            palette={CATEGORY_PALETTES[inspectedNode.category]}
                          >
                            {inspectedNode.extension ?? "Folder"}
                          </Badge>
                          <Badge variant="outline" size="sm">
                            {inspectedNode.kindLabel}
                          </Badge>
                        </HStack>
                        <Text size="xs" tone="muted" align="center">
                          {inspectedNode.summary}
                        </Text>
                      </VStack>

                      <HStack gap="2">
                        <Button
                          variant="surface"
                          size="xs"
                          style={styles.inspectorActionBtn}
                          onClick={() => handleShare(inspectedNode)}
                        >
                          <ShareIcon />
                          Share
                        </Button>
                        <Button
                          variant="surface"
                          size="xs"
                          style={styles.inspectorActionBtn}
                          onClick={() => handleDownload(inspectedNode)}
                        >
                          <DownloadIcon />
                          Download
                        </Button>
                        <IconButton
                          variant="ghost"
                          size="xs"
                          aria-label={
                            inspectedNode.starred
                              ? `Remove star from ${inspectedNode.name}`
                              : `Star ${inspectedNode.name}`
                          }
                          style={[
                            styles.starIconBtn,
                            inspectedNode.starred && styles.starIconBtnActive,
                          ]}
                          onClick={() => handleToggleStar(inspectedNode)}
                        >
                          <StarIcon filled={inspectedNode.starred} />
                        </IconButton>
                      </HStack>

                      <Separator decorative />

                      <VStack render={<section />} gap="2.5">
                        <Text render={<h3 />} variant="overline" tone="subtle">
                          Information
                        </Text>
                        <DataList.Root
                          size="sm"
                          orientation="horizontal"
                          variant="subtle"
                          style={styles.dataListCompact}
                        >
                          <DataList.Item>
                            <DataList.ItemLabel>Size</DataList.ItemLabel>
                            <DataList.ItemValue>
                              <Text render={<span />} size="xs" style={styles.breakWord}>
                                {inspectedNode.type === "folder"
                                  ? `${childCountByFolder.get(inspectedNode.id) ?? 0} items · ${inspectedNode.sizeLabel}`
                                  : inspectedNode.sizeLabel}
                              </Text>
                            </DataList.ItemValue>
                          </DataList.Item>
                          <DataList.Item>
                            <DataList.ItemLabel>Location</DataList.ItemLabel>
                            <DataList.ItemValue>
                              <Text render={<span />} size="xs" style={styles.breakWord}>
                                {getLocationPath(nodes, inspectedNode, workspaceName)}
                              </Text>
                            </DataList.ItemValue>
                          </DataList.Item>
                          <DataList.Item>
                            <DataList.ItemLabel>Modified</DataList.ItemLabel>
                            <DataList.ItemValue>
                              <Text render={<span />} size="xs" style={styles.breakWord}>
                                {inspectedNode.modifiedAt}
                              </Text>
                            </DataList.ItemValue>
                          </DataList.Item>
                          <DataList.Item>
                            <DataList.ItemLabel>Created</DataList.ItemLabel>
                            <DataList.ItemValue>
                              <Text render={<span />} size="xs" style={styles.breakWord}>
                                {inspectedNode.createdAt}
                              </Text>
                            </DataList.ItemValue>
                          </DataList.Item>
                          <DataList.Item>
                            <DataList.ItemLabel>Access</DataList.ItemLabel>
                            <DataList.ItemValue>
                              <Text render={<span />} size="xs" style={styles.breakWord}>
                                {inspectedNode.access}
                              </Text>
                            </DataList.ItemValue>
                          </DataList.Item>
                        </DataList.Root>
                      </VStack>

                      <Separator decorative />

                      <VStack render={<section />} gap="2.5">
                        <Text render={<h3 />} variant="overline" tone="subtle">
                          Tags
                        </Text>
                        <HStack gap="1.5" wrap="wrap">
                          {inspectedNode.tags.map((tag) => (
                            <Badge key={tag} variant="subtle" size="sm">
                              {tag}
                            </Badge>
                          ))}
                          <Button
                            variant="ghost"
                            size="xs"
                            onClick={() => handleAddTag(inspectedNode)}
                          >
                            + Add tag
                          </Button>
                        </HStack>
                      </VStack>

                      <Separator decorative />

                      <VStack render={<section />} gap="2.5">
                        <Text render={<h3 />} variant="overline" tone="subtle">
                          Collaborators
                        </Text>
                        <VStack gap="2">
                          {inspectedNode.collaborators.map((person, index) => (
                            <HStack key={person.name} gap="2" justify="between">
                              <HStack gap="2">
                                <Avatar.Root
                                  size="xs"
                                  variant="subtle"
                                  palette={OWNER_PALETTES[person.paletteKey]}
                                >
                                  <Avatar.Fallback>{person.initials}</Avatar.Fallback>
                                </Avatar.Root>
                                <VStack gap="0">
                                  <Text size="xs" weight="medium">
                                    {person.name}
                                  </Text>
                                  <Text size="xs" tone="subtle">
                                    {person.role}
                                  </Text>
                                </VStack>
                              </HStack>
                              <Badge variant="outline" size="xs">
                                {index === 0 ? "Owner" : "Editor"}
                              </Badge>
                            </HStack>
                          ))}
                        </VStack>
                      </VStack>

                      <VStack render={<section />} gap="2.5">
                        <Text render={<h3 />} variant="overline" tone="subtle">
                          Latest activity
                        </Text>
                        <Text variant="mono" size="xs" tone="muted" style={styles.versionCard}>
                          {inspectedNode.versionNote}
                        </Text>
                      </VStack>
                    </VStack>
                  ) : (
                    <EmptyState.Root size="sm">
                      <EmptyState.Content>
                        <EmptyState.Title>No selection</EmptyState.Title>
                        <EmptyState.Description>
                          Select a file or folder to inspect its metadata and permissions.
                        </EmptyState.Description>
                      </EmptyState.Content>
                    </EmptyState.Root>
                  )}
                </VStack>
              </Splitter.Panel>
            </>
          ) : null}
        </Splitter.Root>
      </HStack>

      <Toaster toaster={queue} />
    </VStack>
  );
}
```

Credit: Inspired by [File Explorer](https://astryx.atmeta.com/playground?template=file-explorer) from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.)
