# Design Guide and Rules

Guide for anyone who changes AI Document Maker (https://aidoc.wondermayank.in). It keeps the tool looking and behaving like the rest of ThunderStudy. Made by wondermayank, design help by Shruti.

## 1. Purpose
Turn a person's own text into a beautiful PDF, Word, Slides, Excel or audio file, fast and without sign-up. The design should feel calm, soft and friendly, never busy.

## 2. Principles
1. **Words are sacred.** The AI styles text, it never edits it (see section 7).
2. **One main action per screen.** Choose output, add text, press Generate.
3. **Simple first, power second.** Advanced options live inside "Customize" and are never required.
4. **Soft clay look.** Rounded shapes, gentle raised shadows, plenty of space.
5. **Works for everyone.** Phones, dark mode, keyboards, screen readers, Hindi and English.

## 3. Design tokens (clay system)
All colours, radii and shadows come from the ThunderStudy clay design system (`design.html`) and are used only through CSS variables. Never hard-code them in the page UI.

| Token | Use |
|---|---|
| `--primary`, `--on-primary` | Main buttons, active chips, links. Brand blue is `#70A1FC` (dark mode `#9A7AFB`). |
| `--ink` | Headings and main text |
| `--body-c`, `--muted` | Body text, hints, helper lines |
| `--surface`, `--canvas-deep` | Cards, inputs, inset areas |
| `--hairline` | Thin dividers and borders |
| `--clay-dark`, `--clay-light` | The raised or pressed clay shadows |
| `--radius-sm / md / lg / pill` | Corners: inputs, cards, hero cards, chips |

Fonts: **Inter** for the interface, **Noto Serif** for the big headline only, **Noto Sans Devanagari** for Hindi.

## 4. Components
- **Header and footer:** copied from `design.html` and must stay identical. Never restyle them here.
- **Format chips** (`depth-seg` / `depth-chip`): PDF, Word, Slides, Excel, Audio. One active at a time.
- **Prompt box** (`card ap-box`): mode pills (My text, AI writes it), a large borderless textarea, then a bar with Attach, Sample, Clear, word count and one primary **Generate** button.
- **Customize panel:** a closed `details` card. Order: templates, colour, layout, font, page, text size, toggles, AI provider, name and page number style.
- **Buttons:** `btn-primary` for the one main action, `btn-secondary` or `btn-soft` for others, `btn-outline` for destructive or minor actions. Only one primary button visible per area.
- **Badges:** `badge-success` only for "Every word kept". `badge-primary` for counters.
- **Status line:** one short friendly sentence under the box, `aria-live="polite"`.

## 5. Layout
- Single centred column, max width 980px, generous vertical space.
- Order: hero, format chips, prompt box, status, Customize, result, features, FAQ.
- Mobile first: chips scroll sideways, grids collapse to one column, tap targets at least 44px.
- Light and dark themes both supported through tokens.

## 6. Document sheet rules (the files people download)
The document itself is always **light** (white page), whatever the site theme.
- **Colours:** three only, `primary` (dark), `accent` (bright), `soft` (very light). Chosen by a preset, or by AI for "Auto". Validate every colour as `#rrggbb` before use.
- **Structure:** title banner, section cards with a coloured header, bullets with accent markers, tip boxes with an accent left border, code in a soft box, tables with a primary header row.
- **Layouts:** Cards (default), Clean headings, Compact.
- **Footer:** the person's name bottom left in the primary colour, page number bottom right in grey, a thin primary line above. Name is drawn as an image in the PDF so any language works.
- **Word:** real headings, bullets, tables, footer with live page fields.
- **Slides:** title slide, then one slide per section (up to 6 lines), long sections continue on the next slide, tables get their own slide.
- **Excel:** a Notes sheet (Section, Type, Text) plus one sheet per table. Header row in the primary colour, frozen. Cells starting with `=` become formulas.
- **Maths:** `$...$` inline and `$$...$$` display, rendered with KaTeX in the PDF. In Word, Slides and Excel the formula is kept as text.

## 7. Text safety rules (non-negotiable)
1. AI may only return a colour theme and a role per line (title, sub, h1, h2, bullet, text, note, code). Never document text.
2. The page builds every output from the person's original text.
3. Markers (`#`, `-`, `>`, table pipes, dollar signs) are layout hints. Marker characters may be dropped from display, the words may not.
4. Before any download unlocks, the preview text is compared with the original, line by line, and must match. Show "Every word kept" only when it does.
5. "AI writes it" produces a draft that goes into the text box. The person can edit it, and the same checks then apply to the edited text.
6. AI provider names and models are chosen only in server code (`functions/_lib/ai.js`), never from user text.
7. Keep secrets (API keys) in Pages secrets, never in the page or the repo.

## 8. Voice and copy
- Friendly, short, plain words. Talk to one person ("your notes").
- Buttons say what happens: "Generate", "Download Word".
- Errors say what to do next, never blame: "AI is busy, so I used the smart basic design."
- No jargon in the interface (say "AI provider", not "inference endpoint").

## 9. Accessibility
- Every input has a label (visible or `aria-label`). Toggles are real checkboxes.
- Colour is never the only signal. Visible keyboard focus on every control.
- Respect `prefers-reduced-motion`.
- Contrast: body text at least 4.5:1 on its background, including inside generated documents.

## 10. Do and don't
| Do | Don't |
|---|---|
| Use tokens and existing `btn`, `card`, `badge` classes | Invent new colours or shadows in the UI |
| Keep one primary action visible | Add several competing big buttons |
| Hide advanced settings in Customize | Put every option on the main screen |
| Test Hindi, long lines, tables and maths | Test only short English text |
| Say what AI did and did not do | Hide that AI wrote a draft |

## 11. Checklist before adding a feature
- Does it keep the text-safety rules in section 7?
- Does it use tokens and work in light and dark?
- Is it optional and out of the way for new users?
- Is it described in README, `llms.txt`, `llms-full.txt` and the FAQ?
- Does it work on a phone?
