# DESIGN.md — how Siftlode looks and behaves This is the one written source of truth for the UI: principles, tokens, the canonical solution per pattern, and the interaction rules. Screens are measured against it. A pattern that has more than one look in the code is either a decision still open here (marked **Pending**) or a violation to fix. **Status:** being written in E28. Chapters marked _Decided_ are in force. Chapters marked **Pending** are open decisions, each rendered side by side in the design lab (below) and settled by the product owner. ## How this document changes - A rule changes only through an explicit decision recorded in the [decision log](#decision-log): what was decided, the options it was chosen from, and why. No mid-sprint taste changes. A new idea goes on the list for the next design round. - Every rule rests on a named standard: Nielsen's heuristics, WCAG 2.2 AA, WAI-ARIA APG, Apple HIG or Material. The tag is in brackets after the rule. - A rule stated here should also be enforced in code (an eslint rule, a primitive's type, a test). A rule that lives only in prose drifts. That is the finding that started this document. ## The design lab `npm run dev`, then open **`http://localhost:5173/design-lab`**. The lab renders each open decision's variants with the app's real CSS, tokens, glass and themes, and has its own switches for theme, scheme, text size and backdrop. It is dev-only: `main.tsx` reaches it behind `import.meta.env.DEV`, and the build plugin `frontend/devOnlyGuard.ts` fails a production build that would contain it. Once a decision is taken, the losing variants are deleted and the chosen one stays as the reference rendering: the lab is the living style guide. ## Principles 1. **Glass over a calm background is the look.** Surfaces are translucent layers (`.glass`, `.glass-card`, `.glass-menu`, `.glass-media`) over a per-scheme backdrop. Depth comes from the **header + fade**: a crisp sticky header with a short gradient just below it, so content dissolves as it slides under. The reference is `DataTable`'s sticky header. A flat opaque box where a glass surface belongs is a violation. 2. **Built for one known, daily user, on a desktop and a tablet.** Density is welcome where a mouse is the pointer; on touch every target grows. Nothing is designed for phones. 3. **One primitive per pattern.** Where a `components/ui/` primitive exists and is used, the looks don't drift. The drift lives in hand-rolled markup. A new generic control goes into `ui/`, and a screen composes primitives rather than restyling them. 4. **Measured, not eyeballed.** Contrast, target sizes and layout at the contract sizes are measured in a real browser before a UI change is called done. 5. **Honest states.** An error never renders as an empty state; loading, empty and error are three different screens (`QueryState` / `StateMessage`). ## Device adaptation — _Decided_ - **Supported:** tablet portrait and landscape and every size above them (from 768px wide). Phones are not a target. Measure a UI change at 1024×768, 820×1180 (portrait) and a desktop size. - **Adapt by capability, never by user agent:** `@media (pointer: coarse)` and `(hover: none)` decide touch behaviour; container queries decide how a panel lays itself out. Breakpoints are named tokens, never literal pixel values scattered in call sites. [HIG, WCAG 1.4.10] - **Touch never loses a function.** Anything revealed on hover is visible at rest on `hover: none` (the `.reveal` class), or it is removed on touch because the same action is reachable another way (`.reveal-hover`). [WCAG 1.4.13, Nielsen #6] - **Targets:** at least 2.75rem (44px) on a coarse pointer, as a real box, not an invisible hit area: overlapping hit areas fire the wrong control. [HIG, WCAG 2.5.8] _Which controls this covers beyond `Button` is decision A3._ - **Text inputs** use at least 1rem text on a coarse pointer, so a tablet browser doesn't zoom the page when an input gets focus. - **Below 768px** (a narrow window, split screen): what replaces the side rails is **Pending (C)**. ## Tokens - **Colour:** only semantic tokens (`--bg --surface --card --fg --muted --accent --accent-fg --danger --warn --success --info --border`, each with a `-fg` partner where text sits on it). Six schemes × dark and light. Normal text ≥ 4.5:1 and a control's edge ≥ 3:1 in **every** scheme and mode. [WCAG 1.4.3, 1.4.11] _The light-theme accent fix is decision B; the input edge token is decision A4._ - **Type and size:** everything is rem-derived off `--font-scale` (the Settings text-size slider), so a px font size or a px-frozen box is an eslint error. - **Radius:** chips and segmented controls `rounded-full`; tabs `rounded-lg`. _Buttons, inputs, triggers and icon buttons: decisions A1, A2, A4, A5. Surfaces per role: decision B._ - **Layers:** the fixed z-index scale in `index.css` (`base < menu < chrome < paneltab < panel < rail < overlay < popover < tooltip`). No ad-hoc z-index. [maintainability] ## Controls — **Pending (batch A)** Open in the lab: **A1** button shape and size rule · **A2** icon-button sizes and the on-media button · **A3** the touch size beyond `Button` · **A4** the input primitive · **A5** the dropdown trigger · **A6** checkbox, switch, slider. Already in force: - An action button is `ui/Button` with a `SIZES` rung. A hand-rolled `