# Work orders

> A property-operations board where a reported leak becomes a work order: filed, assigned, scheduled and completed in one place.

A maintenance board with a sidebar, a list of requests grouped by priority and a detail pane. File a new request in a dialog (property, unit, category, priority, what is wrong) and it drops into its group, unassigned. Its title is one sentence, the problem in ink and where it stands in grey, and every step rewrites the grey half: assign it to a vendor and a work order opens with an estimate, schedule the visit, mark it completed and the actual cost appears. In the work orders view the rows glide from group to group as they move along, and each step says so in a toast.

A React component by Bruno Delorence: https://brunodelorence.com/components/work-orders. MIT License, Copyright (c) 2026 Bruno Delorence.

Category: Dashboards.

## Anatomy

1. **Board**: The whole app frame, 640 px tall, on a warm light grey. A container: its own width sets the layout, not the window’s.
2. **Sidebar**: The product’s sections, 172 px, with Operations current, the Dark theme switch and the signed-in person. Gone under 940 px of board.
3. **List**: Requests grouped by priority, or work orders grouped by where they stand, under a search field. The group holding the chosen row is lifted onto a card.
4. **Row**: An icon, the problem in ink, the property or the order number in grey, and the status word or the cost at the end. 30 px tall.
5. **Sentence title**: What is wrong, in ink, then where it is and where it stands, in grey: one sentence the board rewrites at each step.
6. **Primary action**: The next step, always first and always blue: Assign, Open work order, Schedule, Mark completed.
7. **Panel**: A grey tray with its title over a lighter card: Request (status, reporter, number), then the Work order once there is one.
8. **New request**: Opens the form in a modal inside the board.

## Properties

### Layout

1. **Side by side (default)**: From 640 px of board: list and detail together, and the sidebar from 940 px.
2. **Drill-in**: Under 640 px: one column. Choosing a row opens its detail; the back button returns to the list with the focus on that row.

There is no prop: the board reads its own width with a container query, so the same board works in a page column, a split view or a phone.

## When to use

- Operations work that moves through a few fixed steps, each one a decision someone takes: a maintenance request that is assigned, scheduled and completed.
- A queue people scan by urgency and then work through one item at a time, with the item’s state said in words next to the list.
- Intake that starts small (where, what kind, how urgent, what is wrong) and grows into a record with a vendor, a date and costs.
- A back office used on a phone as well as at a desk: under 640 px the list and the detail drill into each other.

## When not to use

- Free-form tasks with no fixed steps. Use a task list or a kanban board where people make their own columns.
- Hundreds of rows to compare by many fields at once. Use a data table with sorting and filters.
- A single form that ends when it is sent, as a public repair request from a tenant. Use a plain form page with a confirmation.
- Steps that need several people to sign off. The board gives each step one button; approvals want their own flow with who and when.

### The lifecycle

- **New**: filed through the form; Not assigned in red, and the one next step is Assign to the vendor for its category.
- **Assigned**: the work order opens with the vendor’s usual estimate, approved as it stands. The request shows it as a panel.
- **Scheduled**: a visit two days out. The row moves from To schedule to Scheduled.
- **Completed**: the actual cost shows, the row moves to Completed, and the toast says Work order completed.

### Motion

- **Rows glide** to their new group over 420 ms; a new request drops in with a blue tint that fades over 1.6 s.
- **The grey half of the title** blurs in over 420 ms when it is rewritten; the ink half stays put.
- **A beat of skeleton**, 320 ms, when a work order opens, as the page it stands for would load.
- **With reduced motion** none of these play: the state changes at once, and the demo does not run.

### Side by side and drill-in

**Side by side**
- From 640 px of board.
- The list stays in view while a step runs.

**Drill-in**
- Under 640 px.
- A back button names the list it returns to.

## Do’s and don’ts

- **Do**: Write the title as one sentence: the problem in ink, then where it is and where it stands in grey, rewritten at each step.
- **Don’t**: Stack the state into a row of capitalised badges. They are read as a list of codes, not as where the work stands.
- **Do**: Give each step one primary button, the next step, in the same place every time, so the focus stays on it as the step changes.
- **Caution**: Under 640 px the list and the detail take turns. Keep the board wider where people compare rows while they work on one.

## Content

The words are the request’s problem, its place, the status words, the step buttons and the toasts.

- **The problem in the reporter’s words**, sentence case, the first sentence of What is wrong, up to 80 characters: `Dishwasher leaking onto the floor`.
- **Buttons say the step and who**: `Assign to Ridgeline Plumbing`, `Schedule for Thu, Nov 5`, `Mark completed`.
- **Status words are short and the same everywhere**: `Not assigned`, `Assigned`, `Scheduled`, `In progress`, `Waiting`, `Completed`.
- **Toasts say what happened**, in the past tense, without a full stop: `Request MR-3820 created`, `Work order completed`.

## Installation

Install it with the shadcn CLI, into components/work-orders of any React project:

```sh
npx shadcn@latest add https://brunodelorence.com/r/work-orders.json
```

Or add the registry to components.json once, as a namespace that coding agents and the shadcn MCP server search by name:

```json
{
  "registries": {
    "@brunodelorence": "https://brunodelorence.com/r/{name}.json"
  }
}
```

```sh
npx shadcn@latest add @brunodelorence/work-orders
```

Or copy all the source files below into one folder of your project. Either way it needs React 19.2 and a bundler with CSS Modules (Next.js, Vite).

It has a dark colour scheme. Its colours are CSS light-dark() pairs, kept inside @supports so that builds which rewrite light-dark() for older browsers leave them alone: it follows your page’s color-scheme (light unless the page sets one) or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

## Usage

```tsx
'use client';

import { WorkOrders, type LifecycleEvent } from './work-orders';

export function MaintenanceBoard() {
  const log = (event: LifecycleEvent) => console.log(event.type, event.id);
  return <WorkOrders onLifecycle={log} autoplay={false} />;
}
```

## States

- **Browsing**: The board as it opens: fifteen requests across Urgent, High and Normal, the newest unassigned leak chosen.
- **New maintenance request**: The form filled in, the board behind it dimmed and inert.
- **New**: Filed just now: Not assigned in red in the list, Status New, and Assign to the vendor for its category as the next step.
- **Assigned**: The work order exists, with its vendor and estimate, and shows as a panel under the request.
- **Scheduled**: The work order’s own page: estimate and approved cost, the details, and Mark completed as the next step.
- **Completed**: The actual cost joins the cards, the row has moved to Completed, and the title says completed just now.
- **Dark**: With `colorScheme="dark"`: near-black board, graphite cards; the blue, the red and the orange are lifted to read on it.
- **390 px**: One column: the detail with a back button to the list.

## How it works

- One record per request carries the whole lifecycle: new until it is assigned, then assigned, scheduled, in progress or waiting, completed, with the work order (vendor, estimate, approved, actual cost, visit) inside it. The list, the detail and the toasts are all read from that one array.
- The title is two spans: the problem in ink and a status sentence in grey written from the record (“Ridgeline Plumbing at Alder Court · A-101, scheduled Thu, Nov 5.”). The grey span is keyed by its words, so a rewrite mounts it again and it blurs in from 4 px over 420 ms.
- Rows that change group glide there with FLIP: after each change, every row’s top is measured in the list’s own px (scroll and any scale of the board taken out) and compared with the last one; a row that moved is played from its old place to its new one with the Web Animations API, 420 ms on cubic-bezier(0.2, 0.7, 0.2, 1).
- A new request drops into its priority group with a blue tint that fades over 1.6 s; the group holding the chosen row is lifted onto a card; a work order panel and the actual cost card rise 6 px as they fade in over 320 ms; opening a work order shows 320 ms of skeleton.
- The dialog is a modal inside the board, not over the page: the board behind it is inert, Tab loops round the form, Escape or the scrim closes it and the focus goes back to the button that opened it. An empty What is wrong keeps it open and marks the field.
- The layout answers to the board’s own width with container queries: 172 px sidebar, 284 px list and the detail from 940 px; no sidebar below that; one column under 640 px, where choosing a row drills into it and a back button returns to the list.
- While on screen and untouched, a demo pointer files the dishwasher leak (typing the unit and the problem), assigns it, opens its work order, schedules it and marks it completed, then starts over; any input from the reader stops it.
- Every colour is a token on the root, light-dark() where the schemes differ: at night the board is near-black with graphite cards, the blue, red and orange lifted to keep their contrast. The sidebar’s Dark theme switch flips the board on its own.

## API reference

- **defaultState** (`'browse' | 'dialog' | 'new' | 'assigned' | 'scheduled' | 'completed'`, default `'browse'`): Where the board starts: browsing, with the New request form open, or with the dishwasher leak filed and at one of its steps. A still for docs and screenshots; anything but browse turns the demo off.
- **onLifecycle** (`(event: LifecycleEvent) => void`): Called after each step the reader takes, with its type (created, updated, assigned, scheduled, completed) and the request’s number.
- **autoplay** (`boolean`, default `true`): While on screen and untouched, a demo pointer takes a leak from report to completed. Never under reduced motion; the first real input stops it.
- **colorScheme** (`'light' | 'dark' | 'system'`): Light or dark colours, or the reader’s; without it, the page’s color-scheme.
- **className** (`string`): A class for the board.

## Accessibility

### Keyboard

- The list is one tab stop: Up and Down, Home and End move between rows across the groups, Enter opens one.
- New request opens the form with the focus on Property; Tab and Shift+Tab go round the form; Escape or Cancel closes it and the focus goes back to the button that opened it.
- Sending an empty What is wrong keeps the form open, marks the field invalid and puts the focus on it with the message under it.
- After a step the focus stays on the primary button, which now offers the next step; opening a request or a work order moves the focus to its title.

### Screen readers

- The form is a `dialog` with `aria-modal`, named by its title; the board behind it is `inert`.
- Each step is announced in a polite live region, with the same words as its toast (“Assigned to Ridgeline Plumbing”); the toasts themselves are hidden from screen readers so it is said once.
- The chosen row has `aria-current`; the facts are a description list; the view switch is two buttons with `aria-pressed`.

### Colour and contrast

Not assigned is said in words as well as in red, and the alert dots sit beside words. Small grey text is at least 4.5 : 1 on the board and the cards in both schemes; the grey half of the title is large text at 3 : 1 or more. White on the primary blue is above 4.5 : 1.

### In this build

- The list is one Tab stop: Up, Down, Home and End move through the rows across groups, Enter opens one; the chosen row has aria-current.
- New request opens a dialog (role="dialog", aria-modal, named by its title) with the focus on its first field; the board behind is inert, Tab loops inside, Escape closes, and the focus returns to the opener.
- An empty What is wrong is marked aria-invalid, described by its message, and focused.
- Each step is announced in a polite live region with the words of its toast; the toasts are hidden from screen readers so nothing is read twice.
- After a step the focus stays on the primary button, which now offers the next step; opening a request or a work order, or drilling in on a narrow board, moves the focus to its title.
- Status is said in words, never by colour alone; small text is at least 4.5 : 1 in both schemes. With reduced motion the glides, blurs, tints and skeleton are dropped and the demo does not play.

## Source

### work-orders/work-orders.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useEffectEvent,
  useLayoutEffect,
  useRef,
  useState,
  type KeyboardEvent as ReactKeyboardEvent,
  type ReactNode,
} from 'react';
import {
  ORDER_GROUPS,
  PRIORITIES,
  REQUEST_WORD,
  SEED,
  STAGE_WORD,
  USER,
  VENDORS,
  money,
  nextId,
  orderStatus,
  requestStatus,
  titleFrom,
  visitDate,
  type Request,
  type Stage,
} from './data';
import { DemoPointer, runDemo, type Point } from './demo-pointer';
import { Glyph, type GlyphName } from './glyphs';
import { EMPTY_DRAFT, RequestDialog, type Draft } from './request-dialog';
import { useAutoplay } from './use-autoplay';
import styles from './work-orders.module.css';

