# Auto skeleton

> A loading wrapper that reads its skeleton from the content’s own shape, shimmers it in sync, then reveals each piece with a soft wipe.

Wrap any piece of interface and give it placeholder data while it loads: the wrapper renders it invisibly, measures every leaf (each line of text as wide as its words, every image, icon, field, bubble and button with its own corner radius) and draws a skeleton in exactly that shape, keeping the cards and tiles around them as they are. The bones shimmer as one diagonal band, in sync across every frame on the page. When the data lands, each piece wipes in from the left behind a soft edge while its bone wipes out, top to bottom. Content rendered with its data shows at once, data that comes back quickly shows with no skeleton at all, and an image keeps its bone until it has loaded. The gallery loads seven cards (stats, a chat, a player, a list of people, an article with its photo, a portfolio and a photo strip), each with its own latency; Reload fetches them again.

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

Category: Feedback.

## Anatomy

1. **Stage**: The gallery’s quiet panel. Three columns of cards, one column of four under 760 px.
2. **Frame**: The wrapper around one card. aria-busy while loading; its content is laid out but invisible and inert.
3. **Surface**: The card itself, drawn with its own background, border and radius: the skeleton keeps the chrome.
4. **Bone**: One leaf of the content at its exact place: a line of text as wide as its words, or a block with its radius. Translucent ink, so it reads on any surface.
5. **Reload**: Fetches every card again; aria-disabled while any is loading, so a pressed Reload keeps the focus.

## Properties

### Reveal (`reveal`)

1. **Wipe (default)**: A soft 32 px edge runs left to right over each piece, its content sharpening from a 4 px blur.
2. **Blur**: Each piece comes into focus from 8 px.
3. **Fade**: Each piece fades in, nothing else.

Keep the wipe for text-heavy cards: the bar seems to turn into the words. A fade suits dense tables, where many moving edges are noise.

### Shimmer (`shimmer`)

1. **Sweep (default)**: One 105° band every 1.6 s, in step across every frame.
2. **Pulse**: The bones breathe, on the same clock.
3. **None**: Still bones.

Use one shimmer per page. Still bones suit a page that loads many small frames at once.

## When to use

- Cards, lists and panels whose data comes from the network and takes long enough to notice, from about a fifth of a second to a few seconds.
- Layouts you already render with placeholder data: the wrapper reads the skeleton from them, so it never drifts from the real component.
- Dashboards and feeds where several pieces load on their own: each frame reveals when its own data lands, and every skeleton shimmers on the same clock.
- Content whose shape is known before its words: a stat, a message, a track, a row with an avatar.

## When not to use

- Data that is there at render time, on the server or from a cache: render it. The wrapper shows it at once anyway, but it is a wrapper for nothing.
- Loads under about 120 ms. The skeleton never shows (showAfter), so there is nothing to gain; leave the content as it is.
- Waits with no known shape (a search with no results yet, an upload): use a spinner or a progress bar.
- Long operations with progress to report, or that can fail and retry: show the progress and the error, not bones.
- Content whose size depends on its real data so much that a placeholder can’t stand for it (a chart’s axis, a free-form article). Draw a simpler fixed skeleton.

### Placeholder data

The skeleton is as good as the placeholder it is read from.

- Give the placeholder the same rows as the real data: the same number of messages, holdings, tiles.
- Use words of about the real length, so lines wrap where the real ones will and the card keeps its height.
- Leave fixed chrome as it is: labels like “Portfolio” can be the real words, they are drawn as bones all the same.

## Do’s and don’ts

- **Do**: Pass a placeholder of the real shape: the skeleton then matches the content, and nothing moves when it lands.
- **Don’t**: Don’t render the card empty while loading: with no words there is nothing to measure, and the frame collapses.
- **Caution**: Many frames at once are fine (they share one clock), but give the page one live region and set announce={false} on the frames.

## Content

The placeholder is never seen or read, but it decides the skeleton.

- Keep each placeholder string within a few characters of the real one.
- Mark an element with `data-skeleton="skip"` when it should not be drawn (a decoration inside a bubble), `"block"` to draw it whole.

## Installation

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

```sh
npx shadcn@latest add https://brunodelorence.com/r/auto-skeleton.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/auto-skeleton
```

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
import { AutoSkeleton } from './auto-skeleton';

const PLACEHOLDER = { name: 'Full name', role: 'Their role, here', plan: 'Plan' };

