import re # Only these keys can be emitted into CSS. The colors are the picker defaults. PUBLIC_AREAS = { 'Public site · Essentials': { 'background': ('Page background', '#0c0e15'), 'ink': ('Main text', '#f7f7fc'), 'muted': ('Secondary text', '#b4bdd5'), 'accent': ('Links and accents', '#82c3ff'), 'button': ('Primary button fill', '#ffdd00'), 'button_ink': ('Primary button text', '#121623'), 'border': ('Lines and borders', '#323a4d'), }, 'Public site · Navigation and footer': { 'nav': ('Navigation background', '#121623'), 'nav_ink': ('Navigation text', '#f7f7fc'), 'footer': ('Footer background', '#121623'), 'footer_ink': ('Footer text', '#b4bdd5'), }, 'Public site · Homepage and interiors': { 'hero': ('Homepage hero background', '#192a40'), 'hero_ink': ('Homepage hero text', '#f7f7fc'), 'panel': ('Cards and panels', '#181f2f'), 'panel_ink': ('Card and panel text', '#f7f7fc'), 'archive': ('Chapter archive background', '#0c0e15'), 'editorial': ('Blog, cast and world background', '#0c0e15'), 'shop': ('Shop background', '#0c0e15'), 'account': ('Reader profile and library background', '#0c0e15'), }, 'Public site · Reader and reviews': { 'reader': ('Reader canvas', '#0b0e17'), 'reader_bar': ('Reader toolbar', '#161f30'), 'reader_ink': ('Reader controls and text', '#eff4ff'), 'reviews': ('Review and discussion background', '#181f2f'), 'reviews_ink': ('Review and discussion text', '#f7f7fc'), 'bubble': ('Comment bubble paper', '#f7f7fc'), 'bubble_ink': ('Comment bubble text', '#121623'), 'bubble_edge': ('Comment bubble outline', '#121623'), }, 'Public site · Author comments': { 'author_card': ('Gradient bottom', '#ffffff'), 'author_name': ('Author name color', '#121623'), 'author_bubble': ('Gradient top', '#ffdb71'), 'author_border': ('Frame border', '#0b0b0b'), 'author_ink': ('Comment text color', '#121623'), 'author_avatar': ('Avatar ring and placeholder', '#b7eff0'), }, 'Public site · Releases and streaming': { 'countdown': ('Countdown background', '#242316'), 'countdown_ink': ('Countdown text', '#f7f7fc'), 'live': ('SLX Live background', '#281e21'), 'live_ink': ('SLX Live text', '#f7f7fc'), }, } STUDIO_AREAS = { 'Studio · Workspace and menu': { 'studio_background': ('Workspace background', '#eef2f7'), 'studio_paper': ('Panels and forms', '#ffffff'), 'studio_ink': ('Workspace text', '#121623'), 'studio_muted': ('Secondary text', '#48566c'), 'studio_rule': ('Lines and borders', '#abb8cb'), 'studio_sidebar': ('Menu background', '#f4f7fb'), 'studio_sidebar_ink': ('Menu text', '#121623'), 'studio_sidebar_active': ('Selected menu fill', '#ffdd00'), 'studio_sidebar_active_ink': ('Selected menu text', '#121623'), }, 'Studio · Masthead and actions': { 'studio_header': ('Header background', '#121623'), 'studio_header_ink': ('Header text', '#f7f7fc'), 'studio_section': ('Section header background', '#ffdd00'), 'studio_section_ink': ('Section header text', '#121623'), 'studio_link': ('Links and accents', '#15558e'), 'studio_button': ('Primary action fill', '#ffdd00'), 'studio_button_ink': ('Primary action text', '#121623'), 'studio_release': ('Publishing marks', '#ff6633'), }, } AREAS = {**PUBLIC_AREAS, **STUDIO_AREAS} PUBLIC_KEYS = {key for group in PUBLIC_AREAS.values() for key in group} STUDIO_KEYS = {key for group in STUDIO_AREAS.values() for key in group} FIELDS = PUBLIC_KEYS | STUDIO_KEYS HEX_COLOR = re.compile(r'#[0-9A-Fa-f]{6}\Z') def clean_palette(palette): if not isinstance(palette, dict): return {} return {key: color for key, color in palette.items() if key in FIELDS and isinstance(color, str) and HEX_COLOR.fullmatch(color)} def css_variables(palette, keys=PUBLIC_KEYS): return ';'.join('--slx-' + key.replace('_', '-') + ':' + color for key, color in clean_palette(palette).items() if key in keys)