Part of [Design system](https://docs.mapcairn.com/design.md), which is built from [DESIGN.md](https://github.com/MapCairn/mapcairn/blob/main/DESIGN.md) in the repository, where it is edited.

The SDK ships compiled CSS, not `.css.ts` source, so an app that uses it needs no vanilla-extract plugin. `@mapcairn/theme` ships `tokens.css`, which holds every token's `:root` block and its dark-theme blocks once, and `@mapcairn/map` ships `styles.css`, the styles of every component. An app imports both, `tokens.css` first:

```ts no-check
import "@mapcairn/theme/tokens.css";
import "@mapcairn/map/styles.css";
```

The packages' JavaScript imports no CSS, so server rendering (Workers included) loads plain modules and the stylesheets are static assets that a strict Content Security Policy allows: nothing is inlined. In `theme`'s manifest `sideEffects` names only `.css` files; `core` and `react` set it to `false`; `map` names `**/*.css` and `**/*.css.ts`. A bundler therefore keeps the stylesheet imports and drops unused JavaScript. The `.css.ts` pattern is for a host that resolves the source condition, as `packages/web` does, and does nothing for an app that uses `dist`. `styles.css` holds the styles of every component, whether or not the app uses it. The primitives' styles sit in one cascade layer, so an app's own unlayered rules beat them, element resets included; put the app's base styles in an `@layer` declared before `styles.css` is imported ("Overriding a primitive").

`map` is built against the built `theme`, never its source, so the custom property names in `styles.css` are the ones in `tokens.css`; a test in `packages/core/src/lint/sdkDist.test.ts` fails if `styles.css` reads a property that neither file defines, unless it is a readable name (two or more lower-case words, such as `--sheet-offset`) that a component sets from JavaScript, or if `styles.css` repeats a token property. A generated name must always be defined in a stylesheet. A repository build tool resolves the `@mapcairn/source` condition instead and compiles the source itself, as `packages/web` does.

`@mapcairn/adapter-maplibre` ships a third stylesheet, `styles.css`, which holds the rules that fit MapLibre into the map region (hide its controls, take its type and background from the tokens). `MapLibreMapAdapter.ts` imports `styles.css.ts` so the build compiles it, its `sideEffects` list is the same as `map`'s, and it uses the same custom property names as `tokens.css`, which `sdkDist.test.ts` checks. Its built JavaScript imports no stylesheet of its own; it loads the engine's own stylesheet dynamically, beside the engine, the first time a map mounts. `packages/web` resolves the package's source and so does not import this stylesheet.

The token custom properties have generated names (`--rogqo0r`, say), which stay the same for a given build of the packages and may change between releases. A stylesheet written by hand should not name them. The maintainer has decided they are not public API: they are private and may change in any release, and theming goes through a generated stylesheet, not through these names (`createThemeStylesheet`, under Tokens; `sites/docs/docs/guides/public-api.md`). An app reads token values through `tokens` from `@mapcairn/theme`, as `examples/embed` does for its page colours.

The generated class names in `styles.css` (such as `._1n4n9ad2`) are not API and may change in any release. `styles.css` also holds a few selectors that are not scoped to a generated class. `[data-tour-highlight="true"]` matches any element on the page with that attribute, and rules such as `[data-layout="sheet"] > <class>`, `[data-dragging="true"] <class>`, `[data-minimised="true"] > <class>` and `[data-disabled="true"] > <class>` match when any ancestor carries the attribute, as does `* + <class>` for a sibling. The `data-*` attributes the components set (`data-layout`, `data-detent`, `data-state` and the rest) are used by those rules and by tests; whether a host may rely on them is not decided.

A host restyles the SDK through `createThemeStylesheet` (colours for each theme, `fontFamily` and `shape`, for each scope), and the generated property names stay private. The SDK ships no base stylesheet and no alias properties, and the host provides its own base styles and a cascade layer for its reset, declared first. A base stylesheet, alias properties, per-component styling hooks, density, slot moves, icon swaps and a light or dark choice for one map alone are out until a named adopter needs one. See "What an app of your own provides" in [Extending MapCairn](https://docs.mapcairn.com/guides/extending.md) and the task [Theme the interface](https://docs.mapcairn.com/tasks/theme-the-interface/).