export function Profile({ user }: { user?: User }) {
  return (
    <AutoSkeleton loading={!user} onRevealed={() => console.log('shown')}>
      <article className="card">
        <Avatar src={user?.avatar} />
        <h3>{(user ?? PLACEHOLDER).name}</h3>
        <p>{(user ?? PLACEHOLDER).role}</p>
        <span className="chip">{(user ?? PLACEHOLDER).plan}</span>
      </article>
    </AutoSkeleton>
  );
}
```

## States

- **Loading**: Every card as its skeleton, the band sweeping across all of them in step.
- **Loaded**: The real cards. Content rendered with its data starts here, with no skeleton.
- **Loading, pulse**: `shimmer="pulse"`: the bones breathe between 100% and 45%.
- **Loading, still**: `shimmer="none"`, and what reduced motion shows: bones with no movement.
- **Loading, dark**: The same bones, 7.5% white on the dark cards.

## How it works

- The children are always rendered, in their place, with whatever data the caller has: the real data, or a placeholder of the same shape. While loading they are visibility: hidden and inert, still laid out, so they set the frame’s size and nothing moves when the real content arrives.
- The skeleton is read from that invisible DOM in a layout effect, with no markers and no build step, and again on every resize (a ResizeObserver) and once the fonts are ready. A text node becomes one bar per line from a Range’s client rects, as wide as its words, 0.75 of its font size tall, clipped to its box when it ends in an ellipsis. An image, SVG, canvas, field, or an element that paints a background around nothing but inline text (a bubble, a button, a chip, an avatar with initials) becomes one block with its computed border radius. An element that paints around other pieces is a surface, drawn with its own background, border, radius and shadow, so the card and its tiles stay as they are.
- Overrides are data attributes: `data-skeleton="skip"` leaves an element out, `"block"` draws it as one block, `"keep"` draws it as a surface.
- Bones are translucent ink (7% on light, 7.5% on dark), so they read on any surface. The sweep is one 105° band that crosses each frame every 1.6 s: every bone clips a frame-sized gradient placed back by its own offset, moved by a transform on the compositor, so all of them show slices of the same band. The animation’s negative delay is the page clock modulo 1.6 s, so frames that started at different times shimmer in step. `shimmer="pulse"` breathes the bones between 100% and 45% instead.
- Bones fade in over 200 ms only after `showAfter` (120 ms): if the data lands sooner, the content shows at once with no skeleton and no reveal. Content that was never loading, as when it was rendered on the server with its data, shows at once too.
- Revealing, every piece is animated with the Web Animations API before the first paint, staggered by where it is: 85% by its height in the frame, 15% by its offset along the line, over `stagger` (360 ms) in all. Each one runs for `duration` (320 ms) on cubic-bezier(0.22, 0.61, 0.36, 1).
- The wipe is a registered <length-percentage>, --wipe, inside two mask gradients: the content is opaque up to 32 px before it and sharpens from a 4 px blur, the bone is the reverse, so one soft 32 px edge runs left to right and the bar seems to turn into the words. `reveal="blur"` fades each piece in from an 8 px blur, `"fade"` from transparent, `"none"` swaps at once.
- An image that is still loading keeps its bone, and both animations wait for its load event. The frame is shown once every animation has finished, and calls onRevealed.
- The gallery is three columns of cards (one column of four under 760 px), each in its own frame with its own latency, from 0.9 to 1.7 s. While on screen and untouched, a demo pointer types a reply into the chat, plays the track and reloads; any press or key hands it to the reader for good.
- Under reduced motion the bones hold still (no sweep, no pulse, no fade-in) and the content shows at once.

## API reference

- **loading** (`boolean`): True holds the skeleton, false reveals the content. Required with children. On the gallery it forces every card.
- **children** (`ReactNode`): The content to load, given its placeholder data while loading. Without children, AutoSkeleton shows its gallery of cards.
- **reveal** (`'wipe' | 'blur' | 'fade' | 'none'`, default `'wipe'`): How each piece comes in: a soft 32 px wipe from the left with a 4 px blur, a blur from 8 px, a fade, or at once.
- **shimmer** (`'sweep' | 'pulse' | 'none'`, default `'sweep'`): How the bones move while loading: one diagonal band in sync across every frame, a pulse, or still.
- **stagger** (`number`, default `360`): Ms from the first piece’s reveal (top left) to the last one’s (bottom right).
- **duration** (`number`, default `320`): Ms each piece’s reveal takes.
- **showAfter** (`number`, default `120`): Data that arrives sooner than this, in ms, shows at once, with no skeleton and no reveal.
- **announce** (`boolean`, default `true`): Say “Loading” and “Loaded” in a polite live region. Turn it off when a page speaks once for many frames.
- **onRevealed** (`() => void`): Called once every piece is shown (on the gallery: every card).
- **autoplay** (`boolean`, default `true`): The gallery: load once on screen and let a demo pointer try it. False shows the cards loaded at once (Reload still loads them).
- **colorScheme** (`'light' | 'dark' | 'system'`, default `'system'`): The gallery: forces a scheme, or follows the page’s color-scheme.
- **className** (`string`): Extra classes for the frame, or the gallery’s stage.

## Accessibility

### While loading

- The frame is aria-busy and its content inert and hidden: placeholder data is never focused or read.
- The skeleton is aria-hidden. One polite status says “Loading”, then “Loaded”.

### Motion

- Under reduced motion the bones hold still and the content shows at once, with no wipe or blur.

### In this build

- While loading, the frame is aria-busy and its content is visibility: hidden and inert: neither the keyboard nor a screen reader reaches placeholder data. The skeleton is aria-hidden.
- A polite status says “Loading”, then “Loaded” once every piece is shown; the gallery speaks once for all its cards.
- The cards are real: the chat’s reply is a labelled field with a Send button, playback is a progressbar with its time as text and a Play/Pause button, the drawn photos are images with a description.
- Focus shows as a blue ring on every control; the demo pointer is decorative and stops for good at the first press or key.
- Under reduced motion there is no shimmer and no reveal: the bones hold still and the content shows at once.

## Source

### auto-skeleton/auto-skeleton.tsx

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

'use client';

import { useEffect, useEffectEvent, useRef, useState, type ReactNode } from 'react';
import { Icon } from './art';
import {
  ARTICLE,
  ARTICLE_PLACEHOLDER,
  ArticleCard,
  CHAT,
  CHAT_PLACEHOLDER,
  ChatCard,
  PEOPLE,
  PEOPLE_PLACEHOLDER,
  PeopleCard,
  PHOTOS,
  PhotosCard,
  PLAYER,
  PLAYER_PLACEHOLDER,
  PlayerCard,
  PORTFOLIO,
  PORTFOLIO_PLACEHOLDER,
  PortfolioCard,
  STATS,
  STATS_PLACEHOLDER,
  StatsCard,
} from './cards';
import { DemoPointer, runDemo, type Demo } from './demo-pointer';
import { SkeletonFrame, type Reveal, type Shimmer } from './skeleton';
import { useAutoplay } from './use-autoplay';
import styles from './auto-skeleton.module.css';

export { SkeletonFrame, type SkeletonFrameProps, type Reveal, type Shimmer } from './skeleton';

/*
 * Auto skeleton: loading states drawn from the content's own shape.
 *
 * - With children, AutoSkeleton is the wrapper (SkeletonFrame, skeleton.tsx): it renders the
 *   children invisibly with their placeholder data, reads a skeleton from them, shimmers it, and
 *   reveals the real content piece by piece when `loading` turns false.
 * - Without children it is the gallery: seven cards in a masonry (stats, a chat, a player, a list
 *   of people, an article with its photo, a portfolio, a photo strip), each in its own frame,
 *   each with its own latency, so they come in one after another as their data "arrives".
 *   Reload fetches it all again. While on screen and untouched, a demo pointer types a reply,
 *   plays the track and reloads; any press or key hands it to the reader for good.
 *   autoplay={false} shows the cards loaded, as content rendered with its data would.
 * - Light or dark: every colour is a light-dark() token in the CSS, so the scheme is the page's
 *   color-scheme, or the one the colorScheme prop sets.
 */

type Card = 'stats' | 'chat' | 'player' | 'people' | 'article' | 'portfolio' | 'photos';

/** How long each card's data takes to arrive, in ms: they land in a loose order, as fetches do. */
const LATENCY: Record<Card, number> = {
  people: 900,
  stats: 1040,
  player: 1180,
  chat: 1300,
  article: 1450,
  portfolio: 1560,
  photos: 1700,
};
const CARDS = Object.keys(LATENCY) as Card[];
/** The reply the demo types. */
const REPLY = 'What about server rendering?';

type Props = {
  className?: string;
  /** With children: the content to load. Without: the gallery of cards. */
  children?: ReactNode;
  /** With children, required: true holds the skeleton, false reveals. In the gallery: forces every card. */
  loading?: boolean;
  /** How each piece comes in: a soft wipe from the left with a blur (default), a blur, a fade, or none. */
  reveal?: Reveal;
  /** How the bones move while loading: one diagonal sweep in sync (default), a pulse, or none. */
  shimmer?: Shimmer;
  /** Ms from a frame's first piece revealing to its last one. */
  stagger?: number;
  /** Ms each piece's reveal takes. */
  duration?: number;
  /** Data that arrives sooner than this, in ms, shows at once. */
  showAfter?: number;
  /** With children: say “Loading” and “Loaded” in a polite live region (default true). */
  announce?: boolean;
  /** Called once every piece is shown (the gallery: every card). */
  onRevealed?: () => void;
  /** The gallery: load on its own once on screen and let a demo pointer try it (default true). */
  autoplay?: boolean;
  colorScheme?: 'light' | 'dark' | 'system';
};

export function AutoSkeleton({ children, ...props }: Props) {
  if (children !== undefined)
    return (
      <SkeletonFrame {...props} loading={props.loading ?? false}>
        {children}
      </SkeletonFrame>
    );
  return <Gallery {...props} />;
}

function Gallery({
  className,
  loading,
  reveal = 'wipe',
  shimmer = 'sweep',
  stagger,
  duration,
  showAfter,
  onRevealed,
  autoplay = true,
  colorScheme = 'system',
}: Omit<Props, 'children'>) {
  const { ref: stage, take, playing, visible } = useAutoplay<HTMLDivElement>();
  const pointer = useRef<HTMLSpanElement>(null);
  const controlled = loading !== undefined;
  // Autoplaying, the cards start as skeletons and load once on screen; otherwise they start loaded.
  const [pending, setPending] = useState<Set<Card>>(() =>
    autoplay && !controlled ? new Set(CARDS) : new Set(),
  );
  const [started, setStarted] = useState(!autoplay || controlled);
  const [revealed, setRevealed] = useState<Set<Card>>(() => new Set(autoplay ? [] : CARDS));
  const [round, setRound] = useState(0);
  const [draft, setDraft] = useState('');
  const [music, setMusic] = useState(false);
  const [at, setAt] = useState(PLAYER.at);
  const timers = useRef<number[]>([]);

  const isLoading = (card: Card) => (controlled ? loading : pending.has(card));
  const allShown = !CARDS.some(isLoading) && revealed.size === CARDS.length;

  /** Fetches every card again: each one's data lands after its own latency. */
  const load = () => {
    timers.current.forEach((timer) => window.clearTimeout(timer));
    setPending(new Set(CARDS));
    setRevealed(new Set());
    setDraft('');
    setMusic(false);
    setAt(PLAYER.at);
    setRound((value) => value + 1);
    timers.current = CARDS.map((card) =>
      window.setTimeout(
        () =>
          setPending((current) => {
            const next = new Set(current);
            next.delete(card);
            return next;
          }),
        LATENCY[card],
      ),
    );
  };

  // The first load starts once the gallery is on screen.
  useEffect(() => {
    if (started || !visible) return;
    // Being on screen is outside React (an IntersectionObserver): this is where it lands.
    // eslint-disable-next-line react-hooks/set-state-in-effect
    setStarted(true);
    load();
    // load only sets state and timers; it is the same on every render.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [started, visible]);
  useEffect(() => () => timers.current.forEach((timer) => window.clearTimeout(timer)), []);

  // The track plays on while it is shown.
  useEffect(() => {
    if (!music || !visible) return;
    const timer = window.setInterval(
      () => setAt((value) => (value + 1 >= PLAYER.length ? 0 : value + 1)),
      1000,
    );
    return () => window.clearInterval(timer);
  }, [music, visible]);

  const shown = (card: Card) => () => {
    setRevealed((current) => new Set(current).add(card));
  };
  const reported = useRef(false);
  useEffect(() => {
    if (!allShown) reported.current = false;
    else if (!reported.current) {
      reported.current = true;
      onRevealed?.();
    }
  }, [allShown, onRevealed]);

  // The demo: once every card is in, the pointer types a reply, plays the track, then reloads.
  const script = useEffectEvent(async (demo: Demo) => {
    const element = stage.current;
    if (!element) return;
    const spot = (selector: string) => {
      const target = element.querySelector<HTMLElement>(selector);
      if (!target) return null;
      const box = element.getBoundingClientRect();
      const scale = box.width / element.offsetWidth || 1;
      const rect = target.getBoundingClientRect();
      const y = (rect.top + rect.height / 2 - box.top) / scale;
      // A control below the stage's visible part (a narrow stage stacks the cards) is skipped.
      if (y < 0 || y > element.offsetHeight) return null;
      return { target, x: (rect.left + rect.width / 2 - box.left) / scale, y };
    };
    const press = async (selector: string) => {
      const at = spot(selector);
      if (!at) return null;
      await demo.glide(at, 640);
      demo.glyph('hand');
      await demo.wait(200);
      at.target.click();
      await demo.wait(300);
      demo.glyph('arrow');
      return at;
    };
    await demo.wait(900);
    const field = await press('[aria-label="Reply"]');
    if (field) {
      for (let i = 1; i <= REPLY.length; i += 1) {
        setDraft(REPLY.slice(0, i));
        await demo.wait(i % 7 === 0 ? 130 : 48);
      }
      await demo.wait(500);
    }
    await press('[data-control="play"]');
    await demo.wait(1400);
    // Reload is pressed by hand, without its click: a click there is the reader's, and ends the demo.
    const reload = spot('[data-part="reload"]');
    if (!reload) return load();
    await demo.glide(reload, 640);
    demo.glyph('hand');
    await demo.wait(220);
    load();
  });

  useEffect(() => {
    const element = stage.current;
    const hand = pointer.current;
    if (!autoplay || controlled || !playing || !allShown || !element || !hand) return;
    return runDemo(element, hand, script);
  }, [autoplay, controlled, playing, allShown, stage]);

  const frame = (card: Card, node: ReactNode) => (
    <SkeletonFrame
      key={`${card}-${round}`}
      loading={isLoading(card) ?? false}
      reveal={reveal}
      shimmer={shimmer}
      stagger={stagger}
      duration={duration}
      showAfter={showAfter}
      onRevealed={shown(card)}
      // The gallery speaks once for all its cards.
      announce={false}
      className={styles[`at_${card}`]}
    >
      {node}
    </SkeletonFrame>
  );
  const busy = CARDS.some(isLoading);

  return (
    // The stage only listens for the reader's first input, to hand the demo over; it is no control.
    // eslint-disable-next-line jsx-a11y/no-static-element-interactions
    <div
      ref={stage}
      className={`${styles.root} ${className ?? ''}`}
      data-color-scheme={colorScheme === 'system' ? undefined : colorScheme}
      data-part="stage"
      onPointerDown={(event) => {
        if (event.isPrimary) take();
      }}
      onKeyDown={take}
    >
      <div className={styles.masonry} data-part="masonry">
        <div className={styles.column}>
          {frame(
            'article',
            <ArticleCard data={isLoading('article') ? ARTICLE_PLACEHOLDER : ARTICLE} />,
          )}
          {frame('photos', <PhotosCard data={PHOTOS} />)}
        </div>
        <div className={styles.column}>
          {frame(
            'chat',
            <ChatCard
              data={isLoading('chat') ? CHAT_PLACEHOLDER : CHAT}
              draft={draft}
              onDraft={setDraft}
            />,
          )}
          {frame('stats', <StatsCard data={isLoading('stats') ? STATS_PLACEHOLDER : STATS} />)}
        </div>
        <div className={styles.column}>
          {frame('people', <PeopleCard data={isLoading('people') ? PEOPLE_PLACEHOLDER : PEOPLE} />)}
          {frame(
            'player',
            <PlayerCard
              data={isLoading('player') ? PLAYER_PLACEHOLDER : PLAYER}
              playing={music}
              onPlaying={setMusic}
              at={isLoading('player') ? PLAYER_PLACEHOLDER.at : at}
            />,
          )}
          {frame(
            'portfolio',
            <PortfolioCard data={isLoading('portfolio') ? PORTFOLIO_PLACEHOLDER : PORTFOLIO} />,
          )}
        </div>
      </div>
      {!controlled && (
        <button
          type="button"
          className={styles.reload}
          // aria-disabled, not disabled: a pressed Reload keeps the focus while the cards load.
          onClick={() => {
            if (!busy) load();
          }}
          aria-disabled={busy}
          data-part="reload"
        >
          <Icon name="reload" />
          Reload
        </button>
      )}
      <p className={styles.hidden} role="status">
        {busy ? 'Loading' : allShown && round > 0 ? 'Loaded' : ''}
      </p>
      <div className={styles.pointerLayer} aria-hidden="true">
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
    </div>
  );
}
```

