<!-- generated by scripts/gen-docs.mjs from docs/system/layout.md. Edit the source and rerun. -->
# Layout

## Description

Spacing uses Tailwind's scale in 4px steps. Controls of one size share one height, so a row of them lines up. The content column is at most 72rem wide. Its side padding is 16px on phones and 24px from 640px up. A page has a main column, plus a side column when the page needs one.

## Tokens

<!-- tokens:start layout -->
| Token | Light | Dark | Role |
|---|---|---|---|
| `--control-edge` | `color-mix(in srgb, var(--foreground) 45%, transparent)` | same | The outline of an unchecked box or an off track, 3:1 against the page |
| `--line-icon` | `1.5px` | same | An icon's stroke at every size, the weight of a 14px medium label's stems |
| `--line-focus` | `2px` | same | The keyboard focus outline's width |
| `--focus-offset` | `2px` | same | The gap between a control and its focus outline |
| `--control-sm` | `32px` | same | A small button or field |
| `--control` | `36px` | same | A button, a field, a pill |
| `--control-lg` | `40px` | same | A large button, a search field |
| `--touch` | `44px` | same | The smallest target on a phone |
| `--nav-item` | `var(--control)` | same | The height of a top nav link; set it on your root for a slimmer or taller bar |
| `--page` | `72rem` | same | The content column |
| `--gutter` | `1.5rem` | same | The page's side padding from 640px up |
| `--row` | `40px` | same | A dense table row |
| `--pad-card` | `24px` | same | A card's padding, and the gap between its parts |
| `--pad-card-sm` | `16px` | same | A small card's padding, and the gap between its parts |
| `--pad-popup` | `6px` | same | Between a menu, select, list or calendar popup's edge and its rows or days |
| `--pad-composer` | `6px` | same | Between the message composer's edge and the buttons and pictures inside it |
<!-- tokens:end layout -->

Breakpoints are Tailwind's: `sm` 640, `md` 768, `lg` 1024, `xl` 1280. Below 640px the shell shows the bottom tab bar and the data table switches to phone rows. `PageColumns` stacks the side column under the main column below 1024px.

## Specimens

None yet.

## Usage

| When                                | Use                                                                                     |
| ----------------------------------- | --------------------------------------------------------------------------------------- |
| The page's content width            | `mx-auto w-full max-w-(--page) px-(--gutter)`                                           |
| A page with a list                  | `PageColumns`, with the list in the main column and a `RailCard` in the side column     |
| Space between sections              | `gap-10`                                                                                |
| Space inside a card                 | `p-5` (RailCard) or `p-6` (Card default)                                                |
| Space between controls in a row     | `gap-2`                                                                                 |
| Space between a label and its field | `gap-1.5`                                                                               |
| A control's height                  | `--control` (36px) by default, `--control-sm` (32px) small, `--control-lg` (40px) large |
| A top nav link's height             | `--nav-item` (36px, the value of `--control`), set on your root to change the bar       |
| A touch target on a phone           | at least `--touch` (44px), through padding or the `touch-target` utility                |

- `rule/layout-one-control-height`: When controls sit in one row, give them all the same size so they share one height, `--control` (36px) for Button, Input, Select and Pill by default, because mixed heights in a row look misaligned. Evidence: app 4/4 default-size controls in tsaglobal are h-9, apps/web/app/components/ui (survey 2026-10-16); principle heuristic: consistency and standards, trap/control-height. Check: review of every row in the showcase; lint rule/component-override on height overrides.
  - Don't: `<Input className="h-11" /> <Button>Search</Button>`
  - Do: `<Input /> <Button>Search</Button>`
- `rule/layout-steps-only`: When setting padding, gap, size or an offset, use a spacing step such as `p-4`, `gap-1.5` or `size-9`, because one shared scale makes separate screens line up. Evidence: measured 248 arbitrary values in tsaglobal, .design-system/triage/tsaglobal-superapp/signals.tsv (tw_arbitrary); measured 0 in adv-atlas, .design-system/triage/adv-atlas/signals.tsv. Check: lint rule/arbitrary-value and rule/inline-px (scripts/check-system.mjs).
  - Don't: `<div className="p-[13px] gap-[7px]">`
  - Do: `<div className="p-3 gap-2">`
- `rule/layout-page-sets-width`: When building a page, leave `max-w-*` and `mx-auto` off its top element and let the shell set the width, because a second width makes the side column and the list misalign. Evidence: principle heuristic: consistency and standards, one page width keeps the columns aligned; single use docs/research/2026-10-16-findings.md:52, the first source app's shell sets the content column for every route. Check: review.
  - Don't: `<main className="mx-auto max-w-4xl">`
  - Do: `<PageColumns rail={<RailCard id="saved" heading="Saved">…</RailCard>}>…</PageColumns>`
- `rule/layout-touch-floor`: When a control is smaller than 44px, add `touch-target`, which grows its hit area to 44 by 44px on touch screens, because a 16px checkbox is too small for a thumb. Evidence: app 2/2 source apps grow phone hit areas to 44px, tsaglobal apps/web/app/components/ui/checkbox.tsx and adv-atlas web/css/touch.css; principle wcag: 2.5.8 Target size minimum, 24px everywhere and 44px where thumbs press. Check: probe at 390 on the showcase; review.
  - Don't: `<Checkbox className="size-4" />`
  - Do: `<Checkbox />`
- `rule/layout-phone-is-one-column`: When the viewport is under 640px, use one column, show `NavTabs` at the bottom and open a bottom `Sheet` where wider screens use a popover, because a 390px screen has no room for a second column. Evidence: app 2/2 source apps stack to one column on phones, tsaglobal apps/web/app/components/page-columns.tsx and adv-atlas web/css/bottom.css; person D15. Check: review at 390.
  - Don't: `<div className="grid grid-cols-[1fr_20rem]">`
  - Do: `<PageColumns rail={rail}>{list}</PageColumns>`

## Accessibility

Every page must fit 320px in one column without horizontal scroll. This has not been checked yet. Touch targets are 44px on touch screens, by the rule above. Pointer targets are at least 24px everywhere (WCAG 2.5.8). Put prose inside `max-w-prose` to keep lines under about 80 characters.

## Not tokens

- `0`, `auto`, `1fr`, `100%` and viewport units stay plain values.
- Breakpoints are Tailwind's and are listed above.
- `calc()` between tokens stays a `calc()`.
