Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

49.9 KB
Raw Blame
export const DEFAULT_THEME_ID = 'kestrel-neon';

const baseStatusColors = {
  '--port-success': '34 197 94',
  '--port-warning': '245 158 11',
  '--port-error': '239 68 68',
  // `on-*` tokens are for text inside filled controls. The `*-text` tokens are
  // for semantic text on page/card surfaces; the two contexts need different
  // colors in several day themes.
  '--port-on-success': '5 46 22',
  '--port-on-warning': '17 24 39',
  '--port-on-error': '48 8 8',
  '--port-success-text': '134 239 172',
  '--port-warning-text': '252 211 77',
  '--port-error-text': '253 164 175',
  '--port-accent-text': '96 165 250',
  '--port-text-subtle': '140 140 149',
};

// Secondary accent — a semantic home for the "purple/violet" highlight used
// throughout the app for AI-generated / recommendation / secondary-emphasis
// content (issue #1909). Every theme defines its own value tuned to its
// palette (see each theme's `colors` block below); this default only covers
// any future theme that forgets to set one explicitly.
const DEFAULT_ACCENT2 = {
  '--port-accent-2': '168 85 247',
  '--port-on-accent-2': '37 7 56',
  '--port-accent-2-text': '216 180 254',
};

// Full-screen effects a theme composes by listing them in `effects`; each is
// a shared block in index.css ("Theme effects layer") tuned by --port-fx-*
// tokens. Catalogue and tokens: docs/themes/README.md, "Effects".
export const THEME_EFFECTS = Object.freeze(['scanlines', 'vignette', 'sweep', 'grid-floor', 'glitch', 'aurora', 'grain']);

const baseMotionTokens = {
  '--port-motion-fast': '120ms',
  '--port-motion-medium': '220ms',
  '--port-motion-slow': '420ms',
};

const classicShapeTokens = {
  '--port-radius-sm': '0.25rem',
  '--port-radius-md': '0.375rem',
  '--port-radius-lg': '0.5rem',
  '--port-radius-xl': '0.75rem',
  '--port-radius-pill': '9999px',
};

// Kestrel Neon / Kestrel Dawn share their shell: monospaced everywhere, square
// corners, uppercase tracked titles. The day entry differs only in color,
// shadow, and effect tuning.
const kestrelShellTokens = {
  '--port-motion-fast': '90ms',
  '--port-motion-medium': '160ms',
  '--port-motion-slow': '300ms',
  '--port-radius-sm': '0',
  '--port-radius-md': '0.125rem',
  '--port-radius-lg': '0.25rem',
  '--port-radius-xl': '0.375rem',
  '--port-radius-pill': '0.25rem',
  '--port-bg-alpha': '1',
  '--port-border-alpha': '0.3',
  '--port-sidebar-alpha': '0.96',
  '--port-panel-padding-scale': '0.92',
  '--port-font-ui': "'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace",
  '--port-font-display': "'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace",
  '--port-font-mono': "'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace",
  '--port-heading-tracking': '0.06em',
  '--port-title-tracking': '0.14em',
  '--port-title-transform': 'uppercase',
  '--port-border-style': 'solid',
  '--port-body-size': 'cover, cover',
  '--port-body-overlay-opacity': '1',
  '--port-app-backdrop': 'transparent',
  '--port-control-border': 'rgb(var(--port-border) / 0.3)',
  // Card border channel + top wash + nav-active rule are identical night vs.
  // dawn (#6248) — only the border ALPHA differs, set per-theme below.
  '--port-card-border-color': 'var(--port-accent-2)',
  '--port-card-surface-image': 'linear-gradient(180deg, rgb(var(--port-accent) / 0.06), transparent 32px)',
  '--port-nav-active-rule': '2px solid rgb(var(--port-accent-2))',
  '--port-fx-scanline-period': '3px',
  '--port-fx-overlay-blend': 'multiply',
};

