# Layout and spacing · Divan

> Space separates groups, so it has to be consistent. Everything is on Tailwind’s 4px grid inside one page width.

Part of Divan, the DivanWorks design system. Web page: https://brand.divanworks.com/layout · All topics: https://brand.divanworks.com/llms.txt

## Rules

- A grid of cards or rows gets a column that can shrink, grid-cols-[minmax(0,1fr)], and its text wrap-anywhere: an auto column grows to its widest word (a file path, a class name) and pushes the cards past the screen. A <ul> or <ol> laid out as a grid too, on every page (pnpm divan:lint: list-grid-auto-column).
- A collection that grows (projects, shots, palettes) uses gallery: every card one size, the last row may end short. A set whose count you know (the composer’s five tiles) gets columns that divide it by the container’s width (grid-cols-2 @md:grid-cols-3 @4xl:grid-cols-5), its last item spanning the rest of its row.
- A label beside its value keeps to one line: whitespace-nowrap on each <dt> in grid-cols-[auto_minmax(0,1fr)], so the value wraps instead (pnpm divan:lint: label-wraps).
- Every element that scrolls (overflow-y-auto, overflow-x-auto, overflow-auto) is relative, so what is absolutely placed inside it (an sr-only label, a badge, a dot) scrolls with it and stays inside; one that scrolls only from some width is positioned at that width (lg:relative lg:overflow-y-auto). Without a position such a part belongs to the page: far down a list it stretches a screen-tall view’s page (the room’s composer moved up with empty space under it), and in a table that scrolls sideways it makes the page scroll sideways (pnpm divan:lint: scroll-area-unpositioned).
- page-container: max-w-page (72rem) with a 16px phone gutter, 20px from tablets up.
- Reading text near 38rem (max-w-prose), about 75 characters a line.
- Compact spacing: rows in a group 4px apart (gap-1); inside a card 18px; between groups 24–40px; between page sections 48–80px. A page starts 20–24px below its header.
- Grids stack to one column on phones and fill their columns on wider screens.
- Logical sides only: ps-/pe-, ms-/me-, start-/end-, text-start. A Sheet opens from side="end" (a task) or side="start" (a menu): the right in English, the left in Persian.
- Widths: phones from 360px, sm 640px, md 768px (tablets), lg 1024px (the header’s links), xl 1280px. wide: and short: variants handle screens held sideways and short laptops. Every part has one behaviour per width, listed in RESPONSIVE.
- Check every page at 360, 768 and 1280px in both languages, scrolled to the end: nothing scrolls sideways or runs off the edge, no control covers another, no label is cut short.
- The backoffice speaks English and Persian too: the language switch in its menu sets a cookie (dw-bo-lang), the server sets <html lang dir> from it, and every page has data.lang. A page keeps its words as T = { en, fa } and picks them with data.lang; shared components use currentLang() or pick() from src/lib/i18n/backoffice.ts; numbers, shares and dates go through fmtFor(lang) from src/lib/format.ts (Persian digits and calendar); server messages follow locals.lang.

## Containers

| Token | Value | Classes | For |
| --- | --- | --- | --- |
| `page` | `72rem` | `max-w-page` |  |
| `prose` | `38rem` | `max-w-prose` | about 75 characters of body text |

## Responsive: what each part does at each width

Phone 360–639px · tablet 640–1023px · desktop 1024px and up.

| Part | Phone | Tablet | Desktop |
| --- | --- | --- | --- |
| Header | Logo, language, Support (heart only), menu; links and account in the drawer | Adds Sign in / My activity and the Support label | Links in the bar from 1024px; no menu |
| Footer | Brand, then two columns of groups; Follow spans both with two columns of links; legal row centred | Brand and three groups in four columns | The same, wider gaps |
| Page width | 16px gutters | 20px gutters | At most 72rem, centred |
| Card grids | One column | Two columns | Three or four columns |
| Side menu (My activity) | The sections as one segmented row above the page | From 768px a side menu on the start side (right in Persian), with counts | The same, staying in view while the page scrolls |
| Data table | Scrolls sideways inside its card below its minWidth, or shows each row as a card (stack); search full width | Fits most tables; search 18rem | Fits; pages or rows drawn as you scroll |
| Segmented control | Scrolls sideways inside its own track | Fits | Fits |
| Sheets and dialogs | Sheets take the full height from the start side; dialogs the width minus the gutter | Sheets 24rem wide; dialogs 32rem | The same |
| Room panel | A full-height bottom sheet over the chat, a step back at its top | The same | From 1024px docked beside the chat, which shrinks to what is left |
| Type | display and large-title shrink with the screen and its height | Grow with the screen | Reach their largest size |
| Fields | Full width, 16px text (no zoom on iPhone) | Side by side in two columns where they belong together | The same |
| Charts | Full width, fewer ticks | Resize with their card | Resize with their card |
| Bars at the bottom | Buttons wrap under the count; the page leaves room so nothing hides behind | One row | One row, beside the side menu |