### auto-skeleton/skeleton.tsx

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

'use client';

import {
  useEffect,
  useLayoutEffect,
  useRef,
  useState,
  type CSSProperties,
  type ReactNode,
} from 'react';
import styles from './auto-skeleton.module.css';

/*
 * Skeleton frame: the loading state of any piece of interface, drawn from the piece itself.
 *
 * - The children are always rendered, in their place. While loading they hold placeholder data
 *   (whatever the caller passes them before the real data is there) and are invisible
 *   (visibility: hidden, and inert), but still laid out, so they set the frame's size and can be
 *   measured. Nothing moves when the real content arrives.
 * - The skeleton is read from that invisible DOM, with no markers and no build step. Every leaf
 *   becomes a bone at its exact place: a line of text becomes a bar as wide as its words on that
 *   line (one per line, from a Range's client rects) and three quarters of its font size tall; an
 *   image, an SVG icon, a field, or an element that paints a background around nothing but text
 *   (a bubble, a button, a chip, an avatar with initials) becomes a block with its own corner
 *   radius. Elements that paint a background around other pieces (the card, a tile, a track) are
 *   surfaces: they are drawn as they are, so the skeleton keeps the content's chrome.
 *   data-skeleton="skip" leaves an element out, "block" makes it one block, "keep" draws it as is.
 * - The bones shimmer in sync: every bone holds a frame-sized diagonal band placed back by its
 *   own offset and moved by a transform (on the compositor), all on one timing, so the band
 *   crosses the whole frame as one. Frames started at different times line up on the same clock (the
 *   animation's negative delay is the time now, modulo the period).
 * - Revealing, each piece comes in on its own, staggered by where it is (top to bottom, then left
 *   to right): its content is wiped in from the left behind a soft 32 px edge while it sharpens
 *   from a 4 px blur, and its bone is wiped out by the same edge, so the bar seems to turn into
 *   the words. The wipe is a registered <length-percentage> (--wipe) inside a mask gradient,
 *   animated with the Web Animations API. `reveal` picks the wipe, a blur, a fade or none.
 * - Content that was never loading (rendered on the server with its data) shows at once; data
 *   that arrives within `showAfter` ms shows at once too, before any bone was drawn. An image that
 *   is still loading keeps its bone until it has loaded, then fades in.
 * - The frame is aria-busy while loading, and a polite status says "Loading", then "Loaded"
 *   (announce={false} leaves that to the host). Under reduced motion the bones hold still and the
 *   content shows at once.
 */

export type Reveal = 'wipe' | 'blur' | 'fade' | 'none';
export type Shimmer = 'sweep' | 'pulse' | 'none';

export type SkeletonFrameProps = {
  /** True holds the skeleton; false reveals the content. */
  loading: boolean;
  children: ReactNode;
  /** How each piece comes in (default 'wipe'). */
  reveal?: Reveal;
  /** How the bones move while loading (default 'sweep'). */
  shimmer?: Shimmer;
  /** Ms from the first piece's reveal (top left) to the last one's (bottom right). */
  stagger?: number;
  /** Ms each piece's reveal takes. */
  duration?: number;
  /** Data that arrives sooner than this, in ms, shows at once, with no skeleton and no reveal. */
  showAfter?: number;
  /** Speak "Loading" and "Loaded" in a polite live region (default true). */
  announce?: boolean;
  /** Called once every piece is shown. */
  onRevealed?: () => void;
  className?: string;
};

type Phase = 'loading' | 'revealing' | 'shown';
type Bone = {
  x: number;
  y: number;
  w: number;
  h: number;
  r: string;
  media: boolean;
  /** A line of text, a painted block, or an image, icon or field. */
  kind: 'text' | 'block' | 'media';
  /** The element it stands for, when it is one block (an image waits for it to load). */
  source?: Element;
};
type Surface = { x: number; y: number; w: number; h: number; style: CSSProperties };
type Shape = { w: number; h: number; bones: Bone[]; surfaces: Surface[] };
/** An element that is revealed as one piece, and where it is. */
type Target = { element: HTMLElement | SVGElement; x: number; y: number; media: boolean };

/** The shimmer's period, in ms (the CSS animation's duration). */
const PERIOD = 1600;
/** The wipe's soft edge, in px (the CSS masks draw the same). */
const EDGE = 32;
/** The pieces' easing: quick to start, long to settle. */
const EASE = 'cubic-bezier(0.22, 0.61, 0.36, 1)';
/** Elements drawn as one block whatever they hold. */
const MEDIA = new Set(['IMG', 'SVG', 'CANVAS', 'VIDEO', 'PICTURE', 'INPUT', 'TEXTAREA', 'SELECT']);
/** The chrome a surface copies from its element. */
const CHROME = [
  'background-color',
  'background-image',
  'background-size',
  'background-position',
  'background-repeat',
  'border-top',
  'border-right',
  'border-bottom',
  'border-left',
  'border-radius',
  'box-shadow',
] as const;