export const THEMES = {
  'classic-midnight': {
    id: 'classic-midnight',
    label: 'Classic Midnight',
    shortLabel: 'Classic',
    concept: 'The existing PortOS interface, kept as the stable baseline.',
    family: 'classic',
    mode: 'night',
    accent: '#2563eb',
    doc: '/docs/themes/classic-midnight.md',
    colorScheme: 'dark',
    density: 'comfortable',
    swatches: ['#0f0f0f', '#1e1e1e', '#2563eb', '#22c55e'],
    colors: {
      '--port-bg': '15 15 15',
      '--port-card': '30 30 30',
      '--port-border': '42 42 42',
      '--port-accent': '37 99 235',
      '--port-text': '212 212 216',
      '--port-text-muted': '161 161 170',
      '--port-text-subtle': '140 140 149',
      '--port-accent-text': '96 165 250',
      '--port-control-text': '212 212 216',
      '--port-focus-ring': '37 99 235',
      '--port-on-accent': '255 255 255',
      ...baseStatusColors,
      ...DEFAULT_ACCENT2,
    },
    tokens: {
      ...classicShapeTokens,
      ...baseMotionTokens,
      '--port-bg-alpha': '1',
      '--port-card-alpha': '1',
      '--port-card-min-alpha': '1',
      '--port-border-alpha': '1',
      '--port-sidebar-alpha': '1',
      '--port-overlay-alpha': '0.72',
      '--port-panel-padding-scale': '1',
      '--port-font-ui': "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      // Baseline stays neutral graphite + blue; what changed is material, not
      // identity — a hairline top sheen and a real cast shadow so a card reads
      // as raised rather than as a same-color rectangle with a border.
      '--port-heading-tracking': '-0.011em',
      '--port-card-surface-image': 'linear-gradient(180deg, rgb(255 255 255 / 0.03), transparent 72px)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-shadow-card': 'inset 0 1px 0 rgb(255 255 255 / 0.04), 0 10px 28px -18px rgb(0 0 0 / 0.9)',
      '--port-shadow-elevated': 'inset 0 1px 0 rgb(255 255 255 / 0.05), 0 18px 45px rgb(0 0 0 / 0.35)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.35)',
      '--port-backdrop-filter': 'none',
      '--port-border-style': 'solid',
      // Deep-to-near-black fall with a faint accent haze off the top edge, read
      // through a slightly translucent app backdrop.
      '--port-body-gradient': 'linear-gradient(180deg, rgb(24 25 30) 0%, rgb(15 15 15) 55%, rgb(10 10 12) 100%)',
      '--port-body-texture': 'radial-gradient(ellipse 90% 46% at 50% -8%, rgb(var(--port-accent) / 0.1) 0%, transparent 70%)',
      '--port-body-size': 'cover, cover',
      '--port-body-overlay-opacity': '1',
      '--port-app-backdrop': 'rgb(var(--port-bg) / 0.88)',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(32 32 34), rgb(26 26 28))',
      '--port-input-bg': 'rgb(var(--port-bg))',
      '--port-control-bg': 'rgb(var(--port-border))',
      '--port-control-bg-hover': 'rgb(64 64 64)',
      '--port-control-border': 'rgb(var(--port-border))',
      '--port-active-bg': 'rgb(var(--port-accent) / 0.1)',
      '--port-hover-bg': 'rgb(var(--port-border) / 0.5)',
      '--port-terminal-bg': 'rgb(7 7 7)',
      '--port-terminal-text': 'rgb(212 212 216)',
      '--port-chart-1': '37 99 235',
      '--port-chart-2': '34 197 94',
      '--port-chart-3': '245 158 11',
      '--port-chart-4': '236 72 153',
      '--port-chart-grid': '64 64 64',
    },
  },

  'classic-noon': {
    id: 'classic-noon',
    label: 'Classic Noon',
    shortLabel: 'Classic',
    concept: 'Classic Midnight reflected to a clean white workspace — same blue accent, daylight legibility.',
    family: 'classic',
    mode: 'day',
    accent: '#2563eb',
    doc: '/docs/themes/classic-midnight.md',
    colorScheme: 'light',
    density: 'comfortable',
    swatches: ['#f0f0f0', '#ffffff', '#2563eb', '#166534'],
    colors: {
      '--port-bg': '240 240 240',
      '--port-card': '255 255 255',
      '--port-border': '212 212 216',
      '--port-accent': '37 99 235',
      '--port-text': '39 39 42',
      '--port-text-muted': '82 82 91',
      '--port-control-text': '38 38 38',
      '--port-focus-ring': '37 99 235',
      '--port-on-accent': '255 255 255',
      ...baseStatusColors,
      // Keep tertiary labels and semantic foregrounds readable on the light
      // page instead of inheriting the brighter night-theme defaults.
      '--port-text-subtle': '90 90 100',
      '--port-accent-text': '26 70 193',
      '--port-success': '22 101 52',
      '--port-success-text': '19 88 45',
      '--port-on-success': '255 255 255',
      // Darken warning to amber-700 (+ white on-warning) like the other day themes —
      // the base bright amber (#f59e0b) washes out as foreground on the light bg,
      // most visibly as ANSI yellow in the shell terminal, which tracks --port-warning.
      '--port-warning': '161 98 7',
      '--port-warning-text': '120 69 13',
      '--port-on-warning': '255 255 255',
      '--port-error': '185 28 28',
      '--port-error-text': '146 22 22',
      '--port-on-error': '255 255 255',
      // violet-700 — darkened from the night theme's violet-500 for AA contrast
      // on the white card background.
      '--port-accent-2': '109 40 217',
      '--port-on-accent-2': '255 255 255',
      '--port-accent-2-text': '95 34 191',
    },
    tokens: {
      ...classicShapeTokens,
      ...baseMotionTokens,
      '--port-bg-alpha': '1',
      '--port-card-alpha': '1',
      '--port-card-min-alpha': '1',
      '--port-border-alpha': '1',
      '--port-sidebar-alpha': '1',
      '--port-overlay-alpha': '0.72',
      '--port-panel-padding-scale': '1',
      '--port-font-ui': "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-heading-tracking': '-0.011em',
      '--port-card-surface-image': 'linear-gradient(180deg, rgb(var(--port-accent) / 0.028), transparent 72px)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-shadow-card': 'inset 0 1px 0 rgb(255 255 255 / 0.9), 0 1px 2px rgb(15 23 42 / 0.05), 0 6px 16px -10px rgb(15 23 42 / 0.16)',
      '--port-shadow-elevated': 'inset 0 1px 0 rgb(255 255 255 / 0.9), 0 14px 40px -12px rgb(15 23 42 / 0.18), 0 4px 10px -2px rgb(15 23 42 / 0.08)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.4)',
      '--port-backdrop-filter': 'none',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'linear-gradient(180deg, rgb(252 252 253) 0%, rgb(240 240 240) 52%, rgb(232 232 235) 100%)',
      '--port-body-texture': 'radial-gradient(ellipse 90% 44% at 50% -8%, rgb(var(--port-accent) / 0.07) 0%, transparent 70%)',
      '--port-body-size': 'cover, cover',
      '--port-body-overlay-opacity': '1',
      '--port-app-backdrop': 'rgb(var(--port-bg) / 0.86)',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(255 255 255), rgb(249 249 250))',
      '--port-input-bg': 'rgb(255 255 255)',
      '--port-control-bg': 'rgb(244 244 245)',
      '--port-control-bg-hover': 'rgb(228 228 231)',
      '--port-control-border': 'rgb(var(--port-border))',
      '--port-active-bg': 'rgb(var(--port-accent) / 0.1)',
      '--port-hover-bg': 'rgb(0 0 0 / 0.04)',
      '--port-terminal-bg': 'rgb(247 247 248)',
      '--port-terminal-text': 'rgb(39 39 42)',
      '--port-chart-1': '37 99 235',
      '--port-chart-2': '22 163 74',
      '--port-chart-3': '202 138 4',
      '--port-chart-4': '219 39 119',
      '--port-chart-grid': '212 212 216',
    },
  },

  'lumen-glass': {
    id: 'lumen-glass',
    label: 'Lumen Glass',
    shortLabel: 'Glass',
    concept: 'A translucent local-first command deck with layered glass panes and soft luminous depth.',
    family: 'glass',
    mode: 'night',
    accent: '#67e8f9',
    doc: '/docs/themes/lumen-glass.md',
    colorScheme: 'dark',
    density: 'spacious',
    // The night pane finally gets the ambient depth its day partner always had
    // (which drifts on its own body::before/::after): two slow blooms behind
    // the glass, plus edge falloff so the stack reads as lit from the middle.
    effects: ['aurora', 'vignette'],
    swatches: ['#071016', '#1c2e37', '#67e8f9', '#fb7185'],
    colors: {
      '--port-bg': '7 16 22',
      '--port-card': '28 46 55',
      '--port-border': '129 229 255',
      '--port-accent': '103 232 249',
      '--port-success': '74 222 128',
      '--port-success-text': '134 239 172',
      '--port-warning': '251 191 36',
      '--port-warning-text': '252 211 77',
      '--port-error': '251 113 133',
      '--port-error-text': '253 164 175',
      '--port-on-accent': '4 35 44',
      '--port-on-success': '6 43 24',
      '--port-on-warning': '55 37 5',
      '--port-on-error': '69 10 24',
      // violet-400 — a glass-panel-friendly secondary highlight distinct from
      // the cyan accent and rose error.
      '--port-accent-2': '192 132 252',
      '--port-on-accent-2': '37 7 56',
      '--port-accent-2-text': '216 180 254',
      '--port-text': '213 232 237',
      '--port-text-muted': '154 182 192',
      '--port-text-subtle': '127 154 165',
      '--port-accent-text': '113 233 249',
      '--port-control-text': '220 247 252',
      '--port-focus-ring': '103 232 249',
    },
    tokens: {
      ...baseMotionTokens,
      '--port-radius-sm': '0.5rem',
      '--port-radius-md': '0.75rem',
      '--port-radius-lg': '1rem',
      '--port-radius-xl': '1.25rem',
      '--port-radius-pill': '9999px',
      '--port-bg-alpha': '0.92',
      '--port-card-alpha': '0.58',
      '--port-card-min-alpha': '0.5',
      '--port-border-alpha': '0.24',
      '--port-sidebar-alpha': '0.72',
      '--port-overlay-alpha': '0.68',
      '--port-panel-padding-scale': '1.08',
      '--port-font-ui': "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-card-border-alpha': '0.28',
      '--port-heading-tracking': '-0.015em',
      // A pane of glass catches the light along its top-left edge; the wash is
      // what separates a glass panel from a flat translucent rectangle.
      '--port-card-surface-image': 'linear-gradient(155deg, rgb(255 255 255 / 0.075), rgb(255 255 255 / 0.012) 42%, transparent 70%)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent) / 0.85)',
      '--port-nav-active-glow': '0 0 14px rgb(var(--port-accent) / 0.4)',
      '--port-focus-glow': '0 0 0 4px rgb(var(--port-focus-ring) / 0.18), 0 0 36px rgb(var(--port-focus-ring) / 0.12)',
      '--port-shadow-card': '0 22px 55px rgb(0 0 0 / 0.28), inset 0 1px 0 rgb(255 255 255 / 0.08)',
      '--port-shadow-elevated': '0 28px 80px rgb(0 0 0 / 0.42), inset 0 1px 0 rgb(255 255 255 / 0.12)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.18), 0 0 28px rgb(var(--port-accent) / 0.12)',
      '--port-backdrop-filter': 'blur(22px) saturate(1.35)',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'linear-gradient(135deg, rgb(6 12 18) 0%, rgb(9 31 38) 45%, rgb(29 17 34) 100%)',
      '--port-body-texture': 'linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px), linear-gradient(180deg, rgb(255 255 255 / 0.018) 1px, transparent 1px)',
      '--port-body-size': '28px 28px, 28px 28px, cover',
      '--port-body-overlay-opacity': '0.72',
      // Thinned from 0.82 so the aurora behind it actually reaches the page —
      // a translucent command deck whose shell is nearly opaque isn't one.
      '--port-app-backdrop': 'linear-gradient(135deg, rgb(var(--port-bg) / 0.6), rgb(9 28 36 / 0.62))',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(12 24 31 / 0.82), rgb(13 20 29 / 0.72))',
      '--port-input-bg': 'rgb(8 18 24 / 0.72)',
      '--port-control-bg': 'rgb(21 42 52 / 0.82)',
      '--port-control-bg-hover': 'rgb(31 62 75 / 0.9)',
      '--port-control-border': 'rgb(var(--port-border) / 0.3)',
      '--port-active-bg': 'linear-gradient(135deg, rgb(var(--port-accent) / 0.18), rgb(251 113 133 / 0.12))',
      '--port-hover-bg': 'rgb(255 255 255 / 0.08)',
      '--port-terminal-bg': 'rgb(5 12 16 / 0.86)',
      '--port-terminal-text': 'rgb(213 232 237)',
      '--port-chart-1': '103 232 249',
      '--port-chart-2': '74 222 128',
      '--port-chart-3': '251 191 36',
      '--port-chart-4': '251 113 133',
      '--port-chart-grid': '129 229 255',
      '--port-fx-aurora-a': 'rgb(var(--port-accent) / 0.45)',
      '--port-fx-aurora-b': 'rgb(var(--port-accent-2) / 0.38)',
      '--port-fx-aurora-opacity': '0.7',
      '--port-fx-aurora-blur': '90px',
      '--port-fx-aurora-duration': '44s',
      '--port-fx-vignette-color': 'rgb(0 0 0 / 0.5)',
      '--port-fx-overlay-blend': 'normal',
      '--port-fx-overlay-opacity': '0.55',
    },
  },

  'lumen-glass-day': {
    id: 'lumen-glass-day',
    label: 'Lumen Glass Day',
    shortLabel: 'Glass',
    concept: 'Lumen Glass at noon — cream-and-cyan glass panels floating on a sunlit drifting mesh.',
    family: 'glass',
    mode: 'day',
    accent: '#155e75',
    doc: '/docs/themes/lumen-glass.md',
    colorScheme: 'light',
    density: 'spacious',
    // The drifting mesh stays on this theme's own body pseudo-elements; grain
    // is what turns its white panes from flat fill into frosted glass.
    effects: ['grain'],
    swatches: ['#eae4db', '#ffffff', '#155e75', '#fb7185'],
    colors: {
      '--port-bg': '234 228 219',
      '--port-card': '255 255 255',
      '--port-border': '21 94 117',
      '--port-accent': '21 94 117',
      '--port-success': '22 101 52',
      '--port-success-text': '18 84 43',
      '--port-warning': '161 98 7',
      '--port-warning-text': '115 67 12',
      '--port-error': '225 29 72',
      '--port-error-text': '144 14 46',
      '--port-on-accent': '255 255 255',
      '--port-on-success': '255 255 255',
      '--port-on-warning': '255 255 255',
      '--port-on-error': '255 255 255',
      // violet-700 — darkened for AA contrast on the cream/white glass panels.
      '--port-accent-2': '126 34 206',
      '--port-on-accent-2': '255 255 255',
      '--port-accent-2-text': '99 27 162',
      '--port-text': '25 52 60',
      '--port-text-muted': '78 102 110',
      '--port-text-subtle': '70 92 101',
      '--port-accent-text': '18 80 99',
      '--port-control-text': '36 60 70',
      '--port-focus-ring': '21 94 117',
    },
    tokens: {
      ...baseMotionTokens,
      '--port-radius-sm': '0.5rem',
      '--port-radius-md': '0.75rem',
      '--port-radius-lg': '1rem',
      '--port-radius-xl': '1.25rem',
      '--port-radius-pill': '9999px',
      '--port-bg-alpha': '1',
      '--port-card-alpha': '0.6',
      '--port-card-min-alpha': '0.52',
      '--port-border-alpha': '0.2',
      '--port-sidebar-alpha': '0.72',
      '--port-overlay-alpha': '0.6',
      '--port-panel-padding-scale': '1.08',
      '--port-font-ui': "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-card-border-alpha': '0.22',
      '--port-heading-tracking': '-0.015em',
      '--port-card-surface-image': 'linear-gradient(155deg, rgb(255 255 255 / 0.85), rgb(255 255 255 / 0.2) 40%, transparent 68%)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent) / 0.85)',
      '--port-focus-glow': '0 0 0 3px rgb(var(--port-focus-ring) / 0.22), 0 0 24px rgb(var(--port-focus-ring) / 0.16)',
      '--port-shadow-card': 'inset 0 1px 0 0 rgb(255 255 255 / 0.6), 0 10px 30px -12px rgb(8 80 110 / 0.16), 0 2px 6px -2px rgb(8 80 110 / 0.08)',
      '--port-shadow-elevated': 'inset 0 1px 0 0 rgb(255 255 255 / 0.7), 0 22px 56px -16px rgb(8 80 110 / 0.24), 0 6px 14px -4px rgb(8 80 110 / 0.12)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.3), 0 0 28px rgb(var(--port-accent) / 0.16)',
      '--port-backdrop-filter': 'blur(22px) saturate(1.4)',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'radial-gradient(ellipse at top, rgb(249 233 222) 0%, rgb(245 239 230) 60%), radial-gradient(70vw 70vw at -10vw -20vw, rgb(178 230 238 / 0.7) 0%, transparent 60%), radial-gradient(60vw 60vw at 110vw 115vw, rgb(255 200 210 / 0.55) 0%, transparent 60%)',
      '--port-body-texture': 'linear-gradient(90deg, rgb(8 80 110 / 0.018) 1px, transparent 1px), linear-gradient(180deg, rgb(8 80 110 / 0.014) 1px, transparent 1px)',
      '--port-body-size': '28px 28px, 28px 28px, 100% 100%, 100% 100%, 100% 100%',
      '--port-body-overlay-opacity': '1',
      '--port-app-backdrop': 'transparent',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(255 255 255 / 0.7), rgb(245 250 252 / 0.6))',
      '--port-input-bg': 'rgb(255 255 255 / 0.7)',
      '--port-control-bg': 'rgb(255 255 255 / 0.78)',
      '--port-control-bg-hover': 'rgb(255 255 255 / 0.94)',
      '--port-control-border': 'rgb(8 80 110 / 0.16)',
      '--port-active-bg': 'linear-gradient(135deg, rgb(var(--port-accent) / 0.16), rgb(251 113 133 / 0.1))',
      '--port-hover-bg': 'rgb(8 80 110 / 0.06)',
      '--port-terminal-bg': 'rgb(255 255 255 / 0.85)',
      '--port-terminal-text': 'rgb(36 60 70)',
      '--port-chart-1': '21 94 117',
      '--port-chart-2': '22 163 74',
      '--port-chart-3': '202 138 4',
      '--port-chart-4': '225 29 72',
      '--port-chart-grid': '21 94 117',
      '--port-fx-grain-blend': 'multiply',
      '--port-fx-grain-opacity': '0.035',
    },
  },

  'black-ice-terminal': {
    id: 'black-ice-terminal',
    label: 'Black ICE Terminal',
    shortLabel: 'Terminal',
    concept: 'A dense cyberpunk terminal interface for agents, logs, orchestration, and system control.',
    family: 'terminal',
    mode: 'night',
    accent: '#00f5a0',
    doc: '/docs/themes/black-ice-terminal.md',
    colorScheme: 'dark',
    density: 'compact',
    // A cyberpunk CRT was already scanlined but otherwise inert: the phosphor
    // sweep, the tube's edge falloff, and the title glitch are the rest of the
    // same monitor.
    effects: ['scanlines', 'vignette', 'sweep', 'glitch'],
    swatches: ['#020403', '#151c19', '#00f5a0', '#ff2bd6'],
    colors: {
      '--port-bg': '2 4 3',
      '--port-card': '21 28 25',
      '--port-border': '0 245 160',
      '--port-accent': '0 245 160',
      '--port-success': '45 255 136',
      '--port-success-text': '85 226 137',
      '--port-warning': '255 214 10',
      '--port-warning-text': '236 193 54',
      '--port-error': '255 47 117',
      '--port-error-text': '255 113 145',
      '--port-on-accent': '0 22 14',
      '--port-on-success': '0 28 12',
      '--port-on-warning': '26 20 0',
      '--port-on-error': '48 5 24',
      // Neon violet — distinct from the neon-green accent and magenta chart-2,
      // matching the cyberpunk palette's saturation.
      '--port-accent-2': '178 102 255',
      '--port-on-accent-2': '20 0 38',
      '--port-accent-2-text': '196 138 255',
      '--port-text': '185 222 201',
      '--port-text-muted': '112 166 139',
      '--port-text-subtle': '96 145 119',
      '--port-accent-text': '0 224 147',
      '--port-control-text': '207 255 230',
      '--port-focus-ring': '0 245 160',
    },
    tokens: {
      '--port-motion-fast': '80ms',
      '--port-motion-medium': '140ms',
      '--port-motion-slow': '260ms',
      '--port-radius-sm': '0',
      '--port-radius-md': '0.125rem',
      '--port-radius-lg': '0.1875rem',
      '--port-radius-xl': '0.25rem',
      '--port-radius-pill': '0.25rem',
      '--port-bg-alpha': '1',
      '--port-card-alpha': '0.9',
      '--port-card-min-alpha': '0.8',
      '--port-border-alpha': '0.42',
      '--port-sidebar-alpha': '0.98',
      '--port-overlay-alpha': '0.82',
      '--port-panel-padding-scale': '0.9',
      '--port-font-ui': "'GeistPixelSquare', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-font-display': "'GeistPixelGrid', 'SFMono-Regular', Consolas, monospace",
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      // The shared heading rule sets text-shadow explicitly, so restate the
      // body glow here or headings would lose what they used to inherit.
      '--port-heading-glow': '0 0 12px rgb(var(--port-accent) / 0.08)',
      '--port-heading-tracking': '0.04em',
      '--port-title-tracking': '0.12em',
      '--port-title-transform': 'uppercase',
      '--port-focus-glow': '0 0 0 1px rgb(var(--port-focus-ring) / 0.7), 0 0 20px rgb(var(--port-focus-ring) / 0.3)',
      '--port-nav-active-glow': '0 0 8px rgb(var(--port-accent) / 0.55)',
      '--port-card-border-alpha': '0.34',
      '--port-card-surface-image': 'linear-gradient(180deg, rgb(var(--port-accent) / 0.035), transparent 38px)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-code-glow': '0 0 10px rgb(var(--port-accent) / 0.1)',
      '--port-shadow-card': '0 0 0 1px rgb(var(--port-border) / 0.18), 0 0 26px rgb(var(--port-accent) / 0.08)',
      '--port-shadow-elevated': '0 0 0 1px rgb(var(--port-border) / 0.3), 0 0 48px rgb(var(--port-accent) / 0.16), 0 18px 60px rgb(0 0 0 / 0.62)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.45), 0 0 20px rgb(var(--port-accent) / 0.22)',
      '--port-backdrop-filter': 'none',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'linear-gradient(180deg, rgb(0 0 0) 0%, rgb(2 8 6) 100%)',
      '--port-body-texture': 'linear-gradient(0deg, rgb(0 245 160 / 0.035) 1px, transparent 1px), linear-gradient(90deg, rgb(255 43 214 / 0.025) 1px, transparent 1px)',
      '--port-body-size': '28px 28px, 28px 28px, cover',
      '--port-body-overlay-opacity': '0.9',
      '--port-app-backdrop': 'rgb(var(--port-bg))',
      '--port-sidebar-bg': 'rgb(1 8 5 / 0.98)',
      '--port-input-bg': 'rgb(0 0 0 / 0.72)',
      '--port-control-bg': 'rgb(4 24 16 / 0.96)',
      '--port-control-bg-hover': 'rgb(7 42 28 / 0.98)',
      '--port-control-border': 'rgb(var(--port-border) / 0.42)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.18), rgb(255 43 214 / 0.08))',
      '--port-hover-bg': 'rgb(var(--port-accent) / 0.08)',
      '--port-terminal-bg': 'rgb(0 0 0)',
      '--port-terminal-text': 'rgb(0 194 127)',
      '--port-chart-1': '0 245 160',
      '--port-chart-2': '255 43 214',
      '--port-chart-3': '255 214 10',
      '--port-chart-4': '0 194 255',
      '--port-chart-grid': '0 245 160',
      // `normal` rather than the default `screen`: the overlay carries the
      // vignette too, and screening a black radial is a no-op. Straight alpha
      // compositing still lifts the phosphor line on this near-black page.
      '--port-fx-scanline-color': 'rgb(0 245 160 / 0.055)',
      '--port-fx-scanline-period': '4px',
      '--port-fx-overlay-blend': 'normal',
      '--port-fx-overlay-opacity': '0.75',
      '--port-fx-vignette-color': 'rgb(0 0 0 / 0.62)',
      '--port-fx-sweep-color': 'rgb(var(--port-accent) / 0.05)',
      '--port-fx-sweep-duration': '9s',
      '--port-fx-glitch-period': '14s',
    },
  },

  'black-ice-terminal-day': {
    id: 'black-ice-terminal-day',
    label: 'Phosphor Paper',
    shortLabel: 'Terminal',
    concept: 'Black ICE Terminal printed on cream paper — green ink, pixel grid, line-printer report aesthetic.',
    family: 'terminal',
    mode: 'day',
    accent: '#086c43',
    doc: '/docs/themes/black-ice-terminal.md',
    colorScheme: 'light',
    density: 'compact',
    // Paper tooth moved off --port-body-texture (where a 400-char inline SVG
    // sat behind the app backdrop) and onto the shared grain effect, which
    // blends over the whole page the way real stock does. Vignette is the
    // warm edge fall of a page under a desk lamp.
    effects: ['scanlines', 'vignette', 'grain'],
    swatches: ['#ece6d5', '#fbf6e8', '#086c43', '#b91d6a'],
    colors: {
      '--port-bg': '236 230 213',
      '--port-card': '251 246 232',
      '--port-border': '8 108 67',
      '--port-accent': '8 108 67',
      '--port-success': '22 101 52',
      '--port-success-text': '18 84 43',
      '--port-warning': '133 77 14',
      '--port-warning-text': '111 64 12',
      '--port-error': '185 29 106',
      '--port-error-text': '137 21 78',
      '--port-on-accent': '255 255 255',
      '--port-on-success': '255 255 255',
      '--port-on-warning': '255 255 255',
      '--port-on-error': '255 255 255',
      // Plum ink — readable on cream paper, distinct from the rose error ink.
      '--port-accent-2': '106 27 154',
      '--port-on-accent-2': '255 255 255',
      '--port-accent-2-text': '102 26 148',
      '--port-text': '22 75 50',
      '--port-text-muted': '65 99 76',
      '--port-text-subtle': '76 110 86',
      '--port-accent-text': '6 85 53',
      '--port-control-text': '20 70 46',
      '--port-focus-ring': '8 108 67',
    },
    tokens: {
      '--port-motion-fast': '80ms',
      '--port-motion-medium': '140ms',
      '--port-motion-slow': '260ms',
      '--port-radius-sm': '0',
      '--port-radius-md': '0.125rem',
      '--port-radius-lg': '0.1875rem',
      '--port-radius-xl': '0.25rem',
      '--port-radius-pill': '0.25rem',
      '--port-bg-alpha': '1',
      '--port-card-alpha': '0.94',
      '--port-card-min-alpha': '0.86',
      '--port-border-alpha': '0.38',
      '--port-sidebar-alpha': '0.96',
      '--port-overlay-alpha': '0.7',
      '--port-panel-padding-scale': '0.9',
      '--port-font-ui': "'GeistPixelSquare', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-font-display': "'GeistPixelGrid', 'SFMono-Regular', Consolas, monospace",
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-heading-glow': '0 0 8px rgb(var(--port-accent) / 0.04)',
      '--port-heading-tracking': '0.04em',
      '--port-title-tracking': '0.12em',
      '--port-title-transform': 'uppercase',
      '--port-focus-glow': '0 0 0 2px rgb(var(--port-focus-ring) / 0.45)',
      '--port-card-border-alpha': '0.32',
      '--port-card-surface-image': 'linear-gradient(180deg, rgb(255 255 255 / 0.5), transparent 38px)',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-code-glow': '0 0 6px rgb(var(--port-accent) / 0.06)',
      '--port-shadow-card': '0 0 0 1px rgb(var(--port-border) / 0.18), 0 4px 14px -6px rgb(40 60 30 / 0.18)',
      '--port-shadow-elevated': '0 0 0 1px rgb(var(--port-border) / 0.28), 0 12px 36px -10px rgb(40 60 30 / 0.22)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.5)',
      '--port-backdrop-filter': 'none',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'linear-gradient(180deg, rgb(248 242 226) 0%, rgb(243 237 220) 100%)',
      '--port-body-texture': 'linear-gradient(0deg, rgb(10 122 74 / 0.05) 1px, transparent 1px), linear-gradient(90deg, rgb(185 29 106 / 0.035) 1px, transparent 1px)',
      '--port-body-size': '28px 28px, 28px 28px, cover',
      '--port-body-overlay-opacity': '0.9',
      '--port-app-backdrop': 'transparent',
      '--port-sidebar-bg': 'rgb(248 242 226 / 0.96)',
      '--port-input-bg': 'rgb(255 252 240 / 0.85)',
      '--port-control-bg': 'rgb(248 242 226 / 0.92)',
      '--port-control-bg-hover': 'rgb(238 230 208 / 0.96)',
      '--port-control-border': 'rgb(var(--port-border) / 0.38)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.16), rgb(185 29 106 / 0.08))',
      '--port-hover-bg': 'rgb(var(--port-accent) / 0.08)',
      '--port-terminal-bg': 'rgb(248 242 226)',
      '--port-terminal-text': 'rgb(8 108 67)',
      '--port-chart-1': '8 108 67',
      '--port-chart-2': '185 29 106',
      '--port-chart-3': '170 110 0',
      '--port-chart-4': '8 100 134',
      '--port-chart-grid': '8 108 67',
      '--port-fx-scanline-color': 'rgb(10 60 30 / 0.04)',
      '--port-fx-overlay-blend': 'multiply',
      '--port-fx-overlay-opacity': '0.4',
      '--port-fx-vignette-color': 'rgb(96 78 44 / 0.5)',
      '--port-fx-grain-blend': 'multiply',
      '--port-fx-grain-opacity': '0.06',
      '--port-fx-grain-size': '200px 200px',
    },
  },

  'blueprint-ops': {
    id: 'blueprint-ops',
    label: 'Blueprint Ops',
    shortLabel: 'Blueprint',
    concept: 'A systems-map aesthetic with drafting-grid structure, annotated panels, and calm operational contrast.',
    family: 'blueprint',
    mode: 'night',
    accent: '#60a5fa',
    doc: '/docs/themes/blueprint-ops.md',
    colorScheme: 'dark',
    density: 'compact',
    // A drafting table is lit from above: the sheet falls off toward its edges.
    effects: ['vignette'],
    swatches: ['#0b1020', '#1b2231', '#60a5fa', '#f59e0b'],
    colors: {
      '--port-bg': '11 16 32',
      '--port-card': '27 34 49',
      '--port-border': '148 163 184',
      '--port-accent': '96 165 250',
      '--port-success': '52 211 153',
      '--port-warning': '245 158 11',
      '--port-error': '248 113 113',
      '--port-on-accent': '7 17 32',
      '--port-on-success': '6 36 27',
      '--port-on-warning': '38 24 3',
      '--port-on-error': '52 8 8',
      // Indigo — fits the schematic blueprint palette alongside the blue accent.
      '--port-accent-2': '129 140 248',
      '--port-on-accent-2': '17 19 46',
      '--port-accent-2-text': '168 176 250',
      '--port-success-text': '71 215 162',
      '--port-warning-text': '246 171 44',
      '--port-error-text': '250 148 148',
      '--port-text': '190 207 231',
      '--port-text-muted': '156 178 204',
      '--port-text-subtle': '126 150 179',
      '--port-accent-text': '136 188 251',
      '--port-control-text': '224 236 251',
      '--port-focus-ring': '96 165 250',
    },
    tokens: {
      ...baseMotionTokens,
      '--port-radius-sm': '0.125rem',
      '--port-radius-md': '0.25rem',
      '--port-radius-lg': '0.375rem',
      '--port-radius-xl': '0.5rem',
      '--port-radius-pill': '0.375rem',
      '--port-bg-alpha': '1',
      '--port-card-alpha': '0.86',
      '--port-card-min-alpha': '0.76',
      '--port-border-alpha': '0.28',
      '--port-sidebar-alpha': '0.94',
      '--port-overlay-alpha': '0.78',
      '--port-panel-padding-scale': '0.96',
      '--port-font-ui': "'Avenir Next', Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      // Sheet titles are drafting labels: uppercase, tracked, ruled off by the
      // accent bar the per-theme heading rule already draws.
      '--port-heading-tracking': '0.03em',
      '--port-title-tracking': '0.1em',
      '--port-title-transform': 'uppercase',
      '--port-card-border-color': 'var(--port-accent)',
      '--port-card-border-alpha': '0.2',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-focus-glow': '0 0 0 1px rgb(var(--port-focus-ring) / 0.6), 0 0 0 4px rgb(var(--port-focus-ring) / 0.12)',
      '--port-card-surface-image': 'linear-gradient(90deg, rgb(var(--port-border) / 0.045) 1px, transparent 1px), linear-gradient(180deg, rgb(var(--port-border) / 0.035) 1px, transparent 1px)',
      '--port-card-surface-size': '20px 20px',
      '--port-shadow-card': 'inset 0 1px 0 rgb(var(--port-border) / 0.08), 0 0 0 1px rgb(var(--port-border) / 0.1), 0 12px 28px rgb(0 0 0 / 0.2)',
      '--port-shadow-elevated': 'inset 0 1px 0 rgb(var(--port-border) / 0.1), 0 0 0 1px rgb(var(--port-border) / 0.18), 0 22px 54px rgb(0 0 0 / 0.38)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.35), 0 0 0 4px rgb(var(--port-accent) / 0.08)',
      '--port-backdrop-filter': 'blur(6px)',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'radial-gradient(ellipse 120% 60% at 50% -10%, rgb(22 38 66) 0%, transparent 62%), linear-gradient(180deg, rgb(9 14 28) 0%, rgb(13 22 38) 100%)',
      '--port-body-texture': 'linear-gradient(rgb(148 163 184 / 0.055) 1px, transparent 1px), linear-gradient(90deg, rgb(148 163 184 / 0.045) 1px, transparent 1px), linear-gradient(rgb(96 165 250 / 0.08) 1px, transparent 1px), linear-gradient(90deg, rgb(96 165 250 / 0.065) 1px, transparent 1px)',
      '--port-body-size': '20px 20px, 20px 20px, 100px 100px, 100px 100px, cover, cover',
      '--port-body-overlay-opacity': '0.82',
      '--port-app-backdrop': 'rgb(var(--port-bg) / 0.94)',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(13 20 37 / 0.96), rgb(15 23 42 / 0.92))',
      '--port-input-bg': 'rgb(8 13 26 / 0.82)',
      '--port-control-bg': 'rgb(24 35 56 / 0.92)',
      '--port-control-bg-hover': 'rgb(34 48 76 / 0.96)',
      '--port-control-border': 'rgb(var(--port-border) / 0.34)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.16), rgb(var(--port-warning) / 0.08))',
      '--port-hover-bg': 'rgb(var(--port-border) / 0.1)',
      '--port-terminal-bg': 'rgb(8 13 26)',
      '--port-terminal-text': 'rgb(191 219 254)',
      '--port-chart-1': '96 165 250',
      '--port-chart-2': '52 211 153',
      '--port-chart-3': '245 158 11',
      '--port-chart-4': '248 113 113',
      '--port-chart-grid': '148 163 184',
      '--port-fx-vignette-color': 'rgb(2 6 18 / 0.6)',
      '--port-fx-overlay-blend': 'normal',
      '--port-fx-overlay-opacity': '0.7',
    },
  },

  'blueprint-ops-day': {
    id: 'blueprint-ops-day',
    label: 'Drafting Paper',
    shortLabel: 'Blueprint',
    concept: 'Blueprint Ops on white drafting paper — pale cyan grid, navy accents, amber annotations.',
    family: 'blueprint',
    mode: 'day',
    accent: '#1d4ed8',
    doc: '/docs/themes/blueprint-ops.md',
    colorScheme: 'light',
    density: 'compact',
    // Vellum tooth over the printed grid — the day sheet's counterpart to the
    // night table's edge falloff.
    effects: ['grain'],
    swatches: ['#eaeef2', '#ffffff', '#1d4ed8', '#d97706'],
    colors: {
      '--port-bg': '234 238 242',
      '--port-card': '255 255 255',
      '--port-border': '37 99 235',
      '--port-accent': '29 78 216',
      '--port-success': '22 101 52',
      '--port-success-text': '19 88 45',
      '--port-warning': '161 98 7',
      '--port-warning-text': '120 69 13',
      '--port-error': '185 28 28',
      '--port-on-accent': '255 255 255',
      '--port-on-success': '255 255 255',
      '--port-on-warning': '255 255 255',
      '--port-on-error': '255 255 255',
      // Indigo-700 — darkened for AA contrast on white drafting paper.
      '--port-accent-2': '67 56 202',
      '--port-on-accent-2': '255 255 255',
      '--port-accent-2-text': '61 50 189',
      '--port-error-text': '146 22 22',
      '--port-text': '30 42 68',
      '--port-text-muted': '71 85 105',
      '--port-text-subtle': '84 100 122',
      '--port-accent-text': '24 65 180',
      '--port-control-text': '23 37 84',
      '--port-focus-ring': '29 78 216',
    },
    tokens: {
      ...baseMotionTokens,
      '--port-radius-sm': '0.125rem',
      '--port-radius-md': '0.25rem',
      '--port-radius-lg': '0.375rem',
      '--port-radius-xl': '0.5rem',
      '--port-radius-pill': '0.375rem',
      '--port-bg-alpha': '1',
      '--port-card-alpha': '0.92',
      '--port-card-min-alpha': '0.84',
      '--port-border-alpha': '0.18',
      '--port-sidebar-alpha': '0.94',
      '--port-overlay-alpha': '0.72',
      '--port-panel-padding-scale': '0.96',
      '--port-font-ui': "'Avenir Next', Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
      '--port-font-display': 'var(--port-font-ui)',
      '--port-font-mono': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
      '--port-heading-tracking': '0.03em',
      '--port-title-tracking': '0.1em',
      '--port-title-transform': 'uppercase',
      '--port-card-border-color': 'var(--port-accent)',
      '--port-card-border-alpha': '0.18',
      '--port-nav-active-rule': '2px solid rgb(var(--port-accent))',
      '--port-card-surface-image': 'linear-gradient(90deg, rgb(var(--port-border) / 0.05) 1px, transparent 1px), linear-gradient(180deg, rgb(var(--port-border) / 0.04) 1px, transparent 1px)',
      '--port-card-surface-size': '20px 20px',
      '--port-shadow-card': 'inset 0 1px 0 rgb(255 255 255 / 0.9), 0 0 0 1px rgb(var(--port-border) / 0.14), 0 8px 22px -8px rgb(15 23 42 / 0.12)',
      '--port-shadow-elevated': 'inset 0 1px 0 rgb(255 255 255 / 0.9), 0 0 0 1px rgb(var(--port-border) / 0.22), 0 22px 54px -16px rgb(15 23 42 / 0.22)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.45), 0 0 0 4px rgb(var(--port-accent) / 0.1)',
      '--port-backdrop-filter': 'none',
      '--port-border-style': 'solid',
      '--port-body-gradient': 'radial-gradient(ellipse 120% 55% at 50% -8%, rgb(255 255 255) 0%, transparent 60%), linear-gradient(180deg, rgb(248 250 252) 0%, rgb(238 242 247) 100%)',
      '--port-body-texture': 'linear-gradient(rgb(37 99 235 / 0.07) 1px, transparent 1px), linear-gradient(90deg, rgb(37 99 235 / 0.06) 1px, transparent 1px), linear-gradient(rgb(29 78 216 / 0.1) 1px, transparent 1px), linear-gradient(90deg, rgb(29 78 216 / 0.08) 1px, transparent 1px)',
      '--port-body-size': '20px 20px, 20px 20px, 100px 100px, 100px 100px, cover, cover',
      '--port-body-overlay-opacity': '0.82',
      '--port-app-backdrop': 'rgb(var(--port-bg) / 0.94)',
      '--port-sidebar-bg': 'linear-gradient(180deg, rgb(255 255 255 / 0.94), rgb(248 250 252 / 0.9))',
      '--port-input-bg': 'rgb(255 255 255 / 0.94)',
      '--port-control-bg': 'rgb(255 255 255 / 0.94)',
      '--port-control-bg-hover': 'rgb(241 245 249 / 0.98)',
      '--port-control-border': 'rgb(var(--port-border) / 0.28)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.14), rgb(var(--port-warning) / 0.08))',
      '--port-hover-bg': 'rgb(var(--port-border) / 0.08)',
      '--port-terminal-bg': 'rgb(248 250 252)',
      '--port-terminal-text': 'rgb(23 37 84)',
      '--port-chart-1': '29 78 216',
      '--port-chart-2': '21 128 61',
      '--port-chart-3': '180 83 9',
      '--port-chart-4': '185 28 28',
      '--port-chart-grid': '148 163 184',
      '--port-fx-grain-blend': 'multiply',
      '--port-fx-grain-opacity': '0.045',
      '--port-fx-grain-size': '180px 180px',
    },
  },
  'kestrel-neon': {
    id: 'kestrel-neon',
    label: 'Kestrel Neon',
    shortLabel: 'Kestrel',
    concept: 'A CRT boot terminal at midnight — cyan wireframes and magenta panel labels over a scanlined void with a perspective grid floor.',
    family: 'kestrel',
    mode: 'night',
    accent: '#00f0ff',
    doc: '/docs/themes/kestrel-neon.md',
    colorScheme: 'dark',
    density: 'compact',
    effects: ['scanlines', 'vignette', 'sweep', 'grid-floor', 'glitch'],
    swatches: ['#05060a', '#161a32', '#00f0ff', '#ff2bd6'],
    colors: {
      '--port-bg': '5 6 10',
      '--port-card': '22 26 50',
      '--port-border': '0 240 255',
      '--port-accent': '0 240 255',
      '--port-success': '92 255 138',
      '--port-success-text': '110 240 150',
      '--port-warning': '255 184 48',
      '--port-warning-text': '255 196 90',
      '--port-error': '255 77 109',
      '--port-error-text': '255 128 150',
      '--port-on-accent': '3 24 30',
      '--port-on-success': '0 40 14',
      '--port-on-warning': '40 24 0',
      '--port-on-error': '50 0 12',
      // Hot magenta — the reference terminal's second neon. Distinct from the
      // cyan accent and the rose error.
      '--port-accent-2': '255 43 214',
      '--port-on-accent-2': '48 0 40',
      '--port-accent-2-text': '255 120 226',
      '--port-text': '208 220 244',
      '--port-text-muted': '150 162 196',
      '--port-text-subtle': '126 138 172',
      '--port-accent-text': '0 224 240',
      '--port-control-text': '220 236 255',
      '--port-focus-ring': '0 240 255',
    },
    tokens: {
      ...kestrelShellTokens,
      '--port-card-alpha': '0.92',
      '--port-card-min-alpha': '0.88',
      '--port-overlay-alpha': '0.8',
      '--port-heading-glow': '0 0 12px rgb(var(--port-accent) / 0.5)',
      '--port-focus-glow': '0 0 0 1px rgb(var(--port-focus-ring) / 0.7), 0 0 18px rgb(var(--port-focus-ring) / 0.35)',
      '--port-code-glow': '0 0 8px rgb(var(--port-accent) / 0.25)',
      '--port-nav-active-glow': '0 0 8px rgb(var(--port-accent) / 0.6)',
      '--port-shadow-card': '0 0 0 1px rgb(var(--port-accent-2) / 0.14), 0 0 34px rgb(var(--port-accent-2) / 0.08), inset 0 0 48px rgb(0 0 0 / 0.45)',
      '--port-shadow-elevated': '0 0 0 1px rgb(var(--port-accent) / 0.28), 0 0 44px rgb(var(--port-accent) / 0.14), 0 18px 60px rgb(0 0 0 / 0.7)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.45), 0 0 18px rgb(var(--port-accent) / 0.22)',
      '--port-backdrop-filter': 'blur(6px)',
      '--port-body-gradient': 'radial-gradient(ellipse at 50% 0%, rgb(16 20 42) 0%, rgb(5 6 10) 60%)',
      '--port-body-texture': 'radial-gradient(ellipse at 50% 100%, rgb(var(--port-accent-2) / 0.08) 0%, transparent 55%)',
      '--port-sidebar-bg': 'rgb(10 12 22 / 0.94)',
      '--port-input-bg': 'rgb(3 4 8 / 0.8)',
      '--port-control-bg': 'rgb(14 18 36 / 0.94)',
      '--port-control-bg-hover': 'rgb(22 30 56 / 0.98)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.16), rgb(var(--port-accent-2) / 0.1))',
      '--port-hover-bg': 'rgb(var(--port-accent) / 0.08)',
      '--port-terminal-bg': 'rgb(3 4 8)',
      '--port-terminal-text': 'rgb(208 220 244)',
      '--port-chart-1': '0 240 255',
      '--port-chart-2': '255 43 214',
      '--port-chart-3': '255 184 48',
      '--port-chart-4': '92 255 138',
      '--port-chart-grid': '0 240 255',
      '--port-fx-scanline-color': 'rgb(0 0 0 / 0.18)',
      '--port-fx-overlay-opacity': '0.8',
      '--port-fx-grid-floor-x': 'rgb(var(--port-accent-2) / 0.32)',
      '--port-fx-grid-floor-y': 'rgb(var(--port-accent) / 0.32)',
      '--port-fx-grid-floor-opacity': '0.7',
    },
  },

  'kestrel-neon-day': {
    id: 'kestrel-neon-day',
    label: 'Kestrel Dawn',
    shortLabel: 'Kestrel',
    concept: 'Kestrel Neon at first light — holographic white panels, teal and magenta ink, the CRT grid faded to a watermark.',
    family: 'kestrel',
    mode: 'day',
    accent: '#0e7c8c',
    doc: '/docs/themes/kestrel-neon.md',
    colorScheme: 'light',
    density: 'compact',
    effects: ['scanlines', 'grid-floor'],
    swatches: ['#eaecf6', '#ffffff', '#0e7c8c', '#b5178f'],
    colors: {
      '--port-bg': '234 236 246',
      '--port-card': '255 255 255',
      '--port-border': '14 124 140',
      '--port-accent': '14 124 140',
      '--port-success': '21 128 61',
      '--port-success-text': '19 88 45',
      '--port-warning': '161 98 7',
      '--port-warning-text': '120 69 13',
      '--port-error': '190 18 60',
      '--port-error-text': '136 10 42',
      '--port-on-accent': '255 255 255',
      '--port-on-success': '255 255 255',
      '--port-on-warning': '255 255 255',
      '--port-on-error': '255 255 255',
      // Magenta ink — the night theme's second neon, darkened for AA on white.
      '--port-accent-2': '181 23 143',
      '--port-on-accent-2': '255 255 255',
      '--port-accent-2-text': '134 12 106',
      '--port-text': '32 38 66',
      '--port-text-muted': '76 84 118',
      '--port-text-subtle': '88 96 130',
      '--port-accent-text': '6 78 90',
      '--port-control-text': '32 38 66',
      '--port-focus-ring': '14 124 140',
    },
    tokens: {
      ...kestrelShellTokens,
      '--port-card-alpha': '1',
      '--port-card-min-alpha': '1',
      '--port-overlay-alpha': '0.66',
      '--port-shadow-card': '0 0 0 1px rgb(var(--port-accent-2) / 0.12), 0 8px 24px -10px rgb(14 124 140 / 0.18)',
      '--port-shadow-elevated': '0 0 0 1px rgb(var(--port-accent) / 0.24), 0 22px 54px -16px rgb(14 124 140 / 0.28)',
      '--port-shadow-interactive': '0 0 0 1px rgb(var(--port-accent) / 0.5), 0 0 14px rgb(var(--port-accent) / 0.14)',
      '--port-backdrop-filter': 'none',
      '--port-body-gradient': 'radial-gradient(ellipse at 50% 0%, rgb(255 255 255) 0%, rgb(234 236 246) 60%)',
      '--port-body-texture': 'radial-gradient(ellipse at 50% 100%, rgb(var(--port-accent-2) / 0.07) 0%, transparent 55%)',
      '--port-sidebar-bg': 'rgb(255 255 255 / 0.9)',
      '--port-input-bg': 'rgb(255 255 255 / 0.92)',
      '--port-control-bg': 'rgb(244 246 252 / 0.96)',
      '--port-control-bg-hover': 'rgb(228 232 246 / 0.98)',
      '--port-active-bg': 'linear-gradient(90deg, rgb(var(--port-accent) / 0.14), rgb(var(--port-accent-2) / 0.08))',
      '--port-hover-bg': 'rgb(var(--port-accent) / 0.07)',
      '--port-terminal-bg': 'rgb(246 247 252)',
      '--port-terminal-text': 'rgb(32 38 66)',
      '--port-chart-1': '14 124 140',
      '--port-chart-2': '181 23 143',
      '--port-chart-3': '161 98 7',
      '--port-chart-4': '21 128 61',
      '--port-chart-grid': '14 124 140',
      '--port-fx-scanline-color': 'rgb(var(--port-accent) / 0.05)',
      '--port-fx-overlay-opacity': '0.6',
      '--port-fx-grid-floor-x': 'rgb(var(--port-accent-2) / 0.2)',
      '--port-fx-grid-floor-y': 'rgb(var(--port-accent) / 0.22)',
      '--port-fx-grid-floor-opacity': '0.6',
      '--port-fx-grid-floor-duration': '12s',
    },
  },
};

