Galaxy Shell / docs
Docs / Interface e recursos

Profile copies of UI themes

openspec/specs/profile-ui-themes/spec.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Nesta página

Profile copies of UI themes

Purpose

Lets the user personalize the Office or Galaxy window theme through an independent copy inside the active profile, with live CSS reload, while the distributed theme files stay seeds.

Requirements

Requirement: Personalization edits only the profile copy

Personalization SHALL edit only the profile copy <profile>/ui-themes/<base>/theme.css and MUST NOT edit vendor/interface/host/ui-themes/*.css; worktrees and generated HTML MUST NOT become theme sources. Full text: sections Introduction and Editing from Codex or authenticated maintenance.

Scenario: Customizing a theme

  • WHEN a theme is personalized
  • THEN only the profile theme.css changes and the distributed seed stays untouched

Requirement: Copies are never overwritten

Selecting a built-in theme for the first time SHALL copy its seed, and subsequent updates MUST NOT overwrite an existing copy or the original snapshot; no separate setting or new permission is needed. Full text: section Files and identity.

Scenario: Seed update

  • WHEN the distributed seed changes later
  • THEN the existing copy and original.css are not overwritten

Requirement: Static rules for profile CSS

Profile style.css and theme.css SHALL be refused when they declare a --protected- custom property, use @import, @font-face, @namespace, @property or @function, or use a url, src or image-set string that is not a data:image/ URL; theme.css is also refused when it ends inside a comment, string, url, block or rule prelude, or puts a style rule in another at-rule than the allowed ones. Full text: section Static rules.

Scenario: Protected token declared

  • WHEN a profile stylesheet declares a --protected- property
  • THEN it is refused as invalid CSS

Scenario: Copy ends inside an open construct

  • WHEN theme.css ends with /*, @media not all{, .a{--x:" or @layer x
  • THEN it is refused as invalid CSS and the typography and palette of /theme.css still apply

Requirement: Theme copy must not touch protected surfaces

A profile theme.css MUST NOT use :modal, :open, :popover-open, ::backdrop or the dialog selector, name a protected surface by listed id or class, use attribute selectors on id, class or open, place images outside the three image custom properties, declare a reserved custom property, set pointer-events other than auto, or use interactivity, anchor-name, position-anchor, anchor-scope, anchor() or anchor-size(). Full text: section Static rules.

Scenario: Selector names a protected surface

  • WHEN theme.css names the review card by id
  • THEN it is refused like invalid CSS

Scenario: Reserved token or click-through

  • WHEN theme.css declares --ui-spacing, --font-family-ui or pointer-events: none
  • THEN it is refused like invalid CSS

Scenario: Anchor name

  • WHEN theme.css declares anchor-name: --protected-slot-change-review
  • THEN it is refused like invalid CSS

Requirement: Rejected copy keeps last good stylesheet

A stored theme.css that breaks a rule SHALL NOT be rewritten or deleted; the last good copy, then original.css, then the distributed seed loads, or no copy when all of them fail, and the snapshot error carries the reason of at most 200 characters. Full text: section Static rules.

Scenario: Invalid theme.css

  • WHEN theme.css breaks a rule
  • THEN the last good copy or original.css loads and uiThemeProfile.error shows the reason

Scenario: Every copy fails a check

  • WHEN theme.css, last-good.css and original.css all break a rule
  • THEN the snapshot does not throw, the distributed seed or no copy loads and uiThemeProfile.error shows the reason

Requirement: Selector rule is best effort

The selector rule is best effort; the protected surfaces of the documents that load the copy (approval dialogs, review card, trash and session-action confirmations, window-reading consent) MUST be isolated by the served copy: every selector is restricted so no rule matches them or their descendants, whatever the selector or !important, and their roots reset the inherited properties that hide or disguise them. Full text: section Static rules.

Scenario: Universal selector

  • WHEN a profile copy uses * { border-radius: 0 !important } or button { opacity: 0 !important }
  • THEN the approval dialogs and the review card keep their host style while the rest of the chat page takes the rule

Requirement: Edit limits and recovery

Edits SHALL be limited to 128 KiB of nonempty valid CSS in regular files with no theme-file symlinks; invalid edits MUST keep the last good stylesheet and revision, and the last good stylesheet SHALL be persisted across a core restart. Full text: section Editing from Codex or authenticated maintenance.

Scenario: Invalid edit

  • WHEN an edit is invalid
  • THEN the last good stylesheet and revision stay and diagnostics contain no CSS

Requirement: Atomic edits and no restart

Edits SHALL preferably be written as a complete candidate beside the file and atomically renamed over theme.css, and subsequent edits SHALL need no build, API credential, generic compositor command or runtime restart. Full text: section Editing from Codex or authenticated maintenance.

Scenario: Edit applied

  • WHEN theme.css is atomically replaced
  • THEN the host loads it without a document reload

Requirement: No new authority

Reverting the implementation SHALL restore the built-in CSS without deleting copies, updates to the base MUST NOT merge into a copy automatically, and no writer route for built-in themes or new authority SHALL be granted to generated HTML, plugins or schedules. Full text: section Compatibility and rollback.

Scenario: Older core

  • WHEN an older core reads the profile
  • THEN it ignores the new folder and uses built-in CSS

Requirement: A saved style.css still loads at core start

The checks of the static rules SHALL NOT run on a style.css that is already saved or checkpointed, which still loads at core start. Full text: section Static rules.

Scenario: Core start

  • WHEN the core starts with a saved or checkpointed style.css
  • THEN it still loads, because the rules do not apply to a stored copy

Requirement: Lock and recovery do not load the copy

The lock page and recovery SHALL load /protected-theme.css, the host theme, the typography and the palette without the profile copy, so no rule of the copy reaches them. Full text: section Static rules.

Scenario: Hostile copy and the lock page

  • WHEN the profile copy hides inputs and buttons with !important
  • THEN the lock form and the recovery page keep their host style

Requirement: The copy does not style the ancestors of a protected surface

In the served copy, a declaration that is not a custom property MUST NOT apply to an element that contains a protected root, html and body included, and a custom property MUST apply to such an element only when it is the root element. Full text: section Isolation of the protected surfaces.

Scenario: Hiding the page under an open dialog

  • WHEN the copy declares body { display: none !important } or html { zoom: 0.1; content-visibility: hidden }
  • THEN an open approval dialog keeps its box, size and buttons

Requirement: Protected roots keep the trusted tokens

/theme.css SHALL serve, after the copy, the custom properties that the host theme and the distributed seed declare on the root element, except paint, reserved and --protected-* ones, again on every protected root, and each root SHALL declare its font size, line height, font family and Tailwind spacing unit, so no custom property of the copy on the root element changes the layout or text of a root; paint tokens still follow the theme. Full text: section Isolation of the protected surfaces.

Scenario: Blank tool arguments

  • WHEN the copy declares :root { --text-reading: 0px; --space-md: 900px }
  • THEN the computed style of every element inside an approval dialog stays as with the seed

Requirement: Copy keyframes stay its own

The served copy SHALL prefix the name of each of its @keyframes and the matching names of its own animation declarations, so a keyframes name of the copy never replaces a trusted animation. Full text: section Isolation of the protected surfaces.

Scenario: Trusted animation name

  • WHEN the copy declares @keyframes approval-in { from { opacity: 0 } to { opacity: 0 } }
  • THEN an approval dialog still opens with the trusted animation and stays visible

Requirement: Trusted layer order is fixed first

/theme.css SHALL begin with one @layer statement that lists every cascade layer of the trusted sheets of the documents that link it, in their order, so a layer statement in the copy cannot reorder them. Full text: section Isolation of the protected surfaces.

Scenario: Reversed Tailwind layers

  • WHEN the copy declares @layer utilities, components, base, theme;
  • THEN the utilities of the panel sheets still win over their base and components layers

Requirement: Protected surfaces are in the top layer

The change review card and the panel confirmations SHALL render in the top layer as manual popovers of the trusted host, over a slot that keeps their place and size, with the fixed colors of the approval dialogs, so no element of their page paints over them or takes their press and no ancestor paints them. Full text: section Isolation of the protected surfaces.

Scenario: Covering element

  • WHEN the copy places a fixed element with the highest z-index over the review card or a panel confirmation
  • THEN the surface paints above it and a press on a button reaches the button

Status

Doc status: current contract. Profile copies of UI themes, added 2026-11-06; AGENTS.md section Profile copies of UI themes. Checked 2026-11-11.

Introduction

A built-in Office or Glass stylesheet is a distributed seed. Personalization edits only a profile copy, never vendor/interface/host/ui-themes/*.css.

Files and identity

The first read of a selected built-in theme creates <profile>/ui-themes/<base>/:

  • theme.css: the editable, active full copy.
  • original.css: the original snapshot, created once for local recovery.
  • theme.json: identity (profile-office or profile-glass), original display name, base id and original content hash.
  • last-good.css: the most recent syntactically valid, bounded stylesheet.

The protected uiTheme choice still selects Office or Galaxy. It resolves to that profile's copy; no separate setting, additional theme picker or new permission is needed. The display name stays the same as the base; the storage identity is different. Selecting a theme for the first time copies its distributed seed. Galaxy (formerly Glass, a stored glass reads as galaxy) starts from its own seed in <profile>/ui-themes/galaxy/; an existing <profile>/ui-themes/glass/ stays on disk, untouched and unused. Subsequent updates never overwrite an existing copy or original snapshot. Shared framework CSS (host/theme.css) and the protected theme layout remain part of the product, outside this customization contract.

Editing from Codex or authenticated maintenance

Discover the actual profile in project.json or system_context. Read the active copy and edit only its theme.css, preserving unrelated customizations. Prefer writing a complete candidate beside the file and atomically renaming it over theme.css; a partial write can otherwise be read between two editor writes. No build, API credential, generic compositor command or runtime restart is needed for subsequent edits. Worktrees and generated HTML do not become theme sources.

The core checks file identity and timestamps on normal theme/state reads. Content changes enter the existing 64-digit stylesheet revision, including the compact bar poll signature. The host retains the old stylesheet until the replacement loads. The CSS compositor bridge then applies changed bar material values on its next state poll. No document reload is required. Panels follow their existing theme polls, and the wallpaper follows the palette event stream.

Limits: 128 KiB, nonempty valid CSS, regular files and no theme-file symlinks. Invalid edits keep the last good stylesheet and revision. uiThemeProfile of the protected state reports the copy identity and error; diagnostics contain no CSS. The last good stylesheet is persisted so a core restart does not lose recovery. To restore the original appearance, atomically copy original.css over theme.css; preserve the customized file separately if desired.

For the compositor material variables, see UI themes. The first installation of this reader requires a core update; the compositor bridge requires its initial compositor update. Copies created ahead of that update remain inert until the new reader starts.

Static rules

web-shell/core/css-rules.js checks two kinds of profile CSS before they load. The checks run on a new candidate only: checkProfileStyle for style.css (the validate of core/store.js with rules: true, called by commitInterfaceBundle for replace_ui, import_theme_style, apply_wallpaper_theme and remove_wallpaper_theme; validateStylesheet of core/themes.js; create_theme in core/theme-create.js), and checkProfileTheme for the profile copy theme.css (read() of core/profile-ui-themes.js, on every load, so a violating file is treated exactly like invalid CSS: the last good stylesheet stays, then original.css, then the distributed seed, then no copy, and the snapshot error is set; the snapshot never throws because of a check or a hostile file in the theme folder, only when the folder itself is a symbolic link). A style.css that is already saved or checkpointed still loads at core start; the rules do not apply to validate without rules.

Both stylesheets refuse:

  • a declaration of a custom property that starts with --protected- (case-insensitive, after unescaping): host/theme.css pins the shape and timing of the approval dialogs, the review card, the lock page and recovery with those tokens in an unlayered :root block, and a profile copy of a theme is unlayered too, so one declaration would win over the pin. Reading one with var() is allowed;
  • @import, @font-face, @namespace, @property and @function (also inside @media, @layer and @supports, and through an escaped name): @property --protected-x { inherits: false; initial-value: 0px } would register the name again and override the pin below :root, or invalidate it with another syntax, and a custom function returns a value that no check sees (@function --f() { result: "/x.png" } with image-set(--f()) loads /x.png). No seed and no profile copy registers a custom property or a function (the @property rules of the compiled shadcn-*.css sheets are trusted host CSS, not profile CSS);
  • url(), src() and the strings of image-set() whose value is not a data:image/ URL (an empty value or a #fragment passes). A function named url through an escape (u\72l(...)) counts as url(). Text that the parser keeps unparsed (a custom property value, the fallback of var(), unknown arguments) is parsed again by the css-tree value tokenizer and checked the same way, so a url( inside a string ("url('data:image/png," url(/x.png)), a comment or an escape cannot hide a url() that follows it. A custom property value that this tokenizer cannot parse (for example an if() with ; inside) is refused as a parse error in both stylesheets. A function named url through an escape takes exactly one quoted string: with an unquoted argument the browser reads a url-token in which /**/ is literal text while css-tree drops the comment, so the check would see a different URL than the one loaded. image-set(), -webkit-image-set(), src(), image() and cross-fade() (also -webkit-) take no var(), env(), attr(), inherit(), if(), custom function (--f()) or unparsed text at any depth, and every string inside them goes through the same URL check, except the MIME type of type(), which is never loaded. Only style.css may also name the same-origin /desktop-wallpaper.png; the chat page CSP (img-src 'self' blob: data:, core/server.js) confines it, and the outer-document theme never gets it.