const camel = (name: string) =>
  name.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());

/** Whether a computed colour paints nothing: transparent, or an alpha of 0. */
const clear = (colour: string) =>
  colour === 'transparent' || /[,/]\s*0\)$/.test(colour) || colour === '';

/** Whether an element paints a background (a colour or an image). */
const fills = (style: CSSStyleDeclaration) =>
  !clear(style.backgroundColor) || style.backgroundImage !== 'none';

/** Whether an element draws a visible border on any side. */
const edged = (style: CSSStyleDeclaration) =>
  (['Top', 'Right', 'Bottom', 'Left'] as const).some(
    (side) =>
      parseFloat(style.getPropertyValue(`border-${side.toLowerCase()}-width`)) > 0 &&
      style.getPropertyValue(`border-${side.toLowerCase()}-style`) !== 'none' &&
      !clear(style.getPropertyValue(`border-${side.toLowerCase()}-color`)),
  );

const isMedia = (element: Element) =>
  MEDIA.has(element.tagName.toUpperCase()) ||
  (element as HTMLElement).dataset?.skeleton === 'block';

/** Whether an element holds anything that paints, below itself: then it is a surface. */
function holdsPaint(element: Element): boolean {
  for (const child of element.children) {
    const data = (child as HTMLElement).dataset?.skeleton;
    if (data === 'skip') continue;
    if (isMedia(child)) return true;
    const style = getComputedStyle(child);
    if (style.display === 'none') continue;
    if (fills(style) || edged(style) || holdsPaint(child)) return true;
  }
  return false;
}

const hasText = (element: Element) => (element.textContent ?? '').trim().length > 0;

/** Whether an element lays out children of its own (block, flex, grid): then it is a surface. */
const holdsBlocks = (element: Element) =>
  Array.from(element.children).some((child) => {
    const display = getComputedStyle(child).display;
    return display !== 'none' && display !== 'contents' && !display.startsWith('inline');
  });

/**
 * Reads the skeleton from the content: bones, surfaces, and the elements the reveal animates,
 * all in the content box's own px (a zoomed or scaled frame is brought back by `scale`).
 */
function read(content: HTMLElement) {
  const box = content.getBoundingClientRect();
  const scale = box.width / (content.offsetWidth || 1) || 1;
  const place = (rect: DOMRect) => ({
    x: (rect.left - box.left) / scale,
    y: (rect.top - box.top) / scale,
    w: rect.width / scale,
    h: rect.height / scale,
  });
  const bones: Bone[] = [];
  const surfaces: Surface[] = [];
  const targets: Target[] = [];
  const range = document.createRange();

  const block = (element: HTMLElement | SVGElement, style: CSSStyleDeclaration, media: boolean) => {
    const at = place(element.getBoundingClientRect());
    if (at.w < 1 || at.h < 1) return;
    const kind = MEDIA.has(element.tagName.toUpperCase()) ? 'media' : 'block';
    bones.push({ ...at, r: style.borderRadius || '0px', media, kind, source: element });
    targets.push({ element, x: at.x, y: at.y, media });
  };

  const walk = (element: HTMLElement | SVGElement) => {
    const mode = element.dataset?.skeleton;
    if (mode === 'skip') return;
    const style = getComputedStyle(element);
    // Not visibility: the whole content is visibility: hidden while it is read.
    if (style.display === 'none' || style.opacity === '0') return;
    if (isMedia(element)) return block(element, style, element.tagName === 'IMG');
    const paints = fills(style) || edged(style);
    const around =
      holdsPaint(element) || holdsBlocks(element) || (!hasText(element) && !fills(style));
    if (mode === 'keep' || (paints && around)) {
      const at = place(element.getBoundingClientRect());
      const chrome: Record<string, string> = {};
      for (const name of CHROME) chrome[camel(name)] = style.getPropertyValue(name);
      surfaces.push({ ...at, style: chrome as CSSProperties });
    } else if (paints) {
      // A painted element around nothing but text, or around nothing: one block.
      return block(element, style, false);
    }
    let lines = false;
    for (const node of element.childNodes) {
      if (node.nodeType === Node.ELEMENT_NODE) {
        walk(node as HTMLElement);
      } else if (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim()) {
        range.selectNodeContents(node);
        // Text cut off by its box (an ellipsis) is drawn only as far as the box.
        const clip = style.overflowX !== 'visible' ? place(element.getBoundingClientRect()) : null;
        const size = parseFloat(style.fontSize) || 14;
        const h = Math.max(6, Math.round(size * 0.75));
        for (const rect of range.getClientRects()) {
          const at = place(rect);
          if (clip) at.w = Math.min(at.x + at.w, clip.x + clip.w) - at.x;
          if (at.w < 2) continue;
          bones.push({
            x: at.x,
            y: at.y + (at.h - h) / 2,
            w: at.w,
            h,
            r: `${Math.min(h / 2, Math.max(3, Math.round(h * 0.4)))}px`,
            media: false,
            kind: 'text',
          });
          if (!lines) {
            lines = true;
            // The text's own element is what fades in; a surface around it shows at once.
            if (!paints) targets.push({ element, x: at.x, y: at.y, media: false });
          }
        }
      }
    }
  };

  for (const child of content.children) walk(child as HTMLElement);
  return { w: content.offsetWidth, h: content.offsetHeight, bones, surfaces, targets };
}

/** Whether the reader prefers reduced motion; read when it is needed. */
const prefersReduced = () =>
  typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;

