# AGENTS.md — BR Atelier for coding agents

Read this before writing any UI. The goal is **zero invention**: every size, colour, radius and
state you need already exists. If you catch yourself typing a raw px value, hex colour or a new
class, stop and find the token/class below.

## 1. Source of truth (and nothing else)

| File | Role |
|---|---|
| `tokens.css` | ALL values: colours, type scale, space, radii, control heights, icons, z-index, motion, variants A/B/C × light/dark, accents |
| `base.css` | Reset, `.br-canvas` (glow + grain), type classes (`.page-title`, `.eyebrow`, `.label`, `.display-*`) |
| `components.css` | Every component class with all states |
| `styles.css` | Imports the three above — the only file to link |
| `src/app/globals.css` | Next.js/Tailwind v4/shadcn bridge — maps tokens, defines no values |
| `components/**/*.jsx` | Reference React components (thin wrappers over the classes) |
| `templates/app-shell/` | Reference screen — copy its structure for new apps |
| `templates/login/`, `list-detail/`, `form/`, `states/`, `dark-table/` | Reference screens: sign-in, master–detail, form with validation, empty/loading/error, Variant B dark table |

Ignore as a source: `_archive/`, `ui_kits/` (marketing showcase), `preview/` (cards), `colors_and_type.css` (shim).

## 2. Setup (Next.js + Tailwind v4 + shadcn)

1. Copy `tokens.css`, `base.css`, `components.css`, `styles.css`, `fonts/`, `assets/` into `src/styles/br/`.
2. Use `src/app/globals.css` from this repo; fix the `@import` path to `./styles/br/styles.css` or similar.
3. Fonts: `npm i geist` → `GeistSans.variable GeistMono.variable` on `<html>`; delete the two Geist `@font-face` rules in `tokens.css`. Clash Display stays self-hosted.
4. Root: `<html data-variant="A" data-theme="light">` + `<body className="br-canvas">`. **The canvas (glow + grain) is mandatory on every screen — exactly once.**
   `<AppShell>` renders its own `.br-canvas` + `data-*` wrapper by default (it *is* the root, for previews/standalone pages). In an app whose layout already sets them, use `<AppShell root={false}>` — otherwise glow and grain paint twice.
5. Icons: **apps import `lucide-react` directly** (`import { Search } from 'lucide-react'`). `<Icon name>` from `components/icon` fetches SVGs from unpkg (lucide-static 0.469) at runtime — previews only, never in an app. Always `size={16} strokeWidth={1.75}` (14 in `sm` buttons, 20 in empty states). Never filled, never coloured except `--accent` on the active nav item.

## 3. Exact values — cheat sheet

**Fonts (3 roles, never a 4th):** display `--font-display` Clash Display 500 (never italic) · UI `--font-ui` Geist · meta/data `--font-mono` Geist Mono.

**Type (use only these):**
| Use | Token / class | px |
|---|---|---|
| Sidebar/menu/table section label | `.label` (mono caps .1em) | 10 |
| Eyebrow above a title, badge, hint, count | `.eyebrow` / `--text-xs` | 11 |
| Secondary UI, small button, crumbs | `--text-sm` | 12 |
| **Default UI**: nav item, button, input, table cell, list row | `--text-base` | 13 |
| Body copy, dialog text, page description | `--text-md` | 14 |
| Card / empty-state title | `.card-title` / `.title-s` | 18 |
| Dialog title | `.display-s` | 22 |
| **Page title in apps** | `.page-title` | 32 |
| Marketing heroes only | `.display-m/l/xl/xxl` | 24–168 fluid |

`h1–h6` and `p` are reset (no size, no margin) — always add a class.

**Space:** `--space-1…24` on a 4px grid (4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 64, 96). Tailwind `p-4` = 16px matches.

**Sizes per variant (A / B / C):** control `38/36/34` (sm `30/30/28`, lg `46/42/40`) · nav item `34/32/30` · topbar `56/56/52` · card padding `20/18/16` · page padding `32/28/24` · sidebar `240`.

**Radii:** always role tokens — `--radius-control` (buttons, inputs, search, chips: pill in A), `--radius-nav` (nav/menu items), `--radius-card` (cards, sidebar, dialog). Never hard-code a radius; never add `[data-variant]` overrides.

**Text colour:** `--text` → `--text-muted` (≥6:1) → `--text-subtle` (≥4.5:1, lowest for information) → `--text-faint` (decoration/disabled only).

**Accent — one per screen:**
- `--accent` = brand mark, 2px active bar, active icon, focus ring, chart line.
- `--accent-fill` = background under white text (primary button, checked checkbox).
- `--accent-text` = accent as small text (eyebrow-accent, error, danger button label, links).
- `--accent-soft` / `--accent-ghost` = tinted backgrounds only.

**Status:** destructive = accent (there is **no red**). `--success(-text)`, `--warning(-text)` for badges/alerts only.

**Identity palette `--id-1…6`** (ochre, olive, sage, slate blue, lavender, mauve) — ONLY to distinguish projects/areas: 8px `.id-dot` in a nav item, 22px `.id-tile`, a 2px bar. Never text, buttons, control borders, states or charts. Never the accent hue.

## 4. Components — use these classes, don't restyle them

