# Design system

The design system hierarchy, its source documents, and the rule for changing a token or a shared component.

HTML page: https://developer.mpalo.com/design
Markdown page: https://developer.mpalo.com/design.md

## Navigate sections

- [Source of truth](design#source-of-truth)
- [Hierarchy](design#hierarchy)
- [Documents](design#documents)
- [Changing the system](design#change-rule)
- [Enforcement](design#enforcement)

## Source of truth

Scope: every visual decision on every Mpalo surface.

**Rule.** Every Mpalo surface reads from `apps/dev-site/design-system/`. The developer build writes the public copy to `public/design-system/`, and every host serves that folder at `/design-system/`. A value is changed in the token source or it is not changed at all.

The design system is one hierarchy, not a page-level stylesheet, a copied value set, or a second source. The institution's charter and doctrine remain authoritative in `internal/doctrine/`. The documents in this folder are the design-facing expression of that material. Where they quote a commitment, they quote it exactly and do not soften it.

**Do:** change the token, rebuild, and verify every surface that consumes it. **Do not:** add a hex value, an alpha tint, a second radius, or a shadow to a page stylesheet to solve a local problem.

## Hierarchy

One folder owns each kind of decision, so a change has one place to land.

| Path | Holds | Authority |
| --- | --- | --- |
| `tokens/` | Color, type, spacing, radius, motion, layers, domains, and base styles. | Canonical values. Every surface reads them. |
| `components.css` | Buttons, cards, badges, fields, tables, overlays, and the other shared components. | Canonical component styles. Pages do not restyle a shared component. |
| `media.css`, `media.js` | The video player and its behavior. | Canonical media treatment. See [Media](media.md). |
| `data.js` | Pagination and chart tooltip behavior. | Canonical behavior for the data components. See [Data](data.md). |
| `assets/` | Icons, logos, and scribbles. | Canonical files. Do not add a second copy under `public/`. |
| `fonts/` | Radley, Helvetica LT Std, Eina, and ASM. | Canonical font files. Verify licences before adding a weight. |
| `docs/` | System, language, constitution, philosophy, and media notes. | Canonical explanation. Public pages express this material; they do not keep a second copy. |
| `public/design-system/` | The built stylesheet, components, media files, fonts, and assets. | Generated output. Never hand-edit it. |

The build bundles `styles.css` and its token imports into one `mpalo.css`, writes `components.css` and the media files beside it, and copies the fonts and assets. A page makes one stylesheet request for tokens and one for components, and the same relative URLs resolve on every host.

## Documents

Each document has a source file and a public expression. The source governs.

| Document | Source | Public expression |
| --- | --- | --- |
| Design system | `apps/dev-site/design-system/README.md` | [Elements](elements.md) |
| Language | `design/LANGUAGE.md` | [Language](language.md) |
| Constitution | `apps/dev-site/design-system/docs/constitution.md` | [No-Go's](no-gos.md) |
| Philosophy | `apps/dev-site/design-system/docs/philosophy.md` | [Principles](principles.md) and [Domains](domains.md) |
| Media | `apps/dev-site/design-system/docs/media.md` | [Media](media.md) |
| Mind Platform | `design/code/DESIGN_SYSTEM.md` | Mind Platform implementation rules |
| Public site | `design/code/PUBLIC_SITE_DESIGN_SYSTEM.md` | Public marketing implementation rules |

### Design system

The system is the tokens and the components that read them. A page chooses a surface and a theme; it does not choose a palette, a radius, or a shadow. The rules are absolute because a local exception becomes a second design system.

### Language

Three registers share one standard: institutional, explanatory, and interface. Each says what is known, names the real operation, and leaves the next decision with the person. The canonical statement is in [Language](language.md). [Contributing](contributing.md) covers how a rule is written.

### Constitution

The charter's commitments are design constraints, not background reading. Consent is a condition of operation. A preserved representation is a tribute to a person, not the person. Non-weaponisation is absolute. The interface may not imply a capability the system cannot show. [No-Go's](no-gos.md) states the resulting boundaries.

### Philosophy

Mpalo is an institution for human understanding, memory, and agency. Cognitive infrastructure is how that purpose is pursued today, and experience-aware memory is the current technical expression. The design system is quiet because the work is intimate; it does not perform depth with decoration. [Principles](principles.md) derives the visual rules from that position.

### Media

The player is one component for MP4 playback on every surface. It has no window chrome, one system radius, and the softer media shadow. [Media](media.md) documents the anatomy, tokens, and keyboard behavior.

## Changing the system

A change lands in the source, the document, and the public page together.

1. **Change the token, not the page.** If a value needs a new name, add it to `tokens/` and update the component that reads it. Do not write a hex value, an alpha tint, or a second radius in a page stylesheet.
2. **Fix the component, not the instance.** A page that needs a different button is a signal that the shared button is wrong. Change it once, then verify every surface that uses it.
3. **Keep one explanation.** If a rule already has a canonical paragraph, link to it. Do not restate it in a second place with different wording.
4. **Update the document with the rule.** A visual rule that is not written down will be reinvented. Add the reason and the boundary to the matching file under `docs/`.
5. **Build and check.** Run `npm run build:dev-site`, then `npm run check:design-rules`. The check fails on borders, non-token radius, shadows other than the two documented ones, alpha values, hard-coded hex values, and easing curves.
6. **Verify the generated page.** Inspect the generated output for every affected surface before publishing. The generated files are output, not source.

**Why.** A visual rule that is not checked will be reintroduced, and the next person will copy the exception rather than the system.

| Do | Do not |
| --- | --- |
| Add a semantic token when a repeated value has a real role. | Add a one-off value because a single page looks wrong. |
| Change `components.css` and re-check every surface. | Override the component with a page id selector. |
| Regenerate and review the output. | Hand-edit a generated file under `public/`. |

**Two shadows, two jobs.** `--shadow-overlay` belongs to menus, dialogs, popovers, toasts, and the search panel. `--shadow-media` belongs to the video player and nothing else. The player also derives an ambient edge from its current frame; that edge is part of the player, not a third shadow token. A card, a button, and a page never cast a shadow.

## Enforcement

The system is checked before publication and at deploy.

- `npm run check:design-rules` checks the canonical token, component, media, and developer styles.
- `npm run check:design-runtime` checks runtime design surfaces and control contrast.
- `npm run check:fonts` checks for external font dependencies.
- `npm run build:dev-site` regenerates the public copy, and `npm run check:dev-site` checks the page inventory.
- Preview every affected surface before production. Do not change a surface that serves production traffic without a preview.

**Owner:** the Design owner. **Review:** before publication and before a deploy that changes a shared token or component.

## Related pages

- [Elements](elements.md)
- [Modes and surfaces](modes.md)
- [Components](components.md)
- [Contributing](contributing.md)

## Authoritative integration reference

- [API quickstart](https://api.mpalo.com/get-started)
- [API reference](https://api.mpalo.com/landing)