export function SkeletonFrame({
  loading,
  children,
  reveal = 'wipe',
  shimmer = 'sweep',
  stagger = 360,
  duration = 320,
  showAfter = 120,
  announce = true,
  onRevealed,
  className,
}: SkeletonFrameProps) {
  const content = useRef<HTMLDivElement>(null);
  const layer = useRef<HTMLDivElement>(null);
  const [phase, setPhase] = useState<Phase>(loading ? 'loading' : 'shown');
  const [shape, setShape] = useState<Shape | null>(null);
  // What the live region says: nothing until the frame has loaded something.
  const [status, setStatus] = useState(loading ? 'Loading' : '');
  const started = useRef(0);
  const revealedRef = useRef(onRevealed);
  useEffect(() => {
    revealedRef.current = onRevealed;
  });

  // The phase follows `loading`: data that came back quickly, or nothing to animate, shows at once.
  const phaseRef = useRef(phase);
  useLayoutEffect(() => {
    phaseRef.current = phase;
  }, [phase]);
  useLayoutEffect(() => {
    if (loading) {
      started.current = performance.now();
      // The phase must turn with the prop before the next paint, so the content never flashes.
      // eslint-disable-next-line react-hooks/set-state-in-effect
      setPhase('loading');
      setStatus('Loading');
      return;
    }
    if (phaseRef.current !== 'loading') return;
    const quick = performance.now() - started.current < showAfter;
    if (quick || reveal === 'none' || prefersReduced()) {
      setPhase('shown');
      setStatus('Loaded');
      revealedRef.current?.();
    } else {
      setPhase('revealing');
    }
  }, [loading, reveal, showAfter]);

  // Loading: the skeleton is read from the invisible content, and again whenever it resizes.
  useLayoutEffect(() => {
    const element = content.current;
    if (phase !== 'loading' || !element) return;
    let frame = 0;
    const measure = () => {
      const { w, h, bones, surfaces } = read(element);
      setShape({ w, h, bones, surfaces });
    };
    measure();
    const later = () => {
      cancelAnimationFrame(frame);
      frame = requestAnimationFrame(measure);
    };
    const observer = new ResizeObserver(later);
    observer.observe(element);
    document.fonts?.ready.then(later);
    return () => {
      observer.disconnect();
      cancelAnimationFrame(frame);
    };
  }, [phase]);

  // Revealing: every piece of the content and every bone is animated, before the first paint.
  useLayoutEffect(() => {
    const element = content.current;
    if (phase !== 'revealing' || !element) return;
    const { w, h, targets } = read(element);
    // Where a piece is sets when it starts: down the frame, then a little along each line.
    const delayAt = (x: number, y: number) =>
      Math.round((Math.min(1, y / (h || 1)) * 0.85 + Math.min(1, x / (w || 1)) * 0.15) * stagger);
    const timing = (delay: number): KeyframeAnimationOptions => ({
      duration,
      delay,
      easing: EASE,
      fill: 'both',
    });
    const wipeIn: Keyframe[] = [
      { '--wipe': '0%', filter: 'blur(4px)' },
      { '--wipe': `calc(100% + ${EDGE}px)`, filter: 'blur(0px)' },
    ];
    const wipeOut: Keyframe[] = [{ '--wipe': '0%' }, { '--wipe': `calc(100% + ${EDGE}px)` }];
    const fadeIn: Keyframe[] =
      reveal === 'blur'
        ? [
            { opacity: 0, filter: 'blur(8px)' },
            { opacity: 1, filter: 'blur(0px)' },
          ]
        : [{ opacity: 0 }, { opacity: 1 }];
    const fadeOut: Keyframe[] = [{ opacity: 1 }, { opacity: 0 }];
    const animations: Animation[] = [];
    const waits: Promise<unknown>[] = [];

    /** An image still loading keeps its bone, and fades in with it once it has loaded. */
    const whenLoaded = (source: Element | undefined, animation: Animation) => {
      if (!(source instanceof HTMLImageElement) || source.complete) return;
      animation.pause();
      const go = () => animation.play();
      source.addEventListener('load', go, { once: true });
      source.addEventListener('error', go, { once: true });
    };

    for (const target of targets) {
      const wipe = reveal === 'wipe' && !target.media;
      if (wipe) target.element.setAttribute('data-sk-wipe', '');
      const animation = target.element.animate(
        wipe ? wipeIn : target.media ? [{ opacity: 0 }, { opacity: 1 }] : fadeIn,
        timing(delayAt(target.x, target.y)),
      );
      whenLoaded(target.element, animation);
      animations.push(animation);
    }
    const bones = layer.current?.querySelectorAll<HTMLElement>('[data-bone]') ?? [];
    bones.forEach((bone) => {
      const x = Number(bone.dataset.x);
      const y = Number(bone.dataset.y);
      const media = bone.dataset.media === '';
      const animation = bone.animate(
        reveal === 'wipe' && !media ? wipeOut : fadeOut,
        timing(delayAt(x, y)),
      );
      if (media) whenLoaded(shape?.bones[Number(bone.dataset.index)]?.source, animation);
      animations.push(animation);
    });
    for (const animation of animations) waits.push(animation.finished);

    let alive = true;
    Promise.all(waits).then(
      () => {
        if (!alive) return;
        setPhase('shown');
        setStatus('Loaded');
        revealedRef.current?.();
      },
      () => {},
    );
    return () => {
      alive = false;
      animations.forEach((animation) => animation.cancel());
      element
        .querySelectorAll('[data-sk-wipe]')
        .forEach((piece) => piece.removeAttribute('data-sk-wipe'));
    };
    // The shape is read for the bones' sources only; it is settled before the reveal starts.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [phase, reveal, stagger, duration]);

  // Every frame's shimmer is on one clock: its band crosses each frame at the same moment.
  const [clock] = useState(() =>
    typeof performance === 'undefined' ? 0 : Math.round(performance.now() % PERIOD),
  );

  return (
    <div
      className={`${styles.frame} ${className ?? ''}`}
      data-phase={phase}
      data-shimmer={shimmer}
      data-part="frame"
      aria-busy={phase === 'loading'}
    >
      <div ref={content} className={styles.frameContent} inert={phase === 'loading'}>
        {children}
      </div>
      {phase !== 'shown' && shape && (
        <div
          ref={layer}
          className={styles.skeleton}
          aria-hidden="true"
          data-part="skeleton"
          style={
            {
              '--W': shape.w,
              '--H': shape.h,
              '--show-after': `${showAfter}ms`,
              '--clock': `${-clock}ms`,
            } as CSSProperties
          }
        >
          {phase === 'loading' &&
            shape.surfaces.map((surface, index) => (
              <div
                key={`s${index}`}
                className={styles.surface}
                style={{
                  ...surface.style,
                  left: surface.x,
                  top: surface.y,
                  width: surface.w,
                  height: surface.h,
                }}
              />
            ))}
          <div className={styles.bones}>
            {shape.bones.map((bone, index) => (
              <div
                key={index}
                className={styles.bone}
                data-bone=""
                data-index={index}
                data-part="bone"
                data-x={Math.round(bone.x)}
                data-y={Math.round(bone.y)}
                data-media={bone.media ? '' : undefined}
                data-kind={bone.kind}
                style={
                  {
                    left: bone.x,
                    top: bone.y,
                    width: bone.w,
                    height: bone.h,
                    borderRadius: bone.r,
                    '--x': bone.x,
                    '--y': bone.y,
                  } as CSSProperties
                }
              />
            ))}
          </div>
        </div>
      )}
      {announce && (
        <span className={styles.hidden} role="status">
          {status}
        </span>
      )}
    </div>
  );
}
```

### auto-skeleton/cards.tsx

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

'use client';

import { CoinMark, Face, Icon, Landscape, Lighthouse, type Coin, type Scene } from './art';
import styles from './auto-skeleton.module.css';

/*
 * The gallery's cards. Each one draws whatever data it is given: the real data once it has
 * arrived, or, while it loads, its placeholder, which has the same shape (the same rows, words of
 * about the same length). The skeleton frame around it reads its skeleton from that placeholder.
 * Nothing here knows about skeletons.
 */

/* Stats */

type Stat = { label: string; value: string; change: string; up: boolean };
export type StatsData = Stat[];

export const STATS: StatsData = [
  { label: 'Visitors', value: '12,480', change: '+12%', up: true },
  { label: 'Signups', value: '1,204', change: '+4%', up: true },
  { label: 'Churn', value: '2.1%', change: '-0.3%', up: false },
  { label: 'Revenue', value: '$9.6k', change: '+18%', up: true },
];
export const STATS_PLACEHOLDER: StatsData = [
  { label: 'Visits', value: '10,000', change: '+10%', up: true },
  { label: 'Signups', value: '1,000', change: '+1%', up: true },
  { label: 'Churn', value: '1.0%', change: '-0.1%', up: false },
  { label: 'Revenue', value: '$1.0k', change: '+10%', up: true },
];

export function StatsCard({ data }: { data: StatsData }) {
  return (
    <article className={styles.card} aria-label="This week" data-part="card">
      <div className={styles.stats}>
        {data.map((stat) => (
          <div key={stat.label} className={styles.tile}>
            <span className={styles.label}>{stat.label}</span>
            <span className={styles.figure}>{stat.value}</span>
            <span className={styles.chip} data-tone={stat.up ? 'up' : 'down'}>
              {stat.change}
            </span>
          </div>
        ))}
      </div>
    </article>
  );
}

/* Chat */

type Message = { from: 'me' | 'them'; text: string; skull?: boolean };
export type ChatData = Message[];

export const CHAT: ChatData = [
  { from: 'me', text: 'Wait, how does it know the content length?' },
  { from: 'them', text: 'it renders sample data invisibly' },
  {
    from: 'them',
    text: 'then measures each element and draws a skeleton in that shape while your content loads',
  },
  { from: 'me', text: 'Spooky' },
  { from: 'them', text: 'skeletons usually are', skull: true },
];
export const CHAT_PLACEHOLDER: ChatData = [
  { from: 'me', text: 'Wait, what does it read to know the size?' },
  { from: 'them', text: 'it draws your sample data unseen' },
  {
    from: 'them',
    text: 'then reads where each part sits and draws a bone in its place while the data loads',
  },
  { from: 'me', text: 'Eerie' },
  { from: 'them', text: 'bones usually are', skull: true },
];

export function ChatCard({
  data,
  draft,
  onDraft,
}: {
  data: ChatData;
  draft: string;
  onDraft: (value: string) => void;
}) {
  return (
    <article className={styles.card} aria-label="Conversation" data-part="card">
      <ul className={styles.thread}>
        {data.map((message, index) => (
          <li key={index} className={styles.bubble} data-from={message.from}>
            {message.text}
            {message.skull && (
              // One block with its bubble: the skull is part of the words.
              <span className={styles.skull} data-skeleton="skip">
                <Icon name="skull" />
              </span>
            )}
          </li>
        ))}
      </ul>
      <form
        className={styles.composer}
        onSubmit={(event) => {
          event.preventDefault();
          onDraft('');
        }}
      >
        <input
          className={styles.field}
          value={draft}
          onChange={(event) => onDraft(event.target.value)}
          placeholder="Write a reply"
          aria-label="Reply"
        />
        <button type="submit" className={styles.send}>
          Send
        </button>
      </form>
    </article>
  );
}

/* Player */

export type PlayerData = { title: string; artist: string; at: number; length: number };

export const PLAYER: PlayerData = {
  title: 'Skeletons',
  artist: 'The Hollow Frames',
  at: 72,
  length: 214,
};
export const PLAYER_PLACEHOLDER: PlayerData = {
  title: 'Song title',
  artist: 'Artist name',
  at: 60,
  length: 200,
};

const clock = (seconds: number) =>
  `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, '0')}`;

export function PlayerCard({
  data,
  playing,
  onPlaying,
  at,
}: {
  data: PlayerData;
  playing: boolean;
  onPlaying: (playing: boolean) => void;
  /** The playhead, in seconds, once playing has moved it. */
  at: number;
}) {
  const share = Math.min(1, at / data.length);
  return (
    <article className={styles.card} aria-label="Now playing" data-part="card">
      <div className={styles.track}>
        <span className={styles.cover} />
        <span className={styles.trackText}>
          <span className={styles.title}>{data.title}</span>
          <span className={styles.muted}>{data.artist}</span>
        </span>
      </div>
      <div
        className={styles.progress}
        role="progressbar"
        aria-label="Playback"
        aria-valuemin={0}
        aria-valuemax={data.length}
        aria-valuenow={Math.round(at)}
        aria-valuetext={`${clock(at)} of ${clock(data.length)}`}
      >
        <span className={styles.played} style={{ width: `${share * 100}%` }} />
      </div>
      <span className={styles.time}>{clock(at)}</span>
      <div className={styles.controls}>
        <button type="button" className={styles.control} aria-label="Previous track">
          <Icon name="prev" />
        </button>
        <button
          type="button"
          className={styles.control}
          data-control="play"
          aria-label={playing ? 'Pause' : 'Play'}
          onClick={() => onPlaying(!playing)}
        >
          <Icon name={playing ? 'pause' : 'play'} />
        </button>
        <button type="button" className={styles.control} aria-label="Next track">
          <Icon name="next" />
        </button>
      </div>
    </article>
  );
}

/* Presence */

type Person = { name: string; initials?: string; text: string };
export type PeopleData = Person[];

export const PEOPLE: PeopleData = [
  { name: 'Odin Hale', text: 'The skeletons shimmer in sync now, across every card' },
  { name: 'Juno Sato', initials: 'JS', text: 'Naming things is the hardest part, again' },
];
export const PEOPLE_PLACEHOLDER: PeopleData = [
  { name: 'Full name', text: 'A line of their last message, cut short here' },
  { name: 'Full name', initials: 'AB', text: 'Another message preview that runs past the edge' },
];

export function PeopleCard({ data }: { data: PeopleData }) {
  return (
    <article className={styles.card} aria-label="Messages" data-part="card">
      <ul className={styles.people}>
        {data.map((person, index) => (
          <li key={index} className={styles.person}>
            {person.initials ? (
              <span className={styles.initials} aria-hidden="true">
                {person.initials}
              </span>
            ) : (
              <span className={styles.face}>
                <Face />
              </span>
            )}
            <span className={styles.personText}>
              <span className={styles.name}>{person.name}</span>
              <span className={styles.preview}>{person.text}</span>
            </span>
          </li>
        ))}
      </ul>
    </article>
  );
}

/* Article */

export type ArticleData = { title: string; body: string; author: string; read: string };

export const ARTICLE: ArticleData = {
  title: 'Low tide at Cape Veil',
  body: 'Twice a day the sea at Cape Veil pulls back almost a mile, and the old lighthouse stands on wet sand instead of rock. Walkers cross to it at dusk, timing the return by the bell on the harbour wall, while the keepers’ cottage, empty since 1970, catches the last of the light.',
  author: 'Ines Moreau',
  read: '6 min read',
};
export const ARTICLE_PLACEHOLDER: ArticleData = {
  title: 'An article title goes here',
  body: 'A paragraph of the story’s opening lines runs here, about as long as the real one, so the lines it wraps into are the lines the reader will see when the text arrives, give or take a word at the end of each line, and the card keeps its height.',
  author: 'Author name',
  read: '5 min read',
};

export function ArticleCard({ data }: { data: ArticleData }) {
  return (
    <article className={styles.card} aria-label={data.title} data-part="card">
      <Landscape scene="tide" className={styles.photo}>
        <Lighthouse />
      </Landscape>
      <h3 className={styles.heading}>{data.title}</h3>
      <p className={styles.body}>{data.body}</p>
      <div className={styles.byline}>
        <span>{data.author}</span>
        <span className={styles.muted}>{data.read}</span>
      </div>
    </article>
  );
}

/* Portfolio */

type Holding = { coin: Coin; symbol: string; name: string; value: string };
export type PortfolioData = { total: string; change: string; holdings: Holding[] };

export const PORTFOLIO: PortfolioData = {
  total: '$4,974.06',
  change: '-1.10%',
  holdings: [
    { coin: 'nova', symbol: 'NOVA', name: 'Nova', value: '$2,541.18' },
    { coin: 'orbit', symbol: 'ORB', name: 'Orbit Dollar', value: '$1,366.40' },
    { coin: 'kelp', symbol: 'KELP', name: 'Kelp', value: '$1,066.48' },
  ],
};
export const PORTFOLIO_PLACEHOLDER: PortfolioData = {
  total: '$0,000.00',
  change: '-0.00%',
  holdings: [
    { coin: 'nova', symbol: 'AAA', name: 'Token', value: '$0,000.00' },
    { coin: 'orbit', symbol: 'BBB', name: 'Token name', value: '$0,000.00' },
    { coin: 'kelp', symbol: 'CCC', name: 'Token', value: '$0,000.00' },
  ],
};

export function PortfolioCard({ data }: { data: PortfolioData }) {
  return (
    <article className={styles.card} aria-label="Portfolio" data-part="card">
      <span className={styles.label}>Portfolio</span>
      <span className={styles.total}>{data.total}</span>
      <span className={styles.chip} data-tone="down">
        {data.change}
      </span>
      <ul className={styles.holdings}>
        {data.holdings.map((holding) => (
          <li key={holding.coin} className={styles.holding}>
            <span className={styles.coin}>
              <CoinMark coin={holding.coin} />
            </span>
            <span className={styles.personText}>
              <span className={styles.name}>{holding.symbol}</span>
              <span className={styles.muted}>{holding.name}</span>
            </span>
            <span className={styles.amount}>{holding.value}</span>
          </li>
        ))}
      </ul>
    </article>
  );
}

/* Photos */

export type PhotosData = Scene[];
export const PHOTOS: PhotosData = ['coast', 'dusk', 'mist', 'lake', 'glacier', 'forest'];

export function PhotosCard({ data }: { data: PhotosData }) {
  return (
    <article className={styles.card} aria-label="Album: Coastlines" data-part="card">
      <div className={styles.photos}>
        {data.map((scene) => (
          <Landscape key={scene} scene={scene} className={styles.thumb} />
        ))}
      </div>
    </article>
  );
}
```

