图表设计
创建技术/产品图表(架构图、流程图、序列图、状态机、ER/数据模型图、时间线、泳道图、象限图、嵌套图、树形图、组织图、分层堆栈图、韦恩图、金字塔图),以独立HTML文件输出,含内嵌SVG。内置中性编辑风格,首次运行时提示用户自定义样式指南(颜色、字体),再生成图表。包含标注标注原语和可选手绘变体。
文件预览
---
name: diagram-design
description: Create technical and product diagrams — architecture, flowchart, sequence, state machine, ER / data model, timeline, swimlane, quadrant, nested, tree, org chart, layer stack, venn, pyramid — as standalone HTML files with inline SVG. Ships with a neutral editorial skin and a first-run gate that prompts users to customize the style guide (colors, fonts) from their own website before generating. Includes annotation-callout primitive and optional sketchy variant.
license: MIT
metadata:
version: "1.0"
---
# Diagram Design
Create visual diagrams as self-contained HTML files with inline SVG and CSS, following an opinionated editorial design system.
Fourteen diagram types. One shared design system, complexity budget, and taste gate. Type-specific conventions live in `references/` and are loaded only when you pick a type.
---
## 0. First-time setup — style guide gate
**Before generating your first diagram in a new project, verify the style guide has been customized.**
Open [`references/style-guide.md`](references/style-guide.md) and check the default tokens. If they're still the shipped defaults (paper `#faf7f2`, ink `#1c1917`, accent `#b5523a` rust), **pause and ask the user**:
> *"This is your first Schematic in this project. The style guide is still at the default (neutral stone + rust). Do you want to customize it to match your brand first? Options: (a) run onboarding — I'll pull colors and fonts from your website, (b) paste your tokens manually, (c) proceed with the default for now."*
Then branch:
- **(a)** → follow [`references/onboarding.md`](references/onboarding.md) to fetch the site, extract palette + fonts, propose a diff, and write `style-guide.md`.
- **(b)** → accept the user's tokens and write them into `style-guide.md` under a new "Custom tokens" section.
- **(c)** → proceed; optionally remind the user they can run onboarding later.
**Once the style guide has been customized** (or the user explicitly opted for default), skip this gate on subsequent runs. A simple way to detect customization: if the `accent` value in `style-guide.md` differs from `#b5523a`, assume custom.
Don't silently ship default-skinned diagrams into a branded project — that's the failure mode this gate exists to prevent.
---
## 1. Philosophy
**The highest-quality move is usually deletion.**
From `.impeccable.md`: *"Confident restraint. Earn every element. One color accent, two families, a small spacing vocabulary. If removing it wouldn't hurt the page, remove it."*
Applied to schematics:
- Every node represents a distinct idea. Two nodes that always travel together are one node.
- Every connection carries information. If the relationship is obvious from layout, remove the line.
- Coral is **editorial, not a flag.** 1–2 focal nodes per diagram. Using it on 5 nodes erases the signal.
- The schematic isn't done when everything is added. It's done when nothing can be removed.
**Target density: 4/10.** Enough to be technically complete. Not so dense it needs a guide. Above 9 nodes, it's probably two diagrams.
---
## 2. When to Use
Use for any of the 14 diagram types (§3) when a reader will learn more from a visual than from prose, a table, or a bulleted list.
**Don't use for:**
- Quick unicode diagrams → use **wiretext**.
- Lists of things → table or bullets.
- Simple before/after → table.
- One-shape "diagrams" → just write the sentence.
Before drawing, ask: *Would the reader learn more from this than from a well-written paragraph?* If no, don't draw.
---
## 3. Diagram Types
### Selection guide
| If you're showing… | Use | Reference |
|---|---|---|
| Components + connections in a system | **Architecture** | [type-architecture.md](references/type-architecture.md) |
| Decision logic with branches | **Flowchart** | [type-flowchart.md](references/type-flowchart.md) |
| Time-ordered messages between actors | **Sequence** | [type-sequence.md](references/type-sequence.md) |
| States + transitions + guards | **State machine** | [type-state.md](references/type-state.md) |
| Entities + fields + relationships | **ER / data model** | [type-er.md](references/type-er.md) |
| Events positioned in time | **Timeline** | [type-timeline.md](references/type-timeline.md) |
| Cross-functional process with handoffs | **Swimlane** | [type-swimlane.md](references/type-swimlane.md) |
| Two-axis positioning / prioritization | **Quadrant** | [type-quadrant.md](references/type-quadrant.md) |
| Hierarchy through containment / scope | **Nested** | [type-nested.md](references/type-nested.md) |
| Parent → children relationships | **Tree** | [type-tree.md](references/type-tree.md) |
| Human/agent/team ownership, reporting, routing, escalation | **Org chart** | [type-org-chart.md](references/type-org-chart.md) |
| Stacked abstraction levels | **Layer stack** | [type-layers.md](references/type-layers.md) |
| Overlap between sets | **Venn** | [type-venn.md](references/type-venn.md) |
| Ranked hierarchy or conversion drop-off | **Pyramid / funnel** | [type-pyramid.md](references/type-pyramid.md) |
Rules of thumb:
- If a 3-column table communicates the same thing, pick the table.
- If you're combining two types, pick the dominant axis — don't hybridize grammars.
- If you're past the complexity budget (§7), split into an overview + detail.
**Always load the relevant `references/type-*.md` before drawing** — it contains layout conventions, anti-patterns, and example files for that type.
---
## 4. Universal Anti-patterns
These mark "AI slop" schematics of any type:
| Anti-pattern | Why it fails |
|---|---|
| Dark mode + cyan/purple glow | Looks "technical" without design decisions |
| JetBrains Mono as blanket "dev" font | Mono is for *technical* content — ports, commands, URLs. Names go in Geist sans. |
| Identical boxes for every node | Erases hierarchy |
| Legend floating inside the diagram area | Collides with nodes |
| Arrow labels with no masking rect | Bleeds through the line |
| Vertical `writing-mode` text on arrows | Unreadable |
| 3 equal-width summary cards as default | Generic grid — vary widths |
| Shadow on any element | Shadows are out. Borders are in. |
| `rounded-2xl` on boxes | Max radius 6–10px or none |
| Coral on every "important" node | Coral is 1–2 editorial accents, not a signaling system |
Type-specific anti-patterns live in each `references/type-*.md`.
---
## 5. Design System
**The design system is skinnable.** All colors, typography, and tokens live in a single source of truth — [`references/style-guide.md`](references/style-guide.md). This file describes semantic roles (`paper`, `ink`, `muted`, `accent`, `link`, …). The default skin is a cool editorial palette (white-smoke paper, jet-black ink, atomic-tangerine accent, blue-slate muted, silver hairlines); to apply your own brand, either edit `style-guide.md` directly or run the URL-based flow described in [`references/onboarding.md`](references/onboarding.md).
> When specs below or in type references mention "ink", "accent", "muted", etc., look up the current hex value in `style-guide.md`.
### Semantic roles (at a glance)
| Role | Purpose |
|---|---|
| `paper`, `paper-2` | Page bg and container bg |
| `ink` | Primary text / stroke |
| `muted`, `soft` | Secondary text, default arrows, sublabels |
| `rule`, `rule-solid` | Hairline borders |
| `accent`, `accent-tint` | 1–2 focal elements per diagram |
| `link` | HTTP/API calls, external arrows |
**Focal rule:** `accent` goes on 1–2 elements max. Everything else is `ink` / `muted` / `soft`. If you're tempted to accent 4 things, you haven't decided what's focal yet.
### Node type → treatment
| Type | Fill | Stroke |
|---|---|---|
| **Focal** (1–2 max) | `accent-tint` | `accent` |
| **Backend / API / Step** | white | `ink` |
| **Store / State** | `ink @ 0.05` | `muted` |
| **External / Cloud** | `ink @ 0.03` | `ink @ 0.30` |
| **Input / User** | `muted @ 0.10` | `soft` |
| **Optional / Async** | `ink @ 0.02` | `ink @ 0.20` dashed `4,3` |
| **Security / Boundary** | `accent @ 0.05` | `accent @ 0.50` dashed `4,4` |
### Typography (summary — full spec in style-guide.md)
- **Title** — Instrument Serif, 1.75rem, 400 — H1 only
- **Node name** — Geist (sans), 12px, 600 — human-readable labels
- **Sublabel** — Geist Mono, 9px — ports, URLs, field types
- **Eyebrow / tag** — Geist Mono, 7–8px, uppercase, tracked — type tags, axis labels
- **Arrow label** — Geist Mono, 8px — annotation on arrows
- **Editorial aside** — Instrument Serif *italic*, 14px — callouts only
**Mono is for technical content.** Names are Geist sans. Page title is Instrument Serif. Italic Instrument Serif is reserved for annotation callouts. Never JetBrains Mono as a blanket "dev" font.
```html
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
```
---
## 6. Core SVG Primitives
Universal building blocks. Type-specialized primitives (lifeline, activation bar, region) live in the relevant `references/type-*.md`. Optional primitives:
- Editorial callouts → [primitive-annotation.md](references/primitive-annotation.md)
- Hand-drawn variant → [primitive-sketchy.md](references/primitive-sketchy.md)
### Background
**Default: clean paper, no dot pattern.** Single `<rect>` filled with `paper`. Don't wrap the diagram in a secondary container background — the diagram sits directly on the page.
```svg
<rect width="100%" height="100%" fill="#f5f5f5"/>
```
**Optional: dotted paper variant.** When a long-form editorial diagram benefits from textured ground (essays, hero diagrams on a dedicated page), opt in by adding the `dots` pattern and a second rect:
```svg
<defs>
<pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
<circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>
</pattern>
</defs>
<rect width="100%" height="100%" fill="#f5f5f5"/>
<rect width="100%" height="100%" fill="url(#dots)" opacity="0.6"/>
```
Don't use the dot pattern when the diagram sits inside a product page, slide, or card — the texture compounds with surrounding chrome and reads as noise.
### Arrow markers (define all three, always)
```svg
<marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
<polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/>
</marker>
<marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
<polygon points="0 0, 8 3, 0 6" fill="#eb6c36"/>
</marker>
<marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">
<polygon points="0 0, 8 3, 0 6" fill="#2e5aa8"/>
</marker>
```
| Arrow | Stroke | When |
|---|---|---|
| Default | muted `#4f5d75` | Internal, generic |
| Accent | coral `#eb6c36` | Primary / highlighted / headline |
| Link-blue | `#2e5aa8` | HTTP/API calls, external systems |
| Dashed | `stroke-dasharray="5,4"` + any color | Optional, passive, return, async |
**Draw arrows before boxes** so z-order puts lines behind nodes.
### Node box — full pattern
```svg
<!-- 1. Opaque paper mask — prevents arrows bleeding through transparent fills -->
<rect x="X" y="Y" width="W" height="H" rx="6" fill="#f5f5f5"/>
<!-- 2. Styled box -->
<rect x="X" y="Y" width="W" height="H" rx="6" fill="FILL" stroke="STROKE" stroke-width="1"/>
<!-- 3. Rectangular type tag (rx=2, NOT a pill) -->
<rect x="X+8" y="Y+6" width="28" height="12" rx="2" fill="transparent" stroke="STROKE@0.40" stroke-width="0.8"/>
<text x="X+22" y="Y+15" fill="STROKE@0.8" font-size="7" font-family="'Geist Mono', monospace"
text-anchor="middle" letter-spacing="0.08em">API</text>
<!-- 4. Node name (Geist sans — human-readable) -->
<text x="CX" y="CY+2" fill="#2d3142" font-size="12" font-weight="600"
font-family="'Geist', sans-serif" text-anchor="middle">Node Name</text>
<!-- 5. Technical sublabel (Geist Mono) -->
<text x="CX" y="CY+18" fill="#4f5d75" font-size="9"
font-family="'Geist Mono', monospace" text-anchor="middle">tech:port</text>
```
### Arrow labels — always mask
Every arrow label needs an opaque rect behind it. Without one it bleeds through the line.
```svg
<rect x="MID_X-18" y="ARROW_Y-12" width="36" height="12" rx="2" fill="#f5f5f5"/>
<text x="MID_X" y="ARROW_Y-3" fill="#7a8399" font-size="8"
font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.06em">WRITE</text>
```
Rules: ≤14 characters, all-caps, centered on segment midpoint, 8–10px above line. Never `writing-mode` vertical.
### Legend — horizontal strip at the bottom
**Never put the legend inside the diagram area.** Place as a horizontal strip after all nodes, with a hairline separator:
```svg
<line x1="30" y1="LEGEND_Y-8" x2="VIEWBOX_W-30" y2="LEGEND_Y-8"
stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>
<text x="30" y="LEGEND_Y+8" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace"
letter-spacing="0.14em">LEGEND</text>
<!-- Items — horizontal row, ~160px apart -->
```
Expand SVG `viewBox` height by ~60px.
---
## 7. Layout & Spacing
### 4px grid
**All values — font sizes, padding, node dimensions, gaps, x/y coords — divisible by 4.** Non-negotiable.
| Category | Allowed values |
|---|---|
| Font sizes | 8, 12, 16, 20, 24, 28, 32, 40 |
| Node width / height | 80, 96, 112, 120, 128, 140, 144, 160, 180, 200, 240, 320 |
| x / y coordinates | multiples of 4 |
| Gap between nodes | 20, 24, 32, 40, 48 |
| Padding inside boxes | 8, 12, 16 |
| Border radius | 4, 6, 8 |
Exempt: stroke widths (0.8, 1, 1.2), opacity values, and the 22×22 dot-pattern.
Quick check: if a coordinate ends in 1, 2, 3, 5, 6, 7, 9 — fix it.
### Complexity budget (per diagram)
| Limit | Rule |
|---|---|
| Max nodes | 9 |
| Max arrows / transitions | 12 |
| Max coral elements | 2 |
| Max lifelines (sequence) | 5 |
| Max lanes (swimlane) | 5 |
| Max items (quadrant) | 12 |
| Max entities (ER) | 8 |
| Max nesting levels (nested) | 6 |
| Max tree depth | 4 |
| Max org chart depth | 4 |
| Max org chart nodes | 12 |
| Max layers (layer stack) | 6 |
| Max circles (venn) | 3 |
| Max layers (pyramid) | 6 |
| Max annotation callouts | 2 |
If you exceed, split into two diagrams (overview + detail).
### Page layout
1. **Header** — eyebrow (Geist Mono), title (Instrument Serif), optional subtitle (Geist muted).
2. **Diagram container** — default: **clean, borderless**, no background — the SVG sits directly on the page paper. Optional *framed* variant (for card-heavy layouts or hero placements): `paper-2` bg + 1px `rule` border + 8px radius + `1.5rem` padding + `overflow-x: auto`.
3. **Summary cards** — 2–3 col grid with *varied* widths (e.g., `1.1fr 1fr 0.9fr`).
4. **Footer** — colophon in Geist Mono, muted, hairline top border.
---
## 8. Summary Card Pattern
Don't use 3 identical generic cards. Vary the treatment:
```html
<div class="card">
<p class="eyebrow">SECTION LABEL</p>
<div class="card-header">
<span class="card-dot coral"></span>
<h3>Card Title</h3>
</div>
<ul><li>Item</li></ul>
</div>
```
Rules:
- `background: #ffffff` (not paper — slight lift without shadow)
- `border: 1px solid rgba(45,49,66,0.12)`
- `border-radius: 6px`, `padding: 1.25rem`
- **No `box-shadow`**
- Card dots: 7px, `border-radius: 50%` — ink / muted / coral / link / soft variants
---
## 9. Pre-Output Checklist (Taste Gate)
Run before producing any diagram.
**Type fit:**
- [ ] Right type for what I'm showing? (§3 selection guide)
- [ ] Would a table / paragraph do the same job? (If yes — don't draw.)
- [ ] Loaded the matching `references/type-*.md`?
**Remove test:**
- [ ] Can I remove any node? (Would a reader still understand?)
- [ ] Can I merge any two nodes? (Do they always travel together?)
- [ ] Can I remove any arrow? (Is the relationship obvious from layout?)
- [ ] Can I remove any label? (Does color or shape already signal it?)
**Signal:**
- [ ] Coral used on ≤2 elements? If more, which actually deserve focal status?
- [ ] Legend covers every type used — and nothing extra?
- [ ] Within the type's complexity budget (§7)?
**Technical:**
- [ ] Arrows drawn before boxes?
- [ ] Every arrow label has an opaque `fill="#f5f5f5"` rect behind it?
- [ ] Legend is a horizontal bottom strip, not floating?
- [ ] No vertical `writing-mode` text?
- [ ] `viewBox` expanded for the legend strip (~60px)?
- [ ] Every font size, coord, width, height, gap divisible by 4?
**Typography:**
- [ ] Human-readable names in Geist sans, not Geist Mono?
- [ ] Technical sublabels (ports, commands, URLs) in Geist Mono?
- [ ] Page title in Instrument Serif?
- [ ] Annotation callouts (if any) in *italic* Instrument Serif? (see [primitive-annotation.md](references/primitive-annotation.md))
- [ ] No JetBrains Mono anywhere?
---
## 10. Templates & Variants
Every diagram ships in three variants (see `assets/`):
| Variant | File pattern | When to use |
|---|---|---|
| **Minimal light** (default) | `template.html`, `example-<type>.html` | Screenshot-ready. Diagram + title. Warm paper. |
| **Minimal dark** | `template-dark.html`, `example-<type>-dark.html` | Dark mode sites, slides, high-contrast posts. |
| **Full editorial** | `template-full.html`, `example-<type>-full.html` | Long-form posts where the diagram is the hero. |
| **Consultant special** (quadrant only) | `example-quadrant-consultant.html` | BCG/McKinsey-style 2×2 scenario matrix. Clinical sans-serif, white bg, bold blue double-ended axes, named scenario cells. See [type-quadrant.md](references/type-quadrant.md#consultant-special-2x2-scenario-matrix). |
**Sketchy variant** (optional, applied to any of the above) — see [primitive-sketchy.md](references/primitive-sketchy.md). SVG turbulence filter wobbles strokes for a hand-drawn feel. Good for essays, not for technical docs.
### To create a new diagram
1. Copy the variant closest to what you want (`template.html` for minimal, `template-full.html` for cards).
2. Load the matching `references/type-<name>.md` for layout conventions.
3. Replace the eyebrow, h1, and SVG body.
4. Run the §9 taste gate.
---
## 11. Output
Always produce a single self-contained `.html` file:
- Embedded CSS (no external except Google Fonts)
- Inline SVG (no external images)
- No JavaScript required
Renders correctly in any modern browser.
SKILL.md
---\nname: diagram-design\ndescription: 创建技术/产品图表(架构图、流程图、序列图、状态机、ER/数据模型图、时间线、泳道图、象限图、嵌套图、树形图、组织图、分层堆栈图、韦恩图、金字塔图),以独立HTML文件输出,含内嵌SVG。内置中性编辑风格,首次运行时提示用户自定义样式指南(颜色、字体),再生成图表。包含标注标注原语和可选手绘变体。\nlicense: MIT\nmetadata:\n version: "1.0"\n---\n\n# 图表设计\n\n创建可视化图表为自包含HTML文件,内嵌SVG和CSS,遵循一套有观点的编辑设计系统。\n\n十四种图表类型。一个共享设计系统、复杂度预算和品味检查。各类型特有约定位于references/,仅在选定类型时加载。\n\n---\n\n## 0. 首次设置 — 样式指南检查点\n\n在新项目中生成第一个图表前,请确认样式指南已被定制。\n\n打开references/style-guide.md并检查默认标记。如果仍然是发布时的默认值(纸张 #faf7f2,墨水 #1c1917,强调色 #b5523a 铁锈红),暂停并询问用户:\n\n> "这是你在本项目中的第一个示意图。样式指南仍为默认值(中性石色+铁锈红)。你要先定制为符合你的品牌吗?选项:(a) 运行引导——我会从你的网站提取颜色和字体,(b) 手动粘贴你的标记,(c) 暂时使用默认值。"\n\n然后分支:\n- (a) → 遵循 references/onboarding.md 获取网站,提取调色板和字体,提出差异,并写入 style-guide.md。\n- (b) → 接受用户的标记并将其写入 style-guide.md 的新“Custom tokens”部分。\n- (c) → 继续;可选提醒用户以后可以运行引导。\n\n一旦样式指南被定制(或用户明确选择默认),后续运行跳过此检查。检测定制的一个简单方法:如果 style-guide.md 中的 accent 值不同于 #b5523a,则视为定制。\n\n不要默默地在品牌项目中使用默认皮肤的图表——这正是此检查旨在防止的失败模式。\n\n---\n\n## 1. 哲学\n\n最高质量的举措通常是删除。\n\n引自 .impeccable.md:"自信的克制。挣来每一个元素。一种颜色强调,两种字体族,少量间距词汇。如果删除某元素不会影响页面,就删掉它。"\n\n应用于示意图:\n- 每个节点代表一个独特概念。两个总是同时出现的节点合并成一个节点。\n- 每条连线承载信息。如果关系从布局中显而易见,就移除连线。\n- 珊瑚色是编辑性的,不是标记。每个图最多1–2个焦点节点。在5个节点上使用会抹去信号。\n- 示意图不是加完了才算完成,而是删无可删才算完成。\n\n目标密度:4/10。 足够技术上完整,但又不至于密集到需要指南。超过9个节点,就应考虑拆成两个图。\n\n---\n\n## 2. 使用时机\n\n当读者从视觉中能比从文字、表格或列表中学到更多时,使用这14种图表之一。\n\n不要用于:\n- 快速 Unicode 图表 → 使用 wiretext。\n- 事物列表 → 表格或列表。\n- 简单的前后对比 → 表格。\n- 单一形状的“图表” → 直接写句子。\n\n画图前问自己:读者会从这个图中学到比一个写得好的段落更多吗? 如果不会,就别画。\n\n---\n\n## 3. 图表类型\n\n### 选择指南\n\n| 如果想展示… | 使用 | 参考文件 |\n|---|---|---|\n| 系统中的组件与连接 | 架构图 | type-architecture.md |\n| 带分支的决策逻辑 | 流程图 | type-flowchart.md |\n| 参与者间按时间顺序的消息 | 序列图 | type-sequence.md |\n| 状态、转换与条件 | 状态机 | type-state.md |\n| 实体、字段与关系 | ER/数据模型 | type-er.md |\n| 时间线上定位的事件 | 时间线 | type-timeline.md |\n| 跨职能流程及交接 | 泳道图 | type-swimlane.md |\n| 双轴定位/优先级 | 象限图 | type-quadrant.md |\n| 通过包含/范围展示层次 | 嵌套图 | type-nested.md |\n| 父子关系 | 树形图 | type-tree.md |\n| 人员/代理/团队所有权、汇报、路由、升级 | 组织架构图 | type-org-chart.md |\n| 分层抽象级别 | 分层堆栈图 | type-layers.md |\n| 集合重叠 | 韦恩图 | type-venn.md |\n| 排名层次或转化漏斗 | 金字塔/漏斗 | type-pyramid.md |\n\n经验法则:\n- 如果三列表格能传达同样内容,选表格。\n- 如果要组合两种类型,选主导轴——不要混合语法。\n- 如果超过复杂度预算(第7节),拆分为概览 + 详情。\n\n绘图前务必加载相关 references/type-*.md —— 它包含该类型的布局约定、反模式和示例文件。\n\n---\n\n## 4. 通用反模式\n\n这些标记任何类型的“AI 劣质”示意图:\n\n| 反模式 | 失败原因 |\n|---|---|\n| 暗色模式 + 青/紫光晕 | 看起来“技术”但缺乏设计决策 |\n| 将 JetBrains Mono 作为通用“开发”字体 | 等宽字体用于技术内容——端口、命令、URL。名称用 Geist sans。 |\n| 所有节点使用相同盒子 | 抹去层次 |\n| 图例浮在图表区域内 | 与节点冲突 |\n| 箭头标签无遮挡矩形 | 透过线条渗出 |\n| 箭头上的垂直 writing-mode 文字 | 不可读 |\n| 3 个等宽摘要卡片作为默认 | 通用网格——应变换宽度 |\n| 任何元素添加阴影 | 阴影是过时的,边框才是主流。 |\n| 盒子上 rounded-2xl | 最大半径 6–10px 或无 |\n| 每个“重要”节点都用珊瑚色 | 珊瑚色是 1–2 个编辑强调,不是信号系统 |\n\n类型特定反模式见各 references/type-*.md。\n\n---\n\n## 5. 设计系统\n\n设计系统是可换肤的。 所有颜色、排版和标记都在单一真实来源——references/style-guide.md。该文件描述语义角色(paper、ink、muted、accent、link、…)。默认皮肤是一个冷调编辑调色板(白烟纸、墨黑墨水、原子橘强调、蓝灰弱化、银色发丝线);若要应用自有品牌,直接编辑 style-guide.md 或运行 references/onboarding.md 中描述的基于 URL 的流程。\n\n> 当后续规范或类型引用提到“ink”、“accent”、“muted”等时,查看 style-guide.md 中的当前十六进制值。\n\n### 语义角色(概览)\n\n| 角色 | 用途 |\n|---|---|\n| paper、paper-2 | 页面背景和容器背景 |\n| ink | 主文本/描边 |\n| muted、soft | 次要文本、默认箭头、子标签 |\n| rule、rule-solid | 发丝边框 |\n| accent、accent-tint | 每个图 1–2 个焦点元素 |\n| link | HTTP/API 调用、外部箭头 |\n\n焦点规则:accent 最多用于 1–2 个元素。其余用 ink / muted / soft。如果想强调 4 个东西,说明还没确定焦点。\n\n### 节点类型 → 处理\n\n| 类型 | 填充 | 描边 |\n|---|---|---|\n| 焦点(最多 1–2) | accent-tint | accent |\n| 后端/API/步骤 | 白色 | ink |\n| 存储/状态 | ink @ 0.05 | muted |\n| 外部/云 | ink @ 0.03 | ink @ 0.30 |\n| 输入/用户 | muted @ 0.10 | soft |\n| 可选/异步 | ink @ 0.02 | ink @ 0.20 虚线 4,3 |\n| 安全/边界 | accent @ 0.05 | accent @ 0.50 虚线 4,4 |\n\n### 排版(摘要——完整规范见 style-guide.md)\n\n- 标题 — Instrument Serif, 1.75rem, 400 — 仅 H1\n- 节点名称 — Geist(sans), 12px, 600 — 人类可读标签\n- 子标签 — Geist Mono, 9px — 端口、URL、字段类型\n- 眉标/标签 — Geist Mono, 7–8px,大写,加宽 — 类型标签、轴标签\n- 箭头标签 — Geist Mono, 8px — 箭头上的注释\n- 编辑旁白 — Instrument Serif italic, 14px — 仅标注\n\n等宽字体用于技术内容。 名称用 Geist sans。页面标题用 Instrument Serif。斜体 Instrument Serif 保留给标注标注。从不使用 JetBrains Mono 作为通用“开发”字体。\n\nhtml\n<link href=\"https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap\" rel=\"stylesheet\">\n\n\n---\n\n## 6. 核心 SVG 基础元素\n\n通用构建块。类型专用基础元素(如生命线、激活条、区域)见相关 references/type-*.md。可选基础元素:\n- 编辑标注 → primitive-annotation.md\n- 手绘变体 → primitive-sketchy.md\n\n### 背景\n\n默认:干净纸张,无点阵。 单个 <rect> 填充 paper。不要将图表包裹在二级容器背景中——图表直接放在页面上。\n\nsvg\n<rect width=\"100%\" height=\"100%\" fill=\"#f5f5f5\"/>\n\n\n可选:点阵纸变体。 当长篇编辑图表受益于纹理背景时(文章、独立页面上的英雄图),通过添加 dots 图案和第二个 rect 开启:\n\nsvg\n<defs>\n <pattern id=\"dots\" width=\"22\" height=\"22\" patternUnits=\"userSpaceOnUse\">\n <circle cx=\"1\" cy=\"1\" r=\"0.9\" fill=\"rgba(45,49,66,0.10)\"/>\n </pattern>\n</defs>\n<rect width=\"100%\" height=\"100%\" fill=\"#f5f5f5\"/>\n<rect width=\"100%\" height=\"100%\" fill=\"url(#dots)\" opacity=\"0.6\"/>\n\n\n不要在产品页面、幻灯片或卡片内的图表上使用点阵图案——纹理与周围 chrome 叠加变成噪音。\n\n### 箭头标记(总是定义全部三个)\n\nsvg\n<marker id=\"arrow\" markerWidth=\"8\" markerHeight=\"6\" refX=\"7\" refY=\"3\" orient=\"auto\">\n <polygon points=\"0 0, 8 3, 0 6\" fill=\"#4f5d75\"/>\n</marker>\n<marker id=\"arrow-accent\" markerWidth=\"8\" markerHeight=\"6\" refX=\"7\" refY=\"3\" orient=\"auto\">\n <polygon points=\"0 0, 8 3, 0 6\" fill=\"#eb6c36\"/>\n</marker>\n<marker id=\"arrow-link\" markerWidth=\"8\" markerHeight=\"6\" refX=\"7\" refY=\"3\" orient=\"auto\">\n <polygon points=\"0 0, 8 3, 0 6\" fill=\"#2e5aa8\"/>\n</marker>\n\n\n| 箭头 | 描边 | 使用场景 |\n|---|---|---|\n| 默认 | muted #4f5d75 | 内部、通用 |\n| 强调 | coral #eb6c36 | 主路径/高亮/标题 |\n| 链接蓝 | #2e5aa8 | HTTP/API 调用、外部系统 |\n| 虚线 | stroke-dasharray=\"5,4\" + 任意颜色 | 可选、被动、返回、异步 |\n\n在画框之前画箭头,这样 z-order 将线条放在节点后面。\n\n### 节点盒——完整模式\n\nsvg\n<!-- 1. Opaque paper mask — prevents arrows bleeding through transparent fills -->\n<rect x=\"X\" y=\"Y\" width=\"W\" height=\"H\" rx=\"6\" fill=\"#f5f5f5\"/>\n<!-- 2. Styled box -->\n<rect x=\"X\" y=\"Y\" width=\"W\" height=\"H\" rx=\"6\" fill=\"FILL\" stroke=\"STROKE\" stroke-width=\"1\"/>\n<!-- 3. Rectangular type tag (rx=2, NOT a pill) -->\n<rect x=\"X+8\" y=\"Y+6\" width=\"28\" height=\"12\" rx=\"2\" fill=\"transparent\" stroke=\"STROKE@0.40\" stroke-width=\"0.8\"/>\n<text x=\"X+22\" y=\"Y+15\" fill=\"STROKE@0.8\" font-size=\"7\" font-family=\"'Geist Mono', monospace\"\n text-anchor=\"middle\" letter-spacing=\"0.08em\">API</text>\n<!-- 4. Node name (Geist sans — human-readable) -->\n<text x=\"CX\" y=\"CY+2\" fill=\"#2d3142\" font-size=\"12\" font-weight=\"600\"\n font-family=\"'Geist', sans-serif\" text-anchor=\"middle\">Node Name</text>\n<!-- 5. Technical sublabel (Geist Mono) -->\n<text x=\"CX\" y=\"CY+18\" fill=\"#4f5d75\" font-size=\"9\"\n font-family=\"'Geist Mono', monospace\" text-anchor=\"middle\">tech:port</text>\n\n\n### 箭头标签——始终带遮罩\n\n每个箭头标签后面需要一个不透明矩形。没有它,文字会透过线条渗出。\n\nsvg\n<rect x=\"MID_X-18\" y=\"ARROW_Y-12\" width=\"36\" height=\"12\" rx=\"2\" fill=\"#f5f5f5\"/>\n<text x=\"MID_X\" y=\"ARROW_Y-3\" fill=\"#7a8399\" font-size=\"8\"\n font-family=\"'Geist Mono', monospace\" text-anchor=\"middle\" letter-spacing=\"0.06em\">WRITE</text>\n\n\n规则:≤14 字符,全大写,居中在线段中点,在线条上方 8–10px。永远不要用 writing-mode 垂直。\n\n### 图例——底部水平条\n\n绝不要把图例放在图表区域内。 将其作为所有节点之后的水平条,带发丝分隔线:\n\nsvg\n<line x1=\"30\" y1=\"LEGEND_Y-8\" x2=\"VIEWBOX_W-30\" y2=\"LEGEND_Y-8\"\n stroke=\"rgba(45,49,66,0.10)\" stroke-width=\"0.8\"/>\n<text x=\"30\" y=\"LEGEND_Y+8\" fill=\"#4f5d75\" font-size=\"8\" font-family=\"'Geist Mono', monospace\"\n letter-spacing=\"0.14em\">LEGEND</text>\n<!-- Items — horizontal row, ~160px apart -->\n\n\n扩展 SVG viewBox 高度约 60px。\n\n---\n\n## 7. 布局与间距\n\n### 4px 网格\n\n所有值——字体大小、内边距、节点尺寸、间距、x/y 坐标——必须能被 4 整除。 不可妥协。\n\n| 类别 | 允许值 |\n|---|---|\n| 字体大小 | 8, 12, 16, 20, 24, 28, 32, 40 |\n| 节点宽高 | 80, 96, 112, 120, 128, 140, 144, 160, 180, 200, 240, 320 |\n| x / y 坐标 | 4 的倍数 |\n| 节点间距 | 20, 24, 32, 40, 48 |\n| 盒子内边距 | 8, 12, 16 |\n| 圆角半径 | 4, 6, 8 |\n\n豁免:描边宽度(0.8, 1, 1.2)、不透明度值和 22×22 点阵图案。\n\n快速检查:如果坐标以 1, 2, 3, 5, 6, 7, 9 结尾——修正它。\n\n### 复杂度预算(每个图表)\n\n| 限制 | 规则 |\n|---|---|\n| 最大节点数 | 9 |\n| 最大箭头/转换数 | 12 |\n| 最大珊瑚元素数 | 2 |\n| 最大生命线数(序列图) | 5 |\n| 最大泳道数(泳道图) | 5 |\n| 最大项目数(象限图) | 12 |\n| 最大实体数(ER) | 8 |\n| 最大嵌套层数(嵌套图) | 6 |\n| 最大树深度 | 4 |\n| 最大组织图深度 | 4 |\n| 最大组织图节点数 | 12 |\n| 最大层数(分层堆栈图) | 6 |\n| 最大圆圈数(韦恩图) | 3 |\n| 最大层数(金字塔) | 6 |\n| 最大标注标注数 | 2 |\n\n如果超出,拆分为两个图表(概览 + 详情)。\n\n### 页面布局\n\n1. 页眉 — 眉标(Geist Mono)、标题(Instrument Serif)、可选副标题(Geist muted)。\n2. 图表容器 — 默认:干净、无边框,无背景——SVG 直接放在页面纸张上。可选带框变体(用于卡片较多布局或英雄图位置):paper-2 背景 + 1px rule 边框 + 8px 圆角 + 1.5rem 内边距 + overflow-x: auto。\n3. 摘要卡片 — 2–3 列网格,使用不同宽度(例如 1.1fr 1fr 0.9fr)。\n4. 页脚 — 出版信息,Geist Mono,弱化,顶部发丝边框。\n\n---\n\n## 8. 摘要卡片模式\n\n不要使用三个相同的通用卡片。变换处理:\n\nhtml\n<div class=\"card\">\n <p class=\"eyebrow\">SECTION LABEL</p>\n <div class=\"card-header\">\n <span class=\"card-dot coral\"></span>\n <h3>Card Title</h3>\n </div>\n <ul><li>Item</li></ul>\n</div>\n\n\n规则:\n- background: #ffffff(不是 paper——轻微抬起而无阴影)\n- border: 1px solid rgba(45,49,66,0.12)\n- border-radius: 6px、padding: 1.25rem\n- 无 box-shadow\n- 卡片点:7px,border-radius: 50% — ink / muted / coral / link / soft 变体\n\n---\n\n## 9. 输出前检查清单(品味检查)\n\n每种图表生成前执行。\n\n类型匹配:\n- [ ] 我展示的内容用对了类型吗?(第3节选择指南)\n- [ ] 表格或段落能完成同样工作吗?(如果能——就别画。)\n- [ ] 加载了对应的 references/type-*.md 吗?\n\n移除测试:\n- [ ] 我能移除任何节点吗?(读者还能理解吗?)\n- [ ] 我能合并任何两个节点吗?(它们总是一起出现吗?)\n- [ ] 我能移除任何箭头吗?(从布局中关系是否显而易见?)\n- [ ] 我能移除任何标签吗?(颜色或形状是否已表明?)\n\n信号:\n- [ ] 珊瑚色用在 ≤2 个元素上?如果更多,哪些真正值得焦点地位?\n- [ ] 图例覆盖所有使用过的类型——没有多余?\n- [ ] 在类型复杂度预算内(第7节)?\n\n技术:\n- [ ] 箭头画在盒子之前?\n- [ ] 每个箭头标签后面都有一个不透明 fill=\"#f5f5f5\" 的矩形?\n- [ ] 图例是底部水平条,不是浮动的?\n- [ ] 没有垂直 writing-mode 文本?\n- [ ] viewBox 为图例条扩展了(~60px)?\n- [ ] 所有字体大小、坐标、宽度、高度、间距都能被 4 整除?\n\n排版:\n- [ ] 人类可读名称使用 Geist sans,不是 Geist Mono?\n- [ ] 技术子标签(端口、命令、URL)使用 Geist Mono?\n- [ ] 页面标题使用 Instrument Serif?\n- [ ] 标注标注(如有)使用斜体 Instrument Serif?(见 primitive-annotation.md)\n- [ ] 没有 JetBrains Mono 的任何地方?\n\n---\n\n## 10. 模板与变体\n\n每个图表都有三种变体(见 assets/):\n\n| 变体 | 文件模式 | 使用场景 |\n|---|---|---|\n| 极简浅色(默认) | template.html、example-<type>.html | 截图即用。图表 + 标题。暖纸。 |\n| 极简深色 | template-dark.html、example-<type>-dark.html | 暗色模式网站、幻灯片、高对比度帖子。 |\n| 完整编辑 | template-full.html、example-<type>-full.html | 长篇文章,图表是主角。 |\n| 咨询特供(仅象限图) | example-quadrant-consultant.html | BCG/麦肯锡风格 2×2 情景矩阵。冷峻无衬线字体,白色背景,粗体蓝色双端轴,命名情景单元格。见 type-quadrant.md。 |\n\n手绘变体(可选,应用于以上任何变体)——见 primitive-sketchy.md。SVG 湍流滤镜使笔触摇晃,产生手绘感。适合文章,不适合技术文档。\n\n### 创建新图表\n\n1. 复制最接近你想要的变体(template.html 用于极简,template-full.html 用于卡片)。\n2. 加载匹配的 references/type-<name>.md 以了解布局约定。\n3. 替换眉标、h1 和 SVG 主体。\n4. 执行第9节品味检查。\n\n---\n\n## 11. 输出\n\n总是输出单个自包含的 .html 文件:\n- 嵌入式 CSS(除 Google Fonts 外无外部资源)\n- 内联 SVG(无外部图片)\n- 无需 JavaScript\n\n在任何现代浏览器中正确渲染。\n