# Design system

**Last updated:** 2026-11-27T06:14:39-03:00 (UTC-3)

The m7gtw console and this documentation site share one design system: liquid glass over a quiet field of light, in a dark and a light theme, with the same colors, type, motion and brand, read from one file. Change a value there and both products change with it. This page explains how the system is built and where to go next; the sections below lead to a page per topic.

## Sections

**Foundations**: the values everything else is made of.

- [Color](/docs/design/color/): the two themes and how a reader picks one; surface, glass, text, border, accent, state, status and brand roles, with the contrast of every declared pair.
- [Typography](/docs/design/typography/): the three families, where their files come from, the type scale, weights and line heights.
- [Layout and spacing](/docs/design/layout-and-spacing/): spacing steps, sizes, corner radius, the layers of glass, the background field, breakpoints and the layouts that use them.
- [Motion](/docs/design/motion/): durations, easing, how m7 moves and what reduced motion turns off.
- [Iconography and brand](/docs/design/iconography-and-brand/): m7, its colors, the favicon and the icon set.

**Components**: how the foundations come together in the console and on the site.

- [Buttons](/docs/design/buttons/): primary, secondary, quiet and destructive actions, and the menus that hold them.
- [Forms](/docs/design/forms/): fields, selects, placeholders, focus, validation and filter forms that fold.
- [Tables](/docs/design/tables/): headers, rows, numbers, status, row actions and wide tables on small screens.
- [Cards](/docs/design/cards/): the two kinds of glass, panels, stats, the rim light and the site's cards and asides.
- [Navigation](/docs/design/navigation/): the console's rail, top bar, theme switch, tabs and breadcrumbs, and the site's header and sidebar.
- [Charts](/docs/design/charts/): the validated palettes and how charts read the rest of the system.

**Patterns**: recurring states that every page has to handle.

- [Empty states](/docs/design/empty-states/): nothing to show yet, or nothing matches.
- [Error states](/docs/design/error-states/): failures, refusals and the semantic red.
- [Loading states](/docs/design/loading-states/): first load, refresh and long operations.

## Principles