/*
 * Work orders: a property-operations board where a reported leak becomes a work order and is seen
 * through to done. A sidebar, a list and a detail pane.
 *
 * - The list shows requests grouped by priority (Urgent, High, Normal), or work orders grouped by
 *   where they stand (Past schedule, To schedule, Scheduled, In progress, Waiting, Completed). When
 *   a step moves a row to another group, it glides there (FLIP, played with the Web Animations
 *   API); a new request drops into its group with a short tint.
 * - The detail's title is one sentence: what is wrong, in ink, then where it is and where it
 *   stands, in grey. Each step rewrites the grey half, which blurs in over the old.
 * - The lifecycle is one record: New → Assigned (the work order opens, with a vendor and an
 *   estimate) → Scheduled → Completed (the actual cost shows). Every step is a button, and says
 *   so in a toast and in a polite live region.
 * - New request opens a modal form inside the board: the rest is inert, Tab goes round the form,
 *   Escape closes it, and the focus comes back where it was.
 * - Under 640 px of board the list and the detail are one column: choosing a row drills into it,
 *   and a back button returns to the list.
 * - While on screen and untouched, a demo pointer files the dishwasher leak, assigns it, opens its
 *   work order, schedules it and marks it completed, then starts over. Any input stops it.
 */

export type WorkOrdersState = 'browse' | 'dialog' | 'new' | 'assigned' | 'scheduled' | 'completed';

export type LifecycleEvent = {
  type: 'created' | 'updated' | 'assigned' | 'scheduled' | 'completed';
  /** The request's number: MR-3820. */
  id: string;
};

type View = 'requests' | 'orders';
type Toast = { id: number; text: string };
type DialogState = { mode: 'new' | 'edit'; draft: Draft; focus: boolean } | null;
type Board = {
  requests: Request[];
  view: View;
  selected: string;
  detail: View;
  pane: 'list' | 'detail';
};

/** The request the demo files, and the docs' stills show at each step. */
const LEAK = 'Dishwasher leaking onto the floor';
const leak = (stage: Stage): Request => {
  const { vendor, estimate } = VENDORS.Plumbing;
  return {
    id: nextId(
      'MR',
      SEED.map((r) => r.id),
    ),
    title: LEAK,
    property: 'Alder Court',
    unit: 'A-101',
    category: 'Plumbing',
    priority: 'high',
    stage,
    reporter: USER.name,
    reported: 'just now',
    order:
      stage === 'new'
        ? undefined
        : {
            id: nextId(
              'WO',
              SEED.flatMap((r) => (r.order ? [r.order.id] : [])),
            ),
            vendor,
            estimate,
            approved: estimate,
            assigned: 'Just now',
            when: stage === 'assigned' ? undefined : 'Thursday',
            actual: stage === 'completed' ? estimate : undefined,
            done: stage === 'completed' ? 'just now' : undefined,
          },
  };
};

function initialBoard(state: WorkOrdersState): Board {
  if (state === 'browse' || state === 'dialog')
    return {
      requests: SEED,
      view: 'requests',
      selected: SEED[0].id,
      detail: 'requests',
      pane: 'list',
    };
  const request = leak(state);
  const order = state === 'scheduled' || state === 'completed';
  return {
    requests: [request, ...SEED],
    view: order ? 'orders' : 'requests',
    selected: request.id,
    detail: order ? 'orders' : 'requests',
    pane: 'detail',
  };
}

const PRIORITY_LABEL = Object.fromEntries(PRIORITIES.map((p) => [p.id, p.label]));

/** The rows of a view, in their groups. */
function groupsOf(requests: Request[], view: View, query: string) {
  const q = query.trim().toLowerCase();
  const shown = q
    ? requests.filter((r) =>
        [r.title, r.property, r.unit, r.id, r.order?.id, r.order?.vendor]
          .join(' ')
          .toLowerCase()
          .includes(q),
      )
    : requests;
  if (view === 'requests')
    return PRIORITIES.map((p) => ({
      id: p.id,
      label: p.label,
      alert: p.id === 'urgent',
      rows: shown.filter((r) => r.priority === p.id),
    })).filter((group) => group.rows.length > 0);
  return ORDER_GROUPS.map((g) => ({
    id: g.id,
    label: g.label,
    alert: !!g.alert,
    rows: shown.filter((r) => r.order && g.holds(r)),
  })).filter((group) => group.rows.length > 0);
}

/** Easing of every glide on the board: quick out, long settle. */
const GLIDE = 'cubic-bezier(0.2, 0.7, 0.2, 1)';

