Enforce the strict spacing grid, token vocabulary, restraint rules and the v2 interaction layer (spring motion, traveling indicators, Switch/Loader/RollingNumber/useShinyBurst/confirmAction) that give this app its calm, aligned, tactile identity. Use before writing or editing ANY CSS in src/styles/ or src/index.css, before adding a new view or control, before adding any animation, and when auditing drift ("the UI feels loose/soft/inconsistent/generic"). Includes the drift-detection commands a...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Design System?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ensinho-design-system)
---
name: design-system
description: Enforce the strict spacing grid, token vocabulary, restraint rules and the v2 interaction layer (spring motion, traveling indicators, Switch/Loader/RollingNumber/useShinyBurst/confirmAction) that give this app its calm, aligned, tactile identity. Use before writing or editing ANY CSS in src/styles/ or src/index.css, before adding a new view or control, before adding any animation, and when auditing drift ("the UI feels loose/soft/inconsistent/generic"). Includes the drift-detection commands and the taste gate.
---
# Design System — calm structure, living material
> **Creative direction (Enzo, 2026-11-05):** the trainer-profile onboarding's creativity — a scene that answers the user, Pokémon's own devices (evolution lines, silhouettes, type colours, artwork) as the UI language — is the standard from now on, "definitivamente". Read [creative_direction.md](../../../docs/modules/creative_direction.md) before designing any new screen.
## This branch: "Neon Sticker" — calm data, loud moments (2026-10-26)
Read this first; everything below still holds, with these overrides. The
theme takes the graffiti wordmark's own language (purple letters, an ink
outline, then magenta, then yellow) and splits the app into two layers.
**Base layer — calm, data-first (everywhere).** Flat surfaces with a real 1px
border (no sheen on `dark`/`light`), one accent (`--color-primary`, Volt
`#7C3AFF` on `dark`, `#6A2BF0` on `light`), canon type colours carry meaning.
Volt as a *word* is `--color-primary-text` (`text-primary` in Tailwind reads it)
— the fill is only 3.4:1 as text on the dark surface. The page's dots are Volt
at low alpha. No amber in chrome.
**Brand layer — only on objects you hold and on moments.** Tokens in
`index.css` → "BRAND LAYER"; they exist and read in all ten themes.
| Mark | Token / class | Allowed on | Never on |
|---|---|---|---|
| Logo ring (ink · pink · gold) | `--ring-logo` (= `--ring-focus`) | `:focus-visible`, the team slot being edited (`.team-builder-slot.is-editing`), the trainer's own avatar on Profile with no frame | hover; lists of other trainers |
| Sticker (3px inset edge — fg on dark, ink on light — + hard 4px drop) | `--sticker`, `.sticker`; `--sticker-filter` for a transparent sprite/emblem | filled team slots (edge in the member's type colour, `--type-a`, since 2026-11-12 — Enzo), the hovered/selected Pokémon card, the landing demo's picked members, earned badges/emblems, landing hero sprites, a full empty state's sprite | containers, panels, tables, rows, chrome |
| Spark burst | `--spark-burst` (clip-path), `.spark-host` (+ `--spark-color`) | ONE per screen: behind the landing hero lead (its type colour), behind a reward/badge emblem (gold) | anything repeated |
| Shiny Gold `#FFD23F` | `--brand-gold` fill + `--brand-on-gold` ink; as a word `--color-accent`; `.badge--gold` | something EARNED: streak, level, reward line, journey badge, the peak stat (`StatBar peak`), a favourite, the shiny sparkle | chrome, beside a type chip |
| Live Pink `#FF3D9A` | `--brand-live` fill + `--brand-on-live` ink; as a word `--brand-live-text` (`#D6246F` on light); `.live-dot`, `.badge--live` | NEW / LIVE: your-turn battles, pending counts, today's open puzzle, a live toast (`showToast(…, { live: true })`), the "new" count | chrome, beside a type chip |
- **Primary button** (`.btn-primary`): Volt on a 4px lip (`--color-primary-lip`);
a press translates 3px onto the lip (no scale). `.btn-primary.btn-lg` (the
primary CTA) speaks in Unbounded. Secondary = raised fill + control edge;
ghost = no chrome until hover.
- **Segmented**: pill track, Volt thumb (still the anchor-positioned traveller),
on-primary label. **Tabs**: a 3px Volt underline. **Dock**: the active tab is
a Volt lozenge.
- **Stat bars**: 8px, Volt; the peak stat gold.
- **Type**: three families. `--font-heading` Unbounded 700 for every `h1`, the
page/dialog-level `h2`s (`.modal-title`, `.landing-section-title`,
`.cozy-hero__title`, `.pdm__name`, `.auth-dialog__title`, any `h2.text-xl+`),
`.text-hero/-display/-title`, a full empty state's title and the primary CTA
— sentence case, `-0.01…-0.02em`. Section headings, `h3`–`h6`, nav, tabs and
labels: Space Grotesk. Figures, ids, eyebrows: JetBrains Mono
(`--font-display` / `--font-mono` are still the mono readout voice).
Unbounded is wider than the mono it replaced — re-check any fitted headline.
- **Motion**: 150ms for data, the glide spring for selection, and the *peel* —
`.is-peeling` (rotate −3° → 0 on the pop spring) on a team slot that was
filled while the builder is open; never on load, settles on `animationend`.
- **The game exception**: `.ds-screen` keeps its unit, its face and its field; its HUD wears this theme through `--hud-*` (2026-11-10).
## Taste pass (2026-11-11): colour that means something, figures not boxes
Enzo's reference was the classic "before/after" of a product sidebar: grey
outline icons, counts in pills, identical boxes → coloured filled icons, plain
numerals, a breadcrumb. Four moves, each from Pokémon's own vocabulary
(taste-skill + Impeccable are installed as user plugins for audits —
`/impeccable critique|audit|polish <target>`; their marketing-site rules do not
override this skill):
- **A destination has a tone.** Rail and dock icons sit in a tile washed in the
type colour of their world (`utils/navHue.js` → `--nav-hue`; 14% tile, 55%
glyph toward `--color-fg`, 30% when current). The current row is the neutral
`--color-surface-active` — the tone is the signal, Volt is not repeated. A new
nav entry gets a tone in that table, never inline.
- **A count is a figure, not a box.** `.count-badge` and
`.team-builder-panel__meta` are mono muted numerals with no fill or edge.
Live counts (`.app-shell__nav-badge`, Live Pink) keep their pill — they are
the brand layer's "new", not a count.
- **A party is pips.** `<PartyPips team>` (2026-11-12, one component): six
0.5rem pips, a filled one in its member's first type (`--pip`, mixed 72%
toward the foreground), an absent one a dim dot. Use it wherever a team is
counted and its slots are not on screen — never write "3/6" as text.
- **A sprite stands on its platform.** `.pokemon-card__media::before` and
`.type-platform::before` (index.css, one rule) are the battle base, toned in
the first type (`--card-type`). Static, behind the sprite; never animate it.
A sprite outside a PokemonCard takes `.type-platform` on its wrapper (the
meta ranking, the phone picker).
- **Where before what — and a way there.** The desktop header shows the rail
section before the title; since 2026-11-12 it is a button (`HeaderCrumb`)
that opens the section's other pages in a `.menu-surface`, each with its
rail tile. Pinned pages have no crumb; a phone has the dock.
**Second pass (2026-11-12) — the same moves, everywhere they apply:**
- **The tone follows the destination.** `--nav-hue` also tones the Mais
sheet's tiles and the search's page rows. On a phone "you are here" stays
Volt (the dock's lozenge, the sheet's current tile); on the rail it is the
tile's own tone on the neutral row.
- **The tile keeps its inset.** In the compact rail rows (screens up to
1200px tall — every laptop) the tile is 1.25rem in a 1.75rem row: the same
4px above and below it has in the 2rem row. A tile that fills its row reads
as a stripe.
- **A rank is a figure too.** "#1" in the muted mono, never a chip.
- **A cue is not a row.** The picker card's "+ Adicionar" bar is gone: the
whole card adds, and the cue is `.pokemon-card__add`, a round "+" at the
sprite's corner — Volt on hover/focus with a pointer, a quiet edged dot on
touch (nothing lives only on hover). One word repeated on seventy cards is
the same tell as seventy count pills.
- **An edge takes the object's colour.** The hovered / selected Pokémon card's
sticker edge is its type (`--card-sticker`, from `--card-type`, falling back
to `--color-primary`), like the filled team slot's. Bare `--sticker` — whose
edge is `--color-fg`, white on the dark themes — is only for objects with no
colour of their own. A white frame on a coloured object is the wound of
2026-11-12; Enzo flagged it as recurring.
- **A filter is quieter than a place.** `.segmented--quiet` (lifted neutral
thumb, foreground ink) for a segmented control that narrows or orders the
list under it; the Volt thumb is for "which page of this hub". One Volt
selection per screen — /meta had four, and the word "Uso" three times.
The app's identity is **restraint**. Calm comes from repetition, not decoration:
few values, used everywhere, landing on a grid. Every rule below exists because
breaking it produced a UI that read as *mole, solto e desconexo* (soft, loose,
disconnected) — see `docs/wounds.md`, 2026-08-28.
**v2 (2026-09-24, at Enzo's call: "não quero ficar amarrado, e sim evoluir").**
Restraint still governs *structure* — spacing, borders, colour, type. v2 adds a
**material layer** on top: controls behave like objects. A selection travels
instead of teleporting, a knob stretches under the finger, a figure rolls to its
new value, a favourite answers with the shiny sparkle, a theme change spreads
from the button that asked for it. Read **"v2 — the material layer"** below
before adding any motion; it is where this skill says yes, and the taste gate is
where it says no.
## The one rule that matters most
**Never invent a spacing value.** Every `padding`, `margin`, and `gap` must be a
`var(--space-*)` token. Not `0.35rem`. Not `0.4rem`. Not `0.6rem`.
The failure this prevents is subtle and cumulative. One card at `0.35rem` next to
one at `0.4rem` differ by 0.8px — invisible alone, but their edges never line up,
and no amount of polish elsewhere recovers the loss. The eye reads misalignment it
cannot consciously locate as cheapness. Before the 2026-08-28 sweep this codebase
used **58 distinct spacing values**, 27 of them crammed between 0.1rem and 2.5rem.
### The grid
Two tiers, both on a 2px grid. Fine control where components live, coarse rhythm
where layout lives.
| Token | Value | px | Use |
|---|---|---|---|
| `--space-0_5` | 0.125rem | 2 | hairline nudges, icon optical centering |
| `--space-1` | 0.25rem | 4 | tightest gap — icon↔label |
| `--space-1_5` | 0.375rem | 6 | chip padding, dense inline gaps |
| `--space-2` | 0.5rem | 8 | **default small gap** |
| `--space-2_5` | 0.625rem | 10 | button padding-inline (compact) |
| `--space-3` | 0.75rem | 12 | **default component padding** |
| `--space-3_5` | 0.875rem | 14 | input padding-inline |
| `--space-4` | 1rem | 16 | **default card padding / section gap** |
| `--space-5` | 1.25rem | 20 | roomy card padding |
| `--space-6` | 1.5rem | 24 | **section separation** |
| `--space-8` | 2rem | 32 | major block separation |
| `--space-10` | 2.5rem | 40 | page-level rhythm |
| `--space-12` | 3rem | 48 | hero padding |
| `--space-16` | 4rem | 64 | page top/bottom |
Bold rows are the defaults. **Reach for 2 / 3 / 4 / 6 first.** If a layout seems to
need `--space-2_5`, check whether the real problem is a sibling that should have
been `--space-3`.
Underscores (not dots) in token names: `--space-0_5`, not `--space-0.5`. A dot in
a custom-property name is legal CSS but breaks Tailwind's arbitrary-value parser
and several editor tools.
### Page rhythm (desktop layout tokens, 2026-10-09)
A view's *layout* — the gutter around the page, the gap between its columns,
the width of a side column — reads three variables set on `.app-shell`
(`app-shell.css`), never its own numbers:
| Token | Phone | Desktop (fluid 1280 → 1920) |
|---|---|---|
| `--page-gutter` | `clamp(1rem, …, 2rem)` | `--space-5` → `--space-10` |
| `--page-gap` | `--space-4` | `--space-4` → `--space-6` |
| `--page-rail-width` | 19rem | 17rem → 22rem |
Home's rail, the forum's rail and the builder's team column all use
`--page-rail-width`, so side columns line up across pages and grow on a
larger monitor. A new two-column view does the same:
`grid-template-columns: minmax(0, 1fr) var(--page-rail-width); gap: var(--page-gap)`.
Pick breakpoints for the medium monitors people actually use (1280–1600, minus
the 13.5rem nav): a third column that only fits from 1440 starts at 1440.
## Radius
`--radius-sm` 6px (badges/chips) · `--radius-md` 10px (buttons/inputs) ·
`--radius-lg` 16px (cards) · `--radius-xl` 22px (modals/panels) ·
`--radius-full` (pills/avatars). (One step rounder since 2026-09-24 — the old
8/12/16 read as a web dashboard, not a dedicated app.)
Use `--radius-full` for pills — never `999px` or `9999px`. `50%` is acceptable
only for true circles where the element is known square.
**Nesting rule:** an inner radius must be smaller than its parent's. A 12px card
containing a 12px element reads as a mistake even when it's deliberate. Inner =
parent − 4px, or share a corner.
## Elevation
`--shadow-sm` / `--shadow-md` / `--shadow-lg` / `--shadow-xl` only. They alias
per-theme `--elevation-*`, so they resolve correctly in all six themes.
**Never write a literal `rgba()` shadow.** It will be wrong in at least three of
the six themes — a shadow tuned on `dark` is invisible on `solar` and muddy on
`daybreak`.
**`--surface-sheen`** is the material of a top-level region panel: a 1px top
highlight on the dark themes, `--shadow-sm` on the light ones. It is applied in
one zero-specificity `:where()` list in `index.css` (desktop). Add a new view's top-level panel to that list
rather than writing the highlight inline.
**`--card-sheen`** (2026-10-09) is the material of a *card*: on the dark themes
a 1px lit top edge, a soft wash of light entering from the top (an inset shadow
offset downward, so it paints only the top band), and `--elevation-1`;
`--card-sheen-hover` brightens it for a clickable card. Light themes: `none`.
Depth on a near-black page has to come from light — a black drop shadow on
`#09090b` is invisible, which is why every card read "chapado". It is applied
in one zero-specificity `:where()` list in `index.css`; add a new card class
there, and never write the highlight inline. It is a shadow, not a gradient,
because a card's own `background:` shorthand would erase a background-image.
`--canvas-light` is the faint pool of the theme's primary at the top of the
page on dark themes (desktop, `.app-shell__content`, scrolls away) — the room
the cards stand in. Neither one animates.
**The page's ground** (2026-10-09, Enzo): behind the page — never behind the
rail — a dot grid (`--canvas-dots`, every `--canvas-dot-gap`) and four hairline
shapes (`--canvas-shapes`: two concentric rings top-right, an arc and a faint
pool bottom-left), all mixed from `--color-fg` / `--color-primary`, so they
follow every theme. They are backgrounds on `.app-shell__content` with
attachment `scroll` (they stay put while the page moves over them), desktop
only. Opaque cards are what make it work: keep it to these layers, keep it
static, and never put the pattern inside a card or panel. `--canvas-shapes` is
exactly four layers — `app-shell.css` lists sizes and attachments by position,
so adding a shape means updating both lists.
Prefer a border over a shadow. Most surfaces need `1px solid var(--color-border)`
and nothing else. Reserve shadow for things that genuinely float: modals,
dropdowns, drag states. Never both on the same element.
## Never nest a border inside a border
**This is the rule that decides whether the app looks calm.** A bordered element
placed inside an already-bordered container draws a box inside a box, and the
effect compounds: the home page once rendered **299 bordered containers, 139 of
them nested**, which is what made it read as busy no matter how well-tokenised it
was.
Inside a bordered panel, children separate themselves with **fill**, not lines:
```css
.panel { border: 1px solid var(--color-border); background: var(--color-surface); }
.panel .card { border: none; background: var(--color-surface-raised); }
.panel .card:hover { background: color-mix(in srgb, var(--color-fg) 7%, var(--color-surface-raised)); }
```
The container owns the border; everything inside owns a fill. Corollaries:
- **A filled button needs no border.** A solid `--color-primary` fill already
reads as a button.
- **A selected state is an inset ring, not a border**:
`box-shadow: inset 0 0 0 1px var(--color-primary)`. A real border changes the
element's size and shifts its neighbours when selection moves.
- **`border-style: dashed` means "empty / absent / locked" — nothing else.** An
unfilled team slot, an empty-state panel, a locked hint card: correct. A real
control, a populated card, or a panel that merely wants texture: wrong, because
it tells the user something is missing when it isn't.
- **A header inside a card rarely needs a divider.** Drop the `border-bottom` and
let the type hierarchy carry it.
Before adding any border, ask what it separates that a fill or a gap could not.
## Restraint — what NOT to do
The temptation is to add. Calm comes from subtracting.
- **One accent per view.** If everything is highlighted, nothing is.
- **No gradient as decoration.** Gradients are for the one hero surface or a data
bar that encodes a value. A gradient on a card background is noise.
- **No hover translate on large surfaces.** `translateY(-2px)` on a card makes the
page feel like it wobbles — that is literally the "mole" complaint. Hover
belongs in `background-color` and `border-color`. Reserve transform for small,
clearly-clickable objects.
- **State changes are 150ms** (v2 adds three named exceptions — travel,
reward, theme reveal — see "v2 — the material layer"). `--duration-fast` for hover,
`--duration-slow` (250ms) for entrances. Nothing above 350ms except the
deliberate sprite blur reveal.
- **Borders separate; whitespace groups.** Before adding a divider, try removing
it and increasing the gap by one step. It is almost always better.
- **Type: 3 sizes and 2 weights per view, max.** Hierarchy comes from size *and*
color (`--color-muted`), not from adding weights.
- **Section headings are sentence case, never ALL CAPS.** A heading set in
800-weight caps at 0.08em tracking is the loudest thing on a page it only meant
to organise, and caps are measurably slower to scan. Caps survive in exactly one
place: tiny pill badges (≤ 0.7rem) where the extra tracking genuinely aids
legibility. Losing caps loses apparent size, so step the size up and the weight
down when converting one.
- **Don't stack de-emphasis.** `opacity: 0.5` on top of `--color-muted` pushes
text to the edge of legibility. Muted color alone is the de-emphasis.
## Colour is light on a dark theme (2026-11-12, the Home's hearth pass)
A subject's colour (a type, a tone) reaches a dark surface as **light**, not
as paint. Three rules, each from a measured failure (`docs/wounds.md`,
2026-11-12):
- **Never flat-mix a subject's colour into the surface for a fill.**
`color-mix(in srgb, type N%, var(--color-surface))` drags the hue toward
the violet surface; for the yellow-ish types (Electric, Ground, Rock, Bug,
Normal, the gold) violet is the complement, so the result is khaki by
construction. A card's band is `--color-surface-raised` with the tone as a
pool under the platform:
`radial-gradient(62% 95% at 50% 100%, color-mix(in srgb, var(--tone, transparent) 30%, transparent), transparent 74%)`.
One family down the page, each card with its own lamp (`home-grid.css`).
- **Where a whole surface takes a subject's colour** (the Home's hero — the
one tinted surface), keep the hue and set the lightness instead of mixing:
`oklch(from var(--hero-type) 0.3 calc(c * 0.45) h)`, behind
`@supports` and inside `light-dark()` so the light themes keep their
pastel mix (`applyTheme` sets `color-scheme`, which is what
`light-dark()` reads — no theme list in a view stylesheet). Dragon comes
out where the old mix put it; Rock is bronze, not olive.
- **No radiating rays** on anything whose tone can be red or gold: a fan of
rays on a red field is a rising-sun flag. The Home's motifs are the Town
Map's grid, a halftone, rings, speed lines; an aura is rings that breathe.
The light themes were never the problem — a pastel mix into white keeps its
hue — which is why this is written for the dark ones, not as a new token.
## Canon colours (types, game versions)
Pokémon type colours and game-version colours are the documented exception to "never
write a raw colour" — they are canon and theme-independent. That exemption covers the
*value*, not the *rule you build with it*: a canon colour arrives as a custom property
and is **mixed into theme tokens**, never applied raw as ink.
The standard is `.type-chip` (`index.css`, via the `TypeChip` component) — icon +
label, outlined and tinted in the type's own colour:
```css
border: 1px solid color-mix(in srgb, var(--type-chip) 45%, transparent);
background: color-mix(in srgb, var(--type-chip) 14%, transparent);
color: color-mix(in srgb, var(--type-chip) 45%, var(--color-fg));
```
Reuse those three mixes for any other canon-coloured chip. The label mix is the load-
bearing one: mixing toward `--color-fg` darkens it on the light themes and lightens it
on the dark ones, so one rule survives all six. It is measured — at 45% the worst of
the 18 types clears 4.5:1 everywhere; at 70% `electric` scored 2.78:1 on `light` and
raw `#705746` (dark) is illegible on any dark theme. **Never set a canon colour as
`color:` directly.**
Solid-fill `.type-badge--*` stays for dense grids where a type is counted, not read.
## The game screen exception (`.ds-screen`, 2026-10-15)
The Champion Challenge (`/challenge`, `src/styles/champion-challenge-ds.css`) draws
two Nintendo DS screens, and **inside a `.ds-screen` it is the game, not the app**.
Three rules replace the app's there — and only there:
- **Unit: the DS pixel.** Every size and offset is `calc(N * var(--px))`, where
`--px` = screen width / 256 (`useScreenScale`). Spacing tokens would break the
256 × 192 grid the sprites are drawn on. Sprites render 1:1 (Gen 4 battle
sprites are 96 × 96 DS px; never scale them to another size — 80/96 blurred
them and lifted them off their platforms).
- **Palette: `--ds-*`, declared once on `.ds-screen`.** Canon DPPt/HGSS colours,
theme-independent (a DS screen does not go dark with the app). No raw colour
anywhere else in a screen; type colours arrive as `--type` / `--fx-color` and
are mixed with `--ds-*`, never used raw as ink.
- **Type: DotGothic16, regular only (`font-synthesis: none`).** The one fourth
family the app has, loaded with the route's CSS and used nowhere else. Its
thin 1-px strokes match the DS text box and keep C/O and 8/S apart at small
sizes (Pixelify Sans failed that); a faux-bold pixel font smears, so the
hierarchy is size and colour, as on the DS.
Two palettes live there: `--ds-*` (the room, the field, the DS console's paper
and the Pokétch) and `--hud-*` (everything laid over the field — since
2026-11-10, at Enzo's call, the site's material inside the screen: ink
surfaces, one Volt primary on its lip, raised fills with an edge, moves tinted
by their type, warm/cool stat chips; the `--bw-*` names that remain point at
it). BW's shapes stay — the slanted data boxes, the FIGHT capsule, the menus'
layout. `.ds-screen` is no longer "untouched" by the Neon Sticker theme: its
HUD is that theme, in DS pixels and DotGothic16. Two layouts
(`useConsoleLayout`): **single** — one screen holds everything on a desktop,
the HUD as a strip inside it — and **dual** — two stacked screens on a phone,
the bottom one for touch. Every sub-menu ends in the same VOLTAR capsule
(`.bw-cancel`).
The same exception covers two more pieces of the game (2026-10-20): **the VS
card** (`.ds-vs`, `src/styles/battle-versus.css`) — a full-screen cinematic with
its own canon arcade palette (`--vs-*`, declared once on `.ds-vs`) and sizes
derived from its band's height — and **the friend battle's chat and lobby**
inside a screen or rail (`src/styles/battle-pvp.css`, DS pixels and `--ds-*` /
`--bw-*`). Their chips on the console's bar are app UI and follow every rule.
Motion inside a screen may use game timings (a 160 ms walk step, a 450 ms
send-out) but stays transform/opacity and stops under reduced motion. The
console frame around the screens (`.ds-console`, its bar, the D-pad) is ordinary
app UI and follows every rule in this skill.
## Type
**Two voices, and they do not swap jobs** (changed 2026-09-14 at Enzo's call;
before this it was Inter for everything, and the pairing below is what replaced
it — a single neutral sans made every level of the hierarchy arrive in the same
register).
| Token | Face | Carries |
|---|---|---|
| `--font-display` | JetBrains Mono | headings `h1`–`h6`, panel titles, eyebrows, nav and tab labels, badges, **every figure** |
| `--font-body` | Space Grotesk | running prose, descriptions, team and Pokémon names, inputs, long labels |
| `--font-mono` | JetBrains Mono | code, ids, anything with `tabular-nums` |
Structure is mono because the fixed advance genuinely aligns a column of counts,
streaks and percentages — not for the look. **Never set `--font-display` on
running prose**: a paragraph of mono is slower to read and there is no third
face to fall back to. Never introduce a fourth family, and never a serif.
Two mechanical consequences of the swap, both already applied in `index.css`:
mono is wide, so display type carries negative tracking (`-0.045em` on `h1`–`h3`,
`-0.03em` below) or a headline measures ~8% longer than its Inter original and
starts wrapping in cards that used to hold it; and Space Grotesk is a `300..700`
variable font, so a `font-weight: 800` written for Inter clamps to 700 — do not
"fix" that by synthesising bolder weight, use 700.
## Alignment
Elements in a column share a left edge. Elements in a row share a baseline. If two
things nearly align but don't, that is the single most damaging thing on the page —
either commit to alignment or make the offset unmistakably intentional (≥ 2 steps).
Sibling cards get identical padding. A grid's `gap` should equal or exceed its
items' internal padding, never fall between.
## Sizing must scale
**Desktop density (2026-10-09):** from 1024 to 1919px the root runs at 90%
(`--ui-density` × 0.9 in `index.css`) — automatic browser-zoom-90% for laptops
and medium monitors; 1920+ gets the full baseline. Because of this, anything
sized in `px` is 11% larger than its neighbours in that band. One more reason
the rule below has no exceptions.
Size type and spacing in `rem`/`em`, never `px`. The interface-scale control
(`--ui-scale`) works by scaling the root font-size — `px` values silently opt out
and break the layout at non-100% scale. The one exception is the iOS zoom guard
(`input { font-size: 16px }` under 768px).
## Motion
One curve, one duration, unless there is a reason. `var(--ease-smooth)` with
`var(--duration-fast)` covers essentially every state change (hover, colour,
fill); `--duration-slow` for entrances. Three more have a job each (2026-09-22):
| Token | Job |
|---|---|
| `--ease-out` + `--duration-press` (100ms) | a press, and anything answering one — starts fast, settles long |
| `--ease-drawer` + `--duration-entrance` (350ms) | anything that slides in from an edge: sheets, the drawer. The iOS sheet curve; nothing else uses it |
| `--press-scale` (0.97) | how far a pressed control sinks — one value for every button |
Press with the **`scale` property**, not `transform: scale()`: it composes with a
control's own translate, so a centred icon button doesn't jump when pressed. And
list `scale` in the transition, or the press snaps. Buttons, icon buttons and
small in-card controls give; cards, rows and nav items never do (a grid that
shrinks under the finger reads as the page wobbling) — their press is a fill.
`--ease-spring` / `--ease-bounce` / `--ease-out-expo` exist for deliberate
moments, not for variety.
**Never write a bare `ease`.** It is `cubic-bezier(0.25, 0.1, 0.25, 1)` — a
visibly different deceleration from `--ease-smooth`, so elements animating side
by side settle at different rates. That mismatch is a large part of what reads as
"not fluid".
Scrollable panels get `overscroll-behavior: contain` (the `.custom-scrollbar`
utility now carries it). Without it, reaching the end of an inner list hands the
remaining momentum to the page behind it, and the whole app lurches.
**Never `transition: all`.** It animates layout properties (width, height,
padding) along with the one you meant, which is both janky and expensive. List
the properties: `background-color, border-color, color, box-shadow, opacity,
transform` covers essentially every hover state in this app.
**No infinite animation on a repeated element.** A pulsing glow on one card is a
highlight; the same glow on the fifty cards of a results grid is an alarm, and
fifty forever-animating shadows to composite. If a whole list qualifies for an
effect, the effect is not carrying information — make it static.
## v2 — the material layer (2026-09-24)
v1 stopped the UI wobbling. It also left it inert: a selection jumped between
segments in one frame, a switch was a checkbox in a costume, a loader was the
spinner every template ships. v2 keeps every v1 rule for structure and adds
five rules for *behaviour*. The primitives live in `src/styles/interactions.css`
(loaded after `index.css`) and `src/components/{Switch,Loader,RollingNumber,
ShinyBurst,ThemeToggle}.jsx`, `src/hooks/useShinyBurst.js`,
`src/store/{useConfirmStore,themeChoice}.js`.
### The five rules
1. **Continuity — a selection travels.** When the chosen option changes, the
thing marking it moves there; it never disappears here and reappears there.
The same holds for an object opened from a list: a Pokémon's sprite flies
from its card into the detail hero (`navigateWithHero`, `utils/heroTransition.js`;
mark the destination with `<Sprite heroTarget>` or `data-vt-hero`, the source
with `data-hero-source={id}`; wait with timers, never rAF — rendering is
suspended while a view transition's update is pending).
`.segmented` draws one thumb and `.tabs` one underline, positioned against
the selected item with CSS anchor positioning and transitioned on the glide
spring — no JS, no measuring, every call site for free. It is gated on
`@supports (anchor-scope: all)` (Chrome/Edge 131+, Safari/iOS 26+, Firefox
147+); `anchor-scope` is the gate, not anchor positioning, because two
controls on one screen must not share an anchor name. Older engines keep the
v1 per-item fill. **Direct children only** — the selected item must be a
direct child of the track (`:has(> …)` hides the thumb when nothing is
selected).
2. **Physicality — controls give.** Presses sink (v1); a switch knob stretches
toward the side it is leaving (`.switch:active` widens it) and springs
across. Width on a 16px absolutely positioned knob is fine; never animate
the size of anything in flow.
3. **Reward — once, only for the user's own act.** `useShinyBurst` (the shiny
sparkle from the games) fires from the click that earned it: starring a
Pokémon, flipping a sprite to shiny. Never on load, never from data that
arrived (Firestore, another device), never on a list of things, never looped.
If the effect would fire on a page load or on fifty cards at once, it is
decoration and it goes.
4. **Figures move, they do not jump — on change.** `<RollingNumber>` rolls each
digit column to its new value (mono digits share one advance, so columns
never jitter). It renders its first value still: **counting up on load is a
template tell.** Use it where the user is changing the number (EVs left).
5. **A theme change is an event.** `chooseTheme(id, originFromEvent(e))` spreads
the new theme from the pressed control as a circular same-document View
Transition (`utils/themeTransition.js`, scoped by `html[data-theme-transition]`
so other view transitions keep the platform cross-fade). No origin → instant
(a theme restored on boot is not an event).
### Physics tokens
| Token | Curve | Job |
|---|---|---|
| `--ease-glide` + `--duration-glide` (520ms, arrives visually ~200ms) | spring ζ 0.72, +3.8% | anything that travels: thumb, underline, knob, a figure's digits, a toast springing home |
| `--ease-pop` + `--duration-pop` (690ms) | spring ζ 0.42, +23% | a one-shot reward: the favourite pop, the check tick |
| `--ease-out` + `--duration-reveal` (560ms) | — | the theme reveal, and nothing else |
The springs are **real**: a damped oscillator simulated and sampled into
`linear()`, with cubic-bezier fallbacks for engines without it. The durations
include the flat settle tail, so they read longer than they feel. Do not
hand-edit a point — one bad sample is a visible hitch. Regenerate:
```bash
node - <<'EOF'
// x'' = -k(x-1) - c x' from rest; prints CSS linear() + its duration.
function spring(z, settle, samples) {
const w = 4 / (z * settle), k = w * w, c = 2 * z * w, dt = 1 / 2000;
let x = 0, v = 0, t = 0, last = 0; const h = [];
while (t < 3) { v += (-k * (x - 1) - c * v) * dt; x += v * dt; t += dt; h.push(x);
if (Math.abs(x - 1) > 0.004 || Math.abs(v) > 0.05) last = t; }
const dur = Math.ceil(last * 100) * 10, pts = [];
for (let i = 0; i <= samples; i++) pts.push(i === samples ? 1 : +h[Math.min(h.length - 1, Math.round((i / samples) * dur / 1000 / dt))].toFixed(3));
return `${dur}ms linear(${pts.join(', ')})`;
}
console.log('glide', spring(0.72, 0.36, 28));
console.log('pop ', spring(0.42, 0.5, 36));
EOF
```
### The taste gate
Before adding any effect — from React Bits, Kokonut UI, a Dribbble shot or your
own head — it has to answer yes to all of these (uizze: *show the agent what
good looks like*; this is what good looks like here):
- **Does it answer something the user just did**, or say something they need to
know? Motion that answers nobody is decoration.
- **Would it survive being on fifty cards?** If not, it is a highlight — and a
highlight on everything is an alarm.
- **Is it transform/opacity only on phones**, and does it degrade to the v1
behaviour under reduced motion and on older engines?
- **Is it ours?** The shiny sparkle, the Poké Ball wobble, the Gengar — the
Pokémon vocabulary is the identity. A generic effect a template could ship is
the slop this gate exists to stop.
Rejected on purpose (2026-09-24 survey): WebGL/shader backgrounds (Aurora, Silk,
Beams, Plasma…), cursor effects (SplashCursor, ClickSpark, BlobCursor),
spotlight/glare/border-glow cards on grids, liquid glass and any backdrop blur
on phones, headline text gimmicks (SplitText, BlurText, GlitchText, TextType,
ShinyText on titles), count-up on load, particle/magnet/attract buttons,
gradient text. Built from the survey since: the ⌘K global search (Kokonut
*action-search-bar*), the card → detail sprite transition and the PokéPuzzle
name reveal (`DecryptText`, React Bits *DecryptedText* — plays only for a win
that just happened), and a forum post that arrives while you read rising in
once (`.forum-message-item--new` — never the rows present at open). Candidates
that passed but are not built yet: ScrubField on EV inputs. Declined by Enzo
(2026-09-24): SwipeRow on the phone's team list.
## Interaction tokens
Do not hand-write hover/active tints. Use these — they are defined once in
`index.css` and resolve per theme, and they mix toward `--color-fg`, so "raise on
hover" correctly means *darker* on the light themes and *lighter* on the dark
ones:
| Token | Use |
|---|---|
| `--color-surface-hover` | hover fill on any row, tile, card, menu item |
| `--color-surface-active` | selected/current fill (nav item, active tab) |
| `--color-on-primary` | text/icons on a filled `--color-primary` or `--color-danger` |
| `--ring-primary` | selection ring: `box-shadow: var(--ring-primary)` |
| `--color-border-strong` | the visible edge of a **control** — input, outline button, dashed empty slot. `--color-border` stays for regions; on the light themes it is `#f7f7f7` on white, which gave the search field no edge at all |
| `--color-surface-elevated` | a thumb lifted onto a raised track (active segment). Lighter than raised on dark themes, white on light ones |
Tailwind exposes all of these (`bg-surface-hover`, `border-border-strong`, …), and
since 2026-09-22 opacity modifiers on theme colours work (`bg-primary/15` is a
`color-mix()`); before that they silently compiled to nothing. Still never on
text: `text-muted/60` is opacity stacked on the de-emphasis.
A hover tint written inline at each call site drifts, and drift is the whole
reason this document exists.
**Known defect — `--color-on-primary` is white in every theme, and in four of
them that fails.** Measured white-on-`--color-primary` contrast: `midnight`
2.14, `eclipse` 2.72, `solar` 2.94, `dark` 4.13 — all under the 4.5 AA needs for
body text (`light` 6.14 and `daybreak` 5.17 pass). Dark ink would score 8.80 /
6.93 / 6.42 / 4.56 on those same four. Fixing it means computing the token from
the primary's luminance in `applyTheme` (which already writes the theme's colors
onto `:root` as inline properties, so CSS alone cannot do it). That flips the
text on every filled button in four themes, so it is a deliberate visual
decision, not a sweep — do not change it without asking. Until then, a filled
primary button is legible but not AA-compliant on the dark themes; prefer it for
short labels, never for body copy.
**Never write a raw colour.** No hex, no `rgb()`, no `rgba()` for anything that
is part of the interface. Brand colours written as raw triples (`rgba(124, 58,
237, …)`) do not follow the theme — the app shipped 41 of them plus a
`--color-primary-rgb` that was **never defined anywhere**, so its fallback indigo
was wrong in all six themes. The exceptions are Pokémon type/stat colours (canon,
theme-independent) and scrims over photography, where white/black is correct
regardless of theme.
## Component vocabulary
The controls the claude.ai reference is built from exist once, in `index.css`.
Reach for them before writing a control; the app had twelve button systems and
eight segmented controls before this list existed (2026-09-22).
| Need | Use |
|---|---|
| a button | `.btn` + a voice (`btn-primary` / `-secondary` / `-outline` / `-ghost` / `-danger`) + optional `btn-sm` / `btn-lg`, `btn-icon` (square, needs `aria-label`), `btn-block` |
| 2–5 exclusive options, all visible | `.segmented` > `.segmented__item[aria-pressed]` (`--sm` / `--lg` / `--block`) |
| sections of one object | `.tabs` > `.tabs__item[aria-selected]` |
| a count in a tab or segment | `.count-badge` |
| a filter or a sort (2–5 options) under a hub's own switcher | `.segmented.segmented--quiet` |
| a team's size where its slots are not on screen | `<PartyPips team>` (or `count`) |
| a sprite outside a PokemonCard | wrapper `.type-platform` + `--card-type` |
| a dialog | `.modal-scrim` > `.modal-panel` with `ref={useModalA11y(onClose)}`; `.modal-header` / `.modal-title` / `.modal-subtitle` / `.modal-close` / `.modal-body` / `.modal-footer` (`--ruled` when the body scrolls under it). Phones get a draggable sheet and every dialog an exit animation for free |
| a form row | `.field` > `.field-label` + `.input-clean` / `.select-clean` / `.textarea-clean` |
| a short form that IS the screen (sign in, a code) | `.field.field--filled` — no edge, a fill, `--control-h-lg`; a leading icon is `.field__control` > `.field__icon` + the input (2026-11-09) |
| the one word a headline is about | `<em className="accent-word">` — the primary as a word, colour only, one per screen (2026-11-09) |
| a menu | `.menu-surface` > `.menu-item` |
| **v2** a yes/no setting | `<Switch checked onChange label description variant="row" size="sm" tone>` — never two buttons that each mean half of a boolean |
| **v2** a checkbox | native `<input type="checkbox" className="check">` inside a `<label>` |
| **v2** anything loading | `<Loader size="xs\|sm\|md\|lg" label block scene />` — never a CSS ring, never `animate-spin` on a Poké Ball. `md`/`lg` (a region waiting) draw a scene of the mascot picked by what is loading (`scene`: capture · battle · pokedex · think · search; `ball` inside a `.ds-screen` or a solemn moment); `xs`/`sm` (controls, rows) stay the rocking ball |
| **v2** a figure the user is changing | `<RollingNumber value format />` — on change only |
| **v2** a reward for the user's own tap | `const shiny = useShinyBurst()` → `shiny.fire()` in the click, `{shiny.burst}` inside a `position: relative` control, `is-bursting` on it while `shiny.isBursting` |
| **v2** an icon that moves | `data-glyph="<motion>"` on the icon's wrapper (`glyphMotion(key)` in `utils/glyphMotion.js` picks it by destination: hop · clash · wobble · rise · lift · snap · scan · turn · open · swing · pop · nudge); a trigger in `interactions.css` "Glyph motion" plays it once (rail hover, the dock tab becoming current, the hero's action). Never a second set of keyframes (2026-11-09) |
| **v2** a question before destruction | `if (await confirmAction({ title, message, confirmText }))` — never `window.confirm` |
| **v2** a reversible destructive action | do it, then `toast.info(title, { actions: [{ label: t('toast.undo'), onClick }] })` — undo beats confirm |
| **v2** the theme | `chooseTheme(id, originFromEvent(event))` / `<ThemeToggle>` — never `changeTheme` from a control (it does not save) |
| a hub page's search / toolbar | `<HubSlot>` (`components/HubSwitch.jsx`) — it shares the hub switcher's row (one height, pill fields); never a search row of its own under the switcher (2026-11-12) |
| **v2** find anything | the global search (`CommandPalette`, `setIsSearchOpen` in AppLayout, ⌘K / `/`) — add searchable data as a group in it, never a second search dialog |
Control heights are `--control-h-sm/md/lg` (1.75 / 2.25 / 2.75rem): a button, an
input and a segmented control in one toolbar share a height.
**These rules come after `@tailwind utilities`, so they beat a utility on the
same element.** Size a `.btn` with its modifier, not `h-8 px-2` (the utility
loses). Never hide a `.btn` / `.tabs` / `.segmented` with `hidden` — their
`display` wins; render them conditionally. Where a call site genuinely needs to
override (a dialog's `z-[60]`), the primitive declares that property in
`:where()` so the utility can win.
## Drift detection
Run these before claiming a visual task is done. Both should print `0`.
```bash
cd src
# Ad-hoc spacing literals (the cardinal sin)
grep -rhoE "(padding|margin|gap)[a-z-]*:[^;]+" styles/ index.css \
| grep -oE "[0-9]*\.?[0-9]+(rem|px)" | grep -v "0px" | sort | uniq -c | sort -rn
# Literal shadows (theme-breaking)
grep -rnE "box-shadow:[^;]*rgba" styles/ index.css | grep -v "^\s*/\*"
```
**Undefined tokens fail silently — audit for them.** A `var(--typo)` with no
fallback makes the whole declaration invalid, so the rule just does nothing and
nothing warns you. This app carried 15 of them, including a dot-named
`--space-1.5` / `--space-2.5` / `--space-3.5` (the real tokens use underscores),
which meant a dozen paddings and radii silently did nothing for months.
```bash
cd src
python3 - <<'EOF'
import re, pathlib, collections
files = sorted(pathlib.Path('styles').glob('*.css')) + [pathlib.Path('index.css')]
defined = set()
for p in files:
defined |= set(re.findall(r"^\s*(--[\w.-]+)\s*:", p.read_text(), re.M))
for p in list(pathlib.Path('constants').glob('*.js')) + list(pathlib.Path('components').rglob('*.jsx')):
defined |= set(re.findall(r"['\"](--[\w.-]+)['\"]", p.read_text()))
bad = collections.Counter()
for p in files:
for m in re.finditer(r"var\(\s*(--[\w.-]+)\s*(,|\))", p.read_text()):
if m.group(1) not in defined and m.group(2) == ')':
bad[m.group(1)] += 1
for t, n in bad.most_common(): print(n, t)
EOF
```
Legitimate exceptions — `1px` borders, `0`, `100%`, `clamp()` fluid gutters,
`calc()` against a token, and values inside `@keyframes` — are fine; everything
else is drift. When an exception is deliberate, leave a comment saying why, or the
next sweep will "fix" it.
## Layout scroll invariant
`.app-shell__content` is the single scroll container. Anything that should sit at
the bottom of a short page must be pushed there with `margin-top: auto` inside a
`min-height: 100%` flex column — never left to fall under the content, which
creates a phantom scroll that exists only to reveal a footer.
There is exactly one vertical scrollbar in this app. If you introduce a second,
you have made a mistake.
**Never size anything to the screen with a viewport unit — pin it or fill it.**
`100vh` is the *large* viewport in mobile Safari, and `100dvh` counts the status
bar in an iOS home-screen app (viewport-fit=cover) while the web view starts below
it. Both made the shell taller than the screen on 2026-09-10; the second one
dragged the sticky header off the top on a real iPhone. The shell is
`position: fixed; inset: 0`, and everything inside it fills through the layout:
`height: 100%` of a definite parent, or `flex: 1 1 0; min-height: 0` down a flex
chain (see the feed in forum-view.css). A `calc(100dvh - Xrem)` is a guess about
everything above and below it, and it goes stale the moment either changes.
**The root scroller does not rubber-band** (`overscroll-behavior-y: none`). Mind
`.custom-scrollbar`: its `contain` has the same specificity and loads later, so an
override needs the compound selector — and always read the computed value back.
**Below 1024px there is no page footer.** Site chrome — credit, legal, version,
social links — lives in the drawer tail (`.app-shell__drawer-meta`). A phone page
ends where its content ends; do not add anything that re-creates a footer band.
## Phones (below 1024px)
The phone layer has its own rules (2026-09-24 pass — `docs/wounds.md`). Write them
inside `@media (max-width: 1023px)`, or behind `useMediaQuery(maxWidthBelow('lg'))`
in markup; desktop must not move.
- **The page is the panel.** A view's top-level panel is never a box on a phone: no
border, no fill, no padding of its own — the shell's gutter is the gutter. What was
inside it carries `--color-surface`. A control or card placed straight on the page
takes `--color-surface`, **never `--color-surface-raised`** (on the light themes that
is `#f6f6f7` on `#f2f2f3` — nothing).
- **Chrome is solid.** No `backdrop-filter` below 1024px on anything over the scroller
(bars, sticky strips) or behind a sheet (scrims dim, they don't blur): a blur is
recomputed for every frame the content under it moves. Make the background opaque.
- **No entrance per item.** The page fades in on every route change (app-shell.css);
`.motion-enter`, `.motion-stagger` and per-card `fade-in-up` are off on phones. And
never leave an animation with `both` fill on a list item — its final identity
transform is a stacking context and a containing block for as long as it lives.
- **Only transform and opacity loop.** An infinite animation on a phone animates
`opacity`/`transform`/`scale` only — never `box-shadow`, `filter`,
`background-position` or a size. Paint the glow once; breathe its opacity.
- **`content-visibility: auto` for long lists of cheap rows** (Speed Tiers halved its
scroll cost), with `contain-intrinsic-size: auto <row height>`. Measure before
keeping it: on a short list of heavy cards it only moves first paint into the scroll.
Never on items whose children overflow them, on sticky elements, or on lists whose
scroll position is restored (`useScrollRestoration`).
- **The tab bar is a floating dock** (2026-09-24): a pill lifted off the bottom
edge, shrinking to an icon-only capsule while the page scrolls down
(`useDockCompact`, `.is-compact`). The shrink is `scale`/`translate`/`opacity`
only — never animate its size. Bottom reservations are computed from the dock's
row + padding + offset in `app-shell.css`; derive from those, don't restate.
- **The tab bar is the navigation.** "Mais" opens `MobileMoreSheet`; nothing else does,
and the sheet never lists what the bar shows.
**Cascade order — beating a utility from a view stylesheet.** The view stylesheets load
*before* `index.css` (the views barrel pulls them in with `App`, ahead of
`import './index.css'` in `main.jsx`), so a single-class rule in `src/styles/*.css`
**loses** to a Tailwind utility on the same element. Override a utility-styled element
with a compound selector (`.view-root .thing`), and read the computed value back.
(Stylesheets of views that are *not* in the barrel — Meta, Gyms, battles — load after
it.) See the dispattern in `docs/wounds.md`.
## Touch
Below 1024px this app is used with a thumb. Three rules, from the 2026-09-10 wounds:
- **Nothing may be visible only on hover.** Tailwind runs with
`future.hoverOnlyWhenSupported`, so `hover:` never fires on a phone —
`opacity-0 group-hover:opacity-100` is *permanently hidden* there. Give it a
`[@media(hover:none)]:` state, or don't hide it. Hand-written `:hover` in CSS is
gated **by the build** (`scripts/lib/postcssHoverGate.mjs`): it moves into
`(hover: hover) and (pointer: fine)` and its fill/colour declarations are
re-emitted on `:active` for touch. So write hover as fills and colours — that
copy is the phone's press feedback — and never gate it again by hand.
- **Grow the hit area, not the control.** A small secondary control keeps its
calm size and gets `.touch-target` (index.css — an invisible `::after` under
`(pointer: coarse)`), or `.touch-target touch-target--y` when its neighbour
touches it. The utility sets `position: relative`, so an absolutely positioned
control gets its own `::after` in its CSS instead.
- **A list that collapses to one column is multiplied by its column count.**
Past ~3 screens on a phone, reveal it in pages with `useProgressiveReveal` +
`ShowMoreButton`, and never stack a secondary section under an unbounded list.