/* Only message rows become edge-to-edge. Other pages retain their own gutters. */
body[data-screen="hub"][data-section-view="chat"]:not([data-space-ui="true"]) .hub-content:has(>.conversation-list){--message-gutter:18px;padding-inline:0}
body[data-screen="hub"][data-section-view="chat"] .conversation-list .conversation-row{padding-inline:calc(var(--message-gutter,18px) + 2px)}
@media(max-width:360px){body[data-screen="hub"][data-section-view="chat"]:not([data-space-ui="true"]) .hub-content:has(>.conversation-list){--message-gutter:13px}}

html[data-device-theme="on"]{--home-bg:var(--device-bg);--home-panel:var(--device-panel);--home-soft:var(--device-soft);--home-text:var(--device-ink);--home-muted:var(--device-muted);--home-accent:var(--device-accent-text);--home-line:var(--device-line);color-scheme:normal;color:var(--device-ink);background:var(--device-bg)}
html[data-device-theme="on"] body{background:var(--device-bg);color:var(--device-ink)}
html[data-device-theme="on"] :is(.shell,.hub,.hub-header,.hub-content,.hub-tabs){background-color:var(--device-bg);color:var(--device-ink)}
html[data-device-theme="on"] :is(.hub-header h1,.hub-self-name,.plain-icon,.hub-tabs button,.profile-tools button,.conversation-row){color:var(--device-ink)}
html[data-device-theme="on"] body[data-section-view="chat"] :is(.hub-search-wrap,.hub-header){background:var(--device-bg)}
html[data-device-theme="on"] :is(#hub-more,.conversation-copy strong){color:var(--device-ink)}
html[data-device-theme="on"] .hub-tabs button[aria-current="page"]{color:var(--device-accent-text)}
html[data-device-theme="on"] :is(.profile-summary,.section-card,.quota-item,.hub-search-wrap input,.app-sidebar,.gate-card,.pair-review,.history-dialog,.trace-dialog,.characters-dialog,.schedule-item-card,.finance-card){background:var(--device-panel);color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] :is(.app-sidebar button,.profile-tools button,.chat-settings-row){background:transparent;color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] :is(.pair-review>header,.history-dialog>header,.pair-content,.chat-settings-identity,.chat-settings-list,.history-reader-actions,.history-result){background:var(--device-panel);color:var(--device-panel-ink)}
html[data-device-theme="on"] :is(.pair-back,.pair-content h3,.pair-content strong,.chat-settings-row>span,.appearance-editor,.avatar-settings){color:var(--device-panel-ink)}
html[data-device-theme="on"] :is(.hub-state,.conversation-copy small,.conversation-meta,.quota-item span:last-child,.profile-summary p,.profile-tools button small,.pair-content p,.pair-content small,.chat-settings-row small,.app-sidebar header small,.app-sidebar>p){color:var(--device-muted)}
html[data-device-theme="on"] :is(.conversation-row.is-pinned,.quota-item){background:var(--device-soft)}
html[data-device-theme="on"] :is(.app-sidebar button[aria-current="page"],.app-sidebar button[aria-pressed="true"]){background:var(--device-soft);color:var(--device-accent-text)}
html[data-device-theme="on"] :is(.hub-search-wrap input,.pair-review input,.pair-review select,.history-dialog input,.history-dialog select){background:var(--device-bg);color:var(--device-ink);border-color:var(--device-line)}
html[data-device-theme="on"] :is(.appearance-reset-actions button,.bubble-theme-actions button){background:var(--device-soft);color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] :is(.app-sidebar,.hub-tabs,.profile-tools button,.conversation-row){border-color:var(--device-line)}
html[data-device-theme="on"] :is(.finance-summary article,.finance-form,.schedule-entry-editor,.schedule-add-form,.calendar-marks,.calendar-mark){background:var(--device-panel);color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] :is(.finance-nav button,.schedule-perspective,.schedule-date-trigger){background:var(--device-soft);color:var(--device-panel-ink)}
html[data-device-theme="on"] :is(.finance-nav button[data-active="true"],.finance-summary article.is-primary,.finance-primary,.schedule-add-form button,.schedule-entry-editor button){background:var(--device-accent);color:var(--device-button-ink);border-color:var(--device-accent)}
html[data-device-theme="on"] :is(.finance-card-title,.finance-change>small,.schedule-empty,.schedule-item-card small){color:var(--device-muted)}
html[data-device-theme="on"] :is(.finance-form input,.finance-form select,.finance-form textarea,.schedule-add-form input,.schedule-entry-editor input,.schedule-entry-editor textarea){background:var(--device-bg);color:var(--device-ink);border-color:var(--device-line)}
/* An existing space cover/wallpaper remains independent. Theme fills unpictured surfaces. */
html[data-device-theme="on"] body[data-space-ui="true"] .hub:not([data-space-wallpaper="true"]) :is(#home-space,.qs-post,.qs-page-head,.qs-categories,.qs-space-nav,.space-counts,.space-stream-title){background-color:var(--device-bg);color:var(--device-ink)}
html[data-device-theme="on"] #home-space :is(.qs-muted,.qs-time,.qs-text-muted){color:var(--device-muted)}

/* Conversation tokens live on its shell, never overwrite either custom bubble. */
body[data-screen="conversation"] .shell[data-device-chat-theme="on"]{--chat-ink:var(--device-ink);--chat-muted:var(--device-muted);--chat-panel:var(--device-panel);--chat-accent:var(--device-accent);background-color:var(--device-bg)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] :is(.topbar,#chat){background-color:var(--device-bg);color:var(--device-ink)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] :is(.composer,.composer-box){background:var(--device-bg);color:var(--device-ink)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] :is(.composer textarea,.composer .model-panel,.session-actions,.model-dialog){background:var(--device-panel);color:var(--device-panel-ink);border-color:var(--device-line)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] :is(.conversation-back,.plain-icon,.model-label,.composer-plus,.composer p,.context-ring,.process-summary,.autonomy-heart,.empty,.room-status,.time-divider,.free-activity-record){color:var(--device-ink)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] #send{background:var(--device-accent);color:var(--device-button-ink)}
body[data-screen="conversation"] .shell[data-device-chat-theme="on"] .context-ring::after{background:var(--device-bg)}
:is(#chat,.bubble-theme-preview)[data-device-chat-theme="on"][data-bubble="default"][data-other-bubble="default"] .message:not(.me) .bubble{background:var(--device-other);color:var(--device-other-ink);--bubble-surface:var(--device-other)}
:is(#chat,.bubble-theme-preview)[data-device-chat-theme="on"][data-bubble="default"][data-mine-bubble="default"] .message.me .bubble{background:var(--device-mine);color:var(--device-mine-ink);--bubble-surface:var(--device-mine)}
#chat[data-device-chat-theme="on"] .message:has(.process-summary):not(:has(.message-markdown)) .bubble{background:transparent;box-shadow:none}

.device-theme-editor{display:grid;gap:14px;padding:16px;border-radius:16px;background:var(--device-panel,var(--home-panel,#fff));color:var(--device-panel-ink,#282b31);border:1px solid var(--device-line,#dbe1ea);min-width:0}
.device-theme-editor h3,.device-theme-editor p{margin:0}.device-theme-editor h3{font-size:16px}.device-theme-editor p{font-size:12px;line-height:1.65;color:inherit}
.device-theme-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.device-theme-fields label{display:grid;gap:6px;font-size:13px;min-width:0}.device-theme-fields label[hidden]{display:none}
.device-theme-fields input,.device-theme-fields select{width:100%;min-width:0;min-height:44px;font:inherit;padding:10px;border:1px solid var(--device-line,#dbe1ea);border-radius:10px;background:var(--device-bg,#f2f5fc);color:var(--device-ink,#282b31)}
.device-theme-sample{display:grid;gap:10px;padding:14px;border-radius:12px;background:var(--device-bg);color:var(--device-ink)}.device-theme-sample[hidden]{display:none}.device-theme-sample span{padding:10px;border-radius:10px;background:var(--device-panel);color:var(--device-panel-ink)}.device-theme-sample span:nth-child(2){background:var(--device-other);color:var(--device-other-ink)}.device-theme-sample span:nth-child(3){justify-self:end;background:var(--device-mine);color:var(--device-mine-ink)}
.device-theme-sample button{background:var(--device-accent);color:var(--device-button-ink);border:0;border-radius:10px;padding:10px;opacity:1}
.device-theme-actions{display:flex;flex-wrap:wrap;gap:8px}.device-theme-actions button{min-height:44px;padding:10px 13px;border:1px solid var(--device-line,#dbe1ea);border-radius:10px;font:inherit;background:var(--device-soft,#edf1f7);color:var(--device-panel-ink,#282b31)}.device-theme-actions .device-theme-save{background:var(--device-accent,#159ee8);color:var(--device-button-ink,#fff);border:0}.device-theme-status{min-height:20px}
.device-theme-mask{display:grid;grid-template-columns:1fr auto;gap:8px;font-size:13px}.device-theme-mask input{grid-column:1/-1;width:100%;min-height:44px;accent-color:var(--device-accent,#159ee8)}.device-theme-mask small{grid-column:1/-1;font-size:11px;line-height:1.7}.device-theme-mask[hidden]{display:none}
/* Small labels stay readable over the unmodified image; no full-image veil. */
body[data-screen="conversation"] .shell[data-background="image"] :is(.topbar h1,.topbar button,.service-state,.time-divider,.free-activity-record,.process-summary){color:#20252b;text-shadow:1px 0 1px #fff,-1px 0 1px #fff,0 1px 1px #fff,0 -1px 1px #fff}
@media(max-width:350px){.device-theme-fields{grid-template-columns:minmax(0,1fr)}}
/* One color fade on each independent canvas; never stack a white veil on descendants. */
html[data-device-wallpaper="on"] body[data-screen="hub"] .shell,
html[data-device-wallpaper="on"] .app-sidebar{background-color:var(--device-bg);background-image:linear-gradient(color-mix(in srgb,var(--device-bg) calc(var(--device-wallpaper-fade,0) * 100%),transparent),color-mix(in srgb,var(--device-bg) calc(var(--device-wallpaper-fade,0) * 100%),transparent)),var(--device-wallpaper-image)!important;background-size:cover;background-position:center}
html[data-device-wallpaper="on"] body[data-screen="hub"] :is(.hub,.hub-content,.hub-header,.hub-search-wrap,.hub-tabs){background-color:transparent}
html[data-device-wallpaper="on"] body[data-screen="hub"] :is(.hub-header h1,.hub-self-name,.conversation-copy strong,.conversation-copy small,.conversation-meta,.plain-icon){text-shadow:1px 0 1px #fff,-1px 0 1px #fff,0 1px 1px #fff,0 -1px 1px #fff}
body[data-screen="conversation"] .shell[data-device-chat-wallpaper="on"] :is(.topbar,#chat){background-color:transparent;background-image:none!important}
.device-theme-global-image{display:grid;gap:10px;min-width:0;font-size:13px}.device-theme-global-image select,.device-theme-global-image input{max-width:100%;min-width:0;min-height:44px;font:inherit}.device-theme-global-image select{border:1px solid var(--device-line,#dbe1ea);border-radius:10px;padding:9px;background:var(--device-bg,#f2f5fc);color:var(--device-ink,#282b31)}.device-theme-global-image small{font-size:11px;line-height:1.7}.device-theme-global-image img{width:100%;max-height:180px;object-fit:contain;border-radius:12px}.device-theme-global-image img[hidden]{display:none}

/* State selectors and nested schedule surfaces must win over their legacy colors. */
html[data-device-theme="on"] .schedule-preview :is(.schedule-item-card,.schedule-entry-editor,.schedule-add-form){background:var(--device-panel);color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] .schedule-preview :is(.schedule-item-note,.schedule-item-created-by,.calendar-mark,.schedule-entry-actions button,.calendar-mark-form button,.schedule-add){background:var(--device-soft);color:var(--device-panel-ink);border-color:var(--device-line)}
html[data-device-theme="on"] .schedule-preview :is(.schedule-item-heading strong,.schedule-item-owner,.schedule-item-note small){color:var(--device-panel-ink)}
html[data-device-theme="on"] .schedule-preview :is(.schedule-item>time,.schedule-item-detail,.schedule-note-by,.schedule-owner-avatar,.schedule-item-avatar,.calendar-mark-delete,.schedule-perspective){color:var(--device-muted)}
html[data-device-theme="on"] .schedule-preview .schedule-preview-note{color:var(--device-muted)!important}
html[data-device-theme="on"] .schedule-preview :is(.calendar-mark-form input,.schedule-entry-editor input,.schedule-entry-editor textarea,.schedule-add-form input){background:var(--device-bg);color:var(--device-ink);border-color:var(--device-line);color-scheme:var(--device-controls-scheme,light)}
html[data-device-theme="on"] .schedule-preview :is(.schedule-perspective,.schedule-date-trigger,.calendar-marks){background:transparent}
html[data-device-theme="on"] .schedule-preview :is(.schedule-note-toggle,.schedule-date-trigger>span,.schedule-perspective[aria-pressed="true"]){color:var(--device-accent-text)}
html[data-device-theme="on"] .schedule-preview .schedule-perspective[aria-pressed="true"] .schedule-owner-avatar{border-color:var(--device-accent);box-shadow:0 0 0 3px var(--device-soft)}
html[data-device-theme="on"] .schedule-preview .schedule-rail::before{background:var(--device-line)}
html[data-device-theme="on"] .schedule-preview .schedule-rail::after{background:var(--device-panel);border-color:var(--device-muted)}
html[data-device-theme="on"] .schedule-preview .schedule-item.active .schedule-rail::after{border-color:var(--device-accent);box-shadow:0 0 0 3px var(--device-soft)}
html[data-device-theme="on"] .schedule-preview .schedule-item.done .schedule-rail::after{background:var(--device-accent);border-color:var(--device-accent)}
/* Keep controls readable without covering the wallpaper in large opaque panels. */
html[data-device-wallpaper="on"]{--device-wallpaper-label-shadow:1px 0 1px var(--device-bg),-1px 0 1px var(--device-bg),0 1px 1px var(--device-bg),0 -1px 1px var(--device-bg)}
html[data-device-wallpaper="on"] .app-sidebar :is(header,nav,.sidebar-home-mark){background:transparent;color:var(--device-panel-ink);text-shadow:var(--device-wallpaper-label-shadow)}
html[data-device-wallpaper="on"] .app-sidebar .sidebar-theme-toggle,
html[data-device-wallpaper="on"] .app-sidebar>p{background:var(--device-panel);color:var(--device-panel-ink);border-radius:15px}
html[data-device-wallpaper="on"] .app-sidebar>p{padding:8px}
html[data-device-wallpaper="on"] .schedule-preview :is(.schedule-date-trigger,.schedule-perspective>span:last-child,.schedule-item>time,.schedule-item-card){background:transparent;color:var(--device-panel-ink);text-shadow:var(--device-wallpaper-label-shadow)}
html[data-device-wallpaper="on"] .schedule-preview .schedule-item-card{box-shadow:none}
html[data-device-wallpaper="on"] .schedule-preview .schedule-item-card :is(.schedule-item-heading strong,.schedule-item-owner,.schedule-item-detail,.schedule-note-by){color:var(--device-panel-ink)}
html[data-device-wallpaper="on"] .schedule-preview :is(button:not(.schedule-date-trigger),input,textarea,.schedule-item-note){text-shadow:none}
html[data-device-wallpaper="on"] .schedule-preview :is(.schedule-empty,.schedule-preview-note){background:var(--device-panel);color:var(--device-panel-ink);border-radius:6px}
html[data-device-wallpaper="on"] .schedule-preview .schedule-item>time{align-self:start;margin-top:10px;padding:3px 0}