The checks parse the text in the form that the browser tokenizes (CSS Syntax, preprocessing): CR, CRLF and FF read as one newline and U+0000 as U+FFFD, so \70\r\nrotected is the name that the browser reads. A URL value is read exactly once: css-tree already decodes the escapes of url(...) and of a string, so the check takes that decoded value and does not unescape it again (url("\5c 64 ata:...") is the relative path \64 ata:..., not a data: URL). Before it compares the scheme it does what the WHATWG URL parser does: it strips leading and trailing C0 controls and space and removes ASCII tab and newline anywhere, and nothing else (NBSP, U+FEFF and U+2028 stay, so url(\ufeffdata:...) is refused). A hex escape ends at exactly one CSS whitespace (space, tab, newline), not at every character that a JavaScript \s matches. Only what the checks parse is normalized; the stored text stays as written, so a CRLF file still loads. The served style.css (profileStyle of core/store.js) is generated from the same preprocessed text that the check parsed, so the served sheet is what the check read.

Every name the rules compare (at-rule, function, property, pseudo-class, pseudo-element, type selector, id, class, attribute name) is compared after CSS unescaping, so @\69mport and \63 ontent are refused like their plain forms. A pseudo-class or pseudo-element whose arguments the parser keeps as unparsed text (css-tree does this for a name it does not know, and does not unescape names, so :\69 s(#tool-approval) would reach a browser as :is(#tool-approval)) is refused unless the text is one plain identifier (::part(x), :state(x) and ::highlight(x) keep working); the selector-taking names (:is, :where, :not, :nth-child and so on) are refused whenever their arguments stay unparsed, and so is any escaped pseudo name with unparsed arguments.

The profile copy theme.css also refuses, because the outer documents load it (the chat page with the approval dialogs and the change review card, and every protected panel; the lock page and recovery load /protected-theme.css, which has no copy, see Isolation of the protected surfaces below):

  • the pseudo-classes :modal, :open and :popover-open, the pseudo-element ::backdrop, and the type selector dialog;
  • a selector that names a protected surface by id or class (inside :has(), :is() and :nth-child(... of ...) too): the ids and classes listed in protectedSurfaceIds, protectedSurfaceClasses and protectedSurfaceClassPrefixes of css-rules.js (the approval dialogs, #change-review, #change-recovery, the lock page and the recovery page, and the class prefixes approval-, change-, recovery- and lock-), also through escapes;
  • every attribute selector on id, class and open, whatever the matcher; other attribute selectors stay allowed; and a namespaced attribute selector ([ns|id], [*|class]);
  • an image outside three custom properties. imageTokens of css-rules.js is --glass-grain, --material-glass-blurred and --glass-panel-blurred: they hold the grain of galaxy.css and the blurred material built from it, and their only consumers are bars, panels, notifications, the composer and chat bubbles (host.css, notifications.css, panel-base.css, ui-src/style.css), never a protected surface. Those three may hold url() (data:image/ only), image-set() and var(). Any other declaration, a custom property included (--color-scrim paints the backdrop of the approval dialogs and --color-background paints recovery and the lock page), is refused if its value has an image function (url, src, image-set, -webkit-image-set, image, element, -moz-element, cross-fade, -webkit-cross-fade, paint) or a var() of one of the three names, so no other token can carry an image to a protected surface. The references come from the css-tree value parser, so a comment, a string or an escape cannot hide one; inherit(--x) counts like var(--x), and a custom function (--f(), @function), if() and attr() are refused because they could build a reference that the check cannot follow;
  • in a property that paints an image (background, mask, border-image, list-style, cursor, filter, backdrop-filter, shape-outside, content, box-reflect, their -webkit- and similar forms, and all), the keywords inherit, unset, revert and revert-layer, which could chain an image that host CSS placed on an ancestor;
  • generated text: @counter-style; a content other than none, normal and an empty string; in list-style and list-style-type anything but the identifiers none, disc, circle, square, inside, outside, disclosure-open and disclosure-closed (no string, no function, no var()); and in hyphenate-character, text-overflow, text-emphasis and text-emphasis-style (with -webkit- forms) any string, function, var() or CSS-wide keyword.
  • a copy that does not end at the top level with every construct closed: a comment, a string or a url still open, a block or bracket left open, or a top-level rule prelude with no block or ; yet (/*, @media not all{, .a{--x:", .a{b:url(, @layer x, .a, a stray }). /theme.css joins the copy and the trusted typography and palette in one sheet, so such a copy would make the browser read the trusted parts as part of its comment, string, block or prelude and drop them (naaando/galaxy-shell#5). checkComplete of css-rules.js walks the tokens of the copy plus a newline as the stylesheet parser does at its top level (inside a block only the matching closer pops; a top-level block or the ; of an at-rule completes the pending rule), on the source and again on the served text; core/page-routes.js puts a newline before and after the copy;
  • a declaration of a reserved custom property (after unescaping, case-insensitive): the system typography --font-family-ui, --font-family-mono, --font-family-quick and --font-size-<n>, and the names of the compiled host sheets --ui-* (but --ui-theme-*, which the seeds declare), --tw-* and --panel-*. Those sheets declare them layered or inline, so an unlayered copy would win and change the type, the spacing unit and the panel metrics of every surface (naaando/galaxy-shell#16);
  • pointer-events with another value than auto, all with another value than initial (an invalid var() makes all compute as unset, which inherits a trusted pointer-events: none), and any interactivity: an element that the copy moves over a surface outside the top layer would otherwise let a press through to the real button under a false label (#16);
  • a style rule inside an at-rule other than @media, @supports, @layer, @container, @scope, @starting-style and @document (the keyframe selectors of @keyframes stay as written; an at-rule that holds only declarations, as @page, stays allowed at the top level), and inside a style rule any at-rule but @media, @supports, @container, @layer and @starting-style, whose declarations apply to the guarded parent: a nested @scope (button) { opacity: 0 } would apply to every button of the document past the guard of its parent, so no style rule or nested at-rule escapes the restriction below.

!important, the universal selector *, :has() and var() of any other token stay allowed, so an ordinary customization keeps loading. Gradients stay allowed. Nested style rules are a parse error for the css-tree version in use (.a { .b & {} }), so a theme that uses CSS nesting is refused as invalid CSS; that is safe, and a theme writes the full selectors instead.

Why: the CSP of the chat page (style-src with a nonce, img-src 'self' blob: data:, no font-src) already blocks external loads; the rules stop same-origin loads, and the isolation below keeps a theme of the outer documents off the approval dialogs, the review card, the lock form and recovery.

Isolation of the protected surfaces

The owner chose isolation on 2026-11-10 (architecture-decisions.md, Owner decisions on the audit of 2026-11-10), and it closes naaando/galaxy-shell#4: before it, the selector rule was the only defense, and a universal or type selector with !important (* { border-radius: 0 !important }, input, button { opacity: 0 !important }), another attribute (button[aria-describedby=tool-approval-hint]) or structure (body > :nth-child(N) button) reached the protected surfaces without naming them, up to an invisible full-screen Aprovar button under the Recusar press.

  • The lock page and recovery link /protected-theme.css: the host theme.css, the typography and the palette, without the profile copy, under the launch cookie (profileAssetPaths of core/route-table.js; the lock partition allows it and not /theme.css, core/lock-window.cjs). No rule of the copy is in those documents. They keep their fixed palette, the host default tokens and the profile color of the palette.
  • The chat page links /theme.css, which serves the copy generated again from its parsed tree (isolateProfileTheme of css-rules.js) with :where(:not(P, P *)) appended to the subject compound of every selector of every style rule, before its first pseudo-element, where P is protectedChatRoots: #tool-approval, #schedule-approval, #theme-approval, .approval-dialog, #change-review, .change-review, #change-recovery, #window-reading-list (the consent buttons of window reading in the settings), .dock-trash-confirm (the confirmation of the permanent empty of the Lumen trash, in dock-trash-menu.html, which also loads /theme.css; its classes start with dock-trash-confirm, a refused prefix), and the confirmations of the session actions .quick-confirmation, .start-menu-confirmation and .actions-confirm (quick settings, Start menu and desktop actions). An attribute selector such as section[role=alertdialog] button.danger or button[data-allow=true] reached these without naming them. The single-colon pseudo-elements :before, :after, :first-line and :first-letter count as pseudo-elements, so the guard goes before them. :where() adds no specificity, and the layers and the order stay as written, so the cascade of every other element is unchanged; no rule of the copy matches an element inside a protected surface or its pseudo-elements, whatever its selector or !important. Taking the guard out of the served text gives the copy as css-tree generates it (tested for the four seeds). @scope (:root) to (P) was tried in Chromium and rejected: a scoped :root or html rule never matches, so every token rule of a theme would stop applying.
  • The served copy also keeps its rules off the ancestors of the roots (#16): each style rule is split into a rule of its custom properties and a rule of its other declarations, with the same selectors, in place. The other declarations get :where(:not(P, P *, :has(P))), so no declaration that is not a custom property applies to an element that contains a root, html and body included (body { display: none } or html { zoom: 0.1; content-visibility: hidden } no longer remove the box of an open dialog). The custom properties get :where(:not(P, P *, :not(:root):has(P))), so they reach an ancestor of a root only on the root element. A copy loses its non-token rules on body, footer.composer-area, the account dialog content and, while a confirmation is shown, main.panel-surface; the seeds have none.
  • After the copy, /theme.css serves protectedRootTokens (css-rules.js) of the host theme.css and of the distributed seed of the theme (rootTokens of the snapshot): every rule of those trusted sheets whose subject is the root element becomes S :where(roots) (roots: P plus #lock-root and #recovery) with its custom properties that are not paint (paintTokens: --color-*, --border-*, --glass-*, --material-*, --palette-*, the quick panel colors and glass, accents, icon filters, --focus-ring-color), reserved or --protected-*, in the same layers and conditions, with the specificity of S. Each root thus declares the metrics, frame and label tokens that the trusted sheets give the root element, and a custom property of the copy on the root element does not reach it (--text-reading: 0px no longer blanks the arguments of a tool request). The roots also declare, in @layer shell-theme (host.css for the chat roots, panel-base.css for the panel confirmations), their font size, line height and font family from those tokens, the Tailwind spacing unit --ui-spacing and --ui-container-xs as calc() of their font size, so rem no longer follows html, and --change-actions-height: initial until the card measures it. A layered declaration on a root loses to every trusted rule that styles it, so the shipped look of each seed is unchanged.
  • host/theme.css begins with @layer shell-theme, shell-ui-theme, shell-profile, shell-wallpaper, theme, base, components, utilities, panel;, the order of every cascade layer of the trusted sheets of the documents that link /theme.css, so a layer statement in the copy cannot reorder them (@layer utilities, components, base, theme; would let Tailwind base rules win over utilities). A test derives the order from each document.
  • Keyframes are global names: the served copy prefixes profile-theme- to the name of each of its @keyframes and to those names in its own animation and animation-name declarations, so @keyframes approval-in in the copy does not replace the trusted animation of a dialog. The prefixed name is escaped again as an identifier (an escaped ; or { in a name stays part of the name), and the served text must parse back to the same text, or the copy is refused like invalid CSS.
  • The change review card and the panel confirmations are in the top layer (#17), like the approval dialogs: each is a manual popover that the trusted host shows (ui-src/host/ui/top-layer.jsx), so no element of its page paints over it or takes its press, and the opacity, transform, filter and clip of its ancestors do not reach it. The review card, the desktop actions confirmation and the trash confirmation are anchored (CSS anchor positioning) over an empty .protected-slot that stays in the flow where they were, as tall as their content, so the composer footer and the panel <main> that the host measures keep their size; quick settings and the Start menu keep their confirmation as a sheet fixed over the panel. A surface is open only while it is connected, its slot is drawn and in view (some of it inside the viewport and every box whose overflow, paint containment or content-visibility clips it through its containing blocks, because position-visibility: anchors-visible stops painting the surface but leaves it open and focusable, #18; a box that turns, by a rotation, skew, 3D tilt or motion path, on the slot, on a box that holds it or on the root makes the slot count as out of view, since its clip rectangle is not exact, and a clip whose overflow-clip-margin names content-box clips at the content box, #19), the surface really lies over its slot (an unresolved anchor closes it), no modal dialog is open and the overview planes are not drawn, so it never paints over an approval dialog, and the confirm button of a surface (Aprovar, Esvaziar, Encerrar sessão) disarms while it is closed and arms again only 1.5 s after it opens again; one sync() decides it on mount, on resize, on body mutations, when the slot enters or leaves the view and every 250 ms, and a press on a confirm button runs it again first (syncTopLayer), so a change that none of these reports yet closes the surface before the press counts (#19). The copy refuses anchor-name, position-anchor, anchor-scope and the functions anchor() and anchor-size(), so it cannot take the name of a slot, and .protected-slot is a root (class prefix protected- refused); a name in the ShadowRoot of #surface does not reach the light DOM. All of them take the fixed --approval-* pairs, so no theme, palette or profile color paints them. web-shell/test/top-layer-surfaces.test.js checks, in Chromium, a cover with the highest z-index and ancestor opacity, filter and transform against each surface, each hiding state of the card, a slot scrolled or clipped out of view, the boxes that hold a fixed slot, a box that turns, a clip or a broken anchor in the task of the press, a re-parent of the footer and a hostile shadow anchor name.
  • Inheritance from html and body still reaches the roots, as it would reach a shadow root. host/theme.css declares on the roots, unlayered, visibility, pointer-events, -webkit-text-fill-color, -webkit-text-stroke-width, -webkit-text-security, text-shadow, letter-spacing, word-spacing, text-indent, text-transform, direction and writing-mode; a declared value on the root beats any inherited one, !important or not.

web-shell/test/profile-theme-isolation.test.js checks each attack shape of #4, #5 and #16 and, in real Chromium, that a copy declaring every custom property the protected CSS reads (but the paint families) with html, body and ancestor attacks leaves the computed style of every element of each root as with the seed (the review card and the panel confirmations may change size with their ancestors), that a hostile copy restyles the rest of the page and none of an approval dialog or the review card, and that the trusted tail applies after each served seed.

What is guaranteed: no rule of the profile copy matches an element inside the roots above, and none is in the lock page or recovery; no image reaches a protected surface except through the three image tokens, which only trusted host CSS places on bars, panels, the composer and chat bubbles; the copy cannot change how the trusted parts after it in /theme.css parse. The three image tokens may hold any image, an SVG or a raster one, and an image can draw text, so the bars, panels, the composer and chat bubbles can show drawn text; the galaxy.css grain is an SVG, so SVG is not refused.

Residual risks: the layout of the ancestors of a slot still follows the copy (the composer footer, the panel surface), so it decides where the review card, the desktop actions confirmation and the trash confirmation stand and how much room they get; a slot pushed off screen or not drawn closes its surface, which can deny or delay a request but no element covers a surface or takes its press. The approval dialogs, the review card and the panel confirmations are in the top layer, so no rule of the copy can move Aprovar under a Recusar press. The refusal reason can echo a name the copy chose (shown as text, at most 200 characters), and @view-transition in the copy can change page transitions. execute_command runs as the user and can write the checkout and the profile, so the rules are no defense against it.

A stored theme.css that breaks a rule is never rewritten or deleted: it stays on disk, the last good copy (then original.css, then the distributed seed, then no copy) loads, and the snapshot error carries the reason ("Motivo: ...", at most 200 characters), which the protected settings show under "Tema de janela" (uiThemeProfile.error). A saved style.css that already breaks a rule makes the next replace_ui fail with "Profile style.css breaks a static rule ... Fix it with replace_ui."; the agent fixes the stylesheet.

Compatibility and rollback

This expands the profile with new files and changes no existing profile setting, conversation, permission or runtime identifier. Older cores ignore the new folder and continue using built-in CSS. Reverting the implementation restores that behavior without deleting the copies. Updates to the base do not merge into a copy automatically. There is no writer route for built-in themes, and no new tool or theme selection authority is granted to generated HTML, plugins or schedules.

Evidence: web-shell/test/profile-ui-themes.test.js covers atomic edits, stable revision, immutable seeds, independent themes, syntax failure recovery across restarts, symlink refusal and a live synthetic core serving edited CSS through the existing stylesheet URL with a changed bar poll revision.