### auto-skeleton/art.tsx

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

import { useId, type ReactNode } from 'react';

/*
 * Everything the gallery's cards show that is not text, drawn here: the landscapes of the article
 * and the photo strip (gradient skies, layered hills and water in SVG), the token coins, the
 * avatars, the album cover's colours and the player's icons. No photos, no icon set.
 */

export type Scene = 'tide' | 'coast' | 'dusk' | 'mist' | 'lake' | 'glacier' | 'forest';

type Palette = {
  sky: [string, string];
  sun?: string;
  far: string;
  near: string;
  water?: [string, string];
};

const SCENES: Record<Scene, Palette> = {
  tide: {
    sky: ['#2b3a55', '#d9a77f'],
    sun: '#ffd9a8',
    far: '#3e4b63',
    near: '#1c2333',
    water: ['#7c7f93', '#2a3247'],
  },
  coast: {
    sky: ['#9fb8c9', '#e8eef0'],
    far: '#5f7a72',
    near: '#2f4038',
    water: ['#4f8aa3', '#1f4c63'],
  },
  dusk: {
    sky: ['#4a5e86', '#f0c39a'],
    sun: '#fff1d6',
    far: '#6b7690',
    near: '#3a4157',
    water: ['#c8a990', '#59627c'],
  },
  mist: { sky: ['#cfc6c0', '#efe8e3'], far: '#b6aaa4', near: '#8c7f79' },
  lake: {
    sky: ['#6e9cc0', '#d7e7ef'],
    far: '#5d7e93',
    near: '#36505f',
    water: ['#2f6f8f', '#173a4d'],
  },
  glacier: { sky: ['#b9cde0', '#f4f7fa'], far: '#e9eef3', near: '#9fb2c4' },
  forest: { sky: ['#5e7d62', '#c7d6b4'], far: '#3f5a45', near: '#1f3326' },
};

