# Neumorphism (Soft UI) Design Language System

Version 1.0. Tokens for CSS, Tailwind CSS and Figma.

## 1. Design Philosophy & Physical Metaphor

**Tone:** futuristic, tactile, soft, seamless, minimalist.

The interface is one sheet of soft, matte material. Nothing sits on it; everything is formed from it.

- **Raised (extruded):** catches light top-left, casts shadow bottom-right. Available, clickable.
- **Inset (carved):** top-left rim in shadow, bottom-right rim lit. Pressed, active, editable.
- **Flat:** untouched material. Disabled or structural.

Principles: one light, one direction; one material; depth encodes state; color is a signal, not decoration; shadows never carry meaning alone.

## 2. Light Source Physics & Color Tokens

| Rule | Value |
|---|---|
| Light position | Top-left |
| Gradient angle | 145deg |
| Highlight shadow | (-d, -d) |
| Ambient shadow | (+d, +d) |
| Blur | about 2x offset |
| Spread | 0 |

### Base palettes

| Token | Slate | Cream | Soft Dark |
|---|---|---|---|
| surface | `#E0E5EC` | `#F0F3F8` | `#292D32` |
| light shadow | `#FFFFFF` | `#FFFFFF` | `rgba(255,255,255,0.06)` |
| dark shadow | `#A3B1C6` | `#C5CEDD` | `rgba(0,0,0,0.55)` |
| convex from / to | `#E9EEF5` / `#D5DAE1` | `#F7F9FC` / `#E3E8F0` | `#2E3238` / `#24282C` |

### Dual-shadow formula

```
Raised = d d b AMBIENT, -d -d b HIGHLIGHT
Inset  = inset d d b AMBIENT, inset -d -d b HIGHLIGHT
```

### Elevation scale

| Level | Offset | Blur | Use |
|---|---|---|---|
| raised-1 | 4px | 8px | Chips, small icon buttons |
| raised-2 | 6px | 12px | Buttons, list rows |
| raised-3 | 9px | 16px | Cards, panels |
| raised-4 | 14px | 28px | Menus, popovers |
| raised-5 | 20px | 40px | Modals, drawers |
| inset-1 | 2px | 4px | Progress tracks |
| inset-2 | 4px | 8px | Inputs, toggle tracks, pressed buttons |
| inset-3 | 6px | 12px | Textareas, large wells |

Z-index: base 0, raised 10, sticky 100, dropdown 200, overlay 300, modal 400, toast 500.

### Accents (LED)

| Token | Light | Dark | Role |
|---|---|---|---|
| accent (Electric Blue) | `#2563EB` | `#5B9CFF` | Active, focus, links |
| accent-2 (Mint) | `#0B8A5F` | `#34D399` | On, success |
| warn (Amber) | `#B45309` | `#FBBF24` | Warning |
| danger (Red) | `#DC2626` | `#F87171` | Error |

### Text

| Token | Light | Dark |
|---|---|---|
| text | `#3D4852` (about 7.4:1) | `#E6EAF0` |
| text-muted | `#556270` (about 4.9:1) | `#A9B2BD` |

## 3. Surface Math (CSS / Tailwind)

```css
:root {
  --neu-surface: #E0E5EC;
  --neu-light: #FFFFFF;
  --neu-dark: #A3B1C6;
  --neu-o: 1;  /* offset multiplier */
  --neu-b: 1;  /* blur multiplier */
  --neu-raised-3: calc(9px*var(--neu-o)) calc(9px*var(--neu-o)) calc(16px*var(--neu-b)) var(--neu-dark),
                  calc(-9px*var(--neu-o)) calc(-9px*var(--neu-o)) calc(16px*var(--neu-b)) var(--neu-light);
  --neu-inset-2: inset calc(4px*var(--neu-o)) calc(4px*var(--neu-o)) calc(8px*var(--neu-b)) var(--neu-dark),
                 inset calc(-4px*var(--neu-o)) calc(-4px*var(--neu-o)) calc(8px*var(--neu-b)) var(--neu-light);
  --neu-focus-ring: 0 0 0 3px var(--neu-surface), 0 0 0 5px var(--neu-accent);
}
.neu-raised  { background: var(--neu-surface); box-shadow: var(--neu-raised-3); }
.neu-inset   { background: var(--neu-surface); box-shadow: var(--neu-inset-2); }
.neu-convex  { background: linear-gradient(145deg, var(--neu-convex-from), var(--neu-convex-to)); }
.neu-concave { background: linear-gradient(145deg, var(--neu-convex-to), var(--neu-convex-from)); }
```

Define raised-1, 2, 4, 5 and inset-1, 3 the same way using the elevation table.

### Radius

| Token | Value | Use |
|---|---|---|
| sm | 8px | Chips, tags |
| md | 12px | Inputs |
| lg | 16px | Buttons |
| xl | 24px | Cards |
| 2xl | 32px | Modals |
| pill | 9999px | Toggles, round buttons |

Rules: minimum radius 8px; radius at least the shadow offset; no `overflow: hidden` on parents with outer shadows; raised inside raised only once; never raised inside inset.

### Tailwind config (v3)

