/* Palette aliases intentionally override legacy fixed dark/light surfaces. */
html[data-theme],html[data-theme] body{
 --bg-primary:var(--theme-bg)!important;--bg-secondary:var(--theme-surface)!important;--bg-tertiary:var(--theme-field)!important;--bg-hover:var(--theme-hover)!important;--text-primary:var(--theme-text)!important;--text-secondary:var(--theme-muted)!important;--text-muted:var(--theme-dim)!important;--border:var(--theme-border)!important;--accent:var(--theme-accent)!important;--accent-hover:var(--theme-strong)!important;--accent-subtle:var(--theme-tint)!important;--accent-text:var(--theme-accent-text)!important;
 --premium-bg:var(--theme-bg)!important;--premium-surface:var(--theme-field)!important;--premium-surface-strong:var(--theme-hover)!important;--premium-border:var(--theme-border)!important;--premium-border-strong:var(--theme-accent)!important;--premium-text-soft:var(--theme-muted)!important;--premium-accent:var(--theme-accent)!important;
 --bg:var(--theme-bg)!important;--surface:var(--theme-surface)!important;--field:var(--theme-field)!important;--text:var(--theme-text)!important;--muted:var(--theme-muted)!important;--subtle:var(--theme-tint)!important;
 color-scheme:dark;background-color:var(--theme-bg);color:var(--theme-text);
}
html[data-theme-mode=light],html[data-theme-mode=light] body{color-scheme:light}
html[data-theme] body{background:radial-gradient(ellipse at 85% -15%,color-mix(in srgb,var(--theme-glow) 12%,transparent),transparent 48%),var(--theme-bg)!important}
html[data-theme] body :is(.app-container,.main,.messages-container,.admin-page,.admin-main,.admin-content,.profile-page){background:transparent!important}
html[data-theme] body :is(.sidebar,.admin-sidebar){background:linear-gradient(160deg,color-mix(in srgb,var(--theme-surface) 94%,var(--theme-glow)),var(--theme-surface) 60%)!important;border-color:var(--theme-border)!important}
html[data-theme] body :is(.sidebar-header,.sidebar-footer,.chat-header,.mobile-toolbar,.admin-header){background:color-mix(in srgb,var(--theme-surface) 94%,transparent)!important;border-color:var(--theme-border)!important}
html[data-theme] body :is(.user-info,.admin-section,.admin-form,.profile-section,.knowledge-card,.order-card,.control-card,.plugin-panel,.login-box,.modal-content,.uif-dialog-card){background:var(--theme-surface)!important;border-color:var(--theme-border)!important;box-shadow:0 12px 38px color-mix(in srgb,var(--theme-bg) 28%,transparent)!important}
html[data-theme] body :is(.agent-info h3,.user-name,.logo-text h1,.current-agent h2,.admin-section-title,.modal-title){color:var(--theme-text)!important}
html[data-theme] body :is(.agent-info p,.user-role,.section-title,.logo-text span,.current-agent #currentAgentDesc){color:var(--theme-muted)!important}
html[data-theme] body :is(.agent-emoji,.current-agent .emoji,.user-avatar,.logo-icon){background:var(--theme-tint)!important;border-color:var(--theme-border)!important;color:var(--theme-accent)!important}
html[data-theme] body .agent-card.active{background:linear-gradient(120deg,var(--theme-tint),color-mix(in srgb,var(--theme-surface) 92%,var(--theme-accent)))!important;border-color:color-mix(in srgb,var(--theme-accent) 48%,var(--theme-border))!important;box-shadow:inset 3px 0 0 var(--theme-accent),0 8px 20px #0000000a!important}
html[data-theme] body .agent-card:hover{background:var(--theme-field)!important;border-color:var(--theme-border)!important}
html[data-theme] body :is(.sidebar-btn,.clear-btn,.action-btn,.hamburger-btn,.admin-back-btn){background:var(--theme-field)!important;color:var(--theme-muted)!important;border-color:var(--theme-border)!important}
html[data-theme] body :is(.sidebar-btn,.clear-btn,.action-btn,.admin-back-btn):hover{background:var(--theme-hover)!important;color:var(--theme-text)!important;border-color:var(--theme-accent)!important}
html[data-theme] body .sidebar-btn.admin-btn{background:var(--theme-tint)!important;color:var(--theme-accent)!important;border-color:color-mix(in srgb,var(--theme-accent) 38%,var(--theme-border))!important}
html[data-theme] body .input-area{background:linear-gradient(0deg,var(--theme-bg) 85%,color-mix(in srgb,var(--theme-bg) 92%,transparent))!important;border-color:var(--theme-border)!important}
html[data-theme] body :is(.input-container,.input-wrapper .input-container,.form-input){background:var(--theme-field)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
html[data-theme] body #messageInput{background:transparent!important;color:var(--theme-text)!important}
html[data-theme] body #messageInput::placeholder{color:var(--theme-dim)!important}
html[data-theme] body :is(.attach-btn,.input-area .composer-hint,.liv-branding){color:var(--theme-muted)!important}
html[data-theme] body :is(.message.agent,.typing-indicator){background:transparent!important;color:var(--theme-text)!important}
html[data-theme] body .message.user{background:var(--theme-user)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important;box-shadow:0 4px 18px #00000005!important}
html[data-theme] body :is(.send-btn,.login-btn,.btn-save,.theme-picker .primary){background:var(--theme-strong)!important;color:var(--theme-on-accent)!important;border-color:var(--theme-strong)!important}
html[data-theme] body .conversation-tab[aria-selected=true]{background:var(--theme-tint)!important;border-color:color-mix(in srgb,var(--theme-accent) 45%,var(--theme-border))!important;color:var(--theme-text)!important}
html[data-theme] body .conversation-tab[aria-selected=true]::after{background:var(--theme-accent)}
html[data-theme] body :is(.plugin-menu,.archive-panel,.recurring-panel){background:var(--theme-surface)!important;border-color:var(--theme-border)!important}
html[data-theme] body .plugin-menu-item{color:var(--theme-text)!important}
html[data-theme] body .plugin-menu-item:hover{background:var(--theme-tint)!important}
html[data-theme] body :is(.message-code-block,.message-code-header,.message.agent table,.message.agent blockquote){border-color:var(--theme-border)!important}
html[data-theme] body .message-code-block{background:var(--theme-field)!important}
html[data-theme] body .message-code-header{background:var(--theme-surface)!important;color:var(--theme-muted)!important}
html[data-theme] body .message-code-block pre code{background:transparent!important;color:var(--theme-text)!important}
html[data-theme] body .liv-branding{background:transparent!important}
html[data-theme] body .theme-picker{color:var(--theme-text);background:var(--theme-surface);border:1px solid var(--theme-border);border-radius:24px;padding:26px;width:min(580px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;margin:auto;box-shadow:0 32px 100px #0005}
.theme-picker::backdrop{background:#050a1280;backdrop-filter:blur(8px)}.theme-picker-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.theme-picker-heading h2{font:550 20px/1.35 Inter,-apple-system,sans-serif;letter-spacing:-.035em;margin:0!important}.theme-picker button.theme-picker-close{min-width:36px;width:36px;height:36px;min-height:36px;border:1px solid var(--theme-border);background:var(--theme-field);color:var(--theme-muted);border-radius:10px;padding:0;font-size:22px;display:inline-flex;align-items:center;justify-content:center}.theme-picker-intro{font-size:12px;color:var(--theme-muted);line-height:1.7;margin:12px 0 20px!important}.theme-options{display:grid;grid-template-columns:1fr 1fr;gap:12px}.theme-picker button.theme-option{display:flex;flex-direction:column;align-items:stretch;text-align:left;gap:0;width:100%;min-width:0;min-height:44px;padding:9px;border:1px solid var(--theme-border);border-radius:14px;background:var(--theme-field);color:var(--theme-text);font-family:inherit;cursor:pointer;position:relative}.theme-option[aria-pressed=true]{outline:2px solid var(--theme-accent);outline-offset:1px}.theme-option[aria-pressed=true]::after{content:'✓';position:absolute;right:17px;top:16px;background:var(--preview-accent);color:var(--preview-bg);border-radius:50%;width:20px;height:20px;font:600 12px/20px sans-serif;text-align:center}.theme-option strong{font-size:12px;font-weight:550;margin:10px 3px 2px}.theme-option small{font-size:10px;color:var(--theme-muted);margin:0 3px 3px;line-height:1.5}.theme-preview{display:flex;height:80px;border-radius:8px;overflow:hidden;background:var(--preview-bg);border:1px solid var(--preview-border)}.theme-preview-rail{width:25%;padding:15px 8px;background:var(--preview-surface);border-right:1px solid var(--preview-border);display:flex;flex-direction:column;gap:9px}.theme-preview-rail i{height:4px;border-radius:2px;background:var(--preview-border)}.theme-preview-rail i:first-child{background:var(--preview-accent)}.theme-preview-pane{padding:15px 13px;flex:1;display:flex;flex-direction:column;gap:7px}.theme-preview-pane i{height:4px;border-radius:2px;width:90%;background:var(--preview-text);opacity:.35}.theme-preview-pane i:first-child{height:13px;background:var(--preview-user);opacity:1;width:65%;align-self:flex-end;margin-bottom:2px}.theme-preview-pane i:last-child{width:55%}.theme-picker button:focus-visible{outline:2px solid var(--theme-accent);outline-offset:3px}
@media(max-width:420px){html[data-theme] body .theme-picker{padding:18px;border-radius:20px}.theme-options{gap:10px}.theme-preview{height:68px}.theme-option small{font-size:10px}.theme-picker-heading h2{font-size:18px}}
/* Keep branded accents and code contrast coherent on warm and cool palettes. */
html[data-theme],html[data-theme] body{--soft:var(--theme-tint)!important;--control-accent:var(--theme-accent)!important}
html[data-theme] body #loginPage{background:radial-gradient(ellipse at 22% 36%,color-mix(in srgb,var(--theme-glow) 14%,transparent),transparent 55%),var(--theme-bg)}
html[data-theme] body :is(.login-eyebrow,.promotion-cta,.promotion-mark){color:var(--theme-accent)!important}
html[data-theme] body .login-welcome h2 span:last-child{background:linear-gradient(100deg,var(--theme-accent),color-mix(in srgb,var(--theme-accent) 78%,var(--theme-text)));background-clip:text;-webkit-background-clip:text;color:transparent}
html[data-theme] body .login-eyebrow::before{background:var(--theme-accent);box-shadow:0 0 16px color-mix(in srgb,var(--theme-accent) 40%,transparent)}
html[data-theme] body #sidebar .sidebar-footer .sidebar-logout-btn:hover{color:var(--error)!important;border-color:var(--error)!important;background:color-mix(in srgb,var(--error) 6%,var(--theme-field))!important}
html[data-theme-mode=light] :is(.erpcode-keyword,.sql-keyword){color:#6535a3!important}
html[data-theme-mode=light] :is(.erpcode-type,.sql-type){color:#1d657d!important}
html[data-theme-mode=light] :is(.erpcode-string,.sql-string){color:#287344!important}
html[data-theme-mode=light] :is(.erpcode-comment,.sql-comment){color:#59675e!important}
html[data-theme-mode=light] :is(.erpcode-number,.sql-number){color:#99522c!important}
html[data-theme-mode=light] :is(.erpcode-function,.sql-function){color:#256f65!important}
html[data-theme-mode=light] :is(.erpcode-system,.sql-variable){color:#963466!important}
html[data-theme-mode=light] :is(.erpcode-field,.sql-identifier){color:#345f91!important}
html[data-theme-mode=light] :is(.erpcode-operator,.sql-operator){color:#53627a!important}

html[data-theme] body .login-benefits span::before{color:var(--theme-accent)}
html[data-theme] body .connection-status.connected{color:var(--success)!important;background:color-mix(in srgb,var(--success) 10%,var(--theme-surface))!important;border-color:color-mix(in srgb,var(--success) 30%,var(--theme-border))!important}