/** A landscape that fills its box (slice): sky, a sun when it has one, two ridges and water. */
export function Landscape({
  scene,
  className,
  children,
}: {
  scene: Scene;
  className?: string;
  /** Drawn over the scenery, in the same 160 × 100 box (the article's lighthouse). */
  children?: ReactNode;
}) {
  const id = useId();
  const p = SCENES[scene];
  return (
    <svg
      className={className}
      viewBox="0 0 160 100"
      preserveAspectRatio="xMidYMid slice"
      role="img"
      aria-label={LABELS[scene]}
    >
      <defs>
        <linearGradient id={`${id}s`} x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor={p.sky[0]} />
          <stop offset="1" stopColor={p.sky[1]} />
        </linearGradient>
        {p.water && (
          <linearGradient id={`${id}w`} x1="0" y1="0" x2="0" y2="1">
            <stop offset="0" stopColor={p.water[0]} />
            <stop offset="1" stopColor={p.water[1]} />
          </linearGradient>
        )}
        <radialGradient id={`${id}g`} cx="0.5" cy="0.5" r="0.5">
          <stop offset="0" stopColor={p.sun ?? '#fff'} stopOpacity="0.9" />
          <stop offset="1" stopColor={p.sun ?? '#fff'} stopOpacity="0" />
        </radialGradient>
      </defs>
      <rect width="160" height="100" fill={`url(#${id}s)`} />
      {p.sun && (
        <>
          <circle cx="112" cy="58" r="26" fill={`url(#${id}g)`} />
          <circle cx="112" cy="58" r="7" fill={p.sun} />
        </>
      )}
      {scene === 'forest' ? (
        <>
          <path d="M0 62 Q40 48 80 58 T160 54 V100 H0Z" fill={p.far} />
          {[8, 22, 38, 55, 70, 88, 104, 120, 138, 152].map((x, i) => (
            <path
              key={x}
              d={`M${x} ${48 + (i % 3) * 5} l-9 ${34 - (i % 2) * 4} h18z`}
              fill={p.near}
            />
          ))}
          <rect y="80" width="160" height="20" fill={p.near} />
        </>
      ) : scene === 'glacier' ? (
        <>
          <path d="M0 70 L30 38 L48 52 L76 24 L104 50 L124 36 L160 66 V100 H0Z" fill={p.near} />
          <path d="M76 24 L66 36 L76 34 L84 40 L90 37Z M30 38 L24 46 L34 44Z" fill={p.far} />
          <path d="M0 78 Q80 70 160 80 V100 H0Z" fill="#e3ebf2" />
        </>
      ) : (
        <>
          <path d="M0 58 Q24 44 48 52 T100 46 T160 54 V100 H0Z" fill={p.far} />
          <path
            d={
              scene === 'coast'
                ? 'M0 40 Q14 42 26 58 L36 72 H0Z'
                : 'M0 64 Q30 54 62 62 T120 60 T160 66 V100 H0Z'
            }
            fill={p.near}
          />
          {p.water && (
            <>
              <rect y="66" width="160" height="34" fill={`url(#${id}w)`} />
              {[72, 78, 85, 93].map((y, i) => (
                <path
                  key={y}
                  d={`M${10 + i * 14} ${y} h${40 - i * 4} M${92 - i * 6} ${y + 2} h${30 + i * 6}`}
                  stroke="#fff"
                  strokeOpacity={0.18 - i * 0.03}
                  strokeWidth="0.8"
                  strokeLinecap="round"
                />
              ))}
            </>
          )}
          {scene === 'coast' && <path d="M0 60 Q20 64 36 72 L0 80Z" fill="#e9f1f3" opacity="0.6" />}
          {scene === 'mist' && (
            <rect y="40" width="160" height="60" fill="#f3eeea" opacity="0.45" />
          )}
        </>
      )}
      {children}
    </svg>
  );
}

const LABELS: Record<Scene, string> = {
  tide: 'A lighthouse coast at low tide, the sun setting over wet sand',
  coast: 'A green headland over a blue bay',
  dusk: 'A calm sea at dusk under a pale sun',
  mist: 'Dunes fading into a pink mist',
  lake: 'A mountain lake under a clear sky',
  glacier: 'Snowy peaks over a frozen plain',
  forest: 'A ridge of dark pines',
};

/** The lighthouse that stands on the article's coast, inside a Landscape. */
export function Lighthouse() {
  return (
    <g>
      <path d="M30 66 L33 36 H39 L42 66Z" fill="#f1ece4" />
      <path d="M31.2 52 H40.8 L41.3 57 H30.7Z M32.4 41 H39.6 L40 45 H32Z" fill="#b84a3c" />
      <rect x="32" y="31" width="8" height="5" rx="1" fill="#ffe7b0" />
      <path d="M31 31 L36 26 L41 31Z" fill="#2b2f3b" />
      <path d="M22 66 Q36 60 52 66 Z" fill="#1c2333" />
    </g>
  );
}

export type Coin = 'nova' | 'orbit' | 'kelp';

/** A token's coin: a disc in its colour with its mark. */
export function CoinMark({ coin }: { coin: Coin }) {
  return (
    <svg viewBox="0 0 28 28" aria-hidden="true">
      {coin === 'nova' ? (
        <>
          <circle cx="14" cy="14" r="14" fill="#2c2c30" />
          <path d="M14 5 L19 14 L14 17 L9 14Z" fill="#f2f2f4" />
          <path d="M9 15.4 L14 18.4 L19 15.4 L14 23Z" fill="#b8b8c0" />
        </>
      ) : coin === 'orbit' ? (
        <>
          <circle cx="14" cy="14" r="14" fill="#2871d4" />
          <circle cx="14" cy="14" r="8.5" fill="none" stroke="#fff" strokeWidth="1.6" />
          <path
            d="M16.6 11.2c-.5-.9-1.5-1.4-2.6-1.4-1.5 0-2.6.8-2.6 2s1.1 1.6 2.6 1.9 2.8.8 2.8 2.1-1.2 2.1-2.8 2.1c-1.2 0-2.3-.6-2.8-1.6M14 8.6v1.2M14 18v1.3"
            fill="none"
            stroke="#fff"
            strokeWidth="1.4"
            strokeLinecap="round"
          />
        </>
      ) : (
        <>
          <circle cx="14" cy="14" r="14" fill="#8a7cf0" />
          <path
            d="M7.5 17.5 Q14 6 20.5 17.5"
            fill="none"
            stroke="#fff"
            strokeWidth="2.4"
            strokeLinecap="round"
          />
          <circle cx="11" cy="16.5" r="1.4" fill="#fff" />
          <circle cx="17" cy="16.5" r="1.4" fill="#fff" />
        </>
      )}
    </svg>
  );
}

/** A drawn face on a green disc: one of the two people in the presence card. */
export function Face() {
  return (
    <svg viewBox="0 0 32 32" aria-hidden="true">
      <circle cx="16" cy="16" r="16" fill="#35c46b" />
      <path d="M6 31 Q16 19 26 31Z" fill="#20384a" />
      <circle cx="16" cy="14" r="6.2" fill="#f0c4a2" />
      <path
        d="M9.6 13 Q10 6.5 16 6.6 Q22 6.5 22.4 13 Q20 9.6 16 10.2 Q12 9.6 9.6 13Z"
        fill="#3b2a22"
      />
    </svg>
  );
}

/** The player's icons, the skull in the chat and the reload arrow: strokes and fills in currentColor. */
export function Icon({ name }: { name: 'prev' | 'play' | 'pause' | 'next' | 'skull' | 'reload' }) {
  switch (name) {
    case 'prev':
      return (
        <svg viewBox="0 0 20 20" aria-hidden="true">
          <rect x="4" y="4.5" width="2.2" height="11" rx="1" fill="currentColor" />
          <path
            d="M16 4.8v10.4a.8.8 0 0 1-1.2.7L7.6 10.7a.8.8 0 0 1 0-1.4l7.2-5.2a.8.8 0 0 1 1.2.7z"
            fill="currentColor"
          />
        </svg>
      );
    case 'next':
      return (
        <svg viewBox="0 0 20 20" aria-hidden="true">
          <rect x="13.8" y="4.5" width="2.2" height="11" rx="1" fill="currentColor" />
          <path
            d="M4 4.8v10.4a.8.8 0 0 0 1.2.7l7.2-5.2a.8.8 0 0 0 0-1.4L5.2 4.1A.8.8 0 0 0 4 4.8z"
            fill="currentColor"
          />
        </svg>
      );
    case 'play':
      return (
        <svg viewBox="0 0 20 20" aria-hidden="true">
          <path
            d="M5.5 3.6v12.8a1 1 0 0 0 1.5.9l10-6.4a1 1 0 0 0 0-1.7L7 2.7a1 1 0 0 0-1.5.9z"
            fill="currentColor"
          />
        </svg>
      );
    case 'pause':
      return (
        <svg viewBox="0 0 20 20" aria-hidden="true">
          <rect x="4.5" y="3.5" width="4" height="13" rx="1.2" fill="currentColor" />
          <rect x="11.5" y="3.5" width="4" height="13" rx="1.2" fill="currentColor" />
        </svg>
      );
    case 'skull':
      return (
        <svg viewBox="0 0 16 16" aria-hidden="true">
          <path
            d="M8 1.6c-3.3 0-5.6 2.3-5.6 5.3 0 1.8.9 3.1 2.1 3.9v1.9c0 .5.4.9.9.9h5.2c.5 0 .9-.4.9-.9v-1.9c1.2-.8 2.1-2.1 2.1-3.9 0-3-2.3-5.3-5.6-5.3z"
            fill="currentColor"
          />
          <circle cx="5.8" cy="7.4" r="1.4" fill="var(--card)" />
          <circle cx="10.2" cy="7.4" r="1.4" fill="var(--card)" />
          <path d="M7.3 10.2h1.4M7 12.4v1.4M9 12.4v1.4" stroke="var(--card)" strokeWidth="0.9" />
        </svg>
      );
    case 'reload':
      return (
        <svg viewBox="0 0 16 16" aria-hidden="true">
          <path
            d="M12.6 8a4.6 4.6 0 1 1-1.4-3.3M12.6 2.6v2.6H10"
            fill="none"
            stroke="currentColor"
            strokeWidth="1.6"
            strokeLinecap="round"
            strokeLinejoin="round"
          />
        </svg>
      );
  }
}
```

### auto-skeleton/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 yet). 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 (auto-skeleton.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>
  );
}
```

