# Design system The popup is one paper surface. Its tokens live at the top of `src/popup/popup.css`; components use those tokens instead of one-off values. ## Tokens - Palette: `--fg`, `--muted`, `--bg`, `--card`, `--border`, `--red`, `--gold`, `--good`, `--warn`, `--bad`, and their paired text colors. `--ink` is the sticker outline and stays visible on both papers. - Focus: `--focus` and `--focus-ring` are deliberately not the brand red, so a focus ring never reads as an error. - Space: `--space-1` through `--space-6` (4px base). - Radius: `--radius-1` through `--radius-3`. - Type: `--text-xs`, `--text-sm`, `--text-base`, `--text-md`, `--line-tight`, `--line`. - Motion: `--dur-1`, `--dur-2`, `--ease`. The reduced-motion media query turns both animations and transitions off. - `--tap` is the minimum hit target for an icon or text control. Dark mode is chosen by `data-theme` on ``. `public/theme-init.js` reads the stored choice synchronously before the stylesheet, so the first paint is already correct; `src/popup/theme.ts` owns the control and follows the OS while the choice is System. The first-run welcome page includes the same script and uses the same key; its palette is a separate copy because it is a larger surface, but it follows the same theme choice. ## Components - Badges (`.badge`): one identity shape for accounts, publications, posts, authors and labelers. The kind changes the media shape, never the color; color is reserved for severity. - Buttons (`.btn`, `.btn.primary`, `.btn.sm`, `.icon-btn`, `.link-btn`): the minimum height is 32px (26px small, 24px for icon and text links). - Menus (`.menu`, `.item`, `.menu-row`): wired through `src/popup/menu.ts`. Arrow keys, Home/End, Escape and Tab are handled; opening focuses the first item and Escape returns focus to the trigger. - Disclosures (`src/popup/disclosure.ts`): a trigger and a panel, with `aria-expanded` and `aria-controls`. Clicking inside never closes a form. - Tabs (`#tabs`, `.tab`): the popup's primary navigation. Three `role="tab"` buttons select one `role="tabpanel"`; arrow keys, Home and End move selection and focus, and the inactive panels are hidden. - Status pills (`.pill`): severity is both a tone and a shape, so it survives without color vision. ## Accessibility rules - Every interactive element gets the global `:focus-visible` ring. Do not set `outline: none` without an equivalent replacement. - New menus use `wireMenu`; new panels use `wireDisclosure` or are a card whose `render` owns its state. - Status text goes in a live region: `#status` and `#action-note` are `role="status"`; errors use `role="alert"`. - Keyboard focus never moves into a hidden panel. Opening a menu or disclosure moves focus; closing returns it. Tabs keep focus on the selected tab while arrow keys move through the tab list. - Color is not the only channel for a state. Badges use shape, pills use an icon, and focus uses an outline. - `prefers-reduced-motion`, `prefers-contrast: more` and `forced-colors` each have a rule. Keep them working when adding color or motion. - Forms have a label (visually hidden when the design has no room), and a submit button inside the form. ## Adding a surface 1. Use the existing tokens; add a token only when a value repeats. 2. Prefer `.badge` for an identity, `.btn` for an action, `.pill` for a state, and a tab when the surface is a new top-level view. 3. If it opens, wire `wireMenu` or `wireDisclosure` and give the trigger `aria-expanded`/`aria-controls` through it. 4. Add the surface to the popup's card registry when it fetches or owns a section; see `src/popup/cards/card.ts`. 5. Check light, dark, keyboard-only, reduced motion and forced colors.