export const THEME_IDS = Object.keys(THEMES);
export const THEME_LIST = THEME_IDS.map(id => THEMES[id]);

// Fallback color for user-pickable swatches (agent avatars, calendar sources).
// A native <input type="color"> only accepts a literal `#rrggbb` and cannot read
// a CSS custom property, so this mirrors the default theme's accent instead of
// `rgb(var(--port-accent))`. Single definition — every swatch site imports it.
export const DEFAULT_AVATAR_COLOR = THEMES[DEFAULT_THEME_ID].accent;

export const LEGACY_THEME_ALIASES = {
  midnight: 'classic-midnight',
  phosphor: 'black-ice-terminal',
  ember: 'blueprint-ops',
  arctic: 'lumen-glass',
  synthwave: 'black-ice-terminal',
  'pastel-dawn': 'lumen-glass-day',
  'pastel-paper': 'classic-noon',
  'pastel-void': 'classic-midnight',
  'pastel-submarine': 'lumen-glass',
};

export function normalizeThemeId(id) {
  if (!id || typeof id !== 'string') return DEFAULT_THEME_ID;
  if (THEMES[id]) return id;
  return LEGACY_THEME_ALIASES[id] ?? DEFAULT_THEME_ID;
}

export function getTheme(id) {
  return THEMES[normalizeThemeId(id)];
}

export function getPairedThemeId(id) {
  const theme = getTheme(id);
  const opposite = theme.mode === 'day' ? 'night' : 'day';
  return THEME_LIST.find(t => t.family === theme.family && t.mode === opposite)?.id ?? theme.id;
}

export function groupThemesByFamily() {
  const families = new Map();
  for (const theme of THEME_LIST) {
    const fam = families.get(theme.family) ?? { family: theme.family };
    fam[theme.mode] = theme;
    families.set(theme.family, fam);
  }
  return Array.from(families.values());
}