- **One source.** Every color, font, size, radius, shadow, duration and breakpoint is a token in [`design-tokens/tokens.json`](https://github.com/m7gtw/gateway/blob/main/design-tokens/tokens.json). Product stylesheets name tokens instead of repeating values (the console's older layout still carries literal sizes; see below).
- **Two themes, light by default.** Every color role has a dark and a light value, in the console and on the site. Both are light until the reader picks Dark or System, and they share that choice (see [Color](/docs/design/color/#themes)).
- **Glass, never at the cost of reading.** Clear liquid glass is for bars and controls; anything that holds a table, a form or long text is a solid tint or the open page. Text contrast is computed against the surface as it renders, over the page background, and every declared pair meets WCAG AA in both themes.
- **Color never alone.** A status is a word with a mark whose shape changes with the state; a chart series has a label or a marker.
- **The system yields to the reader.** The background field never moves. Under `prefers-reduced-motion: reduce` m7 only blinks and nothing else moves on its own (short transitions the reader starts remain; see [Motion](/docs/design/motion/)); under `prefers-reduced-transparency: reduce` glass turns opaque and blur stops.
- **Closed console.** The console is one inline bundle with no external fonts or files; the tokens never introduce a network request.

## How it is built

```text
design-tokens/tokens.json            the only source
        │  python3 scripts/design-tokens.py write
        ├── web/src/tokens.css             console: dark values on :root, light values on :root[data-theme="light"], @font-face for the inlined fonts
        ├── docs-site/src/styles/tokens.css site: dark values on :root, light values on :root[data-theme="light"]
        └── docs/design-system/*.md         the token tables on these pages
```

Two hand-written layers then map the tokens onto each product, and carry no color of their own:

| Layer | Product | What it maps |
|---|---|---|
| `web/src/theme.css` | Console | Console classes (the background field, rail, top bar, tabs, panels, stats, buttons, fields, tables, status, menus) to color, glass, shadow and font tokens. `web/src/main.tsx` imports `style.css` (layout), then `tokens.css`, then `theme.css` last. |
| `docs-site/src/styles/rgfem.css` | Site | Starlight's variables (`--sl-color-*`, `--sl-font`, `--sl-font-mono`, `--sl-text-*`, `--sl-line-height*`) to tokens, plus the site's glass: the floating header, the background field, cards, asides and link buttons. `tokens.css` is the first entry of `customCss` in `docs-site/astro.config.mjs`. |

Both generated files declare the same tokens in the same two blocks, dark and light; the console adds the font faces and the site imports the font packages. The generated files are committed, so neither build needs Python.

What reads which group today:

| Token group | Console | Site |
|---|---|---|
| Color roles and their alpha variants | `theme.css`, component stylesheets, m7 and the m7 ai launcher | `rgfem.css` (Starlight variables), the site title's m7 |
| Font families and sources | `@font-face` in `tokens.css`, `theme.css` | `@import` in `tokens.css`, `rgfem.css` |
| Type scale, line heights, letter spacing | Weights, line heights and letter spacing; sizes are still pixels | Starlight's text scale and line heights, heading weights and letter spacing |
| Glass blur, saturation and shadows | The rail, top bar, tabs, panels, drawers, buttons, menus, the slab buttons of m7 ai | The header, cards, asides and link buttons |
| Background field (colors, blurs, per-theme opacities) | Behind the shell and the entry screens | Behind every page |
| Radius | Panels, fields, buttons, tabs, menus, rail items | The header, cards, asides, code blocks, the current page |
| Sizes | Tap targets, the rail, the top bar, edges and rims | The edge of the header, the ribbon |
| Motion | m7's own simulation (durations are not tokens there) | The site title m7's float and blink |
| Spacing and breakpoints | Declared for new components | Declared for new components |

The console's layout (`web/src/style.css`) keeps literal spacing and media queries: media queries cannot read custom properties. Its last section lays out the shell (the floating rail and the top bar) with the size and radius tokens. New components use the tokens.

## Change a value

1. Edit [`design-tokens/tokens.json`](https://github.com/m7gtw/gateway/blob/main/design-tokens/tokens.json). A color is a hex (`#rrggbb` or `#rrggbbaa`), a reference to another role (`{bg}`) or another role's RGB with a new alpha byte (`{line}/66`).
2. Render the outputs:

   ```sh
   python3 scripts/design-tokens.py write
   ```

3. Check contrast and consistency (the fast quality gate runs the same check):

   ```sh
   python3 scripts/design-tokens.py check
   python3 scripts/design-tokens.py contrast   # the full table, one line per pair and theme
   ```

4. Build both products and look at them at 1440 and 390 px, each in the dark and the light theme:

   ```sh
   (cd web && npm run build)
   npm --prefix docs-site run build
   ```

5. Commit the JSON together with the regenerated `web/src/tokens.css`, `docs-site/src/styles/tokens.css` and `docs/design-system/*.md`.

## What the check enforces

`python3 scripts/design-tokens.py check` runs in the fast quality gate (`scripts/quality-gate.sh fast`) and fails when:

- a generated file or a token table on these pages differs from what the JSON renders, a table is missing from every page, or a table marker is left unclosed;
- a declared text/background pair is below its minimum in either theme: 4.5:1 for text, 3:1 for large text and UI components (field borders, focus rings, indicators); only a graphic pair (a logo) can carry a written exception, which the table on the [Color](/docs/design/color/) page shows;
- any console stylesheet or component (`web/src/*.css`, `*.tsx`, `*.ts`), or the site's `rgfem.css`, contains a color literal (a hex, a color function such as `rgb()`, a named color, or a color inside an inline SVG data URI) outside the generated `tokens.css` and a short, counted allowlist of data values, or the console page's `theme-color` differs from the dark `--color-bg`; or any stylesheet of either product names a `var(--color-…)`, `var(--font-…)`, `var(--space-…)` or other token that does not exist (an unknown `var()` fails silently in the browser);
- a composed token (a shadow, the reduced-transparency override) names a token that does not exist;
- the console and the site stop declaring the same tokens, `tokens.css` stops being imported before `theme.css` or first in `customCss`, or the two builds pin different versions of a font package;
- the brand files drawn outside CSS (the static logo, the animated logo and the site favicon) carry any color other than the three gradient stops and the eye ink of the brand tokens, or the site favicon is not a copy of the static logo; the m7 engine in `web/src/m7/` is checked like any console source.

## Hard rules

- The console stays a closed inline bundle: fonts are fontsource latin subsets inlined as data URIs (`assetsInlineLimit` in `web/vite.config.ts`, `font-src 'self' data:` in the console's CSP), with no `<link>`, no external URL and nothing in `web/public` for the brand.
- Chart palettes keep their validated values. They are declared as fixed values under `color.chart` in the token file, one per theme, and read with `var(--color-chart-…)`; never tune one color of a palette: re-validate the whole set in both themes. See [Charts](/docs/design/charts/).
- The semantic red (`--color-danger`: `#f7a7aa` in dark, `#a82a33` in light) marks `!panic`, destructive actions and failures only. A refusal or a limit (a 429, a 403) is `--color-status-warning`, which is warm, not red.
- The label on the primary fill is `--color-on-primary`, never white.
- Glass is never nested in glass, and the rim light belongs to the filter panel, the login card and the rail only.
- A theme is never assumed: a new component reads roles, so it works in dark and in light without a rule of its own.
- Layout and media queries stay in `web/src/style.css`; `theme.css` maps color, glass, type and the shape of controls, and carries no color of its own.