export function WorkOrders({
  defaultState = 'browse',
  onLifecycle,
  autoplay = true,
  colorScheme,
  className = '',
}: {
  /**
   * Where the board starts: browsing the seed requests, with the New request form open, or with
   * the dishwasher leak filed and at one of its steps. A still for docs and screenshots; anything
   * but browse turns the demo off.
   */
  defaultState?: WorkOrdersState;
  /** Called after each step the reader takes: a request created or updated, assigned, scheduled, completed. */
  onLifecycle?: (event: LifecycleEvent) => void;
  /** While on screen and untouched, a demo pointer takes a leak from report to completed. */
  autoplay?: boolean;
  /** Light or dark colours, or the reader's ('system'); without it, the page's color-scheme. */
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  const { ref: root, playing, take } = useAutoplay<HTMLDivElement>();
  const [board, setBoard] = useState<Board>(() => initialBoard(defaultState));
  const [query, setQuery] = useState('');
  const [dialog, setDialog] = useState<DialogState>(() =>
    defaultState === 'dialog'
      ? {
          mode: 'new',
          draft: { ...EMPTY_DRAFT, unit: 'A-101', priority: 'high', text: `${LEAK}.` },
          focus: false,
        }
      : null,
  );
  const [toasts, setToasts] = useState<Toast[]>([]);
  const [message, setMessage] = useState('');
  const [loading, setLoading] = useState(false);
  const [fresh, setFresh] = useState<string | null>(null);
  /** The sidebar's Dark theme switch, over the colorScheme prop. */
  const [scheme, setScheme] = useState<'light' | 'dark' | null>(null);
  const [dark, setDark] = useState(false);

  const list = useRef<HTMLDivElement>(null);
  const heading = useRef<HTMLHeadingElement>(null);
  const probe = useRef<HTMLSpanElement>(null);
  const pointer = useRef<HTMLSpanElement>(null);
  const opener = useRef<HTMLElement | null>(null);
  const focusNext = useRef<'heading' | 'row' | null>(null);
  const places = useRef(new Map<string, number>());
  const placesView = useRef<View>(board.view);
  const toastId = useRef(0);
  const timers = useRef(new Set<number>());

  const { requests, view, selected, detail, pane } = board;
  const current = requests.find((r) => r.id === selected) ?? requests[0];
  const groups = groupsOf(requests, view, query);
  const rows = groups.flatMap((group) => group.rows);

  const later = (fn: () => void, ms: number) => {
    const timer = window.setTimeout(() => {
      timers.current.delete(timer);
      fn();
    }, ms);
    timers.current.add(timer);
  };
  useEffect(() => {
    const pending = timers.current;
    return () => pending.forEach((timer) => window.clearTimeout(timer));
  }, []);

  const reduced = () =>
    typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;

  /** A toast, and the same words in the live region (repeats made to differ, so they're read). */
  const say = (text: string) => {
    const id = (toastId.current += 1);
    setToasts((now) => [...now.slice(-2), { id, text }]);
    setMessage((now) => (now === text ? `${text} ` : text));
    later(() => setToasts((now) => now.filter((toast) => toast.id !== id)), 3200);
  };

  const narrow = () => (root.current?.offsetWidth ?? 1000) < 640;

  const update = (id: string, change: (r: Request) => Request) =>
    setBoard((b) => ({ ...b, requests: b.requests.map((r) => (r.id === id ? change(r) : r)) }));

  // The steps of the lifecycle. `reader` steps move the focus; the demo's never do.
  const select = (id: string, by: 'reader' | 'demo' = 'reader') => {
    setBoard((b) => ({ ...b, selected: id, detail: b.view, pane: 'detail' }));
    if (by === 'reader' && narrow()) focusNext.current = 'heading';
  };

  const switchView = (next: View) => {
    setBoard((b) => {
      const keep = next === 'requests' || b.requests.find((r) => r.id === b.selected)?.order;
      const first = groupsOf(b.requests, next, '').flatMap((g) => g.rows)[0];
      return {
        ...b,
        view: next,
        detail: next,
        selected: keep ? b.selected : (first?.id ?? b.selected),
      };
    });
  };

  const openDialog = (mode: 'new' | 'edit', by: 'reader' | 'demo' = 'reader') => {
    opener.current = by === 'reader' ? (document.activeElement as HTMLElement | null) : null;
    const draft: Draft =
      mode === 'edit'
        ? {
            property: current.property,
            unit: current.unit,
            category: current.category,
            priority: current.priority,
            text: `${current.title}.`,
          }
        : EMPTY_DRAFT;
    setDialog({ mode, draft, focus: by === 'reader' });
  };

  const closeDialog = () => {
    setDialog(null);
    const back = opener.current;
    opener.current = null;
    if (back?.isConnected) requestAnimationFrame(() => back.focus({ preventScroll: true }));
  };

  const submitDialog = (by: 'reader' | 'demo' = 'reader') => {
    if (!dialog) return;
    const { draft, mode } = dialog;
    const fields = {
      title: titleFrom(draft.text),
      property: draft.property,
      unit: draft.unit.trim(),
      category: draft.category,
      priority: draft.priority,
    };
    if (mode === 'edit') {
      update(current.id, (r) => ({ ...r, ...fields }));
      say('Request updated');
      onLifecycle?.({ type: 'updated', id: current.id });
    } else {
      const id = nextId(
        'MR',
        requests.map((r) => r.id),
      );
      const created: Request = {
        id,
        ...fields,
        stage: 'new',
        reporter: USER.name,
        reported: 'just now',
      };
      setQuery('');
      setBoard((b) => ({
        ...b,
        requests: [created, ...b.requests],
        view: 'requests',
        detail: 'requests',
        selected: id,
        pane: 'detail',
      }));
      setFresh(id);
      later(() => setFresh((now) => (now === id ? null : now)), 1600);
      say(`Request ${id} created`);
      onLifecycle?.({ type: 'created', id });
    }
    setDialog(null);
    opener.current = null;
    if (by === 'reader') focusNext.current = 'heading';
  };

  const assign = (id: string) => {
    const request = requests.find((r) => r.id === id);
    if (!request || request.order) return;
    const { vendor, estimate } = VENDORS[request.category];
    const orderId = nextId(
      'WO',
      requests.flatMap((r) => (r.order ? [r.order.id] : [])),
    );
    update(id, (r) => ({
      ...r,
      stage: 'assigned',
      order: { id: orderId, vendor, estimate, approved: estimate, assigned: 'Just now' },
    }));
    say(`Assigned to ${vendor}`);
    onLifecycle?.({ type: 'assigned', id });
  };

  const openOrder = (id: string, by: 'reader' | 'demo' = 'reader') => {
    setBoard((b) => ({ ...b, view: 'orders', detail: 'orders', selected: id, pane: 'detail' }));
    // A beat of skeleton while the order "loads", as the page it stands for would.
    if (!reduced()) {
      setLoading(true);
      later(() => setLoading(false), 320);
    }
    if (by === 'reader') focusNext.current = 'heading';
  };

  const openRequest = (id: string, by: 'reader' | 'demo' = 'reader') => {
    setBoard((b) => ({ ...b, view: 'requests', detail: 'requests', selected: id, pane: 'detail' }));
    if (by === 'reader') focusNext.current = 'heading';
  };

  const schedule = (id: string) => {
    const when = visitDate();
    update(id, (r) =>
      r.order ? { ...r, stage: 'scheduled', order: { ...r.order, when, late: false } } : r,
    );
    say(`Scheduled for ${when}`);
    onLifecycle?.({ type: 'scheduled', id });
  };

  const complete = (id: string) => {
    update(id, (r) =>
      r.order
        ? {
            ...r,
            stage: 'completed',
            order: { ...r.order, actual: r.order.approved, done: 'just now' },
          }
        : r,
    );
    say('Work order completed');
    onLifecycle?.({ type: 'completed', id });
  };

  const back = () => {
    setBoard((b) => ({ ...b, pane: 'list' }));
    focusNext.current = 'row';
  };

  // The focus a reader's step asked for, once the new detail or list is on screen.
  useEffect(() => {
    if (loading || !focusNext.current) return;
    const target = focusNext.current;
    focusNext.current = null;
    if (target === 'heading') heading.current?.focus({ preventScroll: true });
    else
      list.current
        ?.querySelector<HTMLElement>('[data-row][tabindex="0"]')
        ?.focus({ preventScroll: true });
  });

  // FLIP: a row whose place changed glides from where it was. Places are kept per view, in the
  // list's own px from the top of its content, so scrolling between steps doesn't count as a move.
  useLayoutEffect(() => {
    const box = list.current;
    if (!box) return;
    const frame = box.getBoundingClientRect();
    const scale = frame.height / box.offsetHeight || 1;
    const sameView = placesView.current === view;
    placesView.current = view;
    const still = reduced();
    const next = new Map<string, number>();
    box.querySelectorAll<HTMLElement>('[data-row]').forEach((row) => {
      const key = row.dataset.row ?? '';
      const top = (row.getBoundingClientRect().top - frame.top) / scale + box.scrollTop;
      next.set(key, top);
      const before = places.current.get(key);
      if (!sameView || still || before === undefined || Math.abs(before - top) < 1) return;
      row.animate([{ transform: `translateY(${before - top}px)` }, { transform: 'none' }], {
        duration: 420,
        easing: GLIDE,
      });
    });
    places.current = next;
  }, [requests, view, query]);

  // Which scheme the board is drawn in, read from a probe coloured with light-dark().
  useEffect(() => {
    const read = () => {
      const colour = probe.current ? getComputedStyle(probe.current).color : '';
      setDark(colour === 'rgb(255, 255, 255)');
    };
    read();
    const media = window.matchMedia('(prefers-color-scheme: dark)');
    media.addEventListener('change', read);
    const observer = new MutationObserver(read);
    observer.observe(document.documentElement, { attributes: true });
    return () => {
      media.removeEventListener('change', read);
      observer.disconnect();
    };
  }, [scheme, colorScheme]);

  // Up and Down (and Home, End) move through the rows; only one row is a tab stop.
  const onListKey = (event: ReactKeyboardEvent) => {
    const all = [...(list.current?.querySelectorAll<HTMLElement>('[data-row]') ?? [])];
    const at = all.indexOf(document.activeElement as HTMLElement);
    if (at < 0) return;
    const to =
      event.key === 'ArrowDown'
        ? Math.min(at + 1, all.length - 1)
        : event.key === 'ArrowUp'
          ? Math.max(at - 1, 0)
          : event.key === 'Home'
            ? 0
            : event.key === 'End'
              ? all.length - 1
              : null;
    if (to === null) return;
    event.preventDefault();
    all[to].focus();
    all[to].scrollIntoView({ block: 'nearest' });
  };

  // The demo: the pointer files the dishwasher leak and takes it all the way to completed.
  const demoAct = useEffectEvent(
    (
      act:
        | { open: true }
        | { draft: Partial<Draft> }
        | { submit: true }
        | { assign: true }
        | { order: true }
        | { schedule: true }
        | { complete: true }
        | { reset: true },
    ) => {
      if ('open' in act) openDialog('new', 'demo');
      else if ('draft' in act)
        setDialog((d) => (d ? { ...d, draft: { ...d.draft, ...act.draft } } : d));
      else if ('submit' in act) submitDialog('demo');
      else if ('assign' in act) assign(current.id);
      else if ('order' in act) openOrder(current.id, 'demo');
      else if ('schedule' in act) schedule(current.id);
      else if ('complete' in act) complete(current.id);
      else {
        setDialog(null);
        setQuery('');
        setBoard(initialBoard('browse'));
      }
    },
  );
  const demo = autoplay && defaultState === 'browse' && playing;
  useEffect(() => {
    const stage = root.current;
    const arrow = pointer.current;
    if (!demo || !stage || !arrow) return;
    const stop = runDemo(stage, arrow, async ({ wait, glide, glyph }) => {
      /** The middle of the visible control marked data-demo=`name`, in the stage's px. */
      const spot = (name: string): Point | null => {
        const element = [...stage.querySelectorAll<HTMLElement>(`[data-demo="${name}"]`)].find(
          (e) => e.getClientRects().length > 0,
        );
        if (!element) return null;
        const frame = stage.getBoundingClientRect();
        const scale = frame.width / stage.offsetWidth || 1;
        const rect = element.getBoundingClientRect();
        return {
          x: (rect.left + Math.min(rect.width / 2, 60) - frame.left) / scale,
          y: (rect.top + rect.height / 2 - frame.top) / scale,
        };
      };
      const go = async (name: string, ms: number, hand = true) => {
        const to = spot(name);
        if (!to) return;
        glyph('arrow');
        await glide(to, ms);
        if (hand) glyph('hand');
      };
      const press = async (name: string) => {
        const element = [...stage.querySelectorAll<HTMLElement>(`[data-demo="${name}"]`)].find(
          (e) => e.getClientRects().length > 0,
        );
        element?.setAttribute('data-pressed', '');
        await wait(140);
        element?.removeAttribute('data-pressed');
      };
      const type = async (field: 'unit' | 'text', text: string, ms: number) => {
        for (let i = 1; i <= text.length; i += 1) {
          demoAct({ draft: { [field]: text.slice(0, i) } });
          await wait(ms);
        }
      };
      await wait(600);
      for (;;) {
        await wait(900);
        await go('new', 800);
        await press('new');
        demoAct({ open: true });
        await wait(700);
        await go('unit', 650, false);
        await press('unit');
        await type('unit', 'A-101', 120);
        await wait(300);
        await go('priority', 520);
        await press('priority');
        demoAct({ draft: { priority: 'high' } });
        await wait(520);
        await go('text', 520, false);
        await press('text');
        await type('text', `${LEAK}.`, 42);
        await wait(500);
        await go('create', 620);
        await press('create');
        demoAct({ submit: true });
        await wait(1500);
        await go('primary', 700);
        await wait(250);
        await press('primary');
        demoAct({ assign: true });
        await wait(1600);
        await go('order-row', 700);
        await press('order-row');
        demoAct({ order: true });
        await wait(1500);
        await go('primary', 650);
        await wait(250);
        await press('primary');
        demoAct({ schedule: true });
        await wait(1800);
        await go('primary', 450);
        await wait(250);
        await press('primary');
        demoAct({ complete: true });
        await wait(2800);
        glyph('arrow');
        await glide({ x: stage.offsetWidth * 0.82, y: stage.offsetHeight * 0.55 }, 700);
        await wait(700);
        demoAct({ reset: true });
      }
    });
    return () => {
      stop();
    };
  }, [demo, root]);

  const groupWithSelection = groups.find((g) => g.rows.some((r) => r.id === selected))?.id;
  const rovingId = rows.some((r) => r.id === selected) ? selected : rows[0]?.id;
  const isOrder = detail === 'orders' && !!current.order;
  const viewName = view === 'requests' ? 'Requests' : 'Work orders';

  const newButton = (where: 'wide' | 'narrow') => (
    <button
      type="button"
      className={`${styles.button} ${where === 'wide' ? styles.newWide : styles.newNarrow}`}
      data-tone="primary"
      data-demo="new"
      data-part={where === 'wide' ? 'new' : undefined}
      onClick={() => openDialog('new')}
      aria-label={where === 'narrow' ? 'New request' : undefined}
    >
      <Glyph name="plus" className={styles.glyph} />
      <span className={where === 'narrow' ? styles.short : undefined}>
        {where === 'wide' ? 'New request' : 'New'}
      </span>
    </button>
  );

  return (
    <div
      ref={root}
      className={`${styles.root} ${className}`}
      data-part="stage"
      data-color-scheme={scheme ?? colorScheme}
      onPointerDownCapture={take}
      onKeyDownCapture={take}
      onPointerMove={(event) => {
        if (event.pointerType !== 'touch') take();
      }}
    >
      <span ref={probe} className={styles.probe} aria-hidden="true" />
      <div className={styles.shell} data-pane={pane} inert={dialog !== null}>
        <aside className={styles.sidebar} data-part="sidebar">
          <div className={styles.brand} aria-hidden="true">
            <Glyph name="mark" className={styles.brandMark} />
            Keystead
          </div>
          <ul className={styles.nav} aria-label="Sections">
            {(
              [
                ['search', 'Search'],
                ['home', 'Home'],
                null,
                ['layers', 'Portfolio'],
                ['key', 'Leasing'],
                ['people', 'Residents'],
                ['coin', 'Financial'],
                ['wrench', 'Operations'],
                ['building', 'Owners'],
                null,
                ['chart', 'Reports'],
                ['bell', 'Notifications'],
              ] as ([GlyphName, string] | null)[]
            ).map((item, index) =>
              item ? (
                <li
                  key={item[1]}
                  className={styles.navItem}
                  aria-current={item[1] === 'Operations' ? 'page' : undefined}
                >
                  <Glyph name={item[0]} className={styles.glyph} />
                  {item[1]}
                </li>
              ) : (
                <li key={index} className={styles.navGap} aria-hidden="true" />
              ),
            )}
          </ul>
          <button
            type="button"
            className={styles.themeSwitch}
            aria-pressed={dark}
            onClick={() => setScheme(dark ? 'light' : 'dark')}
          >
            <Glyph name="moon" className={styles.glyph} />
            Dark theme
          </button>
          <div className={styles.user}>
            <span className={styles.avatar} aria-hidden="true">
              {USER.initials}
            </span>
            <span>
              <span className={styles.userName}>{USER.name}</span>
              <span className={styles.userRole}>{USER.role}</span>
            </span>
          </div>
        </aside>

        <section className={styles.listPane} aria-label={viewName} data-part="list">
          <header className={styles.paneHead}>
            <h3 className={styles.paneTitle}>Operations</h3>
            <div className={styles.switch} role="group" aria-label="Show">
              {(['requests', 'orders'] as View[]).map((v) => (
                <button
                  key={v}
                  type="button"
                  aria-pressed={view === v}
                  onClick={() => switchView(v)}
                >
                  {v === 'requests' ? 'Requests' : 'Work orders'}
                </button>
              ))}
            </div>
            {newButton('narrow')}
          </header>
          <div className={styles.search}>
            <Glyph name="search" className={styles.glyph} />
            <input
              type="search"
              placeholder={view === 'requests' ? 'Search requests' : 'Search work orders'}
              aria-label={view === 'requests' ? 'Search requests' : 'Search work orders'}
              value={query}
              onChange={(event) => setQuery(event.target.value)}
            />
          </div>
          {/* The arrow keys of the rows, caught where they bubble: each row is its own button. */}
          {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
          <div ref={list} className={styles.list} onKeyDown={onListKey}>
            {groups.length === 0 && <p className={styles.empty}>Nothing matches “{query}”.</p>}
            {groups.map((group) => (
              <div
                key={`${view}-${group.id}`}
                className={styles.group}
                data-active={group.id === groupWithSelection}
                data-part="group"
              >
                <h4 className={styles.groupLabel} data-alert={group.alert}>
                  <span className={styles.groupDot} aria-hidden="true" />
                  {group.label}
                </h4>
                <ul className={styles.rows}>
                  {group.rows.map((r) => (
                    <li key={r.id}>
                      <button
                        type="button"
                        className={styles.row}
                        data-row={`${view}:${r.id}`}
                        data-fresh={fresh === r.id || undefined}
                        data-part="row"
                        aria-current={r.id === selected ? 'true' : undefined}
                        tabIndex={r.id === rovingId ? 0 : -1}
                        onClick={() => select(r.id)}
                      >
                        <Glyph
                          name={view === 'requests' ? 'wrench' : 'hammer'}
                          className={styles.rowIcon}
                        />
                        <span className={styles.rowText}>
                          <span className={styles.rowTitle}>{r.title}</span>{' '}
                          <span
                            className={styles.rowMeta}
                            data-mono={view === 'orders' || undefined}
                          >
                            {view === 'requests' ? r.property : r.order?.id}
                          </span>
                        </span>
                        {view === 'requests' ? (
                          <span className={styles.rowStatus} data-stage={r.stage}>
                            {STAGE_WORD[r.stage]}
                            {r.stage === 'new' && (
                              <span className={styles.alertDot} aria-hidden="true" />
                            )}
                          </span>
                        ) : r.order?.late ? (
                          <span className={styles.rowStatus} data-late>
                            {r.order.vendor}
                            <span className={styles.alertDot} aria-hidden="true" />
                          </span>
                        ) : (
                          <span className={styles.rowStatus}>
                            {r.stage === 'waiting' && r.order?.parts
                              ? 'Parts'
                              : money(r.order?.estimate ?? 0)}
                          </span>
                        )}
                      </button>
                    </li>
                  ))}
                </ul>
              </div>
            ))}
          </div>
        </section>

        <section
          className={styles.detailPane}
          aria-label={isOrder ? 'Work order' : 'Request'}
          data-part="detail"
        >
          <header className={styles.paneHead}>
            <button type="button" className={styles.back} onClick={back}>
              <Glyph name="back" className={styles.glyph} />
              {viewName}
            </button>
            <span className={styles.paneTitle}>{isOrder ? 'Work order' : 'Request'}</span>
            {newButton('wide')}
          </header>
          <div className={styles.detailScroll}>
            {loading ? (
              <div className={styles.skeleton} aria-hidden="true">
                <span />
                <span />
                <span />
              </div>
            ) : (
              <div key={`${detail}-${current.id}`} className={styles.detailBody}>
                <p className={styles.eyebrow}>
                  <span className={styles.chip} aria-hidden="true">
                    <Glyph name={isOrder ? 'hammer' : 'wrench'} className={styles.glyph} />
                  </span>
                  {isOrder && current.order ? (
                    <span data-mono>
                      {current.order.id} · {STAGE_WORD[current.stage]}
                    </span>
                  ) : (
                    `${current.category} · ${PRIORITY_LABEL[current.priority]}`
                  )}
                </p>
                <h2 ref={heading} className={styles.title} tabIndex={-1} data-part="title">
                  <span className={styles.titleInk}>{current.title}.</span>{' '}
                  <span
                    key={isOrder ? orderStatus(current) : requestStatus(current)}
                    className={styles.titleState}
                    data-part="title-state"
                  >
                    {isOrder ? orderStatus(current) : requestStatus(current)}
                  </span>
                </h2>
                {isOrder ? (
                  <OrderDetail
                    request={current}
                    onSchedule={() => schedule(current.id)}
                    onComplete={() => complete(current.id)}
                    onRequest={() => openRequest(current.id)}
                  />
                ) : (
                  <RequestDetail
                    request={current}
                    onAssign={() => assign(current.id)}
                    onOrder={() => openOrder(current.id)}
                    onEdit={() => openDialog('edit')}
                  />
                )}
              </div>
            )}
          </div>
        </section>
      </div>

      {dialog && (
        <RequestDialog
          mode={dialog.mode}
          draft={dialog.draft}
          focusOnOpen={dialog.focus}
          onDraft={(draft) => setDialog((d) => (d ? { ...d, draft } : d))}
          onSubmit={() => submitDialog()}
          onClose={closeDialog}
        />
      )}

      <ol className={styles.toasts} aria-hidden="true" data-part="toasts">
        {toasts.map((toast) => (
          <li key={toast.id} className={styles.toast}>
            <Glyph name="check" className={styles.glyph} />
            {toast.text}
          </li>
        ))}
      </ol>
      <p className={styles.hidden} aria-live="polite">
        {message}
      </p>
      <div className={styles.pointerLayer} aria-hidden="true">
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
    </div>
  );
}

/** A grey panel with a title over a lighter card: Request, Work order, Details. */
function Panel({ title, children, part }: { title: string; children: ReactNode; part: string }) {
  return (
    <section className={styles.panel} data-part={part} aria-label={title}>
      <h3 className={styles.panelTitle}>{title}</h3>
      <div className={styles.card}>{children}</div>
    </section>
  );
}

function Facts({ items }: { items: [string, ReactNode, string?][] }) {
  return (
    <dl className={styles.facts}>
      {items.map(([term, value, tone]) => (
        <div key={term}>
          <dt>{term}</dt>
          <dd data-tone={tone}>{value}</dd>
        </div>
      ))}
    </dl>
  );
}

function RequestDetail({
  request,
  onAssign,
  onOrder,
  onEdit,
}: {
  request: Request;
  onAssign: () => void;
  onOrder: () => void;
  onEdit: () => void;
}) {
  const order = request.order;
  return (
    <>
      <div className={styles.actions} data-part="actions">
        {/* One primary button, always in the same place and keyed the same, so the focus stays
            on it when a step changes what it does. */}
        <button
          key="primary"
          type="button"
          className={styles.button}
          data-tone="primary"
          data-demo="primary"
          data-part="primary"
          onClick={order ? onOrder : onAssign}
        >
          {order ? 'Open work order' : `Assign to ${VENDORS[request.category].vendor}`}
        </button>
        <button type="button" className={styles.button} onClick={onEdit}>
          <Glyph name="pencil" className={styles.glyph} />
          Edit request
        </button>
      </div>
      <Panel title="Request" part="request-panel">
        <Facts
          items={[
            ['Status', REQUEST_WORD[request.stage], request.stage === 'new' ? 'alert' : undefined],
            ['Reported by', request.reporter],
            ['Number', <span data-mono>{request.id}</span>],
          ]}
        />
      </Panel>
      {order && (
        <section
          className={`${styles.panel} ${styles.enter}`}
          data-part="order-panel"
          aria-label="Work order"
        >
          <h3 className={styles.panelTitle}>Work order</h3>
          <button
            type="button"
            className={`${styles.card} ${styles.orderRow}`}
            data-demo="order-row"
            onClick={onOrder}
          >
            <span>
              <span className={styles.orderName}>
                <span data-mono>{order.id}</span> · {order.vendor}
              </span>
              <span className={styles.orderSub}>
                {request.stage === 'assigned'
                  ? 'Not scheduled yet'
                  : request.stage === 'completed'
                    ? `Completed ${order.done ?? ''}`.trim()
                    : request.stage === 'scheduled'
                      ? `Scheduled ${order.when}`
                      : STAGE_WORD[request.stage]}
              </span>
            </span>
            <span className={styles.orderCost}>
              {money(order.actual ?? order.estimate)}
              <Glyph name="chevron" className={styles.glyph} />
            </span>
          </button>
        </section>
      )}
    </>
  );
}

function OrderDetail({
  request,
  onSchedule,
  onComplete,
  onRequest,
}: {
  request: Request;
  onSchedule: () => void;
  onComplete: () => void;
  onRequest: () => void;
}) {
  const order = request.order!;
  const stage = request.stage;
  const primary =
    stage === 'assigned'
      ? { label: `Schedule for ${visitDateLabel()}`, run: onSchedule }
      : stage === 'completed'
        ? { label: 'Open request', run: onRequest }
        : { label: 'Mark completed', run: onComplete };
  return (
    <>
      <div className={styles.actions} data-part="actions">
        <button
          key="primary"
          type="button"
          className={styles.button}
          data-tone="primary"
          data-demo="primary"
          data-part="primary"
          onClick={primary.run}
        >
          {primary.label}
        </button>
        {stage !== 'completed' && (
          <button type="button" className={styles.button} onClick={onRequest}>
            Open request
          </button>
        )}
      </div>
      <div className={styles.costs} data-part="costs">
        <Cost label="Estimate" value={order.estimate} glyph="estimate" tone="violet" />
        <Cost label="Approved" value={order.approved} glyph="cash" tone="green" />
        {order.actual !== undefined && (
          <Cost label="Actual cost" value={order.actual} glyph="trend" tone="green" enter />
        )}
      </div>
      <Panel title="Details" part="details-panel">
        <Facts
          items={[
            ['Assigned to', order.vendor],
            ['Assigned', order.assigned],
            ['Priority', PRIORITY_LABEL[request.priority]],
          ]}
        />
      </Panel>
    </>
  );
}

/** The date the Schedule button offers; the same as visitDate(), on the client only. */
function visitDateLabel() {
  return typeof window === 'undefined' ? 'Thursday' : visitDate();
}

function Cost({
  label,
  value,
  glyph,
  tone,
  enter,
}: {
  label: string;
  value: number;
  glyph: GlyphName;
  tone: 'violet' | 'green';
  enter?: boolean;
}) {
  return (
    <div className={`${styles.cost} ${enter ? styles.enter : ''}`} data-part="cost">
      <span className={styles.costLabel}>{label}</span>
      <span className={styles.costIcon} data-tone={tone} aria-hidden="true">
        <Glyph name={glyph} className={styles.glyph} />
      </span>
      <span className={styles.costValue}>{money(value)}</span>
    </div>
  );
}
```

### work-orders/work-orders.module.css

```css
/* Copyright (c) 2026 Bruno Delorence. MIT License. */

/* Work orders (work-orders.tsx): a property-operations board on a warm light grey. A sidebar
   (172 px), the list (284 px) and the detail, which takes the rest.

   Sizes are the reference's, read off a 1920-wide recording and brought to a board about 1000 px
   wide: the title is 24 px (36 there), rows 13 px on a 30 px pitch, buttons 30 px tall. Under
   940 px of board the sidebar goes; under 640 px the list and the detail share one column and
   the board drills in and out (a container query, so the board answers to its own width).

   Motion. Rows that change group glide there over 420 ms (FLIP, from the script); a new row is
   tinted blue for 1.6 s; the grey half of the title blurs in over 420 ms; new panels and the
   actual cost rise 6 px as they fade in over 320 ms; the dialog grows from 97% over 220 ms; toasts
   rise in over 240 ms and fade out after 2.9 s. All on cubic-bezier(0.2, 0.7, 0.2, 1). With reduced
   motion every one of them is dropped and the state just changes.

   Colours are the tokens below, light-dark(light, dark) where the two differ. */

.root {
  container: wo / inline-size;
  --bg: light-dark(#f3f3f1, #141414);
  --line: light-dark(rgb(0 0 0 / 0.07), rgb(255 255 255 / 0.08));
  --line-strong: light-dark(rgb(0 0 0 / 0.13), rgb(255 255 255 / 0.14));
  --surface: light-dark(#fbfbfa, #1f1f1f);
  --panel: light-dark(#ebebe8, #1a1a1a);
  --field: light-dark(#e8e8e5, #232323);
  --input: light-dark(#f7f7f5, #191919);
  --dialog: light-dark(#fff, #1e1e1e);
  --ink: light-dark(#1b1b19, #ededea);
  /* Small grey words: at least 4.5 : 1 on the board and on cards. */
  --muted: light-dark(#66665f, #a3a39c);
  /* The grey half of the title: large text, at least 3 : 1. */
  --soft: light-dark(#86867f, #8a8a83);
  --primary: light-dark(#0b6de3, #1f6fe0);
  --primary-hover: light-dark(#085dc4, #2b7cf0);
  --primary-ink: #fff;
  --alert: light-dark(#c62a35, #ff7a80);
  --dot: light-dark(#e2336b, #ff5c8a);
  /* The urgent group's label: the dot's pink, darkened to 4.5 : 1 for 12.5 px words. */
  --dot-ink: light-dark(#c41f56, #ff6f97);
  --wrench: light-dark(#d9762a, #f0a060);
  --late: light-dark(#a3560e, #f0a868);
  --violet: light-dark(#6a4fe0, #a593ff);
  --green: light-dark(#1d8f53, #4fd08a);
  --selected: light-dark(#e9f1fe, #19263a);
  --selected-edge: light-dark(#bcd4f8, #2c4b78);
  --fresh: light-dark(#d6e6ff, #1f3a63);
  --focus: light-dark(#2f7cf6, #6aa5ff);
  --toast: light-dark(#161616, #f2f2ef);
  --toast-ink: light-dark(#fff, #161616);
  --scrim: light-dark(rgb(30 30 28 / 0.26), rgb(0 0 0 / 0.55));
  --shadow: light-dark(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.45));
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.25);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  position: relative;
  height: 640px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
  font:
    400 13px / 1.4 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Inter,
    Roboto,
    sans-serif;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}
.root[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root[data-color-scheme='system'] {
  color-scheme: light dark;
}
.root *,
.root *::before,
.root *::after {
  box-sizing: border-box;
}
/* The resets weigh no more than one class (:where), so each part's own class wins over them. */
.root :where(h2, h3, h4, p, ul, ol, dl, dd) {
  margin: 0;
  padding: 0;
}
.root :where(ul, ol) {
  list-style: none;
}
.root :where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
}
.root :where(button) {
  cursor: pointer;
}
.root :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Unit and order numbers: even digits, the hyphen given room as the reference sets them. */
.root [data-mono] {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.glyph {
  flex: none;
  width: 15px;
  height: 15px;
}

/* Reads which scheme the board is drawn in: the script compares its colour. */
.probe {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  color: light-dark(#000, #fff);
}

/* The three columns. */
.shell {
  display: grid;
  grid-template-columns: 172px 284px minmax(0, 1fr);
  height: 100%;
}

/* Sidebar. */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 12px 10px 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brandMark {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  overflow: hidden;
}
.navItem {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 29px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
}
.navItem[aria-current='page'] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px var(--shadow);
}
.navGap {
  height: 10px;
  flex: none;
}
.themeSwitch {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 29px;
  margin-top: auto;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
}
.themeSwitch:hover {
  background: var(--field);
}
.themeSwitch[aria-pressed='true'] {
  color: var(--ink);
}
.user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 4px 2px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.25;
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 10.5px;
  font-weight: 600;
}
.userName {
  display: block;
  font-weight: 500;
}
.userRole {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

/* The heads of the list and of the detail: one 46 px row. */
.paneHead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 46px;
  padding: 0 14px;
}
.paneTitle {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* List. */
.listPane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.listPane .paneHead {
  padding: 0 12px 0 16px;
}
.switch {
  display: flex;
  margin-left: auto;
  padding: 2px;
  border-radius: 8px;
  background: var(--field);
}
.switch button {
  height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.switch button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px var(--shadow);
}
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  height: 30px;
  margin: 2px 12px 8px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
}
.search:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: 12.5px;
  outline: none;
}
.search input:focus-visible {
  outline: none;
}
.search input::placeholder {
  color: var(--muted);
}
.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 8px 16px;
  scrollbar-width: thin;
}
.empty {
  padding: 16px 10px;
  color: var(--muted);
}

/* A group: its label, and its rows hung from a faint line under the dot. The group holding the
   chosen row is lifted onto a card. */
.group {
  margin-bottom: 6px;
  padding: 8px 6px 8px;
  border-radius: 12px;
  transition:
    background-color 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}
.group[data-active='true'] {
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--line),
    0 2px 6px var(--shadow);
}
.groupLabel {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}
.groupDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.groupLabel[data-alert='true'] {
  color: var(--dot-ink);
}
.groupLabel[data-alert='true'] .groupDot {
  background: var(--dot);
}
.groupLabel[data-alert='true'] .groupDot {
  opacity: 1;
}
.rows {
  margin-left: 8.5px;
  padding-left: 4px;
  border-left: 1px solid var(--line);
}
.row {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  position: relative;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  text-align: left;
  transition:
    background-color 0.2s var(--ease),
    border-color 0.2s var(--ease);
}
.row:hover {
  background: var(--field);
}
.row[aria-current='true'] {
  border-color: var(--selected-edge);
  background: var(--selected);
}
.row[data-fresh] {
  animation: fresh 1.6s var(--ease);
}
@keyframes fresh {
  from {
    background-color: var(--fresh);
    opacity: 0;
    transform: translateY(-6px);
  }
  20% {
    background-color: var(--fresh);
    opacity: 1;
    transform: none;
  }
}
.rowIcon {
  width: 15px;
  height: 15px;
  color: var(--wrench);
}
.rowText {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rowTitle {
  font-weight: 500;
}
.rowMeta {
  color: var(--muted);
}
.rowStatus {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.rowStatus[data-stage='new'] {
  color: var(--alert);
}
.rowStatus[data-late] {
  max-width: 120px;
  color: var(--late);
}
.alertDot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot);
}

/* Detail. */
.detailPane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
}
.detailPane .paneHead {
  border-bottom: 1px solid var(--line);
  padding: 0 14px 0 20px;
}
.back {
  display: none;
  align-items: center;
  gap: 4px;
  height: 30px;
  margin-left: -8px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--primary);
  font-weight: 500;
}
.back:hover {
  background: var(--field);
}
.detailScroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 26px 72px;
  scrollbar-width: thin;
}
.detailBody {
  animation: rise 0.24s var(--ease);
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12.5px;
}
.chip {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--wrench);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px var(--shadow);
}
.chip .glyph {
  width: 14px;
  height: 14px;
}

/* The sentence title: what is wrong in ink, where it stands in grey. */
.title {
  max-width: 30em;
  margin: 14px 0 18px;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}
.title:focus-visible {
  outline-offset: 4px;
  border-radius: 4px;
}
.titleState {
  color: var(--soft);
  animation: state 0.42s var(--ease);
}
@keyframes state {
  from {
    opacity: 0;
    filter: blur(4px);
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow:
    0 0 0 1px var(--line-strong),
    0 1px 2px var(--shadow);
  transition:
    background-color 0.15s ease,
    transform 0.12s ease;
}
.button:hover {
  background: var(--field);
}
.button[data-tone='primary'] {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 1px 2px rgb(0 40 120 / 0.25);
}
.button[data-tone='primary']:hover {
  background: var(--primary-hover);
}
.button:active,
.root [data-pressed] {
  transform: scale(0.97);
}
.newNarrow {
  display: none;
}
.newWide {
  margin-left: auto;
}

/* Panels: a grey tray with its title, over a lighter card. */
.panel {
  margin-bottom: 14px;
  padding: 0 4px 4px;
  border-radius: 14px;
  background: var(--panel);
}
.panelTitle {
  padding: 9px 12px 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.card {
  display: block;
  width: 100%;
  padding: 12px 16px 13px;
  border: 0;
  border-radius: 11px;
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px var(--shadow);
}
.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.facts dt {
  color: var(--muted);
  font-size: 11.5px;
}
.facts dd {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.facts dd[data-tone='alert'] {
  color: var(--alert);
}
.orderRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  transition: background-color 0.15s ease;
}
.orderRow:hover {
  background: var(--input);
}
.orderName {
  display: block;
  font-weight: 500;
}
.orderSub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.orderCost {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.enter {
  animation: rise 0.32s var(--ease);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Cost cards: a label, an icon chip at the top right, the amount at the foot. */
.costs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 600px;
  margin-bottom: 14px;
}
.cost {
  display: grid;
  grid-template: 'label icon' auto 'value value' 1fr / 1fr auto;
  min-height: 92px;
  padding: 11px 12px 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 3px var(--shadow);
}
.costLabel {
  grid-area: label;
  color: var(--muted);
  font-size: 12px;
}
.costIcon {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}
.costIcon .glyph {
  width: 13px;
  height: 13px;
}
.costIcon[data-tone='violet'] {
  color: var(--violet);
}
.costIcon[data-tone='green'] {
  color: var(--green);
}
.costValue {
  grid-area: value;
  align-self: end;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* The beat of loading a work order. */
.skeleton {
  display: grid;
  gap: 16px;
}
.skeleton span {
  display: block;
  height: 30px;
  border-radius: 8px;
  background: var(--field);
  animation: pulse 1s ease-in-out infinite alternate;
}
.skeleton span:first-child {
  width: 55%;
}
.skeleton span:nth-child(2) {
  height: 84px;
}
.skeleton span:nth-child(3) {
  height: 150px;
}
@keyframes pulse {
  to {
    opacity: 0.55;
  }
}

/* The dialog, inside the board. */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
}
.scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade 0.18s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 22px 20px;
  border-radius: 16px;
  background: var(--dialog);
  box-shadow:
    0 0 0 1px var(--line),
    0 24px 60px rgb(0 0 0 / 0.22);
  animation: pop 0.22s var(--ease);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}
.dialogTitle {
  margin-bottom: 18px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.form {
  display: grid;
  gap: 14px;
}
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 12.5px;
  font-weight: 500;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.input,
.textarea,
.select select {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--input);
  font-size: 13.5px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: 8px 11px;
  resize: vertical;
}
.input:focus,
.textarea:focus,
.select select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px light-dark(rgb(11 109 227 / 0.16), rgb(80 150 255 / 0.25));
}
.textarea[aria-invalid='true'] {
  border-color: var(--alert);
}
.select {
  position: relative;
  display: block;
}
.select select {
  appearance: none;
  padding-right: 30px;
}
/* The select's chevron, drawn as two borders. */
.select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.hint {
  color: var(--muted);
  font-size: 12px;
}
.error {
  color: var(--alert);
  font-size: 12px;
}
.dialogActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.dialogActions .button {
  height: 34px;
  padding: 0 14px;
}

/* Toasts, at the board's lower right. */
.toasts {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: 10px;
  background: var(--toast);
  color: var(--toast-ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  animation:
    toast-in 0.24s var(--ease),
    toast-out 0.22s ease 2.9s forwards;
}
.toast .glyph {
  width: 13px;
  height: 13px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Narrower boards: no sidebar under 940 px, then one column under 640 px. */
@container wo (width < 940px) {
  .shell {
    grid-template-columns: 284px minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
}
@container wo (width < 640px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .shell[data-pane='list'] .detailPane,
  .shell[data-pane='detail'] .listPane {
    display: none;
  }
  .detailPane {
    border-left: 0;
  }
  .detailPane .paneHead {
    padding: 0 12px 0 14px;
  }
  .back {
    display: inline-flex;
  }
  .newWide {
    display: none;
  }
  .newNarrow {
    display: inline-flex;
    padding: 0 10px;
  }
  .detailScroll {
    padding: 20px 16px 72px;
  }
  .title {
    font-size: 21px;
  }
  .costs {
    gap: 8px;
  }
  .cost {
    min-height: 82px;
    padding: 10px 10px 10px 12px;
  }
  .costValue {
    font-size: 19px;
  }
  .facts {
    grid-template-columns: 1fr 1fr;
  }
  .card {
    padding: 12px 14px;
  }
}
@container wo (width < 360px) {
  .switch button {
    padding: 0 6px;
  }
  .short {
    display: none;
  }
}

/* The demo pointer, over everything, the dialog too; one of its glyphs shows at a time. */
.pointerLayer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
.pointer {
  width: 22px;
  height: 22px;
}
.hand {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .arrow {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .hand {
  visibility: visible;
}

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .row[data-fresh],
  .detailBody,
  .titleState,
  .enter,
  .scrim,
  .dialog,
  .skeleton span {
    animation: none;
  }
  .toast {
    animation: toast-out 0s linear 2.9s forwards;
  }
  .group,
  .row,
  .button {
    transition: none;
  }
  .button:active,
  .root [data-pressed] {
    transform: none;
  }
}
```

### work-orders/request-dialog.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useId,
  useRef,
  useState,
  type FormEvent,
  type KeyboardEvent as ReactKeyboardEvent,
} from 'react';
import { CATEGORIES, PRIORITIES, PROPERTIES, type Category, type Priority } from './data';
import styles from './work-orders.module.css';

/*
 * The New maintenance request dialog (and Edit request, the same form filled in). A modal inside
 * the board, not over the whole page: the board behind it is inert while it is open, Tab and
 * Shift+Tab go round its own controls, Escape or a press on the scrim closes it, and the parent
 * puts the focus back where it was.
 *
 * The form's values live in the parent, so the demo can type into it the way a reader would.
 */

export type Draft = {
  property: string;
  unit: string;
  category: Category;
  priority: Priority;
  text: string;
};

export const EMPTY_DRAFT: Draft = {
  property: PROPERTIES[0],
  unit: '',
  category: 'Plumbing',
  priority: 'normal',
  text: '',
};

export function RequestDialog({
  mode,
  draft,
  onDraft,
  onSubmit,
  onClose,
  focusOnOpen,
}: {
  mode: 'new' | 'edit';
  draft: Draft;
  onDraft: (draft: Draft) => void;
  onSubmit: () => void;
  onClose: () => void;
  /** Moves the focus into the form as it opens: not when the demo opens it. */
  focusOnOpen: boolean;
}) {
  const id = useId();
  const box = useRef<HTMLDivElement>(null);
  const first = useRef<HTMLSelectElement>(null);
  const text = useRef<HTMLTextAreaElement>(null);
  const [error, setError] = useState(false);

  useEffect(() => {
    if (focusOnOpen) first.current?.focus({ preventScroll: true });
  }, [focusOnOpen]);

  const set = <K extends keyof Draft>(key: K, value: Draft[K]) => {
    if (key === 'text' && String(value).trim()) setError(false);
    onDraft({ ...draft, [key]: value });
  };

  const submit = (event: FormEvent) => {
    event.preventDefault();
    if (!draft.text.trim()) {
      setError(true);
      text.current?.focus({ preventScroll: true });
      return;
    }
    onSubmit();
  };

  // Tab stays inside the dialog: past the last control it comes back to the first.
  const onKeyDown = (event: ReactKeyboardEvent) => {
    if (event.key === 'Escape') {
      event.preventDefault();
      event.stopPropagation();
      onClose();
      return;
    }
    if (event.key !== 'Tab' || !box.current) return;
    const stops = [
      ...box.current.querySelectorAll<HTMLElement>('select, input, textarea, button'),
    ].filter((element) => !element.hasAttribute('disabled'));
    const head = stops[0];
    const tail = stops.at(-1);
    if (event.shiftKey && document.activeElement === head) {
      event.preventDefault();
      tail?.focus();
    } else if (!event.shiftKey && document.activeElement === tail) {
      event.preventDefault();
      head?.focus();
    }
  };

  return (
    <div className={styles.overlay} data-part="overlay">
      <div className={styles.scrim} onPointerDown={onClose} aria-hidden="true" />
      {/* Escape and the Tab loop, for every control inside the dialog. */}
      {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}
      <div
        ref={box}
        className={styles.dialog}
        role="dialog"
        aria-modal="true"
        aria-labelledby={`${id}-title`}
        data-part="dialog"
        onKeyDown={onKeyDown}
      >
        <h2 id={`${id}-title`} className={styles.dialogTitle}>
          {mode === 'new' ? 'New maintenance request' : 'Edit request'}
        </h2>
        <form className={styles.form} onSubmit={submit} noValidate>
          <div className={styles.field}>
            <label htmlFor={`${id}-property`}>Property</label>
            <span className={styles.select}>
              <select
                ref={first}
                id={`${id}-property`}
                value={draft.property}
                onChange={(event) => set('property', event.target.value)}
              >
                {PROPERTIES.map((property) => (
                  <option key={property}>{property}</option>
                ))}
              </select>
            </span>
          </div>
          <div className={styles.field}>
            <label htmlFor={`${id}-unit`}>Unit</label>
            <input
              id={`${id}-unit`}
              className={styles.input}
              data-demo="unit"
              data-mono
              value={draft.unit}
              autoComplete="off"
              spellCheck={false}
              aria-describedby={`${id}-unit-hint`}
              onChange={(event) => set('unit', event.target.value)}
            />
            <p id={`${id}-unit-hint`} className={styles.hint}>
              Leave empty for a common area.
            </p>
          </div>
          <div className={styles.pair}>
            <div className={styles.field}>
              <label htmlFor={`${id}-category`}>Category</label>
              <span className={styles.select}>
                <select
                  id={`${id}-category`}
                  value={draft.category}
                  onChange={(event) => set('category', event.target.value as Category)}
                >
                  {CATEGORIES.map((category) => (
                    <option key={category}>{category}</option>
                  ))}
                </select>
              </span>
            </div>
            <div className={styles.field}>
              <label htmlFor={`${id}-priority`}>Priority</label>
              <span className={styles.select} data-demo="priority">
                <select
                  id={`${id}-priority`}
                  value={draft.priority}
                  onChange={(event) => set('priority', event.target.value as Priority)}
                >
                  {PRIORITIES.map((priority) => (
                    <option key={priority.id} value={priority.id}>
                      {priority.label}
                    </option>
                  ))}
                </select>
              </span>
            </div>
          </div>
          <div className={styles.field}>
            <label htmlFor={`${id}-text`}>What is wrong</label>
            <textarea
              ref={text}
              id={`${id}-text`}
              className={styles.textarea}
              data-demo="text"
              rows={4}
              value={draft.text}
              aria-invalid={error || undefined}
              aria-describedby={error ? `${id}-text-error` : undefined}
              onChange={(event) => set('text', event.target.value)}
            />
            {error && (
              <p id={`${id}-text-error`} className={styles.error}>
                Say what is wrong, in a few words.
              </p>
            )}
          </div>
          <div className={styles.dialogActions}>
            <button type="button" className={styles.button} onClick={onClose}>
              Cancel
            </button>
            <button type="submit" className={styles.button} data-tone="primary" data-demo="create">
              {mode === 'new' ? 'Create request' : 'Save changes'}
            </button>
          </div>
        </form>
      </div>
    </div>
  );
}
```

### work-orders/data.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The data behind the work orders board: maintenance requests, the work order each one gets once
 * it is assigned, and the words the board says about them. Plain data and pure functions, no
 * React, so the docs and the demo build on the same seed.
 *
 * One record carries the whole lifecycle. A request is `new` until it is assigned; assigning it
 * opens its work order with a vendor and an estimate, and from then on the request and its order
 * share one stage: assigned, scheduled, (in progress or waiting on parts), completed.
 */

export type Priority = 'urgent' | 'high' | 'normal';
export type Stage = 'new' | 'assigned' | 'scheduled' | 'progress' | 'waiting' | 'completed';
export type Category = 'Plumbing' | 'Electrical' | 'Appliance' | 'Heating and cooling' | 'General';

export type WorkOrder = {
  /** WO-2564 */
  id: string;
  vendor: string;
  estimate: number;
  approved: number;
  /** Set when the work is completed. */
  actual?: number;
  /** When the visit is booked, in words: "Thu, Nov 5", "tomorrow". */
  when?: string;
  /** The booked visit has gone by without the work being done. */
  late?: boolean;
  /** Waiting on parts rather than on a price. */
  parts?: boolean;
  /** When it was assigned, in words: "Just now", "2 days ago". */
  assigned: string;
  /** When it was completed, in words. */
  done?: string;
};

export type Request = {
  /** MR-3819 */
  id: string;
  /** What is wrong, without its full stop: "Water leaking through ceiling". */
  title: string;
  property: string;
  /** Empty for a common area. */
  unit: string;
  category: Category;
  priority: Priority;
  stage: Stage;
  reporter: string;
  /** When it was reported, in words: "1h ago", "just now". */
  reported: string;
  order?: WorkOrder;
};

export const PROPERTIES = [
  'Alder Court',
  'Birch Terrace',
  'Fenwick House',
  'Marlow Yards',
  'Quarry Lofts',
] as const;

export const CATEGORIES: Category[] = [
  'Plumbing',
  'Electrical',
  'Appliance',
  'Heating and cooling',
  'General',
];

export const PRIORITIES: { id: Priority; label: string }[] = [
  { id: 'urgent', label: 'Urgent' },
  { id: 'high', label: 'High' },
  { id: 'normal', label: 'Normal' },
];

/** The vendor each kind of job goes to first, and what it usually costs. */
export const VENDORS: Record<Category, { vendor: string; estimate: number }> = {
  Plumbing: { vendor: 'Ridgeline Plumbing', estimate: 250 },
  Electrical: { vendor: 'Copperleaf Electric', estimate: 320 },
  Appliance: { vendor: 'Brightline Appliance', estimate: 190 },
  'Heating and cooling': { vendor: 'Coolbrook Air', estimate: 540 },
  General: { vendor: 'Hollis Handyman', estimate: 150 },
};

/** Who is signed in, and so reports what they file. */
export const USER = { name: 'Maya Ortiz', role: 'Portfolio manager', initials: 'MO' };

const order = (
  id: number,
  vendor: string,
  cost: number,
  extra: Partial<WorkOrder> = {},
): WorkOrder => ({
  id: `WO-${id}`,
  vendor,
  estimate: cost,
  approved: cost,
  assigned: '2 days ago',
  ...extra,
});

/** The board as it opens: fifteen requests across the three priorities and every stage. */
export const SEED: Request[] = [
  {
    id: 'MR-3819',
    title: 'Water leaking through ceiling',
    property: 'Alder Court',
    unit: 'B-306',
    category: 'Plumbing',
    priority: 'urgent',
    stage: 'new',
    reporter: 'Priya Raman',
    reported: '1h ago',
  },
  {
    id: 'MR-3790',
    title: 'Elevator stopping between floors',
    property: 'Marlow Yards',
    unit: '',
    category: 'General',
    priority: 'urgent',
    stage: 'progress',
    reporter: 'Tomas Ilic',
    reported: '3 days ago',
    order: order(2561, 'Northgate Lifts', 6800, { when: 'yesterday' }),
  },
  {
    id: 'MR-3802',
    title: 'Backup generator not starting',
    property: 'Fenwick House',
    unit: '',
    category: 'Electrical',
    priority: 'urgent',
    stage: 'waiting',
    reporter: 'Hana Okafor',
    reported: '2 days ago',
    order: order(2540, 'Copperleaf Electric', 4200, { parts: true }),
  },
  {
    id: 'MR-3771',
    title: 'AC compressor replacement',
    property: 'Birch Terrace',
    unit: 'C-204',
    category: 'Heating and cooling',
    priority: 'high',
    stage: 'waiting',
    reporter: 'Leo Brandt',
    reported: '6 days ago',
    order: order(2496, 'Coolbrook Air', 1450),
  },
  {
    id: 'MR-3797',
    title: 'Bathroom drain clogged',
    property: 'Quarry Lofts',
    unit: '5C',
    category: 'Plumbing',
    priority: 'high',
    stage: 'scheduled',
    reporter: 'Noor Haddad',
    reported: '4 days ago',
    order: order(2122, 'Ridgeline Plumbing', 170, { when: 'last Friday', late: true }),
  },
  {
    id: 'MR-3808',
    title: 'Dishwasher not draining',
    property: 'Birch Terrace',
    unit: 'A-112',
    category: 'Appliance',
    priority: 'high',
    stage: 'progress',
    reporter: 'Elena Varga',
    reported: '2 days ago',
    order: order(2270, 'Brightline Appliance', 240, { when: 'today' }),
  },
  {
    id: 'MR-3811',
    title: 'Toilet running constantly',
    property: 'Alder Court',
    unit: 'D-410',
    category: 'Plumbing',
    priority: 'high',
    stage: 'scheduled',
    reporter: 'Sam Whitlock',
    reported: 'yesterday',
    order: order(1865, 'Ridgeline Plumbing', 100, { when: 'tomorrow', assigned: 'Yesterday' }),
  },
  {
    id: 'MR-3815',
    title: 'Refrigerator not cooling',
    property: 'Fenwick House',
    unit: '2B',
    category: 'Appliance',
    priority: 'high',
    stage: 'assigned',
    reporter: 'Priya Raman',
    reported: '5h ago',
    order: order(2563, 'Brightline Appliance', 880, { assigned: '4h ago' }),
  },
  {
    id: 'MR-3760',
    title: 'Kitchen sink leaking',
    property: 'Alder Court',
    unit: 'A-204',
    category: 'Plumbing',
    priority: 'normal',
    stage: 'progress',
    reporter: 'Hana Okafor',
    reported: '1 week ago',
    order: order(1843, 'Ridgeline Plumbing', 170, { when: 'Monday' }),
  },
  {
    id: 'MR-3774',
    title: 'Breaker keeps tripping',
    property: 'Marlow Yards',
    unit: '3F',
    category: 'Electrical',
    priority: 'normal',
    stage: 'waiting',
    reporter: 'Leo Brandt',
    reported: '5 days ago',
    order: order(2049, 'Copperleaf Electric', 320, { parts: true }),
  },
  {
    id: 'MR-3781',
    title: 'Wall paint peeling',
    property: 'Quarry Lofts',
    unit: '2A',
    category: 'General',
    priority: 'normal',
    stage: 'scheduled',
    reporter: 'Noor Haddad',
    reported: '2 weeks ago',
    order: order(2167, 'Fairmont Painting', 310, { when: 'last Tuesday', late: true }),
  },
  {
    id: 'MR-3786',
    title: 'Low water pressure',
    property: 'Birch Terrace',
    unit: 'B-108',
    category: 'Plumbing',
    priority: 'normal',
    stage: 'scheduled',
    reporter: 'Elena Varga',
    reported: '4 days ago',
    order: order(2033, 'Ridgeline Plumbing', 450, { when: 'Friday' }),
  },
  {
    id: 'MR-3799',
    title: 'Water stain on ceiling',
    property: 'Fenwick House',
    unit: '4D',
    category: 'General',
    priority: 'normal',
    stage: 'assigned',
    reporter: 'Tomas Ilic',
    reported: 'yesterday',
    order: order(2259, 'Hollis Handyman', 150, { assigned: 'Yesterday' }),
  },
  {
    id: 'MR-3742',
    title: 'Ants in bathroom',
    property: 'Marlow Yards',
    unit: '1C',
    category: 'General',
    priority: 'normal',
    stage: 'completed',
    reporter: 'Sam Whitlock',
    reported: '2 weeks ago',
    order: order(1887, 'Hollis Handyman', 120, { actual: 135, done: 'last week' }),
  },
];

/** The unit, or the words for a common area. */
const place = (request: Request) => `${request.property} · ${request.unit.trim() || 'common area'}`;

/**
 * The grey half of a request's title: where it is and where it stands. It is rewritten at each
 * step, so the title reads as one sentence about the request's state.
 */
export function requestStatus(request: Request): string {
  const at = place(request);
  const vendor = request.order?.vendor ?? '';
  switch (request.stage) {
    case 'new':
      return `${at}, reported ${request.reported} and not assigned yet.`;
    case 'assigned':
      return `${at}, reported ${request.reported}, assigned to ${vendor}.`;
    case 'scheduled':
      return request.order?.late
        ? `${at}, ${vendor} was due ${request.order.when}.`
        : `${at}, ${vendor} booked for ${request.order?.when}.`;
    case 'progress':
      return `${at}, ${vendor} is on it.`;
    case 'waiting':
      return `${at}, ${vendor} is waiting on ${request.order?.parts ? 'parts' : 'approval'}.`;
    case 'completed':
      return `${at}, fixed by ${vendor} ${request.order?.done ?? 'just now'}.`;
  }
}

/** The grey half of a work order's title: who does it, where, and when. */
export function orderStatus(request: Request): string {
  const order = request.order;
  if (!order) return requestStatus(request);
  const lead = `${order.vendor} at ${place(request)}`;
  switch (request.stage) {
    case 'scheduled':
      return order.late
        ? `${lead}, past its ${order.when} visit.`
        : `${lead}, scheduled ${order.when}.`;
    case 'progress':
      return `${lead}, in progress.`;
    case 'waiting':
      return `${lead}, waiting on ${order.parts ? 'parts' : 'approval'}.`;
    case 'completed':
      return `${lead}, completed ${order.done ?? 'just now'}.`;
    default:
      return `${lead}, not scheduled yet.`;
  }
}

/** The status word at the end of a request's row, and of its panel. */
export const STAGE_WORD: Record<Stage, string> = {
  new: 'Not assigned',
  assigned: 'Assigned',
  scheduled: 'Scheduled',
  progress: 'In progress',
  waiting: 'Waiting',
  completed: 'Completed',
};

/** The request's own status, in its panel: New until it is assigned. */
export const REQUEST_WORD: Record<Stage, string> = { ...STAGE_WORD, new: 'New' };

/** The groups of the work orders list, in their order, and which orders each one holds. */
export const ORDER_GROUPS: {
  id: string;
  label: string;
  alert?: boolean;
  holds: (r: Request) => boolean;
}[] = [
  {
    id: 'late',
    label: 'Past schedule',
    alert: true,
    holds: (r) => r.stage === 'scheduled' && !!r.order?.late,
  },
  { id: 'assigned', label: 'To schedule', holds: (r) => r.stage === 'assigned' },
  {
    id: 'scheduled',
    label: 'Scheduled',
    holds: (r) => r.stage === 'scheduled' && !r.order?.late,
  },
  { id: 'progress', label: 'In progress', holds: (r) => r.stage === 'progress' },
  { id: 'waiting', label: 'Waiting', holds: (r) => r.stage === 'waiting' },
  { id: 'completed', label: 'Completed', holds: (r) => r.stage === 'completed' },
];

export const money = (value: number) =>
  `$${value.toLocaleString('en-US', { maximumFractionDigits: 0 })}`;

/** The next number in a series: MR-3819 → MR-3820. */
export function nextId(prefix: 'MR' | 'WO', taken: string[]): string {
  const numbers = taken
    .filter((id) => id.startsWith(`${prefix}-`))
    .map((id) => Number(id.slice(prefix.length + 1)));
  return `${prefix}-${Math.max(0, ...numbers) + 1}`;
}

/** A visit two days out, as the board writes dates: "Thu, Nov 5". */
export function visitDate(from = new Date()): string {
  const day = new Date(from);
  day.setDate(day.getDate() + 2);
  return day.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
}

/** What the reader typed, as a title: its first sentence, no full stop, at most 80 characters. */
export function titleFrom(text: string): string {
  const first = text.trim().split(/(?<=[.!?])\s/)[0] ?? '';
  const bare = first.replace(/[.!?\s]+$/, '');
  const short = bare.length > 80 ? `${bare.slice(0, 79).trimEnd()}…` : bare;
  return short.charAt(0).toUpperCase() + short.slice(1);
}
```

### work-orders/glyphs.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The board's icons, drawn by hand on a 16-unit grid with 1.5-unit round strokes in currentColor,
 * so each one takes the colour of the text it sits in. All are decorative: the words beside them
 * carry the meaning.
 */

export type GlyphName =
  | 'mark'
  | 'search'
  | 'home'
  | 'layers'
  | 'key'
  | 'people'
  | 'coin'
  | 'wrench'
  | 'hammer'
  | 'building'
  | 'chart'
  | 'bell'
  | 'moon'
  | 'sun'
  | 'plus'
  | 'pencil'
  | 'chevron'
  | 'back'
  | 'estimate'
  | 'cash'
  | 'trend'
  | 'check';

const PATHS: Record<GlyphName, string> = {
  // A house roof over a gear tooth: the board's own mark.
  mark: 'M8 1.8l5.6 3.2v6L8 14.2 2.4 11V5zM8 5.2v5.6M5.6 6.6 8 8l2.4-1.4',
  search: 'M7 12.2a5.2 5.2 0 1 0 0-10.4 5.2 5.2 0 0 0 0 10.4zM10.8 10.8l3.4 3.4',
  home: 'M2.5 7.2 8 2.5l5.5 4.7V13a.8.8 0 0 1-.8.8H9.6V10H6.4v3.8H3.3a.8.8 0 0 1-.8-.8z',
  layers: 'M8 2.2 14 5.4 8 8.6 2 5.4zM2 8.2l6 3.2 6-3.2M2 11l6 3.2 6-3.2',
  key: 'M5.4 13.8a3.4 3.4 0 1 1 2.6-5.6l5.8-5.8M11.6 4.6l1.6 1.6M10 6.2l1.4 1.4',
  people:
    'M6 7.4a2.6 2.6 0 1 0 0-5.2 2.6 2.6 0 0 0 0 5.2zM1.6 13.8c.4-2.6 2.2-4 4.4-4s4 1.4 4.4 4M10.6 2.4a2.6 2.6 0 0 1 0 4.9M12 9.9c1.3.5 2.2 1.8 2.4 3.9',
  coin: 'M8 14.2A6.2 6.2 0 1 0 8 1.8a6.2 6.2 0 0 0 0 12.4zM10 5.6c-.4-.6-1.1-1-2-1-1.1 0-2 .6-2 1.5 0 2.2 4 1.2 4 3.5 0 .9-.9 1.6-2 1.6-.9 0-1.7-.4-2.1-1.1M8 3.6v1M8 11.2v1.2',
  wrench:
    'M10.4 2a3.6 3.6 0 0 0-3.2 4.9L2.3 11.8a1.3 1.3 0 0 0 1.9 1.9l4.9-4.9A3.6 3.6 0 0 0 14 5.6l-2.2 2.2-2-.4-.4-2L11.6 3a3.6 3.6 0 0 0-1.2-1z',
  hammer:
    'M6.6 6.6 2.4 10.8a1.2 1.2 0 0 0 1.8 1.8l4.2-4.2M5.6 3.4l2-1.6c1.8-.6 3.6 0 4.8 1.2l1.4 1.4-1.6 1.6-1-.6-2.6 2.6-2.4-2.4L7 4.8z',
  building: 'M2.5 13.8h11M3.8 13.8V2.6h5.4v11.2M9.2 6h3v7.8M5.8 5h1.4M5.8 7.6h1.4M5.8 10.2h1.4',
  chart: 'M2.5 2.5v11h11M5.5 10.5V8M8.5 10.5V5.5M11.5 10.5V7',
  bell: 'M4 11.2V7.4a4 4 0 0 1 8 0v3.8l1.2 1.2H2.8zM6.6 13.8a1.5 1.5 0 0 0 2.8 0',
  moon: 'M13.4 9.6A5.8 5.8 0 0 1 6.4 2.6a5.8 5.8 0 1 0 7 7z',
  sun: 'M8 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM8 1.6v1.2M8 13.2v1.2M1.6 8h1.2M13.2 8h1.2M3.5 3.5l.8.8M11.7 11.7l.8.8M3.5 12.5l.8-.8M11.7 4.3l.8-.8',
  plus: 'M8 3v10M3 8h10',
  pencil: 'M10.6 2.8a1.5 1.5 0 0 1 2.1 0l.5.5a1.5 1.5 0 0 1 0 2.1L5.6 13H3v-2.6zM9.4 4l2.6 2.6',
  chevron: 'M6 3.5 10.5 8 6 12.5',
  back: 'M10 3.5 5.5 8l4.5 4.5',
  estimate:
    'M3.5 1.8h6.2l2.8 2.8v9.6h-9zM8 6v5.6M9.6 7c-.3-.4-.9-.6-1.6-.6-.8 0-1.5.4-1.5 1 0 1.4 3.2.8 3.2 2.2 0 .6-.7 1-1.6 1-.7 0-1.4-.3-1.7-.7',
  cash: 'M1.8 4.2h12.4v7.6H1.8zM8 9.6a1.6 1.6 0 1 0 0-3.2 1.6 1.6 0 0 0 0 3.2zM4 6.4v3.2M12 6.4v3.2',
  trend: 'M1.8 11.6 6 7.4l2.6 2.6 5.2-5.2M10.4 4.8h3.4v3.4',
  check: 'M3.2 8.4 6.4 11.4 12.8 4.6',
};

export function Glyph({ name, className }: { name: GlyphName; className?: string }) {
  return (
    <svg
      className={className}
      viewBox="0 0 16 16"
      width="16"
      height="16"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.5"
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
      focusable="false"
    >
      <path d={PATHS[name]} />
    </svg>
  );
}
```

### work-orders/demo-pointer.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import type { CSSProperties, Ref } from 'react';

/*
 * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or
 * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends
 * the step in progress at once: its promise rejects, which ends the script right there, and the
 * pointer fades out.
 *
 * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame.
 * The points of the flight are handed to whoever wants to move along with it (nothing here uses
 * them here). The arrow and the hand are HTML boxes
 * that swap by their visibility: a change of style inside an SVG would lay the SVG out again.
 */

export type Point = { x: number; y: number };

/** A glide's path and timing, for an animation that plays along with it. */
export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };

export type Demo = {
  /** Resolves after `ms`. */
  wait: (ms: number) => Promise<void>;
  /** Glides the pointer to `to`, in the stage's own px, in `ms`; `along` gets the flight. */
  glide: (to: Point, ms: number, along?: (flight: Flight) => void) => Promise<void>;
  /** Shows the arrow, or the hand a link shows. */
  glyph: (name: 'arrow' | 'hand') => void;
};

/** What a stopped demo's pending step rejects with. */
class Stopped extends Error {}

/** Where the arrow's tip is, as shares of its box: the point the pointer stands on. */
const TIP: Point = { x: 0.15, y: 0.1 };

/** How many points a flight is drawn through. */
const SAMPLES = 24;

/** Plays `script` with the pointer over `stage`; returns the function that stops it. */
export function runDemo(
  stage: HTMLElement,
  pointer: HTMLElement,
  script: (demo: Demo) => Promise<void>,
): () => void {
  let alive = true;
  let flight: Animation | null = null;
  // The stylesheet sizes the pointer from the stage's width; its tip is where it stands.
  const tip = { x: pointer.offsetWidth * TIP.x, y: pointer.offsetHeight * TIP.y };
  const place = ({ x, y }: Point) => `translate(${x - tip.x}px, ${y - tip.y}px)`;
  const timers = new Set<number>();
  const pending = new Set<() => void>();
  // The pointer comes in from the lower right.
  let at: Point = { x: stage.offsetWidth * 0.8, y: stage.offsetHeight * 0.9 };

  /** Settles like `promise`, or rejects as soon as the demo stops. */
  const step = (promise: Promise<unknown>) =>
    new Promise<void>((resolve, reject) => {
      if (!alive) return reject(new Stopped());
      const cancel = () => reject(new Stopped());
      pending.add(cancel);
      promise.then(
        () => {
          pending.delete(cancel);
          if (alive) resolve();
        },
        () => {
          pending.delete(cancel);
          reject(new Stopped());
        },
      );
    });

  const wait = (ms: number) =>
    step(
      new Promise<void>((resolve) => {
        const timer = window.setTimeout(() => {
          timers.delete(timer);
          resolve();
        }, ms);
        timers.add(timer);
      }),
    );

  const glide: Demo['glide'] = (to, ms, along) => {
    const from = at;
    at = to;
    const dx = to.x - from.x;
    const dy = to.y - from.y;
    // A gentle curve, as a hand moves: the control point sits off the straight line.
    const bend = { x: (from.x + to.x) / 2 - dy * 0.18, y: (from.y + to.y) / 2 + dx * 0.18 };
    const points: Point[] = [];
    for (let i = 0; i <= SAMPLES; i += 1) {
      const t = i / SAMPLES;
      const u = 1 - t;
      points.push({
        x: u * u * from.x + 2 * u * t * bend.x + t * t * to.x,
        y: u * u * from.y + 2 * u * t * bend.y + t * t * to.y,
      });
    }
    const timing: KeyframeAnimationOptions = {
      duration: ms,
      easing: 'cubic-bezier(0.45, 0, 0.25, 1)',
    };
    flight?.cancel();
    // Where it rests once the flight is over.
    pointer.style.transform = place(to);
    flight = pointer.animate(
      points.map((point) => ({ transform: place(point) })),
      timing,
    );
    along?.({ points, timing });
    return step(flight.finished);
  };

  const glyph: Demo['glyph'] = (name) => {
    pointer.dataset.glyph = name;
  };

  pointer.dataset.glyph = 'arrow';
  pointer.style.transform = place(at);
  pointer.style.opacity = '1';
  script({ wait, glide, glyph }).catch((error: unknown) => {
    if (!(error instanceof Stopped)) throw error;
  });

  return () => {
    if (!alive) return;
    alive = false;
    timers.forEach((timer) => window.clearTimeout(timer));
    flight?.cancel();
    pending.forEach((cancel) => cancel());
    pointer.style.opacity = '0';
  };
}

/**
 * The pointer's box: it moves, on a layer of its own. Its size comes from its class, its colours
 * from the stage's tokens (work-orders.module.css).
 */
const POINTER: CSSProperties = {
  position: 'absolute',
  top: 0,
  left: 0,
  zIndex: 2,
  display: 'block',
  pointerEvents: 'none',
  opacity: 0,
  transition: 'opacity 0.3s ease',
  filter: 'drop-shadow(0 1px 1.5px var(--pointer-shadow))',
  willChange: 'transform',
};

/** One glyph over the other, each filling the box. */
const GLYPH: CSSProperties = { position: 'absolute', inset: 0, display: 'block' };
const DRAWING: CSSProperties = {
  display: 'block',
  width: '100%',
  height: '100%',
  overflow: 'visible',
};
/** The arrow is dark on a white edge, the hand white on a dark one, as the system draws them. */
const ARROW: CSSProperties = { fill: 'var(--pointer)', stroke: 'var(--pointer-edge)' };
const HAND: CSSProperties = { fill: 'var(--pointer-edge)', stroke: 'var(--pointer)' };

/**
 * The pointer the demo moves around: an arrow, or a pointing hand over a control. It is
 * decorative: what it does shows on the control itself. The stylesheet shows one glyph at a time,
 * from the box's data-glyph.
 */
export function DemoPointer({
  ref,
  className,
  arrowClass,
  handClass,
}: {
  ref: Ref<HTMLSpanElement>;
  className?: string;
  arrowClass?: string;
  handClass?: string;
}) {
  return (
    <span ref={ref} className={className} style={POINTER} aria-hidden="true">
      <span className={arrowClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          <path
            d="M3 2v14.5l3.6-3.3 2.6 5.6 2.4-1.1-2.6-5.5h5.2z"
            style={ARROW}
            strokeWidth="1.3"
            strokeLinejoin="round"
          />
        </svg>
      </span>
      <span className={handClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          {/* The tip of the finger sits where the arrow's tip is. */}
          <path
            d="M6.4 3.3c0-.8.6-1.4 1.3-1.4S9 2.5 9 3.3v5.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.7c.2-.4.6-.7 1.1-.7.7 0 1.2.5 1.2 1.2v3.5c0 2.8-1.9 4.9-4.6 4.9h-1.2c-1.8 0-3.1-.8-4.1-2.3l-2.6-3.9c-.4-.6-.2-1.3.4-1.7.6-.3 1.3-.2 1.7.4l.6.9z"
            style={HAND}
            strokeWidth="1.1"
            strokeLinejoin="round"
            transform="translate(-4.7 0.1)"
          />
        </svg>
      </span>
    </span>
  );
}
```

### work-orders/use-autoplay.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useCallback, useEffect, useRef, useState } from 'react';

/*
 * When a demo may play on its own: while part of it is on screen and the tab is visible, never
 * under reduced motion, and never again once the reader has used it: `take()` hands it to the
 * reader for good (until the component mounts again), so it can't come back on its own.
 */
export function useAutoplay<T extends HTMLElement>() {
  const ref = useRef<T>(null);
  const [visible, setVisible] = useState(false);
  const [reduced, setReduced] = useState(true);
  const [taken, setTaken] = useState(false);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    let onScreen = false;
    const update = () => setVisible(onScreen && !document.hidden);
    const observer = new IntersectionObserver(
      ([entry]) => {
        onScreen = entry.isIntersecting;
        update();
      },
      { threshold: 0.3 },
    );
    observer.observe(element);
    document.addEventListener('visibilitychange', update);
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    const readMotion = () => setReduced(motion.matches);
    readMotion();
    motion.addEventListener('change', readMotion);
    return () => {
      observer.disconnect();
      document.removeEventListener('visibilitychange', update);
      motion.removeEventListener('change', readMotion);
    };
  }, []);

  const take = useCallback(() => setTaken(true), []);

  return { ref, take, playing: visible && !reduced && !taken };
}
```