# Design craft and styling guide

Read this alongside the build guide (https://nerdout.com/workshop/sdk/guide.md) when designing or polishing an app. The UI kit already handles themes, dark mode, sheets, focus rings, motion and safe areas. This guide shows how to use the kit's styling primitives so every screen feels intentional, easy to use and pleasant to look at.

## 1. Give every screen a clear focal point

Open each main screen with one purposeful top card that tells the viewer where things stand right now:

- **Hero summary card (`ui.hero()`)**: pairs an optional uppercase kicker + icon, bold display heading (`--nerd-font-heading`), subtitle, optional action button, and nested meter or stat cards.
  ```js
  const progress = ui.meter({ label: "8 of 12 packed", value: 8, max: 12, tone: "success" });
  root.appendChild(ui.hero({
    kicker: "Trip readiness",
    icon: "LuBackpack",
    title: "Almost ready for Big Sur",
    sub: "Four items left before Friday morning.",
    tone: "accent"
  }, progress));
  ```
- **Metric cards (`ui.stats(el, items, { variant: "cards" })`)**: renders elevated stat cards with tabular numbers and optional per-stat `tone` (`"accent"`, `"success"`, `"warning"`, `"danger"`).
- **Calm "all clear" state**: when nothing is overdue or uncovered, replace an urgent card with a soft celebratory card (`tone: "success"`, such as "All caught up" or "Every slot covered") rather than an empty void or a scary red zero.
- **Keep headers compact**: put the app's title in `<h1>`, live status or summary in the subtitle, and at most one primary button (`.n-btn`) plus compact 44 px icon buttons (`.n-icon-btn`) beside it.

## 2. Make status scannable at a glance

Flat gray lists make everything look equally urgent. Give groups and states clear visual weight using the kit's theme-aware primitives:

| Helper / Kit classes | Purpose |
| --- | --- |
| `ui.hero(opts, ...children)` / `.n-hero` | Focal top summary card with optional `tone` (`"accent"` | `"success"` | `"warning"` | `"danger"`), kicker, heading, subtitle and nested content. |
| `ui.panel(opts, ...children)` / `.n-panel` | Elevated grouped card with a tinted header band (`tone: "accent"|"success"|"warning"|"danger"`), optional icon, right-aligned count badge, and a clean `.n-list` inside (no double borders). |
| `ui.pill(text, opts)` / `.n-pill` | Compact status badge with optional icon and theme-safe contrast in both light and dark (`tone: "accent"|"success"|"warning"|"danger"|"muted"`). |
| `ui.callout(text, opts)` / `.n-callout` | Highlighted note, instruction or warning box inside detail sheets and cards (`tone: "accent"|"success"|"warning"|"danger"`). |
| `ui.meter(opts)` / `.n-meter` | Labeled progress bar with tabular count/percent and live `.update({ value, max, label, text, tone })`. |
| `.n-table-wrap` + `table.n-table` | Responsive, sticky-header data table with row hover tint and `.n-num` right-aligned tabular numeric columns. |
| `<details class="n-details">` | Accessible collapsible disclosure panel with animated chevron matching the active look. |
| `.n-meta` & `.n-tabular` | Wrapping row of small icons/metadata beneath a title, and `font-variant-numeric: tabular-nums` alignment. |

Pattern for a grouped section panel:

```js
ui.panel({
  title: overdue ? "Needs attention" : "Coming up",
  icon: overdue ? "LuCircleAlert" : "LuCalendar",
  count: items.length,
  tone: overdue ? "danger" : "accent"
}, listEl);
```

## 3. Cut friction on repeated actions

Ask: *what will a person tap five times in a row?* Make that action a single tap with instant feedback:

- **Circular check rings (`.n-check-btn`, `.n-check-ring`)**: on checklists, chores, packing lists and action items, place a 44 px `.n-check-btn` on the left of each `.n-item` instead of a bulky text "Done" button. Add `data-tone="danger"` on overdue items, toggle `aria-checked="true"` (with `role="checkbox"`) or `aria-pressed="true"` and add `.n-completing` briefly before saving, and offer an **Undo** toast so accidental taps never hurt.
- **Tactile toggle switches (`.n-switch`)**: for settings and boolean preferences, use `<label class="n-switch"><input type="checkbox" role="switch"><span>...</span></label>` for a 44 px accessible pill toggle.
- **Accessible row tap targets (`.n-row-btn`)**: wrap the middle title + `.n-meta` content of a list row in `<button type="button" class="n-row-btn">` so tapping anywhere on the row opens details cleanly (for example with `ui.recordSheet(collection, record, { comments: true })`) while the check ring or action icon on either side stays independent.
- **Compact icon buttons (`.n-icon-btn`) & pill actions (`.n-pill-btn`)**: for Copy, Call, Open Link, or More (`...`), use a 44 px icon button with `ui.icon("Lu...")` (never raw Unicode glyphs like `✎` or `🗑`), a clear `aria-label`, and `ui.menu()` when a row has more than two actions. Use `.n-pill-btn` for soft secondary callouts.
- **1-tap form presets (`.n-presets`)**: inside creation sheets, add a row of quick `button.n-chip` presets (common due dates like "Today / Tomorrow / Next week", common shift times, or starter items) that fill inputs in one tap.
- **Subtle save feedback (`.n-flash`)**: add `.n-flash` to a row when it updates or saves so the viewer's eye catches the change without noisy banners.

## 4. Keep phones fast and uncluttered (360 px first)

- **One-row filter bars (`.n-control-bar` + `.n-chip-rail`)**: put a `segmented()` view toggle beside a horizontally scrollable `.n-chip-rail` of `button.n-chip` filters (with `.n-chip-count` badges). Never let wrapped filter rows push the main list below the fold on a 360 px phone.
- **Lead detail sheets with what matters**: use `ui.recordSheet(collection, record, { comments, render })` for live-updating detail views with Edit/Delete permission gating built in. When writing custom detail content, put notes, dietary info, or summaries at the top in `ui.callout()` before `recordFacts()`.
- **Welcoming empty states (`ui.empty({ icon, title, text, action })`)**: pass a Lucide `icon` (like `"LuListChecks"`) so the empty state shows a themed circular icon badge above the title and primary action.
- **Use charts when totals tell a story**: pair `ui.stats(el, items, { variant: "cards" })` with `ui.chart(el, { type: "bar", horizontal: true, data })` for budgets, team hours, or category breakdowns. Charts automatically resize with their container. Keep stat labels short so 2 to 3 stats fit cleanly side by side on a phone.

## 5. Theme harmony, dark mode and contrast

- **Pair the palette to the domain** (avoid defaulting every app to `harbor`):

| Domain | Recommended palette |
| --- | --- |
| Personal notes, recipes, reading log, journaling | `paper` (warm serif headings, crisp sans body) |
| Plants, habits, meal plans, wellness, outdoor logs | `garden` (rounded, calm botanical) |
| Family calendars, events, potlucks, trips, milestones | `sunset` (warm, inviting coral/amber) |
| Workspaces, shift schedules, budgets, client trackers | `harbor` or `slate` (crisp, structured) |
| Dev tools, inventory logs, finance ledgers, utilities | `midnight` or `terminal` (sharp, monospace-ready) |
| Parties, clubs, wishlists, kids' chores, trivia | `candy` or `studio` (playful, expressive) |

- **Color only through tokens**: use `var(--nerd-bg)`, `var(--nerd-surface)`, `var(--nerd-surface-subtle)`, `var(--nerd-fg)`, `var(--nerd-muted)`, `var(--nerd-line)`, `var(--nerd-hairline)`, `var(--nerd-accent)`, `var(--nerd-accent-fg)`, `var(--nerd-accent-text)`, `var(--nerd-accent-soft)`, `var(--nerd-success)`, `var(--nerd-success-soft)`, `var(--nerd-warning)`, `var(--nerd-warning-text)`, `var(--nerd-warning-soft)`, `var(--nerd-danger)`, and `var(--nerd-danger-soft)`. Keep hard-coded colors to zero in `style.css` and inline `style=""` attributes.
- **Contrast trap to avoid**: never place `--nerd-muted` text on a `--nerd-hairline` background. Use `--nerd-fg` or `ui.pill(text, { tone: "muted" })` instead, use `--nerd-accent-text` (not `--nerd-accent`) for colored text, and use `--nerd-warning-text` for amber/warning labels.
- **Respect the active look**: use `var(--nerd-font)`, `var(--nerd-font-heading)`, `var(--nerd-radius)`, `var(--nerd-radius-control)`, `var(--nerd-border)` and `var(--nerd-shadow)` so the app looks native whether the owner keeps the default palette or switches themes.
- **Soften bright illustrations in dark mode**: if you embed decorative SVG artwork, slightly lower its brightness under both `:root[data-theme="dark"]` and `@media (prefers-color-scheme: dark)` (excluding `:root[data-theme="light"]`).
- **Stay inside lint guardrails**: use kit layout classes (`.n-cols-2`, `.n-cols-3`, `.n-sidebar`, `.n-grid`, `split()`) instead of width media queries that change grid columns or flex direction, keep distinct `px` font sizes in `style.css` to 7 or fewer (use `em` / `rem` or kit type classes), never use deprecated `.nerd-*` classes, wrap tables in `.n-table-wrap > table.n-table`, and declare any dynamically chosen icon names in `manifest.icons`.

## 6. Visual inspection checklist

Before telling the owner the app is ready, run the hosted check and look closely at the 360 px light, 360 px dark, 1280 px light and 360 px empty screenshots:

1. Can you tell what the app is for and the single most important thing to do in 2 seconds on a phone?
2. Is real content visible above the fold at 360 px (not pushed down by tall banners or wrapped chip bars)?
3. Do all pills, inactive segments, subtitles, tables and badges look crisp in both light and dark mode?
4. Does the 1280 px layout use width thoughtfully (multi-column panels or `split()`, never one skinny stretched strip)?
5. Does the empty state feel welcoming with an icon badge and one clear button to start?
6. Are all icons resolved (no blank icon placeholders) and at most 1 to 2 primary `.n-btn` actions competing on screen?
