{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "theme",
  "type": "registry:lib",
  "title": "Theme and tokens",
  "description": "Theme (brand, wireframe; system, light, dark), styleToCssVars, palettes, theme.css (tokens + every font) and theme-core.css (tokens only), theme-base.css (tokens without the library-wide @source) with one fonts/<family>.css per family. Import theme.css after Tailwind in your main CSS.",
  "dependencies": [
    "@fontsource-variable/dm-sans@^5.2.8",
    "@fontsource-variable/fraunces@^5.2.9",
    "@fontsource-variable/geist-mono@^5.2.7",
    "@fontsource-variable/geist@^5.2.8",
    "@fontsource-variable/inter@^5.2.8",
    "@fontsource-variable/jetbrains-mono@^5.2.8",
    "@fontsource-variable/oswald@^5.3.0",
    "@fontsource-variable/space-grotesk@^5.2.10",
    "@fontsource/instrument-serif@^5.2.8"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/theme/brand.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/brand.ts",
      "content": "// Shared brand identity for Klarhimmel applications; app shells own their navigation.\nexport const klarhimmelStyle = {\n  preset: 'Klarhimmel',\n  mode: 'light',\n  colors: {\n    canvas: '#faf9f7',\n    surface: '#ffffff',\n    ink: '#17171a',\n    muted: '#6b6b75',\n    line: '#e8e6e1',\n    accent: '#1c6ee0',\n    accentFg: '#ffffff',\n  },\n  altColors: {\n    canvas: '#0b0b0d',\n    surface: '#1a1a1f',\n    ink: '#f2f1ee',\n    muted: '#8f8f9a',\n    line: '#383842',\n    accent: '#5b9bf5',\n    accentFg: '#0b1a2c',\n  },\n  fonts: { display: 'Geist', sans: 'Geist', mono: 'Geist Mono' },\n  radius: 8,\n  size: 16,\n} as const;\n\nexport const klarhimmelMark = {\n  paths: ['M2.325 19A14 14 0 1 1 29.675 19Z', 'M3.083 21.4A14 14 0 0 0 28.917 21.4Z'],\n  viewBox: '0 0 32 32',\n};\n\n"
    },
    {
      "path": "src/theme/style.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/style.ts",
      "content": "// Theme root and the Style -> CSS variable mapping. Shades (hover, soft, strong) and the type scale are derived\n// in theme.css with color-mix/calc from the seven palette colours, so a tone re-map re-derives them for free.\nimport { createContext, createElement, useCallback, useContext, useEffect, useRef, useSyncExternalStore, type ReactNode } from 'react';\nimport { accentInkMix, contrast, derivePalette, type Palette } from './palette';\n\nexport { accentInkMix, derivePalette, contrast } from './palette';\nexport type { Palette } from './palette';\n\nexport { FONT_FAMILIES } from './tokens';\nexport { APPEARANCE_KEY, applyStoredAppearance, readAppearance, setAppearance, useAppearance, type Appearance } from './appearance';\nimport { setAppearance, useAppearance } from './appearance';\nexport type { FontFamily, Style, ThemeName, Mode } from './tokens';\nimport type { FontFamily, Style, Mode, ThemeName } from './tokens';\n\n/** The Klarhimmel brand (portal tokens.css, light and dark). Same values as the canvas's DEFAULT_STYLE. */\nexport const BRAND_STYLE: Style = {\n  preset: 'Klarhimmel',\n  mode: 'light',\n  colors: { canvas: '#faf9f7', surface: '#ffffff', ink: '#17171a', muted: '#6b6b75', line: '#e8e6e1', accent: '#1c6ee0', accentFg: '#ffffff' },\n  altColors: { canvas: '#0b0b0d', surface: '#1a1a1f', ink: '#f2f1ee', muted: '#8f8f9a', line: '#383842', accent: '#5b9bf5', accentFg: '#0b1a2c' },\n  fonts: { display: 'Geist', sans: 'Geist', mono: 'Geist Mono' },\n  radius: 8,\n  size: 16,\n};\n\nconst SERIF = new Set<FontFamily>(['Instrument Serif', 'Fraunces']);\nconst MONO = new Set<FontFamily>(['Geist Mono', 'JetBrains Mono']);\n/** Narrow display faces (a trade's sign-style headings): set at their own spacing, never tightened. */\nconst CONDENSED = new Set<FontFamily>(['Oswald']);\nconst FALLBACK_SANS = \"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif\";\nconst FALLBACK_SERIF = \"ui-serif, Georgia, 'Times New Roman', serif\";\nconst FALLBACK_MONO = 'ui-monospace, SFMono-Regular, Menlo, monospace';\n\n/** CSS font-family value for a FontFamily: the fontsource family name, its metric-matched local fallback (font-fallbacks.css), then a generic one. */\nexport function fontStack(font: FontFamily): string {\n  const name = font === 'Instrument Serif' ? font : `${font} Variable`;\n  const fallback = SERIF.has(font) ? FALLBACK_SERIF : MONO.has(font) ? FALLBACK_MONO : FALLBACK_SANS;\n  return `'${name}', '${name} Fallback', ${fallback}`;\n}\n\n/** The palette a Style renders in `mode`: `colors` for its own mode, else `altColors`, else a derived one. */\nexport function paletteFor(style: Style, mode: Mode): Palette {\n  if (mode === style.mode) return style.colors;\n  return style.altColors ?? derivePalette(style.colors, style.mode, mode);\n}\n\n/** CSS custom properties for a Style rendered in `mode` (default: the style's own). Palette + shadows follow the mode; fonts, radius and size do not. */\nexport function styleToCssVars(style: Style, mode: Mode = style.mode): Record<string, string> {\n  const c = paletteFor(style, mode);\n  const mix = accentInkMix(c, mode);\n  return {\n    '--kh-p-canvas': c.canvas,\n    '--kh-p-surface': c.surface,\n    '--kh-p-ink': c.ink,\n    '--kh-p-muted': c.muted,\n    '--kh-p-line': c.line,\n    '--kh-p-accent': c.accent,\n    '--kh-p-accent-fg': c.accentFg,\n    // only when set, so a palette without one hashes and renders as before (theme-base.css falls back to the accent)\n    ...(c.accentFill ? { '--kh-p-accent-fill': c.accentFill } : {}),\n    // a second action's fill, only as a pair that reads (>= 4.5:1); otherwise that button keeps its outline (theme-base.css .kh-accent2)\n    ...(c.accent2 && c.accent2Fg && contrast(c.accent2, c.accent2Fg) >= 4.5 ? { '--kh-p-accent2': c.accent2, '--kh-p-accent2-fg': c.accent2Fg } : {}),\n    '--kh-font-display': fontStack(style.fonts.display),\n    '--kh-font-sans': fontStack(style.fonts.sans),\n    '--kh-font-mono': fontStack(style.fonts.mono),\n    '--kh-radius': `${style.radius}px`,\n    '--kh-size': `${style.size}px`,\n    // dark surfaces need heavier shadows to read at all\n    '--kh-shadow-rgb': mode === 'dark' ? '0 0 0' : '23 23 26',\n    '--kh-shadow-a': mode === 'dark' ? '3' : '1',\n    // heading tracking scale (theme-base.css): a condensed display face keeps its own spacing; omitted at 1, so other styles are unchanged\n    ...(CONDENSED.has(style.fonts.display) ? { '--kh-track': '0' } : {}),\n    // headings in capitals keep their own spacing plus a little air (theme-base.css); omitted when as written\n    ...(style.headingCase === 'uppercase' ? { '--kh-heading-case': 'uppercase', '--kh-track': '0', '--kh-case-track': '0.04em' } : {}),\n    // a pale accent keeps less of itself in accent text so it stays readable; omitted at the CSS default (78%), so most styles are unchanged\n    ...(mix < 78 ? { '--kh-accent-ink-mix': `${mix}%` } : {}),\n    // primary buttons in the accent fill (theme-base.css --kh-primary), only where accent-fg on it reads (>= 4.5:1) in this mode;\n    // otherwise, and by default, the ink button stays\n    ...(style.buttons === 'accent' && contrast(c.accentFill ?? c.accent, c.accentFg) >= 4.5 ? { '--kh-primary-ink': '0%' } : {}),\n  };\n}\n\n/** Stable short hash of everything `styleToCssVars` would emit for a style, both modes: the class a Theme carries. */\nexport function styleClass(style: Style): string {\n  const text = JSON.stringify([styleToCssVars(style, 'light'), styleToCssVars(style, 'dark')]);\n  let h = 0x811c9dc5;\n  for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 0x01000193);\n  return `kh-s-${(h >>> 0).toString(36)}`;\n}\n\n/**\n * The stylesheet for a Style, to be written to a CSS file at build time: `styleToCss(style)` -> `.css`. A <Theme style> carries\n * `styleClass(style)` instead of an inline style attribute, so server-rendered HTML passes a strict CSP (`style-src 'self'`) and\n * the palette is there on first paint and without JavaScript. Both modes are emitted; `data-kh-mode` picks one.\n */\nexport function styleToCss(style: Style): string {\n  const cls = styleClass(style);\n  const rule = (mode: Mode) =>\n    `.kh-root.${cls}[data-kh-theme='brand'][data-kh-mode='${mode}'] {\\n${Object.entries(styleToCssVars(style, mode)).map(([k, v]) => `  ${k}: ${v};`).join('\\n')}\\n}\\n`;\n  return rule('light') + rule('dark');\n}\n\nconst DARK_QUERY = '(prefers-color-scheme: dark)';\nconst hasMedia = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function';\n/** The OS colour scheme right now. 'light' where there is no window (SSR). */\nexport function systemMode(): Mode {\n  return hasMedia() && window.matchMedia(DARK_QUERY).matches ? 'dark' : 'light';\n}\nfunction subscribeSystem(cb: () => void) {\n  if (!hasMedia()) return () => {};\n  const mq = window.matchMedia(DARK_QUERY);\n  mq.addEventListener('change', cb);\n  return () => mq.removeEventListener('change', cb);\n}\n\n/** The resolved mode of the nearest <Theme>; null outside one. */\nconst ModeContext = createContext<Mode | null>(null);\n\n/** The OS colour scheme, live (re-renders on change). 'light' on the server. */\nexport function useSystemMode(): Mode {\n  return useSyncExternalStore(subscribeSystem, systemMode, () => 'light' as Mode);\n}\n\nexport interface ThemeProps {\n  theme?: ThemeName;\n  /** Per-project overrides of the brand tokens. Ignored by the wireframe theme. */\n  style?: Style | null;\n  /**\n   * 'system' (default): follow `prefers-color-scheme`; the navbar toggle (`kh:theme-toggle`) switches by hand and a later\n   * change of the OS setting wins again. 'light' / 'dark' pin the mode and ignore toggles. A 'system' Theme nested in\n   * another Theme just follows the outer one (one page, one mode): the toggle event bubbles to the outer Theme.\n   */\n  mode?: Mode | 'system';\n  className?: string;\n  children?: ReactNode;\n}\n\n/** Theme root: `.kh-root`, the theme and mode attributes, and the style's CSS variables for the rendered mode. */\nexport function Theme({ theme = 'brand', style, mode = 'system', className, children }: ThemeProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  // useSyncExternalStore: the first client render already has the OS value (no flash); the server snapshot is 'light'.\n  const system = useSystemMode();\n  const outer = useContext(ModeContext);\n  const inherits = mode === 'system' && outer !== null;\n  // The visitor's pick, stored across pages (appearance.ts); only an outermost 'system' Theme reads and writes it.\n  const stored = useAppearance();\n  const manual = stored === 'system' ? null : stored;\n  const pinned = mode !== 'system';\n  const latestPick = useRef(manual);\n  latestPick.current = manual;\n\n  // A change of the OS setting overrides the manual selection. Not in a frame: there prefers-color-scheme follows the parent's\n  // colour scheme, so the parent's own switch would undo itself (Klar Builder App 11-13, the mock framing its screens); and not\n  // when the new mode is the one already picked, since nothing is overridden then.\n  useEffect(() => (pinned || inherits || (typeof window !== 'undefined' && window !== window.top) ? undefined\n    : subscribeSystem(() => { if (systemMode() !== latestPick.current) setAppearance('system'); })), [pinned, inherits]);\n\n  // React owns data-kh-mode: handle the toggle event here and cancel it so nothing flips the attribute behind our back.\n  const onToggle = useCallback((e: Event) => {\n    if (e.defaultPrevented || inherits) return; // a nested Theme closer to the button already took it, or the outer one will\n    e.preventDefault();\n    const next = (e as CustomEvent<{ mode?: Mode }>).detail?.mode;\n    if (!pinned && (next === 'light' || next === 'dark')) setAppearance(next);\n  }, [pinned, inherits]);\n  useEffect(() => {\n    const el = ref.current;\n    el?.addEventListener('kh:theme-toggle', onToggle);\n    return () => el?.removeEventListener('kh:theme-toggle', onToggle);\n  }, [onToggle]);\n\n  const resolvedMode: Mode = pinned ? mode : inherits ? outer : manual ?? system;\n  const override = theme === 'brand' && style ? style : undefined;\n  const vars = override ? styleToCssVars(override, resolvedMode) : undefined;\n  // Without the host's stylesheet (styleToCss) or when the style changes live (an editor), the variables are also set through\n  // the CSSOM after mount: element.style.setProperty is not an inline style attribute in the markup, so a strict CSP allows it.\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || !vars) return;\n    for (const [k, v] of Object.entries(vars)) el.style.setProperty(k, v);\n    return () => { for (const k of Object.keys(vars)) el.style.removeProperty(k); };\n  }, [vars && JSON.stringify(vars)]);\n  return createElement(\n    ModeContext.Provider,\n    { value: resolvedMode },\n    createElement(\n    'div',\n    { ref, className: ['kh-root', override && styleClass(override), className].filter(Boolean).join(' '), 'data-kh-theme': theme, 'data-kh-mode': resolvedMode, ...(pinned ? { 'data-kh-mode-pinned': '' } : {}) },\n    children,\n    ),\n  );\n}\n"
    },
    {
      "path": "src/theme/appearance.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/appearance.ts",
      "content": "// The visitor's light or dark choice, kept across pages and visits in one key (the one /ws already used). Theme mode=\"system\" and\n// the navbar's ThemeToggle read and write it, so a pick on one page holds on the next.\nimport { useSyncExternalStore } from 'react';\nimport type { Mode } from './tokens';\n\nexport type Appearance = 'system' | Mode;\nexport const APPEARANCE_KEY = 'kh-appearance';\n// The palette variables a Theme sets for the rendered mode; a hand switch drops them so the stylesheet's other mode applies.\nexport const MODE_VARS = /^--kh-(p-|shadow)/;\n\nconst listeners = new Set<() => void>();\n\nexport function readAppearance(): Appearance {\n  try {\n    const v = localStorage.getItem(APPEARANCE_KEY);\n    return v === 'light' || v === 'dark' ? v : 'system';\n  } catch {\n    return 'system';\n  }\n}\n\nexport function setAppearance(a: Appearance) {\n  try {\n    if (a === 'system') localStorage.removeItem(APPEARANCE_KEY);\n    else localStorage.setItem(APPEARANCE_KEY, a);\n  } catch { /* private mode: the choice lasts for this page only */ }\n  listeners.forEach((l) => l());\n}\n\nfunction subscribe(l: () => void) {\n  listeners.add(l);\n  addEventListener('storage', l);\n  return () => { listeners.delete(l); removeEventListener('storage', l); };\n}\n\n/** The stored choice, live (another tab's change too). 'system' on the server. */\nexport function useAppearance(): Appearance {\n  return useSyncExternalStore(subscribe, readAppearance, () => 'system' as Appearance);\n}\n\n/** For a page whose Theme does not hydrate (static HTML with an island header): apply the stored choice to every theme root.\n *  Run it as early as the page allows (a module script right after the body opens), so the page does not flash. */\nexport function applyStoredAppearance(root: ParentNode = document) {\n  const a = readAppearance();\n  if (a === 'system') return;\n  root.querySelectorAll<HTMLElement>('[data-kh-theme]').forEach((el) => {\n    el.dataset.khMode = a;\n    for (const k of Array.from(el.style)) if (MODE_VARS.test(k)) el.style.removeProperty(k);\n  });\n}\n"
    },
    {
      "path": "src/theme/tokens.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/tokens.ts",
      "content": "// The Style shape and its names, with no DOM and no React, so a worker (Canvas, MCP) can import presets and types\n// without typechecking the browser half of style.ts (kh-canvas, 2026-10-10).\nimport type { Palette } from './palette';\n\nexport const FONT_FAMILIES = ['Geist', 'Geist Mono', 'Inter', 'Space Grotesk', 'DM Sans', 'Instrument Serif', 'Fraunces', 'JetBrains Mono', 'Oswald'] as const;\nexport type FontFamily = (typeof FONT_FAMILIES)[number];\n\n/** Structurally the canvas's `Style` (src/shared/schema.ts). */\nexport interface Style {\n  preset?: string;\n  /** The mode `colors` is authored for. */\n  mode: 'light' | 'dark';\n  colors: Palette;\n  /** The palette for the opposite of `mode`. Absent: derived by `derivePalette`. */\n  altColors?: Palette;\n  fonts: { display: FontFamily; sans: FontFamily; mono: FontFamily };\n  radius: number;\n  size: number;\n  /** What the primary button is filled with: the ink (default) or the accent, for a brand whose colour is its buttons (a rebuilt site with its own accent). */\n  buttons?: 'ink' | 'accent';\n  /** Headings in capitals, for a brand that sets them so (a hotel's signage, ettsmart.se). Default: as written. */\n  headingCase?: 'none' | 'uppercase';\n}\n\nexport type ThemeName = 'brand' | 'wireframe';\nexport type Mode = 'light' | 'dark';\n"
    },
    {
      "path": "src/theme/palette.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/palette.ts",
      "content": "// Palette maths: sRGB hex <-> OKLCH, WCAG contrast, and the deterministic light<->dark derivation used when a Style\n// has no explicit `altColors`. Pure; no DOM, no React.\n\nexport interface Palette {\n  canvas: string; surface: string; ink: string; muted: string; line: string; accent: string; accentFg: string;\n  /** What accent-fg sits on (buttons, the accent band) when it is not the accent: a light brand colour (a yellow) that fills as\n   *  itself while `accent` is the darker shade text and small marks need on the canvas. Unset: fills use the accent. */\n  accentFill?: string;\n  /** A second brand colour for a second action, a fill with its own foreground (ettsmart.se's hero: 'Our Locations' in their blue beside\n   *  'Book Now' in their burgundy). Used only as a pair, and only where `accent2Fg` on it reads at 4.5:1; never for text or surfaces. */\n  accent2?: string;\n  accent2Fg?: string;\n}\nexport type PaletteMode = 'light' | 'dark';\n\ntype Lch = { l: number; c: number; h: number };\n\nconst toLinear = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst fromLinear = (v: number) => (v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);\n\nfunction hexToRgb(hex: string): [number, number, number] {\n  const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());\n  if (!m) return [0, 0, 0];\n  const n = parseInt(m[1]!, 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\n/** WCAG relative luminance of a #rrggbb colour. */\nexport function luminance(hex: string): number {\n  const [r, g, b] = hexToRgb(hex).map((v) => toLinear(v / 255)) as [number, number, number];\n  return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/** WCAG contrast ratio (1 to 21) of two #rrggbb colours. */\nexport function contrast(a: string, b: string): number {\n  const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n  return (hi + 0.05) / (lo + 0.05);\n}\n\nfunction hexToOklch(hex: string): Lch {\n  const [r, g, b] = hexToRgb(hex).map((v) => toLinear(v / 255)) as [number, number, number];\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n  const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;\n  const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n  const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n  return { l: L, c: Math.hypot(A, B), h: Math.atan2(B, A) };\n}\n\n/** Linear sRGB of an OKLCH colour, unclamped (components outside 0..1 are out of gamut). */\nfunction oklchToLinear({ l, c, h }: Lch): [number, number, number] {\n  const a = c * Math.cos(h);\n  const b = c * Math.sin(h);\n  const l_ = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n  const m_ = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n  const s_ = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;\n  return [\n    4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,\n    -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,\n    -0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_,\n  ];\n}\n\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v));\nconst inGamut = (rgb: number[]) => rgb.every((v) => v >= -0.0005 && v <= 1.0005);\nconst hex2 = (v: number) => Math.round(clamp01(fromLinear(clamp01(v))) * 255).toString(16).padStart(2, '0');\n\n/** OKLCH to #rrggbb. Out-of-gamut chroma is reduced (hue and lightness kept). */\nfunction oklchToHex(lch: Lch): string {\n  const l = Math.min(1, Math.max(0, lch.l));\n  let c = Math.max(0, lch.c);\n  let rgb = oklchToLinear({ l, c, h: lch.h });\n  if (!inGamut(rgb)) {\n    let lo = 0;\n    let hi = c;\n    for (let i = 0; i < 24; i++) {\n      const mid = (lo + hi) / 2;\n      if (inGamut(oklchToLinear({ l, c: mid, h: lch.h }))) lo = mid;\n      else hi = mid;\n    }\n    c = lo;\n    rgb = oklchToLinear({ l, c, h: lch.h });\n  }\n  return `#${rgb.map(hex2).join('')}`;\n}\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n\n/** Steps the lightness of `hex` away from `bg` (lighter on a dark bg, darker on a light one) until contrast >= min. */\nfunction ensureContrast(hex: string, bgs: string[], min: number): string {\n  const lch = hexToOklch(hex);\n  const dir = luminance(bgs[0]!) < 0.4 ? 1 : -1;\n  let out = hex;\n  for (let i = 0; i < 120 && bgs.some((bg) => contrast(out, bg) < min); i++) {\n    lch.l = clamp(lch.l + dir * 0.01, 0, 1);\n    out = oklchToHex(lch);\n  }\n  return out;\n}\n\n/** The accent with its hue and chroma kept, its lightness moved until it reads on `canvas` (text-sized links: 4.5). */\nfunction fitAccent(accent: string, canvas: string, to: PaletteMode): string {\n  const lch = hexToOklch(accent);\n  // start in the band the target mode favours, then walk away from the canvas until contrast holds\n  lch.l = to === 'dark' ? Math.max(lch.l, 0.68) : Math.min(lch.l, 0.55);\n  let out = oklchToHex(lch);\n  const dir = to === 'dark' ? 1 : -1;\n  for (let i = 0; i < 80 && contrast(out, canvas) < 4.5; i++) {\n    lch.l = clamp(lch.l + dir * 0.01, 0, 1);\n    out = oklchToHex(lch);\n  }\n  return out;\n}\n\n/** Near-black or near-white text for an accent fill, tinted with the canvas hue; whichever contrasts more. */\nfunction accentFgFor(accent: string, canvas: string, original: string): string {\n  const { h, c } = hexToOklch(canvas);\n  const dark = oklchToHex({ l: 0.18, c: Math.min(c, 0.03), h });\n  const light = oklchToHex({ l: 0.99, c: Math.min(c, 0.01), h });\n  const prefer = luminance(original) > 0.5 ? light : dark; // keep the original's direction when it passes\n  const other = prefer === light ? dark : light;\n  return contrast(prefer, accent) >= 4.5 || contrast(prefer, accent) >= contrast(other, accent) ? prefer : other;\n}\n\n/**\n * The palette of the opposite mode, derived deterministically. Lightness is inverted in OKLCH for canvas, surface, ink,\n * muted and line (hue and chroma kept, so a warm paper becomes a warm charcoal); the accent keeps its hue and has its\n * lightness walked until it reads on the new canvas. Guarantees (checked by tests): ink/canvas, muted/canvas,\n * muted/surface, accent/canvas and accentFg/accent at 4.5:1 or more.\n */\nexport function derivePalette(colors: Palette, from: PaletteMode, to: PaletteMode): Palette {\n  if (from === to) return { ...colors };\n  const cv = hexToOklch(colors.canvas);\n  const sf = hexToOklch(colors.surface);\n  const ink = hexToOklch(colors.ink);\n  const mu = hexToOklch(colors.muted);\n  const ln = hexToOklch(colors.line);\n  let canvas: Lch;\n  let surface: Lch;\n  let line: Lch;\n  if (to === 'dark') {\n    canvas = { ...cv, l: 0.13 + (1 - cv.l) * 0.5 };\n    surface = { ...sf, l: canvas.l + 0.04 + Math.abs(sf.l - cv.l) };\n    line = { ...ln, l: canvas.l + clamp(Math.abs(ln.l - cv.l) * 1.6, 0.1, 0.26) };\n  } else {\n    canvas = { ...cv, l: 1 - cv.l * 0.15 };\n    surface = sf.l >= cv.l ? { ...sf, l: 1, c: sf.c * 0.3 } : { ...sf, l: canvas.l - clamp(cv.l - sf.l, 0.02, 0.06) };\n    line = { ...ln, l: canvas.l - clamp(Math.abs(ln.l - cv.l) * 0.5, 0.05, 0.13) };\n  }\n  const canvasHex = oklchToHex(canvas);\n  const surfaceHex = oklchToHex(surface);\n  const inkHex = ensureContrast(oklchToHex({ ...ink, l: clamp(1.1 - ink.l, 0.1, 0.98) }), [canvasHex, surfaceHex], 7);\n  const mutedHex = ensureContrast(oklchToHex({ ...mu, l: clamp(1.2 - mu.l, 0.3, 0.8) }), [canvasHex, surfaceHex], 4.5);\n  let accent = fitAccent(colors.accent, canvasHex, to);\n  let accentFg = accentFgFor(accent, canvasHex, colors.accentFg);\n  // a mid-lightness accent may fail with both foregrounds: walk it away from the canvas-side until one passes\n  const lch = hexToOklch(accent);\n  for (let i = 0; i < 80 && contrast(accentFg, accent) < 4.5; i++) {\n    lch.l = clamp(lch.l + (to === 'dark' ? 0.01 : -0.01), 0, 1);\n    accent = oklchToHex(lch);\n    accentFg = accentFgFor(accent, canvasHex, colors.accentFg);\n  }\n  return {\n    canvas: canvasHex,\n    surface: surfaceHex,\n    ink: inkHex,\n    muted: mutedHex,\n    line: oklchToHex(line),\n    accent,\n    accentFg,\n    // a fill with its own foreground reads the same on either canvas, so it carries over as the pair it was given\n    ...(colors.accentFill && contrast(colors.accentFill, colors.accentFg) >= 4.5 ? { accentFill: colors.accentFill, accentFg: colors.accentFg } : {}),\n    // the second action's fill carries over the same way\n    ...(colors.accent2 && colors.accent2Fg && contrast(colors.accent2, colors.accent2Fg) >= 4.5 ? { accent2: colors.accent2, accent2Fg: colors.accent2Fg } : {}),\n  };\n}\n\n/**\n * How much accent `--kh-accent-ink` keeps (the rest is ink) so accent text and icons read at 4.5:1 on the page and on the muted\n * band (theme-base.css: --kh-tone-muted, 4% ink in light mode, 7% in dark). 78 for most palettes; a pale accent (a bright yellow)\n * gets less, down to 0 (plain ink). A step of 2 keeps the result stable.\n */\nexport function accentInkMix(c: Palette, mode: 'light' | 'dark'): number {\n  const bands = [c.canvas, mixHex(c.ink, mode === 'light' ? 4 : 7, c.canvas)];\n  for (let pct = 78; pct > 0; pct -= 2) {\n    const ink = mixHex(c.accent, pct, c.ink);\n    if (bands.every((bg) => contrast(ink, bg) >= 4.5)) return pct;\n  }\n  return 0;\n}\n\n// sRGB hex <-> OKLab\nconst linOk = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst gamOk = (v: number) => (v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);\nconst toOkLab = (hex: string): [number, number, number] => {\n  const n = parseInt(hex.slice(1), 16);\n  const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((v) => linOk(v / 255)) as [number, number, number];\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n  return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];\n};\nconst fromOkLab = ([L, a, b]: [number, number, number]) => {\n  const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n  const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n  const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;\n  const rgb = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];\n  return '#' + rgb.map((v) => Math.round(Math.min(1, Math.max(0, gamOk(v))) * 255).toString(16).padStart(2, '0')).join('');\n};\n/** Mix two #rrggbb colours the way CSS color-mix(in oklab, a pct%, b) does (for the shades theme-base.css derives at runtime). */\nexport const mixHex = (a: string, pctA: number, b: string) => {\n  const [x, y] = [toOkLab(a), toOkLab(b)];\n  return fromOkLab(x.map((v, i) => (v * pctA) / 100 + y[i]! * (1 - pctA / 100)) as [number, number, number]);\n};\n"
    },
    {
      "path": "src/theme/presets.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/presets.ts",
      "content": "// Theme presets: named token bundles, one switch (Felix 2026-10-10, \"make variations easier and faster\"). The one list for\n// Canvas (setStyle {preset}, get_style, its voice-words mapping), sites and kh-vary. No React: the worker imports it.\n// Names are stored in documents: Klarhimmel, Midnight, Editorial, Mono and Studio must never be renamed (kh-canvas).\nimport type { Style } from './tokens';\nimport { clone } from '../lib/clone';\n\nexport const PRESETS: Record<string, Style> = {\n  /** The Klarhimmel theme for sections: warm paper, near-black ink, one sky-blue accent, Inter. BRAND_STYLE's values except the type:\n   *  Felix 16 Nov on the Klarhimmel theme, \"use inter font\" (decision log, the lead: the theme in Workshop and here, not the sites'\n   *  own chrome, which stays Geist in theme-base.css). */\n  Klarhimmel: {\n    preset: 'Klarhimmel',\n    mode: 'light',\n    colors: { canvas: '#faf9f7', surface: '#ffffff', ink: '#17171a', muted: '#6b6b75', line: '#e8e6e1', accent: '#1c6ee0', accentFg: '#ffffff' },\n    altColors: { canvas: '#0b0b0d', surface: '#1a1a1f', ink: '#f2f1ee', muted: '#8f8f9a', line: '#383842', accent: '#5b9bf5', accentFg: '#0b1a2c' },\n    fonts: { display: 'Inter', sans: 'Inter', mono: 'Geist Mono' },\n    radius: 8,\n    size: 16,\n  },\n  Midnight: {\n    preset: 'Midnight',\n    mode: 'dark',\n    colors: { canvas: '#0b0b14', surface: '#151522', ink: '#ececf4', muted: '#a1a1b8', line: '#2a2a40', accent: '#a78bfa', accentFg: '#0b0b14' },\n    altColors: { canvas: '#f7f6fc', surface: '#ffffff', ink: '#15141f', muted: '#5c5a72', line: '#e0ddef', accent: '#6d3fd8', accentFg: '#ffffff' },\n    fonts: { display: 'Geist', sans: 'Geist', mono: 'Geist Mono' },\n    radius: 10,\n    size: 16,\n  },\n  Editorial: {\n    preset: 'Editorial',\n    mode: 'light',\n    colors: { canvas: '#faf6ee', surface: '#f1ebdd', ink: '#1c1917', muted: '#6b6258', line: '#ddd3bf', accent: '#9a3412', accentFg: '#fff8f0' },\n    altColors: { canvas: '#171310', surface: '#231d18', ink: '#f3ece0', muted: '#b3a797', line: '#3b3229', accent: '#f0925f', accentFg: '#1c0f07' },\n    fonts: { display: 'Instrument Serif', sans: 'DM Sans', mono: 'JetBrains Mono' },\n    radius: 4,\n    size: 17,\n  },\n  Mono: {\n    preset: 'Mono',\n    mode: 'light',\n    colors: { canvas: '#ffffff', surface: '#f2f2f2', ink: '#000000', muted: '#555555', line: '#000000', accent: '#000000', accentFg: '#ffffff' },\n    altColors: { canvas: '#000000', surface: '#141414', ink: '#ffffff', muted: '#aaaaaa', line: '#ffffff', accent: '#ffffff', accentFg: '#000000' },\n    fonts: { display: 'JetBrains Mono', sans: 'JetBrains Mono', mono: 'JetBrains Mono' },\n    radius: 0,\n    size: 15,\n  },\n  Studio: {\n    preset: 'Studio',\n    mode: 'light',\n    colors: { canvas: '#ffffff', surface: '#f1f5f9', ink: '#0f172a', muted: '#566277', line: '#e2e8f0', accent: '#1d4ed8', accentFg: '#ffffff' },\n    altColors: { canvas: '#0b1120', surface: '#141c30', ink: '#e6ecf7', muted: '#98a6c0', line: '#26324d', accent: '#7aa2ff', accentFg: '#0b1120' },\n    fonts: { display: 'Space Grotesk', sans: 'Space Grotesk', mono: 'JetBrains Mono' },\n    radius: 12,\n    size: 16,\n  },\n  /** A trade or clinic that wants calm and trust: deep green on off-white, Inter, soft corners. */\n  Forest: {\n    preset: 'Forest',\n    mode: 'light',\n    colors: { canvas: '#f6f7f3', surface: '#ffffff', ink: '#14201a', muted: '#55625a', line: '#dfe4dc', accent: '#1f6b46', accentFg: '#ffffff' },\n    altColors: { canvas: '#0d1411', surface: '#16201b', ink: '#e8efea', muted: '#9aa9a0', line: '#2a3830', accent: '#6fcf9b', accentFg: '#0b1a12' },\n    fonts: { display: 'Inter', sans: 'Inter', mono: 'JetBrains Mono' },\n    radius: 10,\n    size: 16,\n  },\n  /** Hospitality and food: warm sand, a terracotta accent, Fraunces headlines. */\n  Sand: {\n    preset: 'Sand',\n    mode: 'light',\n    colors: { canvas: '#fbf7f1', surface: '#ffffff', ink: '#241a12', muted: '#6e6053', line: '#eadfd1', accent: '#a8431c', accentFg: '#ffffff' },\n    altColors: { canvas: '#16110c', surface: '#211a13', ink: '#f4ebe0', muted: '#b4a594', line: '#3a2f24', accent: '#f08a5d', accentFg: '#1f0f06' },\n    fonts: { display: 'Fraunces', sans: 'DM Sans', mono: 'JetBrains Mono' },\n    radius: 6,\n    size: 17,\n  },\n  /** Finance, legal, B2B services: navy ink, a teal accent, tight corners, Inter. */\n  Harbor: {\n    preset: 'Harbor',\n    mode: 'light',\n    colors: { canvas: '#f7f9fb', surface: '#ffffff', ink: '#0d1b2a', muted: '#536273', line: '#dde4ec', accent: '#0f6e7a', accentFg: '#ffffff' },\n    altColors: { canvas: '#08111b', surface: '#101c29', ink: '#e6eef6', muted: '#93a4b6', line: '#223246', accent: '#5cc6d2', accentFg: '#061218' },\n    fonts: { display: 'Inter', sans: 'Inter', mono: 'JetBrains Mono' },\n    radius: 4,\n    size: 16,\n  },\n};\n\nexport const PRESET_NAMES = Object.keys(PRESETS);\n\n/** A preset by name, case-insensitive; a fresh copy, or undefined. */\nexport function findPreset(name: string): Style | undefined {\n  const key = PRESET_NAMES.find((n) => n.toLowerCase() === name.trim().toLowerCase());\n  return key ? clone(PRESETS[key]!) : undefined;\n}\n"
    },
    {
      "path": "src/lib/clone.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/lib/clone.ts",
      "content": "// Deep copy for JSON data (props, decks, styles). Not structuredClone: that is a DOM/worker global, and these modules\n// must typecheck in a worker program with no DOM lib (tsconfig.nodom.json).\nexport const clone = <T>(v: T): T => (v === undefined ? v : JSON.parse(JSON.stringify(v)));\n"
    },
    {
      "path": "src/theme/theme.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/theme.css",
      "content": "/* Klarhimmel UI theme with every font family: tokens (theme-core.css) plus fonts.css. For only some families, import\n   `theme-core.css` and the `fonts/<family>.css` files you use. */\n@import './fonts.css';\n@import './theme-core.css';\n"
    },
    {
      "path": "src/theme/theme-core.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/theme-core.css",
      "content": "/* The tokens (theme-base.css) plus a Tailwind @source of the whole library, so every class any block or component uses is generated.\n   A consumer that renders only some blocks imports theme-base.css instead and adds its own @source lines for those blocks\n   (e.g. @source \"../node_modules/@klarhimmel/ui/src/blocks/hero-centered\";), which roughly halves the stylesheet. */\n@import './theme-base.css';\n\n@source \"../\";\n@source not \"../**/*.test.*\";\n"
    },
    {
      "path": "src/theme/theme-base.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/theme-base.css",
      "content": "/* Klarhimmel UI tokens. ADDITIVE: no Tailwind theme resets, every name carries the kh- prefix, every value is\n   scoped to .kh-root / [data-kh-theme] / [data-kh-tone], so one Tailwind build can host an app's own chrome too.\n\n   Layers\n   1. Palette   --kh-p-*   seven base colours + mode (light/dark) + theme (brand/wireframe). Set by <Theme> / styleToCssVars.\n   2. Surface   --kh-*     what components read. Mapped from the palette, re-mapped per tone, shades derived with color-mix.\n   3. Tailwind  @theme inline names (bg-kh-surface, text-kh-title, rounded-kh, ...).\n   Consumers: @import \"tailwindcss\"; @import \"@klarhimmel/ui/theme.css\"; (theme-core.css adds the @source of the whole library).\n   This file has no @source: import it instead of theme-core.css and @source only the blocks you render, for a smaller stylesheet. */\n\n/* Metric-matched local fallbacks, so the web-font swap does not move the layout (fontStack() names them). */\n@import './font-fallbacks.css';\n\n\n/* ---------- 1. Palette: brand, light ---------- */\n:where(.kh-root, [data-kh-theme]) {\n  --kh-p-canvas: #faf9f7;\n  --kh-p-surface: #ffffff;\n  --kh-p-ink: #17171a;\n  --kh-p-muted: #6b6b75;\n  --kh-p-line: #e8e6e1;\n  --kh-p-accent: #1c6ee0;\n  --kh-p-accent-fg: #ffffff;\n\n  --kh-font-display: 'Geist Variable', 'Geist Variable Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;\n  --kh-font-sans: 'Geist Variable', 'Geist Variable Fallback', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;\n  --kh-font-mono: 'Geist Mono Variable', 'Geist Mono Variable Fallback', ui-monospace, SFMono-Regular, Menlo, monospace;\n\n  --kh-radius: 8px;\n  --kh-size: 16px;\n  --kh-dur: 150ms;\n  /* the brand mark beside the wordmark (Felix 2026-10-10, from klarhimmel.com's .brandmark: 23px mark by a 20px wordmark, 10px gap) */\n  --kh-mark-size: 1.15em;\n  --kh-mark-gap: 0.5em;\n  --kh-mark-min: 20px;\n  --kh-shadow-rgb: 23 23 26;\n  --kh-shadow-a: 1;\n  --kh-tone-muted: 4%; /* how much ink the muted tone mixes into the canvas */\n  --kh-p-danger: #b42318; /* error text and invalid borders: not part of a Style, so one value per mode (>= 4.5:1 on every canvas of the mode) */\n  --kh-p-warning: #8a5300; /* 'needs attention' text (a high priority, a date close by): same rule as danger */\n  color-scheme: light;\n}\n\n/* brand, dark (portal tokens.css dark) */\n[data-kh-theme='brand'][data-kh-mode='dark'] {\n  --kh-p-canvas: #0b0b0d;\n  --kh-p-surface: #1a1a1f;\n  --kh-p-ink: #f2f1ee;\n  --kh-p-muted: #8f8f9a;\n  --kh-p-line: #383842;\n  --kh-p-accent: #5b9bf5;\n  --kh-p-accent-fg: #0b1a2c;\n  --kh-shadow-rgb: 0 0 0;\n  --kh-shadow-a: 3;\n  --kh-tone-muted: 7%;\n  --kh-p-danger: #ff8a7d;\n  --kh-p-warning: #f2b45c;\n  color-scheme: dark;\n}\n\n/* wireframe: greys only, radius 0, one neutral sans, no shadows, no motion */\n[data-kh-theme='wireframe'] {\n  --kh-p-canvas: #f4f4f4;\n  --kh-p-surface: #ffffff;\n  --kh-p-ink: #222222;\n  --kh-p-muted: #666666;\n  --kh-p-line: #d4d4d4;\n  --kh-p-accent: #3a3a3a;\n  --kh-p-accent-fg: #ffffff;\n  --kh-font-display: 'Geist Variable', 'Geist Variable Fallback', ui-sans-serif, system-ui, sans-serif;\n  --kh-font-sans: 'Geist Variable', 'Geist Variable Fallback', ui-sans-serif, system-ui, sans-serif;\n  --kh-font-mono: 'Geist Variable', 'Geist Variable Fallback', ui-sans-serif, system-ui, sans-serif;\n  --kh-radius: 0px;\n  --kh-dur: 0s;\n}\n[data-kh-theme='wireframe'][data-kh-mode='dark'] {\n  --kh-p-canvas: #1d1d1d;\n  --kh-p-surface: #2a2a2a;\n  --kh-p-ink: #ececec;\n  --kh-p-muted: #9a9a9a;\n  --kh-p-line: #444444;\n  --kh-p-accent: #bdbdbd;\n  --kh-p-accent-fg: #1d1d1d;\n  --kh-tone-muted: 7%;\n  color-scheme: dark;\n}\n\n/* A second action in the brand's second colour (Palette.accent2, styleToCssVars): filled where the style has one, else the outline a\n   secondary button has. The fallbacks are the outline, so a style without accent2 looks exactly as before. */\n.kh-accent2 { background: var(--kh-p-accent2, transparent); color: var(--kh-p-accent2-fg, var(--kh-ink)); border-color: var(--kh-p-accent2, var(--kh-edge)); }\n.kh-accent2:hover { background: color-mix(in oklab, var(--kh-p-accent2, transparent) 88%, var(--kh-p-accent2-fg, var(--kh-ink))); }\n\n/* ---------- 2. Surface tokens, mapped from the palette ---------- */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) {\n  --kh-canvas: var(--kh-p-canvas);\n  --kh-surface: var(--kh-p-surface);\n  --kh-ink: var(--kh-p-ink);\n  --kh-muted: color-mix(in oklab, var(--kh-p-muted) 80%, var(--kh-p-ink)); /* a margin over the palette's muted: it also sits on surface-2/3 and the muted tone */\n  --kh-line: var(--kh-p-line);\n  --kh-accent: var(--kh-p-accent);\n  --kh-accent-fg: var(--kh-p-accent-fg);\n  /* What accent-fg text sits on (buttons, the accent band): the palette's accentFill when it has one, so a light brand colour\n     (a yellow) fills its buttons as itself while accent stays the darker one text, links and small marks need on the canvas. */\n  --kh-accent-fill: var(--kh-p-accent-fill, var(--kh-p-accent));\n  --kh-danger: var(--kh-p-danger);\n  --kh-warning: var(--kh-p-warning);\n}\n\n/* The app shell's panels (Felix 2026-10-22 14:4x: the default look for every app; values from the prototype seat, 36e39dbc\n   panels.tsx SHELL_VARS; Felix 16:33 \"reduce border radius and gap slightly\": radius 16 -> 12, gap 10 -> 8, inner radii scaled). All mixes of theme tokens, so dark mode follows. Used by SidebarLayout (src/ui/sidebar.css), board\n   columns and cards. Declared on every tone too: a custom property resolves where it is declared, so from the root alone a board\n   column on an inverse band kept the root's light surface under the band's light ink (1.05:1). */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) {\n  --kh-shell-canvas: color-mix(in oklab, var(--kh-canvas), #000 6%);\n  --kh-shell-gap: 8px;\n  --kh-panel-radius: 12px;\n  --kh-panel-shadow: 0 0 0 1px color-mix(in oklab, var(--kh-ink) 6%, transparent), 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 12px rgb(0 0 0 / 0.03);\n  --kh-panel-bg: var(--kh-surface);\n  --kh-well: color-mix(in oklab, var(--kh-surface) 55%, var(--kh-shell-canvas));\n  --kh-well-radius: 8px;\n  --kh-row-active: color-mix(in oklab, var(--kh-ink) 6%, var(--kh-surface));\n  --kh-card-line: color-mix(in oklab, var(--kh-ink) 9%, transparent);\n  --kh-card-radius: 8px;\n  --kh-card-shadow: 0 1px 2px rgb(0 0 0 / 0.04);\n  --kh-card-shadow-hover: 0 0 0 1px color-mix(in oklab, var(--kh-ink) 6%, transparent), 0 4px 12px rgb(0 0 0 / 0.08);\n  /* Status fills (a dot, a circle with a white figure): todo, doing, review, done. --kh-warning is too dark in light mode for a fill. */\n  --kh-status-todo: var(--kh-muted);\n  --kh-status-doing: var(--kh-accent);\n  --kh-status-review: oklch(from var(--kh-accent) max(l, 0.66) 0.15 70);\n  --kh-status-done: oklch(from var(--kh-accent) max(l, 0.58) 0.14 150);\n}\n\n/* A selected item raised on a track (a toggle group's on item): the surface in light mode; in dark mode the surface is the panel's\n   own colour and a shadow does not show, so it steps lighter (prototype 15:24, the /ws focus bar's Board / List / Documents). */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) { --kh-selected: var(--kh-surface); }\n/* The inverse band is dark in light mode: its surface sits next to its track, so the pill steps toward its light ink, as in dark mode.\n   Declared on the root alone, the band kept the root's white pill under its white ink (KB-353). */\n[data-kh-tone='inverse'] { --kh-selected: color-mix(in oklab, var(--kh-ink) 20%, var(--kh-surface)); }\n/* Re-derived on every tone (KB-353): declared on the root alone, an inverse band in dark mode (a light band) kept the root's dark\n   pill under its dark ink, a hole with unreadable text. That band is light, so its pill is its lightest colour, as in light mode. */\n[data-kh-mode='dark'],\n[data-kh-mode='dark'] [data-kh-tone] { --kh-selected: color-mix(in oklab, var(--kh-ink) 20%, var(--kh-surface)); }\n[data-kh-mode='dark'] [data-kh-tone='inverse']:not([data-kh-dark='raised']) { --kh-selected: var(--kh-canvas); }\n\n/* A fill on the surface that never matches the panel: the chat's own bubble, a composer chip, the stop button. surface-2 is the\n   panel's colour in dark mode, so these mix ink into the surface instead (Klar Portal 19:11 on /ws dark; Felix 18:1x \"These don't\n   look that good in darkmode\"). */\n/* Recomputed on each tone surface: a band sets its own ink and surface, and a token mixed at the root kept the root's colours\n   (the user bubble on an inverse or accent band read 1.3:1, overflow sweep 22:5x 10-22). */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) { --kh-bubble: color-mix(in oklab, var(--kh-ink) 7%, var(--kh-surface)); }\n/* The accent band carries light ink on a saturated surface: mixing that ink in washed the bubble out (4.0-4.4:1), so it darkens. */\n:where([data-kh-tone='accent']) { --kh-bubble: color-mix(in oklab, var(--kh-surface) 86%, black); }\n/* Dark: the panel is lighter than the canvas, so a tint mixed into the canvas sank below it (the 'Current plan' and 'Due' pills\n   read as bare blue text on /ws, Klar Portal 10-22 and the 10-24 sweep); it mixes into the surface, a little stronger. */\n[data-kh-mode='dark'], [data-kh-mode='dark'] [data-kh-tone] { --kh-accent-soft-mix: 16%; --kh-accent-soft-base: var(--kh-surface); }\n[data-kh-mode='dark'] [data-kh-tone='inverse'] { --kh-accent-soft-mix: 11%; --kh-accent-soft-base: var(--kh-canvas); } /* the inverse band is light here */\n[data-kh-mode='dark'], [data-kh-mode='dark'] [data-kh-tone] { --kh-bubble: color-mix(in oklab, var(--kh-ink) 14%, var(--kh-surface)); }\n\n/* Tones re-map the surface inside one section. They read --kh-p-*, never themselves, so they cannot cycle. */\n[data-kh-tone='muted'] {\n  --kh-canvas: color-mix(in oklab, var(--kh-p-ink) var(--kh-tone-muted), var(--kh-p-canvas));\n}\n[data-kh-tone='inverse'] {\n  --kh-canvas: var(--kh-p-ink);\n  --kh-surface: color-mix(in oklab, var(--kh-p-canvas) 9%, var(--kh-p-ink));\n  --kh-ink: var(--kh-p-canvas);\n  --kh-muted: color-mix(in oklab, var(--kh-p-canvas) 80%, var(--kh-p-ink));\n  --kh-line: color-mix(in oklab, var(--kh-p-canvas) 16%, var(--kh-p-ink));\n  --kh-accent: oklch(from var(--kh-p-accent) max(l, 0.74) c h); /* lightness pinned so a dark or black accent still reads on the dark surface */\n  --kh-accent-fg: var(--kh-p-ink);\n  --kh-accent-fill: var(--kh-accent);\n}\n[data-kh-tone='inverse'] { --kh-danger: #ff8a7d; --kh-warning: #f2b45c; }\n/* Text on a photo (hero-cover): light on a fixed near-black in either mode, so a dark-mode page cannot flip it to dark ink on the\n   picture. The primary button turns white on dark; an accent button keeps the accent pinned light, as on the inverse band. */\n[data-kh-tone='cover'] {\n  --kh-canvas: #0d0d0e;\n  --kh-surface: #1c1c1e;\n  --kh-ink: #ffffff;\n  --kh-muted: #dcdcdc;\n  --kh-line: rgb(255 255 255 / 0.28);\n  --kh-accent: oklch(from var(--kh-p-accent) max(l, 0.74) c h);\n  --kh-accent-fg: #0d0d0e;\n  --kh-accent-fill: var(--kh-accent);\n  --kh-danger: #ff8a7d;\n  --kh-warning: #f2b45c;\n}\n/* The scrim between the photo and the text: never under 55% black, so white body text keeps about 4.5:1 even on a white photo;\n   darker toward the foot, where the text sits in the start alignment. */\n[data-kh-tone='cover'] {\n  --kh-line-strong: color-mix(in oklab, var(--kh-ink) 80%, var(--kh-canvas));\n  --kh-edge: var(--kh-line-strong);\n  --kh-ghost-edge: var(--kh-edge);\n}\n.kh-cover-scrim { background: linear-gradient(to top, rgb(0 0 0 / 0.8), rgb(0 0 0 / 0.58) 55%, rgb(0 0 0 / 0.55)); }\n[data-kh-mode='dark'] [data-kh-tone='inverse'] {\n  --kh-accent: oklch(from var(--kh-p-accent) min(l, 0.46) c h);\n  --kh-accent-fill: var(--kh-accent);\n  /* darker than light mode's: a derived dark palette's ink, this band's canvas, can be a pale grey (#b42318 measured 3.6:1) */\n  --kh-danger: #8f1a12;\n  --kh-warning: #6e4200;\n}\n/* An inverse panel that follows the mode (cta-band; Felix 10-23 22:4x \"too bright for my eyes\"): a dark panel on a light page, but in\n   dark mode the page's own colours on a raised surface with a hairline, never a light slab on a dark page. */\n[data-kh-mode='dark'] [data-kh-tone='inverse'][data-kh-dark='raised'] {\n  --kh-canvas: color-mix(in oklab, var(--kh-p-ink) 6%, var(--kh-p-surface));\n  --kh-surface: color-mix(in oklab, var(--kh-p-ink) 10%, var(--kh-p-surface));\n  --kh-ink: var(--kh-p-ink);\n  --kh-muted: color-mix(in oklab, var(--kh-p-muted) 80%, var(--kh-p-ink));\n  --kh-line: var(--kh-p-line);\n  --kh-accent: var(--kh-p-accent);\n  --kh-accent-fg: var(--kh-p-accent-fg);\n  --kh-accent-fill: var(--kh-p-accent-fill, var(--kh-p-accent));\n  --kh-danger: var(--kh-p-danger);\n  --kh-warning: var(--kh-p-warning);\n  --kh-line-strong: color-mix(in oklab, var(--kh-ink) 13%, var(--kh-line));\n  --kh-edge: var(--kh-line-strong);\n  --kh-ghost-edge: transparent;\n  --kh-accent-soft-mix: 16%;\n  --kh-accent-soft-base: var(--kh-surface);\n  box-shadow: inset 0 0 0 1px var(--kh-p-line);\n}\n[data-kh-tone='accent'] {\n  --kh-canvas: var(--kh-p-accent-fill, var(--kh-p-accent));\n  --kh-surface: var(--kh-p-accent-fill, var(--kh-p-accent)); /* not lighter or darker: ink on it keeps the accent-fg/accent contrast; cards read by their line */\n  --kh-ink: var(--kh-p-accent-fg);\n  --kh-muted: color-mix(in oklab, var(--kh-p-accent-fg) 97%, var(--kh-p-accent-fill, var(--kh-p-accent)));\n  --kh-line: color-mix(in oklab, var(--kh-p-accent-fg) 28%, var(--kh-p-accent-fill, var(--kh-p-accent)));\n  --kh-accent: var(--kh-p-accent-fg);\n  --kh-accent-fg: var(--kh-p-accent-fill, var(--kh-p-accent));\n  --kh-accent-fill: var(--kh-accent);\n  /* shades step away from the foreground (a mid-dark accent carries a light fg, so darker; a light accent, lighter) to keep ink readable on them */\n  --kh-surface-2: oklch(from var(--kh-p-accent-fill, var(--kh-p-accent)) calc(l + sign(l - 0.6) * 0.05) c h);\n  --kh-surface-3: oklch(from var(--kh-p-accent-fill, var(--kh-p-accent)) calc(l + sign(l - 0.6) * 0.09) c h);\n  --kh-accent-soft: var(--kh-surface-2); /* the accent here is the fg colour, so the generic 11% mix would lighten the fill */\n}\n\n/* Internal tone for code consoles and terminals: dark in light and dark mode alike (not part of the public Tone union). */\n[data-kh-tone='console'] {\n  --kh-canvas: #111114;\n  --kh-surface: #1b1b20;\n  --kh-ink: #f2f1ee;\n  --kh-muted: #9c9ca8;\n  --kh-line: #2d2d35;\n  --kh-accent: #7fb4ff;\n  --kh-accent-fg: #0b1a2c;\n  --kh-accent-fill: var(--kh-accent);\n  --kh-danger: #ff8a7d;\n  --kh-warning: #f2b45c;\n}\n[data-kh-theme='wireframe'] [data-kh-tone='console'] {\n  --kh-canvas: #262626;\n  --kh-surface: #303030;\n  --kh-muted: #a0a0a0;\n  --kh-line: #444444;\n  --kh-accent: #c8c8c8;\n  --kh-accent-fg: #262626;\n  --kh-accent-fill: var(--kh-accent);\n}\n\n/* How far the two surface shades step from the canvas toward the ink. Dark mode steps further: its panels are lighter than the\n   canvas, so the light-mode steps left surface-3 the same colour as a panel and a selected row, a pressed chip or a progress\n   track disappeared. Blocks still add a non-colour cue (a bar, a border, a weight) to anything that shows a state. */\n:where(.kh-root, [data-kh-theme]) {\n  --kh-shade-2: 5%;\n  --kh-shade-3: 9%;\n}\n/* In dark mode the shades step from the surface, not the canvas (KB-353, 2026-11-14): stepped from the canvas, surface-2 landed on\n   the panel's own colour (1.01:1 measured on the brand), so a quiet fill (a soft button, a toggle track, a folded section) vanished and\n   apps drew borders instead. Declared on every tone, so each band steps from its own surface. The bar, checked by\n   src/theme/shades-dark.test.ts on the brand and wireframe palettes: surface-2 >= 1.12:1 on the surface, surface-3 >= 1.10:1 on\n   surface-2. Light mode keeps the canvas base and its 5% and 9%; the base is set on every root and band, so a light Theme inside a\n   dark one does not inherit the dark surface. */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) { --kh-shade-base: var(--kh-canvas); }\n[data-kh-mode='dark'],\n[data-kh-mode='dark'] [data-kh-tone] {\n  --kh-shade-2: 7%;\n  --kh-shade-3: 13%;\n  --kh-shade-base: var(--kh-surface);\n}\n/* The inverse band in light mode is dark the same way (KB-354, 2026-11-15): stepped from its canvas, surface-3 (9%) landed on the band's\n   own surface (also 9%), 1.0:1, so a quiet fill and an off Switch's track vanished there. It steps from its surface, as dark mode does;\n   in dark mode the rule above wins on every band. Light page and muted bands keep the canvas base. */\n[data-kh-tone='inverse'] {\n  --kh-shade-2: 7%;\n  --kh-shade-3: 13%;\n  --kh-shade-base: var(--kh-surface);\n}\n\n/* Derived shades. Declared with the same selector as the mapping so they follow a tone's re-mapped colours. */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) {\n  --kh-surface-2: color-mix(in oklab, var(--kh-ink) var(--kh-shade-2), var(--kh-shade-base, var(--kh-canvas)));\n  --kh-surface-3: color-mix(in oklab, var(--kh-ink) var(--kh-shade-3), var(--kh-shade-base, var(--kh-canvas)));\n  --kh-line-strong: color-mix(in oklab, var(--kh-ink) 13%, var(--kh-line));\n  --kh-ink-2: color-mix(in oklab, var(--kh-ink) 62%, var(--kh-muted));\n  --kh-accent-hover: color-mix(in oklab, var(--kh-accent-fill) 86%, var(--kh-ink));\n  --kh-accent-soft: color-mix(in oklab, var(--kh-accent) var(--kh-accent-soft-mix, 11%), var(--kh-accent-soft-base, var(--kh-canvas)));\n  --kh-accent-ink: color-mix(in oklab, var(--kh-accent) var(--kh-accent-ink-mix, 78%), var(--kh-ink)); /* the mix: styleToCssVars, accentInkMix */\n  --kh-focus: color-mix(in oklab, var(--kh-ink) 72%, transparent);\n  --kh-on-ink: var(--kh-canvas); /* text on an ink-coloured fill */\n  /* The backdrop behind a dialog, sheet or command menu: always a dark dim, never the ink, which is near white in dark themes and\n     laid a milky veil over the page (cms.klarhimmel.com, 14 Nov). */\n  --kh-scrim: rgb(0 0 0 / 0.5);\n  /* The primary button: ink by default; a Style with buttons 'accent' sets --kh-primary-ink to 0% (styleToCssVars), and the\n     mix then gives the accent pair. A 100%/0% mix rather than a swap, so every tone re-derives it from its own accent and ink\n     (on the accent band the button turns accent-fg on accent, the pair presets.test.ts checks). Ink comes first: the CSS build\n     adds a no-color-mix fallback from the first colour, so an old browser keeps the ink button. */\n  --kh-primary: color-mix(in oklab, var(--kh-ink) var(--kh-primary-ink, 100%), var(--kh-accent-fill));\n  --kh-on-primary: color-mix(in oklab, var(--kh-on-ink) var(--kh-primary-ink, 100%), var(--kh-accent-fg));\n}\n\n/* The edge of a control (the border of a secondary button, the underline of a link). On the light and muted bands it is the\n   quiet line-strong. On the inverse and accent bands that colour is a few percent away from the band and the control\n   disappears, so there it is mixed far toward the ink: at least 3:1 against the band (WCAG 1.4.11; 80% is what the awkward mid-tone accents need), checked by\n   src/theme/edge.test.ts for the brand and every preset palette. `--kh-ghost-edge` is the same colour for buttons that are\n   otherwise borderless (ghost, soft): transparent on light bands, drawn on dark ones. */\n:where(.kh-root, [data-kh-theme], [data-kh-tone]) {\n  --kh-edge: var(--kh-line-strong);\n  --kh-ghost-edge: transparent;\n}\n[data-kh-tone='inverse'],\n[data-kh-tone='accent'] {\n  --kh-line-strong: color-mix(in oklab, var(--kh-ink) 80%, var(--kh-canvas)); /* every control edge that reads line-strong follows */\n  --kh-edge: var(--kh-line-strong);\n  --kh-ghost-edge: var(--kh-edge);\n}\n\n/* Accent tone: the fill is any brand colour, so no fixed red or amber reads on it; status text takes the band's ink (accent-fg,\n   which holds its contrast by design), and its words and icon carry the meaning, as in the wireframe theme. */\n[data-kh-tone='accent'] { --kh-danger: var(--kh-ink); --kh-warning: var(--kh-ink); }\n\n/* Dark mode + accent tone: the surface is light blue and ink is navy, so text on navy fills must be the light ink. */\n[data-kh-mode='dark'] [data-kh-tone='accent'] {\n  --kh-on-ink: var(--kh-p-ink);\n  --kh-accent-fg: var(--kh-p-ink);\n}\n\n/* Wireframe stays grey and legible: accent text is plain secondary ink. */\n[data-kh-theme='wireframe'],\n[data-kh-theme='wireframe'] [data-kh-tone] {\n  --kh-accent-ink: var(--kh-ink-2);\n  --kh-danger: var(--kh-ink);\n  --kh-warning: var(--kh-ink);\n}\n\n/* Radius scale from the base radius; type scale from the base size. */\n:where(.kh-root, [data-kh-theme]) {\n  --kh-r-sm: calc(var(--kh-radius) * 0.5);\n  --kh-r: var(--kh-radius);\n  --kh-r-lg: calc(var(--kh-radius) * 1.75);\n  --kh-r-xl: calc(var(--kh-radius) * 2.75);\n  --kh-r-pill: 999px;\n\n  --kh-text-caption: calc(var(--kh-size) * 0.8125);\n  --kh-text-small: calc(var(--kh-size) * 0.875);\n  --kh-text-body: var(--kh-size);\n  --kh-text-lead: calc(var(--kh-size) * 1.1875);\n  --kh-text-heading: calc(var(--kh-size) * 1.25);\n  /* fluid by the block's container (cqi), not the viewport; outside a block cqi falls back to viewport units */\n  --kh-text-title: clamp(calc(var(--kh-size) * 1.875), 0.9rem + 3cqi, calc(var(--kh-size) * 2.75));\n  --kh-text-display: clamp(calc(var(--kh-size) * 2.5), 0.8rem + 5.2cqi, calc(var(--kh-size) * 4.5));\n\n  --kh-section: clamp(4rem, 2rem + 6cqi, 7.5rem);\n  --kh-gutter: clamp(1.25rem, 0.5rem + 3.2cqi, 2.5rem);\n  /* The page column (max-w-kh-page): a runtime variable, so a theme or a host sets its own width (Builder's own front: 80rem, KB-275). */\n  --kh-page: 72rem;\n\n  --kh-shadow-1: 0 1px 2px rgb(var(--kh-shadow-rgb) / calc(0.05 * var(--kh-shadow-a)));\n  --kh-shadow-2: 0 1px 2px rgb(var(--kh-shadow-rgb) / calc(0.04 * var(--kh-shadow-a))), 0 6px 16px -4px rgb(var(--kh-shadow-rgb) / calc(0.08 * var(--kh-shadow-a)));\n  --kh-shadow-3: 0 2px 4px rgb(var(--kh-shadow-rgb) / calc(0.04 * var(--kh-shadow-a))), 0 16px 40px -8px rgb(var(--kh-shadow-rgb) / calc(0.14 * var(--kh-shadow-a)));\n}\n\n/* ---------- 3. Tailwind names ---------- */\n@theme inline {\n  --color-kh-canvas: var(--kh-canvas);\n  --color-kh-surface: var(--kh-surface);\n  --color-kh-surface-2: var(--kh-surface-2);\n  --color-kh-surface-3: var(--kh-surface-3);\n  --color-kh-ink: var(--kh-ink);\n  --color-kh-ink-2: var(--kh-ink-2);\n  --color-kh-muted: var(--kh-muted);\n  --color-kh-line: var(--kh-line);\n  --color-kh-line-strong: var(--kh-line-strong);\n  --color-kh-accent: var(--kh-accent);\n  --color-kh-accent-fill: var(--kh-accent-fill);\n  --color-kh-accent-hover: var(--kh-accent-hover);\n  --color-kh-accent-soft: var(--kh-accent-soft);\n  --color-kh-accent-ink: var(--kh-accent-ink);\n  --color-kh-accent-fg: var(--kh-accent-fg);\n  --color-kh-on-ink: var(--kh-on-ink);\n  --color-kh-primary: var(--kh-primary);\n  --color-kh-on-primary: var(--kh-on-primary);\n  --color-kh-danger: var(--kh-danger);\n  --color-kh-warning: var(--kh-warning);\n\n  --font-kh-display: var(--kh-font-display);\n  --font-kh-sans: var(--kh-font-sans);\n  --font-kh-mono: var(--kh-font-mono);\n\n  --text-kh-caption: var(--kh-text-caption);\n  --text-kh-caption--line-height: 1.5;\n  --text-kh-small: var(--kh-text-small);\n  --text-kh-small--line-height: 1.5;\n  --text-kh-body: var(--kh-text-body);\n  --text-kh-body--line-height: 1.6;\n  --text-kh-lead: var(--kh-text-lead);\n  --text-kh-lead--line-height: 1.55;\n  --text-kh-heading: var(--kh-text-heading);\n  --text-kh-heading--line-height: 1.3;\n  --text-kh-heading--letter-spacing: calc(-0.012em * var(--kh-track, 1) + var(--kh-case-track, 0em));\n  --text-kh-title: var(--kh-text-title);\n  --text-kh-title--line-height: 1.12;\n  --text-kh-title--letter-spacing: calc(-0.03em * var(--kh-track, 1) + var(--kh-case-track, 0em));\n  --text-kh-display: var(--kh-text-display);\n  --text-kh-display--line-height: 1.02;\n  --text-kh-display--letter-spacing: calc(-0.04em * var(--kh-track, 1) + var(--kh-case-track, 0em)); /* --kh-track: 0 for a condensed display face (styleToCssVars), whose letters would touch */\n\n  --radius-kh-sm: var(--kh-r-sm);\n  --radius-kh: var(--kh-r);\n  --radius-kh-lg: var(--kh-r-lg);\n  --radius-kh-xl: var(--kh-r-xl);\n  --radius-kh-pill: var(--kh-r-pill);\n\n  --shadow-kh-1: var(--kh-shadow-1);\n  --shadow-kh-2: var(--kh-shadow-2);\n  --shadow-kh-3: var(--kh-shadow-3);\n\n  --spacing-kh-section: var(--kh-section);\n  --spacing-kh-gutter: var(--kh-gutter);\n\n  --container-kh-page: var(--kh-page);\n  --container-kh-narrow: 48rem;\n  --container-kh-prose: 40rem;\n  --container-kh-lead: 34rem;\n}\n\n/* ---------- Block surface ---------- */\n.kh-root,\n.kh-block {\n  font-family: var(--kh-font-sans);\n  font-size: var(--kh-text-body);\n  line-height: 1.6;\n  color: var(--kh-ink);\n  -webkit-font-smoothing: antialiased;\n  text-rendering: optimizeLegibility;\n}\n.kh-root { background: var(--kh-canvas); }\n.kh-block {\n  background: var(--kh-canvas);\n  container-type: inline-size;\n  overflow-x: clip;\n  overflow-wrap: break-word; /* a long word or path wraps instead of widening its grid track */\n}\n/* A grid item defaults to min-width: auto, so one nowrap run (a code line, a truncated label) or a long unbroken string stretches its track past the block\n   at narrow widths. Zero specificity: any min-w utility on the item still wins. */\n.kh-block :where(.grid) > :where(*) { min-width: 0; }\n/* A bare section (hero-prompt bare): the page's background shows behind it, and a focus glow or shadow is not clipped. */\n.kh-block:has(> [data-kh-bare]) { background: transparent; overflow: visible; }\n/* Two bands of the same tone in a row: the first band's bottom padding is already the gap, so the second does not add its top padding again\n   (two full section paddings read as ~240px of dead air). Only after a section band, never after a navbar or banner, and both for blocks that\n   sit side by side and for blocks each wrapped in a div (the directory and the Canvas export). Not after a band that ends flush (a hero whose\n   picture sits on its bottom edge, Section flushEnd): it has no bottom padding, so the next band keeps its top padding. A section that paints its own\n   band inside the block (data-kh-own-band: stats-band's accent fill) keeps its padding and leaves its neighbours theirs: its padding is inside its colour. */\n[data-kh-tone='accent'] > [data-kh-own-band] { --kh-accent-fill: var(--kh-canvas); --kh-accent-fg: var(--kh-ink); } /* already on the accent: the band is the tone's own */\n.kh-block[data-kh-tone='default']:has(> section:not([data-kh-flush-end], [data-kh-own-band])) + .kh-block[data-kh-tone='default'] > section:not([data-kh-own-band]),\ndiv:has(> .kh-block[data-kh-tone='default'] > section:not([data-kh-flush-end], [data-kh-own-band])) + div:has(> .kh-block[data-kh-tone='default']) > .kh-block > section:not([data-kh-own-band]) { padding-top: 0; }\n.kh-block[data-kh-tone='muted']:has(> section:not([data-kh-flush-end], [data-kh-own-band])) + .kh-block[data-kh-tone='muted'] > section:not([data-kh-own-band]),\ndiv:has(> .kh-block[data-kh-tone='muted'] > section:not([data-kh-flush-end], [data-kh-own-band])) + div:has(> .kh-block[data-kh-tone='muted']) > .kh-block > section:not([data-kh-own-band]) { padding-top: 0; }\n.kh-block[data-kh-tone='inverse']:has(> section:not([data-kh-flush-end], [data-kh-own-band])) + .kh-block[data-kh-tone='inverse'] > section:not([data-kh-own-band]),\ndiv:has(> .kh-block[data-kh-tone='inverse'] > section:not([data-kh-flush-end], [data-kh-own-band])) + div:has(> .kh-block[data-kh-tone='inverse']) > .kh-block > section:not([data-kh-own-band]) { padding-top: 0; }\n.kh-block[data-kh-tone='accent']:has(> section:not([data-kh-flush-end], [data-kh-own-band])) + .kh-block[data-kh-tone='accent'] > section:not([data-kh-own-band]),\ndiv:has(> .kh-block[data-kh-tone='accent'] > section:not([data-kh-flush-end], [data-kh-own-band])) + div:has(> .kh-block[data-kh-tone='accent']) > .kh-block > section:not([data-kh-own-band]) { padding-top: 0; }\n.kh-block :where(h1, h2, h3, h4) { font-family: var(--kh-font-display); text-wrap-style: balance; }\n/* A Style's heading case reaches app screens too, not only blocks (chatadmin 10:59). Zero specificity and 'none' unless the Style\n   sets it, so no app's headings change by default; the font stays block-only so apps keep choosing their own. */\n:where(.kh-root, [data-kh-theme]) :where(h1, h2, h3, h4) { text-transform: var(--kh-heading-case, none); }\n.kh-block :where(p) { text-wrap-style: pretty; }\n.kh-block ::selection { background: color-mix(in oklab, var(--kh-accent) 28%, transparent); }\n\n/* ---------- Media: image, or a themed placeholder ---------- */\n/* In @layer components so utility classes passed to <Media className> (rounded-*, border-*) win. */\n@layer components {\n  .kh-media {\n    position: relative;\n    overflow: hidden;\n    width: 100%;\n    background: var(--kh-surface-2);\n    border-radius: inherit;\n  }\n  /* aspect ratios by attribute, so SSR output carries no inline style (CSP style-src 'self'); 16/10 is the fallback */\n  .kh-media { aspect-ratio: 16 / 10; }\n  .kh-media[data-kh-ratio='16/9'] { aspect-ratio: 16 / 9; }\n  .kh-media[data-kh-ratio='16/8'] { aspect-ratio: 16 / 8; }\n  .kh-media[data-kh-ratio='16/7'] { aspect-ratio: 16 / 7; }\n  .kh-media[data-kh-ratio='16/6'] { aspect-ratio: 16 / 6; }\n  .kh-media[data-kh-ratio='16/10'] { aspect-ratio: 16 / 10; }\n  .kh-media[data-kh-ratio='21/9'] { aspect-ratio: 21 / 9; }\n  .kh-media[data-kh-ratio='4/5'] { aspect-ratio: 4 / 5; }\n  .kh-media[data-kh-ratio='5/4'] { aspect-ratio: 5 / 4; }\n  .kh-media[data-kh-ratio='4/3'] { aspect-ratio: 4 / 3; }\n  .kh-media[data-kh-ratio='3/4'] { aspect-ratio: 3 / 4; }\n  .kh-media[data-kh-ratio='9/16'] { aspect-ratio: 9 / 16; }\n  .kh-media[data-kh-ratio='3/1'] { aspect-ratio: 3 / 1; }\n  .kh-media[data-kh-ratio='2/1'] { aspect-ratio: 2 / 1; }\n  .kh-media[data-kh-ratio='1/1'] { aspect-ratio: 1 / 1; }\n  /* ratio 'auto': the box takes the picture's own shape and nothing is cropped (a figure in a report) */\n  .kh-media[data-kh-ratio='auto'] { aspect-ratio: auto; }\n  .kh-media[data-kh-ratio='auto'] > img { position: static; height: auto; object-fit: contain; }\n  .kh-media[data-kh-ratio='auto'][data-kh-media='placeholder'] { aspect-ratio: 16 / 10; }\n  .kh-media > picture { display: contents; }\n  .kh-media > img, .kh-media > picture > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }\n  /* A picture with a dark twin (Media srcDark): the theme's mode attribute shows one and hides the other. */\n  .kh-media > img[data-kh-dark], .kh-media > picture[data-kh-dark] { display: none; }\n  [data-kh-mode='dark'] .kh-media[data-kh-media-dark] > img[data-kh-light], [data-kh-mode='dark'] .kh-media[data-kh-media-dark] > picture[data-kh-light] { display: none; }\n  [data-kh-mode='dark'] .kh-media[data-kh-media-dark] > img[data-kh-dark] { display: block; }\n  [data-kh-mode='dark'] .kh-media[data-kh-media-dark] > picture[data-kh-dark] { display: contents; }\n  .kh-media[data-kh-media='placeholder'] {\n    background:\n      radial-gradient(120% 90% at 0% 0%, color-mix(in oklab, var(--kh-accent) 17%, transparent), transparent 62%),\n      radial-gradient(90% 80% at 100% 100%, color-mix(in oklab, var(--kh-accent) 9%, transparent), transparent 58%),\n      var(--kh-surface-2);\n  }\n  .kh-media[data-kh-media='placeholder']::after {\n    content: '';\n    position: absolute;\n    inset: 0;\n    background-image:\n      linear-gradient(to right, color-mix(in oklab, var(--kh-ink) 5%, transparent) 1px, transparent 1px),\n      linear-gradient(to bottom, color-mix(in oklab, var(--kh-ink) 5%, transparent) 1px, transparent 1px);\n    background-size: 2.5rem 2.5rem;\n    mask-image: radial-gradient(80% 80% at 50% 50%, #000 30%, transparent 100%);\n  }\n\n  /* ---------- Wireframe: the same layout, honestly grey ---------- */\n  [data-kh-theme='wireframe'] .kh-media,\n  [data-kh-theme='wireframe'] .kh-media[data-kh-media] {\n    background:\n      linear-gradient(to top right, transparent calc(50% - 0.5px), var(--kh-line-strong) calc(50% - 0.5px), var(--kh-line-strong) calc(50% + 0.5px), transparent calc(50% + 0.5px)),\n      linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--kh-line-strong) calc(50% - 0.5px), var(--kh-line-strong) calc(50% + 0.5px), transparent calc(50% + 0.5px)),\n      var(--kh-surface-3);\n    border: 1px solid var(--kh-line-strong);\n  }\n  [data-kh-theme='wireframe'] .kh-media > img,\n  [data-kh-theme='wireframe'] .kh-media::after { display: none; }\n}\n\n[data-kh-theme='wireframe'] *,\n[data-kh-theme='wireframe'] *::before,\n[data-kh-theme='wireframe'] *::after {\n  box-shadow: none !important;\n  transition: none !important;\n  animation: none !important;\n  text-shadow: none !important;\n}\n[data-kh-theme='wireframe'] .kh-block *:not(.kh-media) { background-image: none !important; }\n[data-kh-theme='wireframe'] .kh-block :where(h1, h2, h3, h4) { font-weight: 600; }\n\n@media (prefers-reduced-motion: reduce) {\n  .kh-root *, .kh-root *::before, .kh-root *::after { transition-duration: 0s !important; animation: none !important; }\n}\n\n/* Where text wraps (Felix's red flags, 2026-10-10): headings balance their lines and paragraphs avoid a one-word last line.\n   Zero specificity and scoped to the library, so a block or a host app can still override it. The longhand text-wrap-style: the\n   text-wrap shorthand also set the wrap mode, so a heading with Tailwind's truncate wrapped again (Klar Portal 10-23). */\n:where(.kh-root, [data-kh-theme]) :where(h1, h2, h3, h4) { text-wrap-style: balance; }\n:where(.kh-root, [data-kh-theme]) :where(p, li, blockquote) { text-wrap-style: pretty; }\n\n/* Google's mark on \"Continue with Google\" (app-auth-signin): its brand colours, the same in both modes, as Google asks. */\n.kh-google-g path:nth-child(1) { fill: #ea4335; }\n.kh-google-g path:nth-child(2) { fill: #4285f4; }\n.kh-google-g path:nth-child(3) { fill: #fbbc05; }\n.kh-google-g path:nth-child(4) { fill: #34a853; }\n/* Microsoft's mark on \"Continue with Microsoft\" (app-auth-signin): its four colours, the same in both modes, as Microsoft asks. */\n.kh-microsoft-mark rect:nth-child(1) { fill: #f25022; }\n.kh-microsoft-mark rect:nth-child(2) { fill: #7fba00; }\n.kh-microsoft-mark rect:nth-child(3) { fill: #00a4ef; }\n.kh-microsoft-mark rect:nth-child(4) { fill: #ffb900; }\n\n/* KlarhimmelMark: the brand navy on light, the ink on dark (the navy would vanish on the dark canvas). */\n.kh-klarhimmel-mark { color: #0b1a2c; }\n[data-kh-mode='dark'] .kh-klarhimmel-mark { color: var(--kh-ink); }\n\n/* IconCircle tone=\"brand\": Klarhimmel's blue (klarhimmelStyle accent) under any theme, so an organisation's dark accent cannot grey it. */\n.kh-icon-circle { background: #1c6ee0; color: #ffffff; }\n[data-kh-mode='dark'] .kh-icon-circle { background: #5b9bf5; color: #0b1a2c; }\n"
    },
    {
      "path": "src/theme/font-fallbacks.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/font-fallbacks.css",
      "content": "/* GENERATED by scripts/font-fallbacks.mjs. Metric-matched fallback faces: while a web font loads, text sets in a local system\n   font scaled to the web font's width (measured on English UI copy) and line box, so the swap does not move the layout (CLS).\n   Two faces per family, regular and bold, since bold system fonts run wider; fontStack() in style.ts names them second in every stack. */\n@font-face {\n  font-family: 'Geist Variable Fallback';\n  src: local('Arial'), local('ArialMT');\n  font-weight: 100 549;\n  size-adjust: 102.23%;\n  ascent-override: 98.30%;\n  descent-override: 28.86%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Geist Variable Fallback';\n  src: local('Arial Bold'), local('Arial-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 100.51%;\n  ascent-override: 99.99%;\n  descent-override: 29.35%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Geist Mono Variable Fallback';\n  src: local('Courier New'), local('CourierNewPSMT');\n  font-weight: 100 549;\n  size-adjust: 99.98%;\n  ascent-override: 100.52%;\n  descent-override: 29.50%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Geist Mono Variable Fallback';\n  src: local('Courier New Bold'), local('CourierNewPS-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 99.98%;\n  ascent-override: 100.52%;\n  descent-override: 29.51%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Inter Variable Fallback';\n  src: local('Arial'), local('ArialMT');\n  font-weight: 100 549;\n  size-adjust: 106.32%;\n  ascent-override: 91.12%;\n  descent-override: 22.69%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Inter Variable Fallback';\n  src: local('Arial Bold'), local('Arial-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 101.45%;\n  ascent-override: 95.49%;\n  descent-override: 23.78%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Space Grotesk Variable Fallback';\n  src: local('Arial'), local('ArialMT');\n  font-weight: 100 549;\n  size-adjust: 108.51%;\n  ascent-override: 90.68%;\n  descent-override: 26.91%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Space Grotesk Variable Fallback';\n  src: local('Arial Bold'), local('Arial-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 101.24%;\n  ascent-override: 97.19%;\n  descent-override: 28.84%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'DM Sans Variable Fallback';\n  src: local('Arial'), local('ArialMT');\n  font-weight: 100 549;\n  size-adjust: 103.26%;\n  ascent-override: 96.07%;\n  descent-override: 30.02%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'DM Sans Variable Fallback';\n  src: local('Arial Bold'), local('Arial-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 100.75%;\n  ascent-override: 98.46%;\n  descent-override: 30.77%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Fraunces Variable Fallback';\n  src: local('Times New Roman'), local('TimesNewRomanPSMT');\n  font-weight: 100 549;\n  size-adjust: 115.22%;\n  ascent-override: 84.88%;\n  descent-override: 22.13%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Fraunces Variable Fallback';\n  src: local('Times New Roman Bold'), local('TimesNewRomanPS-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 114.12%;\n  ascent-override: 85.70%;\n  descent-override: 22.34%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'JetBrains Mono Variable Fallback';\n  src: local('Courier New'), local('CourierNewPSMT');\n  font-weight: 100 549;\n  size-adjust: 99.98%;\n  ascent-override: 102.02%;\n  descent-override: 30.00%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'JetBrains Mono Variable Fallback';\n  src: local('Courier New Bold'), local('CourierNewPS-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 99.98%;\n  ascent-override: 102.02%;\n  descent-override: 30.01%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Instrument Serif Fallback';\n  src: local('Times New Roman'), local('TimesNewRomanPSMT');\n  font-weight: 100 549;\n  size-adjust: 83.03%;\n  ascent-override: 119.24%;\n  descent-override: 37.34%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Instrument Serif Fallback';\n  src: local('Times New Roman Bold'), local('TimesNewRomanPS-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 78.48%;\n  ascent-override: 126.15%;\n  descent-override: 39.50%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Oswald Variable Fallback';\n  src: local('Arial'), local('ArialMT');\n  font-weight: 100 549;\n  size-adjust: 80.46%;\n  ascent-override: 148.28%;\n  descent-override: 35.92%;\n  line-gap-override: 0.00%;\n}\n@font-face {\n  font-family: 'Oswald Variable Fallback';\n  src: local('Arial Bold'), local('Arial-BoldMT');\n  font-weight: 550 900;\n  size-adjust: 83.53%;\n  ascent-override: 142.83%;\n  descent-override: 34.60%;\n  line-gap-override: 0.00%;\n}\n"
    },
    {
      "path": "src/theme/fonts.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts.css",
      "content": "/* Every family the Style `FontFamily` enum offers. Faces load on demand (unicode-range), so unused families cost nothing in the browser,\n   but every file lands in the build. To ship only some, import `fonts/<family>.css` yourself and use `theme-core.css` instead of `theme.css`. */\n@import './fonts/geist.css';\n@import './fonts/geist-mono.css';\n@import './fonts/inter.css';\n@import './fonts/space-grotesk.css';\n@import './fonts/dm-sans.css';\n@import './fonts/fraunces.css';\n@import './fonts/jetbrains-mono.css';\n@import './fonts/instrument-serif.css';\n@import './fonts/oswald.css';\n"
    },
    {
      "path": "src/theme/fonts/dm-sans.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/dm-sans.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only dm-sans. */\n@import '@fontsource-variable/dm-sans/index.css';\n"
    },
    {
      "path": "src/theme/fonts/fraunces.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/fraunces.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only fraunces. */\n@import '@fontsource-variable/fraunces/index.css';\n"
    },
    {
      "path": "src/theme/fonts/geist-mono.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/geist-mono.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only geist-mono. */\n@import '@fontsource-variable/geist-mono/index.css';\n"
    },
    {
      "path": "src/theme/fonts/geist.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/geist.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only geist. */\n@import '@fontsource-variable/geist/index.css';\n"
    },
    {
      "path": "src/theme/fonts/instrument-serif.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/instrument-serif.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only instrument-serif. */\n@import '@fontsource/instrument-serif/index.css';\n"
    },
    {
      "path": "src/theme/fonts/inter.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/inter.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only inter. */\n@import '@fontsource-variable/inter/index.css';\n"
    },
    {
      "path": "src/theme/fonts/jetbrains-mono.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/jetbrains-mono.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only jetbrains-mono. */\n@import '@fontsource-variable/jetbrains-mono/index.css';\n"
    },
    {
      "path": "src/theme/fonts/oswald.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/oswald.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only oswald. */\n@import '@fontsource-variable/oswald/index.css';\n"
    },
    {
      "path": "src/theme/fonts/space-grotesk.css",
      "type": "registry:file",
      "target": "components/klarhimmel/theme/fonts/space-grotesk.css",
      "content": "/* One family, on demand: import this instead of fonts.css to ship only space-grotesk. */\n@import '@fontsource-variable/space-grotesk/index.css';\n"
    }
  ]
}
