/* Planning, chat and shared-tool theme colours.
 * Append after the shared theme foundation and existing module styles.
 * Palette values come exclusively from theme-spec.json via --theme-* tokens.
 * Default has no matching rule. Geometry, typography and shadow geometry stay intact.
 * Focus outline width/offset are the explicit theme-spec 2px / 2px exception.
 */

/* Chat: incoming content uses card/text; outgoing content is exactly primary/on-primary.
 * No timestamp, username or action opacity is used to soften outgoing text.
 */
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-scroller,.fgc-thread,.place-messages,.owner-chat-messages){background-color:var(--theme-page);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message,.fgc-message,.place-message,.owner-chat-message){background-color:var(--theme-card);border-color:var(--theme-border);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message time,.fgc-message time,.fgc-edited,.fgc-options summary,.place-message time,.owner-chat-message>span,.owner-chat-message time){color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own,.fgc-message.own,.place-message.own,.owner-chat-message.is-mine){background-color:var(--theme-primary);border-color:var(--theme-primary);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own p,.dm-message.own time,.fgc-message.own p,.fgc-message.own .fgc-author>span,.fgc-message.own time,.fgc-message.own .member-username,.fgc-message.own .fgc-edited,.fgc-message.own .fgc-options>summary,.place-message.own p,.place-message.own b,.place-message.own time,.owner-chat-message.is-mine p,.owner-chat-message.is-mine>span,.owner-chat-message.is-mine time){color:var(--theme-on-primary);opacity:1}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own,.fgc-message.own,.place-message.own) .btn.ghost{color:var(--theme-on-primary);background-color:transparent}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own,.fgc-message.own,.place-message.own) .btn.ghost:hover:not(:disabled){color:var(--theme-on-primary);background-color:var(--theme-primary-hover)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own,.fgc-message.own,.place-message.own) .btn.ghost:active:not(:disabled){color:var(--theme-on-primary);background-color:var(--theme-primary-pressed)}
/* An explicit destructive action keeps a readable error pair even inside an outgoing bubble. */
:where(html[data-theme]:not([data-theme="default"])) .fgc-message.own .btn.ghost.danger{color:var(--theme-error-fg);background-color:var(--theme-error-bg)}
:where(html[data-theme]:not([data-theme="default"])) .fgc-message.own .btn.ghost.danger:hover:not(:disabled){color:var(--theme-on-danger);background-color:var(--theme-danger-hover)}
:where(html[data-theme]:not([data-theme="default"])) .fgc-message.own .btn.ghost.danger:active:not(:disabled){color:var(--theme-on-danger);background-color:var(--theme-danger-pressed)}
:where(html[data-theme]:not([data-theme="default"])) .dm-share-link{color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .dm-share-link:hover{color:var(--theme-primary-hover)}
:where(html[data-theme]:not([data-theme="default"])) .dm-message.own .dm-share-link,
:where(html[data-theme]:not([data-theme="default"])) .dm-message.own .dm-share-link:hover{color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) .message-contact:hover{background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) :is(.message-contact[aria-current=true],.message-contact[data-unread=true]){background-color:var(--theme-selection-bg);border-color:var(--theme-border);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.message-contact[aria-current=true],.message-contact[data-unread=true]) .message-contact-copy small{color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .message-unread{background-color:var(--theme-primary);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) .messages-search input{background-color:var(--theme-input)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-composer,.fgc-composer){background-color:var(--theme-input)}
:where(html[data-theme]:not([data-theme="default"])) .messages-latest{background-color:var(--theme-info-bg);color:var(--theme-info-fg)}
:where(html[data-theme]:not([data-theme="default"])) .messages-confirm{background-color:var(--theme-warning-bg);color:var(--theme-warning-fg);border-color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .messages-empty-art{background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .messages-layout:not(.has-selection) .messages-empty-art{background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-options>summary:hover,.fgc-header-menu[open]>summary,.fgc-caption){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .messages-options-panel{background-color:var(--theme-raised);box-shadow:0 10px 30px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-chooser-search,.messages-chooser-actions,.messages-chooser-person){border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-search input{background-color:var(--theme-input);color:var(--theme-text);border-color:var(--theme-control-border)}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-search>svg{color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-chooser-person,.messages-chooser-group){color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-chooser-group:hover:not(:disabled),.messages-chooser-person:hover){background-color:var(--theme-subtle);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-chooser-person[data-selected=true],.messages-chooser-group:active:not(:disabled)){background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-group>svg:first-child{background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-group>svg:last-child{background-color:transparent;color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-modal :is(.messages-chooser-label,#dmNewChatStatus){color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-chooser-group:focus-visible,.messages-chooser-person:has(input:focus-visible)){outline-color:var(--theme-primary);outline-offset:2px}
:where(html[data-theme]:not([data-theme="default"])) .messages-chooser-group:disabled{background-color:var(--theme-disabled-bg);color:var(--theme-disabled-fg);opacity:1}
:where(html[data-theme]:not([data-theme="default"])) .fgc-header-panel{background-color:var(--theme-raised);box-shadow:0 10px 28px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) .fgc-new .btn{background-color:var(--theme-raised);box-shadow:0 3px 12px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.contact-chat-invite,.owner-chat-person){background-color:var(--theme-subtle);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) .guest-contact{background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) .contact-address a{color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .owner-chat-pending{color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .owner-chat-modal .owner-chat-delete{color:var(--theme-danger)}
:where(html[data-theme]:not([data-theme="default"])) .feedback-card blockquote{background-color:var(--theme-subtle);border-inline-start-color:var(--theme-border)}

/* Group/calendar identities and actions. Selection does not replace availability meaning. */
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-group-mark,.fg-person-avatar,.fg-people-avatars>span){background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-common-icon,.fg-tool-icon){background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .fg-people-avatars>span{border-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-common-people,.fg-week-grid){border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fg-common-people{background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-days button,.fg-common-durations button,.fg-people-choice,.fg-missing-people>span){background-color:var(--theme-card);border-color:var(--theme-border);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-common-durations button:not([aria-pressed=true]),.fg-brushes .btn:not([aria-pressed=true])){background-color:var(--theme-subtle);color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) .fg-people-choice[aria-pressed=true]{background-color:var(--theme-selection-bg);border-color:var(--theme-primary);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-people-choice[aria-pressed=true] .member-username{color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-days button[aria-pressed=true]{background-color:var(--theme-primary);border-color:var(--theme-primary);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-common-durations button[aria-pressed=true],.fg-brushes .btn[aria-pressed=true],.fg-brushes .btn[aria-pressed=true]:hover:not(:disabled)){background-color:var(--theme-selection-bg);border-color:var(--theme-primary);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-brushes [aria-pressed=true]{box-shadow:inset 0 0 0 2px var(--theme-selection-fg),0 0 0 1px var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .fg-paint-tools [aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-common-time,.fg-apply-days,.fg-schedule-switch){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .fg-calendar-tools .fg-common-time{background-color:transparent}
:where(html[data-theme]:not([data-theme="default"])) .fg-common-open:hover{background-color:var(--theme-selection-bg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-common-open:active{background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .fg-common-cue{color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-grid-head,.fg-grid-corner,.fg-grid-time){background-color:var(--theme-subtle);color:var(--theme-secondary);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fg-grid-day{border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-grid-cell,.fg-grid-cell[data-status=unknown]){background-color:var(--theme-card);color:var(--theme-secondary);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fg-shared-cell{background-color:var(--theme-subtle);color:var(--theme-secondary);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-status-free,.fg-grid-cell[data-status=free],.fg-shared-cell[data-status=free]){background-color:var(--theme-success-bg);color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-status-busy,.fg-grid-cell[data-status=busy],.fg-shared-cell[data-status=busy]){background-color:var(--theme-subtle);color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-status-unknown,.fg-shared-cell[data-status=unknown]){background-color:var(--theme-subtle);color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-status-activity,.fg-grid-cell[data-status=activity],.fg-shared-cell[data-status=activity]){background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-shared-cell[data-status=mixed]{background-color:var(--theme-info-bg);color:var(--theme-info-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-shared-cell[aria-pressed=true]{box-shadow:inset 0 0 0 2px var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .fg-apply-day-list [aria-pressed=true],
:where(html[data-theme]:not([data-theme="default"])) .fg-apply-day-list .btn[aria-pressed=true]:is(:hover,:focus-visible){background-color:var(--theme-primary);border-color:var(--theme-primary);color:var(--theme-on-primary);box-shadow:inset 0 0 0 2px var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) .fg-tool-link:hover:not(:disabled){border-color:var(--theme-primary);background-color:var(--theme-selection-bg)}
:where(html[data-theme]:not([data-theme="default"])) .fg-tool-link:active:not(:disabled){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .fg-schedule-switch>button[aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);box-shadow:0 1px 4px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-filter input,.fg-day-checks input[type=checkbox]){accent-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-duration-label,.ps-two>.field>label,.ps-two>.field>#psDurationLabel){color:var(--theme-text)}

/* Polls, proposals, private schedule and reviewed invitations. */
:where(html[data-theme]:not([data-theme="default"])) :is([data-plan-state="Cancelled"],[data-poll-state="Cancelled"]){background-color:var(--theme-error-bg);color:var(--theme-error-fg);border-color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(#timePollRoot,#groupPollRoot,#groupPlansRoot,#groupProposalsRoot,#friendGroupsRoot,#activityInvitationsRoot,#costRoot,.tp-modal,.gp-modal,.gpl-modal,.gpr-modal,.fg-modal,.fgc-conversation,.cost-modal,.ain-modal) .notice.warning[role=alert]{background-color:var(--theme-error-bg);color:var(--theme-error-fg);border-color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(#fgcFormMessage,.ain-modal [role=alert]){color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.tp-choices label:has(input:checked),.gp-option:has(input:checked)){background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .gp-option:has(input:checked) .gp-option-title>span{color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .tp-choices input[type=radio]{accent-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.gp-mark,.gp-bar,.gp-voters>span,.gpr-idea,.gpr-count,.gpr-saved-label,.ps-kind){background-color:var(--theme-subtle);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) .gp-bar>span{background-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .gp-modal .form-actions{background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) .gpr-options>div{background-color:var(--theme-raised);box-shadow:0 8px 24px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.gpr-card:hover,.gpr-options summary:hover){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .gpr-tabs .btn[aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .ps-error{background-color:var(--theme-error-bg);color:var(--theme-error-fg);border-color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ps-recovery{background-color:var(--theme-warning-bg);color:var(--theme-warning-fg);border-color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ps-notice{color:var(--theme-info-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ps-kind[data-schedule-kind=free]{background-color:var(--theme-success-bg);color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ps-kind[data-schedule-kind=busy]{background-color:var(--theme-subtle);color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) .ps-kind[data-schedule-kind=open]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ps-duration .btn[aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .ps-duration .btn[aria-pressed=false]{background-color:var(--theme-subtle);color:var(--theme-secondary);border-color:var(--theme-control-border)}
:where(html[data-theme]:not([data-theme="default"])) .ps-duration .btn:disabled{background-color:var(--theme-disabled-bg);color:var(--theme-disabled-fg);border-color:var(--theme-border);opacity:1}
:where(html[data-theme]:not([data-theme="default"])) .ain-visual{background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .ain-empty>svg{color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) :is(.ain-options>summary:hover,.ain-private,.ain-counts>span,.ain-suggestion){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .ain-options>div{background-color:var(--theme-raised);box-shadow:0 8px 28px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.ain-kind-choices .btn[aria-pressed=true],.ain-choices>.btn[aria-pressed=true]){background-color:var(--theme-selection-bg);border-color:var(--theme-primary);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .ain-experience-option{background-color:var(--theme-card);color:var(--theme-text)}
/* QR quiet zones and encoded dark paths are intentionally not recoloured. */

/* Expenses: warning means owing, success means money owed to this person.
 * data-balance-state comes from the validated numeric balance, never its label.
 * Settled zero is also success per user requirement, with its existing label.
 * Never infer a sign from localized text or the generic .export-money class.
 */
:where(html[data-theme]:not([data-theme="default"])) :is(.cost-owes,[data-balance-state="owing"]){color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) [data-balance-state="owed"]{color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) [data-balance-state="settled"]{color:var(--theme-success-fg)}
/* Explicit delete/undo/leave intent; never infer it from localized button text. */
:where(html[data-theme]:not([data-theme="default"])) button.btn[data-destructive="true"]{background-color:var(--theme-danger);color:var(--theme-on-danger);border-color:var(--theme-danger)}
:where(html[data-theme]:not([data-theme="default"])) button.btn[data-destructive="true"]:hover:not(:disabled){background-color:var(--theme-danger-hover);color:var(--theme-on-danger);border-color:var(--theme-danger-hover)}
:where(html[data-theme]:not([data-theme="default"])) button.btn[data-destructive="true"]:active:not(:disabled){background-color:var(--theme-danger-pressed);color:var(--theme-on-danger);border-color:var(--theme-danger-pressed)}
:where(html[data-theme]:not([data-theme="default"])) button.btn[data-destructive="true"]:disabled{background-color:var(--theme-disabled-bg);color:var(--theme-disabled-fg);border-color:var(--theme-border);opacity:1}
:where(html[data-theme]:not([data-theme="default"])) :is(.fgc-ledger,.cost-changes-tabs){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .cost-friend-chip{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .cost-friend-avatar{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .cost-friend-option:has(input:checked){background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.cost-member-choice input,.cost-history-mine input,.cost-friend-option input){accent-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .cost-modal [aria-invalid=true]{outline-color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) .cost-empty{border-color:var(--theme-border);background:linear-gradient(150deg,var(--theme-subtle),var(--theme-card))}
/* Existing decorative SVG only; never use a global SVG fill/stroke selector. */
:where(html[data-theme]:not([data-theme="default"])) .cost-empty-art>rect{fill:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .cost-empty-art>rect[stroke]{stroke:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .cost-empty-art>rect[fill="#fff"]{fill:var(--theme-card);stroke:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .cost-empty-art>path{stroke:var(--theme-icon)}

/* Shared and activity checklists, birthdays and follow-up reminders. */
:where(html[data-theme]:not([data-theme="default"])) :is(.scl-card,.scl-item,.kit-card,.kit-friend){background-color:var(--theme-card);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .scl-item{border-inline-start-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .scl-done{background-color:var(--theme-subtle);border-inline-start-color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) .scl-item-form{background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .scl-notice{background-color:var(--theme-warning-bg);border-color:var(--theme-warning-fg);color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .scl-notice[role=alert]{background-color:var(--theme-error-bg);border-color:var(--theme-error-fg);color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) .scl-success{color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.gpc-overdue,.idt-due){color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.pac-recovery,.idt-recovery,.kit-recovery){background-color:var(--theme-warning-bg);color:var(--theme-warning-fg);border-color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.idt-error,.kit-error){background-color:var(--theme-error-bg);color:var(--theme-error-fg);border-color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) .idt-tile{background-color:var(--theme-subtle);color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .kit-avatar{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .kit-section:first-of-type .kit-card{border-inline-start-color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .kit-empty>svg{color:var(--theme-icon)}
:where(html[data-theme]:not([data-theme="default"])) .kit-notice{background-color:var(--theme-success-bg);color:var(--theme-success-fg)}

/* Retained friend offers: same palette, no decorative per-card colour assignment. */
:where(html[data-theme]:not([data-theme="default"])) .fo-card{background-color:var(--theme-card);border-color:var(--theme-border);box-shadow:3px 3px 0 var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fo-card:nth-of-type(3n+1),.fo-card:nth-of-type(3n+2),.fo-card.fo-sent){border-block-start-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fo-person-copy small,.fo-empty p,.fo-selection-count,.fo-reply-privacy){color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) .fo-avatar{background-color:var(--theme-selection-bg);border-color:var(--theme-border);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fo-time{background-color:var(--theme-subtle);border-color:var(--theme-border);color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) .fo-chip{background-color:var(--theme-selection-bg);border-color:var(--theme-border);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fo-empty{background-color:var(--theme-subtle);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fo-compose input,.fo-compose textarea,.fo-search input){background-color:var(--theme-input);border-color:var(--theme-control-border);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fo-compose details,.fo-response){border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fo-friend{background-color:var(--theme-card);color:var(--theme-text);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fo-friend[aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .fo-recovery{background-color:var(--theme-warning-bg);color:var(--theme-warning-fg);border-color:var(--theme-warning-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fo-notice{background-color:var(--theme-success-bg);color:var(--theme-success-fg);border-inline-start-color:var(--theme-success-fg)}
:where(html[data-theme]:not([data-theme="default"])) .fo-header #foNew{background-color:var(--theme-primary);color:var(--theme-on-primary);border-color:var(--theme-primary);box-shadow:2px 2px 0 var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) .fo-header #foNew:hover:not(:disabled){background-color:var(--theme-primary-hover);border-color:var(--theme-primary-hover)}
:where(html[data-theme]:not([data-theme="default"])) .fo-header #foNew:active:not(:disabled){background-color:var(--theme-primary-pressed);border-color:var(--theme-primary-pressed)}
:where(html[data-theme]:not([data-theme="default"])) .fo-invitation-mark [fill="#ffe491"]{fill:var(--theme-selection-bg)}

/* Local planning tools. The wheel is existing SVG, not a canvas: CSS updates
 * paint in place during a spin. No listener, redraw, DOM replacement or state change.
 * Option-number backgrounds retain their exact Default value as the var fallback.
 */
:where(html[data-theme]:not([data-theme="default"])) :is(.team-mode,.team-source-panel,.team-group){background-color:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .team-mode>button{color:var(--theme-secondary)}
:where(html[data-theme]:not([data-theme="default"])) .team-mode>button[aria-pressed=true]{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg);border-color:var(--theme-primary);box-shadow:0 2px 5px var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) .team-mode>button:hover:not([aria-pressed=true]){background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) :is(.team-people-list li,.team-choices>label){background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) .team-person-mark{background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .team-remove:hover{background-color:var(--theme-subtle);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) :is(.team-choices input,.team-select-all input){accent-color:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-svg text{fill:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) #wheelRotor>g>path{fill:var(--theme-selection-bg);stroke:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) #wheelRotor>g:nth-child(even)>path{fill:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) #wheelGraphic.is-draft #wheelRotor>g>path{fill:var(--theme-subtle)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-svg>circle{fill:var(--theme-card);stroke:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-svg>path{fill:var(--theme-primary)}
:where(html[data-theme]:not([data-theme="default"])) #wheelPointer{stroke:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-number{color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-icon:hover:not(:disabled){background-color:var(--theme-subtle);color:var(--theme-text)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-starter{background-color:var(--theme-subtle);color:var(--theme-secondary);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) :is(.decision-wheel-starter.food,.decision-wheel-starter.games,.decision-wheel-starter.activities){background-color:var(--theme-subtle);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-starter:hover{filter:none;background-color:var(--theme-card)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-starter:active{filter:none;background-color:var(--theme-selection-bg);color:var(--theme-selection-fg)}
:where(html[data-theme]:not([data-theme="default"])) #wheelSaveEdit{background-color:var(--theme-primary);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) #wheelSaveEdit:hover:not(:disabled){background-color:var(--theme-primary-hover);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) #wheelSaveEdit:active:not(:disabled){background-color:var(--theme-primary-pressed);color:var(--theme-on-primary)}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel-status.has-error{color:var(--theme-error-fg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.decision-wheel button,#teamResultTitle):focus-visible{outline:2px solid var(--theme-primary);outline-offset:2px}
:where(html[data-theme]:not([data-theme="default"])) .decision-wheel input:focus-visible{outline:2px solid var(--theme-primary);outline-offset:2px}

/* Remove legacy opacity from whole disabled fields, controls and text containers.
 * Shared foundation handles native :disabled descendants. These precise overrides
 * cover module rules and aria-disabled controls without dimming unrelated content.
 */
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-modal #fgFields:disabled,.tp-modal #tpFields:disabled,.cost-fields:disabled,.places-suggestion-fields:disabled){opacity:1}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-modal .fg-person-identity .member-username,.cost-changes-tabs .btn>span,.cost-change-actor>bdi+bdi){opacity:1}
:where(html[data-theme]:not([data-theme="default"])) .cost-friend-option:has(input:disabled){opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) #gplUpcomingBody[aria-busy=true] button{opacity:1}
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-peer-button:disabled,.fg-tool-link:disabled,.fg-common-durations button[aria-disabled=true],#friendGroupsRoot[aria-busy=true] button[aria-disabled=true],#friendGroupsRoot[aria-busy=true] input[aria-disabled=true],#groupPlansRoot[aria-busy=true] button[aria-disabled=true],#gplUpcomingBody button:disabled,#gplUpcomingBody button[aria-disabled=true],.gpc-section [aria-disabled=true]){opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fg-tool-link:disabled .fg-tool-icon{color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg)}
:where(html[data-theme]:not([data-theme="default"])) :is(.fg-days button,.fg-common-durations button,.fg-brushes .btn,.fg-paint-tools .btn,.fg-modal .fg-grid-cell,.fg-shared-cell,.fg-apply-day-list .btn,.fg-schedule-switch>button,.ain-kind-choices .btn,.ain-choices>.btn,.gpr-tabs .btn):disabled{opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border)}
:where(html[data-theme]:not([data-theme="default"])) .fo-header #foNew:disabled{opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border);box-shadow:2px 2px 0 var(--theme-shadow)}
:where(html[data-theme]:not([data-theme="default"])) :is(.dm-message.own,.fgc-message.own,.place-message.own) .btn:disabled{color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);opacity:1}
:where(html[data-theme]:not([data-theme="default"])) :is(.decision-wheel button:disabled,#wheelSaveEdit:disabled,.team-mode>button:disabled){opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border)}

/* Explicit module focus rules otherwise outrank shared foundation selectors. */
:where(html[data-theme]:not([data-theme="default"])) :is(.messages-scope-details>summary,.message-contact,.messages-page-actions .btn,.chats-return,.messages-peer-button,.messages-back,.messages-options>summary,.dm-share-link,.owner-chat-modal a,.owner-chat-modal button,.fgc-conversation :focus-visible,.fg-modal :focus-visible,.fg-schedule :focus-visible,.fg-head :focus-visible,.fg-detail-nav :focus-visible,.fg-common-time :focus-visible,.fg-planning :focus-visible,.fg-time-row>summary,.fg-help>summary,.fg-common-people>summary,.fg-common-people :focus-visible,.fg-weekly select,.fg-weekly .btn,.fg-calendar-tools :focus-visible,.fg-group-tools :focus-visible,.fg-shared-cell,.fg-modal .fg-grid-cell,.tp-modal :focus-visible,.gp-refresh,.gpl-upcoming :focus-visible,.gpl-detail :focus-visible,.gpr-card,.gpr-response-group summary,.gpr-options summary,.ain-heading .btn,.ain-card,.ain-options>summary,.ain-more>summary,.ain-kind-choices .btn,.ain-experience-option,.ain-chat-person,.cost-share-action,.cost-share-code>summary,.cost-replace-invite>summary,.cost-friend-chip,.cost-friend-picker>summary,.cost-change-row>summary,.cost-changes-tabs .btn,.cost-changes-link,.cost-list-actions .btn,.gpc-section :focus-visible,.post-activity-checklist :focus-visible,.important-dates button,.important-dates summary,.important-dates input,.important-dates select):focus-visible{outline:2px solid var(--theme-primary);outline-offset:2px}
:where(html[data-theme]:not([data-theme="default"])) :is(.tp-local,.gp-option,.cost-friend-option):focus-within{outline:2px solid var(--theme-primary);outline-offset:2px}
:where(html[data-theme]:not([data-theme="default"])) .cost-modal #costMessage:focus{outline:2px solid var(--theme-primary);outline-offset:2px}

/* Standalone cost report: load shared tokens/prepaint there too. Screen only;
 * preserve existing monochrome print output and every printed layout rule.
 */
@media screen{
  :where(html[data-theme]:not([data-theme="default"])):has(#costExportReport){background-color:var(--theme-page);color:var(--theme-text)}
  :where(html[data-theme]:not([data-theme="default"])) #costExportReport{background-color:var(--theme-card);border-color:var(--theme-border)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand,.export-record,.export-note,.export-shares li,.export-balances li,.export-footer){border-color:var(--theme-border)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-kind,.export-eyebrow,.export-meta,.export-caption,.export-handle,.export-facts dt,.export-choice,.export-empty){color:var(--theme-secondary)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-controls,#costExportFeedback) :is(button,.button){color:var(--theme-on-primary);background-color:var(--theme-primary);border-color:var(--theme-primary)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-controls,#costExportFeedback) :is(button,.button):hover:not(:disabled){background-color:var(--theme-primary-hover);border-color:var(--theme-primary-hover)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-controls,#costExportFeedback) :is(button,.button):active:not(:disabled){background-color:var(--theme-primary-pressed);border-color:var(--theme-primary-pressed)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand,.export-controls,#costExportFeedback) .secondary{color:var(--theme-text);background-color:var(--theme-card);border-color:var(--theme-control-border)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand,.export-controls,#costExportFeedback) .secondary:hover:not(:disabled){color:var(--theme-text);background-color:var(--theme-subtle);border-color:var(--theme-control-border)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand,.export-controls,#costExportFeedback) .secondary:active:not(:disabled){color:var(--theme-selection-fg);background-color:var(--theme-selection-bg);border-color:var(--theme-primary)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand,.export-controls,#costExportFeedback) :is(button,.button):disabled{opacity:1;color:var(--theme-disabled-fg);background-color:var(--theme-disabled-bg);border-color:var(--theme-border)}
  :where(html[data-theme]:not([data-theme="default"])) :is(.export-brand a,.export-brand button,.export-controls button,.export-controls .button,#costExportFeedback button,#costExportFeedback .button):focus-visible{outline:2px solid var(--theme-primary);outline-offset:2px}
}
