# Spec, Tokens & Security Reference

> Complete YAML/JSON item fields, theme tokens, keyboard shortcuts, accessibility, and security boundaries.

## Common Item Fields

Every node, step, layer, actor, or event accepts either a plain string or a mapping with:

| Field | Type | Description |
|---|---|---|
| `title` | string | Primary card heading |
| `note` | string | Secondary subtitle rendered below `title` |
| `description` | string | Longer explanation shown in the inline inspector when clicked |
| `code` | string | Copyable code/CLI snippet shown in the inline inspector |
| `href` | string | Clickable reference link (`https:`, `http:`, `/path`, or `#anchor` only) |
| `highlight` | boolean | Highlights the card with the active accent tint and stroke |
| `fallback` | boolean | Styles the card or edge as a dashed recovery/return path |

## Theme Token Overrides

Override any semantic token per mode using `theme: { light: {...}, dark: {...} }`:

| Token | Role |
|---|---|
| `ink` | Primary headings and strong borders |
| `body` | Body text |
| `muted` | Secondary notes and eyebrows |
| `line` | Neutral borders and connector wires |
| `card` | Card fill |
| `soft` | Soft panel and subgraph background |
| `acc` | Active accent stroke, arrows, and pulses |
| `hi` | Highlighted card fill |
| `ok` / `okbg` | Success badge text and fill |
| `back` | Fallback/rollback dashed edge colour |
| `bg` | Stage canvas background |

## Keyboard & Accessibility

| Key | Action |
|---|---|
| `ArrowRight` / `ArrowLeft` | Next / previous step |
| `Home` / `End` | Jump to first / last step |
| `Enter` / `Space` | Inspect focused node or step |
| `Escape` | Exit fullscreen or clear active selection |

- **Reduced motion:** `@media (prefers-reduced-motion: reduce)` stops all CSS animations and hides travelling `<animateMotion>` dots while keeping all arrowheads and cards crisp.
- **Screen readers:** Every SVG sets `role="img"` and `aria-label` from `label`; step counters use `aria-live="polite"`; icon-only buttons carry explicit `aria-label`s.

## Security Guarantees

- **Zero `innerHTML` / `dangerouslySetInnerHTML`:** Both the Web Component and React adapter construct pure DOM/JSX nodes.
- **Prototype pollution protection:** `__proto__`, `constructor`, and `prototype` keys are stripped during YAML/JSON parsing.
- **URL allowlist (`safeHref`):** Only `http:`, `https:`, root-relative `/`, and `#` anchors are permitted; `javascript:`, `data:`, and protocol-relative `//` URLs are rejected.
- **CSS token validation:** Custom `theme` values must match strict `#rgb` or `#rrggbb` hex strings, blocking `url(...)` exfiltration or CSS injection.

## Related pages

- [Layout Gallery](https://diagram.praison.ai/docs/layouts.md)
- [Fan Layout](https://diagram.praison.ai/docs/layouts/fan.md)
- [Flow Layout](https://diagram.praison.ai/docs/layouts/flow.md)
