# Themes

The terminal interface uses Pi's theme model (`packages/coding-agent` `theme.ts`, `dark.json`,
`light.json`). Every colour is one of Pi's 51 tokens (`accent`, `border*`, `userMessage*`, `tool*`,
`md*`, `syntax*`, `toolDiff*`, `thinking*`, `bashMode`, ...); the built-in `dark` and `light` themes
are Pi's files and their OKHSL values convert to the same sRGB as Pi's `okhslToRgb`. Colours are
truecolor when `COLORTERM` says so and otherwise the nearest of 256, chosen as Pi's `rgbToAnsi256`
does.

## Choosing one

`--theme NAME` (or `--use-theme`) for one run; the `theme` setting, set in `/settings` (Theme opens
a picker that previews as you move and saves on enter) or with `pic settings theme dark`.
`light/dark` picks by the terminal, and so does `system` (the default): light when `COLORFGBG` names
a background of 7 or 9-15, else dark, as Pi decides. Text already printed to the scrollback keeps
the colours it was drawn with.

## Custom themes

JSON files in Pi's schema (`name`, optional `appearance`, `vars`, `colors`, `export`; colours as
`#rgb`/`#rrggbb`, `oklch()`, `okhsl()`, a 0-255 index, `""` for the terminal's default, or a
variable) in `~/.pic/themes/*.json`, and in the workspace's `.pic/themes/` only once it is trusted.
They are read through the input reader. An invalid file is reported with Pi's messages (missing
tokens, bad variables) and skipped; of two themes with one name the user's wins. pic does not
generate Pi's terminal-palette `system` theme.

`/reload` re-reads the theme files and the theme setting.
