# Surface system

Navigation and content each have their own interaction language, in light and dark themes alike.

- **Deep page**: `--bg-secondary`
- **Left and right rails**: `--bg-input`, 7px gutter
- **Centre column**: `--bg-primary`, 7px off top and bottom

## The two surfaces

|  | Deep: rails | Panel: content, dialogs |
| --- | --- | --- |
| Components | List rows: conversations, branches, favourites | Buttons, pills, cards |
| Idle | No border, outline or fill | Variant face ([below](#button-variants)) |
| Hover, selected | Visible grey, `--bg-hover` or `--bg-selected`; text stays `--text-primary` or `--text-secondary` | The variant's hover |
| Brand colour | Only tiny `.indicator-dot` indicators: a dense, scanned list must stay calm | Primary action |

**Shell geometry**

| Part | Rule |
| --- | --- |
| Rails | shadcn Sidebar `floating` shell (`components/ui/sidebar.tsx`); centre takes its `inset` idea |
| Card | `rounded-lg` (12px), per-theme `--composer-shadow`, no border or ring. Split panes and the canvas overview share `--radius-lg`. |
| Why white rails | The rails share a material with the input box and user bubble; those stand out on the centre card |
| Split layout | `.center-col[data-split]`: the centre card dissolves, each pane is a card of the same material, 7px to rails and edges, 8px apart. Empty panes draw the card themselves. |
| Collapsed rail | `--rail-collapsed-w` 62px; `components/layout/use-resizable-rail.ts` carries the same number |
| Focus | No mouse focus ring on buttons; keyboard focus is a small brightness change. Top-strip `role="tab"` uses each theme's `--focus-ring`. |

## One list-row recipe

Sidebar nav and content-pane rows (MCP `drawio`, `+ Add server`) are one box. `+ Add server` is the same row as `+ New chat`, slightly muted.

- **Height**: `--ui-list-h`, 30px
- **Padding, gap**: 6px 8px, 12px
- **Radius**: `--ui-list-radius`
- **Idle**: Transparent
- **Hover, selected**: `--bg-hover`, never `--bg-input` (white on a white rail disappears)

Source: `.ui-list-item` in `apps/web/app/styles/base/list-row.css`. Page list columns use `RailItem` ([secondary rail](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/sidebar/secondary-rail.html)); MCP `.serverItem` matches its metrics.

## Buttons

`apps/web/components/ui/button.tsx` is the shadcn radix-nova Button from the official registry. Local changes: imports, a `forwardRef` for React 18, px-pinned sizes and one look: `rounded-md` (8px) at every size, no border, raised by the composer shadow pair (`shadow-raised`, `shadow-raised-hover`). Colour alone marks the role. Tier tables: [Design tokens](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/visual-system/design-tokens.html).

| Variant | Face, hover | Use |
| --- | --- | --- |
| `default` | `bg-primary`; `primary/90` | One main action per area: Run, Save, Test, Apply, Send, New |
| `elevated` | `--bg-input`; deeper shadow. Pressed, checked or on: 1.5px `primary` ring. | Every other action; composer triggers, environment chips. A choice among a few is a groove ([below](#choices)). |
| `destructive` | `bg-destructive/10`; `/20` | Delete, Remove, Stop, Clear history |
| `ghost` | Transparent, no shadow; `bg-muted` (`/50` dark) | Icon tools hidden until hover: close, more, rename |
| `link` | Primary text; underline | Inline |

All press 1px while active, show a 3px `ring/50` on keyboard focus, and go to 50% when disabled. Sidebar rows are not Buttons: use `.ui-list-item` or `nav-classes.ts`. `outline` and `secondary` are not offered. `Toggle` and `ToggleGroup` offer the same face as `elevated`, with a tint for on, and the `segmented` groove.

- What cannot be a `<Button>` (a span hosting its own ✕, a Radix trigger span) uses `cn(buttonVariants({ variant, size }))`; the `cn()` merge resolves `border-transparent` against the variant's border.
- A 1 to 2px height mismatch inside a header row (search, pills, icon buttons) is a bug.

## Choosing one of a few

Two materials make every control: a **face** (`--bg-input`, `shadow-raised`: cards, buttons, inputs, menus) and a **groove** (`bg-groove`: a step below the surface in light themes, the deep page in dark ones; `shadow-groove`), which only ever holds a single choice. No glass.

| Control | Rule |
| --- | --- |
| View, filter or setting | A groove 32px tall (`--ui-choice-h` 26px options, 3px around), so it reads as large as the raised 30px controls beside it; the options are plain text and a face (`SlidingThumb`) slides under the chosen one, running past it by 8% of the distance (at most 8px), swinging back once and settling; the groove's walls stop it at the ends. `ToggleGroup variant="segmented"`, `Tabs`, or `CAPSULE_GROOVE` with `CAPSULE_OPTION` from `components/ui/capsule.ts` for a row a page builds itself. |
| Sizes | Every choice on a page is the default 32px, so choices side by side match. `sm` only in a compact tool palette (the image annotator), `xs` only inside a list row. |
| Counts | A quiet number after the label, never a pill: a pill weighs the option's right side and pulls it off centre under the face. |
| Drag | Like a finger: pressed anywhere in the groove, the face glides under the pointer at once and follows it while held (each frame closing a third of the gap); the option under the pointer on release is chosen. |
| Page section | One size up (`TabsList variant="section"`, or `SECTION_GROOVE`, `SECTION_OPTION`), centred on the line between header and content (`SECTION_BAR`). The new content slides in from the side the switch moved towards (`SectionSlide`, or `TabsContent` by itself). |
| Corners | Rounded rectangles like every other control, concentric: the face takes the button's 8px (`rounded-md`), the groove that plus its padding (`rounded-groove`, 11px; a section switch 8 + 4 = `rounded-xl`). Smaller groups step down together (sm: 8 in 10, xs: 6 in 8). No capsule: it would be the one round-ended shape on the page. |
| Several on at once | `ToggleGroup variant="elevated"`: each option is a face; on is a `primary/12` tint with primary ink |
| Colour or shape swatch | The only choice that keeps a 1.5px accent ring: the swatch itself is the content |
| Long or changing list | `Select` ([below](#selects-and-menus)) |

## Selects and menus

Every fixed-list choice is the radix-nova `Select` (`components/ui/select.tsx`). No native `<select>`, no hand-rolled listbox. `SimpleSelect` is the one-line form (`value`, `onValueChange`, `options`, `label`, `placeholder`, `size`; groups as `{label, options}`).

| Part | Rule |
| --- | --- |
| Trigger | A face: `rounded-lg`, `bg-input`, `shadow-raised` (deeper on hover and while open), no border, `--ui-button-h` or `-sm`. Default `w-full max-w-48`; call sites add only width; an error is a destructive ring. |
| Popup | Solid `bg-popover` in the menu frame, `item-aligned`, `z-[130]` above dialogs. Muted heading names the choice (`label`, else `aria-label`), one per group. Plain check on the chosen row. |
| Empty value | Radix reserves `""`: an option with that value uses a sentinel inside `SimpleSelect`; otherwise `""` shows the placeholder |
| Other menus | DropdownMenu, popover pickers, sidebar footer, tab and function context menus use `MENU_PANEL`, `itemCls`, `GROUP_LABEL`, `MENU_SEPARATOR` from `components/ui/menu/menu-styles.ts`. A CSS module keeps only placement. |

Action menus from a small button or right-click build rows with `MenuRow` (`components/ui/menu/menu-parts.tsx`), in the page and the desktop overlay (`DesktopContextMenuItem` carries `glyph` and `keys`). `apps/web/scripts/ui/check-menu-rows.mjs` holds every menu file to it. Left to right:

| Slot | Rule |
| --- | --- |
| Icon | Solar Bold Duotone (`MenuIcon`, 16px, muted). Folder rows in `--folder-color`, destructive rows red. |
| Label | Fills the row |
| Key | Price tag (`MenuKey`): 10px tip, the rounded end of Solar's `tag-horizontal` mirrored left, joined to a shadcn `Kbd` plate, 18px tall, square at the tip, 5px round at the right, 1px 6px padding around at least 8px of text. Paint `--menu-key-bg`, ink at 12% over the popover. Text from `formatMenuKeys`: `⌘T`, `⇧⌘C`, or `Ctrl+T`, `Ctrl+Shift+C`. Shows only keys that work; no global shortcut exists just to fill a tag. |
| Check | `MenuCheck`; unchecked rows in a group keep the column (`CHECK_SLOT_PAD`) |
| Submenu | Trailing chevron, any depth |
| Lit row | Hover, keyboard, open submenu or active row: muted icon, key and chevron turn bright, icon pops 1.12, key plate ink at 22%. A tinted icon keeps colour and only pops. |

**Menu frame and geometry**

Tokens in `app/globals.css`, shared by menus, Select popup, `Popover`, command palette and page preview. Light themes: `--popover-ring` transparent, `--popover-shadow` is `--composer-shadow`, `--popover-shadow-hover` is `--composer-shadow-focus`. Dark themes lift the popup a step, keep a light hairline and soft deep shadow, with no hover change.

| Part | Nova, at the docs' scale |
| --- | --- |
| Panel | `rounded-lg` `p-1` `min-w-32`, solid `bg-popover` |
| Row | `min-h-7` (28px), `rounded-md`, `px-1.5 py-1`, `text-fs-base`, `gap-1.5`, `size-4` icons not shifted |
| Hover | `bg-accent` (ink at 9%), `text-bright` |
| Label | `px-1.5 py-1` `text-fs-xs` `font-medium`, muted |
| Separator | `-mx-1 my-1`, 1px, `--border` |
| Shortcut | `MenuKey`, `text-[11px]`, muted |
| Chosen | Accent `MenuCheck` at the end, never a fill |

`--popover` is `--bg-input`: white in light themes, one step above the page in dark. Menus, Select popup and dialogs are one surface; only the accent check is the app's own.

## Inputs and borders

One single-layer 1px edge (`border: 1px solid var(--border)`, fill `--bg-input`) in Settings, dialogs, plugins and MCP editors. Hover keeps the border; no 2px halo on focus.

## Dialogs

Every modal is radix-nova `Dialog` or `AlertDialog` (`components/ui/`). No hand-rolled backdrops, no browser `confirm()`.

| Part | Nova, at the docs' scale |
| --- | --- |
| Overlay | `bg-black/10`, no backdrop blur, `z-[110]`, `data-native-view-occluder` |
| Content | `rounded-xl` `bg-popover` `ring-1 ring-foreground/10` `p-4` `gap-4` `max-w-sm` `z-[120]` |
| Title, description | `text-fs-md font-medium`; `text-fs-base` muted |
| Footer | `-mx-4 -mb-4` `border-t` `bg-muted/50` `p-4`, right-aligned, Cancel first, Buttons only: `elevated` Cancel or Close, `default` main |
| Close | `ghost` `icon-sm`, `top-2 right-2` (Dialog only) |
| Motion | 100ms fade and `zoom-in-95`, no slide |
| Confirmation | `ConfirmDialog` or `await confirmAction({...})` through `<ConfirmDialogHost />` in `app/providers.tsx`. `destructive` when it deletes or lowers a safeguard. Escape, outside click and Cancel all cancel. |
| Three answers | `await chooseAction({..., alternateLabel})` adds a third button on the left, as macOS sets **Don't Save** apart from Cancel and Save. |
| Module class | Sizes only: width, `max-width: none`, max-height, overflow |
| Edge-to-edge | Source viewer, function runner, provider setup: `p-0 gap-0`, own padding, `DialogFooter` `m-0` |

## Settings rows

| Block | Shape |
| --- | --- |
| `SettingsPage` | Title (with optional actions at the end of its row), description, scrolling body |
| `SettingsSection` | Titled group on one `Card`, hairline dividers |
| `SettingsRow` | Horizontal `Field`: name and description left, control right (a lone Select is 12rem). `stacked` puts a wide control under the name. |

In `components/settings/settings-ui.tsx`. Controls: `Switch`, `Input`, `Textarea`, `Slider`, `RadioGroup`, `ToggleGroup`, `Checkbox`, `Button`, `SimpleSelect`. A tab has no row, label or card CSS of its own.

**History project tabs**

Settings and Info use the same blocks. Chats, Memory, Settings and Info share one layout: fixed head and tab bar, each panel scrolls edge to edge (Settings and Info with a 24px edge). Chats groups by recency, one titled `Card` per group.

Today, Last 7 days and the newest group start open, older ones folded; the choice per group is remembered in this browser. An open group lists 8, then "Show all N" (10 or fewer: all). A toolbar button expands or folds all; a search opens all. `apps/web/scripts/projects/check-project-tabs.mjs` (in `npm run check`) guards this.

## Composer controls

| Part | Rule |
| --- | --- |
| Environment chips | Channel, web surface, project, folders, DAG HUD: `elevated` `sm`; add-folder `icon-sm` |
| Bottom row | Permission, model, Agent, effort, plus, tools, context ring: `elevated`, `sm` or `icon-sm`; old rules handed back with `revert-layer`. Height follows its chips, 10px under the box, as the environment chips sit above it. |
| Glyphs in both rows | 16px, 5px gap, centred, 13px labels, set unlayered in the rows' module CSS because Button sizes would shrink an unsized svg to 12.25px. The effort card keeps its sizes. |
| Send, mic | Colours from variants (send `default`, `ghost` when empty, `destructive` to stop; mic `ghost`). Size from `app/styles/design/composer.css`: `--composer-action-size` (28px), centred in `--composer-line-h` (46px), `--composer-action-inset`. Mic hover is `--composer-action-hover` because `--muted` is the box's colour. |
| Input box | `--composer-*` tokens: `--bg-input`, no border, `shadow-sm`, `shadow-md` on hover or focus (alpha 0.1 light, 0.25 dark), no ring, `--radius-lg` |

## Web page preview and browser toolbar

| Part | Rule |
| --- | --- |
| Preview frame | `components/center-tabs/pip/web-tab-pip.tsx`: `bg-popover` in the menu frame, 10px corners, stage clipped alike. Pinned to the native view's corner radius in `apps/desktop/main/web-views/web-views.js`, which the DOM cannot clip; the two change together. |
| 32px header | Title `text-fs-base font-medium text-text-primary`, status `text-fs-xs text-text-muted`, `ghost` `icon-sm` buttons, 14px icons, `HoverTip` + `TipBody` ([hover tips](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/composer/hover-tips.html)). A resume error is one line of `text-fs-xs text-destructive`. |
| CSS module | Geometry only: unlayered module rules would beat the utilities |
| Browser toolbar | `webToolbarButton()` (`components/center-tabs/browser/toolbar/toolbar-button.ts`): `ghost` `icon-sm`, held at 26px by `.webToolbarBtn` in the 40px row |

## Agent cards

| Part | Rule |
| --- | --- |
| Card | `--bg-input`, `--composer-shadow` (deeper on hover), no border, `xl` corner, 14px inside |
| Grid | Raised cards in columns of at least 260px |
| Contents | Avatar (40px), name, **Default** on the default Agent, up to three lines of description |
| Settings | Stay in the quick panel, whose open card wears the 1.5px `--accent-blue` ring |
| Groups | Two by the always-on switch, each with an `md` title and one muted line |

**Always-on surf**

Foam lines drift diagonally toward the lower right, each a soft crest with a broader wash on its seaward side, every line ragged in its own way.

| Aspect | Rule |
| --- | --- |
| Layers | Two, the card fill with text ink mixed in at 14% and 9%, each masked by a seamless SVG tile; 56s and 72s a tile, so lines pass and cross |
| One field | `SheenField` offsets each card's layers by grid position, again on resize; all drifts share a start, so lines continue across cards and gaps and scroll with them |
| Motion | One whole tile per cycle as a compositor animation: no jump, no repaint. Still under reduced motion. |
| Limits | No colour of its own, nothing over the text |

## Don'ts

| Don't | Why, or instead |
| --- | --- |
| A new hover, selected, border or pill treatment | Add a line here first. Budget: deep grey hover, panel, brand fill, the face and the groove. |
| Brand fills on the deep surface | A brand pill reads as an alert |
| Different metrics for MCP or any other content-pane list | One set of metrics for every content-pane list |
| Hover motion (`translate-y`, `scale-105`) | Applies to either surface |
| Editing `button.tsx` classes at a call site, or restating a Button in CSS | Pick a variant and size; remove an overriding legacy rule or use `revert-layer` |
| A settings description overflowing into the control column, or label above control | Label above control only in `stacked` |

## Implementation status

| Status | Items |
| --- | --- |
| Implemented | Every part in `components/ui` is radix-nova, every former `<select>` and dropdown included: `Command`, `Popover`, `Tooltip` (`--surface-tooltip`, `--text-on-tooltip` alias `--foreground`, `--background`), `Tabs` (the capsule groove), `Kbd`, `ScrollArea`, `Sidebar`. Every modal and confirmation. Menu panels and rows, Settings General, desktop attention, composer parts, preview, browser toolbar. |
| Exception | The attachment lightbox keeps its own full-screen viewer |
| Not yet | Other Settings pages (`settings-page.module.css` rows); form inputs outside Settings keep the 1px rule until they move to the shadcn input |