### auto-skeleton/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). It also tells whether the element is on
 * screen in a visible tab, and whether the reader prefers reduced motion.
 */
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.2 },
    );
    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, visible, reduced, playing: visible && !reduced && !taken };
}
```

### auto-skeleton/auto-skeleton.module.css

```css
/* Auto skeleton (auto-skeleton.tsx, skeleton.tsx): a masonry of cards on a quiet stage, each one
   loading behind a skeleton read from its own shape, then revealed piece by piece.

   The skeleton. Bones are translucent ink (7% on light, 7.5% on dark), so they read on the card
   and on any tile inside it. The shimmer is one diagonal band (105°) that crosses the whole frame
   every 1.6 s: each bone holds a frame-sized gradient placed back by its own --x and --y, moved
   by a transform, so every bone shows its slice of the same band.

   The reveal. --wipe is a registered length that the script animates per piece (Web Animations
   API): the content's mask is opaque up to 32 px before it, the bone's mask is the reverse, so a
   soft 32 px edge runs left to right over each piece while its content sharpens from 4 px of blur.

   Colours are the tokens below, light-dark(light, dark): the component takes the color-scheme it
   inherits from the page, or the one its colorScheme prop sets. */

@property --wipe {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 0%;
}

.root,
.frame {
  --bone: light-dark(rgb(0 0 0 / 0.07), rgb(255 255 255 / 0.075));
  --sk-sheen: light-dark(rgb(255 255 255 / 0.8), rgb(255 255 255 / 0.075));
}
.root {
  --stage: light-dark(#f1f1f2, #000);
  --card: light-dark(#fff, #0d0d0e);
  --card-edge: light-dark(rgb(0 0 0 / 0.07), rgb(255 255 255 / 0.07));
  --tile: light-dark(#f5f5f6, #161617);
  --ink: light-dark(#121214, #f3f3f4);
  --muted: light-dark(#6b6b73, #8c8c93);
  --track: light-dark(rgb(0 0 0 / 0.1), rgb(255 255 255 / 0.14));
  --up: light-dark(#137a37, #4ade80);
  --up-bg: light-dark(rgb(22 163 74 / 0.12), rgb(74 222 128 / 0.13));
  --down: light-dark(#bf2d39, #f87171);
  --down-bg: light-dark(rgb(220 38 38 / 0.1), rgb(248 113 113 / 0.14));
  --them: light-dark(#f0f0f2, #1b1b1d);
  --initials: light-dark(#e7c6f1, #d29ae6);
  --initials-ink: #4f1f63;
  /* The same on both schemes: the sender's bubbles, the send button, focus and the pointer. */
  --me: #3866ee;
  --send: #f5a524;
  --send-ink: #1d1404;
  --focus: #387bff;
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.25);

  position: relative;
  container-type: inline-size;
  box-sizing: border-box;
  width: 100%;
  padding: 28px 24px 76px;
  border-radius: 20px;
  background: var(--stage);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
.root[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root :where(button) {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.root :where(button, input):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* The frame (skeleton.tsx) */

.frame {
  position: relative;
}
/* Loading, the content is laid out (it sets the size and is measured) but not seen or reached. */
.frame[data-phase='loading'] > .frameContent {
  visibility: hidden;
}
.skeleton {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Bones come in only after showAfter: data that lands sooner never shows a skeleton. */
.frame[data-phase='loading'] > .skeleton {
  animation: appear 200ms ease var(--show-after, 0ms) both;
}
@keyframes appear {
  from {
    opacity: 0;
  }
}
.surface,
.bone {
  position: absolute;
  box-sizing: border-box;
}
.bones {
  position: absolute;
  inset: 0;
}
.bone {
  background: var(--bone);
}
.frame[data-shimmer='sweep'] .bone {
  overflow: hidden;
}
/* The band: one frame-sized gradient behind every bone, placed back by the bone's own offset so
   all of them show slices of the same band; each moves it by a transform, on the compositor, on
   the same clock, so the slices stay one band. It sweeps from 0.8 of the frame's width before
   its place to 0.8 after. */
.frame[data-shimmer='sweep'] .bone::after {
  position: absolute;
  top: calc(var(--y) * -1px);
  left: calc(var(--x) * -1px);
  width: calc(var(--W) * 1px);
  height: calc(var(--H) * 1px);
  background: linear-gradient(105deg, transparent 35%, var(--sk-sheen) 50%, transparent 65%);
  animation: sweep 1600ms linear var(--clock, 0ms) infinite;
  content: '';
}
@keyframes sweep {
  from {
    transform: translateX(calc(var(--W) * -0.8px));
  }
  to {
    transform: translateX(calc(var(--W) * 0.8px));
  }
}
.frame[data-shimmer='pulse'] .bones {
  animation: pulse 1600ms ease-in-out var(--clock, 0ms) infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}
/* The wipe: content shows up to the soft edge, its bone from the soft edge on. */
.frame [data-sk-wipe] {
  mask-image: linear-gradient(90deg, #000 calc(var(--wipe) - 32px), transparent var(--wipe));
}
.frame[data-phase='revealing'] .bone:not([data-media]) {
  mask-image: linear-gradient(90deg, transparent calc(var(--wipe) - 32px), #000 var(--wipe));
}

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

/* The gallery: three columns of cards, as a masonry. */

.masonry {
  display: flex;
  gap: 16px;
  max-width: 1040px;
  margin: 0 auto;
}
.column {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  display: flex;
  box-sizing: border-box;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--card-edge);
  border-radius: 20px;
  background: var(--card);
}
.label {
  color: var(--muted);
  font-size: 11.5px;
}
.muted {
  color: var(--muted);
  font-size: 12px;
}
.chip {
  align-self: flex-start;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip[data-tone='up'] {
  background: var(--up-bg);
  color: var(--up);
}
.chip[data-tone='down'] {
  background: var(--down-bg);
  color: var(--down);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--tile);
}
.figure {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Chat */
.thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--them);
  font-size: 12.5px;
}
.bubble[data-from='me'] {
  align-self: flex-end;
  background: var(--me);
  color: #fff;
}
.bubble[data-from='them'] {
  align-self: flex-start;
}
.skull {
  display: inline-flex;
  width: 13px;
  height: 13px;
  margin-left: 4px;
  vertical-align: -2px;
}
.skull svg {
  width: 100%;
  height: 100%;
  --card: var(--them);
}
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--card-edge);
}
.field {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}
.field::placeholder {
  color: var(--muted);
}
.send {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--send);
  color: var(--send-ink);
  font-size: 12.5px;
  font-weight: 600;
}

/* Player */
.track {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cover {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8d6cf7, #f2748a);
}
.trackText,
.personText {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.title {
  font-size: 15px;
  font-weight: 600;
}
.progress {
  height: 3px;
  margin-top: 16px;
  border-radius: 2px;
  background: var(--track);
}
.played {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--ink);
  transition: width 1s linear;
}
.time {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.controls {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 4px;
}
.control {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
}
.control svg {
  width: 20px;
  height: 20px;
}
.control:hover {
  background: var(--tile);
}

/* People */
.people,
.holdings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.person,
.holding {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.face,
.initials,
.coin {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
}
.face svg,
.coin svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.initials {
  background: var(--initials);
  color: var(--initials-ink);
  font-size: 11px;
  font-weight: 600;
}
.name {
  font-size: 13px;
  font-weight: 600;
}
.preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Article */
.photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
}
.heading {
  margin: 14px 0 6px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.body {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.byline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
}

/* Portfolio */
.total {
  margin: 4px 0 8px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.holdings {
  margin-top: 18px;
}
.coin {
  width: 28px;
  height: 28px;
}
.amount {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Photos */
.photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 8px;
}

/* Reload, and the demo's pointer */
.reload {
  position: absolute;
  bottom: 20px;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  transform: translateX(-50%);
  transition: opacity 0.2s ease;
}
.reload svg {
  width: 14px;
  height: 14px;
}
.reload[aria-disabled='true'] {
  opacity: 0.5;
  cursor: default;
}
.pointerLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  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;
}

/* Narrow: one column of four cards, stats first, in the order a phone would show them. */
@container (max-width: 759.98px) {
  .root {
    padding: 16px 16px 68px;
  }
  .masonry {
    flex-direction: column;
    max-width: 380px;
  }
  .column {
    display: contents;
  }
  .at_stats {
    order: 1;
  }
  .at_chat {
    order: 2;
  }
  .at_player {
    order: 3;
  }
  .at_article {
    order: 4;
  }
  .at_people,
  .at_portfolio,
  .at_photos {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .frame .bones,
  .frame[data-phase='loading'] > .skeleton {
    animation: none;
  }
  .frame .bone::after {
    display: none;
  }
  .played {
    transition: none;
  }
}
```