| Need | Class / component |
|---|---|
| App frame | `.shell[data-shell="floating"|"rail"]` + `.sidebar` + `.shell-main` · `<AppShell>` |
| Sidebar item | `.nav-item` (+ `aria-current="page"`) · `.count` · `.id-dot` · `<NavItem>` |
| Sidebar group label | `.sidebar-section` · `<NavSection>` |
| Top bar | `.topbar` + `.crumbs` + `.search` · `<Topbar>` |
| Page top | `.page` + `.page-header` · `<PageHeader>` |
| Buttons | `.btn .btn-primary|ink|ghost|quiet|danger` + `.btn-sm|lg` + `.btn-icon` · `<Button>` `<IconButton>` |
| Fields | `.field` `.field-label` `.input` `.input-group` `.textarea` `.select` `.kbd` · `<Input>` `<SearchField>` `<Textarea>` |
| Toggles | `.check` (`.check-round` for tasks) `.radio` `.switch` · `<Checkbox>` `<Switch>` |
| Containers | `.card` (`.card-flush` for lists) · `.list-row` · `<Card>` `<ListRow>` |
| Nothing to show | `.empty` · `<EmptyState>` |
| Overlays | `.menu` `.menu-item` `.popover` `.tooltip` `.dialog` `.sheet` `.scrim` `.toast` `.alert` |
| Data | `.table` `.badge` `.count` `.avatar` `.progress` `.skeleton` `.spinner` `.tabs .tab` |

**States are built in** — use attributes, not new classes: `:disabled`/`aria-disabled`, `aria-pressed`, `aria-selected`, `aria-current="page"`, `aria-invalid="true"`, `data-loading="true"`.

**shadcn mapping** (globals.css): `bg-primary` = ink (default buttons) · `bg-brand-fill text-brand-foreground` = the ONE accent CTA · `bg-accent` = subtle hover surface (**not** orange) · `destructive` = accent · `rounded-control|card|nav` utilities exist. Add a `brand` variant to shadcn's button cva: `brand: "bg-brand-fill text-brand-foreground hover:bg-brand-fill/90"`.

**Page grids:** `.page-split` (main + aside), `.list-detail` (list + detail pane), `.form-grid` (2 cols, `.span-2` full row) — all collapse to one column on small screens. Wrap tables in `.table-wrap`.

**Responsive (built into components.css — don't write your own):** `< 1024px` sidebar collapses to a 64px icon rail (labels stay for screen readers, `title` tooltips), page grids stack; `< 640px` tighter floating frame, crumbs hidden, search fills the topbar, dialog actions full-width, tables scroll inside their card. Only give every `NavItem` an icon or identity dot so the rail has something to show.

## 4a. Overlays — behaviour comes from Radix, look from the DS

`.dialog` `.sheet` `.menu` `.popover` `.tooltip` `.scrim` `.toast` are **visual only**: no focus trap, no Esc, no portal, no ARIA. Never hand-roll those. Use the shadcn/Radix primitive and put the DS class on its parts:

| Need | Primitive (shadcn) | DS classes on |
|---|---|---|
| Modal | `Dialog` / `AlertDialog` | `Overlay` → `.scrim`, `Content` → `.dialog`, then `.dialog-head/-title/-desc/-body/-foot` |
| Side panel | `Sheet` (Radix Dialog) | `Overlay` → `.scrim`, `Content` → `.sheet` |
| Actions menu | `DropdownMenu` | `Content` → `.menu`, `Item` → `.menu-item` (`data-highlighted` is styled), `Separator` → `.menu-sep`, `Label` → `.menu-label` |
| Popover | `Popover` | `Content` → `.popover` |
| Tooltip | `Tooltip` | `Content` → `.tooltip` |
| Toast | `sonner` | `toastOptions.classNames.toast` → `.toast` |

Radix gives: focus trap + return focus, Esc/outside-click close, portal to `body`, `role`/`aria-*`, scroll lock. The DS positions `.dialog`/`.sheet` with `position:fixed`; for `.menu`/`.popover`/`.tooltip` Radix's positioner wins — don't add your own `top/left`.

## 5. Checklist before you finish a screen

- [ ] Root has `.br-canvas` and `data-variant`/`data-theme`; nothing sits on a flat solid page.
- [ ] No raw hex, no raw px font sizes/radii/heights — only tokens/classes above.
- [ ] Exactly one `btn-primary` (accent) on the screen; other actions ink/ghost/quiet.
- [ ] Disabled buttons use the neutral disabled style — never a faded accent.
- [ ] Nav items 13px/500, section labels 10px mono caps, counts via `.count` (mono).
- [ ] Project colours only as `.id-dot` / `.id-tile`.
- [ ] Icons Lucide 16px stroke 1.75, `--text-subtle`; accent only on the active nav item.
- [ ] Page title `.page-title` (32px Clash, sentence case, trailing period) with `.eyebrow` above.
- [ ] Textareas have no native resize grip (`.textarea`, add `.textarea-resizable` only on purpose).
- [ ] Focus visible everywhere (2px accent outline or focus ring) — don't remove outlines.
- [ ] No emoji, no gradients on buttons/cards, no red, no italic Clash Display, no fourth font.
- [ ] Hover ≤ 1px lift; motion `--dur` .22s / `--ease`.
- [ ] Checked at 390px: no horizontal page scroll (tables scroll in `.table-wrap`).
- [ ] Overlays are Radix primitives with DS classes — no hand-made focus handling.

## 6. Linting

`_adherence.oxlintrc.json` is generated by Claude Design. Its rules use `no-restricted-syntax`, which oxlint does not implement, and it carries an `x-omelette` key that oxlint rejects — run the rules through **ESLint** (strip `x-omelette` first). The per-component prop rules accept every prop declared in the component's `.d.ts`, including pass-through DOM props (`id`, `name`, `placeholder`, `onClick`, `aria-*`…).