```js
module.exports = { theme: { extend: {
  colors: { neu: { surface: 'var(--neu-surface)', text: 'var(--neu-text)', muted: 'var(--neu-text-muted)', accent: 'var(--neu-accent)' } },
  boxShadow: {
    'neu-raised-2': 'var(--neu-raised-2)', 'neu-raised-3': 'var(--neu-raised-3)',
    'neu-inset-2': 'var(--neu-inset-2)',
    'neu-raised-focus': 'var(--neu-raised-2), var(--neu-focus-ring)',
    'neu-inset-focus': 'var(--neu-inset-2), var(--neu-focus-ring)',
  },
  borderRadius: { 'neu-md': '12px', 'neu-lg': '16px', 'neu-xl': '24px', 'neu-2xl': '32px' },
}}};
```

## 4. Typography

Fonts: Inter for UI and body; Outfit or Poppins for headings. Fallback: SF Pro, system-ui, sans-serif.

| Style | Size / line | Weight | Tracking |
|---|---|---|---|
| Display | 40 / 48 | 700 | -0.02em |
| H1 | 32 / 40 | 700 | -0.015em |
| H2 | 24 / 32 | 700 | -0.01em |
| Body | 16 / 26 | 500 | 0.005em |
| Small | 14 / 22 | 500 | 0.01em |
| Label | 13 / 16 | 600 | 0.04em |
| Caption | 12 / 16 | 500 | 0.02em |

Rules: minimum weight 500; use only the text and text-muted tokens; positive tracking for small text; optional engraved heading shadow `0 1px 0 rgba(255,255,255,.7)` (light) or `0 1px 1px rgba(0,0,0,.5)` (dark).

## 5. Interactive Components

| State | Depth | Extra cue |
|---|---|---|
| Idle | raised-2 | none |
| Hover | raised-3, 1px lift | text shifts toward accent |
| Pressed | inset-2 | lift removed |
| Focus-visible | current plus ring | 2px accent ring, 3px gap |
| Selected | inset-2 | accent text plus icon or LED |
| Disabled | flat | opacity 0.6 |

```css
.neu-btn { min-height: 44px; padding: 0 24px; border: 0; border-radius: 16px; background: var(--neu-surface);
  color: var(--neu-text); font: 600 14px/1 Inter, sans-serif; box-shadow: var(--neu-raised-2);
  transition: box-shadow .18s, transform .18s; }
.neu-btn:hover { box-shadow: var(--neu-raised-3); transform: translateY(-1px); }
.neu-btn:active { box-shadow: var(--neu-inset-2); transform: none; }
.neu-btn:focus-visible { outline: none; box-shadow: var(--neu-raised-2), var(--neu-focus-ring); }
.neu-input { min-height: 44px; padding: 12px 16px; border: 0; border-radius: 12px;
  background: var(--neu-surface); box-shadow: var(--neu-inset-2); }
.neu-input:focus-visible { outline: none; box-shadow: var(--neu-inset-2), var(--neu-focus-ring); }
```

- **Toggle:** 56x30 inset track, 22px convex raised-1 knob that slides 26px, LED dot on the knob (mint with glow when on). Always include a text label.
- **Card:** raised-3, radius 24px, padding 24px.
- **Modal:** raised-5, radius 32px, z-index 400, scrim tinted with the surface color.

## 6. Accessibility, Usability & Fallbacks

Shadows on a same-color background measure far below the 3:1 required by WCAG 1.4.11, so shadow never carries meaning alone.

| Criterion | Mitigation |
|---|---|
| 1.4.1 Use of Color | Pair LED and accent with icon, label or position |
| 1.4.3 Contrast | Dedicated text tokens, 4.5:1 or better |
| 1.4.11 Non-text Contrast | Boundary border in high-contrast mode; visible labels |
| 2.4.7 Focus Visible | 2px accent ring with surface gap |
| 2.5.5 Target Size | 44px minimum |
| 2.3.3 Motion | Honor `prefers-reduced-motion` |

```css
@media (prefers-contrast: more) {
  :root { --neu-o: 1.15; --neu-b: .8; --neu-edge: rgba(61,72,82,.65); --neu-dark: #7F8EA6; }
  .neu-btn, .neu-input, .neu-card { border: 1px solid var(--neu-edge); }
}
@media (forced-colors: active) {
  .neu-btn, .neu-input, .neu-card { border: 1px solid CanvasText; box-shadow: none; }
}
```

### Dark mode

| Parameter | Light | Dark |
|---|---|---|
| Highlight | `#FFFFFF` | `rgba(255,255,255,0.06)` |
| Ambient | `#A3B1C6` | `rgba(0,0,0,0.55)` |
| Offset multiplier | 1.0 | 0.85 |
| Blur multiplier | 1.0 | 1.15 |
| Glow opacity | 0.45 | 0.60 |

```css
:root[data-theme='dark'] {
  --neu-surface: #292D32; --neu-light: rgba(255,255,255,.06); --neu-dark: rgba(0,0,0,.55);
  --neu-text: #E6EAF0; --neu-text-muted: #A9B2BD; --neu-accent: #5B9CFF;
  --neu-o: .85; --neu-b: 1.15;
}
```

## Figma

Variable collection `Neu / Theme` with modes Light and Dark. Effect styles use exactly two effects: Drop shadow for raised, Inner shadow for inset. Raised/3 is x9 y9 blur16 `shadow-dark` plus x-9 y-9 blur16 `shadow-light`. Inset/2 is x4 y4 blur8 plus x-4 y-4 blur8. Create a Dark variant of each style with offsets x0.85 and blur x1.15.
